├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── build-master.yml
│ ├── build-pull-request.yml
│ ├── build-release.yml
│ └── codeql-analysis.yml
├── .gitignore
├── .npmignore
├── .prettierrc
├── LICENSE
├── README.md
├── example.js
├── package-lock.json
├── package.json
├── src
├── Checkout.js
├── api
│ ├── access
│ │ └── access.js
│ ├── apm-specific
│ │ ├── baloto.js
│ │ ├── boleto.js
│ │ ├── fawry.js
│ │ ├── giropay.js
│ │ ├── ideal.js
│ │ ├── klarna.js
│ │ ├── oxxo.js
│ │ ├── pagofacil.js
│ │ ├── rapipago.js
│ │ └── sepa.js
│ ├── apple-pay
│ │ └── apple-pay.js
│ ├── balances
│ │ └── balances.js
│ ├── card-metadata
│ │ └── card-metadata.js
│ ├── customers
│ │ └── customers.js
│ ├── disputes
│ │ └── disputes.js
│ ├── events
│ │ └── events.js
│ ├── files
│ │ └── files.js
│ ├── financial
│ │ └── financial.js
│ ├── forex
│ │ └── forex.js
│ ├── hosted-payments
│ │ └── hosted-payments.js
│ ├── instruments
│ │ └── instruments.js
│ ├── issuing
│ │ └── issuing.js
│ ├── payment-contexts
│ │ └── payment-contexts.js
│ ├── payment-sessions
│ │ └── payment-sessions.js
│ ├── payments-links
│ │ └── payments-links.js
│ ├── payments
│ │ └── payments.js
│ ├── platforms
│ │ └── platforms.js
│ ├── reconciliation
│ │ └── reconciliation.js
│ ├── reports
│ │ └── reports.js
│ ├── risk
│ │ └── risk.js
│ ├── sessions
│ │ └── sessions.js
│ ├── sources
│ │ └── sources.js
│ ├── tokens
│ │ └── tokens.js
│ ├── transfers
│ │ └── transfers.js
│ ├── webhooks
│ │ └── webhooks.js
│ └── workflows
│ │ └── workflows.js
├── config.js
├── index.js
└── services
│ ├── errors.js
│ ├── http.js
│ ├── utils.js
│ └── validation.js
├── test
├── access
│ └── access.js
├── apm-specific
│ ├── baloto.js
│ ├── boleto.js
│ ├── fawry.js
│ ├── giropay.js
│ ├── ideal.js
│ ├── klarna.js
│ ├── oxxo.js
│ ├── pagofacil.js
│ ├── rapipago.js
│ └── sepa.js
├── apple-pay
│ └── apple-pay.js
├── balances
│ └── balances.js
├── card-metadata
│ └── card-metadata.js
├── config
│ └── config.js
├── customers
│ └── customers.js
├── disputes
│ └── disputes.js
├── errors
│ └── apiError.js
├── events
│ └── events.js
├── files
│ ├── evidence.jpg
│ └── files.js
├── financial
│ └── financial.js
├── forex
│ └── forex.js
├── hosted-payments
│ ├── hosted-payments-it.js
│ └── hosted-payments.js
├── http
│ ├── additionalHeaders.js
│ └── httpClient-it.js
├── instruments
│ ├── instruments-it.js
│ └── instruments.js
├── issuing
│ ├── issuing-it.js
│ └── issuing-unit.js
├── payment-contexts
│ ├── payment-contexts-it.js
│ └── payment-contexts-unit.js
├── payment-sessions
│ ├── payment-sessions-common.js
│ ├── payment-sessions-it.js
│ └── payment-sessions-unit.js
├── payments-links
│ └── payments-links.js
├── payments
│ ├── cancelPayment.js
│ ├── capturePayment.js
│ ├── getPayment.js
│ ├── getPaymentActions.js
│ ├── getPaymentList.js
│ ├── incrementPayment.js
│ ├── refundPayment.js
│ ├── requestPayment.js
│ ├── reversePayment.js
│ ├── searchPayment.js
│ └── voidPayment.js
├── platforms
│ ├── evidence.jpg
│ ├── platforms-reserve-rules-it.js
│ └── platforms.js
├── reconciliation
│ ├── reconciliation.js
│ └── report.csv
├── reports
│ ├── report.csv
│ └── reports.js
├── risk
│ └── risk.js
├── sessions
│ └── sessions.js
├── sources
│ └── addSource.js
├── tokens
│ └── requestToken.js
├── transfers
│ └── transfers.js
├── utils.js
├── webhooks
│ └── webhooks.js
└── workflows
│ └── workflows.js
└── types
└── dist
├── Checkout.d.ts
├── api
├── access
│ └── access.d.ts
├── apm-specific
│ ├── baloto.d.ts
│ ├── boleto.d.ts
│ ├── fawry.d.ts
│ ├── giropay.d.ts
│ ├── ideal.d.ts
│ ├── klarna.d.ts
│ ├── oxxo.d.ts
│ ├── pagofacil.d.ts
│ ├── rapipago.d.ts
│ └── sepa.d.ts
├── apple-pay
│ └── apple-pay.d.ts
├── balances
│ └── balances.d.ts
├── card-metadata
│ └── card-metadata.d.ts
├── customers
│ └── customers.d.ts
├── disputes
│ └── disputes.d.ts
├── events
│ └── events.d.ts
├── files
│ └── files.d.ts
├── financial
│ └── financial.d.ts
├── forex
│ └── forex.d.ts
├── hosted-payments
│ └── hosted-payments.d.ts
├── instruments
│ └── instruments.d.ts
├── issuing
│ └── issuing.d.ts
├── payment-contexts
│ └── payment-contexts.d.ts
├── payment-links
│ └── payment-links.d.ts
├── payment-sessions
│ └── payment-sessions.d.ts
├── payments-links
│ └── payments-links.d.ts
├── payments
│ └── payments.d.ts
├── platforms
│ └── platforms.d.ts
├── reconciliation
│ └── reconciliation.d.ts
├── reports
│ └── reports.d.ts
├── risk
│ └── risk.d.ts
├── sessions
│ └── sessions.d.ts
├── sources
│ └── sources.d.ts
├── tokens
│ └── tokens.d.ts
├── transfers
│ └── transfers.d.ts
├── webhooks
│ └── webhooks.d.ts
└── workflows
│ └── workflows.d.ts
├── config.d.ts
├── index.d.ts
└── services
├── errors.d.ts
├── http.d.ts
├── utils.d.ts
└── validation.d.ts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [{src,scripts}/**.{ts,json,js}]
4 | end_of_line = crlf
5 | charset = utf-8
6 | trim_trailing_whitespace = true
7 | insert_final_newline = true
8 | indent_style = space
9 | indent_size = 4
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | test/
2 | example.js
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "@babel/eslint-parser",
3 | "extends": ["airbnb/base", "prettier"],
4 | "plugins": ["prettier","@babel"],
5 | "rules": {
6 | "prettier/prettier": ["error"],
7 | "no-use-before-define": "off",
8 | "no-underscore-dangle": "off"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Bug report"
3 | about: Create a bug report
4 | ---
5 |
6 |
7 |
8 |
9 | ### Environment
10 |
11 | * Checkout SDK version:
12 | * Platform and version:
13 | * Operating System and version:
14 |
15 |
16 | ### Description
17 |
18 |
19 |
20 | ### Expected behavior
21 |
22 |
23 |
24 | ### Current behavior
25 |
26 |
27 |
28 |
29 | ### Steps to reproduce
30 |
31 |
32 |
33 |
34 | ### Possible solution
35 |
36 |
37 |
38 | - [ ] I may be able to implement this bug fix
39 |
40 | ### Additional information
41 |
42 |
43 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Feature request"
3 | about: Request a new future or an improvement to an existing feature
4 | ---
5 |
6 |
7 |
8 |
9 | ### Environment
10 |
11 | * Checkout SDK version:
12 | * Platform and version:
13 | * Operating System and version:
14 |
15 |
16 | ### Description
17 |
18 |
19 |
20 | ## Proposed Solution
21 |
22 |
23 |
24 |
25 | - [ ] I may be able to implement this feature
26 |
--------------------------------------------------------------------------------
/.github/workflows/build-master.yml:
--------------------------------------------------------------------------------
1 | name: build-master
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | build:
10 | if: "!contains(github.event.commits[0].message, 'Release')"
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v3
14 | - id: setup-node
15 | uses: actions/setup-node@v2.5.1
16 | with:
17 | node-version: 12
18 | registry-url: https://registry.npmjs.org/
19 | - id: build-and-analyse
20 | env:
21 | CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
22 | CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
23 | CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
24 | CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
25 | CHECKOUT_DEFAULT_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_PUBLIC_KEY }}
26 | CHECKOUT_DEFAULT_OAUTH_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_ID }}
27 | CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET }}
28 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID }}
29 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET }}
30 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID }}
31 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
32 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
33 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
34 | run: |
35 | npm ci
36 | npm test
37 | npm run build
--------------------------------------------------------------------------------
/.github/workflows/build-pull-request.yml:
--------------------------------------------------------------------------------
1 | name: build-pull-request
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - id: setup-node
14 | uses: actions/setup-node@v2.5.1
15 | with:
16 | node-version: 12
17 | registry-url: https://registry.npmjs.org/
18 | - id: build-and-analyse
19 | env:
20 | CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
21 | CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
22 | CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
23 | CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
24 | CHECKOUT_DEFAULT_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_PUBLIC_KEY }}
25 | CHECKOUT_DEFAULT_OAUTH_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_ID }}
26 | CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET }}
27 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID }}
28 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET }}
29 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID }}
30 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
31 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
32 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
33 | run: |
34 | npm ci
35 | npm test
36 | npm run build
37 |
38 |
--------------------------------------------------------------------------------
/.github/workflows/build-release.yml:
--------------------------------------------------------------------------------
1 | name: build-release
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | paths:
8 | - package.json
9 |
10 | jobs:
11 | deploy:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/checkout@v3
15 | - id: setup-node
16 | uses: actions/setup-node@v2.5.1
17 | with:
18 | node-version: 12
19 | registry-url: https://registry.npmjs.org/
20 | - id: build-and-analyse
21 | env:
22 | CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
23 | CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
24 | CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
25 | CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
26 | CHECKOUT_DEFAULT_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_PUBLIC_KEY }}
27 | CHECKOUT_DEFAULT_OAUTH_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_ID }}
28 | CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET }}
29 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_ID }}
30 | CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_PAYOUT_SCHEDULE_CLIENT_SECRET }}
31 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_ID }}
32 | CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
33 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
34 | CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
35 | run: |
36 | npm ci
37 | npm test
38 | npm run build
39 | - id: rsync
40 | run: rsync -avh --progress ./types/ ./
41 | - id: read-version
42 | run: echo "CURRENT_VERSION=$( awk -F'"' '/version/ {print $4}' package.json )" >> $GITHUB_ENV
43 | - id: print-version
44 | run: echo "Releasing $CURRENT_VERSION"
45 | - id: publish-to-npm
46 | env:
47 | NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
48 | run: npm publish
49 | - id: create-release
50 | uses: actions/create-release@v1
51 | env:
52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 | with:
54 | tag_name: ${{ env.CURRENT_VERSION }}
55 | release_name: ${{ env.CURRENT_VERSION }}
56 | body: ${{ github.event.head_commit.message }}
57 | draft: false
58 | prerelease: false
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ master ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ master ]
20 | schedule:
21 | - cron: '34 2 * * 0'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'javascript' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38 |
39 | steps:
40 | - name: Checkout repository
41 | uses: actions/checkout@v3
42 | with:
43 | submodules: recursive
44 |
45 | # Initializes the CodeQL tools for scanning.
46 | - name: Initialize CodeQL
47 | uses: github/codeql-action/init@v3
48 | with:
49 | languages: ${{ matrix.language }}
50 | queries: security-and-quality
51 |
52 | # If you wish to specify custom queries, you can do so here or in a config file.
53 | # By default, queries listed here will override any specified in a config file.
54 | # Prefix the list here with "+" to use these queries and those in the config file.
55 |
56 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
57 | # queries: security-extended,security-and-quality
58 | - name: Autobuild
59 | uses: github/codeql-action/autobuild@v3
60 |
61 | - name: Perform CodeQL Analysis
62 | uses: github/codeql-action/analyze@v3
63 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 | .nyc_output
17 | coverage.*
18 |
19 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20 | .grunt
21 |
22 | # node-waf configuration
23 | .lock-wscript
24 |
25 | # Compiled binary addons (http://nodejs.org/api/addons.html)
26 | build/Release
27 |
28 | # Dependency directory
29 | node_modules
30 |
31 | # Optional npm cache directory
32 | .npm
33 |
34 | # Optional REPL history
35 | .node_repl_history
36 |
37 | typings/
38 | lib/*.js
39 | lib/
40 | *.map
41 |
42 | .DS_Store
43 | /.vscode/
44 |
45 | doc
46 | out
47 | .idea
48 |
49 | /dist/
50 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | ./nyc_output
2 | coverage
3 | src
4 | test
5 | types
6 | .DS_Store
7 | website
8 | documentation
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": true,
3 | "singleQuote": true,
4 | "tabWidth": 4,
5 | "useTabs": false,
6 | "printWidth": 100
7 | }
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Checkout.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/checkout/checkout-sdk-node/actions/workflows/build-master.yml)
2 | 
3 | 
4 | [](https://codecov.io/gh/checkout/checkout-sdk-node)
5 |
6 | [](https://github.com/checkout/checkout-sdk-net/actions/workflows/build-release.yml)
7 | [](https://GitHub.com/checkout/checkout-sdk-node/releases/)
8 |
9 | [](https://badgen.net/bundlephobia/minzip/action-test)
10 |
11 |

12 |
13 |
14 |
15 |
16 |
17 | # :rocket: Install
18 |
19 | ```bash
20 | npm install checkout-sdk-node
21 | ```
22 |
23 | # :computer: Import
24 |
25 | ```js
26 | // ES6:
27 | import { Checkout } from 'checkout-sdk-node';
28 | // Common JS:
29 | const { Checkout } = require('checkout-sdk-node');
30 | ```
31 |
32 | > If you don't have your API keys, you can sign up for a test account [here](https://www.checkout.com/get-test-account).
33 |
34 | # :clapper: Initialize SDK
35 |
36 | ## With api keys or access credentials
37 | Based on how your account was set up, you will either have a pair or API key or a set of access credentials. Here is how you can use the SDK in both scenarios:
38 | ```js
39 | // API Keys
40 | const cko = new Checkout('sk_XXXXXXXXX', {
41 | pk: 'pk_XXXXXXX'
42 | });
43 |
44 | // Access credentials
45 | const cko = new Checkout('your api secret here', {
46 | client: 'ack_XXXXXXXX',
47 | scope: ['gateway'], // or whatever scope required
48 | environment: 'sandbox', // or 'production'
49 | });
50 | ```
51 |
52 | ## With environment variables
53 | If your account uses API Keys (pk_XXX + sk_XXX), you can set the following environment variables, and the SK will pick them up:
54 | - *CKO_SECRET_KEY* (with a value like sk_XXX)
55 | - *CKO_PUBLIC_KEY* (with a value like pk_XXX)
56 |
57 | If you use access credentials (ack_XXXX), you can set the following environment variables, and the SK will pick them up:
58 | - *CKO_SECRET*
59 | - *CKO_CLIENT* (with a value like ack_XXXX)
60 | - *CKO_SCOPE* (with a value of the scope or semicolon separated scopes in case you use multiple)
61 | - *CKO_ENVIRONMENT* (with a value like sandbox or production)
62 |
63 | ## Set custom config
64 | Basides the authentication, you also have the option to configure some extra elements about the SDK
65 | ```js
66 | const cko = new Checkout('...', {
67 | ..., //other authentication config
68 | host: "https://myProxyExample.com", // in case you need to use a custom host for tests
69 | timeout: 60000, // HTTP request timout in ms
70 | agent: new http.Agent({ keepAlive: true }), // custom HTTP agent
71 | httpClient: 'axios' // specify axios httpClient, by default fetch. Optional
72 | });
73 | ```
74 |
75 | # :wrench: SDK Environment (Sandbox/Production)
76 | When using API Keys (pk_XXX + sk_XXX) the SDK will automatically figure out what environment you are using however, if you use access credentials (ack_XXXX), make sure you set the "environment" in the config, as shown above in the initialization.
77 |
78 | # :interrobang: Error handling
79 | The SDK is using promises, and you can handle errors similar to any other HTTP call.
80 |
81 | ```js
82 | try {
83 | // some async request made with the SDK
84 | const action = await cko.payments.request({...});
85 | ...
86 | } catch (error) {
87 | console.log(error.name, error.http_code, error.body)
88 | switch (error.name) {
89 | ...
90 | }
91 | }
92 | ```
93 | Here you have all the possible SDK specific errors:
94 |
95 | | error.name | error.http_code | error.body |
96 | | -------------------- | --------------- | ----------------------- |
97 | | AuthenticationError | 401 | undefined |
98 | | ActionNotAllowed | 403 | undefined |
99 | | UrlAlreadyRegistered | 409 | undefined |
100 | | NotFoundError | 404 | undefined |
101 | | BadGateway | 502 | undefined |
102 | | ValidationError | 422 | object |
103 | | TooManyRequestsError | 429 | object/undefined |
104 | | ValueError | 429 | string describing error |
105 |
106 |
107 | # :book: Examples of usage
108 |
109 | You can see examples of how to use the SDK for every endpoint documented in our [API Reference](https://api-reference.checkout.com/). All you have to do is to navigate to the endpoint you want to use, and select "Node" for the example on the right side.
110 | > NOTE: If you use access credentials (ack_XXXX) the link to the API reference relevant to you will be shared by your Solutions Engineers.
111 |
112 | # :eyeglasses: Try it on RunKit
113 |
114 | You can try the SDK [here](https://npm.runkit.com/checkout-sdk-node).
115 |
--------------------------------------------------------------------------------
/example.js:
--------------------------------------------------------------------------------
1 | const { Checkout } = require('checkout-sdk-node');
2 |
3 | /** Go to checkout.com and sign up for a test account to get your own key.*/
4 | const cko = new Checkout('sk_test_3e1ad21b-ac23-4eb3-ad1f-375e9fb56481');
5 |
6 | /**
7 | * Keep in mind that requests with raw card details
8 | * requre a high level of PCI Compliance.
9 | */
10 | (async () => {
11 | const transaction = await cko.payments.request({
12 | source: {
13 | number: '4242424242424242',
14 | expiry_month: 6,
15 | expiry_year: 2029,
16 | cvv: '100'
17 | },
18 | currency: 'USD',
19 | amount: 100
20 | });
21 |
22 | console.log(transaction.status);
23 | })();
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "checkout-sdk-node",
3 | "version": "2.7.0",
4 | "description": "",
5 | "type": "commonjs",
6 | "main": "./dist/index.js",
7 | "types": "./dist/index.d.ts",
8 | "devDependencies": {
9 | "@babel/cli": "^7.16.8",
10 | "@babel/core": "^7.16.7",
11 | "@babel/eslint-parser": "^7.16.5",
12 | "@babel/eslint-plugin": "^7.16.5",
13 | "@babel/node": "^7.16.8",
14 | "@babel/preset-env": "^7.16.8",
15 | "@types/mocha": "^10.0.10",
16 | "chai": "^4.3.4",
17 | "codecov": "^3.8.2",
18 | "eslint": "^8.34.0",
19 | "eslint-config-airbnb": "^19.0.4",
20 | "eslint-config-prettier": "^8.3.0",
21 | "eslint-plugin-chai-friendly": "^0.7.1",
22 | "eslint-plugin-import": "^2.22.1",
23 | "eslint-plugin-prettier": "^3.4.0",
24 | "esm": "^3.2.25",
25 | "mocha": "^8.4.0",
26 | "mocha-junit-reporter": "^2.0.0",
27 | "nock": "^13.0.11",
28 | "nyc": "^15.1.0",
29 | "prettier": "^2.1.2",
30 | "uuid": "^8.3.2"
31 | },
32 | "runkitExampleFilename": "example.js",
33 | "scripts": {
34 | "start": "nodemon --exec babel-node ./src/index.js",
35 | "lint": "eslint --fix --ext .js src/",
36 | "test": "nyc --reporter=html mocha --timeout 300000 'test/**/*.js' --require esm",
37 | "posttest": "nyc report --reporter=json",
38 | "test:watch": "mocha --timeout 300000 'test/**/*.js' --watch --require esm",
39 | "build": "babel src --out-dir ./dist --source-maps",
40 | "codecov": "codecov -f coverage/*.json",
41 | "tsc": "tsc"
42 | },
43 | "dependencies": {
44 | "axios": "^0.30.0",
45 | "form-data": "^4.0.0",
46 | "node-fetch": "^2.6.12"
47 | },
48 | "babel": {
49 | "presets": [
50 | [
51 | "@babel/preset-env",
52 | {
53 | "targets": {
54 | "node": 6
55 | }
56 | }
57 | ]
58 | ]
59 | },
60 | "author": "Ioan Ghisoi",
61 | "license": "MIT"
62 | }
63 |
--------------------------------------------------------------------------------
/src/api/access/access.js:
--------------------------------------------------------------------------------
1 | import { determineError } from '../../services/errors';
2 | import { createAccessToken } from '../../services/http';
3 |
4 | /**
5 | * Class dealing with the access api
6 | *
7 | * @export
8 | * @class Access
9 | */
10 | export default class Access {
11 | constructor(config) {
12 | this.config = config;
13 | }
14 |
15 | /**
16 | * Request an access token
17 | *
18 | * @param {Object} body Access object body.
19 | * @return {Promise