Digital cash api
- Digital currency transactions support currencies: (USDT/BTC/ETH/TRX). If you want to use digital currency transactions, please set orderType=1 and pass in the corresponding currency Currency and network netWork.
- When using digital currency for transactions, the currency and chain network are required. You need to tell us which digital currency and chain network (TRC20/BEP20/OMNI/ERC20/TRX) you want to use for transactions.
- When trading with digital currency, you need to pass in your inAddress to receive the digital currency.
# 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", "USDT");
requestParams.put("orderType", "1");
requestParams.put("money", "1.00000001");
requestParams.put("feeType", "1");
requestParams.put("dateTime", "20200101235959");
requestParams.put("name", "test cash name");
requestParams.put("mobile", "082122965511");
requestParams.put("email", "[email protected]");
requestParams.put("notifyUrl", cashNotify);
requestParams.put("currency", "USDT");
requestParams.put("netWork", "TRC20");
requestParams.put("inAddress", "zkif74bhvkf8934rgg6");
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 some thing
} else {
// ... do some thing
}
}
}
# Request Address
- Request method: POST
- Request address: https://br-openapi.toppay.asia/gateway/cash
# Request parameters
Note: Do not fill in Chinese in all parameters! ! !
Param | Type | Required | Description | Example |
---|---|---|---|---|
merchantCode | string | Y | Merchant ID,Get it in Merchant Platform-Personal Center-Personal Information | S820211021094748000001 |
orderType | string(10) | Y | Order Type | 1-Digital currency trading |
method | string(10) | Y | Method | USDT BTC ETH TRX |
orderNum | string | Y | Merchant order number | 186888188666 |
money | string | Y | Withdrawal amount (Supports up to 6 decimal places);If the feeType is 0, please use the amount with 3 decimal places to place the payment order. | 1.000001 |
feeType | String | Y | Fee Type 0: deduction in order 1: deduction out order | 0 |
name | String | Y | Customer name | Jack |
mobile | String | Y | mobile | 081234567890 |
String | Y | [email protected] | ||
notifyUrl | String | Y | notify url | https://***.com |
dateTime | String | Y | timestamp (format: yyyyMMddHHmmss) | 20200101235959 |
currency | string(14) | Y | Currency | USDT |
netWork | string(30) | Y | Net Work | TRC20 |
inAddress | string | Y | Receiveing Address | vboj3457vbiae5y35y |
# Request example
{
"merchantCode": "S820211021094748000001",
"orderType": "1",
"method": "USDT",
"orderNum": "186888188666",
"money": "1.00000001",
"feeType": "1",
"name": "test cash name",
"mobile": "082122965511",
"email": "[email protected]",
"notifyUrl": "your notify url",
"dateTime": "2021-07-12 09:41:00",
"currency": "USDT",
"netWork": "TRC20",
"inAddress": "vboj3457vbiae5y35y",
"sign": "Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqwH77qRXI1J+jElOBpa"
}
# Response parameters
Parameters | Type | Description | Example |
---|---|---|---|
platRespCode | String | response code | FAIL\SUCCESS |
platRespMessage | String | response message | FAIL\SUCCESS |
platOrderNum | String | platform order number | PI1453242857400963072 |
status | String | order status | View order status description |
statusMsg | String | order message | Apply |
orderNum | String | merchant order number | 23645782 |
money | String | amout | 1.00000001 |
fee | String | fee | 12.25 |
feeType | String | fee type 0:deduction in order 1:deduction out order | 0 |
name | String | name | Jack |
currency | String | currency | USDT |
netWork | String | net work | TRC20 |
platSign | String | sign | PI1453242857400963072 |
# Response message example
{
"platRespCode": "SUCCESS",
"platRespMessage": "Request success",
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"status": "0",
"statusMsg": "Apply",
"money": "50000",
"fee": "7",
"feeType": "1",
"currency": "USDT",
"netWork": "TRC20",
"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 receiving the asynchronous notification of the result, you need to respond with the SUCCESS string, which does not include quotation marks and is not in Json format. Otherwise TopPay will continue to send 5 notifications to the downstream.
# Notify Params
Parameters | Description | Example |
---|---|---|
platOrderNum | platform order number | BK_1563278763273 |
orderNum | merchant order number | T1231511321515 |
money | amount | 1.00000001 |
feeType | fee type 0:deduction in order 1:deduction out order | 1 |
fee | fee | 500 |
name | name | Neo |
status | order status | View order status description |
statusMsg | order status message | Payout Success |
hashCode | hashCode | 5e5c356af0ewrhgnf3d757h8a6a5506cc66354620 |
inAddress | receiveAddress | TDBbbeAB32WE576DVGE82GEC5BhsZs4 |
sendAddress | sendAddress | TDBbbeAB32WE576DVGE82GEC5BhsZs4 |
platSign | sign | ja6R8eukQY9jc8... |
# Cash api callback notify example
{
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"money": "1.00000001",
"fee": "0.0001",
"feeType": "1",
"currency": "USDT",
"netWork": "TRC20",
"name": "test cash name",
"status": "2",
"statusMsg": "SUCCESS",
"hashCode": "5e5c356af0ewrhgnf3d757h8a6a5506cc66354620",
"inAddress": "Twrgtehsd576gsdre876d2545C5Br23324",
"sendAddress": "TDBbbeAB32WE576DVGE82GEC5BhsZs4",
"platSign": "LGEpz2LjbZ6Iyvn+zLc/+t26AaH0aEhHVD62lSCdo6XIkAg86AUncCvmym62wVoE3r2+dHnv27qi/01UQDcqFK8DYioRCcydYSjB4QRVezG3fcZlhWrACmWGacnXkE7p5zChL7pK5h0HuBhbo1zKt4FunQR6QMmcBVfv7YfB3W0"
}