Gilles
Gilles

Reputation: 41

iOS auto renewing subscription (sandbox)

I am currently testing my code for auto renewing subscriptions. In most cases it works as expected. But, from times to times, I see unexpected results.

I buy a new subscription, I get a receipt (transaction_id = 1000000075229775). Just after receiving this receipt (before the expiration date is reached), I send this receipt to sandbox.itunes.apple.com and it returns a new receipt with a different transaction ID (latest_receipt_info with transaction_id = 1000000075229779). I was not expecting to get this new receipt (with a different transaction ID) before the first expiration date is reached. Here is an extract of both receipts. Note that the expiration dates are very close (less than one second difference).

Could you please 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)

Upvotes: 4

Views: 1556

Answers (1)

Nicholas Hart
Nicholas Hart

Reputation: 1724

Take a look at the original_transaction_id and don't worry about the transaction_id. You may get a different transaction_id under certain circumstances (eg: when restoring a purchase). I don't think all of the details of when a transaction_id may change are documented.

According to Apple's documentation on auto-renewable subscription (here: https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html#//apple_ref/doc/uid/TP40008267-CH4-SW2 ):

original_transaction_id - This holds the transaction identifier for the initial purchase. All subsequent renewals of this subscription and recovered transactions all share this identifier.

This id will always reflect the id of the transaction to initially make the purchase.

Upvotes: 1

Related Questions