2

I'm encountering an issue while debugging Apple's in-app purchase receipt. It seems the field "is_trial_period" stays true although the purchase has already expired. To my understanding Apple defines short periods for debugging subscriptions, as seen here:

Testing In-App Purchase Products

Do those times apply for trail periods as well?

mahal tertin
  • 3,239
  • 24
  • 41
gerbil
  • 859
  • 7
  • 26
  • In the sandbox environment is_trial_period won't work. This will only work in production and by the way in sandbox apple will never issue a trial period. – Jad Nov 15 '17 at 07:51
  • @Jad as it seems the is_trial_period works and appear in a separate receipt as seen in the answer below. – gerbil Nov 15 '17 at 10:54
  • @Jad I think that used to be true but now Sandbox is issuing trial's correctly. – Jacob Eiting Nov 16 '17 at 04:40

1 Answers1

5

This is because Apple issues a separate transaction for the trial period.

Here is an example excerpt of a receipt from Apple:

"latest_receipt_info": [
    {
        "quantity": "1",
        "product_id": "onemonth_freetrial",
        "transaction_id": "1000000328795138",
        "original_transaction_id": "1000000328795138",
        "purchase_date": "2017-08-29 23:13:52 Etc/GMT",
        "purchase_date_ms": "1504048432000",
        "purchase_date_pst": "2017-08-29 16:13:52 America/Los_Angeles",
        "original_purchase_date": "2017-08-29 23:13:53 Etc/GMT",
        "original_purchase_date_ms": "1504048433000",
        "original_purchase_date_pst": "2017-08-29 16:13:53 America/Los_Angeles",
        "expires_date": "2017-08-29 23:16:52 Etc/GMT",
        "expires_date_ms": "1504048612000",
        "expires_date_pst": "2017-08-29 16:16:52 America/Los_Angeles",
        "web_order_line_item_id": "1000000036088032",
        "is_trial_period": "true"
    },
    {
        "quantity": "1",
        "product_id": "onemonth_freetrial",
        "transaction_id": "1000000328796241",
        "original_transaction_id": "1000000328795138",
        "purchase_date": "2017-08-29 23:16:52 Etc/GMT",
        "purchase_date_ms": "1504048612000",
        "purchase_date_pst": "2017-08-29 16:16:52 America/Los_Angeles",
        "original_purchase_date": "2017-08-29 23:13:53 Etc/GMT",
        "original_purchase_date_ms": "1504048433000",
        "original_purchase_date_pst": "2017-08-29 16:13:53 America/Los_Angeles",
        "expires_date": "2017-08-29 23:21:52 Etc/GMT",
        "expires_date_ms": "1504048912000",
        "expires_date_pst": "2017-08-29 16:21:52 America/Los_Angeles",
        "web_order_line_item_id": "1000000036088033",
        "is_trial_period": "false"
    }
]

The latest_receipt_info field will contain an array for every 'renewal' or 'transaction'. The way Apple handles free trials is by issuing one transaction that will always have is_trial_period be true, and subsequent non-trial renewal have is_trial_period be false. When you handle the receipt just make sure you are looking at the latest transaction by purchase_date or expiration_date which should represent the latest renewal and the one you should base unlocking content off of.

And regarding length in sandbox, if your IAP product has a free trial, the sandbox environment will issue one trial period, and 5 renewals, for six renewals total.

Jacob Eiting
  • 1,004
  • 6
  • 9
  • Does this two-receipt style work for sandbox and production in same manner? – gerbil Nov 15 '17 at 08:00
  • Its actually separate transactions in one receipt, not separate receipts. And yes, sandbox and production behave the same way, the only difference is the time periods. – Jacob Eiting Nov 16 '17 at 04:34
  • 2
    I'm trying to buy a subscription with a free trial, in sandbox environment, but when i try to purchase it, the popup doesn't tell anything about the free trial period, and in the receipt i see only a transaction. I've created a new sandbox user after i've set the free trial in the subscription – blackstar26 Apr 16 '20 at 09:42