Skip to content

Instantly share code, notes, and snippets.

@alexoro
Created March 23, 2015 13:09
Show Gist options
  • Save alexoro/b954831ffb9f86e66e6e to your computer and use it in GitHub Desktop.
Save alexoro/b954831ffb9f86e66e6e to your computer and use it in GitHub Desktop.
"use strict";
var IABVerifier = require('iab_verifier');
var googleplay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu5KsJ49lLMGatAhehkOddC3rAEFinRbSPt0tQp+IsKUF1w/IoFjujkiJY5ZuAkS99CdPVndSNvkomOqBp9gEVyojQlugQJEwsOambusTnV8i60dY6JnSncFA+qKdTY565yUVFHoERdfF7wotOyw8Hmuxshpegu+6IIxpOI5FqdkqBDtTRBhnFfYGk0MqQSuz+iheU/pxdUeNVgVCt0O2ExaDv+vqLboPklM7y5V7TDEDY/unuwbPj36C6ktQ7ex02Sz7JxabQig+VQrTcAQVIuq1jukMXDES7VeXjPkCspwMLbHtuUBciynsB2lG2ivNgvVZpPRLUs0Gr7NAb3czZwIDAQAB";
var data = "{\"orderId\":\"12999763169054705758.1332873758230775\",\"packageName\":\"com.nemotelecom.tv\",\"productId\":\"com.nemotelecom.nemotv.testpay\",\"purchaseTime\":1427113405727,\"purchaseState\":0,\"purchaseToken\":\"nckfcfcblglnhpjaehiepdpf.AO-J1Oy7RsMUCDf-RKu2Z8BZIvUqnZjmouMIrPXcPzAUJ_ohD-zedB4VlY4ZubjylTPDMOZymfSayNJue7rn0ccsYkXmZVS3qAvg7usrJS2AGybO64Pmd1fgYmPxbtPUC8wHLy1gDeB1wn0gizb9Nq4CiEplL5uotw\"}";
var sign = "rFHGmt5HE8agwtFroBWEQW4pYWuSppN/X19TBSf8dfadADdTDS2pNtCvUDgdY2/tWv2ymYHZfnMjicyHl7m7JRF/yXH7PhhIj5sNoToWrjrK/DbfA6d+IcIRBHzIYfAm8FmO2JOKd213KWBoce+POmliasNP+l/fVQTzwDjvo6L76THxLlY4e6pwEJf4ctWh1iMZ8clehxPV80x+pPxsEZQA9BHmr3G+uarMXW3li3lW3i7R+HcBS0UfGqaFqDem/+thAVYRWD18fFznW52S3e1o5RIyDeu59GQRUwOOI9voMQQuGKpT6+fUoVE3VKdMAYnzO7O7EUqpUqmGjd9Auw==";
var googleplayVerifier = new IABVerifier(googleplay_public_key);
var receiptData = data;
var receiptSignature = sign;
var isValid = googleplayVerifier.verifyReceipt(receiptData,receiptSignature);
if (isValid) {
console.log("Okay");
} else {
console.log("Nope");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment