PayPal 2
Installing with npm
Installing with pnpm
Installing with yarn
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);
});