Devextreme 上的应用程序购买错误中的 Cordova

Cordova in app Purchase Error on Devextreme

请包括: 我买了产品,但我不能第二次购买。

我用的是devextreme;

您的代码/重现步骤

 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);
  });

朋友们可以换个插件解决这个问题:

插件:

   Cordova plugin add cordova-plugin-inapppurchase

Manifest.json

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

LoadProducs 函数

var productIds=['com.company.app.product1','com.company.app.product2'];
inAppPurchase
 .getProducts(productIds)
 .then(function (products) {

//products ok 
})
 .catch(function (err) {

  console.log(err);
});

购买功能

 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);
       });