WIP
A flexible and lightweight SDK for building PayPal integrations with dynamic endpoints, caching, and response transformations.
PayPal SDK for Node.js provides the ability to call PayPal REST API from a Node.js server. It includes making API requests to PayPal servers, generating order information, and supporting authentication and caching capabilities.
Based on the PayPal REST API.
- Node.js >= 18.0.0
- Pre-configured API endpoints for PayPal's platform
- Support for Redis and in-memory caching
- Easy extensibility
Install the SDK using pnpm
or yarn
:
pnpm add @nuecms/paypal-sdk
# or
yarn add @nuecms/paypal-sdk
import { paypalSdk } from '@nuecms/paypal-sdk';
const sdk = paypalSdk({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
});
sdk.r('getOrder', '/v2/checkout/orders/{order_id}', 'GET');
sdk.r('createOrder', '/v2/checkout/orders', 'POST');
const order = await sdk.getOrder({ order_id: '12345' });
console.log(order);
See the testing code in the tests
folder.
Example:
Register endpoints with their HTTP method, path, and dynamic placeholders (e.g., {order_id}
):
sdk.r('getOrder', '/v2/checkout/orders/{order_id}', 'GET');
sdk.r('captureOrder', '/v2/checkout/orders/{order_id}/capture', 'POST');
sdk.r('refundOrder', '/v2/payments/captures/{capture_id}/refund', 'POST');
Call the registered endpoints dynamically with placeholders and additional options:
const orderDetails = await sdk.getOrder({ order_id: '12345' });
console.log(orderDetails);
We welcome contributions to improve this SDK! To get started:
- Fork the repository.
- Create a new branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m "Add feature X"
). - Push to the branch (
git push origin feature-name
). - Open a pull request.
This SDK is released under the MIT License. You’re free to use, modify, and distribute this project. See the LICENSE
file for more details.