verifyPurchase

This section contains the API reference for Verify Purchase API and the sample request code segments.

Description

The verifyPurchase API is used to verify the in-app product purchase before assigning the IAP product to the user.

Important Information

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

Base URL

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

Request Path

 v2/seller/order/verifyPurchase

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 verifyPurchase API:

 
   purchaseToken=<nowgg_purchase_token>

Sample Request

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

import requests

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

  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)
curl --location 'https://cloud-api.bluestacks.cn/v2/seller/order/verifyPurchase' \
 --header 'Authorization: <payment_api_key_here>' \
 --header 'Content-Type: application/x-www-form-urlencoded' \
 --data-urlencode 'purchaseToken=<nowgg_purchase_token>'

Important Information


Expected Response

The following is a sample response from the verifyPurchase API.

{
    "success": true,
    "code": 0,
    "codeMsg": "success",
    "data": {
      "purchaseTimeMillis": "1630529397125", // This field has been deprecated, use purchaseTime instead.
      "purchaseTime": "1630529397125",
      "purchaseState": 0,
      "consumptionState": 0,
      "developerPayload": "<developer_payload>",
      "orderId": "<orderId_here>",
      "kind": "nowgg#productPurchase",
      "regionCode": "US"
    }
  }

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. (Provided here)
purchaseTimeMillis (DEPRECATED) string The time the product was purchased, in milliseconds since the epoch. This field has been deprecated, use purchaseTime instead.
purchaseTime string The time the product was purchased, in seconds since the epoch.
purchaseState int The purchase state of the order. Possible values are:
0: Unpaid, 1: Paid, 2: Failed
consumptionState int The consumption state of the in-app product. Possible values are:
0: Yet to be consumed, 1: Consumed
developerPayload string A developer-specified string containing supplemental information about an order.
orderId string The order ID (Unique transaction identifier) associated with every in-app purchase product.
kind string The kind of in-app product purchased with a hardcoded type nowgg#productPurchase.
regionCode string ISO 3166-1 alpha-2 billing region code of the user at the time the product was granted.

Error Code Mapping

Error Code Message Description
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