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

@gatevector/browser-sdk

v0.2.1

Published

Browser extension payment SDK for GateVector - Accept payments in Chrome/Firefox extensions

Readme

@gatevector/browser-sdk

Official Browser Extension SDK for GateVector - Accept payments in your Chrome/Firefox extensions.

Installation

npm install @gatevector/browser-sdk

Quick Start

1. Initialize the SDK

import { GateVector } from '@gatevector/browser-sdk';

const gateVector = new GateVector({
  apiBaseUrl: 'https://api.gatevector.com',
  apiKey: 'your-api-key-here'
});

2. Create a One-Time Payment

// In your extension's popup or options page
async function handleUpgrade() {
  await gateVector.openPaymentPage({
    amount: 9.99,
    currency: 'usd',
    mode: 'payment',
    description: 'Premium Upgrade'
  });
}

3. Create a Subscription

async function handleSubscribe() {
  await gateVector.openPaymentPage({
    amount: 4.99,
    currency: 'usd',
    mode: 'subscription',
    interval: 'month',
    description: 'Premium Monthly Subscription'
  });
}

4. Check User Payment Status

async function checkUserStatus() {
  try {
    const status = await gateVector.getUserStatus();
    
    if (status.paid) {
      console.log('User has paid!');
      enablePremiumFeatures();
    } else {
      console.log('User has not paid');
      showUpgradePrompt();
    }
  } catch (error) {
    console.error('Failed to check status:', error);
  }
}

5. Handle Payment Success

// In your success page (success.html)
chrome.runtime.sendMessage({ type: 'payment-success' });

// In your background script
chrome.runtime.onMessage.addListener((message) => {
  if (message.type === 'payment-success') {
    extensionPay.clearCache();
    checkUserStatus();
  }
});

API Reference

Constructor

new ExtensionPay(config: ExtensionPayConfig)

Parameters:

  • config.apiBaseUrl (string): Base URL of your ExtensionPay instance
  • config.apiKey (string): Your organization's API key

Methods

createPaymentSession(options: PaymentSessionOptions): Promise<PaymentSession>

Creates a Stripe Checkout session and returns the session URL.

Options:

  • amount (number, required): Payment amount (e.g., 9.99)
  • currency (string, optional): Currency code (default: 'usd')
  • mode ('payment' | 'subscription', optional): Payment mode (default: 'payment')
  • successUrl (string, optional): Redirect URL after successful payment
  • cancelUrl (string, optional): Redirect URL after cancelled payment
  • description (string, optional): Payment description
  • locale (string, optional): Checkout page locale (default: 'auto')
  • priceId (string, optional): Stripe Price ID for subscriptions
  • interval ('day' | 'week' | 'month' | 'year', optional): Subscription interval
  • intervalCount (number, optional): Interval count (e.g., 3 for every 3 months)

Returns:

{
  url: string;         // Stripe Checkout URL
  session_id?: string; // Checkout session ID
}

openPaymentPage(options: PaymentSessionOptions): Promise<void>

Creates a payment session and opens it in a new tab (Chrome) or window.

getUserStatus(userId?: string): Promise<UserStatus>

Checks if a user has paid. Results are cached for 60 seconds.

Parameters:

  • userId (string, optional): User identifier (if not provided, uses default)

Returns:

{
  paid: boolean;
  customer_id?: string;
  subscription_id?: string;
  subscription_status?: string;
  subscription_cancel_at_period_end?: boolean;
}

confirmPayment(sessionId: string): Promise<{ status: string }>

Confirms a payment after checkout (hybrid safety net).

clearCache(userId?: string): void

Clears the user status cache. Call this after successful payments.

setApiKey(apiKey: string): void

Updates the API key and clears cache.

setApiBaseUrl(apiBaseUrl: string): void

Updates the base URL and clears cache.

Manifest Configuration

Chrome Extension (Manifest V3)

{
  "manifest_version": 3,
  "name": "Your Extension",
  "permissions": [
    "tabs"
  ],
  "host_permissions": [
    "https://api.extensionpay.io/*"
  ]
}

Firefox Add-on (Manifest V2)

{
  "manifest_version": 2,
  "name": "Your Extension",
  "permissions": [
    "tabs",
    "https://api.extensionpay.io/*"
  ]
}

Complete Example

background.js (Service Worker)

import ExtensionPay from '@extensionpay/browser-sdk';

const extensionPay = new ExtensionPay({
  apiBaseUrl: 'https://api.extensionpay.io',
  apiKey: 'your-api-key'
});

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.type === 'check-status') {
    extensionPay.getUserStatus()
      .then(status => sendResponse({ paid: status.paid }))
      .catch(error => sendResponse({ error: error.message }));
    return true;
  }
  
  if (message.type === 'upgrade') {
    extensionPay.openPaymentPage({
      amount: 9.99,
      mode: 'payment',
      description: 'Premium Upgrade'
    }).catch(error => console.error(error));
  }
  
  if (message.type === 'payment-success') {
    extensionPay.clearCache();
    chrome.storage.local.set({ premium: true });
  }
});

popup.html + popup.js

document.getElementById('upgrade-btn').addEventListener('click', async () => {
  chrome.runtime.sendMessage({ type: 'upgrade' });
});

chrome.runtime.sendMessage({ type: 'check-status' }, (response) => {
  if (response.paid) {
    document.getElementById('status').textContent = 'Premium Active';
  }
});

success.html

<!DOCTYPE html>
<html>
<head>
  <title>Payment Success</title>
</head>
<body>
  <h1>Payment Successful!</h1>
  <p>Thank you for upgrading to Premium.</p>
  <script>
    chrome.runtime.sendMessage({ type: 'payment-success' });
    setTimeout(() => window.close(), 2000);
  </script>
</body>
</html>

Best Practices

  1. Cache User Status: The SDK automatically caches user status for 60 seconds. Don't call getUserStatus() on every page load.

  2. Clear Cache After Payment: Always call clearCache() after successful payments to ensure fresh status.

  3. Handle Errors: Wrap API calls in try-catch blocks and handle network errors gracefully.

  4. Store Premium State: After confirming payment, store premium status in chrome.storage for offline access.

  5. Test in Development: Use test API keys and test mode in Stripe during development.

Support

  • Documentation: https://docs.extensionpay.io
  • Issues: https://github.com/xgame92/extensionpay-io-v2/issues

License

MIT