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

cordova-plugin-google-play-verify

v1.0.0

Published

Cordova plugin to verify Google Play Subscriptions using Service Account credentials directly on Android device (Client-side Server Verification).

Readme

cordova-plugin-google-play-verify

License: MIT Platform

A professional, enterprise-grade Cordova plugin for Server-Side Verification of Google Play Subscriptions and In-App Products. This plugin utilizes a Native Java Bridge to communicate directly with the Google Publisher API, ensuring maximum security and reliability for your billing system.

💸 Why choose this plugin? (Free vs Paid)

Unlike third-party services (e.g., RevenueCat, Qonversion) that charge monthly fees or take a cut of your revenue, this plugin is 100% FREE.

  • Direct Connection: We connect your app directly to Google's official infrastructure (Google Cloud Platform).
  • No Middleman: Your data stays between you and Google. No third-party servers involved.
  • Zero Cost: Because we use the official GCP path, you avoid the "convenience tax" charged by other platforms.

Because this is the official method, the setup steps are MANDATORY. You are essentially configuring your own backend security, which gives you full control and saves you money.

📊 Quotas & API Versions

  • Generous Quota: Google provides a default quota of 200,000 requests per day (per app). This is more than sufficient for almost any subscription-based app unless you have millions of daily active users checking subscriptions every second.
  • Latest Technology: This guide and plugin utilizes the modern com.google.apis:google-api-services-androidpublisher:v3. Please ignore older tutorials referencing v1 or v2 APIs as they are obsolete.

🚀 Key Features

  • Native-Level Security: Moves sensitive verification logic from vulnerable JavaScript to the Android Native layer.
  • Sandbox Self-Healing: Built-in automatic handling for the common Error 400 (subscriptionInvalidArgument) bug found in the Google Play Sandbox environment for Prepaid plans.
  • Production-Ready Data: Java returns pre-processed data (isPremium, expiryTimeMillis) so you can build professional membership UIs without complex date manipulation.
  • Fraud Protection: Integrated support for the Voided Purchases API to detect and block users who have fraudulently claimed refunds.
  • Detailed Developer Logs: Provides a comprehensive debugLog string from Native to your JS console for rapid troubleshooting.

🛠 Installation

This plugin is designed to verify purchases made with the standard billing plugin.

# 1. Install the Purchase plugin (Required to initiate purchases & get tokens)
cordova plugin add cordova-plugin-purchase

# 2. Install the Verification plugin (Required to verify receipts securely)
cordova plugin add cordova-plugin-google-play-verify

📋 Setup Prerequisites (Important)

To use this plugin, you must configure a Google Cloud Service Account. This is required to authorize your app to speak with Google servers.

👉 CLICK HERE for the Full Setup Guide (Step-by-Step)

Summary of requirements:

  1. Google Cloud Console: Enable the Google Play Android Developer API.
  2. Service Account: Create a Service Account, generate a JSON Key, and download it.
  3. Play Console: Link your GCP project and invite the Service Account email under "Users & Permissions" with "View financial data" permissions.

📖 API Usage

1. Configuration

Store your Service Account JSON securely. It is recommended to load it from an external configuration file (e.g., config.js).

const params = {
    purchaseToken: "token-from-google-play", // Obtained from CdvPurchase
    subscriptionId: "your_product_id",
    packageName: "com.your.package",
    credentials: MY_CONFIG.SERVICE_ACCOUNT // Full JSON object
};

2. Verify Subscriptions (Prepaid & Recurring)

Handles all subscription types with automatic Sandbox fixes.

cordova.plugins.GoogleSubVerify.getSubscriptionStatus(params, (res) => {
    // res.debugLog contains technical details for your dev console
    console.log(res.debugLog);

    if (res.isPremium) {
        const expiry = new Date(res.expiryTimeMillis).toLocaleString();
        console.log("Access Granted! Expiry: " + expiry);
    } else {
        console.log("Access Denied: Expired or Invalid.");
    }
}, (err) => {
    console.error("Verification Error: " + err);
});

3. Verify One-Time Products (IAP)

Use this for consumable items (coins/gems) or permanent unlocks.

cordova.plugins.GoogleSubVerify.getProductStatus(params, (res) => {
    console.log(res.debugLog);
    if (res.isValid) {
        console.log("In-App Product verified successfully!");
    }
}, (err) => {
    console.error(err);
});

4. Acknowledge Purchase (Required)

Mandatory: You must acknowledge purchases within 3 days to prevent automatic refunds by Google Play.

cordova.plugins.GoogleSubVerify.acknowledge(params, (res) => {
    console.log("Transaction acknowledged: " + res.message);
}, (err) => {
    console.error("Acknowledge failed: " + err);
});

5. Fraud Detection (Voided Purchases)

Scan for transactions that were refunded or cancelled after access was granted.

cordova.plugins.GoogleSubVerify.voidedPurchases(params, (res) => {
    console.log("Total voided transactions found: " + res.totalVoided);
    res.voidedList.forEach(item => {
        console.warn("Fraudulent Order ID: " + item.orderId);
    });
}, (err) => {
    console.error(err);
});

⚠️ Error Handling

The plugin translates complex Google API errors into readable instructions:

  • 401: Invalid/Expired Service Account credentials.
  • 403: Permission denied (Check Play Console settings).
  • 404: Product ID or Purchase Token not found.
  • 400 (Fixed): Automatically handled for Sandbox Prepaid "Invalid Argument" bugs.

❤️ Support the Project

This plugin is developed and maintained in my free time. If it saved you hours of work, consider supporting the development!

Your support helps me keep the dependencies updated and the cleaner script running smoothly.

📄 License

Licensed under the MIT License.


Contributions & Feedback: If you find a bug or have a suggestion, please open an issue or submit a pull request on GitHub. Your support is appreciated!