Search code examples
cordovain-app-purchasecordova-pluginsandroid-inapp-purchase

Cordova in app Purchase Error on Devextreme


Please include: I buy the product but I can not buy it the second time.

I use devextreme;

Your code / steps to reproduce

 inAppPurchase
  .buy(urunID)
  .then(function (data) {
    return inAppPurchase.consume(data.type, data.receipt, data.signature);
  })
  .then(function () {
    alert("Satın alma Başarılı");
  })
  .catch(function (err) {
    alert("Başarısız! "+ err);
  });

Solution

  • Friends can solve this problem with a different plugin:

    Plugin:

       Cordova plugin add cordova-plugin-inapppurchase
    

    Manifest.json

    { "play_store_key": "YOUR PLAY STORE KEY" }
    

    LoadProducs function

    var productIds=['com.company.app.product1','com.company.app.product2'];
    inAppPurchase
     .getProducts(productIds)
     .then(function (products) {
    
    //products ok 
    })
     .catch(function (err) {
    
      console.log(err);
    });
    

    buy function

     var productId='com.company.app.product1';
             inAppPurchase
           .buy(productId)
           .then(function (data) {
             console.log(JSON.stringify(data));
             // The consume() function should only be called after purchasing consumable products
             // otherwise, you should skip this step
             return inAppPurchase.consume(data.type, data.receipt, data.signature);
           })
           .then(function () {
             console.log('consume done!');
             //purchase ok
           })
           .catch(function (err) {
             console.log(err);
           });