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

getPurchaseHistory gets empty array in production #385

Closed
ming436534 opened this issue Jan 28, 2019 · 15 comments
Closed

getPurchaseHistory gets empty array in production #385

ming436534 opened this issue Jan 28, 2019 · 15 comments
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@ming436534
Copy link

Version of react-native-iap

2.4.0-beta6

Version of react-native

0.55.4

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

iOS

Expected behavior

getPurchaseHistory result is not empty.

Actual behavior

The library generally works perfectly, but there is one case that confused me a lot. A user claimed that he subscribed a renewable product, for some reason the first purchase was not recorded so that we need the getPurchaseHistory to recover his purchase, but the problem is that the getPurchaseHistory function returned an empty array. When he tried to purchase again (by calling buySubscription), an alert with 'purchased message' pops up which showed that he has already purchased the product. I also confirmed his purchase by checking the purchase history from the itunes developer website.
Is there anyway to solve this problem? Thank you.

Tested environment (Emulator? Real Device?)

Production

Steps to reproduce the behavior

Unknown...

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Jan 28, 2019
@berehovyi
Copy link

Getting same issues.
Please help.

@andersmandersen
Copy link

We had a simular issue, and created the following bug report, which has been closed:
#227

@Cnordbo
Copy link

Cnordbo commented Feb 20, 2019

Same issue here! This is critical as it makes eveyrone unable to restore purchases unless the app i tied up to a user account.

Locally and in Testflight, everything is correct.

Array has a length of 0, and if you try to buy the product again, it fails to do so and Apple throws an error because its already been purchased.

(0) indicates the length of the purchase array.
image

When trying to buy the product again:
(Translation: This is already bought inside the app, it will be restored for free)
image

@hyochan
Copy link
Member

hyochan commented Feb 20, 2019

@Cnordbo I don't think you are on the same issue because to re-purchase the item, you should make it as consumable.

@Cnordbo
Copy link

Cnordbo commented Feb 20, 2019

@hyochan i am on the same issue.
Its not an item that is suppose to be re-purchased. Its a 1-time upgrade to "pro version". Its just something that has been tried out, as restore didnt work.

As a sidenote, im on react-native-iap": "^2.4.0-beta3 and
"react-native": "0.57.7"

@hyochan
Copy link
Member

hyochan commented Feb 20, 2019

@Cnordbo Oh, I see. Yes, then you are on right track. Unfortunately, since I may not dig this problem for a while, I think you need someone else's help or dig yourself with this issue.

@hyochan
Copy link
Member

hyochan commented Feb 20, 2019

Have you guys tried ‘getAvailablePurchases’?

@ming436534
Copy link
Author

I almost forget I still keep this issue open. I can share how I 'solved' the problem. As I really didn't know how to fix this issue and only one of our user has this problem, I told the user to refund. The user refunded successfully and magically calling getPurchaseHistory from his phone was not returning empty array anymore but an array with one result(which showed that the order was refunded). Therefore this maybe a problem of apple iap server.

@Cnordbo
Copy link

Cnordbo commented Feb 21, 2019

@hyochan Your right, i am on another issue. But it could be the same... As im using getAvailablePurchases.. Heres my code for restoring:

const restorePurchases = () => {
  return new Promise((resolve, reject) => {
    RNIap.getAvailablePurchases()
      .then(purchases => {
        let result = purchases.some(purchase => {
          return purchase.productId === itemSkus.premium;
        });
        if (result) {
          setPremium().then(resolve);
        } else {
          unsetPremium().then(() => {
            reject({ message: `No previous purchases (${purchases.length})` });
          });
        }
      })
      .catch(err => {
        return unsetPremium().then(() => reject(err));
      });
  });
};

As with any Open Source, im not expecting you (@hyochan) to handle everything yourself - so i am posting with general information that might aid anyone that takes a look at it.

Im not quite sure on how to attack this, as its basically impossible to reproduce locally for me atm. as i always get a signing issue with the certificate when trying to run with release scheme locally.

@hyochan
Copy link
Member

hyochan commented Feb 21, 2019

@Cnordbo This one looks quite weird even in finding out the actual symptoms. I think it would be nice if we can get some answers out of Apple like what we've done in #307.

@Cnordbo
Copy link

Cnordbo commented Feb 25, 2019

That would be nice, yes. Im too unfamiliar with the iOS purchase process myself to write such a request on the forum. Might be quicker if someone whos familiar with the code and process takes a look.

@ghost
Copy link

ghost commented Feb 27, 2019

I'am sorry, but my English is bad(

I think, you don't close transaction, if you have "This is already bought inside the app, it will be restored for free".

Same issue here! This is critical as it makes eveyrone unable to restore purchases unless the app i tied up to a user account.

Locally and in Testflight, everything is correct.

Array has a length of 0, and if you try to buy the product again, it fails to do so and Apple throws an error because its already been purchased.

(0) indicates the length of the purchase array.
image

When trying to buy the product again:
(Translation: This is already bought inside the app, it will be restored for free)
image

@Cnordbo
Copy link

Cnordbo commented Mar 11, 2019

"ghosts" account is deleted, so cant get any further with that info.

@ming436534
Copy link
Author

This problem still happens occasionally, is there any updates? Thanks.

@ming436534
Copy link
Author

It seems that I solved the problem by calling clearTransaction before every call of buySubscription, users who had the problem can now re-purchase again without costing any extra money because apple won't charge them again.

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

5 participants