Cash Api
# Code Sample
- The code example is for reference only. For specific parameter descriptions, please refer to the request parameter description.
TopPayRequestUtil(Click here to get the code sample)
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.TreeMap;
public class TopCashDemo {
private static final String MCH_ID = "S820250514103726000009";
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GC..........oQIDAQAB";
private static final String MCH_PRIVATE_KEY = "MIICeA2n2Rut..........NxI2kXf3Vp";
private static final String cashUrl = "https://vnm-openapi.toppay.asia/gateway/payOut";
private static final String cashNotify = "http://xxxxx";
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", "T1234567890");
requestParams.put("method", "DISBURSEMENT");
requestParams.put("orderType", "0");
requestParams.put("money", "20000");
requestParams.put("feeType", "0");
requestParams.put("dateTime", "20200101235959");
requestParams.put("bankCard", "1154149865112");
requestParams.put("bankCode", "SCB");
requestParams.put("accountName", "accountName");
requestParams.put("extendParam", "TEST");
requestParams.put("notifyUrl", cashNotify);
List<String> paramNameList = new ArrayList<>();
for (String key : requestParams.keySet()) {
paramNameList.add(key);
}
Collections.sort(paramNameList);
StringBuilder stringBuilder = new StringBuilder();
for (String key : paramNameList) {
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) {
} else {
}
}
}
# Api Address
- Method : POST
- Api Address : https://vnm-openapi.toppay.asia/gateway/payOut
# Request Address
Note: Do not fill in Chinese in all parameters!!!
| Params | Type | Required | Desc | Ex |
|---|---|---|---|---|
| merchantCode | String | Y | MchId | S820250514103726000009 |
| orderType | string(10) | Y | Order Type | The default value is 0 |
| method | string(10) | Y | Method | Default transfer DISBURSEMENT |
| orderNum | String | Y | Merchant order number | 10000001 |
| money | String | Y | Payment amount | 10000.00(Supports two decimal places) |
| feeType | String | Y | Fee Type | 0: Deducted from the payment amount (actual amount received = order amount - handling fee) 1: Handling fee is calculated separately (actual amount received = order amount) |
| bankCode | String | Y | Bank Number | SCB Bank Code |
| bankCard | String | Y | Bank Card | 12312431241 |
| accountName | String | Y | Account Name | accountName |
| notifyUrl | String | Y | Notify Url | https://123123.com |
| dateTime | String | Y | yyyyMMddHHmmss | 20200101235959 |
| extendParam | String | Y | Transparent parameters (original text return) | Test |
| sign | String | Y | Signature | Yg+ePvTFhiRrARcZKBcRG0l8 ... |
# Request Example
{
"merchantCode": "S820250514103726000009",
"orderType": "0",
"method": "DISBURSEMENT",
"orderNum": "T1234567890",
"money": "10000.00",
"feeType": "1",
"bankCode": "SCB",
"bankCard": "2021071209403321313122",
"accountName": "test cash accountName",
"notifyUrl": "your notify url",
"dateTime": "20220101235959",
"extendParam": "test cash",
"sign": "Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqwH77qRXI1J+jElOBpa"
}
# Response Params
| Params | Type | Required | Desc | Ex |
|---|---|---|---|---|
| platRespCode | String | Y | Request Result | FAIL\SUCCESS |
| platRespMessage | String | Y | Message | SUCCESS |
| platOrderNum | String | Y | Platform OrderNum | PI1453242857400963072 |
| orderNum | String | Y | Merchant order number | 23645782 |
| status | Int | Y | Order Status | Cash Order Status |
| statusMsg | String | Y | Order status information | Apply |
| money | String | Y | Order amount | 10000.00 |
| feeType | String | Y | Fee Type | 0: Deduction within the order, 1: Handling fee is calculated separately |
| bankCode | String | N | Bank Code | SCB Bank Code |
| bankCard | String | Y | Bank Card | 12312431241 |
| accountName | String | Y | Account Name | accountName |
| extendParam | String | Y | Transparent parameters (original text return) | Test |
| platSign | String | Y | Platform Signature | PI1453242857400963072 |
# Response Example
{
"platRespCode": "SUCCESS",
"platRespMessage": "Request success",
"platOrderNum": "W0620220119174331000001",
"orderNum": "T1234567890",
"status": 0,
"statusMsg": "Apply",
"money": "10000.00",
"feeType": "0",
"bankCode": "SCB",
"bankCard": "2021071209403321313122",
"accountName": "test cash accountName",
"extendParam": "test cash",
"platSign": "E5uNF7B9NXyhtlRo2I7/KVHN4Sbz0c3VbwCLpH3vjUpv6Cai+bmJA/Q8dVE2RJRe1+dsbzg=="
}
# Order Notification
- When verifying the signature, use the platform public key provided in the merchant backend-payment configuration-API configuration for decryption.
- When verifying the signature, the actual callback parameters shall prevail, and do not verify the fixed parameters
- The final status of the order shall be based on the status of the notification.
- After receiving the asynchronous notification, you need to respond to the
SUCCESSstring, otherwise TopPay will continue to initiate 5 notifications. - TopPay Result Asynchronous Notification: Our notification IP address is
35.240.188.94. Please add it to your IP whitelist.
# Notify Params
| Params | Desc | Ex |
|---|---|---|
| platOrderNum | Platform OrderNum | BK_1563278763273 |
| orderNum | Merchant order number | T1231511321515 |
| money | Order Amount | 10000.00 |
| feeType | Fee Type | 0: Deduction within the order, 1: Handling fee is calculated separately |
| accountName | Account Name | accountName |
| bankCard | ank Card | 45649849659456 |
| bankCode | ank Code | SCB Bank Code |
| status | Order Status | 2 Cash Order Status |
| statusMsg | Status Desc | Payout Success |
| extendParam | Transparent parameters (original text return) | Test |
| platSign | Platform Signature | ja6R8eukQY9jc8... |
# Notify Example
{
"platOrderNum": "W0620220119174331000001",
"orderNum": "T1234567890",
"money": "10000.00",
"feeType": "0",
"accountName": "test cash accountName",
"bankCard": "2021071209403321313122",
"bankCode": "SCB",
"status": "2",
"statusMsg": "SUCCESS",
"extendParam": "test cash",
"platSign": "LGEpz2LjbZ6Iyvn+zLc/+t26AaH0aEhHVD62lSCdo6XIkAg86AUncCvmym62wVoE3r2+dHnv27qi/01UQDcqFK8DYioRCcydYSjB4QRVezG3fcZlhWrACmWGacnXkE7p5zChL7pK5h0HuBhbo1zKt4FunQR6QMmcBVfv7YfB3W0"
}