npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paypal-api

v0.1.4

Published

Node.js package to interact with PayPal REST API

Downloads

26

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

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

  • 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

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

  • 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

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

  • 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

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

  • 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