Skip to content

An unofficial PayPal utils package helping to integrate PayPal Checkout more easily - with good types and JSDoc annotations.

License

Notifications You must be signed in to change notification settings

cowboysandwitches/paypal-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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}.`);

About

An unofficial PayPal utils package helping to integrate PayPal Checkout more easily - with good types and JSDoc annotations.

Resources

License

Stars

Watchers

Forks