Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Call Payment API for Mini Program

Latest update time:2019.11.20 Release notes


API for calling payment from mini program frontend

API intro

Applicable object: Common modeInstitutional mode

Request Parameters

The fields for generating signature when calling payment in Mini Program:

Name ID Type Required Description
Mini Program ID appId String(16) Yes This ID is issued after merchants apply for Mini Program, it should be the one which calls payment.
Example:wx8888888888888888
Timestamp timeStamp String(32) Yes

Specifies the current time. For more information, see Timestamp in Parameter Specifications.
Example:1414561699

Random String nonceStr String(32) Yes 32 characters or fewer. For more information, see Random String Algorithm.
Example:5K8264ILTKCH16CQ2502SI8ZNMTM67VS
Order Extension String package String(128) Yes Specifies the parameter value (prepay_id) returned by the Unified Order API.  The submission format is "prepay_id=***".
Example:prepay_id=123456789
Sign type signType String(32) Yes Currently HMAC-SHA256 and MD5 are supported, default is MD5. This parameter must be submitted if HMAC-SHA256 is chosen
Example:MD5

Example:

paySign = MD5(appId=wxd678efh567hg6787&nonceStr= 5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id= wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key= qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6


Please refer to 【Section Signature Algorithm】 for more information.


Call function wx.requestPayment(OBJECT) to load payment.


Please refer to the description for parameter OBJECT:


Parameter Type Required Description
timeStamp String Yes Specifies the current time. For more information, see Timestamp in Parameter Specifications.
nonceStr String Yes 32 characters or fewer.
package String Yes Specifies the parameter value (prepay_id) returned by the Unified Order API.  The submission format is "prepay_id=***".
signType String Yes MD5 or HMAC-SHA256
paySign String Yes Signature generated with the above parameters
success Function No Callback function if calls successfully
fail Function No Callback function if calls failed
complete Function No Callback function when calling complete (execute both when success and fail)

Return Data

Field Name Return Value Description
success requestPayment:ok Calling payment is successful.
fail requestPayment:fail cancel Payment is cancelled by customer.
fail requestPayment:fail (detail message) Calling payment is failed, the detailed information can be found in parameter value: detail message

Example:

wx.requestPayment(
{
'timeStamp': '1414561699',
'nonceStr': '5K8264ILTKCH16CQ2502SI8ZNMTM67VS',
'package': 'Sign=WXPay',
'signType': 'MD5',
'paySign': 'C380BEC2BFD727A4B6845133519F3AD6',
'success':function(res){},
'fail':function(res){},
'complete':function(res){}
}) 


Release notes

关闭
V1.0
2019.11.20
1. Call Payment API for Mini Program released online

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global