IDR Cash Api

# Code Example

  • The code example is for reference only, please refer to request parameter description for specific parameter description
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.TreeMap;
public class TopPayDemo {
  private static final String MCH_ID = "S820211021094748000001";  // merchant code
  private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB";  // platform public key
  private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp";  // merchant private key
  private static final String cashUrl = "https://id-openapi.toppay.asia/gateway/cash";
  private static final String cashNotify = "http://host:port/notify";

  public static void main(String[] args) throws Exception {
    cash();
  }
  private static void cash() throws Exception {
    Map<String, String> requestParams = new TreeMap<>();
    requestParams.put("merchantCode", MCH_ID);
    requestParams.put("orderNum", "186888188666");
    requestParams.put("method", "Transfer");
    requestParams.put("orderType", "0");
    requestParams.put("money", "125");
    requestParams.put("feeType", "0");
    requestParams.put("dateTime", "20200101235959");
    requestParams.put("number", "2021071209403321313122");
    requestParams.put("bankCode", "014");
    requestParams.put("name", "test cash name");
    requestParams.put("mobile", "082122965511");
    requestParams.put("email", "[email protected]");
    requestParams.put("description", "test cash");
    requestParams.put("notifyUrl", cashNotify);
    StringBuilder stringBuilder = new StringBuilder();
    for (String key : requestParams.keySet()) {
      stringBuilder.append(requestParams.get(key));
    }

    String keyStr = stringBuilder.toString();
    System.out.println("keyStr:" + keyStr);
    String signedStr = TopPayRequestUtil.privateEncrypt(keyStr, TopPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY));
    requestParams.put("sign", signedStr);

    String postJson = new Gson().toJson(requestParams);
    System.out.println("Post Json Params:" + postJson);

    String responseJson = TopPayRequestUtil.doPost(cashUrl, postJson);
    System.out.println("Response Msg:" + responseJson);

    boolean pass = TopPayRequestUtil.verifySign(new Gson().fromJson(responseJson, JsonObject.class), PLAT_PUBLIC_KEY);
    if (pass) {
      // ... do something
    } else {
      // ... do something
    }
  }
}

<?php
// platform public key, from Secret key config
$platPublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiaKBgQCcEUIvQ/5L+SWbHOeR8VFeZvLbUk7V7OeEAQlQwIVLSZMTef3KtsOKKAsUYPf/aAcKRzZZXECODsPQiDPcdZvM/rFkgrFWkR7lPjTj5SiPxGaiK2Z2sne7A8aDF7fV/D7lfmEwNdZ7FWKVEB84/81BHnlGUwb5HpRTISG+boSO6wIDAQAB';
// mchchant private key
$mchPrivateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMigm7rtWnTeNagwFzGTH+Uw1ypbiy7VhIoFJbgSYSSHdCaXWdT/l2+2fQlEYgAETVZ/IXB29MCnrf3O0dwRFXiipIbsm5zyqSLiS6cKXe8zN1/PlQWUbEt5wyWm0GADB/4bV6eu6gA7sGXmjQqrzfKZkcie3aK7+7ry1NFxTI51AgMBAAECgYEAklqXQAVlt1tiSQ7L3J425jp6u6uMHN4lkYmvuleuBbfKQ1yla3wIPLYjAF+iHeEFidOz0Rb19JRdmIkHDkJoJg2W27LvO6RdUwzgRnsuA3OuNz97w08B3aXXbPmB91nTFjKSlUsbh3IQWP71noxW+iKn844EW5hC5Gvn4L3quAECQQDrz1r0VKIbBSBB2aLuz1XyD/TBT2aRhvOKf0XtTRiQhNjtJxoQmvNbbhvUwj8an7HyCuihAbdbrC2ymFFyOSDZAkEA2c4Yudi48C6COrroi1cWgPlEFeGJXP/V1k5loZ1n2vstYAGPhAB4wUnFBLDvMqaBzWJt7MRkiazT8KnBQCDY/QJAMXpNlEyZwt+deBOpO0BnwSWV7mWxmMFfImU4D+WITPbC7aexsWBBxaJh1o93XCe715RwYTAR//stj3akSDoyaQJAa4FKuxC51/Nc3Fg9R+modeiTLqmv/3NXvPvdNjRXesLX1rduex0wfVdII9ShfEKrdxDKaT9W0NyzD+r6NAkCkQJBAMAnTgPYf0f7rh417GdoP7R7Nwi8KBKwPHlmfRukibOQlKt9xjqpsKJwglLn8pcnXbYbswXIdqzuBvIGAe3OWNg=';

