How to handle IAP subscription

Hi.

I’m trying to implement IAP to my game. I have only one item, which is a SUBSCRIPTION and have 3 terms (monthly, quarterly and annually). I have successfully implemented the SDK and everything, so I’m all okay on that side.

My question is how to detect and store a valid subscription. See the following scenario

  • Invoke a purchase request - SDK returns a result. With that result, - for now let’s skip the validation part - I just save it locally that the subscription has been bought. Along with that I also record the expiration date.
  • User deletes the app. But their subscription still exists. Next time the user opens the app, I’d have to check if the user has an active subscription.
  • The subscription has reached its expiration date, however it is a recurring one and Amazon has extended the subscription. I don’t see an update in PurchaseUpdates return. How can I still check that the user has extended its subscription?

Thanks.

Hi @foxview ,

Here is the developer documentation for In-App Purchasing using the Appstore SDK:

  • Post purchase is done, a receipt for the subscription is created in Amazon’s systems.
  • getPurchaseUpdates API will return you all purchase transaction receipts made by the user since last time that method was called. ref: Implement Appstore SDK IAP | In-App Purchasing
  • “How can I still check that the user has extended its subscription?” → If I am interpreting your question correctly. You are trying to figure out if the subscription is still “active” and valid. To check the validity of a subscription receipt , you will need to call the Receipt Verification Service. For valid Subscription receipts the cancelDate will be null, If it is not null it means that subscription expired, or that Amazon customer service canceled the purchase. ref: Receipt Verification Service for Appstore SDK IAP | In-App Purchasing

Thanks,

Moses

Hello @Moses

It’s been a while since I had been testing the SDK. I was trying to handle everything on the client side, without ever relying on the RVS.

The issues I encountered

  1. I get confirmation from the onPurchaseResponse callback. I then store it locally to check it in the next app opening.
  2. I close and reopen the game. Here I check two things.
    2.1. Locally, to check if the subscription is purchased before.
    2.2. PurchasingService.getPurchaseUpdates(false) to check if there’s an update in the purchase status. I almost never got an update here. I disable recurring for the subscription, so I would expect some sort of an update here on this callback.

And if I delete the app and reinstall it, I call PurchasingService.getPurchaseUpdates(true) to fetch all receipts. I foreach all of them, and try to find an active - receipt.isCanceled() - receipt. I couldn’t find any.

I think I’m doing it in wrong way and I wanted to learn how to implement it properly. (I’ve read stackoverflow documents, watched Amazon videos etc.). Maybe my English is not good enough for this :smiley:

I have a backend server running for me, so I can integrate RVS for that. My simplest question is: What are the steps that I need to take? (with details if possible).

Thank you very much

Hi @foxview ,

When a customer disables auto renewal, it does not result in immediate subscription cancellation. So no immediate updates would be sent via GetPurchaseUpdates response. On the renewal date, if auto renewal is turned off subscription will be moved to cancelled state. The next invocation to GetPurchaseUpdates will return the receipt with a cancelled date.

Details about auto-renewal states and changes are not supported on client side SDK. For real-time updates kindly use RTN and for status query of an receipt use RVS.

Please see this documentation for more info:

Thanks,

Moses