Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorenewing subscriptions - no event triggered when subscription ends to check if it is renewed #1468

Closed
oduverne opened this issue Sep 15, 2023 · 4 comments

Comments

@oduverne
Copy link

Hello,
I'm using 13.8.0 version of the plugin.
My issue is on iOS and Android.
I'm using autorenewing subscriptions (auto renew every month if user has not canceled it).
At the end of the monthly subscription we need to check if the user has canceled the renewal of the subscription.
The plugin doesn't trigger an event when the subscription renewaldate is reached.
I tried to run CdvPurchase.store.update() but the receipt is not updated.
If I restart my app the new receipt is correctly fetched and validated.
What should I do to get the new receipt and validate it?
Thank you

@oduverne oduverne changed the title Autorenewing subscriptions - not event triggered when subscription ends to check if it is renewed Autorenewing subscriptions - no event triggered when subscription ends to check if it is renewed Sep 15, 2023
@mebeingken
Copy link

Personally, I don't rely on the plugin to do this, but rather the receipt validation service (either your own or iaptic).

With iaptic it is pretty easy, setup webhooks so the service will ping your backend on subscription changes/renewals/lapses, etc.

https://www.iaptic.com/documentation/webhook

And use the app stores to notify iaptic:

iOS (status url):
https://www.iaptic.com/documentation/setup/ios-subscription-status-url

Android (realtime notifications):
https://www.iaptic.com/documentation/setup/connect-with-google-publisher-api

With that in place, you can rely on a subscription status within your app to control access.

@oduverne
Copy link
Author

@mebeingken thank you for your suggestion. As I didn't want to do too much modifications of my code, I decided to call the validator using this:
CdvPurchase.store.findInLocalReceipts(CdvPurchase.store.get(productId)).verify();
With this I get the expected behavior on Android (not yet tested on iOS). I don't know if it is the best way to do it.

@oduverne
Copy link
Author

@j3k0 Thank you for adding the validator call when subscriptions end in v13.8.4. It works great! I think you should extend a little more the grace period on Android. Sometimes I don't get the correct expiration date when validating the receipt. When I test a 1 month subscriptions (5 minutes for testers), sometimes the expiration date is only extended for 2 minutes when I call Google API. May be we do it to early.

@j3k0
Copy link
Owner

j3k0 commented Oct 2, 2023

When the expiration date is only extended by 2 minutes, it probably means Google Play simulates their actual grace period (billing retry, or something), when a payment method fails.

Too bad we have to figure out the correct grace period with trial and error. I'll add another 20 seconds to the plugin's internal grace period for Google.

@j3k0 j3k0 closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants