Payment Request API

Payment Request API

☑️ Request Message Parameters(JSON Format)

Params Name

Description

Required

Notes

userId

APP ID registered in WeChat https://open.weixin.qq.com

Y

e.g. wxcbb0a73d2d5a8888

amount

Transaction amount in cent

Y

String, "100" for 1.00 dollar

bizType

Business type

Y

WECHATPAY

merchant_id

Merchant ID in OTT PAY

Y

Provided by OTTPay

operator_id

Operator ID from OTT PAY

Y

Provided by OTTPay

order_id

you own order id

N

string, your own order id

call_back_url

Call back URL

Y

Call back data from OTT Pay, shown in the payment completion page

☑️ Request Data Example

{
 "userId": "wxcbb0a73d2d5a8888”, 
 "amount": "100", 
 "bizType": "WECHATPAY", 
 "merchant_id": "AB00000004", 
 "shopId": "", 
 "operator_id": "0000000005", 
 "tip": ""
}

Response Message Parameter

The response message contains all the required parameters to activate the client’s WeChat Wallet.

Params Name

Description

Required

Notes

appId

APP ID registered https://open.weixin.qq.com

required by WeChat Pay

Y

wxcbb0a73d2d5a8888

bizType

Business type

Y

WECHATPAY

nonceStr

Random string

required by WeChat Pay

Y

Random string

package_

String, required by WeChat Pay, must be “Sign=WXPay”

Y

Sign=WXPay

partnerId

PartnerId required by WeChat Pay

Y

XXXXXXXXXXX

paySign

Sign Key in OTT Pay request

N

DBC7B6ED46BE81E927CAA1922A83BE91

prepayId

prepayId obtained from WeChat Pay associated with the current transaction, required by WeChat Pay

Y

wx22014816274706c6ad56f2412344704275

reAmount

Available refund amount for this transaction

N

String, "100" for 1.00 dollar

timeStamp

Time Stamp required by WeChat Pay

Y

2018112112

tradeNo

Transaction Id for OTT Pay

N

1542822494862703

wxapikey

API key, required by WeChat Pay

Y

XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

☑️ Response Message Data Example:

{
"appId":"wxcbb0a73d2d5a8888",
"bizType":"WECHATPAY",
"nonceStr":"hieqzx0aK8sXTdMq",
"package_":"Sign=WXPay",
"partnerId":"XXXXXXXXXX",
"paySign":"DBC7B6ED46BE81E927CAA1922A83BE91",
"prepay_id":"wx22014816274706c6ad56f2412344704275",
"reAmount":"100",
"timeStamp":"2018112112",
"tradeNo":"1542822494862703",
"wxapikey":"XXXXXXXXXXXXXXXXXXXXXX"
}

通过WeChat SDK jar包调起WeChat Wallet支付, 需要用 appId, partnerId, prepayId, packageValue, timestamp, nonceStr, timestamp and Sign参数。其中Sign需要用WeChat Pay的sign creation logic 产生,示例如下:

To activate WeChat Wallet through WeChat SDK jar package needs following parameters: appId, partnerId, prepayId, packageValue, timestamp, nonceStr, timestamp and Sign. The Sign needs the WeChat Pay’s sign creation logic to generate, for example:

private String genAppSign(List<NameValuePair> params, String WECHAT_API_KEY) {
 StringBuilder sb = new StringBuilder();for (int i = 0; i < params.size(); i++) {
 sb.append(params.get(i).getName());
 sb.append('=');
 sb.append(params.get(i).getValue());
 sb.append('&');
 }
 sb.append("key=");
 sb.append(WECHAT_API_KEY);
 String appSign = MD5.getMessageDigest(sb.toString().getBytes()).toUpperCase();
 Log.d("test_api", "sign=" + appSign);
 return appSign;
}
 where params list is created by:
List<NameValuePair> signParams = new LinkedList<NameValuePair>();
signParams.add(new BasicNameValuePair("appid", appid));
signParams.add(new BasicNameValuePair("noncestr", nonceStr));
signParams.add(new BasicNameValuePair("package", packageValue));
signParams.add(new BasicNameValuePair("partnerid", partnerId));
signParams.add(new BasicNameValuePair("prepayid", prepayId));
signParams.add(new BasicNameValuePair("timestamp", timeStamp));
String sign = ss(signParams, );
 Finally, we can use these parameters to construct the PayReq request as:
PayReq req = new PayReq();
req.appId = appid;
req.partnerId = partnerId;
req.prepayId = prepayId;
req.packageValue = packageValue;
req.nonceStr = nonceStr;
req.timeStamp = timeStamp;
req.sign = sign;
Which can be used to raise the Wechat Wallet as:
private IWXAPI api;

api.sendReq(req);

Please note: IWXAP, PayReq are java class defined by WeChat SDK.

☑️ Call-Back Message Data

Params Name

Description

Required

Notes

rsp_code

Response code

Y

Refer to Appendix B

rsp_msg

Response message

Y

merchant_id

Merchant ID

Y

Merchant ID

finish_time

Payment time

Y

YYYYMMDDHHMMSS (Beijing time)

order_id

Order ID

Y

amount

Transaction amount

Y

String, "100" for 1.00 dollar

md5

Message Digest

Y

☑️ Call-Back Message Example(JSON Data):

 {
  "data":"hy0yiXxPH4TDXeY5ET7gqIsUcgY5ykO1vQYOahS5SsbN7/5Ha7+hvcXhgY1hz9kHuf5OxqNfv28kVeiYACrLzngk+hA2o8dVAcifT6h3AquN5micrIi3L9owj6cHT1nJRExC74sNUqF8CDY5fb4jLh9it9tq7r8xFOpcpf19VNWceo/Jt1nHca6HPMvMUEDeX1aUjnxOs7R7B2TUQbAENg\u003d\u003d",
  "rsp_code":"SUCCESS",
  "rsp_msg":"success",
  "merchant_id":"QC00005496",
  "md5":"F70CA0472D1AAA596E720C19A1DD36A0"
 }

☑️ Transaction Data (JSON format, after decrypted)

Params Name

Description

Required

Notes

finish_time

Payment time

Y

YYYYMMDDHHMMSS (Beijing time)

order_id

Order ID

Y

amount

Transaction amount

Y

String, "100" for 1.00 dollar

tip

Tip Amount

N

String, "100" for 1.00 dollar

bizpay_order_id

order id from Acquirer

Y

Returned by the Payment Service Provider (e.g. WeChat Pay, Alipay)

merchant_id

Merchant ID

Y

Provided by OTT Pay

☑️ Data Example(JSON Data, after decrypted):

{
 "amount":"1",
 "bizpay_order_id":"AL781266859681754",
 "tip":"0",
 "merchant_id":"QC00005496",
 "order_id":"2020041553699O153O0407",
 "finish_time":"20200416050429"
}

👉 Call back data中的 data是加密过的数据,参考appendix A进行解密处理。

Data in Call back data in encrypted, refer to appendix A for decryption.

👉 Please reference our Android demo code for details.

Last updated