WeChat Open Platform

Mini Programs Documentation

WeChat Pay


Initiates WeChat Pay.

Object parameter descriptions:

Parameter Type Required Description
timeStamp String Yes Time stamp for the number of seconds from 00:00:00 on January 1, 1970 to the present, that is, the current time
nonceStr String Yes A random string of 32 characters or less.
package String Yes Unifies prepay_id parameter values returned by the order interface, submitted format such as: prepay_id=*
signType String Yes Signature algorithm, temporarily supports MD5
paySign String Yes Signature, refer to the WeChat Official Account Payment Help Document for the specific signature scheme
success Function No Callback function for successful interface call
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

For more information, please see the WeChat Pay Interface Document

Callback results:

Callback type errMsg Description
success requestPayment:ok Payment call successful
fail requestPayment:fail cancel User canceled payment
fail requestPayment:fail (detail message) Payment call failed, wherein detail message is the detailed failure reason returned by the backend

Sample code:

   'timeStamp': '',
   'nonceStr': '',
   'package': '',
   'signType': 'MD5',
   'paySign': '',

Bugs & Tips

  1. bug: In WeChat version 6.5.2 and earlier, a user canceling payment will not trigger a fail callback, it will only trigger a complete callback. The callback errMsg is 'requestPayment:cancel'.