
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@ticketbot/paypal-sdk
Advanced tools
Stripe-inspired PayPal SDK for Node.js with full TypeScript support
A modern, Stripe-inspired PayPal SDK for Node.js with full TypeScript support.
PayPal's official SDKs are incomplete and don't support many of their own APIs. This SDK provides:
npm install @ticketbot/paypal-sdk
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);
// 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
});
// 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();
// Create order
const order = await paypal.orders.create({
intent: 'CAPTURE',
purchase_units: [/* purchase units */]
});
// Capture order
const capture = await paypal.orders.capture('order_id');
// Verify webhook signature
const isValid = await paypal.webhooks.verifySignature(
headers,
rawBody,
webhookId
);
// Parse webhook event
const event = paypal.webhooks.constructEvent(body, headers, webhookId);
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);
}
}
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
};
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);
// 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
});
MIT - See LICENSE file for details.
FAQs
Stripe-inspired PayPal SDK for Node.js with full TypeScript support
The npm package @ticketbot/paypal-sdk receives a total of 32 weekly downloads. As such, @ticketbot/paypal-sdk popularity was classified as not popular.
We found that @ticketbot/paypal-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.