// merchent ID from idntask, from User info
$merchantCode = 'YOUR MERCHANT ID';
// Merchant system unique order number
$orderNum = 'T'.date("YmdHis",time());
// Payment method 
$method = 'Transfer';
$orderType = '0';
$money = '20000';
$feeType = '1';
$dateTime = date("YmdHis",time());
$number = '123456';
$bankCode = '014';
// Display name on bank confirmation display
$name = 'Neo';
// Customer's mobile number(Beginning with 08)
$mobile = '082112345678';
// Customer's email address
$email = '[email protected]';
// The virtual account description
$description = 'Test Withdraw';
// url for callback
$notifyUrl = 'http://example.com/callback';
$params = array(
  'merchantCode' => $merchantCode,
  'orderType' => $orderType,
  'method' => $method,
  'orderNum' => $orderNum,
  'money' => $money,
  'feeType' => $feeType,
  'dateTime' => $dateTime,
  'number' => $number,
  'bankCode' => $bankCode,
  'name' => $name,
  'mobile' => $mobile,
  'email' => $email,
  'notifyUrl' => $notifyUrl,
  'description' => $description
);

ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
  $params_str = $params_str . $val;
}

$sign = pivate_key_encrypt($params_str, $mchPrivateKey);
$params['sign'] = $sign;
$params_string = json_encode($params);
$url = 'https://id-openapi.toppay.asia/gateway/cash';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json',
  'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if($httpCode == 200)
{
  $result = json_decode($request, true);
  echo "platRespCode :". $result['platRespCode'] . "\n";
  echo "platRespMessage :". $result['platRespMessage'] . "\n";
  echo "platOrderNum :". $result['platOrderNum'] . "\n";
  echo "orderNum :". $result['orderNum'] . "\n";
  echo "status :". $result['status'] . "\n";
  echo "statusMsg :". $result['statusMsg'] . "\n";
  echo "money :". $result['money'] . "\n";
  echo "fee :". $result['fee'] . "\n";
  echo "feeType :". $result['feeType'] . "\n";
  echo "bankCode :". $result['bankCode'] . "\n";
  echo "number :". $result['number'] . "\n";
  echo "name :". $result['name'] . "\n";
  echo "description :". $result['description'] . "\n";
  echo "platSign :". $result['platSign'] . "\n";

  $decryptStr = public_key_decrypt($result['platSign'], $platPublicKey);
  echo "decryptStr :". $decryptStr . "\n";
}
else {
  echo $httpCode;
}

function pivate_key_encrypt($data, $pivate_key)
{
  $pivate_key = '-----BEGIN PRIVATE KEY-----'."\n".$pivate_key."\n".'-----END PRIVATE KEY-----';
  $pi_key = openssl_pkey_get_private($pivate_key);
  $crypto = '';
  foreach (str_split($data, 117) as $chunk) {
    openssl_private_encrypt($chunk, $encryptData, $pi_key);
    $crypto .= $encryptData;
  }
  return base64_encode($crypto);
}

function public_key_decrypt($data, $public_key)
{
  $public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
  $data = base64_decode($data);
  $pu_key =  openssl_pkey_get_public($public_key);
  $crypto = '';
  foreach (str_split($data, 128) as $chunk) {
    openssl_public_decrypt($chunk, $decryptData, $pu_key);
    $crypto .= $decryptData;
  }
  return $crypto;
}
No examples yet
No examples yet
No examples yet
No examples yet

# Request Address

  • Request method: POST
  • Request address: https://id-openapi.toppay.asia/gateway/cash

# Request parameters

Note: Do not fill in Chinese in all parameters! ! !

