/paypal-sdk

Primary LanguageTypeScriptMIT LicenseMIT

PayPal Logo PayPal 2

Installation

NPM Logo Installing with npm
npm install paypal2
PNPM Logo Installing with pnpm
pnpm add paypal2
Yarn Logo Installing with yarn
yarn add paypal2

Example

const paypal = require("paypal2");
const { Mode } = paypal.Constants;
const env = process.env;

paypal.initPaypal({
  clientId: env.PAYPAL_ID,
  clientSecret: env.PAYPAL_SECRET,
  mode: Mode.SANDBOX
}).then((client) => {
    const order = await client.orders.create({
      intent: paypal.Constants.Intent.CAPTURE,
      purchaseUnits: [
        {
          amount: {
            currencyCode: "USD",
            value: 10,
          },
        },
      ],
    });

    // Print order response in console
    console.log(order);
});