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

@ticketbot/paypal-sdk

v1.0.1

Published

Stripe-inspired PayPal SDK for Node.js with full TypeScript support

Readme

TicketBot PayPal SDK

A modern, Stripe-inspired PayPal SDK for Node.js with full TypeScript support.

Why This SDK?

PayPal's official SDKs are incomplete and don't support many of their own APIs. This SDK provides:

  • Complete API Coverage - All PayPal REST APIs including subscriptions, billing, webhooks
  • Stripe-like Developer Experience - Clean, intuitive API design
  • Full TypeScript Support - Comprehensive type definitions
  • Automatic Token Management - No manual OAuth handling
  • Built-in Retry Logic - Handles network errors and rate limiting
  • Webhook Verification - Secure webhook handling

Installation

npm install @ticketbot/paypal-sdk

Quick Start

import { PayPal } from '@ticketbot/paypal-sdk';

const paypal = PayPal.create({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  environment: 'sandbox', // or 'live'
  webhookId: 'your_webhook_id'
});

// Create a subscription
const subscription = await paypal.subscriptions.create({
  plan_id: 'your_plan_id',
  start_time: new Date().toISOString(),
  application_context: {
    return_url: 'https://yoursite.com/success',
    cancel_url: 'https://yoursite.com/cancel',
    user_action: 'SUBSCRIBE_NOW'
  }
});

// Cancel a subscription
await paypal.subscriptions.cancel('subscription_id', 'User requested cancellation');

// Verify webhooks
const isValid = await paypal.webhooks.verifySignature(headers, body, webhookId);

API Reference

Subscriptions

// Create subscription
const subscription = await paypal.subscriptions.create(params);

// Get subscription
const subscription = await paypal.subscriptions.retrieve('sub_id');

// Update subscription (plan changes)
const updated = await paypal.subscriptions.update('sub_id', updateParams);

// Cancel subscription
await paypal.subscriptions.cancel('sub_id', 'reason');

// List subscriptions
const subscriptions = await paypal.subscriptions.list({
  plan_id: 'plan_id',
  page_size: 10
});

Plans

// Create plan
const plan = await paypal.plans.create({
  name: 'Basic Plan',
  billing_cycles: [/* billing cycles */]
});

// Get plan
const plan = await paypal.plans.retrieve('plan_id');

// List plans
const plans = await paypal.plans.list();

Orders (One-time payments)

// Create order
const order = await paypal.orders.create({
  intent: 'CAPTURE',
  purchase_units: [/* purchase units */]
});

// Capture order
const capture = await paypal.orders.capture('order_id');

Webhooks

// Verify webhook signature
const isValid = await paypal.webhooks.verifySignature(
  headers,
  rawBody,
  webhookId
);

// Parse webhook event
const event = paypal.webhooks.constructEvent(body, headers, webhookId);

Error Handling

The SDK provides comprehensive error handling:

import { PayPalAPIError, PayPalConnectionError } from '@ticketbot/paypal-sdk';

try {
  const subscription = await paypal.subscriptions.create(params);
} catch (error) {
  if (error instanceof PayPalAPIError) {
    console.log('API Error:', error.code, error.message);
    console.log('Debug ID:', error.debugId);
    console.log('Details:', error.details);
  } else if (error instanceof PayPalConnectionError) {
    console.log('Connection Error:', error.message);
  }
}

TypeScript Support

Full TypeScript definitions are included:

import { Subscription, Plan, CreateSubscriptionParams } from '@ticketbot/paypal-sdk';

const params: CreateSubscriptionParams = {
  plan_id: 'plan_123',
  start_time: new Date().toISOString(),
  // Full autocomplete and type checking
};

Migration from Legacy SDKs

From paypal-rest-sdk

// Old way
const paypal = require('paypal-rest-sdk');
paypal.configure({ ... });
paypal.billingPlan.create(planData, callback);

// New way
const paypal = PayPal.create({ ... });
const plan = await paypal.plans.create(planData);

Advanced Configuration

// Set default config 
PayPal.setDefaultConfig({
  timeout: 60000,
  maxRetries: 3
});

// Create client with custom config
const paypal = PayPal.create({
  clientId: process.env.PAYPAL_CLIENT_ID,
  clientSecret: process.env.PAYPAL_CLIENT_SECRET,
  environment: process.env.NODE_ENV === 'production' ? 'live' : 'sandbox',
  timeout: 30000,
  maxRetries: 2
});

License

MIT - See LICENSE file for details.