NAV
go php js java

Risk control callback

The second review of the withdrawal order

Request example:

POST <withdrawal review URL provided by the merchant>
Content-Type: application/json
X-Cbc-Timestamp: 1792382460
X-Cbc-Nonce: 9f2c4e6a8b0d1f3e5a7c9e1b3d5f7a9c
X-Cbc-Sign-Alg: RSA-SHA256
X-Cbc-Signature: <base64>

{"data":{"trade_id":"W202610190001","user_id":"10086","coin":"usdt_trc20","address":"TUCx9tabZSDRa4MxJzw9R3x5EiWNsvMdE7","amount":"100.5"}}

Request canonical string (4 lines joined by \n, no trailing newline):

1792382460
9f2c4e6a8b0d1f3e5a7c9e1b3d5f7a9c
RSA-SHA256
<lowercase hex SHA-256 of the raw request body bytes>

Merchant handler example:

// riskPlatformKey is the platform risk control public key, riskPrivateKey the merchant risk control private key (parse with cbc.ParsePublicKey / cbc.ParsePrivateKey)
http.HandleFunc("/risk/withdraw/check", func(w http.ResponseWriter, r *http.Request) {
    body,  := io.ReadAll(r.Body)
    status, tradeID := 5400, ""
    if err := cbc.VerifyBody(r.Header, body, riskPlatformKey, true); err == nil {
        // De-duplicate by X-Cbc-Nonce, check the local withdrawal by trade_id and decide status
        var req struct {
            Data struct {
                TradeID string json:"trade_id"
            } json:"data"
        }
        json.Unmarshal(body, &req)
        tradeID, status = req.Data.TradeID, 200
    }
    out,  := json.Marshal(map[string]any{"status": status, "data": map[string]string{"trade_id": tradeID}})
    headers, _ := cbc.SignBody(out, riskPrivateKey)
    for k, v := range headers {
        w.Header().Set(k, v)
    }
    w.Header().Set("Content-Type", "application/json")
    w.Write(out)
})
// $riskPlatformPublicKeyPem is the platform risk control public key, $riskPrivateKeyPem the merchant risk control private key
$body = file_get_contents('php://input');
$headers = array_change_key_case(getallheaders(), CASE_LOWER);
$status = 5400;
$tradeId = '';
try {
    CbcClient::verifyBody($headers, $body, $riskPlatformPublicKeyPem, true);
    // De-duplicate by X-Cbc-Nonce, check the local withdrawal by trade_id and decide status
    $req = json_decode($body, true);
    $tradeId = $req['data']['trade_id'];
    $status = 200;
} catch (RuntimeException $e) {
    // Return 5400 on verification failure; the platform retries later
}
$out = json_encode(['status' => $status, 'data' => ['trade_id' => $tradeId]]);
foreach (CbcClient::signBody($out, $riskPrivateKeyPem) as $k => $v) {
    header("$k: $v");
}
header('Content-Type: application/json');
echo $out;
// riskPlatformPublicKeyPem is the platform risk control public key, riskPrivateKeyPem the merchant risk control private key
app.post('/risk/withdraw/check', express.raw({ type: 'application/json' }), (req, res) => {
  let status = 5400;
  let tradeId = '';
  try {
    verifyBody((name) => req.get(name), req.body, riskPlatformPublicKeyPem, true);
    // De-duplicate by X-Cbc-Nonce, check the local withdrawal by trade_id and decide status
    tradeId = JSON.parse(req.body).data.trade_id;
    status = 200;
  } catch (e) {
    // Return 5400 on verification failure; the platform retries later
  }
  const out = Buffer.from(JSON.stringify({ status, data: { trade_id: tradeId } }));
  res.set(signBody(out, riskPrivateKeyPem)).type('application/json').send(out);
});
// riskPlatformKey is the platform risk control public key, riskPrivateKey the merchant risk control private key; parseTradeId reads data.trade_id with your JSON library
@PostMapping(value = "/risk/withdraw/check", produces = "application/json")
public ResponseEntity<byte[]> withdrawCheck(@RequestHeader HttpHeaders headers, @RequestBody byte[] body) throws Exception {
    Map<String, String> sig = new HashMap<>();
    for (String name : new String[]{"X-Cbc-Timestamp", "X-Cbc-Nonce", "X-Cbc-Sign-Alg", "X-Cbc-Signature"}) {
        sig.put(name, headers.getFirst(name));
    }
    int status = 5400;
    String tradeId = "";
    try {
        CbcClient.verifyBody(sig, body, riskPlatformKey, true);
        // De-duplicate by X-Cbc-Nonce, check the local withdrawal by trade_id and decide status
        tradeId = parseTradeId(body);
        status = 200;
    } catch (Exception e) {
        // Return 5400 on verification failure; the platform retries later
    }
    byte[] out = CbcClient.toJson(Map.of("status", status, "data", Map.of("trade_id", tradeId)))
            .getBytes(StandardCharsets.UTF_8);
    HttpHeaders respHeaders = new HttpHeaders();
    CbcClient.signBody(out, riskPrivateKey).forEach(respHeaders::set);
    return ResponseEntity.ok().headers(respHeaders).body(out);
}

