j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

product.getOffer() returns undefined sometimes #1413

Open Ralle opened 1 year ago

Ralle commented 1 year ago

Observed behavior

I had a customer who clicked order in my app. But my app tracked that product.getOffer() returned undefined.

Can you help me understand what situations causes this?

I have my own web based validator.

j3k0 commented 1 year ago

I can help but need more info. Can you get access to some logs of when that happens? Sometimes, the connection with AppStore fails and not all product information are loaded, but this should be very (very) rare. You could track that and more generally have an error handler that pops up "something unexpected happened, please try again" -- call store.update() in the background, this will try reloading the product information.

Ralle commented 1 year ago

The problem is that a customer experienced it, and I display an error that only happens in the case where getOffer() returns undefined. So I cannot give any details. But I can tell you that we are getting new customers on a daily basis. We just always get worried about how big of a percentage get this error as not every customer reports a problem they are facing.

Are you saying that it is recommended to call store.update() if the offer is missing or would await CdvPurchase.store.initialize() happen to throw an Error in this case?

I am using my own receipt validator. It seems to work. Would a bad receipt validator be able to cause this issue?

Also. Do you consult on support? I would love to show you my receipt validator and app codebase and get feedback on my solution.

Ralle commented 2 months ago

Here's some error output. I added logging of CdvPurchase errors as well as try-catch errors. I don't know if it's any help. cdvpurchase errors.json