Skip to main content

Request & Response

There are some basic rules for PTS request and response. Please check these rules before starting your implementation.

  1. All request and data are using UTF-8 format.
  2. The payment request is based on HTTPS protocol, only POST form is supported.
  3. All parameters & participate in signature must be sorted in ASCII. Null values still need to be added to signature.
  4. All requests have specified header. Please follow the setting for the request header.
  5. Please ask our customer service team for API Host URL
  6. Please let us know your Host IP, so we can add your IP into whitelist

Request Format

Please following guide to build your request:

  1. Prepare your request data and generate the signature.
  2. Convert request body into JSON string.
  3. Encrypt request JSON string by AES-ECB-PKCS7 with your merchant safecode.
  4. Encode your encrypted string via base64_encode and get the final request string.
  5. Content-Type of HTTPS requests should be text/plain
// Prepare your request data and generate the signature
{
"order_id": "20210514183849",
"amount": "40000",
"currency": "CNY",
"timestamp": "1612245402",
"callback_url": "http://my.service/callback",
"redirect_url": "https://my.service/redirect",
"channel": "alipay",
"bank_code": "",
"remark": "test",
"user_id": "1",
"sign": "lOp6SoczkquxzYTDufsVTIjjTdKuCGZnGEa7…."
}

// Convert request body into JSON string
{"order_id":"20210514184046","amount":"40000","currency":"CNY","timestamp":"1612245402","callback_url":"http://my.service/callback","redirect_url":"https://my.service/redirect","channel":"alipay","bank_code":"","remark":"test","user_id":"1","sign":"lOp6SoczkquxzYTDufsVTIjjTdKuCGZnGEa7..."}

// Encrypt JSON string by AES-ECB-PKCS7 with your merchant safecode, and convert it into base64_encode
wbTkX4OdkK8xqvrnqqKalTp/XiC+svRLvgu6UGQ5gDPx9iTRSS3ng8cRkLwfrxnN3Ba4YZAtMtb2PahMj0KNz56ovbuctKsMWMjztpIn2eLCHWNzVHRrU8eJ/aG0OgDztdceON2xBGYEtzpyf1Lc9jycfnd35tANhZgWFlNvCPrTNsbTjrVA3fH1gOKzn35CfHsuyWertBQjp/FqMkDWa7G1gRxXa2L1s...

// Then, now you can send request via HTTPS Post in text/plain
import json
import requests
from aes import AESCrypt

def sendRequest(apiUrl, params, accessToken):

signStr = generateSignature(params)
params['sign'] = rsa_sign(signStr)
jsonStr = json.dumps(params, indent=4, ensure_ascii=False)
aesStr = AESCrypt(safecode).__encrypt__(jsonStr).decode('utf-8')

response = requests.post(url=apiUrl, data=aesStr, headers={
'content-type': 'text/plain',
'Authorization': accessToken
})
if (response.status_code == 200):
return response.text
else:
return None

Response format

The responses and callbacks from PTS will follow this format.

Content-Type: application/json

ParamTypeRequiredDescription
codestringSuccess return 1000 and else are failure indexes
messagestringResult description
dataarrayProvides when code is 1000
// Example
{
"code": "1000",
"message": "Accepted",
"data": {
// available while code=1000
}
}