Example of return result:

HTTP/1.1 200 OK
Content-Type: application/json
X-Cbc-Timestamp: 1792382461
X-Cbc-Nonce: 3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a
X-Cbc-Sign-Alg: RSA-SHA256
X-Cbc-Signature: <base64>

{"status":200,"msg":"success","data":{"trade_id":"W202610190001"}}

HTTP Request

POST: The specific callback URL is provided by the merchant to the platform side

Request headers

Parameter Description
X-Cbc-Timestamp Request time, Unix seconds
X-Cbc-Nonce Random string, 32 lowercase hex characters, different for every request
X-Cbc-Sign-Alg Always RSA-SHA256
X-Cbc-Signature Signature of the canonical string, standard Base64

Signature = Base64(RSA_PKCS1v15_Sign(platform risk control private key, SHA-256, canonical)). The canonical string has 4 lines: X-Cbc-Timestamp, X-Cbc-Nonce, RSA-SHA256, and the lowercase hex SHA-256 of the raw request body bytes, joined by \n with no trailing newline.

Request Parameters

Parameter Required Type Description
data Yes object as follows
data.trade_id Yes string Merchant withdrawal ID, i.e. the trade_id of the withdrawal request
data.user_id Yes string User the order belongs to
data.coin Yes string Lowercase coin identifier
data.address Yes string Withdrawal address
data.amount Yes string Withdrawal amount as a decimal string, identical to the amount in the withdrawal notification

Merchant verification steps

  1. All 4 headers are present and X-Cbc-Sign-Alg is RSA-SHA256;
  2. X-Cbc-Timestamp is within 300 seconds of the current time;
  3. Verify the signature over the canonical string with the platform risk control public key, hashing the raw body bytes exactly as received;
  4. The nonce has not been seen within 300 seconds (caching it for 660 seconds is recommended);
  5. If any of the above fails, return status=5400 and the platform will retry later;
  6. Only after verification succeeds, parse the body, look up the local withdrawal by trade_id, check user_id, coin, address and amount, and return the result.

Response Parameters

Parameter Type Description
status integer Review result, same values as v1: 200 passed, 2001 awaiting review, 5400 signature verification failed (including timestamp out of window and duplicate nonce), 5402 order does not exist, 5001 trade_id mismatch, 5002 wrong amount, 5003 wrong user_id, 5004 wrong address, 5005 wrong coin, 5006 order rejected, 5007 other
msg string Optional, result description
data object
data.trade_id string The trade_id from the request, returned as is

Sign the response with the merchant risk control private key, using the same headers as the request (X-Cbc-Timestamp, X-Cbc-Nonce, X-Cbc-Sign-Alg, X-Cbc-Signature). The canonical string has 4 lines: the response header timestamp, nonce, RSA-SHA256, and the lowercase hex SHA-256 of the raw response body bytes. The entire response body is covered by the signature.

2nd review for exchange order

Request example:

POST <exchange review URL provided by the merchant>
Content-Type: application/json
X-Cbc-Timestamp: 1792382460
X-Cbc-Nonce: 9f2c4e6a8b0d1f3e5a7c9e1b3d5f7a9c
X-Cbc-Sign-Alg: RSA-SHA256
X-Cbc-Signature: <base64>

{"data":{"trade_id":"E202610210001","user_id":"10086","source_coin":"eth","target_coin":"usdt_erc20","amount":"2"}}

Request canonical string (4 lines joined by \n, no trailing newline):

1792382460
9f2c4e6a8b0d1f3e5a7c9e1b3d5f7a9c
RSA-SHA256
<lowercase hex SHA-256 of the raw request body bytes>

Merchant handler example:

