React-native-iap: RNIap.getPurchaseHistory returns only the first purchase of an auto renewing subscription.

Created on 26 Feb 2020  ·  8Comments  ·  Source: dooboolab/react-native-iap

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" } ]

❓ question 🙏 help wanted 🚶🏻 stale

All 8 comments

I did not tried, but I think Android updates the orderId instead of creating multiple purchases.
For example, the first purchase is GPA.3332-0322-1818-48628, the next one will be GPA.3332-0322-1818-48628..1 and so on.

@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.

I see what you mean. Yes, I do something similar using signatureAndroid and getting the reset of the information from Google using their API.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@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.

please how do you generate the token required.. I keep getting this message
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project

while testing with postman

@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.

Can you please explain how you went about it.. I need this so badly.. Didnt know if I'm supplying the right token or not.. please explain how you go about running the android subscription API.. was it at your server end or through your reach native APP. in either case.. Kindly please help with explanation

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

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.

Was this page helpful?
0 / 5 - 0 ratings