like-paypal

1.5.0 • Public • Published

like-paypal

Simple PayPal API for Node.js

npm i like-paypal

Usage

const PayPal = require('like-paypal')

const account = new PayPal({
  clientId: 'AXH41VU0Lji...',
  secretKey: 'ECJeQAFuLn...',
})

main()

async function main () {
  const product = await account.products.create({
    name: 'Video Streaming Service',
    description: 'A video streaming service',
    type: 'SERVICE',
    category: 'SOFTWARE',
    image_url: 'https://example.com/streaming.jpg',
    home_url: 'https://example.com/home'
  })
  console.log(product)
}

API

const account = new PayPal([options])

Creates an instance of a PayPal account.

Available options:

{
  clientId: null, // To auto create an access token
  clientKey: null,
  accessToken: null // Or pass a token directly to avoid creating one
}

const accessToken = await account.auth()

Generates an access token.

const response = await account.api(pathname, [options])

Request to any endpoint easily.

pathname can be i.e. /v1/catalogs/products, etc.

Available options:

{
  auth: null, // Default is `Bearer {accessToken}`
  method: 'POST',
  body: undefined, // Normally an object { ... }
  requestType: 'json',
  responseType: 'json'
}

const product = await account.products.create([options])

Creates a product.

Available options:

{
  name: 'Any name',
  description: 'Some description',
  type: 'SERVICE', // TODO: what are other types?
  category: 'SOFTWARE', // TODO: what are other categories?
  image_url: 'https://example.com/streaming.jpg',
  home_url: 'https://example.com/home'
} // TODO: what are other options? Want to know the full options

const plan = await account.plans.create(options)

Creates a billing plan.

Available options are in docs and schema.

const subscription = await account.subscriptions.create(options)

Creates a subscription for a billing plan.

Available options are in docs and schema.

License

Unlicensed

Readme

Keywords

none

Package Sidebar

Install

npm i like-paypal

Weekly Downloads

1

Version

1.5.0

License

Unlicensed

Unpacked Size

25.1 kB

Total Files

30

Last publish

Collaborators

  • lukks