// riskPlatformKey is the platform risk control public key, riskPrivateKey the merchant risk control private key (parse with cbc.ParsePublicKey / cbc.ParsePrivateKey)
http.HandleFunc("/risk/exchange/check", func(w http.ResponseWriter, r *http.Request) {
    body, _ := io.ReadAll(r.Body)
    status, tradeID := 5400, ""
    if err := cbc.VerifyBody(r.Header, body, riskPlatformKey, true); err == nil {
        // De-duplicate by X-Cbc-Nonce, check the local exchange order by trade_id and decide status
        var req struct {
            Data struct {
                TradeID string `json:"trade_id"`
            } `json:"data"`
        }
        json.Unmarshal(body, &req)
        tradeID, status = req.Data.TradeID, 200
    }
    out, _ := json.Marshal(map[string]any{"status": status, "data": map[string]string{"trade_id": tradeID}})
    headers, _ := cbc.SignBody(out, riskPrivateKey)
    for k, v := range headers {
        w.Header().Set(k, v)
    }
    w.Header().Set("Content-Type", "application/json")
    w.Write(out)
})
// $riskPlatformPublicKeyPem is the platform risk control public key, $riskPrivateKeyPem the merchant risk control private key
$body = file_get_contents('php://input');
$headers = array_change_key_case(getallheaders(), CASE_LOWER);
$status = 5400;
$tradeId = '';
try {
    CbcClient::verifyBody($headers, $body, $riskPlatformPublicKeyPem, true);
    // De-duplicate by X-Cbc-Nonce, check the local exchange order by trade_id and decide status
    $req = json_decode($body, true);
    $tradeId = $req['data']['trade_id'];
    $status = 200;
} catch (RuntimeException $e) {
    // Return 5400 on verification failure; the platform retries later
}
$out = json_encode(['status' => $status, 'data' => ['trade_id' => $tradeId]]);
foreach (CbcClient::signBody($out, $riskPrivateKeyPem) as $k => $v) {
    header("$k: $v");
}
header('Content-Type: application/json');
echo $out;
// riskPlatformPublicKeyPem is the platform risk control public key, riskPrivateKeyPem the merchant risk control private key
app.post('/risk/exchange/check', express.raw({ type: 'application/json' }), (req, res) => {
  let status = 5400;
  let tradeId = '';
  try {
    verifyBody((name) => req.get(name), req.body, riskPlatformPublicKeyPem, true);
    // De-duplicate by X-Cbc-Nonce, check the local exchange order by trade_id and decide status
    tradeId = JSON.parse(req.body).data.trade_id;
    status = 200;
  } catch (e) {
    // Return 5400 on verification failure; the platform retries later
  }
  const out = Buffer.from(JSON.stringify({ status, data: { trade_id: tradeId } }));
  res.set(signBody(out, riskPrivateKeyPem)).type('application/json').send(out);
});
// riskPlatformKey is the platform risk control public key, riskPrivateKey the merchant risk control private key; parseTradeId reads data.trade_id with your JSON library
@PostMapping(value = "/risk/exchange/check", produces = "application/json")
public ResponseEntity<byte[]> exchangeCheck(@RequestHeader HttpHeaders headers, @RequestBody byte[] body) throws Exception {
    Map<String, String> sig = new HashMap<>();
    for (String name : new String[]{"X-Cbc-Timestamp", "X-Cbc-Nonce", "X-Cbc-Sign-Alg", "X-Cbc-Signature"}) {
        sig.put(name, headers.getFirst(name));
    }
    int status = 5400;
    String tradeId = "";
    try {
        CbcClient.verifyBody(sig, body, riskPlatformKey, true);
        // De-duplicate by X-Cbc-Nonce, check the local exchange order by trade_id and decide status
        tradeId = parseTradeId(body);
        status = 200;
    } catch (Exception e) {
        // Return 5400 on verification failure; the platform retries later
    }
    byte[] out = CbcClient.toJson(Map.of("status", status, "data", Map.of("trade_id", tradeId)))
            .getBytes(StandardCharsets.UTF_8);
    HttpHeaders respHeaders = new HttpHeaders();
    CbcClient.signBody(out, riskPrivateKey).forEach(respHeaders::set);
    return ResponseEntity.ok().headers(respHeaders).body(out);
}

Example of return result:

HTTP/1.1 200 OK
Content-Type: application/json
X-Cbc-Timestamp: 1792382461
X-Cbc-Nonce: 3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a
X-Cbc-Sign-Alg: RSA-SHA256
X-Cbc-Signature: <base64>

{"status":200,"msg":"success","data":{"trade_id":"E202610210001"}}

HTTP Request

POST The specific callback URL is provided by the merchant to the platform side

Request headers

Parameter Description
X-Cbc-Timestamp Request time, Unix seconds
X-Cbc-Nonce Random string, 32 lowercase hex characters, different for every request
X-Cbc-Sign-Alg Always RSA-SHA256
X-Cbc-Signature Signature of the canonical string, standard Base64

Signature = Base64(RSA_PKCS1v15_Sign(platform risk control private key, SHA-256, canonical)). The canonical string has 4 lines: X-Cbc-Timestamp, X-Cbc-Nonce, RSA-SHA256, and the lowercase hex SHA-256 of the raw request body bytes, joined by \n with no trailing newline.

