简体   繁体   English

在后端Node.js上从Google Play验证应用内购买

[英]Verify In-App Purchase from Google Play on Backend Node.js

I am working on an mobile app which have some kind of in-app-purchases.. 我正在开发具有某种应用内购买功能的移动应用。

Now on backend/Server-side i want to validate the purchase information from google . 现在在后端/服务器端,我想验证来自google的购买信息。 There are few module in node for validation but they just validate that data is correct but not contact google for the same. 节点中没有用于验证的模块,但它们只是验证数据是否正确,而无法与Google联系以获取同样的信息。 can anyone give any suggations for the same.. In-app-purchase data is like ie 任何人都可以提供相同的建议。.应用内购买数据就像

{
   "orderId":"12999763169054705758.1364365967744519",
   "packageName":"my package name",
   "productId":"77",
   "purchaseTime":1366217534000,
   "purchaseState":0,
   "purchaseToken":"utfwimslnrrwvglktizikdcd.AOJ1OwZ4l5oXz_3d2SAWAAUgFE3QErKoyIX8WuSEnBW26ntsyDmlLgoUd5lshqIY2p2LnlV4tpH4NITB4mJMX98sCtZizH7wGf6Izw3tfW_GflJDKFyb-g"
}

Have you tried iab_verifier module for same 你有没有尝试过iab_verifier模块

In this Google Play public key is required to authenticate the app billing 在此Google Play公共密钥中需要使用身份验证应用程序的账单

var IABVerifier = require('iab_verifier'),

var googleplay_public_key = "-- YOUR PUBLIC KEY --";
var googleplayVerifier = new IABVerifier(googleplay_public_key);

var receiptData = receiptDataFromClient;
var receiptSignature = signatureDataFromClient;

var isValid = googleplayVerifier.verifyReceipt(receiptData,receiptSignature);

if (result) {
    // Receipt is valid. Grab a beer celebrate!
} else {
    // Receipt is NOT valid... 
} 

thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM