cordova-plugin-purchase icon indicating copy to clipboard operation
cordova-plugin-purchase copied to clipboard

Can't define product into consumable

Open vlahde opened this issue 1 year ago • 1 comments

Any ideas what am I doing wrong here:

Expected behavior

The product can be purchased multiple times

Observed behavior

The procuct is non consumable. It can be bought only once. After that the store throws an error that I already own the product.

window.CdvPurchase.store.register([
    {
        id: 'testi',
        type:   window.CdvPurchase.ProductType.CONSUMABLE,
        platform: window.CdvPurchase.Platform.GOOGLE_PLAY
    },
]);

window.CdvPurchase.store.initialize([
    window.CdvPurchase.Platform.GOOGLE_PLAY
]);

  window.CdvPurchase.store.when()
      .approved(transaction => {
          alert("CdvPurchase approved transaction: " + JSON.stringify(transaction))
          //purchaseReceipt.value = transaction
          transaction.verify()
      })
      .verified(receipt => {
          alert("verified receipt: " + JSON.stringify(receipt))
          purchaseReceipt.value = receipt
          // finish transactions from verified receipts
          receipt. Finish();
      });

....

function appStoreOrder(offer){
        console.log('appStoreOrder of ', offer)

        window.CdvPurchase.store.order(offer)

    }

the output of store.products:

        [
            {
                "className": "Product",
                "title": "testaan (fi.****.**** (unreviewed))",
                "description": "testing",
                "platform": "android-playstore",
                "type": "consumable",
                "id": "testi",
                "group": "default",
                "offers":
                    [
                        {
                            "className": "Offer",
                            "id": "testi",
                            "pricingPhases":
                                [
                                    {
                                        "price": "8,50 €",
                                        "priceMicros": 8500000,
                                        "currency": "EUR",
                                        "recurrenceMode": "NON_RECURRING"
                                    }
                                ],
                            "productId": "testi",
                            "productType": "consumable",
                            "productGroup": "default",
                            "platform": "android-playstore",
                            "type": "inapp"
                        }
                    ]
            } ]

`

Thanks for the help!

vlahde avatar Jun 19 '23 11:06 vlahde

Late reply but: If you don't consume a CONSUMABLE, the store won't let you buy it again. Does your verification work and is .verified() ever called? If not, the transaction remains unfinished.

cmaas avatar Sep 20 '23 15:09 cmaas