# Virtual Payment
# Applying for Activation
# Activate WeChat Pay
The entity type is a verified Mini Game of an individual business or a company
Activate WeChat Pay
# Activate virtual payment
# Signing Payment Agreement
Carefully read and agree to the terms of the payment agreement.
# Set withdrawal account
The amounts of transactions completed by the user in the Mini Game will be withdrawn to the developer's bank account after settlement.
# Hosting Game Currency
In game-type Mini Programs, game currency must be hosted on the platform.
- The admin grants authorization
- Enter the game currency name and exchange rate
- Game zone configuration
- Release in integrate testing environment
- The submitted application for app release must be approved
# Query payment order
After virtual payment is activated, payment orders can be queried.
# Development Process
# API list
- [Frontend] Payment API: wx.requestMidasPayment
- [Server] Get game currency balance:
midas.getBalance
- [Server] Deduct game currency:
midas.pay
- [Server] Cancel order:
midas.cancelPay
- [Server] Give game currency to another user:
midas.present
# Call sequence diagram
# Calculating Signature
Below is an example of the "Query Balance" API
- Original request information
(1) Midas key: zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u (2) HTTP request method: POST (3) Request URI: /cgi-bin/midas/getbalance
- sig signature
(1) Midas signature request parameters
"openid":"odkx20ENSNa2w5y3g_qOkOvBNM1g",
"appid":"wx1234567",
"offer_id":"12345678",
"ts":1507530737,
"zone_id":"1",
"pf":"android"
(2) Midas signature request parameters that are in key-value pairs are sorted in an ascending lexicographical order (ASCII code) by their names:
stringA="appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&ts=1507530737&zone_id=1"
(3) Join the URI, method, and Midas key:
stringSignTemp=stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&secret=zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u"
(4) Get the signature using the HMAC-SHA256 algorithm with Midas key as the key
sig=hmac_sha256(key,stringSignTemp)
="1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b"
Note: The key is the AppKey on the Midas platform
- mp_sig signature
(1) Weixin Open Platform signature request parameters
"access_token":"ACCESSTOKEN",
"openid":"odkx20ENSNa2w5y3g_qOkOvBNM1g",
"appid":"wx1234567",
"offer_id":"12345678",
"ts":1507530737,
"zone_id":"1",
"pf":"android",
"sig":"1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b"
(2) Weixin Open Platform signature request parameters that are in key-value pairs are sorted in an ascending lexicographical order (ASCII code) by their names:
stringA="access_token=ACCESSTOKEN&appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&sig=1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b&ts=1507530737&zone_id=1"
(3) Join the URI, method, and session_key:
stringSignTemp=stringA+"&org_loc=/cgi-bin/midas/getbalance&method=POST&session_key=V7Q38/i2KXaqrQyl2Yx9Hg=="
(4) Get the signature using the HMAC-SHA256 algorithm with session_key as the key
mp_sig=hmac_sha256(key,stringSignTemp)
="ff4c5bb39dea1002a8f03be0438724e1a8bcea5ebce8f221f9b9fea3bcf3bf76"