consumePurchase API

This document focuses on the consumePurchase API used for server-side purchase consumption.

After you have verified the purchase, you should mark it as consumed.

Purchase consumption involves:

  • Assigning the purchased product to the user.
  • Notifying now.gg that the product has been consumed.

Important Information

  • This API must be called from your app backend server.

Base URL

 https://cloud-api.bluestacks.cn/

Request Path

 v2/order/consumePurchase

Request Method

 POST

Request Header

 'Authorization': '<payment_api_key_here>',
  'Content-Type': 'application/x-www-form-urlencoded'

Request Body

The following params should be included within the request body with consumePurchase API:

 
   purchaseToken=<nowgg_purchase_token>

Sample Consume Purchase Code

The following sample code illustrates the associated request using the consumePurchase API.

import requests

  url = "https://cloud-api.bluestacks.cn/v2/order/consumePurchase"

  payload = 'purchaseToken=nowgg-_purchase_token'
  headers = {
    'Authorization': 'payment_api_key_here',
    'Content-Type': 'application/x-www-form-urlencoded'
  }

  response = requests.request("POST", url, headers=headers, data=payload)

  print(response.text)

Important Information

Expected Response

The following is a sample response from the consumePurchase API.

 {  
   "success": true,
   "code": 0,
   "codeMsg": "success",
   "data": {}
 }

Response Params

Params Type Description
success boolean Returns success as true or false.
code int Returns 0 for success and non-zero for failure.
codeMsg string Returns msg related to error code.
data object Data returned as a response.

Error Code Mapping

Error Code Message Description
3800 ERROR_CONSUMING_PRODUCT There was an error consuming the product.
3900 INVALID_AUTHORIZATION_KEY The API Key provided for authorization is invalid.
3901 INVALID_PURCHASE_TOKEN The provided purchase token is invalid.
×
Text copied to clipboard
Link copied to clipbord
Questions? Please reach out to us at dev-support@now.gg