Param Type Required Remark Example
merchantCode String Y merchant ID,Get it in Merchant Platform-Personal Center-Personal Information S820211021094748000001
orderType string(10) Y order type 0-Fiat Currency (Indonesian Rupiah) Transaction
method string(10) Y payment method Transfer
orderNum String Y merchant orer number 10000001
money String Y amount (Decimal point is not supported, please do not pass decimals) 150000
feeType String Y fee type
0:deduction in order
1:deduction out order
0
bankCode String Y bank code View supported bank codes
number String Y bank number 12312431241
name String Y name Jack
mobile String Y mobile(Beginning with 08) 081234567890
email String Y email [email protected]
notifyUrl String Y notify url https://123123.com
dateTime String N Timestamp (format:yyyyMMddHHmmss) 20200101235959
description String N description 代付下单
sign String Y sign Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqvqbc3dFevgS9jt

# Request example

{
  "merchantCode": "S820211021094748000001",
  "orderType": "0",
  "method": "Transfer",
  "orderNum": "186888188666",
  "money": "50000",
  "feeType": "1",
  "bankCode": "014",
  "number": "2021071209403321313122",
  "name": "test cash name",
  "mobile": "081234567890",
  "email": "[email protected]",
  "notifyUrl": "your notify url",
  "dateTime": "2021-07-12 09:41:00",
  "description": "test cash",
  "sign": "Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqwH77qRXI1J+jElOBpa"
}

# Response parameters

Parameters Type Required Description Example
platRespCode String Y response code FAIL\SUCCESS
platRespMessage String Y response message FAIL\SUCCESS
platOrderNum String Y platform order number PI1453242857400963072
orderNum String Y merchant order number 23645782
status int Y order status View order status description
statusMsg String Y order status info Apply
money String Y amount 150000
fee String Y fee 12
feeType String Y fee type
0:deduction in order
1:deduction out order
1
bankCode String N bank code View supported bank codes
number String Y bank number 12312431241
name String Y name Jack
description String Y description cash
platSign String Y sign PI1453242857400963072

# Response example

{
  "platRespCode": "SUCCESS",
  "platRespMessage": "Request success",
  "platOrderNum": "W0620220119174331000001",
  "orderNum": "186888188666",
  "status": 0,
  "statusMsg": "Apply",
  "money": "50000",
  "fee": "7",
  "feeType": "0",
  "bankCode": "014",
  "number": "2021071209403321313122",
  "name": "test cash name",
  "description": "test cash",
  "platSign": "E5uNF7B9NXyhtlRo2I7/KVHN4Sbz0c3VbwCLpH3vjUpv6Cai+bmJA/Q8dVE2RJRe1+dsbzg=="
}

# Cash api callback notify

  • When performing signature verification, you must use the platform public key provided in Merchant Backstage-Receipt and Payment Configuration-API Configuration to decrypt! ! !
  • When verifying the signature, the actual callback parameters shall prevail. Do not verify the fixed parameters.
  • The final status of the order is subject to the status of the notification! ! !
  • After TopPay results are notified asynchronously, the SUCCESS string must be responded to, without quotation marks, and not in Json format. Otherwise TopPay will continue to initiate 5 notifications to the downstream.

# Notify Params

Parameters Description Example
platOrderNum platform order number BK_1563278763273
orderNum merchant order number T1231511321515
money amount 100000
feeType fee type
0:deduction in order
1:deduction out order
1
fee fee 500
name name Neo
number bank number 45649849659456
bankCode bank code View supported bank codes
status order status View order status description
statusMsg order status message Payout Success
description description description
platSign sign ja6R8eukQY9jc8...

# Cash api callback notify example

{
  "platOrderNum": "W0620220119174331000001",
  "orderNum": "186888188666",
  "money": "50000",
  "fee": "7",
  "feeType": "0",
  "name": "test cash name",
  "number": "2021071209403321313122",
  "bankCode": "014",
  "status": "2",
  "statusMsg": "SUCCESS",
  "description": "test cash",
  "platSign": "LGEpz2LjbZ6Iyvn+zLc/+t26AaH0aEhHVD62lSCdo6XIkAg86AUncCvmym62wVoE3r2+dHnv27qi/01UQDcqFK8DYioRCcydYSjB4QRVezG3fcZlhWrACmWGacnXkE7p5zChL7pK5h0HuBhbo1zKt4FunQR6QMmcBVfv7YfB3W0"
}