question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How do you know which subscription is active and if it has not been cancelled by user

See original GitHub issue

Version of react-native-iap

1.2.1

Platforms you faced the error (IOS or Android or both?)

iOS (but same question for Android)

In testing environment, it is not very easy to understand how getAvailablePurchases and getPurchaseHistory work. I only use renewable subscriptions. Here is a dump of what it returns :

>>>> Available Purchases :
[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748473
[14:23:29] transactionDate : 25 06 2018 : 11:37:01

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748474
[14:23:29] transactionDate : 24 06 2018 : 20:02:06

[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748475
[14:23:29] transactionDate : 25 06 2018 : 11:52:01

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748476
[14:23:29] transactionDate : 24 06 2018 : 19:52:06

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748477
[14:23:29] transactionDate : 25 06 2018 : 11:57:43

[14:23:29] productId : com.shares.sharesapp.plus
[14:23:29] transactionId : 1000000410748478
[14:23:29] transactionDate : 25 06 2018 : 14:21:49

[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748479
[14:23:29] transactionDate : 25 06 2018 : 12:02:28

[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748480
[14:23:29] transactionDate : 25 06 2018 : 11:47:01

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748481
[14:23:29] transactionDate : 25 06 2018 : 11:35:50

[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748482
[14:23:29] transactionDate : 25 06 2018 : 11:42:01

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748483
[14:23:29] transactionDate : 24 06 2018 : 19:57:06

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748484
[14:23:29] transactionDate : 25 06 2018 : 11:30:50

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748485
[14:23:29] transactionDate : 24 06 2018 : 20:07:06

>>>purchaseHistory 
[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748474
[14:23:29] transactionDate : 24 06 2018 : 20:02:06
[14:23:29] originalTransactionIdentifier : 1000000410436007
[14:23:29] originalTransactionDate : 24 06 2018 : 19:52:06

[14:23:29] productId : com.shares.sharesapp.plus
[14:23:29] transactionId : 1000000410748496
[14:23:29] transactionDate : 25 06 2018 : 14:21:49
[14:23:29] originalTransactionIdentifier : 1000000410436007
[14:23:29] originalTransactionDate : 24 06 2018 : 19:52:06

[14:23:29] productId : com.shares.sharesapp.basic
[14:23:29] transactionId : 1000000410748497
[14:23:29] transactionDate : 25 06 2018 : 11:30:50
[14:23:29] originalTransactionIdentifier : 1000000410436007
[14:23:29] originalTransactionDate : 24 06 2018 : 19:52:06

[14:23:29] productId : com.shares.sharesapp.classic
[14:23:29] transactionId : 1000000410748498
[14:23:29] transactionDate : 25 06 2018 : 11:37:01
[14:23:29] originalTransactionIdentifier : 1000000410436007
[14:23:29] originalTransactionDate : 24 06 2018 : 19:52:06

What a mess ! Last transaction is for com.shares.sharesapp.plus (transactionId : 1000000410748496) at 25 06 2018 : 14:21:49 … correct in history but we don’t have the same transactionId (1000000410748478) at same product/date 25 06 2018 : 14:21:49 in Available Purchases …

How do you know which subscription is active (search with last transactionDate) ? Then how do you if the subscription has not been cancelled by user in system prefs ? How can you cancel subscription in test environnement, I have an “Account creation in ITunes is not allowed - this Apple Id cannot be use un iTunes Store for now. Try again later” when I try to do it with a Sandbox test account.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
AnthonyHaykalcommented, Jul 6, 2018

I don’t know if this might help you, but we can use getPurchaseHistory and get the final receipt. After that, use that receipt to validate it, when validated we get an expiry_time. We then compare with the current date if the subscription is active or not.

0reactions
hyochancommented, Jul 11, 2018

@lc3t35 I’ll close this one because validating receipt issue is left.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If you want to cancel a subscription from Apple
Tap the subscription. Tap Cancel Subscription. You might need to scroll down to find the Cancel Subscription button. If there is no Cancel...
Read more >
Fix problems with subscriptions - Android - Google Play Help
Find missing subscriptions If you can't find your subscriptions, check that ... is declined or has insufficient funds, your subscription may be cancelled....
Read more >
How to determine if user cancels Google Play subscription?
According to In-App Subscription documentation there is no mechanism to detect when the user cancels the subscription.
Read more >
Regal Unlimited™ FAQs
Frequently Asked Questions for Regal's new unlimited movie subscription plans.
Read more >
Expire Subscription
If a customer decides to cancel and then changes their mind, you can reactivate their subscription if the subscription has not yet expired....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found