[Question] How do you know which subscription is active and if it has not been cancelled by user
See original GitHub issueVersion 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:
- Created 5 years ago
- Comments:10 (5 by maintainers)
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.
@lc3t35 I’ll close this one because validating receipt issue is left.