Payment Web API
  • Payment API Solutions Map
  • API Common Specifications
  • Payment Status Query API (Common)
  • Refund & Refund Query API (Common)
  • Query Exchange Rate API (Common)
  • Payment Process Flow with Mobile App (Common)
  • API for PC Browser with Wechat Pay/Alipay/UnionPay
    • Payment Request with WeChat Pay
    • Payment Request with Alipay
    • Payment Request with UnionPay-SecurePay
      • Query Transaction with UnionPay-SecurePay
  • API for WeChat Browser with WeChat Pay
    • Payment Request API
    • Query Transaction with WeChat Pay
  • API for WeChat Mini-Program with WeChat Pay
    • Payment Request API
    • Query Transaction API
  • API for Mobile Browser with Alipay
    • Payment Request API
    • Query Transaction API
  • API for Mobile Browser with WeChat
    • Payment Request API
    • Query Transaction API
  • API for Mobile with UnionPay-SecurePay
    • Payment Request API
    • Query Transaction API
    • Code Samples(Web App, Android, iOS)
  • API for Mobile App with WeChat Pay
    • Payment Request API
    • Query Transaction API
  • API for Mobile App with Alipay
    • Payment Request with OTT Pay SDK
    • Implementation with Android App SDK
    • Implementation with iOS App SDK
  • API for In-Store Channels(via Merchant POS/Terminal)
    • API Process Flows
    • Payment Request API
    • Query Transaction API
  • API for Elavon Converge-Hosted payment
    • Payment Request API
    • Query Transaction API
  • API for Global payments PORTICO Ecomm Payment
    • Payment Request API
    • Query Transaction API
  • API for Checkout payment
    • Payment Request API
    • Query Transaction API
  • Appendix A (Data Encryption / Decryption)
  • Appendix B (Response Code)
  • FAQ
  • > Back to Top Page
Powered by GitBook
On this page
  • Payment Request API
  • Request Message Parameters(JSON Format)
  • Request Data Example
  • Response Message Parameter
  • Response Message Data Example:

Was this helpful?

  1. API for Mobile App with WeChat Pay

Payment Request API

PreviousAPI for Mobile App with WeChat PayNextQuery Transaction API

Last updated 4 years ago

Was this helpful?

Payment Request API

Request Message Parameters(JSON Format)

Params Name

Description

Required

Notes

userId

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": ""
}

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

Params Name

Description

Required

Notes

appId

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

{
"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.

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

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

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

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

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

APP ID registered in WeChat

Response Message Parameter

APP ID registered

Response Message Data Example:

Call-Back Message Data

Call-Back Message Example(JSON Data):

Transaction Data (JSON format, after decrypted)

Data Example(JSON Data, after decrypted):

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

Please reference our Android demo code for details.

✅
☑️
☑️
✅
☑️
☑️
☑️
☑️
☑️
👉
👉
https://open.weixin.qq.com
https://open.weixin.qq.com
12MB
inapppay_demo_code(WeChat Pay).zip
archive
WebChat Pay for Mobile App Demo Codes