# midasPay

本接口应在后端服务器调用

It enables you to deduct a user's remaining game coins for the Mini Game with virtual payment activated. There is a possibility that the API calling times out or a system failure is returned but the game coins are deducted. In the case, use the same bill_no to repeatedly call the API until system failure is not returned and deduction will not be made repeatedly. Alternatively, call the payment canceling API to cancel this deduction.

# Formal 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

# 请求Parameter

property type default value optional description version
openid string yes User unique identifier
appid string yes Mini Program appId
offer_id string yes offer_id distributed by Midas
ts number yes UNIX timestamp in seconds
zone_id string yes Game server zone ID; if the game servers are not classified by zones, the default zoneId ="1", and it is string type. If the app supports selecting role, the zone ID is followed by role ID by using "_".
pf string yes Platform: Android
user_ip string no User's Internet IP
amt number yes Number of game coins deducted, which cannot be 0
bill_no string yes Order ID, which requires unique value; recurring payment will not occur for the same ID It should be no more than 63 characters including numbers, uppercase and lowercase letters_- *@
pay_item string no Prop name
app_remark string no Remarks. They will be recorded in the account statement
sig string yes All parameters above (up to 11 including optional parameters) +uri+Midas key are signed by HMAC-SHA256. For details, please see Midas payment signature algorithm
access_token string yes Proof of interface call
mp_sig string yes All parameters above (up to 13 including optional parameters) +uri+session_key are signed by HMAC-SHA256. For details, please see Midas payment signature algorithm

# Return

# Object

Returned JSON data package

property type description version
errcode number Error code
errmsg string Error message
bill_no string Order number, which expires in 48 hours
balance number Balance after the deduction
used_gen_balance number Deduction is made from the gift game coins balance this time

errcode 's struct

value description
0 Request successful
-1 System busy, the developer is requested to try again later
90009 mp_sig signature error
90010 User has not logged in, or login status has expired
90011 sig signature error
90012 Order already exists
90013 Balance is insufficient
90017 No interface calling permissions
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"
}