IOS auto-renew subscription (sandbox)

I am currently testing my code to automatically renew my subscription. In most cases, it works as expected. But from time to time I see unexpected results.

I buy a new subscription, get a receipt (transaction_id = 1000000075229775). After receiving this receipt (before the expiration date), I send this receipt to sandbox.itunes.apple.com and return a new receipt with a different transaction identifier (last_receipt_info with transaction_id = 1000000075229779). I did not expect to receive this new receipt (with a different transaction identifier) ​​before the first expiration date is reached. Here is an excerpt from both receipts. Please note that the expiration dates are very close (the difference is less than one second).

Could you help me understand what is happening?

Thanks.

["receipt"]=>object(stdClass)#14 (19) { ["original_purchase_date_pst"]=>string(39) "2012-12-03 08:20:49 America/Los_Angeles" ["unique_identifier"]=>string(40) "af430ef98d6bdbbf92ed34e4addec2e834bc25d6" ["original_transaction_id"]=>string(16) "1000000059708880" ["expires_date"]=>string(13) "1369421691100" ["transaction_id"]=>string(16) "1000000075229775" ["quantity"]=>string(1) "1" ["expires_date_formatted"]=>string(27) "2013-05-24 18:54:51 Etc/GMT" ["purchase_date"]=>string(27) "2013-05-24 18:49:51 Etc/GMT" ["purchase_date_ms"]=>string(13) "1369421391100" ["original_purchase_date"]=>string(27) "2012-12-03 16:20:49 Etc/GMT" ["original_purchase_date_ms"]=>string(13) "1354551649000" ... } ["latest_receipt_info"]=>object(stdClass)#12 (19) { ["original_purchase_date_pst"]=>string(39) "2012-12-03 08:20:49 America/Los_Angeles" ["unique_identifier"]=>string(40) "345fade172e62c805d0d354edda97575fc9b9d50" ["original_transaction_id"]=>string(16) "1000000059708880" ["expires_date"]=>string(13) "1369421691000" ["transaction_id"]=>string(16) "1000000075229779" ["quantity"]=>string(1) "1" ["expires_date_formatted"]=>string(27) "2013-05-24 18:54:51 Etc/GMT" ["purchase_date"]=>string(27) "2013-05-24 18:49:51 Etc/GMT" ["purchase_date_ms"]=>string(13) "1369421391000" ["original_purchase_date"]=>string(27) "2012-12-03 16:20:49 Etc/GMT" ["original_purchase_date_ms"]=>string(13) "1354551649000" ... } ["status"]=>int(0) 
+4
source share
1 answer

Take a look at original_transaction_id and don't worry about transaction_id. You may receive another transaction in certain circumstances (for example: when restoring a purchase). I do not think that all the details when transaction_id can change are documented.

According to Apple's Automatic Renewable Subscription documentation (here: https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html#//apple_ref/doc/uid/TP40008 -SW2 ):

original_transaction_id is the transaction identifier for the initial purchase. All subsequent updates to this subscription and restored transactions use this identifier.

This identifier will always display the transaction identifier to initially make a purchase.

+1
source

Source: https://habr.com/ru/post/1482636/


All Articles