question

thesuiter avatar image
thesuiter asked

Subscription Purchase Tokens - weird behaviour.

I am implementing an application with subscriptions. When I make the initial purchase, my onPurchaseResponse method fires, I parse the receipt, verify with my server and allow access - no problems there. But, when I close the app and relaunch it, the onPurchaseUpdatesResponse executes with my previously saved offset and I receive a receipt for the purchase I have just made but there are some confusing things going on. Firstly, it has a different purchase token to the original transaction, this is slightly annoying because I use this is a unique identifier for a subscription and because it is different my app treats this as a separate purchase/transaction and verifies it separately with my server. (I'm also maintaining my subscriptions server side so now it looks like this user has 2 subscriptions). Secondly, the productId is for the parent product. The original transaction gives me the sku for the child product (e.g 1 month). The second point is not so bad, I can live with that, but the first one is a real pain. Is this the intended behaviour? Or is this just a problem with the tester app? Thanks for any assistance.
iap
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

thesuiter avatar image
thesuiter answered
As a workaround, in my onPurchaseResponse method I actually don't try to validate the purchase immediately, instead I call PurchasingManager.initiatePurchaseUpdatesRequest(offset); and verify the transaction details that it provides. Is this going to be suitable in the live envonment?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Samuel@Amazon avatar image
Samuel@Amazon answered
Hi, Sorry for delay in getting back to you. When you re-launch or uninstall and re-install your app, onPurchaseUpdatesResponse is called to check for any valid subscriptions. You can check for a valid subscription using the receipts you got from the API. Valid Subscription: From the returned receipts, Find the most recent receipt (by start date) for that SKU. Verify that the end date has a null value Cancelled Subscription: From the returned receipts, Find the most recent receipt (by start date) for that SKU. Verify that the end date has a value other than null For any more details, please raise a contact us to Amazon Support Team. One of our support engineer will assist you further.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.