Registry / payments / paypal-rest-api

paypal-rest-api

JSON →
library0.0.52jsnpmunverified

A TypeScript SDK for PayPal REST APIs that provides a non-singleton design for multi-currency support, built on requestretry for automatic retries with idempotency, native promises, and Joi schema validation. Version 0.0.52, active development, includes TypeScript types, and offers mock support for testing. Differentiators vs official PayPal Node SDK: ES6+ features, access token expiration tracking, and support for multiple PayPal apps.

npm install paypal-rest-api
INSTALL
IMPORT
SIG · PAYPAL-REST-API
P
paypal-rest-api
paymentsjavascriptv0.0.52
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PayPalRestApi
import { PayPalRestApi } from 'paypal-rest-api'
const PayPalRestApi = require('paypal-rest-api')
Default export not available; must use named import. For CommonJS, use 'const { PayPalRestApi } = require('paypal-rest-api')'.

Initializes the PayPal client with credentials and creates a sale payment.

import { PayPalRestApi } from 'paypal-rest-api'; const paypal = new PayPalRestApi({ client_id: process.env.PAYPAL_CLIENT_ID ?? '', client_secret: process.env.PAYPAL_CLIENT_SECRET ?? '', mode: 'sandbox', requestOptions: { maxRetries: 2, retryDelay: 5000 } }); async function createPayment() { try { const payment = await paypal.payment.create({ intent: 'sale', payer: { payment_method: 'paypal' }, transactions: [{ amount: { total: '10.00', currency: 'USD' } }], redirect_urls: { return_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel' } }); console.log('Payment created:', payment); } catch (err) { console.error('Error:', err); } } createPayment();
Debug
Known issues
gotchaThis package is NOT supported by PayPal. Use at your own risk.
fix
Consider using the official PayPal Node SDK for production.
affects: *
gotchaThe 'request' library is deprecated. This package depends on it via requestretry.
fix
Monitor for updates; consider alternatives like axios-based SDKs.
affects: >=0.0.1
breakingBreaking changes may occur at any minor version (semver not strictly followed due to low version).
fix
Pin exact version in package.json.
affects: <1.0.0
Errors
Common errors & fixes
Cannot find module 'paypal-rest-api'
Package not installed or import path incorrect.
fix
Run 'npm install paypal-rest-api' and ensure import is 'import { PayPalRestApi } from 'paypal-rest-api'.
TypeError: paypal.payment.create is not a function
Method name mismatch or API version.
fix
Check the API: use lowercase methods like 'payment.create'. Refer to examples.
Error: requestOptions.maxRetries must be a number
Configuration option passed incorrectly.
fix
Ensure requestOptions is an object and maxRetries is an integer.
Upgrade
Version history
0.0.52latest on npm
Audit
Dependencies
requestretryrequiredHTTP client with retry logic
requestrequiredUnderlying HTTP request library
joirequiredSchema validation for API calls
Agent activity
29 hits · last 30 days
node
26
Resources
paypal-rest-api — npm install paypal-rest-api · libregistry