Request Parameters

Parameter Required Type Description
data Yes object as follows
data.trade_id Yes string Merchant exchange ID, i.e. the trade_id of the exchange request
data.user_id Yes string User the order belongs to
data.source_coin Yes string Source coin in lowercase, the coin provided by the platform shall prevail
data.target_coin Yes string Target coin in lowercase, the coin provided by the platform shall prevail
data.amount Yes string Exchange amount as a decimal string without trailing zeros. Compare it numerically, not as a string

Merchant verification steps

  1. All 4 headers are present and X-Cbc-Sign-Alg is RSA-SHA256;
  2. X-Cbc-Timestamp is within 300 seconds of the current time;
  3. Verify the signature over the canonical string with the platform risk control public key, hashing the raw body bytes exactly as received;
  4. The nonce has not been seen within 300 seconds (caching it for 660 seconds is recommended);
  5. If any of the above fails, return status=5400 and the platform will retry later;
  6. Only after verification succeeds, parse the body, look up the local exchange order by trade_id, check user_id, source_coin, target_coin and amount, and return the result.

Response Parameters

Parameter Type Description
status integer Review result: 200 passed, 2001 awaiting review, 5400 signature verification failed (including timestamp out of window and duplicate nonce), 5402 order does not exist, 5001 trade_id mismatch, 5002 wrong amount, 5003 wrong user_id, 5005 wrong coin, 5006 order rejected, 5007 other
msg string Optional, result description
data object
data.trade_id string The trade_id from the request, returned as is

Sign the response with the merchant risk control private key, using the same headers as the request (X-Cbc-Timestamp, X-Cbc-Nonce, X-Cbc-Sign-Alg, X-Cbc-Signature). The canonical string has 4 lines: the response header timestamp, nonce, RSA-SHA256, and the lowercase hex SHA-256 of the raw response body bytes. The entire response body is covered by the signature.

MPC order review API

