# midas.pay

Call this API at the server side. For more information, see Server API.

Deducts game currency. For Mini Games that have activated virtual payment, you can use this API to deduct game currency from a user. Because it is possible for the API call to time out or return a system failed message when the currency has actually been deducted, in the event of a system failure, you can call the API again using the same bill_no until another response is returned. This will not result in multiple deductions. You can also call the Cancel Payment API to cancel the deduction.

# Official Environment

POST https://api.weixin.qq.com/cgi-bin/midas/pay?access_token=ACCESS_TOKEN

# Sandbox Environment

POST https://api.weixin.qq.com/cgi-bin/midas/sandbox/pay?access_token=ACCESS_TOKEN

# Request Parameters

Attribute Type Default Required Description
openid string Yes The unique identifier of the user.
appid string Yes The appId of the Mini Program.
offer_id string Yes The offer_id assigned by Midas.
ts number Yes The UNIX timestamp, in seconds.
zone_id string Yes The region ID of the game server, as a string-type value. If the game does not have regions, the default value is zoneId ="1". If the application supports roles, the role ID is placed after the region ID connected by "_".
pf string Yes The platform, e.g. android.
user_ip string No The user’s public network IP address.
amt number Yes The amount of game currency to deduct, the value cannot be 0.
bill_no string Yes The order number, which must be globally unique within the service. Identical order numbers do not result in multiple deductions. Order numbers are composed of numbers, uppercase and lowercase English letters, underscores, and dashes and cannot exceed 63 characters.
pay_item string No The item name.
app_remark string No Remarks, which are written to the account statement.
sig string Yes A signature calculated from all the above parameters (up to 11 with optional parameters) + uri + Midas key using the HMAC-SHA256 algorithm. For details, see Signature Calculation Algorithm.
access_token string Yes The credentials used to call the API.
mp_sig string Yes A signature calculated from all the above parameters (up to 13 with optional parameters) + uri + session_key using the HMAC-SHA256 algorithm. For details, see Signature Calculation Algorithm.

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errcode number Error code
errmsg string Error message
bill_no string The order number, valid for 48 hours.
balance number The balance after deduction.
used_gen_amt number The gift amount of this deduction.

Valid values of errcode

Value Description Minimum Version
0 Request successful
-1 System is busy. Try again later.
90009 Incorrect mp_sig signature
90010 The user is not logged in or the session has expired.
90011 Incorrect sig signature
90012 Order already exists
90013 Insufficient balance
90017 You do not have permission to call this API.
90018 Parameter error

# POST data format: JSON

{
    "openid":"odkx20ENSNa2w5y3g_qOkOvBNM1g",
    "appid":"wx1234567",
    "offer_id":"12345678",
    "ts":1507530737,
    "zone_id":"1",
    "pf":"android",
    "amt":123,
    "bill_no":"BillNo_123",
    "sig":"f705c7351830125282ffc6d3c22c81db19b50a748f60f7c8f267e59152941d83",
    "mp_sig":"168704ac52eea6da27e0d76fd659cd8d628457dd680459a57365e17c0f40de4a"
}