1. Make use of "pay_info" returned from Payment API to invoke WeChat payment module via web page inside WeChat app.
or
2. Make use of "pay_info" object returned from Payment API to invoke WeChat payment module via JS SDK inside WeChat app.
URL: https://pay.ionlinepay.com/gateway/
Request Method: POST Form-Data
| Name | ID | Required | Type | Description |
| API Name | service | Yes | String(32) | ionline.pay.weixin.jspay.intl |
| API Version | version | No | String(8) | Default value: 1.0 |
| Charset | charset | No | String(8) | Default value: UTF-8 |
| Signature Type | sign_type | No | String(8) | Default value: MD5 |
| Merchant ID (MID) | mch_id | Yes | String(32) | Specifies Merchant ID assigned by iOnline Pay |
| Native JS | is_raw | Yes | String(1) | If the value is 1, then the response parameter "pay_info" will return the JSON string, which is used for calling the WeChat Payment modeule via JS SDK. |
| Payment via Mini Program | is_minipg | No | String(1) | If the value is 1, then the payment is used in WeChat Mini Program. Otherwise, the payment is used in WeChat Offical Account. |
| Order Number | out_trade_no | Yes | String(32) | out_trade_no is an internal order number within the Vendor’s system. |
| Device ID | device_info | No | String(32) | Specifies the ID of the terminal device with from which the Merchant submitted their order |
| Item Description | body | Yes | String(127) | Item Description |
| User Tag | sub_openid | Yes | String(128) | Unique ID to identify an user in WeChat Offical Account / Mini Program * To find out how to obtain the Open ID,Please see Weixin public doc > The webpage authorization callback domain name。 |
| Sub Official Account / Mini Program ID | sub_appid | Yes | String(32) | Proivde WeChat Offical Account ID (App ID) when requesting Offical Account Payment. Proivde WeChat Mini Program ID (App ID) when requesting Mini Program Payment. |
| Additional Data | attach | No | String(127) | Allow merchants an additional field to be returned in the payment notification after submitting a payment to the Query Order API |
| Total Order Amount | total_fee | Yes | Int | Specifies the total order amount. The units are expressed in cents as integers. |
| Terminal IP | mch_create_ip | Yes | String(16) | Specifies the machine IP that calls Payment API |
| Payment Notification URL | notify_url | Yes | String(255) | Specifies the callback URL for receiving payment notifications Support port 80 or 443 only |
| Transaction Start Time | time_start | No | String(14) | Specifies the transaction creation time in the format yyyyMMddHHmmss, such as 20170520094130 for May 20, 2017 09:41:30 (GMT+8). |
| Transaction Expire Time | time_expire | No | String(14) | Specifies the transaction end time in the format yyyyMMddHHmmss, such as 20170520094130 for May 20, 2017 09:41:30 (GMT+8).
* Both parameter "time_expire" and the parameter "time_start" must be passed in order to setup expiration time. |
| Item Label | goods_tag | No | String(32) | Specifies the label of goods, which is a parameter in the coupon feature for businesses. |
| Random String | nonce_str | Yes | String(32) | 32 characters or fewer. |
| Prohibit Credit Card to Pay | limit_credit_pay | No | String(32) | If the value is 1, then WeChat Pay will block payer from paying by using credit card |
| Signature | sign | Yes | String(32) | Signature Hash. For more information, see "Security Specification" |
Response Format: JSON
| Name | ID | Required | Type | Description |
| Service Provider's Offical Account ID | app_id | No | String(32) | Service Provider's Offical Account ID |
| API Version | version | Yes | String(8) | Default value: 1.0 |
| Charset | charset | Yes | String(8) | Default value: UTF-8 |
| Signature Type | sign_type | No | String(8) | Default value: MD5 |
| Return Status Code | status | Yes | String(16) | This parameters indicates whether the API call is successful or not but this doesn't indicate to have a successful transaction. If the value is 0, then it indicates sucecssful. Otherwise, it indicates failure. |
| Return Message | message | No | String(128) | The description of the Return Status Code if the value of parameter "status" is not 0. |
| The below parameters will be returned if the value of the parameter "status" is 0. | ||||
| Service Result | result_code | Yes | String(16) | If the value is 0, then it indicates sucecssful. Otherwise, it indicates failure. |
| Merchant ID (MID) | mch_id | Yes | String(32) | Specifies Merchant ID assigned by iOnline Pay |
| Device ID | device_info | No | String(32) | Specifies the ID of the terminal device with from which the Merchant submitted their order |
| Random String | nonce_str | Yes | String(32) | 32 characters or fewer. |
| Error Code | err_code | No | String(32) | Error code |
| Error Message | err_msg | No | String(128) | The description of error code |
| Signature | sign | Yes | String(32) | Signature Hash. For more information, see "Security Specification" |
| The below parameters will be returned if the value of the both parameters "status" and "result_code" are 0. | ||||
| Token ID | token_id | Yes | String(64) | Token ID |
| Payment URL | pay_url | Yes | String(128) | Redirect Payer to WeChat Pay checkout page in WeChat app. * This Payment URL is only working inside WeChat app. |
| Payment Data | pay_info | Yes | String |
Offical Account Payment - if the request parameter "is_raw" is set to 1, it will be the payment data for Offical Account Payment in JSON format.
Mini Program Payment - if the request parameter "is_minipg" is set to 1, it will be the payment data for invoking Mini Program Payment in JSON format. |
* The data type of all the request paramters will be "String" type.
Sample Code:
WeixinJSBridge.invoke("getBrandWCPayRequest",{
"appId" : "wx2421b1c4370ec43b", //Offical Account ID
"timeStamp":" 1395712654", //timeStamp
"nonceStr" : "e61463f8efa94090b1f366cccfbbb444", //Random String
"package" : "prepay_id=u802345jgfjsdfgsdg888",
"signType" : "MD5", //Signature Type:
"paySign" : "70EA570631E4BB79628FBCA90534C63FF7FADD89" //Signature signed by WeChat
},function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ) {}
// if "res.err_msg" returns "get_brand_wcpay_request:ok", then this indicates the payment is sucecssful but you have to double-check the transaction status via Query API on server side also.
});
| Name | ID | Required | Type | Description |
| Offical Account ID | appId | Yes | String | Merchant's Offical Account ID |
| Timestamp | timeStamp | Yes | String | Specifies the current time. |
| Random String | nonceStr | Yes | String | 32 characters or fewer. |
| Additional Data Package | package | Yes | String | Specifies the parameter value (prepay_id) |
| Signature Type | signType | Yes | String | Signature Type |
| Signature | paySign | Yes | String | Signature signed by WeChat |
| 返回值 | ID | |||
| err_msg | "get_brand_wcpay_request:ok" means Payment successful | |||
| "get_brand_wcpay_request:cancel" means Payment cancelled | ||||
| "get_brand_wcpay_request:fail" means Payment failed | ||||
* "get_brand_wcpay_request:ok" is returned by the JSAPI only when the Payer completes the payment. For front-end logic, "get_brand_wcpay_request:cancel" or "get_brand_wcpay_request:fail" can be handled as payment exceptions.
Request Object
| Name | ID | Required | Type | Description |
| Timestamp | timeStamp | Yes | String | Specifies the current time. |
| Random String | nonceStr | Yes | String | 32 characters or fewer. |
| Additional Data Package | package | Yes | String | Specifies the parameter value (prepay_id) |
| Signature Type | signType | Yes | String | Signature signed by WeChat |
| Signature | paySign | Yes | String | Signature generated with the above parameters |
| Success | success | Yes | Function | Callback function if calls successfully |
| Failure | fail | Yes | Function | Callback function if calls failed |
| Complete | complete | Yes | Function | Callback function when calling complete (execute both when success and fail) |
| Callback Type | errMsg | Description | ||
| success | requestPayment:ok | Calling payment is successful. | ||
| fail | requestPayment:fail cancel | Payment is cancelled by payer. | ||
| fail | requestPayment:fail (detail message) | Calling payment is failed, the detailed information can be found in parameter value: detail message | ||
wx.requestPayment(
{
"timeStamp": "",
"nonceStr": "",
"package": "",
"signType": "MD5",
"paySign": "",
"success":function(res){},
"fail":function(res){},
"complete":function(res){}
});