voltrue2 / in-app-purchase

A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
http://iap.gracenode.org
Other
1.04k stars 287 forks source link

Google Service Account #285

Open spedalilama opened 4 years ago

spedalilama commented 4 years ago

I am trouble validating for Google with a Google Service Account was wondering if in index.js (line 107) the check for receipt.purchaseToken should be parsed.purchasedToken (code snipet from index.js below)

try { // receipt could be either Google, Amazon, or Unity (Apple or Google or Amazon) var parsed = JSON.parse(receipt); if (isUnityReceipt(parsed)) { return module.exports.UNITY; } if (parsed.signature) { return module.exports.GOOGLE; } else if (receipt.purchaseToken) { return module.exports.GOOGLE; } else { return module.exports.AMAZON; } }

chr4ss1 commented 4 years ago

I don't know if the answer to your question is yes, but for google service account, I pass the receipt as an object (not a string) (thus the code you see will work).

                receipt = {
                    packageName: developerNotification.packageName,
                    productId: developerNotification.subscriptionNotification.subscriptionId,
                    purchaseToken: developerNotification.subscriptionNotification.purchaseToken,
                    subscription: true
                };

                await processPurchaseReceipt({
                    receipt: receipt,
                    userId: null
                });
famictech2000 commented 3 years ago

Can you please let me know where I can get the following information from?

googleServiceAccount: { clientEmail: 'xxxxxxxxxxxxxxxxxx, privateKey: 'xxxxxxxxxxxxxxxxxx' },