tencent cloud

Virtual Payment
Last updated: 2025-10-15 15:10:54
Virtual Payment
Last updated: 2025-10-15 15:10:54

requestMidasPaymentGameItem

The API is called using wx.requestMidasPaymentGameItem(Object object).
Feature description:Initiates a direct purchase payment request for virtual items. For details, see Mini Game Payment Practical Tutorial.
Parameter and description: Object object.
Property
Type
Default value
‍Required
Description
signData
string
-
True
Original payment string.
For specific payment parameters, see signData below. The data must be passed in JSON format.
Example for signData:
'{"mode":"goods","buyQuantity":1,"currencyType":"USD","platform":"android","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}'
paySig
string
-
True
Payment signature.
The paySig parameter uses the following signing algorithm. Use the appkey to sign the payment request. Super App as a Service (SAS) does not participate in encryption/decryption or signature verification, so the mini game and superapp must handle key exchange themselves. The signature algorithm pseudocode is as follows:
paySig = to_hex(hmac_sha256(appkey,'requestMidasPaymentGameItem' + '&' + signData))
For details, see paySig generation.
signature
string
-
True
User session signature.
The signature algorithm for the signature parameter. The pseudocode is: signature = hmac_sha256(session_key, rawData)
For details, see signature generation.
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)

signData parameter description
:
Property
Type
Default value
‍Required
Description
mode
string
-
True
Payment type.
Different payment types require different additional parameters.
buyQuantity
number
-
True
Purchase quantity.
currencyType
string
-
True
Currency, such as USD (must match the currencies supported by the connected superapp).
platform
string
-
False
Platform. Valid value: Android or iOS.
productId
string
-
True
Virtual item ID.
goodsPrice
number
-
True
Virtual item unit price (in cents).
Used to verify that the price matches the backend item price.
outTradeNo
string
-
True
Order number.
Each order number can only be used once. Reusing it will result in a failure.
Must be no more than 32 characters, using only numbers, uppercase and lowercase letters, and the symbols _ - | * @. It cannot start with an underscore (_).

attach
string
-
False
Pass-through data.
Will be passed back to the developer in the delivery notification.
Error code:
Error code
Description
-15001
Virtual payment API error: Missing parameter.
-15002
Virtual payment API error: Invalid parameter.
-15003
Virtual payment API error: Duplicate order.
-15004
Virtual payment API error: Backend error.
-15005
Virtual payment API error: Mini game ID permission has been banned.
-15006
Virtual payment API error: Currency type not supported.
-15012
Signature error.
-15014
PaySig error.
-15015
Session key expired.
-15016
Virtual item price error.
-16001
Super App as a Service (SAS) error code: Merchant information does not exist.
-16002
Super App as a Service (SAS) error code: Virtual item does not exist.
-16003
Super App as a Service (SAS) error code: The mini game push notification configuration is not provided.
-16004
Super App as a Service (SAS) error code: Virtual item not registered.
-16005
Super App as a Service (SAS) error code: superapp backend service is not configured.
-16006
Super App as a Service (SAS) error code: The payment feature is not enabled in the superapp.
Example:
wx.requestMidasPaymentGameItem({
signData: '{"mode":"goods","buyQuantity":1,"currencyType":"set by yourself","platform":"android","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}',
paySig: 'd0b8bbccbe34ed11549bcfd6602b08711f4acc0965253a949cd6a2b895152f9d',
signature: 'd0b8bbccbe34ed11549bcfd6602b08711f4acc0965253a949cd6a2b895152f9d',
success({errMsg, errCode }) {
console.log('pay', errCode);
},
fail({ errMsg, errCode }) {
console.error(errMsg, errCode)
}


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback