# midas.present

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

Gifts game currency to a user. For Mini Games that have activated virtual currency, you can use this API to gifts game currency to a user.

# Official Environment

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

# Sandbox Environment

POST https://api.weixin.qq.com/cgi-bin/midas/sandbox/present?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.
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.
present_counts number Yes The amount of game currency to gift, the value cannot be 0.
sig string Yes A signature calculated from all the above parameters (up to 9 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 11 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
balance number The balance after the gift.
bill_no string The number of the order to gift game currency.

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
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",
    "present_counts":233,
    "bill_no":"BillNo_123",
    "sig":"e53e5241bbb014b3a9fcc221d66fecab8734b53fe94d7a8c65180e175e29f443",
    "mp_sig":"39271a12d8d56b0395981a0990a9e75ae239c54f419cb6235399fe70acf8ccfb"
}