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.

RNIap.getPurchaseHistory returns only the first purchase of an auto renewing subscription.

See original GitHub issue

Version of react-native-iap

Using react-native-iap v4.4.0

Version of react-native

Using react-native v0.59.9

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

Android Only

Expected behavior

Trying to get the purchase history using const purchaseHistory = await RNIap.getpurchasehistory(); And update my DB with the latest purchase details made by Google Play. iOS returns the whole purchase history made. So I take the latest purchase by const lastPurchaseDetails = purchaseHistory.sort(( a, b ) => b.transactionDate - a.transactionDate)[0];

Actual behavior

But for android only the first purchase of the auto renewing subscription is returned by the RNIap.getPurchaseHistory method.

Tested environment (Emulator? Real Device?)

Tested in Real Device.

Steps to reproduce the behavior

  1. Create an Auto Renewing subscription for 1 month in Google Play Console with/without a Trialing period
  2. Add yourself as a licensed tester so that we get to test the subscription without using real cards.
  3. Using RNIap request the purchase using the product SKU like this : RNIap.requestPurchase('your_product_id')
Screenshot 2020-02-26 at 10 57 08 PM

Note: Test subscriptions will renew a maximum of 6 times.

  1. Based on the above info. At the end of 30 minutes, there should be 6 purchases done. Try to get the purchase history using RNIap.getPurchaseHistory()

  2. The above would code only listed the 1st Purchase made for android.

The array returned by iOS

[ { "transactionReceipt":"<receipt>", "transactionDate":<transaction_date>, "productId":"sub1_monthly", "transactionId":"300000553937461" }, { "transactionReceipt":"<receipt>", "transactionDate":<transaction_date>, "productId":"sub1_monthly", "transactionId":"3000005578937461" } ]

The array returned in Android

[ { "autoRenewingAndroid":true, "isAcknowledgedAndroid":true, "purchaseStateAndroid":1, "signatureAndroid":"...", "developerPayloadAndroid":"", "purchaseToken":"", "orderId":"GPA.31321-0322-1818-312341", "transactionReceipt":"{receiptId: ... ... }", "transactionDate":1581644006609, "transactionId":"GPA.3332-0322-1818-48628", "productId":"sub1_monthly" } ]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
prasanna1211commented, Mar 16, 2020

@nochkin I am also getting the same issue. You are correct, but the orderId is not available in the purchases available. There is always a single purchase with the following fields developerPayload, signatureAndroid, purchaseTime, developerPayload, transactionDate, productId. But none of them are pointing the order ID. I managed to make it work by hitting the Android subscriptions API to get the latest details.

0reactions
stale[bot]commented, Dec 13, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RNIap.getPurchaseHistory returns only the first purchase of ...
But for android only the first purchase of the auto renewing subscription is returned by the RNIap.getPurchaseHistory method.
Read more >
RNIap.getPurchaseHistory() always returns an empty array ...
The RNIap.getPurchaseHistory always return an empty array. Does not matter if I call on app start or after purchase was made.
Read more >
react-native-iap-badoo - npm Package Health Analysis
If true, the subscription is active, and will automatically renew on the next billing date. If false, indicates that the user has canceled...
Read more >
React Native: Subscriptions with In-App Purchases - Ross Bulat
These items are purchased once and once only. The other two types are subscription based, “Auto-renewable subscription” or “non-renewing ...
Read more >
React Native In-App Purchases (iOS) - YouTube
I fixed this in my app by first trying to validate using the production ... If the purchase is valid then a status...
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