1

I'd like to test CANCEL events...

My understanding is that when users switch between two items within the same group (down/up grades) - the old one is CANCELed and a new one PURCHASEd.

How would I simulate that in a sandbox?

The iTunes SUBSCRIPTION manager doesn't seem to be available on the device when I'm logged into a sandbox account. I'd also like to change subscription status from there also.

dashman
  • 2,858
  • 3
  • 29
  • 51

1 Answers1

0

You cannot manage subscriptions in the sandbox, but there is nothing special about the upgrade/downgrade process. You just check the in_app field of the receipt as per usual.

For a downgrade, you will receive a purchase event/updated receipt containing the new, lower, subscription product at the end of the current period. If you validate the receipt then you will also see the new product in the auto_renew_product_id that indicates the product that will renew at the end of the current period

For an upgrade, you will receive a purchase event and updated receipt immediately.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • What about CANCEL? If I implement the server listener to iTunes events - I get the CANCEL event. But if I decide to listen to the transaction queue when the app starts up - I don't get that event - there's no CANCEL event. I suppose I could do a getStoreReceipt() and then find out it's cancelled. – dashman Apr 28 '18 at 16:52
  • That's right. You should always check the receipt when your app starts anyway, and you will see the cancellation fields in the receipt. – Paulw11 Apr 28 '18 at 21:12
  • Re your main response above, you wrote at the "end of the current period". My understanding from the docs is that in the case of both upgrade/downgrades - the change is immediate. The user gets a pro-rated refund and is charged for the new subscription. My subscriptions are not like magazines (i.e. a calendar month) but 30 days. So if they switch from monthly to annual in the middle of a month - I suppose they'll get a refund for 2 weeks and then get charged fully for the annual. – dashman Apr 29 '18 at 01:46
  • No, for upgrades the effect is immediate; they get the higher access immediately (for a pro-rated cost). For downgrades they get the remainder of the product they have already paid for and the downgrade takes effect at the next renewal [Downgrades of any duration or cross-grades with different durations go into effect at the next renewal date](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html) – Paulw11 Apr 29 '18 at 02:01
  • Followup - you wrote check `in_app` field. Shouldn't the last receipt in the array be the same as the `latest_receipt_info` property. In fact in the data I received the `latest_receipt_info` wasn't even an entry in the `in_app` array. Little bit confused. – dashman May 01 '18 at 13:26
  • Actually it was - but with a different `transaction_id` - but rest of the fields were identical. How am I supposed to process this array? Find the non-expired receipts? – dashman May 01 '18 at 13:38
  • Yes, depending on the subscription types you have, you could have multiple active subscriptions – Paulw11 May 01 '18 at 13:54
  • My understanding is that only 1 subscription in a group can be active at a time - this is auto renewable. – dashman May 01 '18 at 14:59
  • Right, but you can have multiple groups. You may not, in which case you would inky see one active subscription at a time. – Paulw11 May 01 '18 at 20:15
  • @Paulw11 we want to provide discount to specific user with auto renewable subscriptions, apart from introductory pricing.. Say if he cancels previous subscription then give him discount on yearly subscription. https://stackoverflow.com/questions/50074883/how-to-offer-discounted-price-via-ios-auto-renewable-subscription-to-specific-us – user3519594 May 10 '18 at 07:13
  • You could expose a normally hidden subscription product that provides the lower cost, but once the user has subscribed to that product they will get that price ongoing. You cannot force them back to the "normal price" product – Paulw11 May 10 '18 at 08:58
  • @Paulw11 : its ok for us to let the user continue to discounted price. But didn't get what do you mean by hidden subscription product. – user3519594 May 10 '18 at 09:15
  • You could have cheaper subscriptions in another product group. You wouldn't normally show this product group in your "store" interface in your app. When you detect that a user has cancelled you can offer an opportunity to subscribe to this cheaper product group. If the user was subscribed to a product from this group you would need to ensure that you hide the original product subscription group from your app interface otherwise they could re-subscribe to that too and be charged twice per month. – Paulw11 May 10 '18 at 09:24
  • @Paulw11 Thanks for the help. Also, we would hide the original product group from the app, but what if the user subscribes to it from the phone settings. He would be able to see his original group in subscription history(Expired.) We were not thinking about another subscription group just for this reason that if by someway he subscribed to both then there will be no way for us to cancel the subscription. – user3519594 May 10 '18 at 09:41
  • That is true, but it is the only way to do it. If they re-subscribe to the original product as well as the discounted product then they would be pretty silly. You could detect this from the receipt and warn them to cancel – Paulw11 May 10 '18 at 09:43
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/170758/discussion-between-user3519594-and-paulw11). – user3519594 May 10 '18 at 09:44
  • @Paulw11 thanks Paul.. Also, had another question. As a part of subscription we offer user to store some of their data on firebase server. Once they cancel the subscription we would like to delete the data stored on our server. Now, after cancelling if the user comes to our app then there is no issue we would communicate the cancellation to our server. But say once he cancels the subscription and delete the app or does not open the app then will there be any way for us to detect the cancellation and get the expiration date. – user3519594 May 10 '18 at 10:02
  • Yes, you can now have your server receive subscription status directly with Apple. See [status update notifications](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html) – Paulw11 May 10 '18 at 11:35
  • @Paulw11Thanks for the help. – user3519594 May 10 '18 at 12:08
  • @Paulw11 : For subscription status i.e server to server notification. Will we get a notification when user cancel's the subscription ? – user3519594 May 11 '18 at 12:06
  • As per the documentation I linked to, only if the subscription is cancelled by Apple. If the user cancels the automatic renewal you simply don't get a renewal notification at the end of the current subscription period. – Paulw11 May 11 '18 at 12:07
  • @Paulw11 Thanks Paul – user3519594 May 11 '18 at 12:10