All Projects → Deishelon → google-play-billing-validator

Deishelon / google-play-billing-validator

Licence: other
Npm module for Node.js to validate In-app purchases and Subscriptions on your backend

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to google-play-billing-validator

In App Purchase
A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
Stars: ✭ 868 (+1105.56%)
Mutual labels:  subscription, purchase
PurchaseHelper
Sample app to explain the In-App purchase implementation in Android using Play-billing library
Stars: ✭ 30 (-58.33%)
Mutual labels:  subscription, purchase
Google-IAP
Android Library for easing Google Play Billing to your apps with support for Subscriptions, In-App Purchases and Consumables with a beautiful sample app.
Stars: ✭ 129 (+79.17%)
Mutual labels:  subscription, purchase
Apphudsdk
Build, Measure and Grow iOS subscription business
Stars: ✭ 93 (+29.17%)
Mutual labels:  subscription, purchase
utopia-crm
Utopía is an open source platform for community based newsrooms to manage their subscriptions
Stars: ✭ 15 (-79.17%)
Mutual labels:  subscription
responsive-html-email-templates
Collection of Free responsive HTML templates for Startups
Stars: ✭ 187 (+159.72%)
Mutual labels:  subscription
vidlist
Command line program to subscribe to youtube channels and view link/thumbnail in a locally generated html page
Stars: ✭ 31 (-56.94%)
Mutual labels:  subscription
apkup
🚀 Publish APKs to Google Play directly from the terminal
Stars: ✭ 33 (-54.17%)
Mutual labels:  google-play
envato-purchase-code-verifier
🚂 A nifty tool for Envato Authors needing to create purchase code verifier as easy and as fast as possible.
Stars: ✭ 19 (-73.61%)
Mutual labels:  purchase
react-native-relay
🚀 demo React Native app using React Navigation and Relay with mutations and subscriptions
Stars: ✭ 20 (-72.22%)
Mutual labels:  subscription
wc4bp
WooCommerce BuddyPress Integration
Stars: ✭ 18 (-75%)
Mutual labels:  purchase
MinifyAllCli
📦 A lightweight, simple and easy npm tool to 𝗺𝗶𝗻𝗶𝗳𝘆 JSON/C, HTML and CSS! Also known as MinifyAll core! ⭐ Usable as 𝑪𝑳𝑰 tool or 𝒊𝒎𝒑𝒐𝒓𝒕𝒂𝒃𝒍𝒆 in TS/JS as a 𝑴𝑶𝑫𝑼𝑳𝑬 🥰
Stars: ✭ 21 (-70.83%)
Mutual labels:  npmjs
DYFStoreKit
([Swift] https://github.com/chenxing640/DYFStore) A lightweight and easy-to-use iOS library for In-App Purchases (Objective-C). DYFStoreKit uses blocks and notifications to wrap StoreKit, provides receipt verification and transaction persistence and doesn't require any external dependencies.
Stars: ✭ 52 (-27.78%)
Mutual labels:  purchase
azure-service-bus-go
Golang library for Azure Service Bus -- https://aka.ms/azsb
Stars: ✭ 67 (-6.94%)
Mutual labels:  subscription
action-mercure
🚀 GitHub Action for Mercure.
Stars: ✭ 14 (-80.56%)
Mutual labels:  subscription
RxBilling
Rx wrapper for Billing Library with connection management
Stars: ✭ 79 (+9.72%)
Mutual labels:  purchase
simple-subscribe
Collect emails with a subscription box you can add to any page and build your own independent subscriber base.
Stars: ✭ 67 (-6.94%)
Mutual labels:  subscription
cashier-register
Cashier Register is a simple quota feature usage tracker for Laravel Cashier subscriptions.
Stars: ✭ 93 (+29.17%)
Mutual labels:  subscription
szkolny-android
Nieoficjalna aplikacja do obsługi najpopularniejszych dzienników elektronicznych w Polsce.
Stars: ✭ 118 (+63.89%)
Mutual labels:  google-play
Android-MonetizeApp
A sample which uses Google's Play Billing Library and it makes In-app Purchases and Subscriptions.
Stars: ✭ 149 (+106.94%)
Mutual labels:  subscription

Node.js Google Play Validator (In-app purchases and Subscriptions)

Or How to check if in-app purchase/subscription is valid?

Tutorial

In-depth tutorial on medium: How to check if in-app purchase / subscription is valid?

Install

Install using npm

npm i google-play-billing-validator

Usage (Set-up)

  1. Go to Developer Console
  2. Settings (in the left side menu)
  3. Select API access
  4. Link your Google Cloud Project to your developer account (If you have not created one yet, go to Google API Console and create one then come back here and link it )
  5. In Google API Console, in the left side menu click on service account
  6. Then create a service account (Don't forget to save private key)
  7. Go back to Developer Console, and grant access to the newly created account (the permission has to be View financial data)
  8. All done

Usage

  • Get Verifier
var Verifier = require('google-play-billing-validator');
  • Add your private key and service account email
var options = {
  "email": 'INSERT SERVICE ACCOUNT EMAIL HERE',
  "key": "INSERT YOUR PRIVATE KEY HERE",
};
  • Create verifier object
var verifier = new Verifier(options);

*Somewhere in your code, where you need to validate purchase or subscription**

Create a receipt object
let receipt = {
  packageName: "your app package name",
  productId: "sku / subscription id",
  purchaseToken: "purchase token"
};
Validate In-app purchase
let promiseData = verifier.verifyINAPP(receipt)

promiseData.then(function(response) {
  // Yay! Purchase is valid
  // See response structure below
})
.then(function(response) {
  // Here for example you can chain your work if purchase is valid
  // eg. add coins to the user profile, etc
  // If you are new to promises API
  // Awesome docs: https://developers.google.com/web/fundamentals/primers/promises
})
.catch(function(error) {
  // Purchase is not valid or API error
  // See possible error messages below
})
Validate Subscription
let promiseData = verifier.verifySub(receipt)

promiseData.then(function(response) {
  // Yay! Subscription is valid
  // See response structure below
})
.then(function(response) {
  // Here for example you can chain your work if subscription is valid
  // eg. add coins to the user profile, etc
  // If you are new to promises API
  // Awesome docs: https://developers.google.com/web/fundamentals/primers/promises
})
.catch(function(error) {
  // Subscription is not valid or API error
  // See possible error messages below
})
Acknowledge Purchase / Subscription

To acknowledge a purchase or a subscription, simple add developerPayload: <String> to the receipt object eg:

let receipt = {
  packageName: "<packageName>",
  productId: "<productId>",
  purchaseToken: "<purchaseToken>",
  developerPayload: "YOUR PAYLOAD"
};

If successful, the result will be

{
   isSuccessful:true,
   errorMessage:null,
   payload:{
      code:204,
      message:'Acknowledged Purchase Successfully'
   }
}
Successful Response (In-app)

Purchases.products @ Google Documentation

{
	"isSuccessful": boolean ,
	"errorMessage": null / string,
	"payload": {
		"kind": "androidpublisher#productPurchase",
		"purchaseTimeMillis": long,
		"purchaseState": integer,
		"consumptionState": integer,
		"developerPayload": string,
		"orderId": string,
		"purchaseType": integer
	}
}
Successful Response (Subscription)

Purchases.subscriptions @ Google Documentation

{
  "isSuccessful": boolean ,
	"errorMessage": null / string,
	"payload": {
		{
			"kind": "androidpublisher#subscriptionPurchase",
			"startTimeMillis": long,
			"expiryTimeMillis": long,
			"autoRenewing": boolean,
			"priceCurrencyCode": string,
			"priceAmountMicros": long,
			"countryCode": string,
			"developerPayload": string,
			"paymentState": integer,
			"cancelReason": integer,
			"userCancellationTimeMillis": long,
			"cancelSurveyResult": {
				"cancelSurveyReason": integer,
				"userInputCancelReason": string
			},
			"orderId": string,
			"linkedPurchaseToken": string,
			"purchaseType": integer,
			"profileName": string,
			"emailAddress": string,
			"givenName": string,
			"familyName": string,
			"profileId": string
		}
	}
}
Failed Response
{
  "isSuccessful": false,
  "errorMessage": "The purchase token does not match the product ID."
}
"Wrong productId (sku)" -> "The purchase token does not match the product ID."
"Wrong purchase token" -> "The purchase token was not found."
"Wrong package name" -> "No application was found for the given package name."

"Wrong service email" -> "Not a valid email or user ID."
"Wrong key" -> "Invalid JWT Signature."
"Wrong service account permissions" -> "The current user has insufficient permissions to perform the requested operation."

Migration from v1 to v2

v1 was a callback based, where v2 is fully promise based. If you are unfamiliar with promises, read this

The migration is very simple:

  1. Remove the callback parameter to verifyINAPP() and/or verifySub() functions
  2. Get result in a promise
  3. See example usage (above)

Links

GitHub
npmjs

Changelog

2.1.3
  • Allow default import syntax from TypeScript Thanks @unpollito
2.1.1
  • Fixed and improved type script support
    Thanks @YogiBear52
2.1.0
  • Added TypeScript support
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].