RNIap.getPurchaseHistory returns only the first purchase of an auto renewing subscription.
See original GitHub issueVersion 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
- Create an Auto Renewing subscription for 1 month in Google Play Console with/without a Trialing period
- Add yourself as a licensed tester so that we get to test the subscription without using real cards.
- Using RNIap request the purchase using the product SKU like this :
RNIap.requestPurchase('your_product_id')

Note: Test subscriptions will renew a maximum of 6 times.
-
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()
-
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:
- Created 4 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
@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.
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.