payjp 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +14 -6
- package/.github/workflows/test.yml +10 -5
- package/.oxfmtrc.json +3 -0
- package/.oxlintrc.json +9 -0
- package/README.md +12 -5
- package/built/{account.d.ts → accounts.d.ts} +2 -2
- package/built/{account.js → accounts.js} +2 -2
- package/built/{balance.d.ts → balances.d.ts} +2 -2
- package/built/{balance.js → balances.js} +4 -4
- package/built/{card.d.ts → cards.d.ts} +2 -2
- package/built/{card.js → cards.js} +6 -6
- package/built/{charge.d.ts → charges.d.ts} +2 -2
- package/built/{charge.js → charges.js} +9 -9
- package/built/{customer.d.ts → customers.d.ts} +3 -3
- package/built/{customer.js → customers.js} +11 -11
- package/built/{event.d.ts → events.d.ts} +2 -2
- package/built/{event.js → events.js} +3 -3
- package/built/index.d.ts +18 -20
- package/built/index.js +30 -32
- package/built/{plan.d.ts → plans.d.ts} +2 -2
- package/built/{plan.js → plans.js} +6 -6
- package/built/resource.d.ts +4 -1
- package/built/resource.js +108 -21
- package/built/{statement.d.ts → statements.d.ts} +2 -2
- package/built/{statement.js → statements.js} +4 -4
- package/built/{subscription.d.ts → subscriptions.d.ts} +2 -2
- package/built/subscriptions.js +35 -0
- package/built/tenantTransfers.d.ts +2 -2
- package/built/tenantTransfers.js +5 -5
- package/built/tenants.d.ts +2 -2
- package/built/tenants.js +7 -7
- package/built/{term.d.ts → terms.d.ts} +2 -2
- package/built/{term.js → terms.js} +3 -3
- package/built/{threeDSecureRequest.d.ts → threeDSecureRequests.d.ts} +2 -2
- package/built/{threeDSecureRequest.js → threeDSecureRequests.js} +4 -4
- package/built/{token.d.ts → tokens.d.ts} +2 -2
- package/built/{token.js → tokens.js} +4 -4
- package/built/{transfer.d.ts → transfers.d.ts} +2 -2
- package/built/{transfer.js → transfers.js} +4 -4
- package/example.ts +78 -0
- package/package.json +18 -28
- package/pnpm-workspace.yaml +1 -0
- package/tsconfig.json +3 -7
- package/.eslintrc.json +0 -26
- package/built/subscription.js +0 -35
|
@@ -8,14 +8,22 @@ jobs:
|
|
|
8
8
|
|
|
9
9
|
publish-npm:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
id-token: write
|
|
11
14
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
13
|
-
-
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- name: Setup pnpm
|
|
17
|
+
uses: pnpm/action-setup@v4
|
|
14
18
|
with:
|
|
15
|
-
|
|
19
|
+
version: 10
|
|
20
|
+
- uses: actions/setup-node@v5
|
|
21
|
+
with:
|
|
22
|
+
node-version: 24
|
|
16
23
|
registry-url: https://registry.npmjs.org/
|
|
17
|
-
|
|
18
|
-
- run:
|
|
19
|
-
- run:
|
|
24
|
+
cache: 'pnpm'
|
|
25
|
+
- run: pnpm install --frozen-lockfile
|
|
26
|
+
- run: pnpm test
|
|
27
|
+
- run: pnpm publish --no-git-checks --provenance
|
|
20
28
|
env:
|
|
21
29
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -11,12 +11,17 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
|
-
node: [
|
|
14
|
+
node: ['22', '24']
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Setup pnpm
|
|
18
|
+
uses: pnpm/action-setup@v4
|
|
19
|
+
with:
|
|
20
|
+
version: 10
|
|
17
21
|
- name: Setup node
|
|
18
|
-
uses: actions/setup-node@
|
|
22
|
+
uses: actions/setup-node@v4
|
|
19
23
|
with:
|
|
20
24
|
node-version: ${{ matrix.node }}
|
|
21
|
-
|
|
22
|
-
- run:
|
|
25
|
+
cache: 'pnpm'
|
|
26
|
+
- run: pnpm install --frozen-lockfile
|
|
27
|
+
- run: pnpm test
|
package/.oxfmtrc.json
ADDED
package/.oxlintrc.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"plugins": ["typescript"],
|
|
4
|
+
"rules": {
|
|
5
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
6
|
+
"no-unused-vars": ["warn", { "caughtErrorsIgnorePattern": "^_", "argsIgnorePattern": "^_" }]
|
|
7
|
+
},
|
|
8
|
+
"ignorePatterns": ["node_modules", "built", "pnpm-lock.yaml"]
|
|
9
|
+
}
|
package/README.md
CHANGED
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
npm install --save payjp
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
## Dependencies
|
|
13
|
-
|
|
14
|
-
- [superagent](https://visionmedia.github.io/superagent/)
|
|
15
|
-
|
|
16
12
|
## Documentation
|
|
17
13
|
|
|
18
14
|
* [API Documentation](https://pay.jp/docs/api/?javascript)
|
|
@@ -30,6 +26,13 @@ payjp.charges.create({
|
|
|
30
26
|
currency: 'jpy',
|
|
31
27
|
card: 'token_id_by_Checkout_or_payjp.js'
|
|
32
28
|
}).then(console.log).catch(console.error);
|
|
29
|
+
|
|
30
|
+
payjp.charges.create({
|
|
31
|
+
amount: 1000,
|
|
32
|
+
currency: 'jpy',
|
|
33
|
+
customer: 'cus_xxx',
|
|
34
|
+
metadata: { user_id: 123 }
|
|
35
|
+
}).then(console.log).catch(console.error);
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
Typescript
|
|
@@ -68,4 +71,8 @@ const payjp = new Payjp('sk_live_xxx', {maxRetry: 5, retryInitialDelay: 1000, re
|
|
|
68
71
|
```
|
|
69
72
|
|
|
70
73
|
A delay of retry is calculated based on [Exponential backoff with equal jitter](https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/) algorithm.
|
|
71
|
-
Each delay is randomly choiced between "`retryInitialDelay` * 2 ** `retryCount`" and "`retryInitialDelay` * 2 ** `retryCount` / 2" but doesn't exceed `retryMaxDelay`.
|
|
74
|
+
Each delay is randomly choiced between "`retryInitialDelay` * 2 ** `retryCount`" and "`retryInitialDelay` * 2 ** `retryCount` / 2" but doesn't exceed `retryMaxDelay`.
|
|
75
|
+
|
|
76
|
+
## Contributors
|
|
77
|
+
|
|
78
|
+
See the [list of contributors](https://github.com/payjp/payjp-node/graphs/contributors) who participated in this project.
|
|
@@ -5,10 +5,10 @@ class Accounts extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "accounts";
|
|
9
9
|
}
|
|
10
10
|
retrieve() {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", `${this.resource}`);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.default = Accounts;
|
|
@@ -5,16 +5,16 @@ class Balances extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "balances";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
statementUrls(id, query = {}) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("POST", `${this.resource}/${id}/statement_urls`, query);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = Balances;
|
|
@@ -5,22 +5,22 @@ class Cards extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "cards";
|
|
9
9
|
}
|
|
10
10
|
list(customerId, query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", `customers/${customerId}/${this.resource}`, query);
|
|
12
12
|
}
|
|
13
13
|
create(customerId, query = {}) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("POST", `customers/${customerId}/${this.resource}`, query);
|
|
15
15
|
}
|
|
16
16
|
retrieve(customerId, id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `customers/${customerId}/${this.resource}/${id}`);
|
|
18
18
|
}
|
|
19
19
|
update(customerId, id, query = {}) {
|
|
20
|
-
return this.request(
|
|
20
|
+
return this.request("POST", `customers/${customerId}/${this.resource}/${id}`, query);
|
|
21
21
|
}
|
|
22
22
|
delete(customerId, id) {
|
|
23
|
-
return this.request(
|
|
23
|
+
return this.request("DELETE", `customers/${customerId}/${this.resource}/${id}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.default = Cards;
|
|
@@ -5,31 +5,31 @@ class Charges extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "charges";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
create(query) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("POST", this.resource, query);
|
|
15
15
|
}
|
|
16
16
|
retrieve(id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
18
18
|
}
|
|
19
19
|
update(id, query = {}) {
|
|
20
|
-
return this.request(
|
|
20
|
+
return this.request("POST", `${this.resource}/${id}`, query);
|
|
21
21
|
}
|
|
22
22
|
refund(id, query = {}) {
|
|
23
|
-
return this.request(
|
|
23
|
+
return this.request("POST", `${this.resource}/${id}/refund`, query);
|
|
24
24
|
}
|
|
25
25
|
reauth(id, query = {}) {
|
|
26
|
-
return this.request(
|
|
26
|
+
return this.request("POST", `${this.resource}/${id}/reauth`, query);
|
|
27
27
|
}
|
|
28
28
|
capture(id, query = {}) {
|
|
29
|
-
return this.request(
|
|
29
|
+
return this.request("POST", `${this.resource}/${id}/capture`, query);
|
|
30
30
|
}
|
|
31
31
|
tds_finish(id) {
|
|
32
|
-
return this.request(
|
|
32
|
+
return this.request("POST", `${this.resource}/${id}/tds_finish`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.default = Charges;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import Cards from "./cards";
|
|
2
|
+
import type * as I from "./index";
|
|
3
|
+
import Resource from "./resource";
|
|
4
4
|
declare class CustomerSubscriptions extends Resource {
|
|
5
5
|
resource: string;
|
|
6
6
|
constructor(payjp: any);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cards_1 = require("./cards");
|
|
3
4
|
const resource_1 = require("./resource");
|
|
4
|
-
const card_1 = require("./card");
|
|
5
5
|
class CustomerSubscriptions extends resource_1.default {
|
|
6
6
|
resource;
|
|
7
7
|
constructor(payjp) {
|
|
8
8
|
super(payjp);
|
|
9
|
-
this.resource =
|
|
9
|
+
this.resource = "subscriptions";
|
|
10
10
|
}
|
|
11
11
|
list(id, query = {}) {
|
|
12
|
-
return this.request(
|
|
12
|
+
return this.request("GET", `customers/${id}/${this.resource}`, query);
|
|
13
13
|
}
|
|
14
14
|
retrieve(id, subscriptionId) {
|
|
15
|
-
return this.request(
|
|
15
|
+
return this.request("GET", `customers/${id}/${this.resource}/${subscriptionId}`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
class Customers extends resource_1.default {
|
|
@@ -21,24 +21,24 @@ class Customers extends resource_1.default {
|
|
|
21
21
|
subscriptions;
|
|
22
22
|
constructor(payjp) {
|
|
23
23
|
super(payjp);
|
|
24
|
-
this.resource =
|
|
25
|
-
this.cards = new
|
|
24
|
+
this.resource = "customers";
|
|
25
|
+
this.cards = new cards_1.default(payjp);
|
|
26
26
|
this.subscriptions = new CustomerSubscriptions(payjp);
|
|
27
27
|
}
|
|
28
28
|
list(query = {}) {
|
|
29
|
-
return this.request(
|
|
29
|
+
return this.request("GET", this.resource, query);
|
|
30
30
|
}
|
|
31
31
|
create(query = {}) {
|
|
32
|
-
return this.request(
|
|
32
|
+
return this.request("POST", this.resource, query);
|
|
33
33
|
}
|
|
34
34
|
retrieve(id) {
|
|
35
|
-
return this.request(
|
|
35
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
36
36
|
}
|
|
37
37
|
update(id, query = {}) {
|
|
38
|
-
return this.request(
|
|
38
|
+
return this.request("POST", `${this.resource}/${id}`, query);
|
|
39
39
|
}
|
|
40
40
|
delete(id) {
|
|
41
|
-
return this.request(
|
|
41
|
+
return this.request("DELETE", `${this.resource}/${id}`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.default = Customers;
|
|
@@ -5,13 +5,13 @@ class Events extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "events";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.default = Events;
|
package/built/index.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import Accounts from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
import Accounts from "./accounts";
|
|
2
|
+
import Balances from "./balances";
|
|
3
|
+
import Charges from "./charges";
|
|
4
|
+
import Customers from "./customers";
|
|
5
|
+
import Events from "./events";
|
|
6
|
+
import Plans from "./plans";
|
|
7
|
+
import Statements from "./statements";
|
|
8
|
+
import Subscriptions from "./subscriptions";
|
|
9
|
+
import Tenants from "./tenants";
|
|
10
|
+
import TenantTransfers from "./tenantTransfers";
|
|
11
|
+
import Terms from "./terms";
|
|
12
|
+
import ThreeDSecureRequests from "./threeDSecureRequests";
|
|
13
|
+
import Tokens from "./tokens";
|
|
14
|
+
import Transfers from "./transfers";
|
|
15
15
|
declare namespace Payjp {
|
|
16
|
-
export
|
|
17
|
-
(apikey: string, options?: PayjpOptions): Payjp;
|
|
18
|
-
}
|
|
16
|
+
export type PayjpStatic = (apikey: string, options?: PayjpOptions) => Payjp;
|
|
19
17
|
export interface Payjp {
|
|
20
18
|
apikey: string;
|
|
21
19
|
config: PayjpOptions;
|
|
@@ -204,7 +202,7 @@ declare namespace Payjp {
|
|
|
204
202
|
has_more: boolean;
|
|
205
203
|
url: string;
|
|
206
204
|
}
|
|
207
|
-
type ThreeDSecureStatus = null |
|
|
205
|
+
type ThreeDSecureStatus = null | "unverified" | "verified" | "attempted" | "failed" | "error";
|
|
208
206
|
export interface Charge {
|
|
209
207
|
object: "charge";
|
|
210
208
|
amount: number;
|
|
@@ -476,12 +474,12 @@ declare namespace Payjp {
|
|
|
476
474
|
bank_info: null | BankInfo;
|
|
477
475
|
}
|
|
478
476
|
export interface ThreeDSecureRequest {
|
|
479
|
-
object:
|
|
477
|
+
object: "three_d_secure_request";
|
|
480
478
|
id: string;
|
|
481
479
|
resource_id: string;
|
|
482
480
|
livemode: boolean;
|
|
483
481
|
created: number;
|
|
484
|
-
state:
|
|
482
|
+
state: "created" | "in_progress" | "result_received" | "finished";
|
|
485
483
|
started_at: null | number;
|
|
486
484
|
result_received_at: null | number;
|
|
487
485
|
finished_at: null | number;
|
package/built/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
2
|
+
const accounts_1 = require("./accounts");
|
|
3
|
+
const balances_1 = require("./balances");
|
|
4
|
+
const charges_1 = require("./charges");
|
|
5
|
+
const customers_1 = require("./customers");
|
|
6
|
+
const events_1 = require("./events");
|
|
7
|
+
const plans_1 = require("./plans");
|
|
8
|
+
const statements_1 = require("./statements");
|
|
9
|
+
const subscriptions_1 = require("./subscriptions");
|
|
8
10
|
const tenants_1 = require("./tenants");
|
|
9
11
|
const tenantTransfers_1 = require("./tenantTransfers");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const balance_1 = require("./balance");
|
|
15
|
-
const threeDSecureRequest_1 = require("./threeDSecureRequest");
|
|
12
|
+
const terms_1 = require("./terms");
|
|
13
|
+
const threeDSecureRequests_1 = require("./threeDSecureRequests");
|
|
14
|
+
const tokens_1 = require("./tokens");
|
|
15
|
+
const transfers_1 = require("./transfers");
|
|
16
16
|
const Payjp = function (apikey, options = {}) {
|
|
17
17
|
if (!apikey) {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error("Please set apikey.");
|
|
19
19
|
}
|
|
20
|
-
else if (apikey.indexOf(
|
|
21
|
-
throw new Error(
|
|
20
|
+
else if (apikey.indexOf("pk_") === 0) {
|
|
21
|
+
throw new Error("You cannot use the public apikey in this SDK.");
|
|
22
22
|
}
|
|
23
23
|
const payjpConfig = {
|
|
24
24
|
apikey,
|
|
25
25
|
config: {
|
|
26
|
-
apibase: options.apibase ||
|
|
26
|
+
apibase: options.apibase || "https://api.pay.jp/v1",
|
|
27
27
|
timeout: options.timeout || 0,
|
|
28
28
|
maxRetry: options.maxRetry || 0,
|
|
29
29
|
retryInitialDelay: options.retryInitialDelay || 2000,
|
|
@@ -31,23 +31,21 @@ const Payjp = function (apikey, options = {}) {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
events: new event_1.default(payjpConfig),
|
|
44
|
-
accounts: new account_1.default(payjpConfig),
|
|
34
|
+
...payjpConfig,
|
|
35
|
+
charges: new charges_1.default(payjpConfig),
|
|
36
|
+
customers: new customers_1.default(payjpConfig),
|
|
37
|
+
plans: new plans_1.default(payjpConfig),
|
|
38
|
+
subscriptions: new subscriptions_1.default(payjpConfig),
|
|
39
|
+
tokens: new tokens_1.default(payjpConfig),
|
|
40
|
+
transfers: new transfers_1.default(payjpConfig),
|
|
41
|
+
events: new events_1.default(payjpConfig),
|
|
42
|
+
accounts: new accounts_1.default(payjpConfig),
|
|
45
43
|
tenants: new tenants_1.default(payjpConfig),
|
|
46
|
-
|
|
47
|
-
statements: new
|
|
48
|
-
terms: new
|
|
49
|
-
balances: new
|
|
50
|
-
three_d_secure_requests: new
|
|
44
|
+
tenant_transfers: new tenantTransfers_1.default(payjpConfig),
|
|
45
|
+
statements: new statements_1.default(payjpConfig),
|
|
46
|
+
terms: new terms_1.default(payjpConfig),
|
|
47
|
+
balances: new balances_1.default(payjpConfig),
|
|
48
|
+
three_d_secure_requests: new threeDSecureRequests_1.default(payjpConfig),
|
|
51
49
|
};
|
|
52
50
|
};
|
|
53
51
|
module.exports = Payjp;
|
|
@@ -5,22 +5,22 @@ class Plans extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "plans";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
create(query) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("POST", this.resource, query);
|
|
15
15
|
}
|
|
16
16
|
retrieve(id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
18
18
|
}
|
|
19
19
|
update(id, query = {}) {
|
|
20
|
-
return this.request(
|
|
20
|
+
return this.request("POST", `${this.resource}/${id}`, query);
|
|
21
21
|
}
|
|
22
22
|
delete(id) {
|
|
23
|
-
return this.request(
|
|
23
|
+
return this.request("DELETE", `${this.resource}/${id}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.default = Plans;
|
package/built/resource.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as I from
|
|
1
|
+
import type * as I from "./index";
|
|
2
2
|
interface Config {
|
|
3
3
|
apikey: string;
|
|
4
4
|
config: I.PayjpOptions;
|
|
@@ -10,6 +10,9 @@ export default class Resource {
|
|
|
10
10
|
get apikey(): string;
|
|
11
11
|
private buildHeader;
|
|
12
12
|
private getCurrentDelay;
|
|
13
|
+
private isPlainObject;
|
|
14
|
+
private appendFormValue;
|
|
15
|
+
private serializeQuery;
|
|
13
16
|
protected request<I>(method: string, endpoint: string, query?: object, headers?: object): Promise<I>;
|
|
14
17
|
}
|
|
15
18
|
export {};
|
package/built/resource.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
const superagent = require("superagent");
|
|
5
3
|
class Resource {
|
|
6
4
|
payjp;
|
|
7
5
|
constructor(payjp) {
|
|
@@ -14,48 +12,137 @@ class Resource {
|
|
|
14
12
|
return this.payjp.apikey;
|
|
15
13
|
}
|
|
16
14
|
buildHeader(method) {
|
|
17
|
-
const encodedKey = Buffer.from(`${this.payjp.apikey}:`).toString(
|
|
15
|
+
const encodedKey = Buffer.from(`${this.payjp.apikey}:`).toString("base64");
|
|
18
16
|
const headers = {
|
|
19
|
-
Accept:
|
|
20
|
-
Authorization: `Basic ${encodedKey}
|
|
17
|
+
Accept: "application/json",
|
|
18
|
+
Authorization: `Basic ${encodedKey}`,
|
|
21
19
|
};
|
|
22
|
-
if (method ===
|
|
23
|
-
headers[
|
|
20
|
+
if (method === "POST" || method === "PUT") {
|
|
21
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
24
22
|
}
|
|
25
23
|
return headers;
|
|
26
24
|
}
|
|
27
25
|
getCurrentDelay(retryCount, initialDelay, maxDelay) {
|
|
28
26
|
const delay = Math.min(initialDelay * 2 ** retryCount, maxDelay);
|
|
29
|
-
return Math.ceil(delay / 2 * (1 + Math.random()));
|
|
27
|
+
return Math.ceil((delay / 2) * (1 + Math.random()));
|
|
28
|
+
}
|
|
29
|
+
isPlainObject(value) {
|
|
30
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
31
|
+
}
|
|
32
|
+
appendFormValue(params, key, value) {
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.isPlainObject(value)) {
|
|
37
|
+
for (const [nestedKey, nestedValue] of Object.entries(value)) {
|
|
38
|
+
this.appendFormValue(params, `${key}[${nestedKey}]`, nestedValue);
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
params.append(key, String(value));
|
|
43
|
+
}
|
|
44
|
+
serializeQuery(query) {
|
|
45
|
+
const params = new URLSearchParams();
|
|
46
|
+
for (const [key, value] of Object.entries(query)) {
|
|
47
|
+
this.appendFormValue(params, key, value);
|
|
48
|
+
}
|
|
49
|
+
return params;
|
|
30
50
|
}
|
|
31
51
|
request(method, endpoint, query = {}, headers = {}) {
|
|
32
|
-
const url = `${this.payjp.config.apibase}/${endpoint}`;
|
|
33
52
|
const header = Object.assign(this.buildHeader(method), headers);
|
|
34
|
-
const doRequest = () => {
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
const doRequest = async () => {
|
|
54
|
+
let url = `${this.payjp.config.apibase}/${endpoint}`;
|
|
55
|
+
const fetchOptions = {
|
|
56
|
+
method,
|
|
57
|
+
headers: header,
|
|
58
|
+
};
|
|
59
|
+
// Set query parameters or request body
|
|
60
|
+
if (method === "GET" || method === "DELETE") {
|
|
61
|
+
// For GET and DELETE, add query parameters to URL
|
|
62
|
+
const params = this.serializeQuery(query);
|
|
63
|
+
const queryString = params.toString();
|
|
64
|
+
if (queryString) {
|
|
65
|
+
url = `${url}?${queryString}`;
|
|
66
|
+
}
|
|
38
67
|
}
|
|
39
|
-
else {
|
|
40
|
-
|
|
68
|
+
else {
|
|
69
|
+
// For POST and PUT, send as request body
|
|
70
|
+
const body = this.serializeQuery(query);
|
|
71
|
+
fetchOptions.body = body.toString();
|
|
41
72
|
}
|
|
73
|
+
// Set timeout
|
|
42
74
|
if (this.payjp.config.timeout > 0) {
|
|
43
|
-
|
|
75
|
+
const controller = new AbortController();
|
|
76
|
+
fetchOptions.signal = controller.signal;
|
|
77
|
+
setTimeout(() => controller.abort(), this.payjp.config.timeout);
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const response = await fetch(url, fetchOptions);
|
|
81
|
+
// fetch doesn't reject on HTTP error status, so check manually
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
// Parse and return error response
|
|
84
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
85
|
+
const error = new Error(`HTTP Error ${response.status}`);
|
|
86
|
+
error.status = response.status;
|
|
87
|
+
error.body = errorBody;
|
|
88
|
+
error.message = errorBody.message || `HTTP Error ${response.status}`;
|
|
89
|
+
// Set response.body for compatibility with superagent
|
|
90
|
+
error.response = { body: errorBody, status: response.status };
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
// Convert timeout error message
|
|
97
|
+
if (error.name === "AbortError" || error.name === "TimeoutError") {
|
|
98
|
+
const timeoutError = new Error(`Timeout of ${this.payjp.config.timeout}ms exceeded`);
|
|
99
|
+
timeoutError.name = "TimeoutError";
|
|
100
|
+
timeoutError.code = "ETIMEDOUT";
|
|
101
|
+
timeoutError.timeout = this.payjp.config.timeout;
|
|
102
|
+
throw timeoutError;
|
|
103
|
+
}
|
|
104
|
+
// Convert network error message
|
|
105
|
+
if (error.cause) {
|
|
106
|
+
if (error.cause.code === "ECONNRESET") {
|
|
107
|
+
const networkError = new Error("socket hang up");
|
|
108
|
+
networkError.code = "ECONNRESET";
|
|
109
|
+
throw networkError;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Convert 'fetch failed' error to 'socket hang up' (when connection is terminated)
|
|
113
|
+
if (error.message?.includes("fetch failed")) {
|
|
114
|
+
const networkError = new Error("socket hang up");
|
|
115
|
+
networkError.code = "ECONNRESET";
|
|
116
|
+
throw networkError;
|
|
117
|
+
}
|
|
118
|
+
throw error;
|
|
44
119
|
}
|
|
45
|
-
return request;
|
|
46
120
|
};
|
|
47
121
|
let retryCount = 0;
|
|
48
|
-
const retry = (resolve, reject) => doRequest()
|
|
49
|
-
|
|
122
|
+
const retry = (resolve, reject) => doRequest()
|
|
123
|
+
.then(async (res) => {
|
|
124
|
+
// Try to parse as JSON. If it fails, return empty object
|
|
125
|
+
try {
|
|
126
|
+
const body = await res.json();
|
|
127
|
+
resolve(body);
|
|
128
|
+
}
|
|
129
|
+
catch (_e) {
|
|
130
|
+
// For non-JSON responses (HTML, etc.), return empty object
|
|
131
|
+
resolve({});
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
.catch((error) => {
|
|
135
|
+
// Retry for 429 (Too Many Requests)
|
|
136
|
+
if (error.status === 429 && retryCount < this.payjp.config.maxRetry) {
|
|
50
137
|
const delayWithJitter = this.getCurrentDelay(retryCount, this.payjp.config.retryInitialDelay, this.payjp.config.retryMaxDelay);
|
|
51
138
|
retryCount++;
|
|
52
139
|
setTimeout(() => retry(resolve, reject), delayWithJitter);
|
|
53
140
|
}
|
|
54
141
|
else {
|
|
55
|
-
return reject(
|
|
142
|
+
return reject(error);
|
|
56
143
|
}
|
|
57
144
|
});
|
|
58
|
-
return new Promise(retry)
|
|
145
|
+
return new Promise(retry);
|
|
59
146
|
}
|
|
60
147
|
}
|
|
61
148
|
exports.default = Resource;
|
|
@@ -5,16 +5,16 @@ class Statements extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "statements";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
statementUrls(id, query = {}) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("POST", `${this.resource}/${id}/statement_urls`, query);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = Statements;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const resource_1 = require("./resource");
|
|
4
|
+
class Subscriptions extends resource_1.default {
|
|
5
|
+
resource;
|
|
6
|
+
constructor(payjp) {
|
|
7
|
+
super(payjp);
|
|
8
|
+
this.resource = "subscriptions";
|
|
9
|
+
}
|
|
10
|
+
list(query = {}) {
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
|
+
}
|
|
13
|
+
create(query) {
|
|
14
|
+
return this.request("POST", this.resource, query);
|
|
15
|
+
}
|
|
16
|
+
update(id, query = {}) {
|
|
17
|
+
return this.request("POST", `${this.resource}/${id}`, query);
|
|
18
|
+
}
|
|
19
|
+
retrieve(id) {
|
|
20
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
21
|
+
}
|
|
22
|
+
pause(id) {
|
|
23
|
+
return this.request("POST", `${this.resource}/${id}/pause`);
|
|
24
|
+
}
|
|
25
|
+
resume(id, query = {}) {
|
|
26
|
+
return this.request("POST", `${this.resource}/${id}/resume`, query);
|
|
27
|
+
}
|
|
28
|
+
cancel(id) {
|
|
29
|
+
return this.request("POST", `${this.resource}/${id}/cancel`);
|
|
30
|
+
}
|
|
31
|
+
delete(id, query = {}) {
|
|
32
|
+
return this.request("DELETE", `${this.resource}/${id}`, query);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = Subscriptions;
|
package/built/tenantTransfers.js
CHANGED
|
@@ -5,19 +5,19 @@ class TenantTransfers extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "tenant_transfers";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
charges(id, query = {}) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}/charges`, query);
|
|
18
18
|
}
|
|
19
19
|
statementUrls(id, query = {}) {
|
|
20
|
-
return this.request(
|
|
20
|
+
return this.request("POST", `${this.resource}/${id}/statement_urls`, query);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.default = TenantTransfers;
|
package/built/tenants.d.ts
CHANGED
package/built/tenants.js
CHANGED
|
@@ -5,25 +5,25 @@ class Tenants extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "tenants";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
create(query) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("POST", this.resource, query);
|
|
15
15
|
}
|
|
16
16
|
retrieve(id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
18
18
|
}
|
|
19
19
|
update(id, query = {}) {
|
|
20
|
-
return this.request(
|
|
20
|
+
return this.request("POST", `${this.resource}/${id}`, query);
|
|
21
21
|
}
|
|
22
22
|
delete(id) {
|
|
23
|
-
return this.request(
|
|
23
|
+
return this.request("DELETE", `${this.resource}/${id}`);
|
|
24
24
|
}
|
|
25
25
|
applicationUrls(id) {
|
|
26
|
-
return this.request(
|
|
26
|
+
return this.request("POST", `${this.resource}/${id}/application_urls`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.default = Tenants;
|
|
@@ -5,13 +5,13 @@ class Terms extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "terms";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.default = Terms;
|
|
@@ -5,16 +5,16 @@ class ThreeDSecureRequests extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "three_d_secure_requests";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
create(query) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("POST", this.resource, query);
|
|
15
15
|
}
|
|
16
16
|
retrieve(id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = ThreeDSecureRequests;
|
|
@@ -5,16 +5,16 @@ class Tokens extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "tokens";
|
|
9
9
|
}
|
|
10
10
|
create(query = {}, headers = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("POST", this.resource, query, headers);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
tds_finish(id) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("POST", `${this.resource}/${id}/tds_finish`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = Tokens;
|
|
@@ -5,16 +5,16 @@ class Transfers extends resource_1.default {
|
|
|
5
5
|
resource;
|
|
6
6
|
constructor(payjp) {
|
|
7
7
|
super(payjp);
|
|
8
|
-
this.resource =
|
|
8
|
+
this.resource = "transfers";
|
|
9
9
|
}
|
|
10
10
|
list(query = {}) {
|
|
11
|
-
return this.request(
|
|
11
|
+
return this.request("GET", this.resource, query);
|
|
12
12
|
}
|
|
13
13
|
retrieve(id) {
|
|
14
|
-
return this.request(
|
|
14
|
+
return this.request("GET", `${this.resource}/${id}`);
|
|
15
15
|
}
|
|
16
16
|
charges(id, query = {}) {
|
|
17
|
-
return this.request(
|
|
17
|
+
return this.request("GET", `${this.resource}/${id}/charges`, query);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = Transfers;
|
package/example.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Payjp = require("./built");
|
|
2
|
+
|
|
3
|
+
const PAYJP_SECRET_KEY = process.env.PAYJP_SECRET_KEY;
|
|
4
|
+
if (!PAYJP_SECRET_KEY) {
|
|
5
|
+
console.error("Please set the PAYJP_SECRET_KEY environment variable");
|
|
6
|
+
console.error("Usage: PAYJP_SECRET_KEY=sk_test_xxx npx ts-node example.ts");
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const payjp = Payjp(PAYJP_SECRET_KEY);
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
console.log("=== PAY.JP SDK Example ===\n");
|
|
14
|
+
|
|
15
|
+
// 1. Retrieve account information
|
|
16
|
+
console.log("1. Retrieving account information...");
|
|
17
|
+
const account = await payjp.accounts.retrieve();
|
|
18
|
+
console.log(` Account ID: ${account.id}`);
|
|
19
|
+
console.log(` Email: ${account.email}\n`);
|
|
20
|
+
|
|
21
|
+
// 2. Create customer
|
|
22
|
+
console.log("2. Creating customer...");
|
|
23
|
+
const customer = await payjp.customers.create({
|
|
24
|
+
email: "test@example.com",
|
|
25
|
+
description: "Test customer for SDK verification",
|
|
26
|
+
});
|
|
27
|
+
console.log(` Customer ID: ${customer.id}`);
|
|
28
|
+
console.log(` Email: ${customer.email}`);
|
|
29
|
+
console.log(` Description: ${customer.description}\n`);
|
|
30
|
+
|
|
31
|
+
// 3. Retrieve customer
|
|
32
|
+
console.log("3. Retrieving customer...");
|
|
33
|
+
const retrievedCustomer = await payjp.customers.retrieve(customer.id);
|
|
34
|
+
console.log(` Customer ID: ${retrievedCustomer.id}`);
|
|
35
|
+
console.log(` Created at: ${new Date(retrievedCustomer.created * 1000).toLocaleString()}\n`);
|
|
36
|
+
|
|
37
|
+
// 4. List customers
|
|
38
|
+
console.log("4. Listing customers...");
|
|
39
|
+
const customerList = await payjp.customers.list({ limit: 3 });
|
|
40
|
+
console.log(` Retrieved: ${customerList.data.length}`);
|
|
41
|
+
console.log(` Total count: ${customerList.count}\n`);
|
|
42
|
+
|
|
43
|
+
// 5. Create plan
|
|
44
|
+
console.log("5. Creating plan...");
|
|
45
|
+
const plan = await payjp.plans.create({
|
|
46
|
+
amount: 500,
|
|
47
|
+
currency: "jpy",
|
|
48
|
+
interval: "month",
|
|
49
|
+
name: "Test plan for SDK verification",
|
|
50
|
+
});
|
|
51
|
+
console.log(` Plan ID: ${plan.id}`);
|
|
52
|
+
console.log(` Amount: ${plan.amount} JPY/${plan.interval}\n`);
|
|
53
|
+
|
|
54
|
+
// 6. List charges
|
|
55
|
+
console.log("6. Listing charges...");
|
|
56
|
+
const chargeList = await payjp.charges.list({ limit: 3 });
|
|
57
|
+
console.log(` Retrieved: ${chargeList.data.length}`);
|
|
58
|
+
console.log(` Total count: ${chargeList.count}\n`);
|
|
59
|
+
|
|
60
|
+
// 7. Cleanup
|
|
61
|
+
console.log("7. Cleaning up...");
|
|
62
|
+
const deletedPlan = await payjp.plans.delete(plan.id);
|
|
63
|
+
console.log(` Plan deleted: ${deletedPlan.deleted ? "success" : "failed"}`);
|
|
64
|
+
const deletedCustomer = await payjp.customers.delete(customer.id);
|
|
65
|
+
console.log(` Customer deleted: ${deletedCustomer.deleted ? "success" : "failed"}\n`);
|
|
66
|
+
|
|
67
|
+
console.log("=== Example completed ===");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main().catch((error) => {
|
|
71
|
+
console.error("An error occurred:");
|
|
72
|
+
if (error.response?.body) {
|
|
73
|
+
console.error(JSON.stringify(error.response.body, null, 2));
|
|
74
|
+
} else {
|
|
75
|
+
console.error(error.message);
|
|
76
|
+
}
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payjp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "PAY.JP node.js bindings",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"types": "built/index.d.ts",
|
|
@@ -10,42 +10,32 @@
|
|
|
10
10
|
"credit cards",
|
|
11
11
|
"api"
|
|
12
12
|
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "npm run lint && npm run build && npm run test:typescript && npm run test:mocha",
|
|
15
|
-
"test:mocha": "mocha --timeout=10000",
|
|
16
|
-
"test:debug": "mocha --inspect-brk",
|
|
17
|
-
"test:typescript": "tsc --noEmit --target esnext --module commonjs test/types/*.ts",
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"lint": "npm run lint:base -- .",
|
|
20
|
-
"lint:base": "eslint --ignore-path .gitignore --ext .js,.ts",
|
|
21
|
-
"lint:fix": "npm run lint -- --fix",
|
|
22
|
-
"prepublish": "npm run build"
|
|
23
|
-
},
|
|
24
13
|
"repository": {
|
|
25
14
|
"type": "git",
|
|
26
15
|
"url": "git://github.com/payjp/payjp-node.git"
|
|
27
16
|
},
|
|
28
17
|
"author": "PAY.JP <support@pay.jp> (https://pay.jp)",
|
|
29
|
-
"contributors": [
|
|
30
|
-
"Daiki Arai <darai0512@yahoo.co.jp>",
|
|
31
|
-
"Yoichi Fujimoto <wozozo@gmail.com>"
|
|
32
|
-
],
|
|
33
18
|
"license": "MIT",
|
|
34
19
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
36
21
|
},
|
|
37
22
|
"devDependencies": {
|
|
38
|
-
"@types/
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
40
|
-
"@types/prettier": "1.16.1",
|
|
41
|
-
"@typescript-eslint/parser": "^5.17.0",
|
|
42
|
-
"eslint": "^8.0.0",
|
|
43
|
-
"eslint-config-prettier": "4.1.0",
|
|
23
|
+
"@types/node": "^22.19.1",
|
|
44
24
|
"mocha": "^6.0.2",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
25
|
+
"oxfmt": "^0.16.0",
|
|
26
|
+
"oxlint": "^1.31.0",
|
|
27
|
+
"typescript": "^5.7.2"
|
|
47
28
|
},
|
|
48
|
-
"
|
|
49
|
-
"
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "npm run lint && npm run build && npm run test:typescript && npm run test:mocha",
|
|
31
|
+
"test:mocha": "mocha --timeout=10000",
|
|
32
|
+
"test:debug": "mocha --inspect-brk",
|
|
33
|
+
"test:typescript": "tsc --noEmit --target esnext --module commonjs test/types/*.ts",
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"lint": "oxlint .",
|
|
36
|
+
"lint:fix": "oxlint --fix .",
|
|
37
|
+
"format": "oxfmt .",
|
|
38
|
+
"format:check": "oxfmt --check .",
|
|
39
|
+
"prepublish": "npm run build"
|
|
50
40
|
}
|
|
51
|
-
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
minimumReleaseAge: 20160 # in minutes (2 weeks)
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2024",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
-
"lib": [
|
|
6
|
-
"dom"
|
|
7
|
-
],
|
|
5
|
+
"lib": ["ES2024", "dom"],
|
|
8
6
|
"outDir": "./built",
|
|
9
7
|
"declaration": true
|
|
10
8
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
"./src/**/*.ts"
|
|
13
|
-
]
|
|
9
|
+
"include": ["./src/**/*.ts"]
|
|
14
10
|
}
|
package/.eslintrc.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"plugins": ["@typescript-eslint"],
|
|
5
|
-
"extends": [
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
"prettier",
|
|
8
|
-
"prettier/@typescript-eslint"
|
|
9
|
-
],
|
|
10
|
-
"rules": {
|
|
11
|
-
"@typescript-eslint/explicit-member-accessibility": ["off"],
|
|
12
|
-
"@typescript-eslint/no-unused-vars": [
|
|
13
|
-
"error",
|
|
14
|
-
{ "argsIgnorePattern": "^_" }
|
|
15
|
-
],
|
|
16
|
-
"@typescript-eslint/no-namespace": ["warn"]
|
|
17
|
-
},
|
|
18
|
-
"overrides": [
|
|
19
|
-
{
|
|
20
|
-
"files": ["test/*.js"],
|
|
21
|
-
"rules": {
|
|
22
|
-
"@typescript-eslint/no-var-requires": ["off"]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
package/built/subscription.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const resource_1 = require("./resource");
|
|
4
|
-
class Subscriptions extends resource_1.default {
|
|
5
|
-
resource;
|
|
6
|
-
constructor(payjp) {
|
|
7
|
-
super(payjp);
|
|
8
|
-
this.resource = 'subscriptions';
|
|
9
|
-
}
|
|
10
|
-
list(query = {}) {
|
|
11
|
-
return this.request('GET', this.resource, query);
|
|
12
|
-
}
|
|
13
|
-
create(query) {
|
|
14
|
-
return this.request('POST', this.resource, query);
|
|
15
|
-
}
|
|
16
|
-
update(id, query = {}) {
|
|
17
|
-
return this.request('POST', `${this.resource}/${id}`, query);
|
|
18
|
-
}
|
|
19
|
-
retrieve(id) {
|
|
20
|
-
return this.request('GET', `${this.resource}/${id}`);
|
|
21
|
-
}
|
|
22
|
-
pause(id) {
|
|
23
|
-
return this.request('POST', `${this.resource}/${id}/pause`);
|
|
24
|
-
}
|
|
25
|
-
resume(id, query = {}) {
|
|
26
|
-
return this.request('POST', `${this.resource}/${id}/resume`, query);
|
|
27
|
-
}
|
|
28
|
-
cancel(id) {
|
|
29
|
-
return this.request('POST', `${this.resource}/${id}/cancel`);
|
|
30
|
-
}
|
|
31
|
-
delete(id, query = {}) {
|
|
32
|
-
return this.request('DELETE', `${this.resource}/${id}`, query);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.default = Subscriptions;
|