# How to handle IAP subscription

**URL:** <https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255>\
**Category:** Q&A\
**Tags:** appstore-iap\
**Created:** [June 5, 2024, 4:54pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255 "2024-06-05T16:54:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxview](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/foxview/32/1716_2.png) [@foxview](https://community.amazondeveloper.com/u/foxview)\
**Post date:** [June 5, 2024, 4:54pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/1 "2024-06-05T16:54:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Moses](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/moses/32/524_2.png) [@Moses](https://community.amazondeveloper.com/u/Moses)\
**Post date:** [July 11, 2024, 6:25pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/4 "2024-07-11T18:25:41Z")

</div>

Hi @foxview ,

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

> **[Implement Appstore SDK IAP | In-App Purchasing](https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html)**
>
> To better understand the Appstore SDK In-App Purchasing (IAP) API, read about the classes contained in the Android IAP package, described below. To learn how to integrate the IA...

- 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](https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html#4-implement-getpurchaseupdates-method)
- “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](https://developer.amazon.com/docs/in-app-purchasing/iap-rvs-for-android-apps.html)

Thanks,

Moses

---

<div class="post-metadata">

**Author:** ![foxview](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/foxview/32/1716_2.png) [@foxview](https://community.amazondeveloper.com/u/foxview)\
**Post date:** [July 12, 2024, 2:25am UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/5 "2024-07-12T02:25:29Z")

</div>

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 😃

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

---

<div class="post-metadata">

**Author:** ![Moses](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/moses/32/524_2.png) [@Moses](https://community.amazondeveloper.com/u/Moses)\
**Post date:** [July 18, 2024, 2:38pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/6 "2024-07-18T14:38:43Z")

</div>

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:

> **[Implement Appstore SDK IAP | In-App Purchasing](https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html)**
>
> To better understand the Appstore SDK In-App Purchasing (IAP) API, read about the classes contained in the Android IAP package, described below. To learn how to integrate the IA...

> **[Install and Configure the App Tester | In-App Purchasing](https://developer.amazon.com/docs/in-app-purchasing/iap-install-and-configure-app-tester.html)**
>
> App Tester allows you to unit test the In-App Purchasing (IAP) functionality of your app in sandbox mode before you submit the app for publication.You download App Tester from t...

Thanks,

Moses

---

<div class="post-metadata">

**Author:** ![foxview](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/foxview/32/1716_2.png) [@foxview](https://community.amazondeveloper.com/u/foxview)\
**Post date:** [August 13, 2024, 9:46pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/7 "2024-08-13T21:46:41Z")

</div>

Hello @Moses

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

```auto
 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?

---

<div class="post-metadata">

**Author:** ![foxview](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/foxview/32/1716_2.png) [@foxview](https://community.amazondeveloper.com/u/foxview)\
**Post date:** [August 13, 2024, 10:45pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/9 "2024-08-13T22:45:05Z")

</div>

Hello again @Moses

I think I’m lost a bit here 😅  
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

```auto
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

---

<div class="post-metadata">

**Author:** ![Moses](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/moses/32/524_2.png) [@Moses](https://community.amazondeveloper.com/u/Moses)\
**Post date:** [August 14, 2024, 12:18am UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/11 "2024-08-14T00:18:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Moses](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/moses/32/524_2.png) [@Moses](https://community.amazondeveloper.com/u/Moses)\
**Post date:** [August 20, 2024, 8:16pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/12 "2024-08-20T20:16:13Z")

</div>

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:

> **[App Tester User Guide | In-App Purchasing](https://developer.amazon.com/docs/in-app-purchasing/iap-app-tester-user-guide.html#installtester)**
>
> With App Tester, you can test Amazon In-App Purchasing (IAP) features before you publish your app to the Amazon Appstore. After you have downloaded, installed, and set up the Ap...

Thanks,

Moses

---

<div class="post-metadata">

**Author:** ![foxview](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/foxview/32/1716_2.png) [@foxview](https://community.amazondeveloper.com/u/foxview)\
**Post date:** [August 20, 2024, 11:47pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/13 "2024-08-20T23:47:16Z")

</div>

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](https://community.amazondeveloper.com/t/drm-app-tester-gamemaker-studio/5919/16)

Thanks again

---

<div class="post-metadata">

**Author:** ![system](https://dhm3gbtzu79o6.cloudfront.net/user_avatar/community.amazondeveloper.com/system/32/5065_2.png) [@system](https://community.amazondeveloper.com/u/system)\
**Post date:** [September 3, 2024, 11:47pm UTC](https://community.amazondeveloper.com/t/how-to-handle-iap-subscription/5255/14 "2024-09-03T23:47:32Z")

</div>

Closed on September 3, 2024, 11:47pm UTC

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