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

Validate receipt on app startup on V13 #1509

Closed veronicatc closed 3 months ago

veronicatc commented 5 months ago

The app I am working on uses auto renewable subscriptions.

On version 11, when I called store.refresh() at initialization, the iOS receipt got automatically validated.

I want to have the same behavior with version 13, but that is not happenning when I call store.initialize(). How can I have the app get the iOS receipt and validate it on startup, after initialize ?

Please help, thanks!

flyingbarista commented 5 months ago

I am also having this problem, can anyone help this has brought my app to a standstill. All worked perfectly before upgrading. Please help?

flyingbarista commented 5 months ago

I have made some progress with the following:

CdvPurchase.store.when() .approved(transaction => {transaction.verify(); console.log("receipt.verify"); document.getElementById('billing_info').innerHTML ="validating purchases" }) .verified(receipt => {receipt.finish(); refreshUI(); console.log("receipt.finish")})

refreshing the UI in the .verified event seems to do the trick

MarcelSchuermann commented 4 months ago

I think this is related to #1363 - I have the same problem (after reopening the app on iOS, the subscription is not found anymore).

j3k0 commented 3 months ago

You need to tell the plugin that you need the application receipt.

store.initialize([
  {
    platform: Platform.APPLE_APPSTORE,
    options: {
      needAppReceipt: true,
    }
  }
])
veronicatc commented 1 month ago

You need to tell the plugin that you need the application receipt.

store.initialize([
  {
    platform: Platform.APPLE_APPSTORE,
    options: {
      needAppReceipt: true,
    }
  }
])

I am starting the plugin this way, but store.when().verified is not getting called. I added console.log in there which never shows, and when I call findInVerifiedReceipts, it doesn't find the product.

I see it calls approved for the transaction for the app itself (transaction with id appstore.application) but for no other transaction. I just purchased a renewable subscription with a Sandbox user, so there is a transaction...

I also updated to the latest version of the plugin, but the issue persists.

I have been checking for hours and don't find the cause. Thanks for any help.