3

我正在开发一个提供自动续订订阅的应用程序。

subscription.A如果用户已购买(7 天后更新),我不知道在验证收据哈希时来自 Apple 的 JSON 响应会是什么样子,然后转到他的 iTunes 设置并将其更改为subscription.B从同一个订阅系列更新。

因为subscription.A更新几次后会是这样的:

...
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494389", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 11:42:01 Etc/GMT", "purchase_date_ms":"1431430921000", "purchase_date_pst":"2015-05-12 04:42:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 11:40:03 Etc/GMT", "original_purchase_date_ms":"1431430803000", "original_purchase_date_pst":"2015-05-12 04:40:03 America/Los_Angeles", "expires_date":"2015-05-12 11:47:01 Etc/GMT", "expires_date_ms":"1431431221000", "expires_date_pst":"2015-05-12 04:47:01 America/Los_Angeles", "web_order_line_item_id":"100000002973145", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494368", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 11:37:01 Etc/GMT", "purchase_date_ms":"1431430621000", "purchase_date_pst":"2015-05-12 04:37:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 11:37:02 Etc/GMT", "original_purchase_date_ms":"1431430622000", "original_purchase_date_pst":"2015-05-12 04:37:02 America/Los_Angeles", "expires_date":"2015-05-12 11:42:01 Etc/GMT", "expires_date_ms":"1431430921000", "expires_date_pst":"2015-05-12 04:42:01 America/Los_Angeles", "web_order_line_item_id":"100000002973145", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494496", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 11:47:01 Etc/GMT", "purchase_date_ms":"1431431221000", "purchase_date_pst":"2015-05-12 04:47:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 11:45:32 Etc/GMT", "original_purchase_date_ms":"1431431132000", "original_purchase_date_pst":"2015-05-12 04:45:32 America/Los_Angeles", "expires_date":"2015-05-12 11:52:01 Etc/GMT", "expires_date_ms":"1431431521000", "expires_date_pst":"2015-05-12 04:52:01 America/Los_Angeles", "web_order_line_item_id":"100000002973147", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494517", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 11:52:01 Etc/GMT", "purchase_date_ms":"1431431521000", "purchase_date_pst":"2015-05-12 04:52:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 11:50:11 Etc/GMT", "original_purchase_date_ms":"1431431411000", "original_purchase_date_pst":"2015-05-12 04:50:11 America/Los_Angeles", "expires_date":"2015-05-12 11:57:01 Etc/GMT", "expires_date_ms":"1431431821000", "expires_date_pst":"2015-05-12 04:57:01 America/Los_Angeles", "web_order_line_item_id":"100000002973149", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494558", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 11:57:01 Etc/GMT", "purchase_date_ms":"1431431821000", "purchase_date_pst":"2015-05-12 04:57:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 11:55:03 Etc/GMT", "original_purchase_date_ms":"1431431703000", "original_purchase_date_pst":"2015-05-12 04:55:03 America/Los_Angeles", "expires_date":"2015-05-12 12:02:01 Etc/GMT", "expires_date_ms":"1431432121000", "expires_date_pst":"2015-05-12 05:02:01 America/Los_Angeles", "web_order_line_item_id":"100000002973151", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.A", "transaction_id":"100000015494630", "original_transaction_id":"100000015494368", "purchase_date":"2015-05-12 12:02:01 Etc/GMT", "purchase_date_ms":"1431432121000", "purchase_date_pst":"2015-05-12 05:02:01 America/Los_Angeles", "original_purchase_date":"2015-05-12 12:00:29 Etc/GMT", "original_purchase_date_ms":"1431432029000", "original_purchase_date_pst":"2015-05-12 05:00:29 America/Los_Angeles", "expires_date":"2015-05-12 12:07:01 Etc/GMT", "expires_date_ms":"1431432421000", "expires_date_pst":"2015-05-12 05:07:01 America/Los_Angeles", "web_order_line_item_id":"100000002973153", "is_trial_period":"false"}, 
...

当订阅延长到不同的持续时间时,我认为它当然会有 product_id subscription.B,但它会有一个 new original_transaction_id,还是仍会连接到(在这种情况下)100000015494368

由于我无法通过沙盒测试用户访问 iTunes 设置,因此我不知道如何对其进行测试,也无法在文档中找到明确的说明。

4

1 回答 1

0

以下是收据验证响应中显示的两次购买不同持续时间的自动续订订阅的方式:

{"quantity":"1", "product_id":"subscription.A", "transaction_id":"1000000276920213", "original_transaction_id":"1000000276916420", "purchase_date":"2017-02-25 14:34:05 Etc/GMT", "purchase_date_ms":"1488033245000", "purchase_date_pst":"2017-02-25 06:34:05 America/Los_Angeles", "original_purchase_date":"2017-02-25 13:03:10 Etc/GMT", "original_purchase_date_ms":"1488027790000", "original_purchase_date_pst":"2017-02-25 05:03:10 America/Los_Angeles", "expires_date":"2017-02-25 14:39:05 Etc/GMT", "expires_date_ms":"1488033545000", "expires_date_pst":"2017-02-25 06:39:05 America/Los_Angeles", "web_order_line_item_id":"1000000034442002", "is_trial_period":"false"}, 
{"quantity":"1", "product_id":"subscription.B", "transaction_id":"1000000276964864", "original_transaction_id":"1000000276916420", "purchase_date":"2017-02-26 09:05:14 Etc/GMT", "purchase_date_ms":"1488099914000", "purchase_date_pst":"2017-02-26 01:05:14 America/Los_Angeles", "original_purchase_date":"2017-02-25 13:03:10 Etc/GMT", "original_purchase_date_ms":"1488027790000", "original_purchase_date_pst":"2017-02-25 05:03:10 America/Los_Angeles", "expires_date":"2017-02-26 09:08:14 Etc/GMT", "expires_date_ms":"1488100094000", "expires_date_pst":"2017-02-26 01:08:14 America/Los_Angeles", "web_order_line_item_id":"1000000034442107", "is_trial_period":"false"}

如您所见,它们确实显示为已连接,共享相同original_transaction_idoriginal_purchase_date. 我不是 100% 确定,但我认为即使第二次订阅是在第一次订阅被取消后购买的也是如此。

于 2017-03-01T18:54:34.113 回答