Git Product home page Git Product logo

paypal-api's Introduction

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

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

paypal.listProducts().then(console.log);

Create products

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

Plans

List plans

paypal.listPlans(productID).then(console.log);

Create plans

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

Subscriptions

Create subscription

paypal.createSubscription({
    plan_id: 'P-2UF78835G6983425GLSM44MA',
    start_time: '2020-12-20T16:17:13Z',
    subscriber: {
        name: {
            given_name: 'John',
            surname: 'Doe'
        },
        email_address: '[email protected]'
    },
    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

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

TODO

Webhooks

List webhooks

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

Create webhook

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

TODO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.