2.2.0 • Published 25 days ago

payjp v2.2.0

Weekly downloads
964
License
MIT
Repository
github
Last release
25 days ago

PAY.JP for Node.js

Build Status npm

Installation

npm install --save payjp

Dependencies

Documentation

Example

In advance, you need to get a token by Checkout or payjp.js.

Javascript

const payjp = require('payjp')('sk_test_c62fade9d045b54cd76d7036');
payjp.charges.create({
  amount: 1000,
  currency: 'jpy',
  card: 'token_id_by_Checkout_or_payjp.js'
}).then(console.log).catch(console.error);

Typescript

import * as Payjp from 'payjp';
const payjp = Payjp('sk_test_c62fade9d045b54cd76d7036');
payjp.charges.create({
  amount: 1000,
  currency: 'jpy',
  card: 'token_id_by_Checkout_or_payjp.js'
}).then((charge: Payjp.Charge) => console.log(charge)
).catch((e: Payjp.ResponseError) => console.error(e.response.body as Payjp.PayjpError));

Options

Options can be specified in the constructor.

Timeout

Timeout is configurable for the entire request (including all uploads, redirects, server processing time) to complete. If the response isn't fully downloaded within that time, the request will be aborted.

const payjp = require('payjp')('sk_...', {timeout: 20 * 1000}); // in ms (this is 20 seconds)

Retry

You can automatically retry the request when the client received HTTP 429 response caused by Rate Limit. By default, the retry feature is disabled. To activate, set maxRetry for 1 or more.

const payjp = new Payjp('sk_live_xxx', {maxRetry: 5, retryInitialDelay: 1000, retryMaxDelay: 20 * 1000})

A delay of retry is calculated based on Exponential backoff with equal jitter algorithm. Each delay is randomly choiced between "retryInitialDelay 2 ** retryCount" and "retryInitialDelay 2 ** retryCount / 2" but doesn't exceed retryMaxDelay.

2.2.0

25 days ago

2.1.4

6 months ago

2.1.3

1 year ago

2.1.1

2 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

4 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago