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

getAvailablePurchases returns each purchase twice #546

Closed
varungupta85 opened this issue Jun 21, 2019 · 2 comments
Closed

getAvailablePurchases returns each purchase twice #546

varungupta85 opened this issue Jun 21, 2019 · 2 comments
Labels
1️⃣ good first issue Good for newcomers 🤖 android Related to android

Comments

@varungupta85
Copy link

varungupta85 commented Jun 21, 2019

Version of react-native-iap

3.0.0

Version of react-native

0.59.9

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

Android

Expected behavior

See each purchases item once in the return value

Actual behavior

See each purchase twice with one differing key

Tested environment (Emulator? Real Device?)

Real device

Steps to reproduce the behavior

Purchase an item on Android and print the getAvailablePurchases on startup.

When I make a call to the getAvailablePurchases, I get two entries in the array although I only made a single purchase. The product ID and a couple of other tokens are also the same in the two entries. Below is a sample response from getAvailablePurchases.

[
  {
    "purchaseStateAndroid": 1,
    "signatureAndroid": "hacFoFOnElkqgDGOGL3aLZLKXeBvQ7XCnZYx1lp2ARsnK+ulmfq4VhLjX0VRnbZCK/KXWpF316j1dqVhMK1xLXYY6Jmig9eO3qWh06oIQXy5qWJggPCYz7HmK2WuvvI54Y8AbJae94eBVEHANJwSr4uF68CSXI0OQWMBPVCp4lrBZSf1v4HG01EFg5GtzOHFBuNIDA2l14NNVMeA/eePsgRWmY44QNIHUgR+vq4t9H2HDnfHYJ5jWaBAFPbg1x6Xgk+Zgla2Wxg0Lqyp0pZ5UOQxQ3WJrsvDgwTb3/lgxLgM1gwe2qhSsGqodUuJeJR1tv8wIyWXpFXQTtu3n9mfGQ==",
    "developerPayloadAndroid": "",
    "purchaseToken": "jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet",
    "orderId": "GPA.3310-1659-8234-22824",
    "transactionReceipt": "{\"orderId\":\"GPA.3310-1659-8234-22824\",\"packageName\":\"com.myapp\",\"productId\":\"com.myapp.premiumupgrade\",\"purchaseTime\":1549648787003,\"purchaseState\":0,\"purchaseToken\":\"jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet\"}",
    "transactionDate": "1549648787003",
    "transactionId": "jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet",
    "productId": "com.myapp.premiumupgrade"
  },
  {
    "developerPayload": "null",
    "signatureAndroid": "bBisZunzi8IJtkyWE1A7LPsSEKdw46DnRIeVVl4eSTgYxF00l8QWaP2itwKduDlj9uja25Cy3ro5AuTFGFC9YDWea03o0Qm28RU0vgLWrlFh2U9R4xURboqWMdRlo6WRNJNb4KnEqpPLGeYp2BzvP50PQyMvl6XeZWUQMnV00LoVCv73CEFvGA55+zNP0jcZWncIEiYRWg1kmiF0m9SUdMf59lW9Nq7wSTVp0jB4l336xjN5u73oxHNkylcsYUQKyK2ss5+poivUxL4W10obJEzeSYpXZXNeEfKSewCxYLo83FhpG1a7NEC0tUi7jxyFTx9uDrwoxHh8TJAQsQMBMw==",
    "dataAndroid": "{\"productId\":\"com.myapp.premiumupgrade\",\"purchaseToken\":\"jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet\",\"purchaseTime\":1549648787003,\"developerPayload\":null}",
    "purchaseToken": "jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet",
    "transactionReceipt": "{\"productId\":\"com.myapp.premiumupgrade\",\"purchaseToken\":\"jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet\",\"purchaseTime\":1549648787003,\"developerPayload\":null}",
    "transactionDate": "1549648787003",
    "transactionId": "jnpfndefgoigjegbpmbljkgi.AO-J1Ox_bkcX9e6OTije4gHKH4LFi6C5WsJhjIJTmVAmDJPGmIZaCCGgdE5LOC-0hxbWVHDz3_H7TZVGeOKJa7du_xr_Ky1bt3nu32KDwpbEpgAz7MoCBPos4dTte1MoUKhHeCaV1Yet",
    "productId": "com.myapp.premiumupgrade"
  }

I looked at the code and I do see that we are making two calls to get the purchases here:
https://github.com/dooboolab/react-native-iap/blob/d6e9aa0c7c90bab5e65586f942dae0c4289e26ab/android/src/main/java/com/dooboolab/RNIap/RNIapModule.java#L271

One call is to queryPurchases which appears to be synchronous and another call to queryPurchaseHistoryAsync which is asynchronous and the promise is resolved in the latter call. Some of the keys differ when entries are added for each call which can be seen in the response.

Could you please let me know why are these entries added twice and if I should ignore one type of entries?

Secondly, when I make a call to consumeAllItemsAndroid and call getAvailablePurchases after that, I still get one entry which is from the latter asynchronous call. Please clarify on these return values.

@alexbazilev
Copy link

alexbazilev commented Jun 21, 2019

I can confirm this problem. For me there are 2 entries in getAvailablePurchases after calling requestSubscription. Response data is similar to data in the message above.

@hyochan hyochan added 🤖 android Related to android 1️⃣ good first issue Good for newcomers need fix labels Jun 22, 2019
hyochan added a commit that referenced this issue Jun 22, 2019
@hyochan
Copy link
Owner

hyochan commented Jun 22, 2019

I've released 3.0.1 for the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1️⃣ good first issue Good for newcomers 🤖 android Related to android
Projects
None yet
Development

No branches or pull requests

3 participants