This API is called using wx.requestPayment(Object object).
Property | Type | Default value | Required | Description |
timeStamp | string | - | True | Timestamp in seconds since 1970-01-01 00:00:00, representing the current time. |
nonceStr | string | - | True | Random string, up to 32 characters long. |
package | string | - | True | The prepay_id parameter value returned from the unified order API, formatted as: prepay_id=***. |
signType | string | - | True | Signature algorithm, should match the value used during backend ordering, typically: RSA. |
paySign | string | - | True | |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.requestPayment({timeStamp: '',nonceStr: '',package: '',signType: 'RSA',paySign: '',success (res) {/* res is typically returned by the superapp to the mini program frontend, with its structure customized by the superapp* Upon successful payment, res.errMsg will be 'requestPayment:ok'* It is recommended for the mini program to call the backend API to confirm payment status in the success callback to ensure payment callback information is synchronized with the mini program backend*/if(res.errMsg === 'resquestPayment:ok'){// send request to miniprogram backend to comfirm payment state}},fail (err) {// The error message is usually returned by the superapp to the mini program frontend, and the mini program frontend should provide appropriate user guidance after the error occurs.}})
This API is called using wx.requestVirtualPayment(Object object).
Property | Type | Default value | Required | Description |
signData | string | - | True | For specific payment parameters, see signData. This parameter must be passed as a string, for example: signData: '{"offerId":"123","buyQuantity":1,"currencyType":"USD","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}' |
mode | string | - | True | Only short_series_goods is supported. |
signature | string | - | True | |
paySign | string | - | True | |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Default value | Required | Description |
offerId | string | - | True | Merchant ID. |
buyQuantity | string | - | True | Purchase quantity. |
currencyType | string | - | True | Currency, e.g., USD. For details, see the payment currencies supported by the superapp in the console. |
productId | string | - | | Item ID. This field is required when mode=short_series_goods. |
goodsPrice | number | - | | Item unit price (in cents). This field is required when mode=short_series_goods. |
outTradeNo | string | - | True | Order number. Each order number can only be used once. Reusing it will result in a failure. |
attach | string | - | True | Pass-through data, which will be passed back to the developer in the delivery push. |
wx.requestVirtualPayment({signData: JSON.stringify({offerId: '123',buyQuantity: 1,currencyType: 'USD',productId: 'testproductId',goodsPrice: 10,outTradeNo: 'xxxxxx',attach: 'testdata',}),paySig: 'd0b8bbccbe109b11549bcfd6602b08711f46600965253a949cd6a2b895152f9d',signature: 'd0b8bbccbe109b11549bcfd6602b08711f46600965253a949cd6a2b895152f9d',mode: 'short_series_goods',success(res) {console.log('requestVirtualPayment success', res)},fail({ errMsg, errCode }) {console.error(errMsg, errCode)},})
Feedback