Confused with Apple's verifyReceipt JSON for Auto-renewable subscription

452 views Asked by At

I got the JSON using this url: https://sandbox.itunes.apple.com/verifyReceipt, so it is about Sandbox, not production.
I have some questions about this JSON because it is not very clear to me, and I think for lot of guys using IAP for the first time, too.

I wnat to remove some user's features if his Premium Account has ended(he cancelled subscription). In my case subscription is 1 week free trial, then $0.99 monthly.

  1. Which objects from this JSON should I check?
  2. Why expire_date is the same as purchase_date(Only few minutes difference)? Is it just up to Sandbox?
  3. I subscribed with my test user, got 7 days free trial, then I went to settings and cancelled the subscription, then opened app again and saw the object is_trial_period is set to true? Is it correct? I then changed my phone's date and made it about 10 days after purchase_date(trial period should be false then I think?) but the object is still true
  4. Also, I tested purchases with this phone many times and seems like I got all those receipts in my json, should I check only the last one?
  5. Can anyone clear the last object in array called 'status'. In my case it is 0 value.
  6. When I want to buy subscription, it is always the [environment:sandbox] version. Is this going to change automatically when the app goes to production?

    I think I have read all Apple's documentation and SO's questions and answers about auto-renewable IAPs, please don't paste links...

    I hope there is someone who understood this well to clear all these things about auto-renewable IAP.

Part of JSON, for @Kishan:
{
            "expires_date" = "2020-10-12 12:51:58 Etc/GMT";
            "expires_date_ms" = 1602507118000;
            "expires_date_pst" = "2020-10-12 05:51:58 America/Los_Angeles";
            "is_in_intro_offer_period" = false;
            "is_trial_period" = true;
            "original_purchase_date" = "2020-10-12 12:49:00 Etc/GMT";
            "original_purchase_date_ms" = 1602506940000;
            "original_purchase_date_pst" = "2020-10-12 05:49:00 America/Los_Angeles";
            "original_transaction_id" = 1000000725499801;
            "product_id" = "com.sleepfan.premium";
            "purchase_date" = "2020-10-12 12:48:58 Etc/GMT";
            "purchase_date_ms" = 1602506938000;
            "purchase_date_pst" = "2020-10-12 05:48:58 America/Los_Angeles";
            quantity = 1;
            "subscription_group_identifier" = 20691399;
            "transaction_id" = 1000000728899049;
            "web_order_line_item_id" = 1000000056417123;
        }
1

There are 1 answers

7
Kishan Bhatiya On BEST ANSWER

I think you forgot to read this document

  1. Which objects from this JSON should I check?

    You have to check latest_receipt_info from JSON which gives information about your latest transaction

  2. Why expire_date is the same as purchase_date(Only a few minutes difference)? Is it just up to Sandbox?

enter image description here

  1. I subscribed with my test user, got 7 days free trial, then I went to settings and canceled the subscription, then opened the app again and saw the object is_trial_period is set to true? Is it correct?

    As far as I know, from my experience, test users can't access the settings page to manage their subscriptions on their iPhone. Sandbox subscriptions will just cancel after 5 or 6 repetitions.

  2. Can anyone clear the last object in array called 'status'. In my case it is 0 value.

    Either 0 if the receipt is valid, or a status code if there is an error.

  3. When I want to buy a subscription, it is always the [environment: sandbox] version. Is this going to change automatically when the app goes to production?

    As far as I know, when you upload your product(which you want to sell as IAP) on iTunes connect, once your product approved, the message of the sandbox will be removed.