Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
paypal-rest
Advanced tools
PayPal-REST is an unofficial implementation of the PayPal Rest API. This npm package is here to simplify the usage of this API.
Warning: For the moment, this package is in ALPHA, so it contains very few of the PayPal API functionalities, and has not yet been fully designed for professional use. You are therefore taking a risk by installing and using this package. Avoid using it in production!
You have to use your favorite package manager like npm, pnpm or yarn to install paypal-rest
.
npm i paypal-rest@latest
pnpm add paypal-rest@latest
yarn add paypal-rest@latest
import { config, auth } from 'paypal-rest';
config({
client_id: '', // your PayPal CLIENT_ID
client_secret: '', // your PayPal SECRET
mode: 'sandbox', // 'sandbox' | 'live' ; default: sandbox
auto_renew: false // Let or not the package reconnect you
});
await auth().catch(console.error);
You can get your CLIENT_ID and your CLIENT_SECRET by following these task on the PayPal Docs:
Create, list, get details and update products!
import { product, ProductBuilder } from 'paypal-rest';
const newProduct = await product.create(
new ProductBuilder()
.setName('paypal-rest')
.setType('DIGITAL')
.setDescription('Buy me a coffee')
.setHomeUrl('https://paypal.me/pioupia')
);
const listProduct = await product.list();
const paypalRestProduct = await product.get(listProduct.products?.[0].id!);
await paypalRestProduct
.setDescription("Yes, I'll")
.update();
import { order, ItemsBuilder, PurchaseUnitBuilder, CurrencyCodes } from 'paypal-rest';
// Create an item
const item = new ItemsBuilder()
.setName('coffee')
.setQuantity(1)
.setUnitAmount({
currency_code: CurrencyCodes.UnitedStatesDollar, // or, you can just type 'USD'
value: 1
});
// Create a purchase unit
const purchaseUnit = new PurchaseUnitBuilder()
.setCurrency('USD')
.setPrice(1)
.setDescription("A coffee")
.addItems(item);
// Create the order
const res = await order.create({
purchase_units: [purchaseUnit]
}).catch(console.error);
// And then, when you have to capture this order:
await order.capture(res.id);
FAQs
SDK for REST PayPal API
The npm package paypal-rest receives a total of 2 weekly downloads. As such, paypal-rest popularity was classified as not popular.
We found that paypal-rest demonstrated a not healthy version release cadence and project activity because the last version was released 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's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.