@jeremybarbet/node-iap
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

@jeremybarbet/node-iap

Node.js library for Apple and Google IAP.

Installation

yarn add @jeremybarbet/node-iap

Google

Getting a service account up and running is surprisingly really hard. Mostly, because of a mix of permissions, scopes, and order in which you are doing all these operations has a huge impact.

  • I recommend following this official documentation to create a new service account. This library use service account's clientEmail and privateKey, so you can ignore the "OAuth client" paragraphs.

Apple

  • Generate an Apple password through the App Store Connect. I recommend creating an "app-specific shared secret".

Usage

import { verifyAppleReceipt, verifyGoogleReceipt } from '@jeremybarbet/node-iap';

const { data } = verifyAppleReceipt(
  {
    transactionReceipt: 'BASE_64_RECEIPT',
  },
  {
    password: 'APPLE_PASSWORD',
  },
);

const { data } = verifyGoogleReceipt(
  {
    packageName: 'PACKAGE_NAME',
    token: 'TOKEN',
    productId: 'PRODUCT_ID',
  },
  {
    clientEmail: 'GOOGLE_CLIENT_EMAIL',
    privateKey: 'GOOGLE_PRIVATE_KEY',
  },
);

Example

You can find an example in the example directory.

You will first, need to duplicate the data.example.json file, rename it data.json and provide your own Apple and Google credentials and receipt data. Then you can run the example:

yarn ts-node ./packages/node-iap/example/index.ts

Supported platforms

  • Apple
  • Google

Acknowledgments

License

This library is licensed under the MIT License.

Dependencies (4)

Dev Dependencies (3)

Package Sidebar

Install

npm i @jeremybarbet/node-iap

Weekly Downloads

1,337

Version

1.4.1

License

MIT

Unpacked Size

29.8 kB

Total Files

36

Last publish

Collaborators

  • jeremy.barbet