Google Play In App Purchase Validation in Node.js

How to validate in-app purchases server side for Google Play apps

Ross Bulat
8 min readJul 7, 2021

Introduction

In-app purchase validation is a critical task that every app supporting purchases and subscription should implement as a means to prove the integrity of purchase tokens and transaction records. Validation can be used to validate a newly created transaction or validate a subscription to check it is still active.

An in-app purchase is initiated on a user’s device; the user authenticates a purchase which is then processed on Google servers, and a successful response should be sent back to the user’s device.

It is with this successful response that a purchaseToken is provided — a unique string that acts as a receipt of the purchase. In order to validate a purchase with Google Billing at any time in the future, the purchaseToken must be supplied to such API calls, that will be discussed further down.

Needless to say, the purchaseToken should be securely persisted in your database and associated with a particular user of your app, otherwise it would not be possible to validate any purchases made by that user.

This article will explain the setup process of validating Google Play in-app purchases. It is split…

--

--

Ross Bulat

Programmer and Author. @ Parity Technologies, JKRB Investments