@toolkitx/paypal
Installing
Using npm
npm install @toolkitx/paypal
Example
Get instance
import {Paypal, PayPalEnvironment} from '@toolkitx/paypal';
const conf = new PayPalEnvironment('CLIENT_ID', 'CLIENT_SECRET', 'Sandbox|Live', 'v1');
const paypal = new Paypal(conf);
Chain
paypal
.api('URL')
.head(key, value)
.query({key: 'value'})
.get()
// or .post(payload)
- Get products
const products: PaypalPageResponse = await paypal.products().get();
- Get single product
const product = await paypal.products('Product id').get();
- Query products
const v = await paypal.products().query({param1: 'EXAMPLE'}).get();
- Plan actions
Support activate/deactivate/updatePricingSchemes
plans
await payPal.plans(testPlanId).activate().post();
- Subscription actions
Support activate/cancel/suspend
subscription
await payPal.subscriptions('id').suspend().post({
"reason": "suspend reason"
});
Custom Request
await paypal.api('RELATE_URL').get();
await paypal.api('RELATE_URL').post(payload);