How to test for free trial in sandbox?
Asked Answered
D

0

7

I have a one year auto-renewable subscription in my app with a three day free trial. According to Apple, while testing in the sandbox, a one year subscription is equivalent to one hour but it says nothing about how long the free trial is. Add to this, when I'm testing and I sign-up for the free trial, the receipt doesn't list a separate transaction for a free trial, it simply lists the first hour long subscription:

transactionIdentifier: 1000000408088544
purchaseDate: Sat Jun 16 19:58:59 2018
originalTransactionIdentifier: 1000000408088544
originalPurchaseDate: Sat Jun 16 19:59:00 2018
subscriptionExpirationDate : Sat Jun 16 20:58:59 2018

I could just check and see if the current date is less or greater than originalPurchaseDate plus three days, but shouldn't another transaction be generated when the free trial ends and the subscription is automatically renewed? That's not happening in the sandbox so I'm unsure of the behavior to expect outside of the sandbox.

In the receipt format documentation, under "Subscription Trial Period", there is a "is_trial_period" key stored in the receipt, however I am validating the receipt locally and believe that I am unable to obtain this value since there is no ASN.1 Field Type and it seems to be stored in JSON when doing server validation.

Does anyone have any clue how to test this or know what the behavior is supposed to be?

Desmond answered 17/6, 2018 at 6:53 Comment(9)
I'm wondering the same thing. There's an ASN.1 field is_in_intro_offer_period (1719) and it appears to be the same as the JSON field is_trial_period, but the documentation is somewhat vague on exactly why there are 2 similar fields here and whether and how they differ.Ferryboat
@SamiSamhuri i put in a DTS ticket, I'll let you know what they say.Desmond
Awesome, thanks! For now we're doing this logic all on the server but that's not a great solution for everyone.Ferryboat
@SamiSamhuri They got back to me and said in the sandbox, if you're offering a one year subscription (which in the sandbox is one hour), then the first hour will be the free trial. Are you able to verify this by getting the "is_trial_period" from the server?Desmond
I do see that on the server side and it all seems to work. There doesn't appear to be any way to get this info without a server though. That seems like a big hint that everyone should really be using a server for subscriptions.Ferryboat
@SamiSamhuri Thanks for letting me know. Yeah it does seem that way.Desmond
Hi, I am trying out the same and falling into this problem where is_in_intro_offer_period (1719) is always 0 even though the StoreKit prompts display 'starting free trial'. I am only using local receipt validation at the moment. Since StoreKit is already keeping track of this, is it safe to assume that the first IAP (with this productID) in a receipt is going to be a 'free trial', so if IAPs count > 1, then we're not in a free trial? That should be enough to display the correct UI. Would it be different in production?Delwyn
@ZS yes, this is what DTS told me. First transaction on receipt in sandbox is the free trial.Desmond
Was there any more info about what field 1719 is for? I would have expected that it should be indicative of whether user is in free trial..Ruler

© 2022 - 2024 — McMap. All rights reserved.