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 🙏

© 2025 – Pkg Stats / Ryan Hefner

iap-verification-sdk

v1.0.12

Published

SDK for verifying in-app purchases from Google Play and Apple App Store

Readme

IAP Verification SDK

A Node.js SDK for verifying in-app purchases from Google Play Store and Apple App Store.

Features

  • Unified API for both Google Play and Apple App Store
  • Simple configuration
  • Platform auto-detection
  • Consistent response format
  • Error handling
  • Environment support (sandbox/production)
  • Backward compatibility with android/ios platform names

Installation

npm install iap-verification-sdk --save

Usage

Initializing the SDK

const iapVerifier = require('iap-verification-sdk');

// Create a verifier instance with your configuration
const verifier = iapVerifier.create({
  // Set environment to 'sandbox' or 'production'
  environment: 'sandbox',
  
  // Google Play configuration
  google: {
    serviceAccount: {
      // Your service account JSON contents
      type: 'service_account',
      project_id: 'your-project-id',
      private_key_id: 'your-private-key-id',
      private_key: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
      client_email: 'your-service-account-email',
      client_id: 'your-client-id',
      // ... other service account fields
    }
  },
  
  // Apple App Store configuration
  apple: {
    issuerId: 'your-issuer-id',
    keyId: 'your-key-id',
    bundleId: 'your-bundle-id',
    privateKey: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
    sharedSecret: 'your-shared-secret' // Optional, for legacy verification
  }
});

Verifying Google Play Purchases

// Verify a Google Play purchase
const googleResult = await verifier.verify({
  platform: 'google', // Both 'google' and 'android' are supported for backward compatibility
  packageName: 'com.example.app',
  productId: 'premium_upgrade',
  purchaseToken: 'token-from-purchase'
});

console.log(googleResult);
// {
//   isSuccess: true,
//   statusCode: 200,
//   message: 'VERIFY_PURCHASE_SUCCESS',
//   result: {
//     status: 'COMPLETED', // or 'WAITING', 'FAILED', 'PENDING'
//     productId: 'premium_upgrade',
//     orderId: '12345678',
//     transactionId: '12345678',
//     purchaseDate: 1632150000000,
//     environment: 'Sandbox'
//   }
// }

Verifying Apple App Store Purchases

// Verify an Apple App Store purchase
const appleResult = await verifier.verify({
  platform: 'apple', // Both 'apple' and 'ios' are supported for backward compatibility
  transactionId: '1000000123456789'
});

console.log(appleResult);
// {
//   isSuccess: true,
//   statusCode: 200,
//   message: 'VERIFY_PURCHASE_SUCCESS',
//   result: {
//     status: 'COMPLETED', // or 'WAITING', 'FAILED', 'PENDING'
//     bundleId: 'com.example.app',
//     productId: 'premium_upgrade',
//     transactionId: '1000000123456789',
//     purchaseDate: 1632150000000,
//     environment: 'Sandbox'
//   }
// }

Direct Verification (One-time Use)

const { verify } = require('iap-verification-sdk');

// Verify a purchase directly
const result = await verify({
  config: {
    environment: 'sandbox',
    google: { /* ... */ },
    apple: { /* ... */ }
  },
  platform: 'google',
  packageName: 'com.example.app',
  productId: 'premium_upgrade',
  purchaseToken: 'token-from-purchase'
});

Platform Auto-detection

// SDK will auto-detect the platform based on provided parameters
const result = await verifier.verify({
  // Google Play parameters
  packageName: 'com.example.app',
  productId: 'premium_upgrade',
  purchaseToken: 'token-from-purchase'
});

// OR

const result = await verifier.verify({
  // Apple App Store parameters
  transactionId: '1000000123456789'
});

Platform Naming

The SDK supports both new and old platform naming conventions for backward compatibility:

  • Google Play Store: 'google' or 'android'
  • Apple App Store: 'apple' or 'ios'

We recommend using the new naming convention ('google' and 'apple'), but the SDK will automatically normalize old platform names.

Publishing and Versioning

This package includes scripts to help with publishing and versioning:

# Publish with automatic patch version increment
npm run release:patch

# Publish with automatic minor version increment
npm run release:minor

# Publish with automatic major version increment
npm run release:major

# Alternative: use the publish.js script
node publish.js patch   # or minor, major

License

MIT