@cowboysandwitches/paypal-utils
v0.1.0
Published
An unofficial PayPal utils package helping to integrate PayPal Checkout more easily - with good types and JSDoc annotations.
Downloads
3
Readme
@cowboysandwitches/paypal-utils
An unofficial PayPal utils package helping to integrate PayPal Checkout more easily - with good types and JSDoc annotations.
Usage
Creating an ServerUtils
instance
const serverUtils = new ServerUtils({
isSandbox: true,
credentials: {
clientId: "blibla...",
clientSecret: "blub...",
},
});
Creating an order
const serverUtils = new ServerUtils(...);
const order = serverUtils.createOrder({
intent: ServerUtilsCreateOrderOptionsIntent.Capture,
purchaseUnits: [
{
amount: {
currencyCode: "EUR",
value: "1",
},
},
],
});
assert(order.ok);
console.debug(`Created order ${order.data.id}`);
Capturing the payment for an order
const serverUtils = new ServerUtils(...);
const capturedOrder = await serverUtils.capturePaymentForOrder({
orderId: "...",
});
assert(capturedOrder.ok);
console.debug(`Captured order ${capturedOrder.id}.`);