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

Tutorial to update from 13.6.0 to a newer version? (IOS error) #1552

Closed RLUCT1 closed 1 month ago

RLUCT1 commented 1 month ago

Is there a tutorial for upgrading the plugin to a version newer than 13.6.0?

After updating beyond version 13.6.0, the functionality breaks on iOS. With version 13.6.0, everything operates correctly, but with any version above that, initiating a purchase on iOS causes CdvPurchase.store.when().finished() to be triggered immediately, completing the purchase (doFinalizePurchase()) before the iOS purchase dialog fully appears.

My implementation:

    CdvPurchase.store.when().productUpdated(product => {
      console.log('productUpdated...', product);
      obj.refreshUi();
    });

    CdvPurchase.store.when().approved(transaction => {
        console.log('approved...', transaction);
        transaction.finish();
    });

    CdvPurchase.store.when().receiptUpdated(receipt => {
        console.log('receiptUpdated...', receipt);
        receipt.verify();
    });

    CdvPurchase.store.when().verified(verifiedReceipt => {
        console.log('verified...', verifiedReceipt);
        verifiedReceipt.finish();
        verifiedReceipt.collection.forEach(purchase => {
            if (CdvPurchase.store.owned(purchase)) {
                console.log("You own product: " + purchase.id);
                obj.refreshUi();
            }
        });
    });

    CdvPurchase.store.when().finished(transaction => {
        console.log('finished...', transaction);
        const productID = transaction.products[0].id;
        const bundleKey = Object.keys(this.activeStoreIds).find(key => productID === this.activeStoreIds[key]);

        if (bundleKey) {
            console.log(`Finalizing purchase for bundle: ${bundleKey}`);
            obj.doFinalizePurchase(transaction, bundleKey);
        }
    });

    CdvPurchase.store.when().unverified(unVerifiedReceipt => {
        console.log('unverified...', unVerifiedReceipt);
    });
CdvPurchase.store.ready(() => {
      console.log('**** Store is ready ****');
      ...

Maybe old transactions or something?! But why only in versions > 13.6.0?! Any hint is appreciated.

RLUCT1 commented 1 month ago

Issue found!