Android – how to use Google play purchase validator to effectively purchase express servers

I hope to integrate the in app settlement function of Google play into the unity project that has obtained payload JSON. I have a node.js server and want to obtain the value of Google play purchase response for server-side verification

My list product on the Google play developer console is to create a productid, but I received an error:

In the index.js file of my node server, I have a segment like this:

var Verifier = require('google-play-purchase-validator');
var options = {
    email: '#############-compute@developer.gserviceaccount.com',
    key: '-----BEGIN PRIVATE KEY-----##some private key##-----END PRIVATE KEY-----',
    keyFile: './Google Play Android Developer-############.json'
};
var verifier = new Verifier(options);
var receipt = {
    packageName:"com.natekgames.######",
    productId:"com.natekgames.######.diamond_48",
    purchaseToken:"ihfeaepjoppolibmeknoghmo.AO-J1OxbHPDa8QLVAU3OqvIa-ZgaAGWhrBhs8DyCEfFbbdTCH8ecvEXQlZtjkqaowPXujb0Osn_aOWBPMT0OpTMcivoQalEtOZmMhS2lDA7oH868NjZP2LgdE9ODafujNM7O9QQr3-hq"
};
verifier.verify(receipt, function cb(err, response){
    if(err){
        console.log("there was an error validating the receipt");
        console.log(err);
    }
    console.log("sucessfully validated the receipt");
    res.send(response);
});

resolvent:

>Make sure that you are calling the subscription endpoint for the subscription and purchasing the endpoint for the in app purchase call. Do not confuse them, otherwise you will get this error. > make sure that the productid parameter is written in exactly the same way as that written in Google play developer console

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>