npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

oem-inapppurchases

v1.0.11

Published

Node.js and TypeScript helpers for verifying Google Play subscriptions and Apple App Store receipts.

Readme

oem-inapppurchases

Node.js and TypeScript package for server-side verification of:

  • Google Play subscriptions
  • Apple App Store receipts

The package exports:

  • PaymentGatewayFactory to select a store implementation
  • InAppPurchases to run a shared verification flow

Installation

npm install oem-inapppurchases

Exports

import { InAppPurchases, PaymentGatewayFactory } from "oem-inapppurchases";

Gateway Names

Use these values with getPaymentGatewayObject(...):

  • playstore
  • appstore

Payloads

Play Store

| Field | Type | Required | Description | | --- | --- | --- | --- | | email | string | Yes | Google service account email | | privateKey | string | Yes | Google service account private key | | packageName | string | Yes | Android package name | | productId | string | Yes | Subscription product ID | | purchaseToken | string | Yes | Purchase token returned by the client app |

App Store

| Field | Type | Required | Description | | --- | --- | --- | --- | | secretKey | string | Yes | App Store shared secret | | sandBox | number | Optional | Backward-compatible alias for internal Appstore API selection (0 or 9) | | dumpData | string | Yes | Base64-encoded receipt data |

Basic Usage

import { InAppPurchases, PaymentGatewayFactory } from "oem-inapppurchases";

const factory = new PaymentGatewayFactory();
const gateway = factory.getPaymentGatewayObject("playstore");

const iap = new InAppPurchases({
  email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL!,
  privateKey: process.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY!.replace(/\\n/g, "\n"),
  packageName: "com.example.app",
  productId: "premium_monthly",
  purchaseToken: "purchase-token-from-device"
});

const result = await iap.verifyPayment(gateway);
console.log(result);

Store-Specific Notes

Google Play

  • verifyPayment() uses the Google Play Android Publisher subscriptions API and acknowledges the subscription when it is still pending acknowledgement.
  • verifyPaymentWithData() uses subscriptionsv2.get() and returns a normalized payload through InAppPurchases.verifyPaymentWithData(...).

Example:

const gateway = new PaymentGatewayFactory().getPaymentGatewayObject("playstore");
const iap = new InAppPurchases({
  email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL!,
  privateKey: process.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY!.replace(/\\n/g, "\n"),
  packageName: "com.example.app",
  productId: "premium_monthly",
  purchaseToken: "purchase-token-from-device"
});

const result = await iap.verifyPaymentWithData(gateway);

Typical normalized Play Store shape:

{
  status: true,
  data: {
    packageName: "com.example.app",
    token: "purchase-token-from-device",
    subscriptionState: "...",
    acknowledgementState: "...",
    startTime: "...",
    latestOrderId: "...",
    regionCode: "...",
    raw: { ... }
  }
}

App Store

Example:

const gateway = new PaymentGatewayFactory().getPaymentGatewayObject("appstore");
const iap = new InAppPurchases({
  secretKey: process.env.APPLE_SHARED_SECRET!,
  sandBox: 0,
  dumpData: "base64-receipt-data"
});

const result = await iap.verifyPayment(gateway);

Notes:

  • verifyPayment() and verifyPaymentWithData() both wrap the Apple verifyReceipt response as { status: true, data: ... }.
  • The current implementation retries transient App Store statuses 21005 and 21009.
  • verifyPaymentWithData() also contains a legacy fallback path for 21007 when sandBox is set to 9.

API

new PaymentGatewayFactory().getPaymentGatewayObject(name)

Returns the store verifier instance for:

  • playstore
  • appstore

Throws Payment Gateway Not Found for unsupported values.

new InAppPurchases(payload).verifyPayment(gateway)

Runs verification and returns:

{
  status: true,
  data: any
}

new InAppPurchases(payload).verifyPaymentWithData(gateway)

Runs verification and returns:

{
  status: boolean,
  data: any
}

For Play Store, this is the normalized subscription payload shown above. For App Store, this is the receipt verification response body.

Errors

Common thrown errors include:

  • Payment Gateway Not Found
  • validation errors for missing required fields
  • Unable to verify payment
  • Failed to verify purchase:<statusText>

Development

npm run build
npm run dev

License

ISC