I have a question regarding the receipt format for In App Purchases.
The main receipt object has a field called Subscription Expiration Date
.
But what if an app has multiple types of renewing subscriptions, what will this field reflect then?
It is called Subscription Expiration Date
in the documentation, however if you read below the actual name of the json key is expires_date
, just wanted to point that out before you go on a search hunt not finding it in your app.
To answer your question, you will see that on the documentation, that specific key Subscription Expiration Date
is listed under a heading called In-App Purchase Receipt Fields
. That means, and I can confirm from my own experience, that this key is present for every In-App purchase of a subscription individually and every renewal thereon forth. That means there can be multiple purchases, each as their own entry into the receipt-json, with each having a expires_date
.
If you want to use that key for validation, the receipt will have a request date sent from the apple server. Use that date to see if one of those subscriptions is still running.
Hope this helps.
Edit: Here's an example of an actual parsed receipt for orientation. Note That I have removed some ids for safety. Here you see a receipt where at the top you see receipt specific information, followed by a one time purchase and then a yearly subscription that was renewed about 4 times.
["original_purchase_date_pst": Optional(2013-08-01 00:00:00
America/Los_Angeles),
"bundle_id": Optional(yourAppBundleId),
"receipt_creation_date_pst": Optional(2018-12-20 02:20:38 America/Los_Angeles),
"receipt_type": Optional(ProductionSandbox),
"app_item_id": Optional(0), "application_version": Optional(2),
"request_date_pst": Optional(2018-12-20 02:20:41 America/Los_Angeles),
"original_purchase_date_ms": Optional(1375340400000),
"receipt_creation_date_ms": Optional(1545301238000),
"in_app": Optional(<__NSArrayI 0x283b736b0>(
{
"is_trial_period" = false;
"original_purchase_date" = "2018-12-07 12:00:43 Etc/GMT";
"original_purchase_date_ms" = 1544184043000;
"original_purchase_date_pst" = "2018-12-07 04:00:43 America/Los_Angeles";
"original_transaction_id" = XXXXXXXXXXXXX;
"product_id" = "someSinglePurchase";
"purchase_date" = "2018-12-07 12:00:43 Etc/GMT";
"purchase_date_ms" = 1544184043000;
"purchase_date_pst" = "2018-12-07 04:00:43 America/Los_Angeles";
quantity = 1;
"transaction_id" = 10000XXXXXXXXX;
},
{
"expires_date" = "2018-12-07 13:01:21 Etc/GMT";
"expires_date_ms" = 1544187681000;
"expires_date_pst" = "2018-12-07 05:01:21 America/Los_Angeles";
"is_in_intro_offer_period" = false;
"is_trial_period" = false;
"original_purchase_date" = "2018-12-07 12:01:22 Etc/GMT";
"original_purchase_date_ms" = 1544184082000;
"original_purchase_date_pst" = "2018-12-07 04:01:22 America/Los_Angeles";
"original_transaction_id" = 10000XXXXXXXXX;
"product_id" = "yearlySubscription";
"purchase_date" = "2018-12-07 12:01:21 Etc/GMT";
"purchase_date_ms" = 1544184081000;
"purchase_date_pst" = "2018-12-07 04:01:21 America/Los_Angeles";
quantity = 1;
"transaction_id" = 10000XXXXXXXXX;
"web_order_line_item_id" = 10000XXXXXXXXX;
},
{
"expires_date" = "2018-12-07 14:01:35 Etc/GMT";
"expires_date_ms" = 1544191295000;
"expires_date_pst" = "2018-12-07 06:01:35 America/Los_Angeles";
"is_in_intro_offer_period" = false;
"is_trial_period" = false;
"original_purchase_date" = "2018-12-07 12:01:22 Etc/GMT";
"original_purchase_date_ms" = 1544184082000;
"original_purchase_date_pst" = "2018-12-07 04:01:22 America/Los_Angeles";
"original_transaction_id" = 10000XXXXXXXXX;
"product_id" = "yearlySubscription";
"purchase_date" = "2018-12-07 13:01:35 Etc/GMT";
"purchase_date_ms" = 1544187695000;
"purchase_date_pst" = "2018-12-07 05:01:35 America/Los_Angeles";
quantity = 1;
"transaction_id" = 10000XXXXXXXXX;
"web_order_line_item_id" = 10000XXXXXXXXX;
},
{
"expires_date" = "2018-12-07 15:01:35 Etc/GMT";
"expires_date_ms" = 1544194895000;
"expires_date_pst" = "2018-12-07 07:01:35 America/Los_Angeles";
"is_in_intro_offer_period" = false;
"is_trial_period" = false;
"original_purchase_date" = "2018-12-07 12:01:22 Etc/GMT";
"original_purchase_date_ms" = 1544184082000;
"original_purchase_date_pst" = "2018-12-07 04:01:22 America/Los_Angeles";
"original_transaction_id" = 10000XXXXXXXXX;
"product_id" = "yearlySubscription";
"purchase_date" = "2018-12-07 14:01:35 Etc/GMT";
"purchase_date_ms" = 1544191295000;
"purchase_date_pst" = "2018-12-07 06:01:35 America/Los_Angeles";
quantity = 1;
"transaction_id" = 10000XXXXXXXXX;
"web_order_line_item_id" = 10000XXXXXXXXX;
}