Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Cordova中实施应用内购买_Javascript_Cordova_Phonegap Plugins_Cordova Plugins_Phonegap Build - Fatal编程技术网

Javascript 在Cordova中实施应用内购买

Javascript 在Cordova中实施应用内购买,javascript,cordova,phonegap-plugins,cordova-plugins,phonegap-build,Javascript,Cordova,Phonegap Plugins,Cordova Plugins,Phonegap Build,这是我的html代码 <html> <head> <script type="text/javascript" charset="utf-8"> function testInapp(){ console.log("Inside in app"); inAppPurchase.getProducts(['myapp.xyz']).then(function(products){ console.log(prod

这是我的html代码

   <html>
    <head>

  <script type="text/javascript" charset="utf-8">
  function testInapp(){
      console.log("Inside in app");

inAppPurchase.getProducts(['myapp.xyz']).then(function(products){
      console.log(products);
}).catch(function(error){
  console.log(error);
});

var restorePurchases = function(){
  inAppPurchase.restorePurchases().then(function(data){
    if(data.productId === 'myapp.xyz'){

    }else if(data.productId === 'myapp.xyze'){

    }
  }).catch(function(error){
    console.log(error);
  });
};

var purchase = function(productId){
  inAppPurchase.buy(productId).then(function(data){
    if(data.productId=== 'myapp.xyz'){


    }else if(data.productId === 'myapp.xyzs'){

    }

    purchases
    return inAppPurchase.consume(data.type, data.receipt, data.signature);
  }).catch(function(error){
    console.log(error);
  });
};


    }


  </script>
  </head>
   <body>
   <input type="button" value="IN-APP" onclick="testInapp()"/>
  </body>
  </html>

函数testInapp(){
console.log(“应用程序内部”);
inAppPurchase.getProducts(['myapp.xyz']),然后(函数(产品){
控制台日志(产品);
}).catch(函数(错误){
console.log(错误);
});
var restorepources=函数(){
inAppPurchase.restorePurchases().then(函数(数据){
如果(data.productId==='myapp.xyz'){
}else if(data.productId==='myapp.xyze'){
}
}).catch(函数(错误){
console.log(错误);
});
};
var采购=功能(productId){
inAppPurchase.buy(productId).then(函数(数据){
if(data.productId==='myapp.xyz'){
}else if(data.productId==='myapp.xyzs'){
}
购买
返回apppurchase.consume(data.type,data.receive,data.signature);
}).catch(函数(错误){
console.log(错误);
});
};
}
在这里,单击按钮,我调用testInapp()函数,该函数包含应用内购买代码,但我得到的
inAppPurchase未定义

这是我正在使用的插件
https://github.com/AlexDisler/cordova-plugin-inapppurchase
有人能帮我找出哪里做错了吗

在CLI中运行:
$cordova plugin list
。确保你安装了插件properly@MaximShoustin运行
cordova插件列表时
its会在AppPurchase 1.1.0“应用内购买”中显示cordova插件这个插件是如何为你工作的?@RobertGarcia是的,它工作得很好now@gauravsingh为什么不与我们分享您发现的解决方案?在CLI中运行:
$cordova plugin list
。确保你安装了插件properly@MaximShoustin在运行
cordova插件列表时
its显示cordova插件在AppPurchase 1.1.0“应用内购买”中,这个特定的插件是如何为您工作的?@RobertGarcia是的,它工作得很好now@gauravsingh为什么不与我们分享一下你发现的解决方案呢?