Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 1.82 KB

README.md

File metadata and controls

69 lines (47 loc) · 1.82 KB

@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.