-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
32 lines (32 loc) · 980 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Created by eladrofman on 7/7/15.
*/
/* example code */
var Verifier = require('google-play-purchase-validator');
var options = {
email: 'gmailservice@accountemail',
key: '-----BEGIN PRIVATE KEY-----your private key-----END PRIVATE KEY-----',
keyFile: 'alternatively path to key file'
};
var verifier = new Verifier(options);
var receipt = {
packageName: "de.example.com",
productId: "subscription",
purchaseToken: "PURCHASE_TOKEN_RECEIVED_BY_THE_USERS_DEVICE_AFTER_PURCHASE"
};
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");
/* response looks like this
{
"kind": "androidpublisher#subscriptionPurchase",
"startTimeMillis": "long",
"expiryTimeMillis": "long",
"autoRenewing": boolean
}*/
console.log(response);
});
/* end example code */