Google Play订阅查询接口未返回cancelSurveyResult字段
对接背景
我们正在为Android应用内购买实现服务器到服务器通知机制。
对于每一个用户触发的事件(购买、取消等),我们都会按照Google Play的RTDN参考文档接收并解析实时开发者通知。
解析每一条通知后,我们会按照Google Play Developer API的purchases.subscriptions规范,向Play商店提交订阅信息进行校验。
我们预期返回的JSON响应应当对应用户执行的操作。例如,接收到SUBSCRIPTION_PURCHASED通知后,校验响应如下:
{ "startTimeMillis": "1615196368232", "expiryTimeMillis": "1615196783756", "autoRenewing": true, "priceCurrencyCode": "EUR", "priceAmountMicros": "3990000", "countryCode": "DE", "developerPayload": "", "paymentState": 1, "orderId": "GPA.3391-4718-6063-47314", "purchaseType": 0, "acknowledgementState": 1, "kind": "androidpublisher#subscriptionPurchase" }
异常表现
当用户通过Play商店应用取消订阅、触发SUBSCRIPTION_CANCELED通知时,问题出现,此时校验响应如下:
{ "startTimeMillis": "1615196368232", "expiryTimeMillis": "1615196664327", "autoRenewing": false, "priceCurrencyCode": "EUR", "priceAmountMicros": "3990000", "countryCode": "DE", "developerPayload": "", "cancelReason": 0, "userCancellationTimeMillis": "1615196648401", "orderId": "GPA.3391-4718-6063-47314", "purchaseType": 0, "acknowledgementState": 1, "kind": "androidpublisher#subscriptionPurchase" }
响应中新增了部分用于标识取消行为的字段:
"cancelReason": integer, "userCancellationTimeMillis": string,
这部分符合预期、运行正常。但仍然缺失部分取消相关字段,具体为SubscriptionCancelSurveyResult,其结构定义如下:
"cancelSurveyResult": { "cancelSurveyReason": integer, "userInputCancelReason": string }
文档对userInputCancelReason和userCancellationTimeMillis的说明均为:
仅当cancelReason为0时存在
如附件截图所示,cancelReason已经为0,但响应中仅存在userCancellationTimeMillis字段,为什么没有返回cancelSurveyResult和userInputCancelReason?
应用可通过Google Play Developer API返回的订阅资源中的cancelReason判断订阅取消原因(例如用户主动取消或账单异常)。若订阅为用户主动取消,应用可通过cancelSurveyResult字段获知用户的取消原因。
以上问题对应Google Play订阅取消流程的官方功能说明。
内容的提问来源于stack exchange,提问作者appoll

