# paypal-api

> Node.js package to interact with PayPal REST API

Latest version **0.1.4** (published 2021-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install paypal-api
pnpm add paypal-api
yarn add paypal-api
bun add paypal-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2021-04-15 |
| First published | 2020-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 24.8 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Androz2091 |
| Maintainers | androz2091 |

## Links

- npm: https://www.npmjs.com/package/paypal-api
- Repository: https://github.com/Androz2091/paypal-api
- Homepage: https://github.com/Androz2091/paypal-api#readme
- Issues: https://github.com/Androz2091/paypal-api/issues
- npm.io page: https://npm.io/package/paypal-api

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.0

## Recent versions

- 0.1.4 (latest) — 2021-04-15
- 0.1.3 — 2021-04-15
- 0.1.2 — 2021-04-15
- 0.1.1 — 2021-04-15
- 0.0.5 — 2020-12-21
- 0.0.4 — 2020-12-20
- 0.0.3 — 2020-12-20
- 0.0.2 — 2020-12-20
- 0.0.1 — 2020-12-20

## README

# PayPal API

💰Easy to use framework to communicate with the PayPal API.

## Only basic endpoints are supported

At this time, the package doesn't support all the endpoints of the PayPal API, as it is made for one of my projects I only built the endpoints I needed. Please open an issue if there are endpoints you want to see in.

## Example

```js
const PayPal = require("paypal-api");
const paypal = new PayPal({
    sandboxMode: true,
    clientID: 'paypal client id',
    clientSecret: 'paypal client secret'
});

paypal.listProducts().then(console.log); // you now have access to all the methods!
```

## Products

### List products
```js
paypal.listProducts().then(console.log);
```

### Create products

```js
paypal.createProduct({
    name: "Video Streaming Service",
    description: "Video streaming service",
    type: "SERVICE",
    category: "SOFTWARE",
    image_url: "https://example.com/streaming.jpg",
    home_url: "https://example.com/home"
})
```

### TODO

* Product details: https://developer.paypal.com/docs/api/catalog-products/v1/#products_get
* Update product: https://developer.paypal.com/docs/api/catalog-products/v1/#products_patch

## Plans

### List plans
```js
paypal.listPlans(productID).then(console.log);
```

### Create plans
```js
paypal.createPlan({
    product_id: 'PROD-XXCD1234QWER65782',
    name: 'Basic Plan',
    description: 'Basic plan',
    billing_cycles: [
        {
            frequency: {
                interval_unit: 'MONTH',
                interval_count: 1
            },
            tenure_type: 'TRIAL',
            sequence: 1,
            total_cycles: 1
        },
        {
            frequency: {
                interval_unit: 'MONTH',
                interval_count: 1
            },
            tenure_type: 'REGULAR',
            sequence: 2,
            total_cycles: 12,
            pricing_scheme: {
                fixed_price: {
                    value: '10',
                    currency_code: 'USD'
                }
            }
        }
    ],
    payment_preferences: {
        service_type: 'PREPAID',
        auto_bill_outstanding: true,
        setup_fee: {
            value: '10',
            currency_code: 'USD'
        },
        setup_fee_failure_action: 'CONTINUE',
        payment_failure_threshold: 3
    },
    quantity_supported: true,
    taxes: {
        percentage: '10',
        inclusive: false
    }
})
```

### TODO

* Plan details: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_get
* Update plan: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_patch
    - update plan pricing: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_update-pricing-schemes
* Activate plan: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_activate
* Deactivate plan: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_deactivate

## Subscriptions

### Create subscription

```js
paypal.createSubscription({
    plan_id: 'P-2UF78835G6983425GLSM44MA',
    start_time: '2020-12-20T16:17:13Z',
    subscriber: {
        name: {
            given_name: 'John',
            surname: 'Doe'
        },
        email_address: 'customer@example.com'
    },
    application_context: {
        brand_name: 'example',
        locale: 'en-US',
        shipping_preference: 'SET_PROVIDED_ADDRESS',
        user_action: 'SUBSCRIBE_NOW',
        payment_method: {
            payer_selected: 'PAYPAL',
            payee_preferred: 'IMMEDIATE_PAYMENT_REQUIRED'
        },
        return_url: 'https://example.com/returnUrl',
        cancel_url: 'https://example.com/cancelUrl'
    }
})
```

### Subscription details

```js
paypal.getSubscription('I-Y3FEL44WUVPU').then(console.log);
```

### TODO

* Activate subscription: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate
* Cancel subscription: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
* Subscription capture: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_capture
* Subscription revisions: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_revise
* Suspend subscription: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_suspend
* List transactions: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions

## Webhooks

### List webhooks

```js
paypal.listWebhooks().then(console.log);
```

### Create webhook

```js
paypal.createWebhook({
    url: "https://example.com/example_webhook",
    event_types: [
        {
            name: "PAYMENT.AUTHORIZATION.CREATED"
        },
        {
            name: "PAYMENT.AUTHORIZATION.VOIDED"
        }
    ]
})
```

### TODO

* Update webhook: https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_update
* Webhook details: https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_get
* Webhook event types: https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_list

---
_Source: https://npm.io/package/paypal-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
