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

store.initialize() never resolves #1485

Closed mikkimichaelis closed 6 months ago

mikkimichaelis commented 6 months ago

I was experiencing expected behavior. I then cleared my sandbox purchase history and then the store.initialize() function would never resolve. I'm not sure if clearing purchase history is really related to the issue. I examined the logs and found an error returned from App Store:

image

I upgraded from v13.8.5 to v13.8.6 and the behavior continued. I set 'needAppReceipt' to false and the app store issue no longer shows in the log:

image

However store.initialize() still does not resolve. I would expecct store.initalize() to resolve or throw an error and neither ever happens.

System Info

"@capacitor/core": "^4.6.3",
"@capacitor/ios": "4.6.3",
"@ionic/angular": "^6.5.5",
"@angular/core": "^15.1.1",
mikkimichaelis commented 6 months ago

removing

discountEligibilityDeterminer: this.iaptic.appStoreDiscountEligibilityDeterminer,

allows store.initialize() to resolve.

j3k0 commented 6 months ago

Somehow it looks like clearing the purchase history makes AppStore's API fail to validate the devices' application receipt. (the iTunes internal data access error returned by iaptic is an error from Apple's API)

Plugin initialization will complete when all products have been loaded. However, on iOS, determining the availability of the introductory period can only be achieved by validating the receipt (to check for potential transactions for a given subscription group). So this step is part of loading product information (when discountEligibilityDeterminer is defined)

If the receipt is invalid, then initialization will not resolve. This is pretty much dev-environment specific, as normal users should never have an invalid receipt on their device (except on jailbroken devices, but you want those users not to be able to make in-app purchases anyway).

You might try uninstalling the app, to clear the cache

mikkimichaelis commented 6 months ago

@j3k0 Thank you so much for the very fast response! Yes, clearing the cache resolved the issue and I'm able to move forward with developemnt. Thank you so much for your support, and all the amazing work you've put into this plugin and iaptic.