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

Hello @Moses

I have pretty much handled all the code, however there are some issues that I encounter.

 AppstoreSDK: Production Mode: Release build or debug.amazon.sandboxmode property is not set on device

I’m using an emulator device and set adb shell setprop debug.amazon.sandboxmode debug, but the SDK couldn’t understand the debug mode.

Perhaps I’m doing something wrong?

Hello again @Moses

I think I’m lost a bit here :sweat_smile:
There’s no /tmp folder for me, or perhaps I couldn’t find it. I tried some other folders but couldn’t make it happen.

For IAP items, I followed the documentation as

adb push [_Your_JSON_File_Folder_]/amazon.sdktester.json /sdcard/amazon.sdktester.json

The IAP items are available in the Tester App.

By Application Id, do you mean the package id (like com.game.app) or the one in the developer panel (amzn1.devportal.mobileapp.9b12…)

Thanks

Hi @foxview ,

Sorry for the confusion, I have reached out to the IAP team to get more info.

In the meantime, I have deleted my previous instructions, to avoid confusing anyone else having the same issue.

I’ll update when I have the correct answer to your issue.

Moses

1 Like

Hi @foxview ,

Here is the answer from our IAP team:

Sandbox mode with app tester would work only if the following criteria is met:

  • The app should be the debug version
  • adb shell setprop debug.amazon.sandboxmode debug - command should be run

The details are available in the documentation:

Thanks,

Moses

1 Like

Hi @Moses

Thanks for returning back,

  • The app should be the debug version

This helped me found the solution. I’m just going to leave another post reference here in case someone else is looking for this issue : DRM - App Tester - GameMaker:Studio - #16 by jzavala

Thanks again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.