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

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

Closed
lc3t35 opened this issue Jun 25, 2018 · 10 comments
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@lc3t35
Copy link

lc3t35 commented Jun 25, 2018

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.

@lc3t35 lc3t35 changed the title [Question] How do you decode Available Purchases / purchaseHistory ? [Question] How do you know which subscription is active and if it has not been cancelled by user Jun 25, 2018
@lc3t35
Copy link
Author

lc3t35 commented Jun 25, 2018

About the autorenewable in test environnement , Available Purchases are (I've removed older events and ordered them for convenient reading as it's randomly get in Array)

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761556
[14:59:01] transactionDate : 25 06 2018 : 14:21:49

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761554
[14:59:01] transactionDate : 25 06 2018 : 14:26:49

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761545
[14:59:01] transactionDate : 25 06 2018 : 14:31:49

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761559
[14:59:01] transactionDate : 25 06 2018 : 14:36:49

productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761542
[14:59:01] transactionDate : 25 06 2018 : 14:41:49

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761557
[14:59:01] transactionDate : 25 06 2018 : 14:46:49

I got 6 events but 5 renewals not as expected (https://help.apple.com/app-store-connect/#/dev7e89e149d) ?

and in history (I removed past events)

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761545
[14:59:01] transactionDate : 25 06 2018 : 14:31:49
[14:59:01] originalTransactionIdentifier : 1000000410436007
[14:59:01] originalTransactionDate : 24 06 2018 : 19:52:06

[14:59:01] productId : com.shares.sharesapp.plus
[14:59:01] transactionId : 1000000410761567
[14:59:01] transactionDate : 25 06 2018 : 14:41:49
[14:59:01] originalTransactionIdentifier : 1000000410436007
[14:59:01] originalTransactionDate : 24 06 2018 : 19:52:06

[14:59:01] productId : com.shares.sharesapp.basic
[14:59:01] transactionId : 1000000410761568
[14:59:01] transactionDate : 24 06 2018 : 19:52:06
[14:59:01] originalTransactionIdentifier : undefined
[14:59:01] originalTransactionDate : 25 06 2018 : 14:59:01

Do you understand something ?

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Jun 26, 2018
@JJMoon
Copy link
Contributor

JJMoon commented Jun 26, 2018

In iOS you can refer this page for subscription.
https://support.apple.com/en-us/ht202039
Simply, you can do such things in iPhone setting app.

@lc3t35
Copy link
Author

lc3t35 commented Jun 26, 2018

Hi @JJMoon , the question is not "how can a user unsubscribe" (which is done in iPhone settings as you refer) but how can I know within react-native-iap "which subscription is active" and if "the subscription has been cancelled by user".
You can look at #203 where I'm trying to get some informations thru validateReceiptIos, but need help to decode base64 json receipt...

@hyochan
Copy link
Member

hyochan commented Jun 30, 2018

@lc3t35 You can use getSubscription method to know if user subscribe your iap.

@lc3t35
Copy link
Author

lc3t35 commented Jun 30, 2018

@dooboolab getSubscription returns an Array of products

Object {
     "currency": "EUR",
     "description": "....",
     "localizedPrice": "3,99 €",
     "price": "3.99",
     "productId": "com.shares.....",
     "title": "Abonnement BASIQUE",
     "type": "Do not use this. It returned sub only before",
 },

but nothing indicates which one the user subscribed ?

@hyochan
Copy link
Member

hyochan commented Jul 1, 2018

@lc3t35 I've understood what you are trying to do now.. along with issue here. I'll look into this one some day.

@AnthonyHaykal
Copy link

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
Copy link
Author

lc3t35 commented Jul 6, 2018

@AnthonyHaykal the problem is now how to decode this receipt -> look at #203

@hyochan
Copy link
Member

hyochan commented Jul 11, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS
Projects
None yet
Development

No branches or pull requests

4 participants