跳到主要内容

获取订阅数据 (V5)

重要

该方法仅适用于通过 Pay SDK 购买的订阅。

该方法允许您通过购买ID获取用户的订阅信息。

提示

如果您不知道从哪里开始,请参阅使用场景中的 操作指南

请求参数

对于正式(真实)订阅:

GET
https://public-api.rustore.ru/public/v5/subscription/{packageName}/{subscriptionId}/{purchaseId}

对于测试订阅,请使用单独的方法:

GET
https://public-api.rustore.ru/public/sandbox/v5/subscription/{packageName}/{subscriptionId}/{purchaseId}
属性类型描述是否必需位置示例
Public-TokenstringRuStore Public API 的 JWE 授权令牌。
如何获取授权令牌
headerN/A
packageNamestring应用程序包名称。pathcom.MashaAndTheBear.HairSalon
subscriptionIdstring订阅产品代码。
由开发者在 RuStore 控制台 中创建产品时指定。

如何创建订阅
pathdaily_sub
purchaseIdstringUUID 格式的购买 ID。可从 SDK 的购买结果、服务器通知或通过查询购买信息获取。path3aa0c7bd-964e-4562-b218-fe365adb4ae3

响应参数

属性类型描述是否必需位置示例
codestring响应代码。bodyOK / ERROR
messagestring响应代码的说明。bodyBad request
body{}object响应体。bodyN/A
timestampstring响应时间。body2024-07-29T12:00:00.000Z

body{}

属性类型描述是否必需示例
startTimeMillisstring订阅生效时间(自纪元以来的毫秒数)。1694431707000
expiryTimeMillisstring订阅到期时间(自纪元以来的毫秒数)。1697083457000
autoRenewingboolean订阅在当前期限到期后是否会自动续订。false
developerPayloadstring包含额外订单信息的字符串,您可以在 SDK 中确认购买时设置。External id = 1
priceCurrencyCodestring订阅价格的 ISO 4217 货币代码。RUB
priceAmountMicrosstring订阅价格。价格以微单位表示,其中 1,000,000 微单位代表一个货币单位。例如,如果订阅价格为 100 卢布,则 AmountMicros 价格为 100,000,000。749000000
countryCodestring订阅生效时用户的账单国家/地区代码。RU
paymentStatenumber订阅支付状态。可能的值:
0 — 等待支付
1 — 已收到付款;
2 — 免费试用。

对于已取消且到期的订阅不返回此字段。
否,仅对有效订阅返回1
cancelReasonnumber订阅被取消的原因。可能的值:
0 — 用户取消订阅
1 — 系统取消订阅,例如由于支付问题
3 — 开发者取消订阅
否,仅对状态为 CLOSED 的已取消订阅返回0
userCancellationTimeMillisstring用户取消订阅的时间(自纪元以来的毫秒数)。否,仅对状态为 CLOSED 的已取消订阅返回1697083457000
orderIdstring与订阅购买相关的最后一个账单的标识符。如果订阅有多个账单,则通过分隔符 ".." 将数量附加到 ID 后,从 0 开始计数。3352..1
acknowledgementStatestring订阅产品的确认状态。可能的值:
"PENDING" — 尚未确认;
"ACKNOWLEDGED" — 已确认;
"UNKNOWN" — 未知状态。
"ACKNOWLEDGED"
externalAccountIdstring外部应用程序中的用户标识符。否,仅当在开始购买时设置了 appUserId 时返回any_string
kindstring始终为 androidpublisher#subscriptionPurchaseandroidpublisher#subscriptionPurchase
purchaseTypenumber购买类型:0 — 测试订阅。否,仅对测试订阅返回,真实订阅不传递0
introductoryPriceInfo{}object订阅免费试用期的信息。此字段并不表示订阅当前处于免费试用期。否,仅当订阅配置了免费试用期时返回见下文
promoPriceInfo{}object订阅优惠期(首期优惠)的信息。仅当存在优惠期时填充。此字段并不表示订阅当前处于优惠期。否,仅当订阅配置了优惠期时返回见下文

introductoryPriceInfo{}

属性类型描述示例
introductoryPriceCurrencyCodestring优惠价格的 ISO-4217 货币代码。RUB
introductoryPriceAmountMicrosstring优惠期费用(以微单位计)。免费试用期值为 0。0
introductoryPricePeriodstring免费试用期时长,采用 ISO-8601 格式(P1WP1MP3MP6MP1Y)。P1Y
introductoryPriceCyclesstring优惠适用的计费周期数。1

promoPriceInfo{}

属性类型描述示例
promoPriceCurrencyCodestring促销价格的 ISO-4217 货币代码。RUB
promoPriceAmountMicrosstring促销期费用(以微单位计)。59900000
promoPricePeriodstring促销期时长,采用 ISO-8601 格式(P1WP1MP3MP6MP1Y)。P1Y
promoPriceCyclesstring促销优惠适用的计费周期数。1

成功响应示例

{
"code": "OK",
"message": "Successful result",
"body": {
"startTimeMillis": "1694431707000",
"expiryTimeMillis": "1697083457000",
"autoRenewing": true,
"developerPayload": "External id = 1",
"priceCurrencyCode": "RUB",
"priceAmountMicros": "749000000",
"countryCode": "RU",
"paymentState": 1,
"cancelReason": 0,
"userCancellationTimeMillis": "1697083457000",
"orderId": "3352..1",
"acknowledgementState": "ACKNOWLEDGED",
"externalAccountId": "any_string",
"kind": "androidpublisher#subscriptionPurchase",
"purchaseType": 0,
"introductoryPriceInfo": {
"introductoryPriceCurrencyCode": "RUB",
"introductoryPriceAmountMicros": "0",
"introductoryPricePeriod": "P1Y",
"introductoryPriceCycles": "1"
},
"promoPriceInfo": {
"promoPriceCurrencyCode": "RUB",
"promoPriceAmountMicros": "59900000",
"promoPricePeriod": "P1Y",
"promoPriceCycles": "1"
}
},
"timestamp": "2025-08-11T14:16:02.236Z"
}

错误响应示例

{
"code": "ERROR",
"message": "Bad request",
"body": null,
"timestamp": "2024-07-29T12:00:00.000Z"
}

错误列表

消息说明
Purchase not found未找到购买记录。请确保指定的购买 ID 正确。
Forbidden禁止访问。请检查授权令牌和请求参数。
Something went wrong出了点问题。请稍后重试或联系技术支持。