Package Exports
- paypal-server-api
- paypal-server-api/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (paypal-server-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Site | NPM Module | GitHub Repo
PayPal API makes it easy to work with the PayPal API.
Install
Install with npm:
npm install paypal-server-api
Features
- Work with the PayPal API
Example Setup
After installing via npm, simply require
the library and authenticate it.
// In your functions/index.js file
const Payapl = require('paypal-server-api');
const paypal = new Payapl({
clientId: 'client_id', // Your PayPal client ID
secret: 'secret', // Your PayPal secret
environment: 'production', // Determine which API URL to use (sandbox OR production)
log: true, // Log some information to the console
});
// Authenticate with PayPal
await paypal.authenticate();
Making calls
After installing and authenticating, begin enjoying the library 🧰.
// Get subscription details
const subscription = await paypal.execute(`v1/billing/subscriptions/I-ABC123ABC123`);
// Update subscription pricing
const update = await paypal.execute(`v1/billing/subscriptions/I-ABC123ABC123`, {
method: 'PATCH',
body: [
{
op: 'replace',
path: '/plan/billing_cycles/@sequence==1/pricing_scheme/fixed_price',
value: {
currency_code: 'USD',
value: '19.95',
},
},
{
op: 'replace',
path: '/plan/payment_preferences/payment_failure_threshold',
value: 0,
},
{
op: 'replace',
path: '/plan/payment_preferences/auto_bill_outstanding',
value: true,
},
]
});
Testing the library
Add your PayPal client secret and client ID to environment variables and run the test command
export PAYPAL_CLIENT_ID="..."
export PAYPAL_SECRET="..."
export PAYPAL_SUBSCRIPTION_ID="..."
npm run test
Final Words
If you are still having difficulty, we would love for you to post a question to the PayPal API issues page. It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
Projects Using this Library
Somiibo: A Social Media Bot with an open-source module library.
JekyllUp: A website devoted to sharing the best Jekyll themes.
Slapform: A backend processor for your HTML forms on static sites.
Proxifly: A backend processor for your HTML forms on static sites.
SoundGrail Music App: A resource for producers, musicians, and DJs.
Hammock Report: An API for exploring and listing backyard products.
Ask us to have your project listed! :)