$url = "http://*****/mpc/order/check";
$header = [
  'Content-Type:application/json',
];
$params = [
    "data" => [
        "amount" => 2.00000000,
        "coin_symbol" => "usdt_trc20",
        "address" => "TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
        "user_id" => "1",
        "order_id" => "1394934189494173697",
        "timestamp" => 1621493658
    ],
    "sign" => "dLtK+uiPcnxt2ACKMbBqQ6wI5ttAvesOHzK5ybVID1R6hqYPDTkagl7Tsjr5iLJafehcSLTZyJLtCRI8O2CtIWQUUroGXBneHZC486NUi/4FMOQs0FaAgm17pWlbhX5/96cWXXXMVeoe3IZFKaFNYSWaA14v3RcdDU6QDE/9ixGiSJ0DIxm9NKA0+RkbIFbyYeuFn8d63OcjmUhv7tsOE6rKCc3Q2yi7Qe9i6BNAQFYMFATztb18MsxsBHKUxNqklqyVnl0ofETAHmQhfOHLmungOJQnOqAAuwfmRtg50Qci5F+R2mXeqjmIXko/u3E+DLYW1ygDBp3afKZmU4PwmA=="
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$return = curl_exec($ch);

print_r($return); 
var url = "http://*****/mpc/order/check"
data := map[string]interface{}{
    "data": map[string]string{
        "amount":"2.00000000",
        "coin_symbol":"usdt_trc20",
        "address":"TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
        "user_id":"1",
        "order_id":"1394934189494173697",
        "timestamp":"1621493658",
    },
    "sign": "OTA8utI8y8G93p7RPCyb4qIilFQ0B4Aq4iUjhaXWK9m2kgektqlHOASDKXT2VE7NPNysrGycYlVfjDR2WGZn1G66phHo3qa9CcCNpG9klOBEuBEMjiVbb/d8AXcxEzvQr9OCwNsikyxonyzLiY/lsNHeGm9cC5eRvlNLdUSVBipH+ajPd0lDHCayZPs1eCMfbm/xnf8e2lfy6z0UPOpHGfyX/0+hz99Ir5Xnx+0sBBzyZZJxKm4ROid5aDv/9m9guILpURae+Yw/IrkYF4uAKGX+/44cBvtTRQSdX76CAOBSiywZa6BAgDYBLRtkAPM+i+vwNzFBovqHUvI+4Ponaw==",
}
dataType, _ := json.Marshal(data)
resp, err := http.Post(url, "application/json", strings.NewReader(string(dataType)))
if err != nil {
  fmt.Println(err)
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
  fmt.Println(err)
}

fmt.Println(string(body))
let HTTP = require('http')
let postData = {
  "data": {
    "amount":"2.00000000",
    "coin_symbol":"usdt_trc20",
    "address":"TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
    "user_id":"1",
    "order_id":"1394934189494173697",
    "timestamp":"1621493658",
  },
  "sign": "OTA8utI8y8G93p7RPCyb4qIilFQ0B4Aq4iUjhaXWK9m2kgektqlHOASDKXT2VE7NPNysrGycYlVfjDR2WGZn1G66phHo3qa9CcCNpG9klOBEuBEMjiVbb/d8AXcxEzvQr9OCwNsikyxonyzLiY/lsNHeGm9cC5eRvlNLdUSVBipH+ajPd0lDHCayZPs1eCMfbm/xnf8e2lfy6z0UPOpHGfyX/0+hz99Ir5Xnx+0sBBzyZZJxKm4ROid5aDv/9m9guILpURae+Yw/IrkYF4uAKGX+/44cBvtTRQSdX76CAOBSiywZa6BAgDYBLRtkAPM+i+vwNzFBovqHUvI+4Ponaw==",
};
let POST_OPTIONS = {
  port: 80,
  host: "api.xxxx.com",
  path: "/mpc/order/check",
  method: 'POST',
  headers: {
    "Content-Type": "application/json; charset=utf-8"
  }
};

const REQUEST = HTTP.request(POST_OPTIONS,function (res) {
  let data = []
  res.on('data', chunk => {
    data.push(...chunk)
  })
  res.on('end', () => {
    let _date = JSON.parse( new TextDecoder().decode(new Uint8Array(data)))
    console.log(_date)
  })
});

REQUEST.setTimeout(6000)
REQUEST.write(JSON.stringify(postData), 'utf8')
REQUEST.end()
public static void main() {
    String priKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCtdgvcfozY7fe/x6UlXR/Fff8+wX++CiG05YVRafDe90O8y5KJAMZ156TgajEUXSRyKZqASz7iVoMAcu5FqfK1KuOOdjTAg0LFe/twIZvKmAqHcCSS2pjUXk0fTpZEgQ5lmDCK12Mg07YXvr+BeHjF+kBpwRJMPMG/+DGBDYNFNeRSJqWyopt6yyF528soAykHIUQ7TTultJV5IPCrvjRQQrGdJ/QtCdE0vZg+tA09nFN7AqgraU99kIvzyS0sqysj+pP1SJRmTRSGtlVAO3mILfkXOekZl1KD60G7CF+7BIaaW83FPD55tZhAGhnbLMYyiq7OiIyU61LTRcNSaJ0tAgMBAAECggEBAIGgGKcSzxCBbMYdXLV6TPbZ/HeaRGrwyVWUu7cmc0E8CJu6iWvmb2jGzbiCwuCT5luF6ZZ8JKchvU4FlTfsE5r9TQY2IZ/Ht4s65qBaDUEts5iY3kv8HX9+ZSXDJZpV0ztqqsPmx4ZNj+NYwWXwcFiKdb5R8OmV8bgSsnPddD6wFhwewglUOBPRAjropHE4sqk1Vam6q1MlFq5kiekMn/CItyFYFFzST/ruqAtVTp7YIvazAMrfCKH+pvXWk6pYNHZmL/JZey0GglRyJ1nItiqL33X8Lji056FcbAclidq022h/KPLEJpZk6irWqYdqYZeF6YMLHtdZFDkTZ/hXY+UCgYEA5i794UTQ1Kd6K+iui/S8K5H8nG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LKAMpByFEO007pbSVeSDwq740UEKxnSf0LQnRNL2YPrQNPZxTewKoK2lPfZCL88ktLKsrI/qT9UiUZk0UhrZVQDt5iC35FznpGZdSg+tBuwhfuwSGmlvNxTw+ebWYQBoZ2yzGMoquzoiMlOtS00XDUmidLQIDAQAB";
    rsaSigner signer = new rsaSigner();

    Map<String, Object> data = new HashMap<>();
    data.put("amount", "2.00000000");
    data.put("coin_symbol", "usdt_trc20");
    data.put("address", "TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi");
    data.put("user_id", "1");
    data.put("order_id", "1394934189494173697");
    data.put("timestamp", "1621493658");

    try {
        Map<String, Object> params = new HashMap<>();
        params.put("data", data);
        params.put("sign", signer.genSign(data, priKey));

        Gson gson = new GsonBuilder().create();
        System.out.println("params = " + gson.toJson(params));

        String res;
        // platform request shop callback API
//            res = doPost("http://api.shophost.com/mpc/order/check", gson.toJson(params));
//            if (null == res) {
//                throw new RuntimeException("http error");
//            }

        // mock response from shop callback API
        {
            res = """
                    {
                      "status":200,
                      "data":{
                        "time":1620617260,
                        "trade_id":"202105101123221335892766889804"
                      },
                      "sign":"YbRyMoUmsCxLbWopD2JD5EZqkT+pIRARsdTSFo+WyhebOMP/TZ96zV/vy4CYn+9gk6nJ55acFnqSO78N4/uemiOyBgE+a8SaIjutc+kFCWGaCorboy9alFBFUbYPvHvFFKHNFJx19Z2cyv9uceGdOdz09g0OBgp8bTyfkCUNrhbUmut2M2S2ixSH3wSefqUq2SUpohb5hlD6tOsyO3JfZr7M/16aiRGcEye2XglsOMFTO5XRkj4hwHKB+nHacttvuZKnGH67ELyoajCc+ef1DkmzmO3P7vFLIuVtVXQ2FPlXVkzCR/+VesyDOpYogHwqyR1BzCCSzxpbZ/aFc/uANg=="
                    }
                    """;
        }

        System.out.println("response = " + res);

        JsonParser jp = new JsonParser();
        JsonObject resEle = jp.parse(res).getAsJsonObject();
        boolean retSignOK = signer.verifySign(resEle.get("data"), resEle.get("sign").getAsString(), pubKey);
        if (!retSignOK) {
            throw new RuntimeException("verify response sign fail");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    System.out.println("OK");
}

Example of return result:

{
  "status":200,
  "data":{
    "is_valid": 1,
    "timestamp":1620617260,
    "order_id":"1394934189494173697"
  },
  "sign":"YbRyMoUmsCxLbWopD2JD5EZqkT+pIRARsdTSFo+WyhebOMP/TZ96zV/vy4CYn+9gk6nJ55acFnqSO78N4/uemiOyBgE+a8SaIjutc+kFCWGaCorboy9alFBFUbYPvHvFFKHNFJx19Z2cyv9uceGdOdz09g0OBgp8bTyfkCUNrhbUmut2M2S2ixSH3wSefqUq2SUpohb5hlD6tOsyO3JfZr7M/16aiRGcEye2XglsOMFTO5XRkj4hwHKB+nHacttvuZKnGH67ELyoajCc+ef1DkmzmO3P7vFLIuVtVXQ2FPlXVkzCR/+VesyDOpYogHwqyR1BzCCSzxpbZ/aFc/uANg=="
}

HTTP Request

POST The specific callback URL is provided by the merchant to the platform side

Request Parameters

Parameter Required Type Description
data No string as follows
data.order_id Yes string The unique ID of the merchant transaction (trade_id when withdrawing)
data.user_id Yes string user the order belongs to
data.coin_symbol Yes string lowercase coin name, subject to the coin provided by the platform
data.address Yes string withdrawal address
data.amount Yes string withdrawal amount
data.timestamp Yes integer current timestamp in second
sign Yes string sign the data in data

Response Parameters

Parameter Type Description
status integer 200 passed, 2001 pending review, 5400 failed signature verification, 5401 time less than 30s, 5402 order number does not exist, 5001 platform order_id is different, 5002 amount is wrong, 5003 user uid is wrong, 5004 address is wrong, 5005 currency The symbol is wrong, 5006 order rejection, 5007 other, the description information can be expanded by yourself
msg string state description
data object
data.is_valid integer 1 pass; 2 fail
data.order_id string order number
data.timestamp integer current time
sign string signature - the signature of the content of the data field in the response parameter

CoSigner-MPC order review API

$url = "http://*****/cs_mpc/order/check";
$header = [
  'Content-Type:application/json',
];
$params = [
    "data" => [
        "amount" => 2.00000000,
        "coin" => "usdt_trc20",
        "address" => "TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
        "user_id" => "1",
        "trade_id" => "1394934189494173697",
        "timestamp" => 1621493658
    ],
    "sign" => "dLtK+uiPcnxt2ACKMbBqQ6wI5ttAvesOHzK5ybVID1R6hqYPDTkagl7Tsjr5iLJafehcSLTZyJLtCRI8O2CtIWQUUroGXBneHZC486NUi/4FMOQs0FaAgm17pWlbhX5/96cWXXXMVeoe3IZFKaFNYSWaA14v3RcdDU6QDE/9ixGiSJ0DIxm9NKA0+RkbIFbyYeuFn8d63OcjmUhv7tsOE6rKCc3Q2yi7Qe9i6BNAQFYMFATztb18MsxsBHKUxNqklqyVnl0ofETAHmQhfOHLmungOJQnOqAAuwfmRtg50Qci5F+R2mXeqjmIXko/u3E+DLYW1ygDBp3afKZmU4PwmA=="
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$return = curl_exec($ch);

print_r($return); 
var url = "http://*****/cs_mpc/order/check"
data := map[string]interface{}{
    "data": map[string]string{
        "amount":"2.00000000",
        "coin":"usdt_trc20",
        "address":"TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
        "user_id":"1",
        "trade_id":"1394934189494173697",
        "timestamp":"1621493658",
    },
    "sign": "OTA8utI8y8G93p7RPCyb4qIilFQ0B4Aq4iUjhaXWK9m2kgektqlHOASDKXT2VE7NPNysrGycYlVfjDR2WGZn1G66phHo3qa9CcCNpG9klOBEuBEMjiVbb/d8AXcxEzvQr9OCwNsikyxonyzLiY/lsNHeGm9cC5eRvlNLdUSVBipH+ajPd0lDHCayZPs1eCMfbm/xnf8e2lfy6z0UPOpHGfyX/0+hz99Ir5Xnx+0sBBzyZZJxKm4ROid5aDv/9m9guILpURae+Yw/IrkYF4uAKGX+/44cBvtTRQSdX76CAOBSiywZa6BAgDYBLRtkAPM+i+vwNzFBovqHUvI+4Ponaw==",
}
dataType, _ := json.Marshal(data)
resp, err := http.Post(url, "application/json", strings.NewReader(string(dataType)))
if err != nil {
  fmt.Println(err)
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
  fmt.Println(err)
}

fmt.Println(string(body))
let HTTP = require('http')
let postData = {
  "data": {
    "amount":"2.00000000",
    "coin":"usdt_trc20",
    "address":"TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi",
    "user_id":"1",
    "trade_id":"1394934189494173697",
    "timestamp":"1621493658",
  },
  "sign": "OTA8utI8y8G93p7RPCyb4qIilFQ0B4Aq4iUjhaXWK9m2kgektqlHOASDKXT2VE7NPNysrGycYlVfjDR2WGZn1G66phHo3qa9CcCNpG9klOBEuBEMjiVbb/d8AXcxEzvQr9OCwNsikyxonyzLiY/lsNHeGm9cC5eRvlNLdUSVBipH+ajPd0lDHCayZPs1eCMfbm/xnf8e2lfy6z0UPOpHGfyX/0+hz99Ir5Xnx+0sBBzyZZJxKm4ROid5aDv/9m9guILpURae+Yw/IrkYF4uAKGX+/44cBvtTRQSdX76CAOBSiywZa6BAgDYBLRtkAPM+i+vwNzFBovqHUvI+4Ponaw==",
};
let POST_OPTIONS = {
  port: 80,
  host: "api.xxxx.com",
  path: "/cs_mpc/order/check",
  method: 'POST',
  headers: {
    "Content-Type": "application/json; charset=utf-8"
  }
};

const REQUEST = HTTP.request(POST_OPTIONS,function (res) {
  let data = []
  res.on('data', chunk => {
    data.push(...chunk)
  })
  res.on('end', () => {
    let _date = JSON.parse( new TextDecoder().decode(new Uint8Array(data)))
    console.log(_date)
  })
});

REQUEST.setTimeout(6000)
REQUEST.write(JSON.stringify(postData), 'utf8')
REQUEST.end()
public static void main() {
    String priKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCtdgvcfozY7fe/x6UlXR/Fff8+wX++CiG05YVRafDe90O8y5KJAMZ156TgajEUXSRyKZq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eNo0icpHrtXfzi7Q8Q/PCpzs4dtioXTjaIkS5nNvzVyG/uL+RyuZmpsxrZ5dYM4KbAhchfwORMutxEZhwKBgQC5zpVw4jCEItBmNuTWO+nTScGvxTgfiXIVw+XLaQa2AJoZlhAL34yPWdffko79tv3lgweY9HsimZXO2rU8dbp8mo5c6ydhy8HPXUeWOcAkDSdv/ApWENW9jgYsRIC3swHY3Fl+Dv3Wjce8huQI3mjwaYvRmBhIToxfmHnscVhTBQKBgB9uciEHfz8hMI7ePrPo2PkyK/RbJDm3HnuWE2lFBp7MOUMlh53MXwv4dIRaYMbRrFuN1UIKEFxuKhWwTHSzZJufk/UENrha/81fpj2BoFsAKkEunKeETvaIh6fZSjec16h2+zxbzwkdS6b+yIYkSlaoAxmDYrMtae0C8G4e0YS9";
    String pubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArXYL3H6M2O33v8elJV0fxX3/PsF/vgohtOWFUWnw3vdDvMuSiQDGdeek4GoxFF0kcimagEs+4laDAHLuRanytSrjjnY0wINCxXv7cCGbypgKh3AkktqY1F5NH06WRIEOZZgwitdjINO2F76/gXh4xfpAacESTDzBv/gxgQ2DRTXkUialsqKbesshedvLKAMpByFEO007pbSVeSDwq740UEKxnSf0LQnRNL2YPrQNPZxTewKoK2lPfZCL88ktLKsrI/qT9UiUZk0UhrZVQDt5iC35FznpGZdSg+tBuwhfuwSGmlvNxTw+ebWYQBoZ2yzGMoquzoiMlOtS00XDUmidLQIDAQAB";
    rsaSigner signer = new rsaSigner();

    Map<String, Object> data = new HashMap<>();
    data.put("amount", "2.00000000");
    data.put("coin", "usdt_trc20");
    data.put("address", "TLhdZuFU1fDPnzxPoXfJ6WZZMpKzY15DUi");
    data.put("user_id", "1");
    data.put("trade_id", "1394934189494173697");
    data.put("timestamp", "1621493658");

    try {
        Map<String, Object> params = new HashMap<>();
        params.put("data", data);
        params.put("sign", signer.genSign(data, priKey));

        Gson gson = new GsonBuilder().create();
        System.out.println("params = " + gson.toJson(params));

        String res;
        // platform request shop callback API
//            res = doPost("http://api.shophost.com/cs_mpc/order/check", gson.toJson(params));
//            if (null == res) {
//                throw new RuntimeException("http error");
//            }

        // mock response from shop callback API
        {
            res = """
                    {
                      "status":200,
                      "data":{
                        "time":1620617260,
                        "trade_id":"202105101123221335892766889804"
                      },
                      "sign":"YbRyMoUmsCxLbWopD2JD5EZqkT+pIRARsdTSFo+WyhebOMP/TZ96zV/vy4CYn+9gk6nJ55acFnqSO78N4/uemiOyBgE+a8SaIjutc+kFCWGaCorboy9alFBFUbYPvHvFFKHNFJx19Z2cyv9uceGdOdz09g0OBgp8bTyfkCUNrhbUmut2M2S2ixSH3wSefqUq2SUpohb5hlD6tOsyO3JfZr7M/16aiRGcEye2XglsOMFTO5XRkj4hwHKB+nHacttvuZKnGH67ELyoajCc+ef1DkmzmO3P7vFLIuVtVXQ2FPlXVkzCR/+VesyDOpYogHwqyR1BzCCSzxpbZ/aFc/uANg=="
                    }
                    """;
        }

        System.out.println("response = " + res);

        JsonParser jp = new JsonParser();
        JsonObject resEle = jp.parse(res).getAsJsonObject();
        boolean retSignOK = signer.verifySign(resEle.get("data"), resEle.get("sign").getAsString(), pubKey);
        if (!retSignOK) {
            throw new RuntimeException("verify response sign fail");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    System.out.println("OK");
}

Example of return result:

{
  "status":200,
  "data":{
    "is_valid": 1,
    "timestamp":1620617260,
    "trade_id":"1394934189494173697"
  },
  "sign":"YbRyMoUmsCxLbWopD2JD5EZqkT+pIRARsdTSFo+WyhebOMP/TZ96zV/vy4CYn+9gk6nJ55acFnqSO78N4/uemiOyBgE+a8SaIjutc+kFCWGaCorboy9alFBFUbYPvHvFFKHNFJx19Z2cyv9uceGdOdz09g0OBgp8bTyfkCUNrhbUmut2M2S2ixSH3wSefqUq2SUpohb5hlD6tOsyO3JfZr7M/16aiRGcEye2XglsOMFTO5XRkj4hwHKB+nHacttvuZKnGH67ELyoajCc+ef1DkmzmO3P7vFLIuVtVXQ2FPlXVkzCR/+VesyDOpYogHwqyR1BzCCSzxpbZ/aFc/uANg=="
}

HTTP Request

POST The specific callback URL is provided by the merchant to the platform side

Request Parameters

Parameter Required Type Description
data No string as follows
data.trade_id Yes string The unique ID of the merchant transaction (trade_id when withdrawing)
data.user_id Yes string user the order belongs to
data.coin Yes string lowercase coin name, subject to the coin provided by the platform
data.address Yes string withdrawal address
data.amount Yes string withdrawal amount
data.timestamp Yes integer current timestamp in second
sign Yes string sign the data in data

Response Parameters

Parameter Type Description
status integer 200 passed, 2001 pending review, 5400 failed signature verification, 5401 time less than 30s, 5402 order number does not exist, 5001 platform order_id is different, 5002 amount is wrong, 5003 user uid is wrong, 5004 address is wrong, 5005 currency The symbol is wrong, 5006 order rejection, 5007 other, the description information can be expanded by yourself
msg string state description
data object
data.is_valid integer 1 pass; 2 fail
data.trade_id string order number
data.timestamp integer current time
sign string signature - the signature of the content of the data field in the response parameter