0

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;
        }
stackich
  • 3,607
  • 3
  • 17
  • 41

1 Answers1

1

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.

Kishan Bhatiya
  • 2,175
  • 8
  • 14
  • Kishan, thanks for long answer, I appreciate that. Ok I saw that `expires_date` is 3 mins longer than `purchase_date`, so that should be the only period where `is_trial_period` is `true` because 3mins = 1week of my free trial. But ~40mins later, the `trial period` is still true. Also, for your 3rd answer, seems like I can manage the sandbox. `Settings-appstore-sandbox account-manage.` – stackich Oct 12 '20 at 13:38
  • @stackich Sorry, I'm not able to see `Settings-appstore-sandbox account-manage` in my device. As you said "But ~40mins later, the trial period is still true", you canceled the subscription and then you checked and got `is_trial_period = true`? – Kishan Bhatiya Oct 12 '20 at 13:48
  • Can you add a JSON response to your question? – Kishan Bhatiya Oct 12 '20 at 13:55
  • I have edited my question. Added that part I was talking about. – stackich Oct 12 '20 at 13:58
  • @stackich on my side, I'm not able to manage subscriptions for the sandbox test user. Once I subscribed for a free trial of 7 days after 3 mins I got is_trial_period: false. I don't know how you set up a free trial for your product but you can check this: https://stackoverflow.com/questions/12297342/how-to-set-up-in-app-purchase-free-trial-period-in-ios-app – Kishan Bhatiya Oct 12 '20 at 14:16
  • thanks, I have already checked that but when I got the Subscribe alert after tapping `Subscribe` button, there it says that it is 1 week free trial and then 0.99$ motnhly. So that is ok. Voted up your answer because it helped me but maybe there is someone who will explain everything more clear to everyone. Do you maybe use any helper for easier handling there receipt json, Swifty StoreKit maybe? Because I tested with one sandbox user many times this subscription, and got tons of receipts in JSON, and it is hard to find the latest one because they are not sorted. – stackich Oct 12 '20 at 14:21
  • @stackich you have to take the last object from `latest_receipt_info` – Kishan Bhatiya Oct 13 '20 at 04:27