REST Resource: purchases.productsv2

资源:ProductPurchaseV2

ProductPurchaseV2 资源指示用户应用内商品购买的状态。

JSON 表示法
{
  "productLineItem": [
    {
      object (ProductLineItem)
    }
  ],
  "kind": string,
  "purchaseStateContext": {
    object (PurchaseStateContext)
  },
  "testPurchaseContext": {
    object (TestPurchaseContext)
  },
  "orderId": string,
  "obfuscatedExternalAccountId": string,
  "obfuscatedExternalProfileId": string,
  "regionCode": string,
  "purchaseCompletionTime": string,
  "acknowledgementState": enum (AcknowledgementState)
}
字段
productLineItem[]

object (ProductLineItem)

包含 ProductPurchaseV2 的商品级信息。

kind

string

此类型代表 androidpublisher 服务中的 ProductPurchaseV2 对象。

purchaseStateContext

object (PurchaseStateContext)

有关购买交易的购买状态的信息。

testPurchaseContext

object (TestPurchaseContext)

与测试购买交易相关的信息。此值仅针对测试购买交易设置。

orderId

string

与应用内商品购买相关的订单 ID。如果购买交易未关联任何订单,则可能不会设置此值。

obfuscatedExternalAccountId

string

与您的应用中的用户账号唯一关联且经过混淆处理的 ID。仅当购买时使用 https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid 指定的情况下才存在。

obfuscatedExternalProfileId

string

与您的应用中的用户个人资料唯一关联且经过混淆处理的 ID。仅当购买时使用 https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid 指定的情况下才存在。

regionCode

string

授予商品使用权时用户账单邮寄地址所在地区的代码,采用 ISO 3166-1 alpha-2 格式。

purchaseCompletionTime

string (Timestamp format)

购买成功的时间,即 PurchaseState 更改为 PURCHASED 的时间。此字段只有在付款完成后才会显示。例如,如果用户发起了待处理的交易 (https://developer.android.com/google/play/billing/integrate#pending),则只有在用户成功完成完成交易所需的步骤后,此字段才会填充。

采用 RFC 3339 标准,生成的输出将始终进行 Z 规范化(即转换为 UTC 零时区格式并在末尾附加 Z),并使用 0、3、6 或 9 个小数位。不带“Z”的偏差时间也是可以接受的。示例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z""2014-10-02T15:01:23+05:30"

acknowledgementState

enum (AcknowledgementState)

仅限输出。相应购买交易的确认状态。

PurchaseStateContext

有关购买状态的上下文。

JSON 表示法
{
  "purchaseState": enum (PurchaseState)
}
字段
purchaseState

enum (PurchaseState)

仅限输出。相应购买交易的购买状态。

PurchaseState

可能的购买状态。

枚举
PURCHASE_STATE_UNSPECIFIED 未指定购买状态。切勿设置此值。
PURCHASED 购买成功。
CANCELLED 交易已取消。
PENDING 购买交易处于待处理状态,尚未完成。如需详细了解如何处理待处理的购买交易,请参阅 https://developer.android.com/google/play/billing/integrate#pending

TestPurchaseContext

有关测试购买的上下文。

JSON 表示法
{
  "fopType": enum (FopType)
}
字段
fopType

enum (FopType)

测试购买的 FOP 类型。

FopType

可能的 fop 类型。

枚举
FOP_TYPE_UNSPECIFIED 未指定 FOP 类型。切勿设置此值。
TEST 购买交易是使用测试卡完成的。

ProductLineItem

包含 ProductPurchaseV2 的商品级信息。

JSON 表示法
{
  "productId": string,
  "productOfferDetails": {
    object (ProductOfferDetails)
  }
}
字段
productId

string

所购买商品的 ID(例如:“monthly001”)。

productOfferDetails

object (ProductOfferDetails)

相应商品的优惠详细信息。

ProductOfferDetails

与购买订单项相关的优惠详情。

JSON 表示法
{
  "offerTags": [
    string
  ],
  "offerId": string,
  "purchaseOptionId": string,
  "rentOfferDetails": {
    object (RentOfferDetails)
  },
  "offerToken": string,
  "quantity": integer,
  "refundableQuantity": integer,
  "consumptionState": enum (ConsumptionState)
}
字段
offerTags[]

string

与优惠相关联的最新优惠标记。这包括从购买选项继承的标记。

offerId

string

优惠 ID。仅针对优惠存在。

purchaseOptionId

string

购买选项 ID。

rentOfferDetails

object (RentOfferDetails)

有关租金优惠的优惠详情。此值仅会针对租赁订单项进行设置。

offerToken

string

用于购买相应购买交易订单项的每交易优惠令牌。

quantity

integer

与应用内商品购买相关的数量。

refundableQuantity

integer

符合退款条件的数量,即尚未退款的数量。该值反映基于数量的部分退款和全额退款。

consumptionState

enum (ConsumptionState)

仅限输出。相应购买交易的消耗状态。

RentOfferDetails

此类型没有字段。

与租赁订单项相关的优惠详情。

ConsumptionState

可能的消费状态。

枚举
CONSUMPTION_STATE_UNSPECIFIED 未指定使用情况状态。切勿设置此值。
CONSUMPTION_STATE_YET_TO_BE_CONSUMED 尚未消耗。
CONSUMPTION_STATE_CONSUMED 已消耗。

AcknowledgementState

一次性商品的确认状态。

枚举
ACKNOWLEDGEMENT_STATE_UNSPECIFIED 未指定确认状态。
ACKNOWLEDGEMENT_STATE_PENDING 购买交易尚未确认。
ACKNOWLEDGEMENT_STATE_ACKNOWLEDGED 购买交易已确认。

方法

getproductpurchasev2

检查应用内商品的购买和消耗状态。

错误代码

此资源的操作会返回以下 HTTP 错误代码:

错误代码 原因 分辨率
5xx Google Play 服务器中的一般错误。 请重试您的请求。

如果问题仍然存在,请与您的 Google Play 客户经理联系,或提交支持请求。 不妨查看 Play 状态信息中心,了解是否存在任何已知的中断。

409 并发更新错误。

尝试更新正在更新的对象。例如,通过同时调用 Play 结算库的 acknowledgePurchase() 方法和 Play Developer API 的 purchases.products.acknowledge 来确认购买交易。

请重试您的请求。