verifyPurchase

本节包含验证购买API(Verify Purchase API)的参考资料和示例请求代码片段。

描述

verifyPurchase API用于在将IAP产品分配给用户前,验证应用内产品的购买。

重要信息

  • 此API须从您应用的后端服务器调用。

基础URL(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)

以下参数须包含于 verifyPurchase API的请求主体中。

 
   purchaseToken=<nowgg_purchase_token>

示例请求

以下示例代码阐明了使用 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>'

重要信息


预期响应

以下是 verifyPurchase API的示例响应。

{
    "success": true,
    "code": 0,
    "codeMsg": "success",
    "data": {
      "purchaseTimeMillis": "1630529397125", // 此字段已弃用,请使用 purchaseTime 代替。
      "purchaseTime": "1630529397125",
      "purchaseState": 0,
      "consumptionState": 0,
      "developerPayload": "<developer_payload>",
      "orderId": "<orderId_here>",
      "kind": "nowgg#productPurchase",
      "regionCode": "US"
    }
  }

响应参数

 

参数 类型 描述
success boolean 返回是否成功,true或false。
code int 成功返回0,失败返回非0
codeMsg string 返回错误码关联的消息。(错误码参考此处
purchaseTimeMillis(弃用) string 购买产品的时间,以自纪元(epoch)以来的毫秒数表示。此字段已弃用,请使用 purchaseTime 代替
purchaseTime string 产品的购买时间,自纪元以来的秒数。
purchaseState int 订单的购买状态。可能的取值有:
0:未支付,1:已支付,2:失败
consumptionState int 应用内产品的消费状态。可能的取值有:
0:还未消费,1:已消费
developerPayload string 由开发者指定的字符串,包含订单的补充信息。
orderId string 关联每个应用内购买产品的订单ID(唯一交易标识符)。
kind string 购买的应用内产品的硬编码类型 nowgg#productPurchase
regionCode string 产品被授予时,用户的计费区域代码(ISO 3166-1 alpha-2)。

错误代码映射

错误代码 消息 描述
3900 INVALID_AUTHORIZATION_KEY The API Key provided for authorization is invalid.
3901 INVALID_PURCHASE_TOKEN The provided purchase token is invalid.
×
文本已复制到剪贴板
copyLinkText
有疑问?请通过以下方式联系我们: dev-support@now.gg