Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Mini Program Calls Payment

Latest update time:2020.04.30 Release notes


Merchants call wx.requestPayment(OBJECT) in the Mini Program to start WeChat Pay.

API intro

Applicable object:Common modeInstitutional mode

API Rules: https://wechatpay-api.gitbook.io/wechatpay-api-v3

List of fields involved to generate paySign during the process of Mini Program calling the payment API:

Name Variable Name Type Required Description
Mini Program id

appId String(16) Yes The merchant can get it after registering a Mini Program successfully.
Example:wx8888888888888888
Timestamp

timeStamp String(32) Yes The current time. For details, see timestamp rules.
Example:1414561699
Random string

nonceStr String(32) Yes Random string, not longer than 32 digits. It is recommended to use the random number generation algorithm.
Example:5K8264ILTKCH16CQ2502SI 8ZNMTM67VS
An extension string for order details

package String(128) Yes The value of the prepay_id parameter returned by the unified order placement API, in the format of prepay_id=***
Example:prepay_id=123456789

paySign generation rules:

Signature fields and formats:

Mini Program id 
Timestamp 
Random string
An extension string for order details

Example of a string to be signed:

wx8888888888888888
1414561699
5K8264ILTKCH16CQ2502SI8ZNMTM67VS
prepay_id=123456789

Calculating signature value

The signature method is the same as the signature for request data. Use the merchant private key to sign the string using the SHA256-with-RSA signature algorithm, and obtain the signature value through Base64 encoding.

Merchants call wx.requestPayment(OBJECT) in the Mini Program to start WeChat Pay.

Object parameter description:

Name Variable Name Type Required Description
TimeStamp timeStamp String(32) Yes The current time. For details, see timestamp rules.
Example:1990840662
NonceStr nonceStr String(32) Yes Random string, not longer than 32 digits.
Example:5K8264ILTKCH16CQ2502SI8ZNMTM67VS
Package package String(128) Yes The value of the prepay_id parameter returned by the order placement API, in the format of prepay_id=*
Example:prepay_id=12345678
SignType signType String(32) Yes Signature type. Default is RSA. This parameter is not used in the signature.
Example:RSA
PaySign paySign String(64) Yes Signature. For more information, see the paySign generation rules.
Example:UGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==

Callback results:

Callback Type errMsg DescriptionCallback results:
success requestPayment:ok Calling payment successful
fail requestPayment:fail cancel User cancels payment
fail requestPayment:fail (detail message) Failed to call payment. The detail message is the specific failure reason returned by the backend.

For example:


wx.requestPayment(
{
"timeStamp": "1414561699",
"nonceStr": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS",
"package": "prepay_id=wx201410272009395522657a690389285100",
"signType": "RSA",
"paySign": "UGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==",
'success':function(res){},
'fail':function(res){},
'complete':function(res){}
})

    
{
JAVA示例代码
}
    


Release notes

关闭
V1.0
2020.04.30
1.Mini Program Calls Payment released online

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global