mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-04-24 23:51:21 +00:00
Compare commits
358 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b76846c031 | ||
|
|
bf1e643973 | ||
|
|
316542a166 | ||
|
|
8c451502e3 | ||
|
|
bd70b93c08 | ||
|
|
fd7b05ab09 | ||
|
|
4ed7e77d0e | ||
|
|
a289846a16 | ||
|
|
277edb212c | ||
|
|
be9194fafe | ||
|
|
f210123964 | ||
|
|
872f86064f | ||
|
|
ba18fcb181 | ||
|
|
79aaf6580e | ||
|
|
2d6330b552 | ||
|
|
ad540c8964 | ||
|
|
e10cd25364 | ||
|
|
7ed7299480 | ||
|
|
c8220fe6d4 | ||
|
|
790c880eef | ||
|
|
e3a2918fa9 | ||
|
|
aa35700e88 | ||
|
|
7a8ef2bc40 | ||
|
|
791f68163a | ||
|
|
91306b86d3 | ||
|
|
086b8bc929 | ||
|
|
8aa158b943 | ||
|
|
4ac101a30c | ||
|
|
533a07c87e | ||
|
|
37b752de49 | ||
|
|
59ce9c5d37 | ||
|
|
f5efb595ef | ||
|
|
50548c1857 | ||
|
|
a298fa84fb | ||
|
|
e6d369506e | ||
|
|
e084599757 | ||
|
|
4246674d29 | ||
|
|
ffbf955b95 | ||
|
|
0d6535f32c | ||
|
|
343e04f475 | ||
|
|
f1f8161f2a | ||
|
|
ba8f2b44f3 | ||
|
|
898be12d1c | ||
|
|
d0ba69a3a8 | ||
|
|
83662185f8 | ||
|
|
9eb30e7a25 | ||
|
|
2d3eccf188 | ||
|
|
962c8d62cd | ||
|
|
3e134634c0 | ||
|
|
8d7fec9d21 | ||
|
|
02996d6b9c | ||
|
|
a3ac8b1144 | ||
|
|
7e790b6bfb | ||
|
|
3b24e07cd3 | ||
|
|
f382796730 | ||
|
|
1e83db3465 | ||
|
|
72d856d1d6 | ||
|
|
b13a666a84 | ||
|
|
6f8389e6cc | ||
|
|
b15ccd88cb | ||
|
|
d9574bcfea | ||
|
|
677fe3cc8e | ||
|
|
983f8777e6 | ||
|
|
81e4ee018e | ||
|
|
163446bfab | ||
|
|
0fda83998f | ||
|
|
f9ee123b7d | ||
|
|
ca0d866c18 | ||
|
|
a3683f6192 | ||
|
|
d33a206543 | ||
|
|
e28a72a6fa | ||
|
|
01503307d0 | ||
|
|
2b1d2266f3 | ||
|
|
9021e205fc | ||
|
|
ad5559c55a | ||
|
|
61a634def0 | ||
|
|
078b120725 | ||
|
|
0138e148e7 | ||
|
|
aefb0e5e19 | ||
|
|
692a133058 | ||
|
|
e36af2f7c7 | ||
|
|
9a12c9e46b | ||
|
|
1d365df9c8 | ||
|
|
bcdc42bd7a | ||
|
|
d6ae7af069 | ||
|
|
35542e5bce | ||
|
|
b955690774 | ||
|
|
022f85b343 | ||
|
|
e1f05edba1 | ||
|
|
b8407eac70 | ||
|
|
1f8b6351ce | ||
|
|
93dad27fca | ||
|
|
1b42fa2125 | ||
|
|
d47a876123 | ||
|
|
20097e6a62 | ||
|
|
fb170c2f88 | ||
|
|
b22502026a | ||
|
|
18c0498e27 | ||
|
|
e6a03d7483 | ||
|
|
d9480ffbb9 | ||
|
|
4a6c1218ea | ||
|
|
26803de094 | ||
|
|
f6d61eae30 | ||
|
|
41f58990b4 | ||
|
|
15799bbd5b | ||
|
|
d69ead8926 | ||
|
|
a250acfa21 | ||
|
|
0b75b1d8f7 | ||
|
|
13309b073a | ||
|
|
71c697e102 | ||
|
|
e4c7c62807 | ||
|
|
de7cd45027 | ||
|
|
219f51620a | ||
|
|
371d910fb6 | ||
|
|
e76c16e540 | ||
|
|
45ec478631 | ||
|
|
390d447093 | ||
|
|
df7f3ad6c5 | ||
|
|
d7f5a17296 | ||
|
|
747f369aa5 | ||
|
|
86d64e8343 | ||
|
|
085ac91bf3 | ||
|
|
f742cbe542 | ||
|
|
19ccff04e5 | ||
|
|
b4b702b1be | ||
|
|
00acf4841f | ||
|
|
7300b9e37b | ||
|
|
e347851506 | ||
|
|
c2daccdf56 | ||
|
|
a6785cab12 | ||
|
|
1b636e98a3 | ||
|
|
dd9eca1ede | ||
|
|
706201f0e2 | ||
|
|
5d00b0cba1 | ||
|
|
ca2515ae37 | ||
|
|
72f167c36a | ||
|
|
5631c99d12 | ||
|
|
e06f45ed49 | ||
|
|
63c768ee45 | ||
|
|
d7602095b3 | ||
|
|
c4e1c96736 | ||
|
|
c335e29869 | ||
|
|
1b095f8e7e | ||
|
|
9505a49ea7 | ||
|
|
8eb1708b03 | ||
|
|
7861a0bf0c | ||
|
|
6c049d8b0d | ||
|
|
b1f58c3ab1 | ||
|
|
95d4894cab | ||
|
|
5d1f89b76a | ||
|
|
f868a8027a | ||
|
|
e31d10504f | ||
|
|
612b95437d | ||
|
|
0bb8963d94 | ||
|
|
0a835c55be | ||
|
|
aba0c19859 | ||
|
|
1e60855be9 | ||
|
|
9943b41589 | ||
|
|
a479c38bf1 | ||
|
|
55c924f925 | ||
|
|
020a392239 | ||
|
|
47f587d43b | ||
|
|
a60f810c8f | ||
|
|
e52ac64370 | ||
|
|
f579c306b1 | ||
|
|
f236355f7c | ||
|
|
5a5a3c618a | ||
|
|
7b23bcd23c | ||
|
|
dc8499f13c | ||
|
|
75243ebd6e | ||
|
|
e3f8eef013 | ||
|
|
0f9ec5d59d | ||
|
|
cc2811555b | ||
|
|
58673103cd | ||
|
|
467a04b215 | ||
|
|
097cd658e5 | ||
|
|
699e1e52ea | ||
|
|
c1ab1018b8 | ||
|
|
3c4f9409e5 | ||
|
|
57b658c917 | ||
|
|
f3e24c0ebc | ||
|
|
040002305c | ||
|
|
78782a8fa6 | ||
|
|
f16612a3ba | ||
|
|
9fe7879b35 | ||
|
|
b075c7a1f6 | ||
|
|
25cfb74feb | ||
|
|
d34a08303a | ||
|
|
9f3ee679e8 | ||
|
|
25f31ca4c1 | ||
|
|
48419f14d9 | ||
|
|
86191a0669 | ||
|
|
05345cdbd8 | ||
|
|
55418abc73 | ||
|
|
c746566a20 | ||
|
|
9494be4675 | ||
|
|
ad756cd558 | ||
|
|
65b2ed0875 | ||
|
|
32adeb6dc0 | ||
|
|
e6e948ea79 | ||
|
|
4820b13a98 | ||
|
|
c65c440cf7 | ||
|
|
bd3df0bef3 | ||
|
|
2b0bbd969a | ||
|
|
ac9dfd99eb | ||
|
|
a2e8fe796b | ||
|
|
79320f3782 | ||
|
|
d67047c9b6 | ||
|
|
73adc4cc07 | ||
|
|
788d96caa3 | ||
|
|
4235c68811 | ||
|
|
05fefe611a | ||
|
|
260ccfcb23 | ||
|
|
1b1e5c313f | ||
|
|
29f98d0d04 | ||
|
|
55ccd7be5e | ||
|
|
610b2d044a | ||
|
|
74885378da | ||
|
|
a29eab08c8 | ||
|
|
d301b91dec | ||
|
|
25a4e12335 | ||
|
|
66764d762f | ||
|
|
5dd32b61a0 | ||
|
|
a37613ee48 | ||
|
|
aa4a6c283c | ||
|
|
3c7db932d5 | ||
|
|
a68a494875 | ||
|
|
79aec0524d | ||
|
|
35b4d4ddfc | ||
|
|
3c425fd918 | ||
|
|
7df995e632 | ||
|
|
0cd8da6dea | ||
|
|
dc1f8352d1 | ||
|
|
df2b42f252 | ||
|
|
dd3b4eec1b | ||
|
|
fba3731f48 | ||
|
|
f285a6b079 | ||
|
|
a7bbdcfd5d | ||
|
|
c725323592 | ||
|
|
18608d624e | ||
|
|
8389edec56 | ||
|
|
2c29b5ee23 | ||
|
|
b535b4037a | ||
|
|
1c844faca1 | ||
|
|
57890b8921 | ||
|
|
31eec15b6f | ||
|
|
63e9db934c | ||
|
|
bf1b43dc10 | ||
|
|
2d4b7bad90 | ||
|
|
c4eabd0f12 | ||
|
|
89eb4dc9c4 | ||
|
|
14839a0cf0 | ||
|
|
dec39db6f9 | ||
|
|
7ad73abab1 | ||
|
|
e17a22db15 | ||
|
|
89a613ada7 | ||
|
|
bb294b9bfd | ||
|
|
f2bcb49e79 | ||
|
|
aeb40ff24c | ||
|
|
a43dd78955 | ||
|
|
bc9a87fccd | ||
|
|
41ad8f5ecc | ||
|
|
10c3ae21dd | ||
|
|
a5acf3dfc5 | ||
|
|
d900d83063 | ||
|
|
a43e4d16fd | ||
|
|
93ee32094d | ||
|
|
1b697c993e | ||
|
|
829ecbdbf8 | ||
|
|
a857cde90c | ||
|
|
ee68e81587 | ||
|
|
af6b48fa44 | ||
|
|
aa75019671 | ||
|
|
f7d158b7e1 | ||
|
|
26fcf54030 | ||
|
|
1b0a89cf68 | ||
|
|
8691fc9bdf | ||
|
|
dd35012405 | ||
|
|
c710018feb | ||
|
|
932b5e6659 | ||
|
|
cea53fbc7c | ||
|
|
7809c5b3d5 | ||
|
|
d9e5046320 | ||
|
|
1b0995b75a | ||
|
|
3d0ad7922c | ||
|
|
c2ea07f5a7 | ||
|
|
24050833e0 | ||
|
|
0f5be9dc1a | ||
|
|
482a3c09d6 | ||
|
|
f660e40545 | ||
|
|
c04567a9f8 | ||
|
|
7fce7e7d65 | ||
|
|
87ffe8f7bc | ||
|
|
873faa548b | ||
|
|
1f37bc34d2 | ||
|
|
12067aa15a | ||
|
|
c88e2a8515 | ||
|
|
ec673c5608 | ||
|
|
751a71cc09 | ||
|
|
e4de89f4bc | ||
|
|
9d464a83d6 | ||
|
|
eee36893a9 | ||
|
|
5f5892b6a0 | ||
|
|
b24e0ffd0b | ||
|
|
e89583b2d3 | ||
|
|
4c346e291c | ||
|
|
767c209212 | ||
|
|
6645a508e1 | ||
|
|
7d69afd91b | ||
|
|
a536c09784 | ||
|
|
1aa67b715e | ||
|
|
d421fc586e | ||
|
|
1954248804 | ||
|
|
cd1d460b95 | ||
|
|
306156af83 | ||
|
|
648e4bb055 | ||
|
|
091c237d06 | ||
|
|
a40925de1c | ||
|
|
1ae41e1e02 | ||
|
|
b94647b060 | ||
|
|
14570afa70 | ||
|
|
a2195b0384 | ||
|
|
30ddae4cee | ||
|
|
e398942fbf | ||
|
|
4e24fd0de9 | ||
|
|
f533ef9e28 | ||
|
|
a26d599503 | ||
|
|
e19c944644 | ||
|
|
e7cd862d0d | ||
|
|
7d562d6ecf | ||
|
|
1d084469ce | ||
|
|
294e1e2e74 | ||
|
|
99a525a97a | ||
|
|
89e0d37108 | ||
|
|
3b3f68604c | ||
|
|
04a6260f97 | ||
|
|
9d3f345b57 | ||
|
|
4f3a84c63e | ||
|
|
b0f21188a0 | ||
|
|
ef94f38cc7 | ||
|
|
2c34316e04 | ||
|
|
d36b1d2d14 | ||
|
|
437ad21add | ||
|
|
d2922e4e22 | ||
|
|
e71dc9e033 | ||
|
|
48fafea931 | ||
|
|
a850d88462 | ||
|
|
9521f2093c | ||
|
|
cef63a9e95 | ||
|
|
8143e0fec6 | ||
|
|
0ebdaa6a49 | ||
|
|
a21f14e143 | ||
|
|
b55d576e82 | ||
|
|
b168f928bb | ||
|
|
74966689d9 | ||
|
|
b287026a3c | ||
|
|
6e14b3068c | ||
|
|
1227acadc0 |
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -1 +1 @@
|
|||||||
* @zaiddreakh @maassenbas @AlexandrosMor @peterojo @wboereboom
|
* @Adyen/javascript
|
||||||
|
|||||||
15
.github/dependabot.yml
vendored
15
.github/dependabot.yml
vendored
@@ -1,15 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
time: "04:00"
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
reviewers:
|
|
||||||
- zaiddreakh
|
|
||||||
maassenbas
|
|
||||||
msilvagarcia
|
|
||||||
AlexandrosMor
|
|
||||||
peterojo
|
|
||||||
wboereboom
|
|
||||||
7
.github/stale.yml
vendored
7
.github/stale.yml
vendored
@@ -3,6 +3,13 @@ daysUntilStale: 60
|
|||||||
# Number of days of inactivity before a stale issue is closed
|
# Number of days of inactivity before a stale issue is closed
|
||||||
daysUntilClose: 7
|
daysUntilClose: 7
|
||||||
# Label to use when marking an issue as stale
|
# Label to use when marking an issue as stale
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
exemptLabels:
|
||||||
|
- Validating request
|
||||||
|
- Bug report
|
||||||
|
- Bug
|
||||||
|
- Enhancement
|
||||||
|
- feature
|
||||||
staleLabel: wontfix
|
staleLabel: wontfix
|
||||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
markComment: >
|
markComment: >
|
||||||
|
|||||||
10
.github/workflows/codeql-analysis.yml
vendored
10
.github/workflows/codeql-analysis.yml
vendored
@@ -13,15 +13,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
# We must fetch at least the immediate parents so that if this is
|
# We must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head.
|
# a pull request then we can checkout the head.
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v2
|
||||||
# Override language selection by uncommenting this and choosing your languages
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
# with:
|
# with:
|
||||||
# languages: go, javascript, csharp, python, cpp, java
|
# languages: go, javascript, csharp, python, cpp, java
|
||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -43,4 +43,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
10
.github/workflows/coveralls.yml
vendored
10
.github/workflows/coveralls.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
on: ["push", "pull_request"]
|
on: ["pull_request"]
|
||||||
|
|
||||||
name: Coveralls
|
name: Coveralls
|
||||||
|
|
||||||
@@ -9,12 +9,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Use Node.js 12.x
|
- name: Use Node.js 16.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
|
||||||
- name: npm install, npm test:coverage
|
- name: npm install, npm test:coverage
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
30
.github/workflows/models.yml
vendored
Normal file
30
.github/workflows/models.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Node.js Models
|
||||||
|
|
||||||
|
on: [ workflow_dispatch ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Generate Models
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: make models
|
||||||
|
- name: Set PR variables
|
||||||
|
id: vars
|
||||||
|
run: |
|
||||||
|
cd build/spec
|
||||||
|
echo ::set-output name=pr_title::"Update models"
|
||||||
|
echo ::set-output name=pr_body::"OpenAPI spec or templates produced new models on $(date +%d-%m-%Y) \
|
||||||
|
by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
|
||||||
|
committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
|
||||||
|
author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
|
||||||
|
base: develop
|
||||||
|
branch: automation/models
|
||||||
|
title: ${{ steps.vars.outputs.pr_title }}
|
||||||
|
body: ${{ steps.vars.outputs.pr_body }}
|
||||||
|
add-paths: |
|
||||||
|
src/typings
|
||||||
8
.github/workflows/nodejs.yml
vendored
8
.github/workflows/nodejs.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Node.js CI
|
name: Node.js CI
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -9,12 +9,12 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [10.x, 12.x, 13.x]
|
node-version: [12.x, 14.x, 16.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- name: npm install, lint and test
|
- name: npm install, lint and test
|
||||||
|
|||||||
10
.github/workflows/npmpublish.yml
vendored
10
.github/workflows/npmpublish.yml
vendored
@@ -1,16 +1,18 @@
|
|||||||
name: Node.js Package
|
name: Node.js Package
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-npm:
|
publish-npm:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12
|
node-version: 14
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- run: |
|
- run: |
|
||||||
npm install
|
npm install
|
||||||
|
|||||||
4
.github/workflows/sonarcloud.yml
vendored
4
.github/workflows/sonarcloud.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: "Sonarcloud Analysis"
|
name: "Sonarcloud Analysis"
|
||||||
|
|
||||||
on: ["push", "pull_request"]
|
on: ["pull_request"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sonarcloud-analysis:
|
sonarcloud-analysis:
|
||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
# Disabling shallow clone to improve relevancy of SonarCloud reporting
|
# Disabling shallow clone to improve relevancy of SonarCloud reporting
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,4 +12,5 @@ node_modules
|
|||||||
.viminfo
|
.viminfo
|
||||||
coverage/
|
coverage/
|
||||||
.env
|
.env
|
||||||
lib/
|
lib/
|
||||||
|
build/
|
||||||
13
.npmignore
13
.npmignore
@@ -1,11 +1,16 @@
|
|||||||
src/
|
src/
|
||||||
.babelrc
|
|
||||||
.eslintignore
|
.eslintignore
|
||||||
.eslintrc.json
|
.eslintrc.js
|
||||||
.gitignore
|
.gitignore
|
||||||
.travis.yml
|
.release-it.json
|
||||||
|
CODE_OF_CONDUCT.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
Makefile
|
||||||
|
config.ts
|
||||||
|
renovate.json
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
jest.config.js
|
jest.config.js
|
||||||
tslint.json
|
tslint.json
|
||||||
webpack.config.js
|
|
||||||
.github
|
.github
|
||||||
|
/**/__mocks__/
|
||||||
|
/**/__tests__/
|
||||||
|
|||||||
74
Makefile
Normal file
74
Makefile
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
generator:=typescript-node
|
||||||
|
openapi-generator-version:=5.4.0
|
||||||
|
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
|
||||||
|
openapi-generator-jar:=build/openapi-generator-cli.jar
|
||||||
|
openapi-generator-cli:=java -jar $(openapi-generator-jar)
|
||||||
|
services:=balancePlatform binlookup checkout dataProtection legalEntityManagement management payments payouts platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration recurring storedValue terminalManagement transfer
|
||||||
|
|
||||||
|
# Generate models (for each service)
|
||||||
|
models: $(services)
|
||||||
|
|
||||||
|
binlookup: spec=BinLookupService-v52
|
||||||
|
checkout: spec=CheckoutService-v69
|
||||||
|
dataProtection: spec=DataProtectionService-v1
|
||||||
|
storedValue: spec=StoredValueService-v46
|
||||||
|
terminalManagement: spec=TfmAPIService-v1
|
||||||
|
payments: spec=PaymentService-v68
|
||||||
|
recurring: spec=RecurringService-v68
|
||||||
|
payouts: spec=PayoutService-v68
|
||||||
|
management: spec=ManagementService-v1
|
||||||
|
managementapi: spec=ManagementService-v1
|
||||||
|
managementapi: service=management
|
||||||
|
legalEntityManagement: spec=LegalEntityService-v2
|
||||||
|
balancePlatform: spec=BalancePlatformService-v2
|
||||||
|
platformsAccount: spec=AccountService-v6
|
||||||
|
platformsFund: spec=FundService-v6
|
||||||
|
platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
|
||||||
|
platformsHostedOnboardingPage: spec=HopService-v6
|
||||||
|
transfer: spec=TransferService-v3
|
||||||
|
|
||||||
|
$(services): build/spec $(openapi-generator-jar)
|
||||||
|
rm -rf src/typings/$@ build/model
|
||||||
|
$(openapi-generator-cli) generate \
|
||||||
|
-i build/spec/json/$(spec).json \
|
||||||
|
-g $(generator) \
|
||||||
|
-t templates/typescript \
|
||||||
|
-o build \
|
||||||
|
--global-property models,supportingFiles \
|
||||||
|
--additional-properties=serviceName=$@
|
||||||
|
mv build/model src/typings/$@
|
||||||
|
|
||||||
|
# Service
|
||||||
|
managementapi: build/spec $(openapi-generator-jar)
|
||||||
|
$(openapi-generator-cli) generate \
|
||||||
|
-i build/spec/json/$(spec).json \
|
||||||
|
-g $(generator) \
|
||||||
|
-t templates/typescript \
|
||||||
|
-o build \
|
||||||
|
--api-package $(service) \
|
||||||
|
--model-package typings/$(service) \
|
||||||
|
--global-property apis \
|
||||||
|
--additional-properties=serviceName=$(service)
|
||||||
|
cp build/$(service)/* src/services/$(service)
|
||||||
|
sed -i.bak '/RestServiceError/d' src/services/$(service)/*
|
||||||
|
rm src/services/$(service)/*.bak
|
||||||
|
|
||||||
|
# Checkout spec (and patch version)
|
||||||
|
build/spec:
|
||||||
|
git clone https://github.com/Adyen/adyen-openapi.git build/spec
|
||||||
|
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
|
||||||
|
|
||||||
|
# Extract templates (copy them for modifications)
|
||||||
|
templates: $(openapi-generator-jar)
|
||||||
|
$(openapi-generator-cli) author template -g $(generator) -o build/templates/typescript
|
||||||
|
|
||||||
|
# Download the generator
|
||||||
|
$(openapi-generator-jar):
|
||||||
|
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
|
||||||
|
|
||||||
|
# Discard generated artifacts and changed models
|
||||||
|
clean:
|
||||||
|
git checkout src/typings src/services/management
|
||||||
|
git clean -f -d src/typings src/services/management
|
||||||
|
|
||||||
|
.PHONY: templates models $(services)
|
||||||
132
README.md
132
README.md
@@ -1,35 +1,47 @@
|
|||||||
|
|
||||||
|

|
||||||
|
|
||||||
# Adyen Node.js API Library
|
# Adyen Node.js API Library
|
||||||

|

|
||||||
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=master)
|
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=main)
|
||||||
[](https://www.npmjs.com/package/@adyen/api-library)
|
[](https://www.npmjs.com/package/@adyen/api-library)
|
||||||

|

|
||||||
[](https://www.npmjs.com/package/@adyen/api-library)
|
[](https://www.npmjs.com/package/@adyen/api-library)
|
||||||
[](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
|
[](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
|
||||||
[](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/alerts/)
|
|
||||||
[](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/context:javascript)
|
|
||||||
|
|
||||||
This is the officially supported NodeJS library for using Adyen's APIs.
|
This is the officially supported NodeJS library for using Adyen's APIs.
|
||||||
|
|
||||||
## Integration
|
## Supported API versions
|
||||||
The Library supports all APIs under the following services:
|
The Library supports all APIs under the following services:
|
||||||
|
| API | Description | Service Name | Supported version |
|
||||||
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/overview): Our latest integration for accepting online payments. Current supported version: **v67**
|
| --- | ----------- | ------------ | ----------------- |
|
||||||
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
|
|[BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview) | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | BinLookup | **v52** |
|
||||||
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
|
| [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview)| Our latest integration for accepting online payments. | CheckoutAPI | **v69** |
|
||||||
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
|
| [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview)| The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | BalancePlatform | **v2** |
|
||||||
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms.
|
| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | DataProtection | **v1** |
|
||||||
* [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
|
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v2/overview)| Manage legal entities that contain information required for verification. | LegalEntityManagement | **v2** |
|
||||||
* [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
|
| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference)| Our point-of-sale integration. | TerminalLocalAPI or TerminalCloudAPI | - |
|
||||||
* [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
|
| [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview)| Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | Management | **v1** |
|
||||||
* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration.
|
| [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview)| Our classic integration for online payments. | ClassicIntegrationAPI | **v68** |
|
||||||
* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v50**
|
| [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview)| Endpoints for sending funds to your customers. | Payout | **v68** |
|
||||||
|
| [Platforms APIs](https://docs.adyen.com/platforms/api)| Set of APIs when using Adyen for Platforms. This API is used for the classic integration. | Platforms | - |
|
||||||
|
| [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) | *Platforms subclass* | Account | **v6** |
|
||||||
|
| [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) | *Platforms subclass* | Fund | **v6** |
|
||||||
|
| [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview)| *Platforms subclass* | HostedOnboardingPage | **v6** |
|
||||||
|
| [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) | *Platforms subclass* | NotificationConfiguration | **v6** |
|
||||||
|
| [Platforms Notifications Webhooks](https://docs.adyen.com/api-explorer/#/NotificationService/v6/overview) || *Models only* | **v6** |
|
||||||
|
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview)| Endpoints for managing your point-of-sale payment terminals. | TerminalManagement | **v1** |
|
||||||
|
| [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview)| Endpoints for managing saved payment details. | Recurring | **v68** |
|
||||||
|
| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | Manage both online and point-of-sale gift cards and other stored-value cards. | StoredValue | **v46** |
|
||||||
|
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | Transfers | **v3** |
|
||||||
|
| [Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | Adyen uses webhooks to send notifications about payment status updates, newly available reports, and other events that can be subscribed to. For more information, refer to our [documentation](https://docs.adyen.com/development-resources/webhooks). | *Models only* | **v1** |
|
||||||
|
|
||||||
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
|
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen). To start using Adyen APIs, you will need a Merchant Account.
|
||||||
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
|
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
|
||||||
- Node 10 or higher
|
- Node 12 or higher
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -46,21 +58,93 @@ Alternatively, you can download the [release on GitHub](https://github.com/Adyen
|
|||||||
|
|
||||||
## Using the library
|
## Using the library
|
||||||
|
|
||||||
### General use with API key
|
### Client initialisation
|
||||||
|
#### General use with API key
|
||||||
|
|
||||||
Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen:
|
Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
const { Client } = require('@adyen/api-library');
|
||||||
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
||||||
```
|
```
|
||||||
### General use with API key for live environment
|
#### General use with API key for live environment
|
||||||
```typescript
|
```typescript
|
||||||
const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});
|
const { Client } = require('@adyen/api-library');
|
||||||
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});
|
||||||
```
|
```
|
||||||
### General use with basic auth
|
#### General use with basic auth
|
||||||
```typescript
|
```typescript
|
||||||
const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});
|
const { Client } = require('@adyen/api-library');
|
||||||
|
const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Consuming Services
|
||||||
|
Every API the library supports is represented by a service object. The name of the service matching the corresponding API is listed in the [Integrations](#supported-api-versions) section of this document.
|
||||||
|
```javascript
|
||||||
|
const { Client, CheckoutAPI } = require('@adyen/api-library');
|
||||||
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
||||||
|
|
||||||
|
const paymentRequest = {
|
||||||
|
amount: {
|
||||||
|
currency: "USD",
|
||||||
|
value: 1000 // value in minor units
|
||||||
|
},
|
||||||
|
reference: "Your order number",
|
||||||
|
paymentMethod: {
|
||||||
|
type: "scheme",
|
||||||
|
encryptedCardNumber: "test_4111111111111111",
|
||||||
|
encryptedExpiryMonth: "test_03",
|
||||||
|
encryptedExpiryYear: "test_2030",
|
||||||
|
encryptedSecurityCode: "test_737"
|
||||||
|
},
|
||||||
|
shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
|
||||||
|
storePaymentMethod: true,
|
||||||
|
shopperInteraction: "Ecommerce",
|
||||||
|
recurringProcessingModel: "CardOnFile",
|
||||||
|
returnUrl: "https://your-company.com/...",
|
||||||
|
merchantAccount: "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
const checkoutAPI = new CheckoutAPI(client);
|
||||||
|
checkoutAPI.payments(paymentRequest)
|
||||||
|
.then( paymentResponse => console.log(paymentResponse.pspReference))
|
||||||
|
.catch(error => console.log(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively you can make use of the Types included in this library using Typescript, and/or use the async syntax:
|
||||||
|
```typescript
|
||||||
|
const { Client, CheckoutAPI } = require('@adyen/api-library');
|
||||||
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
||||||
|
|
||||||
|
import { Types } from '@adyen/api-library';
|
||||||
|
|
||||||
|
const doPaymentsRequest = async () => {
|
||||||
|
const paymentRequest : Types.checkout.PaymentRequest = {
|
||||||
|
amount: {
|
||||||
|
currency: "USD",
|
||||||
|
value: 1000 // value in minor units
|
||||||
|
},
|
||||||
|
reference: "Your order number",
|
||||||
|
paymentMethod: {
|
||||||
|
type: Types.checkout.CardDetails.TypeEnum.Scheme,
|
||||||
|
encryptedCardNumber: "test_4111111111111111",
|
||||||
|
encryptedExpiryMonth: "test_03",
|
||||||
|
encryptedExpiryYear: "test_2030",
|
||||||
|
encryptedSecurityCode: "test_737"
|
||||||
|
},
|
||||||
|
shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
|
||||||
|
storePaymentMethod: true,
|
||||||
|
shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
|
||||||
|
recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.CardOnFile,
|
||||||
|
returnUrl: "https://your-company.com/...",
|
||||||
|
merchantAccount: "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
const checkoutAPI = new CheckoutAPI(client);
|
||||||
|
const paymentResponse : Types.checkout.PaymentResponse = await checkoutAPI.payments(paymentRequest);
|
||||||
|
console.log(paymentResponse.pspReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
doPaymentsRequest();
|
||||||
|
```
|
||||||
|
|
||||||
### Custom HTTP Client Configuration
|
### Custom HTTP Client Configuration
|
||||||
By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`:
|
By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`:
|
||||||
@@ -122,7 +206,7 @@ We strongly encourage you to join us in contributing to this repository so every
|
|||||||
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how to create a pull request.
|
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how to create a pull request.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/).
|
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://www.adyen.help).
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
This repository is available under the [MIT license](LICENSE).
|
This repository is available under the [MIT license](LICENSE).
|
||||||
|
|||||||
26
package.json
26
package.json
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@adyen/api-library",
|
"name": "@adyen/api-library",
|
||||||
"version": "9.1.0",
|
"version": "12.2.0",
|
||||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
|
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -35,30 +35,30 @@
|
|||||||
"author": "Ricardo Ambrogi",
|
"author": "Ricardo Ambrogi",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "27.0.2",
|
"@types/jest": "27.5.2",
|
||||||
"@types/nock": "11.1.0",
|
"@types/nock": "11.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "4.31.2",
|
"@typescript-eslint/eslint-plugin": "5.43.0",
|
||||||
"@typescript-eslint/parser": "4.31.2",
|
"@typescript-eslint/parser": "5.45.0",
|
||||||
"acorn": "^8.0.1",
|
"acorn": "^8.0.1",
|
||||||
"coveralls": "3.1.1",
|
"coveralls": "3.1.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"eslint": "7.32.0",
|
"eslint": "8.28.0",
|
||||||
"jest": "^27.0.6",
|
"jest": "^27.0.6",
|
||||||
"jest-ts-auto-mock": "^2.0.0",
|
"jest-ts-auto-mock": "^2.0.0",
|
||||||
"kind-of": "^6.0.3",
|
"kind-of": "^6.0.3",
|
||||||
"minimist": ">=1.2.3",
|
"minimist": ">=1.2.3",
|
||||||
"nock": "13.1.3",
|
"nock": "13.3.0",
|
||||||
"release-it": "14.11.6",
|
"release-it": "15.5.0",
|
||||||
"ts-auto-mock": "^3.3.5",
|
"ts-auto-mock": "^3.3.5",
|
||||||
"ts-jest": "^27.0.4",
|
"ts-jest": "^27.0.4",
|
||||||
"ts-loader": "8.0.10",
|
"ts-loader": "9.4.2",
|
||||||
"ttypescript": "^1.5.10",
|
"ttypescript": "^1.5.10",
|
||||||
"typescript": "4.4.3"
|
"typescript": "4.9.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"https-proxy-agent": "5.0.0"
|
"https-proxy-agent": "5.0.1"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@types/node": "14.0.9"
|
"@types/node": "14.18.36"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
renovate.json
Normal file
6
renovate.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -44,7 +44,14 @@ export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
|
|||||||
config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||||
config.apiKey = apiKey;
|
config.apiKey = apiKey;
|
||||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
|
||||||
|
config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
|
||||||
|
config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;
|
||||||
|
config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_TEST;
|
||||||
|
config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_TEST;
|
||||||
|
|
||||||
return new Client({ config });
|
return new Client({ config });
|
||||||
};
|
};
|
||||||
@@ -112,7 +119,8 @@ const getReversalRequest = (poiTransaction: TransactionIdentification): Reversal
|
|||||||
TimeStamp: poiTransaction.TimeStamp
|
TimeStamp: poiTransaction.TimeStamp
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ReversalReason: ReversalReasonType.MerchantCancel
|
ReversalReason: ReversalReasonType.MerchantCancel,
|
||||||
|
SaleData: saleData
|
||||||
});
|
});
|
||||||
|
|
||||||
const getSaleToPOIRequest = (messageHeader: MessageHeader, request: Partial<SaleToPOIRequest>): SaleToPOIRequest => ({
|
const getSaleToPOIRequest = (messageHeader: MessageHeader, request: Partial<SaleToPOIRequest>): SaleToPOIRequest => ({
|
||||||
|
|||||||
33
src/__mocks__/checkout/sessionsSuccess.ts
Normal file
33
src/__mocks__/checkout/sessionsSuccess.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* ######
|
||||||
|
* ######
|
||||||
|
* ############ ####( ###### #####. ###### ############ ############
|
||||||
|
* ############# #####( ###### #####. ###### ############# #############
|
||||||
|
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||||
|
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||||
|
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||||
|
* ############# ############# ############# ############# ##### ######
|
||||||
|
* ############ ############ ############# ############ ##### ######
|
||||||
|
* ######
|
||||||
|
* #############
|
||||||
|
* ############
|
||||||
|
* Adyen NodeJS API Library
|
||||||
|
* Copyright (c) 2020 Adyen B.V.
|
||||||
|
* This file is open source and available under the MIT license.
|
||||||
|
* See the LICENSE file for more info.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
export const sessionsSuccess = JSON.stringify({
|
||||||
|
"amount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 100
|
||||||
|
},
|
||||||
|
"countryCode": "NL",
|
||||||
|
"expiresAt": "2021-10-08T17:28:56+02:00",
|
||||||
|
"id": "CS841C62BF399F968C",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"reference": "YOUR_PAYMENT_REFERENCE",
|
||||||
|
"returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
|
||||||
|
"sessionData": "Ab02b4c0!BQABAgAeRei/Zyr+UYwMcTlHkeYjwn143zTmCmDmWwBg+gZr8us16qqoeVFon6NexiKmZLurm05iRiLagbIIS8BtFzvtX5myx4m0N1vBJWZRDZKHP3g4cyXjEnTnK0CmNsX0bDeojkHU4qChCkn1jIux/rSSp2IIBqe1SfbGVRC9bM17Nj90fJPBxp5MFMw7HKpuvlRNj8CncKPAyPhd4pY+O3GKTiFoZKpx/kVKO7PnILEC07q4rqEzVjSW2U5ADcnR+mJ8V0YVn8Yy4KqNLn68GKMHXe2+NRvidA/UC72F72dOtV1bqxRr/0G6bCW7iuxve+M0IYZ3apHbgS1vWcvUaOI7n1u02M6SWsZDcKgsaT0PoxQkUvdU3ViG7f7Xtac8pjcOxAzhtug/B6Qx/zaTUIWBRKQM5Ga9T7Vo9s9I1Kgv3zuQqeN9OiUhB1mvoxfSPkKYTVjYooj4CELNy9+xuU8/TI+XqK24FIiTacvcJ8Vt0RCSWcE47AG4qiKPBFcBMwpUfz78ud/gu4uBHtt/bh5vJu5GG462tr5W3a/5CeGDX37sqTnrUGom86daTll+kbKo3rC4CH8+K245XNIvIVXLUGrci52lzm09ptPEh/Aj8uBGHLA4Cc0ILAi3rxI5nNcurgbAZiZ7QA3iBEih4euVXBZmKRIfY2U0ijEQLBo8mBDuOjj4GNFT2XrRVs2rwhldAEp7ImtleSI6IkFGMEFBQTEwM0NBNTM3RUFFRDg3QzI0REQ1MzkwOUI4MEE3OEE5MjNFMzgyM0Q2OERBQ0M5NEI5RkY4MzA1REMifWHVSkL3b2GTohsmKmsBVvRtOiDyOWBpV+mylCFs/EQuj7PFJBVjaLoIq1Prk4hZFhBzEf7SsQYHzfTr+BKFH+6fblTW4ObszU3YwF6ehRDaLYxv4sPdVPdguWcuxIvzRenzPlGWu78z6cj1ROHNE3uREUgmVYf9ERbMm8OKJ/uqS1pMPvCYcHIJ0IrXbloQhKaSZdJNmsjGFbfBW8Tr29foxKH280TjbauaZydPWsEuEUIyeWYFBMoozW7de/6RLrDhnQEn/We/6EmsL86QzG+JSkBFloTFo2kdttqA9dfK0l7U3HjtEXmNBFy13DTr5tJcYMz+IcTwe0PqPCgUR+MZDOpAOFc1uHdccok7sttiV4K4xTKkpThiCgrAqklNoD7UcctS5c7RaNQxrwHM5orI0vkGG2hzDXKOUNw4068u"
|
||||||
|
});
|
||||||
233
src/__mocks__/legalEntityManagement/requests.ts
Normal file
233
src/__mocks__/legalEntityManagement/requests.ts
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
|
||||||
|
export const businessLineInfo = {
|
||||||
|
"capability": "issueBankAccount",
|
||||||
|
"industryCode": "55",
|
||||||
|
"webData": [
|
||||||
|
{
|
||||||
|
"webAddress": "https://www.adyen.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"legalEntityId": "LE322KT223222D5FJ7THR293F",
|
||||||
|
"sourceOfFunds": {
|
||||||
|
"type": "business",
|
||||||
|
"adyenProcessedFunds": "false",
|
||||||
|
"description": "Funds from my flower shop business"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const businessLineInfoUpdate = {
|
||||||
|
"capability": "string",
|
||||||
|
"industryCode": "string",
|
||||||
|
"legalEntityId": "string",
|
||||||
|
"salesChannels": ["string"],
|
||||||
|
"sourceOfFunds": {
|
||||||
|
"acquiringBusinessLineId": "string",
|
||||||
|
"adyenProcessedFunds": false,
|
||||||
|
"description": "string",
|
||||||
|
"type": "business"
|
||||||
|
},
|
||||||
|
"webData": [{ "webAddress": "string" }],
|
||||||
|
"webDataExemption": { "reason": "noOnlinePresence" }
|
||||||
|
};
|
||||||
|
|
||||||
|
export const document = {
|
||||||
|
"attachment": {
|
||||||
|
"content": "string",
|
||||||
|
"contentType": "string",
|
||||||
|
"filename": "string",
|
||||||
|
"pageName": "string",
|
||||||
|
"pageType": "string"
|
||||||
|
},
|
||||||
|
"attachments": [{
|
||||||
|
"content": "string",
|
||||||
|
"contentType": "string",
|
||||||
|
"filename": "string",
|
||||||
|
"pageName": "string",
|
||||||
|
"pageType": "string"
|
||||||
|
}],
|
||||||
|
"description": "string",
|
||||||
|
"expiryDate": "string",
|
||||||
|
"fileName": "string",
|
||||||
|
"id": "string",
|
||||||
|
"issuerCountry": "string",
|
||||||
|
"issuerState": "string",
|
||||||
|
"number": "string",
|
||||||
|
"owner": {
|
||||||
|
"id": "string",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": "bankStatement"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const onboardingLinkInfo = {
|
||||||
|
"locale": "cs-CZ",
|
||||||
|
"redirectUrl": "https://your.redirect-url.com",
|
||||||
|
"themeId": "123456789"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const legalEntityInfo = {
|
||||||
|
"type": "individual",
|
||||||
|
"individual": {
|
||||||
|
"residentialAddress": {
|
||||||
|
"city": "San Francisco",
|
||||||
|
"country": "US",
|
||||||
|
"postalCode": "94107",
|
||||||
|
"street": "Brannan Street 274",
|
||||||
|
"stateOrProvince": "CA"
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"countryCode": "US",
|
||||||
|
"number": "5551231234",
|
||||||
|
"type": "mobile"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"firstName": "Simone",
|
||||||
|
"lastName": "Hopper"
|
||||||
|
},
|
||||||
|
"birthData": {
|
||||||
|
"dateOfBirth": "1981-12-01"
|
||||||
|
},
|
||||||
|
"email": "s.hopper@example.com"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const genericEntityInfo = {
|
||||||
|
"entityAssociations": [{
|
||||||
|
"associatorId": "string",
|
||||||
|
"entityType": "string",
|
||||||
|
"jobTitle": "string",
|
||||||
|
"legalEntityId": "string",
|
||||||
|
"name": "string",
|
||||||
|
"type": "signatory"
|
||||||
|
}],
|
||||||
|
"individual": {
|
||||||
|
"birthData": { "dateOfBirth": "string" },
|
||||||
|
"email": "string",
|
||||||
|
"identificationData": {
|
||||||
|
"expiryDate": "string",
|
||||||
|
"issuerCountry": "string",
|
||||||
|
"issuerState": "string",
|
||||||
|
"nationalIdExempt": false,
|
||||||
|
"number": "string",
|
||||||
|
"type": "bankStatement"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"firstName": "string",
|
||||||
|
"infix": "string",
|
||||||
|
"lastName": "string"
|
||||||
|
},
|
||||||
|
"nationality": "string",
|
||||||
|
"phone": {
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"residentialAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"taxInformation": [{
|
||||||
|
"country": "string",
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
}],
|
||||||
|
"webData": { "webAddress": "string" }
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"description": "string",
|
||||||
|
"doingBusinessAs": "string",
|
||||||
|
"email": "string",
|
||||||
|
"legalName": "string",
|
||||||
|
"phone": {
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"principalPlaceOfBusiness": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registeredAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registrationNumber": "string",
|
||||||
|
"stockData": {
|
||||||
|
"marketIdentifier": "string",
|
||||||
|
"stockNumber": "string",
|
||||||
|
"tickerSymbol": "string"
|
||||||
|
},
|
||||||
|
"taxInformation": [{
|
||||||
|
"country": "string",
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
}],
|
||||||
|
"taxReportingClassification": {
|
||||||
|
"businessType": "other",
|
||||||
|
"financialInstitutionNumber": "string",
|
||||||
|
"mainSourceOfIncome": "businessOperation",
|
||||||
|
"type": "nonFinancialNonReportable"
|
||||||
|
},
|
||||||
|
"type": "associationIncorporated",
|
||||||
|
"vatAbsenceReason": "industryExemption",
|
||||||
|
"vatNumber": "string",
|
||||||
|
"webData": { "webAddress": "string" }
|
||||||
|
},
|
||||||
|
"soleProprietorship": {
|
||||||
|
"countryOfGoverningLaw": "string",
|
||||||
|
"doingBusinessAs": "string",
|
||||||
|
"name": "string",
|
||||||
|
"principalPlaceOfBusiness": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registeredAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registrationNumber": "string",
|
||||||
|
"vatAbsenceReason": "industryExemption",
|
||||||
|
"vatNumber": "string"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const transferInstrumentInfo = {
|
||||||
|
"bankAccount": {
|
||||||
|
"accountNumber": "string",
|
||||||
|
"accountType": "string",
|
||||||
|
"bankBicSwift": "string",
|
||||||
|
"bankCity": "string",
|
||||||
|
"bankCode": "string",
|
||||||
|
"bankName": "string",
|
||||||
|
"branchCode": "string",
|
||||||
|
"checkCode": "string",
|
||||||
|
"countryCode": "string",
|
||||||
|
"currencyCode": "string",
|
||||||
|
"iban": "string"
|
||||||
|
},
|
||||||
|
"legalEntityId": "string",
|
||||||
|
"recurringDetail": {
|
||||||
|
"merchantAccount": "string",
|
||||||
|
"reference": "string",
|
||||||
|
"shopperReference": "string"
|
||||||
|
},
|
||||||
|
"type": "bankAccount"
|
||||||
|
};
|
||||||
241
src/__mocks__/legalEntityManagement/responses.ts
Normal file
241
src/__mocks__/legalEntityManagement/responses.ts
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
export const businessLine = {
|
||||||
|
"capability": "receivePayments",
|
||||||
|
"id": "123456789",
|
||||||
|
"industryCode": "123456789",
|
||||||
|
"legalEntityId": "123456789",
|
||||||
|
"salesChannels": ["string"],
|
||||||
|
"sourceOfFunds": {
|
||||||
|
"acquiringBusinessLineId": "string",
|
||||||
|
"adyenProcessedFunds": false,
|
||||||
|
"description": "string",
|
||||||
|
"type": "business"
|
||||||
|
},
|
||||||
|
"webData": [{ "webAddress": "string" }],
|
||||||
|
"webDataExemption": { "reason": "noOnlinePresence" }
|
||||||
|
};
|
||||||
|
|
||||||
|
export const document = {
|
||||||
|
"attachment": {
|
||||||
|
"content": "string",
|
||||||
|
"contentType": "string",
|
||||||
|
"filename": "string",
|
||||||
|
"pageName": "string",
|
||||||
|
"pageType": "string"
|
||||||
|
},
|
||||||
|
"attachments": [{
|
||||||
|
"content": "string",
|
||||||
|
"contentType": "string",
|
||||||
|
"filename": "string",
|
||||||
|
"pageName": "string",
|
||||||
|
"pageType": "string"
|
||||||
|
}],
|
||||||
|
"description": "string",
|
||||||
|
"expiryDate": "string",
|
||||||
|
"fileName": "string",
|
||||||
|
"id": "123456789",
|
||||||
|
"issuerCountry": "string",
|
||||||
|
"issuerState": "string",
|
||||||
|
"number": "string",
|
||||||
|
"owner": {
|
||||||
|
"id": "123456789",
|
||||||
|
"type": "passport"
|
||||||
|
},
|
||||||
|
"type": "driversLicense"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const onboardingLink = { "url": "https://your.redirect-url.com" };
|
||||||
|
|
||||||
|
export const onboardingThemes = {
|
||||||
|
"next": "string",
|
||||||
|
"previous": "string",
|
||||||
|
"themes": [{
|
||||||
|
"createdAt": "2022-10-31T01:30:00.000Z",
|
||||||
|
"description": "string",
|
||||||
|
"id": "123456789",
|
||||||
|
"properties": { "sample": "string" },
|
||||||
|
"updatedAt": "2022-10-31T01:30:00.000Z"
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const onboardingTheme = {
|
||||||
|
"createdAt": "string",
|
||||||
|
"description": "string",
|
||||||
|
"id": "123456789",
|
||||||
|
"properties": { "sample": "string" },
|
||||||
|
"updatedAt": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const legalEntity = {
|
||||||
|
"documentDetails": [{
|
||||||
|
"active": false,
|
||||||
|
"fileName": "string",
|
||||||
|
"id": "string"
|
||||||
|
}],
|
||||||
|
"documents": [{ "id": "string" }],
|
||||||
|
"entityAssociations": [{
|
||||||
|
"associatorId": "string",
|
||||||
|
"entityType": "string",
|
||||||
|
"jobTitle": "string",
|
||||||
|
"legalEntityId": "string",
|
||||||
|
"name": "string",
|
||||||
|
"type": "signatory"
|
||||||
|
}],
|
||||||
|
"id": "123456789",
|
||||||
|
"individual": {
|
||||||
|
"birthData": { "dateOfBirth": "string" },
|
||||||
|
"email": "string",
|
||||||
|
"identificationData": {
|
||||||
|
"expiryDate": "string",
|
||||||
|
"issuerCountry": "string",
|
||||||
|
"issuerState": "string",
|
||||||
|
"nationalIdExempt": false,
|
||||||
|
"number": "string",
|
||||||
|
"type": "bankStatement"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"firstName": "string",
|
||||||
|
"infix": "string",
|
||||||
|
"lastName": "string"
|
||||||
|
},
|
||||||
|
"nationality": "string",
|
||||||
|
"phone": {
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"residentialAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"taxInformation": [{
|
||||||
|
"country": "string",
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
}],
|
||||||
|
"webData": { "webAddress": "string" }
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"description": "string",
|
||||||
|
"doingBusinessAs": "string",
|
||||||
|
"email": "string",
|
||||||
|
"legalName": "string",
|
||||||
|
"phone": {
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"principalPlaceOfBusiness": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registeredAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registrationNumber": "string",
|
||||||
|
"stockData": {
|
||||||
|
"marketIdentifier": "string",
|
||||||
|
"stockNumber": "string",
|
||||||
|
"tickerSymbol": "string"
|
||||||
|
},
|
||||||
|
"taxInformation": [{
|
||||||
|
"country": "string",
|
||||||
|
"number": "string",
|
||||||
|
"type": "string"
|
||||||
|
}],
|
||||||
|
"taxReportingClassification": {
|
||||||
|
"businessType": "other",
|
||||||
|
"financialInstitutionNumber": "string",
|
||||||
|
"mainSourceOfIncome": "businessOperation",
|
||||||
|
"type": "nonFinancialNonReportable"
|
||||||
|
},
|
||||||
|
"type": "associationIncorporated",
|
||||||
|
"vatAbsenceReason": "industryExemption",
|
||||||
|
"vatNumber": "string",
|
||||||
|
"webData": { "webAddress": "string" }
|
||||||
|
},
|
||||||
|
"reference": "string",
|
||||||
|
"soleProprietorship": {
|
||||||
|
"countryOfGoverningLaw": "string",
|
||||||
|
"doingBusinessAs": "string",
|
||||||
|
"name": "string",
|
||||||
|
"principalPlaceOfBusiness": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registeredAddress": {
|
||||||
|
"city": "string",
|
||||||
|
"country": "string",
|
||||||
|
"postalCode": "string",
|
||||||
|
"stateOrProvince": "string",
|
||||||
|
"street": "string",
|
||||||
|
"street2": "string"
|
||||||
|
},
|
||||||
|
"registrationNumber": "string",
|
||||||
|
"vatAbsenceReason": "industryExemption",
|
||||||
|
"vatNumber": "string"
|
||||||
|
},
|
||||||
|
"transferInstruments": [{ "id": "string" }],
|
||||||
|
"type": "individual"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const businessLines = {
|
||||||
|
"businessLines": [{
|
||||||
|
"capability": "receivePayments",
|
||||||
|
"id": "123456789",
|
||||||
|
"industryCode": "123456789",
|
||||||
|
"legalEntityId": "123456789",
|
||||||
|
"salesChannels": ["string"],
|
||||||
|
"sourceOfFunds": {
|
||||||
|
"acquiringBusinessLineId": "string",
|
||||||
|
"adyenProcessedFunds": false,
|
||||||
|
"description": "string",
|
||||||
|
"type": "business"
|
||||||
|
},
|
||||||
|
"webData": [{ "webAddress": "string" }],
|
||||||
|
"webDataExemption": { "reason": "noOnlinePresence" }
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const transferInstrument = {
|
||||||
|
"bankAccount": {
|
||||||
|
"accountNumber": "string",
|
||||||
|
"accountType": "string",
|
||||||
|
"bankBicSwift": "string",
|
||||||
|
"bankCity": "string",
|
||||||
|
"bankCode": "string",
|
||||||
|
"bankName": "string",
|
||||||
|
"branchCode": "string",
|
||||||
|
"checkCode": "string",
|
||||||
|
"countryCode": "string",
|
||||||
|
"currencyCode": "string",
|
||||||
|
"iban": "string"
|
||||||
|
},
|
||||||
|
"documentDetails": [{
|
||||||
|
"active": false,
|
||||||
|
"fileName": "string",
|
||||||
|
"id": "string"
|
||||||
|
}],
|
||||||
|
"id": "123456789",
|
||||||
|
"legalEntityId": "123456789",
|
||||||
|
"recurringDetail": {
|
||||||
|
"merchantAccount": "string",
|
||||||
|
"reference": "string",
|
||||||
|
"shopperReference": "string"
|
||||||
|
},
|
||||||
|
"type": "bankAccount"
|
||||||
|
};
|
||||||
225
src/__mocks__/management/requests.ts
Normal file
225
src/__mocks__/management/requests.ts
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
export const createMerchantRequest = {
|
||||||
|
"companyId": "YOUR_COMPANY_ACCOUNT",
|
||||||
|
"legalEntityId": "YOUR_LEGAL_ENTITY_ID",
|
||||||
|
"businessLineId": "YOUR_BUSINESS_LINE_ID",
|
||||||
|
"description": "YOUR_DESCRIPTION",
|
||||||
|
"reference": "YOUR_OWN_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const allowedOrigin = {
|
||||||
|
"_links": { "self": { "href": "string" } },
|
||||||
|
"domain": "string",
|
||||||
|
"id": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createMerchantApiCredentialRequest = {
|
||||||
|
"roles": [
|
||||||
|
"Checkout webservice role"
|
||||||
|
],
|
||||||
|
"allowedOrigins": [
|
||||||
|
"https://www.mystore.com"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateMerchantApiCredentialRequest = {
|
||||||
|
"active": false,
|
||||||
|
"allowedOrigins": ["string"],
|
||||||
|
"description": "string",
|
||||||
|
"roles": ["string"]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const paymentMethodSetupInfo = {
|
||||||
|
"type": "visa",
|
||||||
|
"currencies": [
|
||||||
|
"USD"
|
||||||
|
],
|
||||||
|
"countries": [
|
||||||
|
"US"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updatePaymentMethodInfo = {
|
||||||
|
"countries": ["string"],
|
||||||
|
"currencies": ["string"],
|
||||||
|
"enabled": false
|
||||||
|
};
|
||||||
|
|
||||||
|
export const payoutSettingsRequest = {
|
||||||
|
"enabled": false,
|
||||||
|
"enabledFromDate": "string",
|
||||||
|
"transferInstrumentId": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updatePayoutSettingsRequest = { "enabled": false };
|
||||||
|
|
||||||
|
export const shippingLocation = {
|
||||||
|
"name": "YOUR_MERCHANT_ACCOUNT Barcelona depot",
|
||||||
|
"address": {
|
||||||
|
"companyName": "YOUR_COMPANY",
|
||||||
|
"streetAddress": "El quinto pino 42",
|
||||||
|
"postalCode": "08012",
|
||||||
|
"city": "Barcelona",
|
||||||
|
"stateOrProvince": "",
|
||||||
|
"country": "ES"
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"firstName": "Rita",
|
||||||
|
"lastName": "Perengano",
|
||||||
|
"phoneNumber": "+34 93 1234567",
|
||||||
|
"email": "Rita.Perengano@company.com"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const terminalOrderRequest = {
|
||||||
|
"shippingLocation": "S2-73536B20665526704F30792642212044452F714622375D477270",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "TBOX-V400m-684-EU",
|
||||||
|
"name": "V400m Package",
|
||||||
|
"quantity": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "PART-287001-EU",
|
||||||
|
"name": "Bluetooth Charging Base - V400m",
|
||||||
|
"quantity": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "PART-620222-EU",
|
||||||
|
"name": "Receipt Roll",
|
||||||
|
"quantity": 20
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const logo = {
|
||||||
|
"data": ""
|
||||||
|
};
|
||||||
|
|
||||||
|
export const terminalSettings = {
|
||||||
|
"wifiProfiles": {
|
||||||
|
"profiles": [
|
||||||
|
{
|
||||||
|
"authType": "wpa-eap",
|
||||||
|
"autoWifi": false,
|
||||||
|
"bssType": "infra",
|
||||||
|
"channel": 0,
|
||||||
|
"defaultProfile": true,
|
||||||
|
"eap": "peap",
|
||||||
|
"eapCaCert": {
|
||||||
|
"data": "MD1rKS05M2JqRVFNQ...RTtLH1tLWo=",
|
||||||
|
"name": "eap-peap-ca.pem"
|
||||||
|
},
|
||||||
|
"eapIdentity": "admin",
|
||||||
|
"eapIntermediateCert": {
|
||||||
|
"data": "PD3tUS1CRDdJTiGDR...EFoLS0tLQg=",
|
||||||
|
"name": "eap-peap-client.pem"
|
||||||
|
},
|
||||||
|
"eapPwd": "EAP_PEAP_PASSWORD",
|
||||||
|
"hiddenSsid": false,
|
||||||
|
"name": "Profile-eap-peap-1",
|
||||||
|
"ssid": "your-network",
|
||||||
|
"wsec": "ccmp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"authType": "wpa-psk",
|
||||||
|
"autoWifi": false,
|
||||||
|
"bssType": "infra",
|
||||||
|
"channel": 0,
|
||||||
|
"defaultProfile": false,
|
||||||
|
"hiddenSsid": false,
|
||||||
|
"name": "Profile-guest-wifi",
|
||||||
|
"psk": "WIFI_PASSWORD",
|
||||||
|
"ssid": "your-network",
|
||||||
|
"wsec": "ccmp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"band": "2.4GHz",
|
||||||
|
"roaming": true,
|
||||||
|
"timeout": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createMerchantUserRequest = {
|
||||||
|
"name": {
|
||||||
|
"firstName": "John",
|
||||||
|
"lastName": "Smith"
|
||||||
|
},
|
||||||
|
"username": "johnsmith",
|
||||||
|
"email": "john.smith@example.com",
|
||||||
|
"timeZoneCode": "Europe/Amsterdam",
|
||||||
|
"roles": [
|
||||||
|
"Merchant standard role"
|
||||||
|
],
|
||||||
|
"associatedMerchantAccounts": [
|
||||||
|
"YOUR_MERCHANT_ACCOUNT"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateMerchantUserRequest = {
|
||||||
|
"accountGroups": ["string"],
|
||||||
|
"active": false,
|
||||||
|
"email": "string",
|
||||||
|
"name": {
|
||||||
|
"firstName": "string",
|
||||||
|
"lastName": "string"
|
||||||
|
},
|
||||||
|
"roles": ["string"],
|
||||||
|
"timeZoneCode": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createMerchantWebhookRequest = {
|
||||||
|
"acceptsExpiredCertificate": false,
|
||||||
|
"acceptsSelfSignedCertificate": false,
|
||||||
|
"acceptsUntrustedRootCertificate": false,
|
||||||
|
"active": false,
|
||||||
|
"additionalSettings": {
|
||||||
|
"includeEventCodes": ["string"],
|
||||||
|
"properties": { "sample": false }
|
||||||
|
},
|
||||||
|
"communicationFormat": "HTTP",
|
||||||
|
"description": "string",
|
||||||
|
"networkType": "LOCAL",
|
||||||
|
"password": "string",
|
||||||
|
"populateSoapActionHeader": false,
|
||||||
|
"sslVersion": "HTTP",
|
||||||
|
"type": "string",
|
||||||
|
"url": "string",
|
||||||
|
"username": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateMerchantWebhookRequest = {
|
||||||
|
"acceptsExpiredCertificate": false,
|
||||||
|
"acceptsSelfSignedCertificate": false,
|
||||||
|
"acceptsUntrustedRootCertificate": false,
|
||||||
|
"active": false,
|
||||||
|
"additionalSettings": {
|
||||||
|
"includeEventCodes": ["string"],
|
||||||
|
"properties": { "sample": false }
|
||||||
|
},
|
||||||
|
"communicationFormat": "HTTP",
|
||||||
|
"description": "string",
|
||||||
|
"networkType": "LOCAL",
|
||||||
|
"password": "string",
|
||||||
|
"populateSoapActionHeader": false,
|
||||||
|
"sslVersion": "HTTP",
|
||||||
|
"url": "string",
|
||||||
|
"username": "string"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const testWebhookRequest = {
|
||||||
|
"notification": {
|
||||||
|
"amount": {
|
||||||
|
"currency": "string",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"eventCode": "string",
|
||||||
|
"eventDate": "string",
|
||||||
|
"merchantReference": "string",
|
||||||
|
"paymentMethod": "string",
|
||||||
|
"reason": "string",
|
||||||
|
"success": false
|
||||||
|
},
|
||||||
|
"types": ["string"]
|
||||||
|
};
|
||||||
1506
src/__mocks__/management/responses.ts
Normal file
1506
src/__mocks__/management/responses.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,8 @@
|
|||||||
"totalFraudScore": "10",
|
"totalFraudScore": "10",
|
||||||
"hmacSignature": "OzDjCMZIsdtDqrZ+cl\/FWC+WdESrorctXTzAzW33dXI=",
|
"hmacSignature": "OzDjCMZIsdtDqrZ+cl\/FWC+WdESrorctXTzAzW33dXI=",
|
||||||
"NAME2": " VALUE2 ",
|
"NAME2": " VALUE2 ",
|
||||||
"fraudCheck-6-ShopperIpUsage": "10"
|
"fraudCheck-6-ShopperIpUsage": "10",
|
||||||
|
"paymentLinkId": "ABCDEFG"
|
||||||
},
|
},
|
||||||
"amount": {
|
"amount": {
|
||||||
"currency": "EUR",
|
"currency": "EUR",
|
||||||
|
|||||||
@@ -18,54 +18,60 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const listRecurringDetailsSuccess = {
|
export const listRecurringDetailsSuccess = {
|
||||||
creationDate: "2017-03-01T10:53:11.000",
|
"creationDate": "2017-03-01T11:53:11+01:00",
|
||||||
details: [
|
"details": [
|
||||||
{
|
{
|
||||||
additionalData: {
|
"acquirer": "TestPmmAcquirer",
|
||||||
cardBin: "411111",
|
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||||
|
"additionalData": {
|
||||||
|
"cardBin": "411111"
|
||||||
},
|
},
|
||||||
alias: "cardAlias",
|
"alias": "cardAlias",
|
||||||
aliasType: "Default",
|
"aliasType": "Default",
|
||||||
card: {
|
"card": {
|
||||||
expiryMonth: "8",
|
"expiryMonth": "8",
|
||||||
expiryYear: "2018",
|
"expiryYear": "2018",
|
||||||
holderName: "Holder",
|
"holderName": "Holder",
|
||||||
number: "1111",
|
"number": "1111"
|
||||||
},
|
},
|
||||||
contractTypes: [
|
"contractTypes": [
|
||||||
"ONECLICK",
|
"ONECLICK"
|
||||||
],
|
],
|
||||||
creationDate: "2017-03-01T10:53:11.000",
|
"creationDate": "2017-03-07T09:43:33+01:00",
|
||||||
firstPspReference: "8524888762135795",
|
"firstPspReference": "8524888762135795",
|
||||||
paymentMethodVariant: "visa",
|
"paymentMethodVariant": "visa",
|
||||||
recurringDetailReference: "recurringReference",
|
"recurringDetailReference": "recurringReference",
|
||||||
variant: "visa",
|
"variant": "visa"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
billingAddress: {
|
"acquirer": "PayPalSandbox",
|
||||||
city: "City",
|
"acquirerAccount": "TestPmmAcquirerAccount",
|
||||||
country: "NL",
|
"billingAddress": {
|
||||||
houseNumberOrName: "1",
|
"city": "City",
|
||||||
postalCode: "2312aa",
|
"country": "NL",
|
||||||
stateOrProvince: "NA",
|
"houseNumberOrName": "1",
|
||||||
street: "Street",
|
"postalCode": "2312aa",
|
||||||
|
"stateOrProvince": "NA",
|
||||||
|
"street": "Street"
|
||||||
},
|
},
|
||||||
contractTypes: [
|
"contractTypes": [
|
||||||
"RECURRING",
|
"RECURRING"
|
||||||
],
|
],
|
||||||
creationDate: "2017-03-01T10:53:11.000",
|
"creationDate": "2017-10-10T08:50:02+02:00",
|
||||||
firstPspReference: "8515076181707110",
|
"firstPspReference": "8515076181707110",
|
||||||
paymentMethodVariant: "paypal",
|
"paymentMethodVariant": "paypal",
|
||||||
recurringDetailReference: "8315076181982020",
|
"recurringDetailReference": "8315076181982020",
|
||||||
tokenDetails: {
|
"tokenDetails": {
|
||||||
tokenData: {
|
"tokenData": {
|
||||||
"BillingAgreementId": "B-7MA42752FE774625C",
|
|
||||||
"EmailId": "tedtest@test.nl",
|
"EmailId": "tedtest@test.nl",
|
||||||
"PayPal.PayerId": "H95EPL8B2KFE6",
|
"PayPal.PayerId": "H95EPL8B2KFE6",
|
||||||
|
"BillingAgreementId": "B-7MA42752FE774625C"
|
||||||
},
|
},
|
||||||
tokenDataType: "PayPal",
|
"tokenDataType": "PayPal"
|
||||||
},
|
},
|
||||||
variant: "paypal",
|
"variant": "paypal"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
|
"shopperReference": "test-123",
|
||||||
|
"invalidOneclickContracts": "false"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -365,3 +365,24 @@ export const syncRefund = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const syncResEventNotification = {
|
||||||
|
SaleToPOIRequest: {
|
||||||
|
EventNotification: {
|
||||||
|
EventToNotify: "Reject",
|
||||||
|
EventDetails: "message=Did+not+receive+a+response+from+the+POI.",
|
||||||
|
RejectedMessage: "ewoi...0KfQo=",
|
||||||
|
TimeStamp: "2020-03-31T10:28:39.515Z"
|
||||||
|
},
|
||||||
|
MessageHeader: {
|
||||||
|
DeviceID: "666568147",
|
||||||
|
MessageCategory: "Event",
|
||||||
|
MessageClass: "Event",
|
||||||
|
MessageType: "Notification",
|
||||||
|
POIID: "P400Plus-123456789",
|
||||||
|
ProtocolVersion: "3.0",
|
||||||
|
SaleID: "saleid-4c32759faaa7",
|
||||||
|
ServiceID: "31122609"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
135
src/__mocks__/transfers/responses.ts
Normal file
135
src/__mocks__/transfers/responses.ts
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
export const transfersSuccess = {
|
||||||
|
"id" : "1W1UG35U8A9J5ZLG",
|
||||||
|
"amount" : {
|
||||||
|
"value" : 110000,
|
||||||
|
"currency" : "EUR"
|
||||||
|
},
|
||||||
|
"balanceAccountId" : "BAB8B2C3D4E5F6G7H8D9J6GD4",
|
||||||
|
"category" : "bank",
|
||||||
|
"counterparty" : {
|
||||||
|
"accountHolder" : {
|
||||||
|
"fullName" : "A. Klaassen",
|
||||||
|
"address" : {
|
||||||
|
"city" : "San Francisco",
|
||||||
|
"country" : "US",
|
||||||
|
"postalCode" : "94678",
|
||||||
|
"stateOrProvince" : "CA",
|
||||||
|
"street" : "Brannan Street",
|
||||||
|
"street2" : "274"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"accountIdentification" : {
|
||||||
|
"type" : "numberBic",
|
||||||
|
"accountNumber" : "123456789",
|
||||||
|
"bic" : "BOFAUS3NXXX"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"priority" : "wire",
|
||||||
|
"referenceForBeneficiary" : "Your reference sent to the beneficiary",
|
||||||
|
"reference" : "Your internal reference for the transfer",
|
||||||
|
"description" : "Your description for the transfer",
|
||||||
|
"direction" : "outgoing",
|
||||||
|
"reason" : "approved",
|
||||||
|
"status" : "authorised"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTransactionSuccess = {
|
||||||
|
"accountHolderId" : "AHA1B2C3D4E5F6G7H8I9J0",
|
||||||
|
"amount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : 9887
|
||||||
|
},
|
||||||
|
"balanceAccountId" : "BAB8B2C3D4E5F6G7H8D9J6GD4",
|
||||||
|
"balancePlatform" : "YOUR_BALANCE_PLATFORM",
|
||||||
|
"bookingDate" : "2022-03-14T12:01:00+01:00",
|
||||||
|
"category" : "bank",
|
||||||
|
"counterparty" : {
|
||||||
|
"balanceAccountId" : "NL29ADYX0000000001"
|
||||||
|
},
|
||||||
|
"createdAt" : "2022-03-14T12:01:00+01:00",
|
||||||
|
"description" : "YOUR_DESCRIPTION",
|
||||||
|
"id" : "IZK7C25U7DYVX03Y",
|
||||||
|
"instructedAmount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : 9887
|
||||||
|
},
|
||||||
|
"reference" : "2L6C6B5U7DYULLXC",
|
||||||
|
"referenceForBeneficiary" : "YOUR_REFERENCE_FOR_BENEFICIARY",
|
||||||
|
"status" : "booked",
|
||||||
|
"transferId" : "2QP32A5U7IWC5WKG",
|
||||||
|
"type" : "bankTransfer",
|
||||||
|
"valueDate" : "2022-03-14T12:01:00+01:00"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const listTransactionsSuccess = {
|
||||||
|
"data" : [
|
||||||
|
{
|
||||||
|
"accountHolderId" : "AHA1B2C3D4E5F6G7H8I9J0",
|
||||||
|
"amount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -9
|
||||||
|
},
|
||||||
|
"balanceAccountId" : "BAB8B2C3D4E5F6G7H8D9J6GD4",
|
||||||
|
"balancePlatform" : "YOUR_BALANCE_PLATFORM",
|
||||||
|
"bookingDate" : "2022-03-11T11:21:24+01:00",
|
||||||
|
"category" : "internal",
|
||||||
|
"createdAt" : "2022-03-11T11:21:24+01:00",
|
||||||
|
"id" : "1VVF0D5U66PIUIVP",
|
||||||
|
"instructedAmount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -9
|
||||||
|
},
|
||||||
|
"reference" : "REFERENCE_46e8c40e",
|
||||||
|
"status" : "booked",
|
||||||
|
"transferId" : "1VVF0D5U66PIUIVP",
|
||||||
|
"type" : "fee",
|
||||||
|
"valueDate" : "2022-03-11T11:21:24+01:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accountHolderId" : "AHA1B2C3D4E5F6G7H8I9J0",
|
||||||
|
"amount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -46
|
||||||
|
},
|
||||||
|
"balanceAccountId" : "BAB8B2C3D4E5F6G7H8D9J6GD4",
|
||||||
|
"balancePlatform" : "YOUR_BALANCE_PLATFORM",
|
||||||
|
"bookingDate" : "2022-03-12T14:22:52+01:00",
|
||||||
|
"category" : "internal",
|
||||||
|
"createdAt" : "2022-03-12T14:22:52+01:00",
|
||||||
|
"id" : "1WEPGD5U6MS1CFK3",
|
||||||
|
"instructedAmount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -46
|
||||||
|
},
|
||||||
|
"reference" : "YOUR_REFERENCE",
|
||||||
|
"status" : "booked",
|
||||||
|
"transferId" : "1WEPGD5U6MS1CFK3",
|
||||||
|
"type" : "fee",
|
||||||
|
"valueDate" : "2022-03-12T14:22:52+01:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accountHolderId" : "AHA1B2C3D4E5F6G7H8I9J0",
|
||||||
|
"amount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -8
|
||||||
|
},
|
||||||
|
"balanceAccountId" : "BAB8B2C3D4E5F6G7H8D9J6GD4",
|
||||||
|
"balancePlatform" : "YOUR_BALANCE_PLATFORM",
|
||||||
|
"bookingDate" : "2022-03-14T21:00:48+01:00",
|
||||||
|
"createdAt" : "2022-03-14T15:00:00+01:00",
|
||||||
|
"description" : "YOUR_DESCRIPTION_2",
|
||||||
|
"id" : "2QP32A5U7IWC5WKG",
|
||||||
|
"instructedAmount" : {
|
||||||
|
"currency" : "EUR",
|
||||||
|
"value" : -8
|
||||||
|
},
|
||||||
|
"status" : "booked",
|
||||||
|
"valueDate" : "2022-03-14T21:00:48+01:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_links" : {
|
||||||
|
"next" : {
|
||||||
|
"href" : "https://balanceplatform-api-test.adyen.com/btl/v2/transactions?balancePlatform=Bastronaut&createdUntil=2022-03-21T00%3A00%3A00Z&createdSince=2022-03-11T00%3A00%3A00Z&limit=3&cursor=S2B-TSAjOkIrYlIlbjdqe0RreHRyM32lKRSxubXBHRkhHL2E32XitQQz5SfzpucD5HbHwpM1p6NDR1eXVQLFF6MmY33J32sobDxQYT90MHIud1hwLnd6JitcX32xJ"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
894
src/__tests__/balancePlatform.spec.ts
Normal file
894
src/__tests__/balancePlatform.spec.ts
Normal file
@@ -0,0 +1,894 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import Client from "../client";
|
||||||
|
import { createClient } from "../__mocks__/base";
|
||||||
|
import BalancePlatform from "../services/balancePlatform";
|
||||||
|
import { balancePlatform } from "../typings";
|
||||||
|
import { AccountHolderUpdate } from "../services/balancePlaftform/accountHolders";
|
||||||
|
import { SweepConfigurationV2Create, SweepConfigurationV2Update } from "../services/balancePlaftform/balanceAccounts";
|
||||||
|
import { TransactionRuleInfoUpdate } from "../services/balancePlaftform/transactionRules";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let balancePlatformService: BalancePlatform;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.balancePlatformEndpoint}/${Client.BALANCE_PLATFORM_API_VERSION}`);
|
||||||
|
balancePlatformService = new BalancePlatform(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Balance Platform", (): void => {
|
||||||
|
const balanceAccountId = "BA32272223222B59CZ3T52DKZ";
|
||||||
|
const sweepId = "SWPC4227C224555B5FTD2NT2JV4WN5";
|
||||||
|
const paymentInstrumentId = "PI32272223222B5CMD3MQ3HXX";
|
||||||
|
const paymentInstrumentGroupId = "PG3227C223222B5CMD3FJFKGZ";
|
||||||
|
const transactionRuleId = "TR3227C223222B5FCB756DV9H";
|
||||||
|
|
||||||
|
describe("AccountHolders", (): void => {
|
||||||
|
it("should support POST /accountHolders", async (): Promise<void> => {
|
||||||
|
scope.post("/accountHolders")
|
||||||
|
.reply(200, {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"contactDetails": {
|
||||||
|
"email": "s.hopper@example.com",
|
||||||
|
"phone": {
|
||||||
|
"number": "+315551231234",
|
||||||
|
"type": "Mobile"
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"street": "Brannan Street",
|
||||||
|
"houseNumberOrName": "274",
|
||||||
|
"postalCode": "1020CD"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "S.Hopper - Staff 123",
|
||||||
|
"legalEntityId": "LE322KT223222D5FJ7THR293F",
|
||||||
|
"id": "AH3227C223222B5CMD2SXFKGT",
|
||||||
|
"status": "active"
|
||||||
|
});
|
||||||
|
const request: balancePlatform.AccountHolderInfo = {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"description": "S.Hopper - Staff 123",
|
||||||
|
"legalEntityId": "LE322KT223222D5FJ7THR293F",
|
||||||
|
"contactDetails": {
|
||||||
|
"email": "s.hopper@example.com",
|
||||||
|
"phone": {
|
||||||
|
"number": "+315551231234",
|
||||||
|
"type": balancePlatform.Phone.TypeEnum.Mobile
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"street": "Brannan Street",
|
||||||
|
"houseNumberOrName": "274",
|
||||||
|
"postalCode": "1020CD"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe("AH3227C223222B5CMD2SXFKGT");
|
||||||
|
expect(response.legalEntityId).toBe("LE322KT223222D5FJ7THR293F");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /accountHolders/{id}", async (): Promise<void> => {
|
||||||
|
scope.get("/accountHolders/AH32272223222B5CM4MWJ892H")
|
||||||
|
.reply(200, {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"contactDetails": {
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"houseNumberOrName": "274",
|
||||||
|
"postalCode": "1020CD",
|
||||||
|
"street": "Brannan Street"
|
||||||
|
},
|
||||||
|
"email": "s.hopper@example.com",
|
||||||
|
"phone": {
|
||||||
|
"number": "+315551231234",
|
||||||
|
"type": "Mobile"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "S.Hopper - Staff 123",
|
||||||
|
"id": "AH32272223222B5CM4MWJ892H",
|
||||||
|
"status": "Active"
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.retrieve("AH32272223222B5CM4MWJ892H");
|
||||||
|
|
||||||
|
expect(response.id).toBe("AH32272223222B5CM4MWJ892H");
|
||||||
|
expect(response.balancePlatform).toBe("YOUR_BALANCE_PLATFORM");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /accountHolders/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch("/accountHolders/AH32272223222B5CM4MWJ892H")
|
||||||
|
.reply(200, {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"contactDetails": {
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"houseNumberOrName": "274",
|
||||||
|
"postalCode": "1020CD",
|
||||||
|
"street": "Brannan Street"
|
||||||
|
},
|
||||||
|
"email": "s.hopper@example.com",
|
||||||
|
"phone": {
|
||||||
|
"number": "+315551231234",
|
||||||
|
"type": "Mobile"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "S.Hopper - Staff 123",
|
||||||
|
"id": "AH32272223222B5CM4MWJ892H",
|
||||||
|
"status": "Suspended"
|
||||||
|
});
|
||||||
|
const request: AccountHolderUpdate = {
|
||||||
|
status: balancePlatform.AccountHolder.StatusEnum.Suspended,
|
||||||
|
legalEntityId: "LE322KT223222D5FJ7THR293F",
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.update("AH32272223222B5CM4MWJ892H", request);
|
||||||
|
|
||||||
|
expect(response.status).toBe("Suspended");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /accountHolders/{id}/balanceAccounts", async (): Promise<void> => {
|
||||||
|
scope.get("/accountHolders/AH32272223222B5CM4MWJ892H/balanceAccounts?limit=5&offset=10")
|
||||||
|
.reply(200, {
|
||||||
|
"balanceAccounts": [
|
||||||
|
{
|
||||||
|
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||||
|
"defaultCurrencyCode": "EUR",
|
||||||
|
"id": "BA32272223222B59K6ZXHBFN6",
|
||||||
|
"status": "Active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||||
|
"defaultCurrencyCode": "EUR",
|
||||||
|
"id": "BA32272223222B59K72CKBFNJ",
|
||||||
|
"status": "Active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||||
|
"defaultCurrencyCode": "EUR",
|
||||||
|
"id": "BA32272223222B5BRR27B2M7G",
|
||||||
|
"status": "Active"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hasNext": true,
|
||||||
|
"hasPrevious": false
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.PaginatedBalanceAccountsResponse = await balancePlatformService.AccountHolders.listBalanceAccounts("AH32272223222B5CM4MWJ892H", {
|
||||||
|
params: {
|
||||||
|
"limit": "5",
|
||||||
|
"offset": "10"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.balanceAccounts[0].id).toBe("BA32272223222B59K6ZXHBFN6");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("BalanceAccounts", (): void => {
|
||||||
|
it("should support POST /balanceAccounts", async (): Promise<void> => {
|
||||||
|
scope.post("/balanceAccounts")
|
||||||
|
.reply(200, {
|
||||||
|
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||||
|
"defaultCurrencyCode": "EUR",
|
||||||
|
"reference": "S.Hopper - Main balance account",
|
||||||
|
"balances": [
|
||||||
|
{
|
||||||
|
"available": 0,
|
||||||
|
"balance": 0,
|
||||||
|
"currency": "EUR",
|
||||||
|
"reserved": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": balanceAccountId,
|
||||||
|
"status": "active"
|
||||||
|
});
|
||||||
|
const request: balancePlatform.BalanceAccountInfo = {
|
||||||
|
"accountHolderId": "AH32272223222B59K6ZKBBFNQ",
|
||||||
|
"description": "S.Hopper - Main balance account"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(balanceAccountId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /balanceAccounts/{balanceAccountId}/sweeps", async (): Promise<void> => {
|
||||||
|
scope.get(`/balanceAccounts/${balanceAccountId}/sweeps?limit=5&offset=10`)
|
||||||
|
.reply(200, {
|
||||||
|
"hasNext": false,
|
||||||
|
"hasPrevious": false,
|
||||||
|
"sweeps": [
|
||||||
|
{
|
||||||
|
"id": sweepId,
|
||||||
|
"schedule": {
|
||||||
|
"type": "daily"
|
||||||
|
},
|
||||||
|
"status": "active",
|
||||||
|
"targetAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"triggerAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"type": "push",
|
||||||
|
"counterparty": {
|
||||||
|
"balanceAccountId": "BA32272223222B5FTD2KR6TJD"
|
||||||
|
},
|
||||||
|
"currency": "EUR"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.BalanceSweepConfigurationsResponse = await balancePlatformService.BalanceAccounts.listSweeps(balanceAccountId, {
|
||||||
|
params: {
|
||||||
|
"limit": "5",
|
||||||
|
"offset": "10"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.hasNext).toBeFalsy();
|
||||||
|
expect(response.sweeps.length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /balanceAccounts/{balanceAccountId}/sweeps", async (): Promise<void> => {
|
||||||
|
scope.post(`/balanceAccounts/${balanceAccountId}/sweeps`)
|
||||||
|
.reply(200, {
|
||||||
|
"id": sweepId,
|
||||||
|
"counterparty": {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
},
|
||||||
|
"triggerAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 50000
|
||||||
|
},
|
||||||
|
"currency": "EUR",
|
||||||
|
"schedule": {
|
||||||
|
"type": "balance"
|
||||||
|
},
|
||||||
|
"type": "pull",
|
||||||
|
"status": "active"
|
||||||
|
});
|
||||||
|
const request: SweepConfigurationV2Create = {
|
||||||
|
"counterparty": {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
},
|
||||||
|
"triggerAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 50000
|
||||||
|
},
|
||||||
|
"currency": "EUR",
|
||||||
|
"schedule": {
|
||||||
|
"type": balancePlatform.SweepSchedule.TypeEnum.Balance
|
||||||
|
},
|
||||||
|
"type": balancePlatform.SweepConfigurationV2.TypeEnum.Pull,
|
||||||
|
"status": balancePlatform.SweepConfigurationV2.StatusEnum.Active
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.createSweep(balanceAccountId, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(sweepId);
|
||||||
|
expect(response.triggerAmount!.value).toBe(50000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`).reply(204);
|
||||||
|
|
||||||
|
await balancePlatformService.BalanceAccounts.deleteSweep(balanceAccountId, sweepId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"id": sweepId,
|
||||||
|
"schedule": {
|
||||||
|
"type": "daily"
|
||||||
|
},
|
||||||
|
"status": "active",
|
||||||
|
"targetAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"triggerAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"type": "push",
|
||||||
|
"counterparty": {
|
||||||
|
"balanceAccountId": "BA32272223222B5FTD2KR6TJD"
|
||||||
|
},
|
||||||
|
"currency": "EUR"
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.retrieveSweep(balanceAccountId, sweepId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(sweepId);
|
||||||
|
expect(response.status).toBe("active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"id": sweepId,
|
||||||
|
"counterparty": {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
},
|
||||||
|
"triggerAmount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 50000
|
||||||
|
},
|
||||||
|
"currency": "EUR",
|
||||||
|
"schedule": {
|
||||||
|
"type": "balance"
|
||||||
|
},
|
||||||
|
"type": "pull",
|
||||||
|
"status": "inactive"
|
||||||
|
});
|
||||||
|
const request: SweepConfigurationV2Update = {
|
||||||
|
"status": balancePlatform.SweepConfigurationV2.StatusEnum.Inactive
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.updateSweep(balanceAccountId, sweepId, request);
|
||||||
|
|
||||||
|
expect(response.status).toBe("inactive");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /balanceAccounts/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/balanceAccounts/${balanceAccountId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"accountHolderId": "AH32272223222B59K6RTQBFNZ",
|
||||||
|
"defaultCurrencyCode": "EUR",
|
||||||
|
"balances": [
|
||||||
|
{
|
||||||
|
"available": 0,
|
||||||
|
"balance": 0,
|
||||||
|
"currency": "EUR",
|
||||||
|
"reserved": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": balanceAccountId,
|
||||||
|
"status": "Active"
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.retrieve(balanceAccountId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(balanceAccountId);
|
||||||
|
expect(response.status).toBe("Active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /balanceAccounts/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/balanceAccounts/${balanceAccountId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"accountHolderId": "string",
|
||||||
|
"balances": [
|
||||||
|
{
|
||||||
|
"available": 0,
|
||||||
|
"balance": 0,
|
||||||
|
"currency": "string",
|
||||||
|
"reserved": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaultCurrencyCode": "string",
|
||||||
|
"description": "Testing",
|
||||||
|
"id": "string",
|
||||||
|
"reference": "string",
|
||||||
|
"status": "active",
|
||||||
|
"timeZone": "Europe/Amsterdam"
|
||||||
|
});
|
||||||
|
const request: balancePlatform.BalanceAccountUpdateRequest = {
|
||||||
|
"description": "Testing",
|
||||||
|
"status": balancePlatform.BalanceAccountUpdateRequest.StatusEnum.Active,
|
||||||
|
"timeZone": "Europe/Amsterdam"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.update(balanceAccountId, request);
|
||||||
|
|
||||||
|
expect(response.status).toBe("active");
|
||||||
|
expect(response.timeZone).toBe("Europe/Amsterdam");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /balanceAccounts/{id}/paymentInstruments", async (): Promise<void> => {
|
||||||
|
scope.get(`/balanceAccounts/${balanceAccountId}/paymentInstruments?limit=3&offset=6`)
|
||||||
|
.reply(200, {
|
||||||
|
"hasNext": "true",
|
||||||
|
"hasPrevious": "false",
|
||||||
|
"paymentInstruments": [
|
||||||
|
{
|
||||||
|
"balanceAccountId": balanceAccountId,
|
||||||
|
"issuingCountryCode": "GB",
|
||||||
|
"status": "Active",
|
||||||
|
"type": "card",
|
||||||
|
"card": {
|
||||||
|
"brandVariant": "mc",
|
||||||
|
"cardholderName": "name",
|
||||||
|
"formFactor": "virtual",
|
||||||
|
"bin": "555544",
|
||||||
|
"expiration": {
|
||||||
|
"month": "12",
|
||||||
|
"year": "2022"
|
||||||
|
},
|
||||||
|
"lastFour": "2357",
|
||||||
|
"number": "************2357"
|
||||||
|
},
|
||||||
|
"id": "PI32272223222B59M5TM658DT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"balanceAccountId": balanceAccountId,
|
||||||
|
"issuingCountryCode": "GB",
|
||||||
|
"status": "Active",
|
||||||
|
"type": "card",
|
||||||
|
"card": {
|
||||||
|
"brandVariant": "mc",
|
||||||
|
"cardholderName": "name",
|
||||||
|
"formFactor": "virtual",
|
||||||
|
"bin": "555544",
|
||||||
|
"expiration": {
|
||||||
|
"month": "01",
|
||||||
|
"year": "2023"
|
||||||
|
},
|
||||||
|
"lastFour": "8331",
|
||||||
|
"number": "************8331"
|
||||||
|
},
|
||||||
|
"id": "PI32272223222B59PXDGQDLSF"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.PaginatedPaymentInstrumentsResponse = await balancePlatformService.BalanceAccounts.listPaymentInstruments(balanceAccountId, {
|
||||||
|
params: {
|
||||||
|
limit: "3",
|
||||||
|
offset: "6",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.paymentInstruments.length).toBe(2);
|
||||||
|
expect(response.paymentInstruments[0].id).toBe("PI32272223222B59M5TM658DT");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("General", (): void => {
|
||||||
|
it("should support GET /balancePlatforms/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/balancePlatforms/${balanceAccountId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"id": balanceAccountId,
|
||||||
|
"status": "Active"
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.BalancePlatform = await balancePlatformService.General.retrieve(balanceAccountId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(balanceAccountId);
|
||||||
|
expect(response.status).toBe("Active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /balancePlatforms/{id}/accountHolders", async (): Promise<void> => {
|
||||||
|
scope.get(`/balancePlatforms/${balanceAccountId}/accountHolders`)
|
||||||
|
.reply(200, {
|
||||||
|
"accountHolders": [
|
||||||
|
{
|
||||||
|
"contactDetails": {
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"houseNumberOrName": "6",
|
||||||
|
"postalCode": "12336750",
|
||||||
|
"street": "Simon Carmiggeltstraat"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "J. Doe",
|
||||||
|
"id": "AH32272223222B59DDWSCCMP7",
|
||||||
|
"status": "Active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contactDetails": {
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"houseNumberOrName": "11",
|
||||||
|
"postalCode": "12336750",
|
||||||
|
"street": "Simon Carmiggeltstraat"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "S. Hopper",
|
||||||
|
"id": "AH32272223222B59DJ7QBCMPN",
|
||||||
|
"status": "Active"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hasNext": "true",
|
||||||
|
"hasPrevious": "false"
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.PaginatedAccountHoldersResponse = await balancePlatformService.General.listAccountHolders(balanceAccountId);
|
||||||
|
|
||||||
|
expect(response.accountHolders.length).toBe(2);
|
||||||
|
expect(response.accountHolders[0].id).toBe("AH32272223222B59DDWSCCMP7");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("PaymentInstruments", (): void => {
|
||||||
|
it("should support POST /paymentInstruments", async (): Promise<void> => {
|
||||||
|
scope.post("/paymentInstruments")
|
||||||
|
.reply(200, {
|
||||||
|
"balanceAccountId": balanceAccountId,
|
||||||
|
"description": "S. Hopper - Main card",
|
||||||
|
"issuingCountryCode": "GB",
|
||||||
|
"status": "Active",
|
||||||
|
"type": "card",
|
||||||
|
"card": {
|
||||||
|
"brand": "mc",
|
||||||
|
"brandVariant": "mcdebit",
|
||||||
|
"cardholderName": "Simon Hopper",
|
||||||
|
"formFactor": "virtual",
|
||||||
|
"bin": "555544",
|
||||||
|
"cvc": "873",
|
||||||
|
"expiration": {
|
||||||
|
"month": "01",
|
||||||
|
"year": "2024"
|
||||||
|
},
|
||||||
|
"lastFour": "3548"
|
||||||
|
},
|
||||||
|
"id": paymentInstrumentId
|
||||||
|
});
|
||||||
|
const request: balancePlatform.PaymentInstrumentInfo = {
|
||||||
|
"type": balancePlatform.PaymentInstrumentInfo.TypeEnum.Card,
|
||||||
|
"issuingCountryCode": "NL",
|
||||||
|
"balanceAccountId": balanceAccountId,
|
||||||
|
"status": balancePlatform.PaymentInstrumentInfo.StatusEnum.Inactive,
|
||||||
|
"card": {
|
||||||
|
"formFactor": balancePlatform.CardInfo.FormFactorEnum.Physical,
|
||||||
|
"brand": "mc",
|
||||||
|
"brandVariant": "mcdebit",
|
||||||
|
"cardholderName": "Sam Hopper",
|
||||||
|
"deliveryContact": {
|
||||||
|
"address": {
|
||||||
|
"city": "Amsterdam",
|
||||||
|
"country": "NL",
|
||||||
|
"stateOrProvince": "NH",
|
||||||
|
"line1": "Simon Carmiggeltstraat",
|
||||||
|
"line2": "6-50",
|
||||||
|
"postalCode": "1011DJ"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"firstName": "Sam",
|
||||||
|
"lastName": "Hopper"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"configuration": {
|
||||||
|
"configurationProfileId": "YOUR_CONFIGURATION_PROFILE_ID"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"description": "S.Hopper - Main card"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(paymentInstrumentId);
|
||||||
|
expect(response.balanceAccountId).toBe(balanceAccountId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /paymentInstruments/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/paymentInstruments/${paymentInstrumentId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"balanceAccountId": balanceAccountId,
|
||||||
|
"description": "S. Hopper - Main card",
|
||||||
|
"issuingCountryCode": "GB",
|
||||||
|
"status": "active",
|
||||||
|
"type": "card",
|
||||||
|
"card": {
|
||||||
|
"brand": "mc",
|
||||||
|
"brandVariant": "mcdebit",
|
||||||
|
"cardholderName": "Simon Hopper",
|
||||||
|
"formFactor": "virtual",
|
||||||
|
"bin": "555544",
|
||||||
|
"expiration": {
|
||||||
|
"month": "01",
|
||||||
|
"year": "2024"
|
||||||
|
},
|
||||||
|
"lastFour": "3548",
|
||||||
|
"number": "************3548"
|
||||||
|
},
|
||||||
|
"id": paymentInstrumentId
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.retrieve(paymentInstrumentId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(paymentInstrumentId);
|
||||||
|
expect(response.status).toBe("active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /paymentInstruments/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/paymentInstruments/${paymentInstrumentId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"balanceAccountId": "BA32272223222B5CM82WL892M",
|
||||||
|
"description": "S. Hopper - Main card",
|
||||||
|
"issuingCountryCode": "GB",
|
||||||
|
"status": "inactive",
|
||||||
|
"type": "card",
|
||||||
|
"card": {
|
||||||
|
"brand": "mc",
|
||||||
|
"brandVariant": "mcdebit",
|
||||||
|
"cardholderName": "Simon Hopper",
|
||||||
|
"formFactor": "virtual",
|
||||||
|
"bin": "555544",
|
||||||
|
"expiration": {
|
||||||
|
"month": "01",
|
||||||
|
"year": "2024"
|
||||||
|
},
|
||||||
|
"lastFour": "5785",
|
||||||
|
"number": "************5785"
|
||||||
|
},
|
||||||
|
"id": paymentInstrumentId
|
||||||
|
});
|
||||||
|
const request: balancePlatform.PaymentInstrumentUpdateRequest = {
|
||||||
|
"balanceAccountId": "BA32272223222B5CM82WL892M"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.update(paymentInstrumentId, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(paymentInstrumentId);
|
||||||
|
expect(response.balanceAccountId).toBe("BA32272223222B5CM82WL892M");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /paymentInstruments/{id}/transactionRules", async (): Promise<void> => {
|
||||||
|
scope.get(`/paymentInstruments/${paymentInstrumentId}/transactionRules`)
|
||||||
|
.reply(200, {
|
||||||
|
"transactionRules": [
|
||||||
|
{
|
||||||
|
"description": "Allow 5 transactions per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"maxTransactions": 5,
|
||||||
|
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||||
|
"reference": "myRule12345",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"status": "active",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": "TR32272223222B5CMDGMC9F4F"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 10000
|
||||||
|
},
|
||||||
|
"description": "Allow up to 100 EUR per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||||
|
"reference": "myRule16378",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"status": "active",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": "TR32272223222B5CMDGT89F4F"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRulesResponse = await balancePlatformService.PaymentInstruments.listTransactionRules(paymentInstrumentId);
|
||||||
|
|
||||||
|
expect(response.transactionRules!.length).toBe(2);
|
||||||
|
expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("PaymentInstrumentGroups", (): void => {
|
||||||
|
it("should support POST /paymentInstrumentGroups", async (): Promise<void> => {
|
||||||
|
scope.post("/paymentInstrumentGroups")
|
||||||
|
.reply(200, {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"txVariant": "mc",
|
||||||
|
"id": paymentInstrumentGroupId
|
||||||
|
});
|
||||||
|
const request: balancePlatform.PaymentInstrumentGroupInfo = {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"txVariant": "mc"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.PaymentInstrumentGroup = await balancePlatformService.PaymentInstrumentGroups.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(paymentInstrumentGroupId);
|
||||||
|
expect(response.txVariant).toBe("mc");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /paymentInstrumentGroups/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/paymentInstrumentGroups/${paymentInstrumentGroupId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"balancePlatform": "YOUR_BALANCE_PLATFORM",
|
||||||
|
"txVariant": "mc",
|
||||||
|
"id": paymentInstrumentGroupId
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.PaymentInstrumentGroup = await balancePlatformService.PaymentInstrumentGroups.retrieve(paymentInstrumentGroupId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(paymentInstrumentGroupId);
|
||||||
|
expect(response.txVariant).toBe("mc");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /paymentInstrumentGroups/{id}/transactionRules", async (): Promise<void> => {
|
||||||
|
scope.get(`/paymentInstrumentGroups/${paymentInstrumentGroupId}/transactionRules`)
|
||||||
|
.reply(200, {
|
||||||
|
"transactionRules": [
|
||||||
|
{
|
||||||
|
"description": "Allow 5 transactions per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"maxTransactions": 5,
|
||||||
|
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||||
|
"reference": "myRule12345",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"status": "active",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": "TR32272223222B5CMDGMC9F4F"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 10000
|
||||||
|
},
|
||||||
|
"description": "Allow up to 100 EUR per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"paymentInstrumentGroupId": paymentInstrumentGroupId,
|
||||||
|
"reference": "myRule16378",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"status": "active",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": "TR32272223222B5CMDGT89F4F"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRulesResponse = await balancePlatformService.PaymentInstrumentGroups.listTransactionRules(paymentInstrumentGroupId);
|
||||||
|
|
||||||
|
expect(response.transactionRules!.length).toBe(2);
|
||||||
|
expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("TransactionRules", (): void => {
|
||||||
|
it("should support POST /transactionRules", async (): Promise<void> => {
|
||||||
|
scope.post("/transactionRules")
|
||||||
|
.reply(200, {
|
||||||
|
"description": "Allow only point-of-sale transactions",
|
||||||
|
"entityKey": {
|
||||||
|
"entityReference": "PI3227C223222B5BPCMFXD2XG",
|
||||||
|
"entityType": "paymentInstrument"
|
||||||
|
},
|
||||||
|
"interval": {
|
||||||
|
"timeZone": "UTC",
|
||||||
|
"type": "perTransaction"
|
||||||
|
},
|
||||||
|
"outcomeType": "hardBlock",
|
||||||
|
"reference": "YOUR_REFERENCE_4F7346",
|
||||||
|
"requestType": "authorization",
|
||||||
|
"ruleRestrictions": {
|
||||||
|
"processingTypes": {
|
||||||
|
"operation": "noneMatch",
|
||||||
|
"value": [
|
||||||
|
"pos"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"startDate": "2022-03-23T15:05:11.979433+01:00",
|
||||||
|
"status": "active",
|
||||||
|
"type": "blockList",
|
||||||
|
"id": transactionRuleId
|
||||||
|
});
|
||||||
|
const request: balancePlatform.TransactionRuleInfo = {
|
||||||
|
"description": "Allow only point-of-sale transactions",
|
||||||
|
"reference": "YOUR_REFERENCE_4F7346",
|
||||||
|
"entityKey": {
|
||||||
|
"entityType": "paymentInstrument",
|
||||||
|
"entityReference": "PI3227C223222B5BPCMFXD2XG"
|
||||||
|
},
|
||||||
|
"status": balancePlatform.TransactionRuleInfo.StatusEnum.Active,
|
||||||
|
"interval": {
|
||||||
|
"type": balancePlatform.TransactionRuleInterval.TypeEnum.PerTransaction
|
||||||
|
},
|
||||||
|
"ruleRestrictions": {
|
||||||
|
"processingTypes": {
|
||||||
|
"operation": "noneMatch",
|
||||||
|
"value": [
|
||||||
|
balancePlatform.ProcessingTypesRestriction.ValueEnum.Pos
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": balancePlatform.TransactionRuleInfo.TypeEnum.BlockList
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(transactionRuleId);
|
||||||
|
expect(response.status).toBe("active");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/transactionRules/${transactionRuleId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"transactionRule": {
|
||||||
|
"description": "Allow 5 transactions per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"maxTransactions": 5,
|
||||||
|
"paymentInstrumentId": "PI3227C223222B59KGTXP884R",
|
||||||
|
"reference": "myRule12345",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"status": "active",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": transactionRuleId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRuleResponse = await balancePlatformService.TransactionRules.retrieve(transactionRuleId);
|
||||||
|
|
||||||
|
expect(response.transactionRule!.id).toBe(transactionRuleId);
|
||||||
|
expect(response.transactionRule!.type).toBe("velocity");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/transactionRules/${transactionRuleId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"description": "Allow 5 transactions per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"reference": "myRule12345",
|
||||||
|
"startDate": "2021-01-21T12:46:35.476629Z",
|
||||||
|
"status": "inactive",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": transactionRuleId
|
||||||
|
});
|
||||||
|
const request: TransactionRuleInfoUpdate = {
|
||||||
|
"status": balancePlatform.TransactionRuleInfo.StatusEnum.Inactive
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.update(transactionRuleId, request);
|
||||||
|
|
||||||
|
expect(response.status).toBe("inactive");
|
||||||
|
expect(response.reference).toBe("myRule12345");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /transactionRules/{transactionRuleId}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/transactionRules/${transactionRuleId}`)
|
||||||
|
.reply(200, {
|
||||||
|
"amount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 10000
|
||||||
|
},
|
||||||
|
"description": "Allow up to 100 EUR per month",
|
||||||
|
"interval": {
|
||||||
|
"type": "monthly"
|
||||||
|
},
|
||||||
|
"paymentInstrumentGroupId": "PG3227C223222B5CMD3FJFKGZ",
|
||||||
|
"reference": "myRule16378",
|
||||||
|
"startDate": "2021-01-25T12:46:35.476629Z",
|
||||||
|
"type": "velocity",
|
||||||
|
"id": transactionRuleId
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.delete(transactionRuleId);
|
||||||
|
|
||||||
|
expect(response.id).toBe(transactionRuleId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,26 +1,9 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createClient } from "../__mocks__/base";
|
import { createClient } from "../__mocks__/base";
|
||||||
import BinLookup from "../services/binLookup";
|
import BinLookup from "../services/binLookup";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import HttpClientException from "../httpClient/httpClientException";
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
import { binlookup } from "../typings";
|
||||||
|
|
||||||
const threeDSAvailabilitySuccess = {
|
const threeDSAvailabilitySuccess = {
|
||||||
binDetails: {
|
binDetails: {
|
||||||
@@ -32,7 +15,7 @@ const threeDSAvailabilitySuccess = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let binLookup: BinLookup;
|
let binLookupService: BinLookup;
|
||||||
let scope: nock.Scope;
|
let scope: nock.Scope;
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
@@ -40,7 +23,7 @@ beforeEach((): void => {
|
|||||||
nock.activate();
|
nock.activate();
|
||||||
}
|
}
|
||||||
client = createClient();
|
client = createClient();
|
||||||
binLookup = new BinLookup(client);
|
binLookupService = new BinLookup(client);
|
||||||
scope = nock(`${client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}`);
|
scope = nock(`${client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -49,9 +32,8 @@ afterEach((): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Bin Lookup", function (): void {
|
describe("Bin Lookup", function (): void {
|
||||||
test.each([false, true])("should succeed on get 3ds availability. isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on get 3ds availability", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
const threeDSAvailabilityRequest: binlookup.ThreeDSAvailabilityRequest = {
|
||||||
const threeDSAvailabilityRequest: IBinLookup.ThreeDSAvailabilityRequest = {
|
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
brands: ["randomBrand"],
|
brands: ["randomBrand"],
|
||||||
cardNumber: "4111111111111111"
|
cardNumber: "4111111111111111"
|
||||||
@@ -60,13 +42,12 @@ describe("Bin Lookup", function (): void {
|
|||||||
scope.post("/get3dsAvailability")
|
scope.post("/get3dsAvailability")
|
||||||
.reply(200, threeDSAvailabilitySuccess);
|
.reply(200, threeDSAvailabilitySuccess);
|
||||||
|
|
||||||
const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
const response = await binLookupService.get3dsAvailability(threeDSAvailabilityRequest);
|
||||||
|
|
||||||
expect(response).toEqual<IBinLookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
expect(response).toEqual< binlookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail with invalid merchant. isMock: %p", async function (isMock): Promise<void> {
|
test("should fail with invalid merchant", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
|
||||||
const threeDSAvailabilityRequest: { [key: string]: undefined|string|[] } = {
|
const threeDSAvailabilityRequest: { [key: string]: undefined|string|[] } = {
|
||||||
merchantAccount: undefined,
|
merchantAccount: undefined,
|
||||||
cardNumber: "4111111111111",
|
cardNumber: "4111111111111",
|
||||||
@@ -77,15 +58,14 @@ describe("Bin Lookup", function (): void {
|
|||||||
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
|
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest);
|
await binLookupService.get3dsAvailability(threeDSAvailabilityRequest as unknown as binlookup.ThreeDSAvailabilityRequest);
|
||||||
fail("Expected request to fail");
|
fail("Expected request to fail");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e instanceof HttpClientException).toBeTruthy();
|
expect(e instanceof HttpClientException).toBeTruthy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should succeed on get cost estimate. isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on get cost estimate", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expected = {
|
const expected = {
|
||||||
cardBin: {
|
cardBin: {
|
||||||
bin: "",
|
bin: "",
|
||||||
@@ -103,7 +83,7 @@ describe("Bin Lookup", function (): void {
|
|||||||
resultCode: "Unsupported",
|
resultCode: "Unsupported",
|
||||||
surchargeType: "ZERO"
|
surchargeType: "ZERO"
|
||||||
};
|
};
|
||||||
const costEstimateRequest: IBinLookup.CostEstimateRequest = {
|
const costEstimateRequest: binlookup.CostEstimateRequest = {
|
||||||
amount: { currency: "EUR", value: 1000 },
|
amount: { currency: "EUR", value: 1000 },
|
||||||
assumptions: {
|
assumptions: {
|
||||||
assumeLevel3Data: true,
|
assumeLevel3Data: true,
|
||||||
@@ -116,13 +96,13 @@ describe("Bin Lookup", function (): void {
|
|||||||
mcc: "7411",
|
mcc: "7411",
|
||||||
enrolledIn3DSecure: true
|
enrolledIn3DSecure: true
|
||||||
},
|
},
|
||||||
shopperInteraction: "Ecommerce"
|
shopperInteraction: binlookup.CostEstimateRequest.ShopperInteractionEnum.Ecommerce,
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.post("/getCostEstimate")
|
scope.post("/getCostEstimate")
|
||||||
.reply(200, expected);
|
.reply(200, expected);
|
||||||
|
|
||||||
const response = await binLookup.getCostEstimate(costEstimateRequest);
|
const response = await binLookupService.getCostEstimate(costEstimateRequest);
|
||||||
|
|
||||||
expect(response).toEqual(expected);
|
expect(response).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||||
import { PeerCertificate } from "tls";
|
import { PeerCertificate } from "tls";
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2021 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import {createClient} from "../__mocks__/base";
|
import {createClient} from "../__mocks__/base";
|
||||||
import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess";
|
import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess";
|
||||||
@@ -26,52 +7,35 @@ import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess"
|
|||||||
import {originKeysSuccess} from "../__mocks__/checkout/originkeysSuccess";
|
import {originKeysSuccess} from "../__mocks__/checkout/originkeysSuccess";
|
||||||
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
|
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
|
||||||
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
|
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
|
||||||
|
import {sessionsSuccess} from "../__mocks__/checkout/sessionsSuccess";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import Checkout from "../services/checkout";
|
import Checkout from "../services/checkout";
|
||||||
import HttpClientException from "../httpClient/httpClientException";
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
import {
|
import { checkout } from "../typings";
|
||||||
Amount,
|
|
||||||
CardDetails,
|
|
||||||
CheckoutBalanceCheckRequest,
|
|
||||||
CheckoutBalanceCheckResponse,
|
|
||||||
CheckoutCancelOrderResponse,
|
|
||||||
CheckoutCreateOrderRequest,
|
|
||||||
CheckoutCreateOrderResponse,
|
|
||||||
CheckoutUtilityRequest,
|
|
||||||
CreatePaymentLinkRequest,
|
|
||||||
DetailsRequest,
|
|
||||||
PaymentLinkResource,
|
|
||||||
PaymentMethodsRequest,
|
|
||||||
PaymentRequest,
|
|
||||||
PaymentResponse,
|
|
||||||
PaymentSetupRequest,
|
|
||||||
PaymentVerificationRequest,
|
|
||||||
} from "../typings/checkout/models";
|
|
||||||
|
|
||||||
const merchantAccount = process.env.ADYEN_MERCHANT!;
|
const merchantAccount = process.env.ADYEN_MERCHANT!;
|
||||||
const reference = "Your order number";
|
const reference = "Your order number";
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
|
|
||||||
function createAmountObject(currency: string, value: number): Amount {
|
function createAmountObject(currency: string, value: number): checkout.Amount {
|
||||||
return {
|
return {
|
||||||
currency,
|
currency,
|
||||||
value,
|
value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPaymentsDetailsRequest(): DetailsRequest {
|
function createPaymentsDetailsRequest(): checkout.DetailsRequest {
|
||||||
return {
|
return {
|
||||||
details: {
|
details: {
|
||||||
MD: "mdValue",
|
mD: "mdValue",
|
||||||
PaRes: "paResValue",
|
paRes: "paResValue",
|
||||||
},
|
},
|
||||||
paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
|
paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createPaymentsCheckoutRequest(): PaymentRequest {
|
export function createPaymentsCheckoutRequest(): checkout.PaymentRequest {
|
||||||
const paymentMethodDetails = {
|
const paymentMethodDetails = {
|
||||||
type: CardDetails.TypeEnum.Scheme,
|
type: checkout.CardDetails.TypeEnum.Scheme,
|
||||||
encryptedCardNumber: "test_4111111111111111",
|
encryptedCardNumber: "test_4111111111111111",
|
||||||
encryptedExpiryMonth: "test_03",
|
encryptedExpiryMonth: "test_03",
|
||||||
encryptedExpiryYear: "test_2030",
|
encryptedExpiryYear: "test_2030",
|
||||||
@@ -89,30 +53,30 @@ export function createPaymentsCheckoutRequest(): PaymentRequest {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPaymentSessionRequest(): PaymentSetupRequest {
|
function createPaymentSessionRequest(): checkout.PaymentSetupRequest {
|
||||||
return {
|
return {
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
countryCode: "NL",
|
countryCode: "NL",
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
reference,
|
reference,
|
||||||
returnUrl: "https://your-company.com/...",
|
returnUrl: "https://your-company.com/...",
|
||||||
channel: PaymentSetupRequest.ChannelEnum.Web,
|
channel: checkout.PaymentSetupRequest.ChannelEnum.Web,
|
||||||
sdkVersion: "3.7.0"
|
sdkVersion: "3.7.0"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getPaymentLinkSuccess(expiresAt: string): PaymentLinkResource {
|
function getPaymentLinkSuccess(expiresAt: string): checkout.PaymentLinkResponse {
|
||||||
return {
|
return {
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
expiresAt,
|
expiresAt,
|
||||||
reference,
|
reference,
|
||||||
url: "paymentLinkResponse.url",
|
url: "PaymentLinkResponse.url",
|
||||||
id: "mocked_id",
|
id: "mocked_id",
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
status: PaymentLinkResource.StatusEnum.Active
|
status: checkout.PaymentLinkResponse.StatusEnum.Active
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPaymentLinkRequest(): CreatePaymentLinkRequest {
|
function createPaymentLinkRequest(): checkout.CreatePaymentLinkRequest {
|
||||||
return {
|
return {
|
||||||
allowedPaymentMethods: ["scheme", "boletobancario"],
|
allowedPaymentMethods: ["scheme", "boletobancario"],
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
@@ -141,8 +105,18 @@ function createPaymentLinkRequest(): CreatePaymentLinkRequest {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createSessionRequest(): checkout.CreateCheckoutSessionRequest {
|
||||||
|
return {
|
||||||
|
amount: createAmountObject("USD", 1000),
|
||||||
|
countryCode: "NL",
|
||||||
|
merchantAccount,
|
||||||
|
reference,
|
||||||
|
returnUrl: "https://your-company.com/...",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let checkout: Checkout;
|
let checkoutService: Checkout;
|
||||||
let scope: nock.Scope;
|
let scope: nock.Scope;
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
@@ -151,7 +125,7 @@ beforeEach((): void => {
|
|||||||
}
|
}
|
||||||
client = createClient();
|
client = createClient();
|
||||||
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
||||||
checkout = new Checkout(client);
|
checkoutService = new Checkout(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -159,37 +133,126 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Checkout", (): void => {
|
describe("Checkout", (): void => {
|
||||||
test.each([false, true])("should make a payment. isMock: %p", async (isMock): Promise<void> => {
|
test("should add idempotency key to request headers", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||||
|
scope.post("/payments")
|
||||||
|
.reply(200, paymentsSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.payments(paymentsRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
const paymentMethodsRequest: checkout.PaymentMethodsRequest = {merchantAccount};
|
||||||
|
scope.post("/paymentMethods")
|
||||||
|
.reply(200, paymentMethodsSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.paymentMethods(paymentMethodsRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
|
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt);
|
||||||
|
scope.post("/paymentLinks")
|
||||||
|
.reply(200, paymentLinkSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.paymentLinks(createPaymentLinkRequest(), {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.patch("/paymentLinks/321")
|
||||||
|
.reply(200, { ...paymentLinkSuccess, status: "expired" })
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.updatePaymentLinks("321", "expired", {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.get("/paymentLinks/123")
|
||||||
|
.reply(200, paymentLinkSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.getPaymentLinks("123", {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.post("/payments/details")
|
||||||
|
.reply(200, paymentDetailsSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.paymentsDetails(createPaymentsDetailsRequest(), {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.post("/paymentSession")
|
||||||
|
.reply(200, paymentSessionSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
const paymentSessionRequest: checkout.PaymentSetupRequest = createPaymentSessionRequest();
|
||||||
|
await checkoutService.paymentSession(paymentSessionRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.post("/payments/result")
|
||||||
|
.reply(200, paymentsResultSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
const paymentResultRequest: checkout.PaymentVerificationRequest = {
|
||||||
|
payload: "This is a test payload",
|
||||||
|
};
|
||||||
|
await checkoutService.paymentResult(paymentResultRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
const orderRequest: checkout.CheckoutCreateOrderRequest = {
|
||||||
|
amount: createAmountObject("USD", 1000),
|
||||||
|
merchantAccount,
|
||||||
|
reference
|
||||||
|
};
|
||||||
|
scope.post("/orders")
|
||||||
|
.reply(200, {})
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.orders(orderRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.post("/orders/cancel")
|
||||||
|
.reply(200, {})
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
await checkoutService.ordersCancel({
|
||||||
|
order: {
|
||||||
|
orderData: "mock_data",
|
||||||
|
pspReference: "mock_pspref"
|
||||||
|
},
|
||||||
|
merchantAccount
|
||||||
|
}, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
scope.post("/sessions")
|
||||||
|
.reply(200, sessionsSuccess)
|
||||||
|
.matchHeader("Idempotency-Key", "testKey");
|
||||||
|
|
||||||
|
const sessionsRequest: checkout.CreateCheckoutSessionRequest = createSessionRequest();
|
||||||
|
await checkoutService.sessions(sessionsRequest, {idempotencyKey: "testKey"});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test("should make a payment.", async (): Promise<void> => {
|
||||||
scope.post("/payments")
|
scope.post("/payments")
|
||||||
.reply(200, paymentsSuccess);
|
.reply(200, paymentsSuccess);
|
||||||
|
|
||||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||||
const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest);
|
const paymentsResponse: checkout.PaymentResponse = await checkoutService.payments(paymentsRequest);
|
||||||
expect(paymentsResponse.pspReference).toBeTruthy();
|
expect(paymentsResponse.pspReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should return correct Exception, isMock: %p", async (isMock): Promise<void> => {
|
test("Should properly handle error responses from API", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
try {
|
try {
|
||||||
scope.post("/payments")
|
scope.post("/payments")
|
||||||
.reply(401);
|
.reply(422, {
|
||||||
|
"status": 422,
|
||||||
|
"errorCode": "200",
|
||||||
|
"message": "Field 'countryCode' is not valid.",
|
||||||
|
"errorType": "validation",
|
||||||
|
"pspReference": "DMB552CV6JHKGK82",
|
||||||
|
});
|
||||||
|
|
||||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||||
await checkout.payments(paymentsRequest);
|
await checkoutService.payments(paymentsRequest);
|
||||||
} catch (e) {
|
fail("No exception was thrown");
|
||||||
expect(e instanceof HttpClientException).toBeTruthy();
|
} catch (error) {
|
||||||
|
expect(error instanceof HttpClientException).toBeTruthy();
|
||||||
|
if(error instanceof HttpClientException && error.responseBody) {
|
||||||
|
expect(JSON.parse(error.responseBody).errorType).toBe("validation");
|
||||||
|
} else {
|
||||||
|
fail("Error did not contain the expected data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should have valid payment methods, isMock: %p", async (isMock): Promise<void> => {
|
test("should have valid payment methods", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
const paymentMethodsRequest: checkout.PaymentMethodsRequest = {merchantAccount};
|
||||||
const paymentMethodsRequest: PaymentMethodsRequest = {merchantAccount};
|
|
||||||
|
|
||||||
scope.post("/paymentMethods")
|
scope.post("/paymentMethods")
|
||||||
.reply(200, paymentMethodsSuccess);
|
.reply(200, paymentMethodsSuccess);
|
||||||
|
|
||||||
const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest);
|
const paymentMethodsResponse = await checkoutService.paymentMethods(paymentMethodsRequest);
|
||||||
if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) {
|
if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) {
|
||||||
expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0);
|
expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -197,102 +260,98 @@ describe("Checkout", (): void => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should have valid payment link, isMock: %p", async (isMock): Promise<void> => {
|
test("should have valid payment link", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expiresAt = "2019-12-17T10:05:29Z";
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
const paymentLinkSuccess: PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt);
|
||||||
|
|
||||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||||
|
|
||||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest());
|
||||||
expect(paymentSuccessLinkResponse).toBeTruthy();
|
expect(paymentSuccessLinkResponse).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should get payment link, isMock: %p", async (isMock): Promise<void> => {
|
test("should get payment link", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expiresAt = "2019-12-17T10:05:29Z";
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
const paymentLinkSuccess: PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt);
|
||||||
|
|
||||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||||
|
|
||||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest());
|
||||||
|
|
||||||
scope.get(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, paymentLinkSuccess);
|
scope.get(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, paymentLinkSuccess);
|
||||||
const paymentLink = await checkout.getPaymentLinks(paymentSuccessLinkResponse.id);
|
const paymentLink = await checkoutService.getPaymentLinks(paymentSuccessLinkResponse.id);
|
||||||
expect(paymentLink).toBeTruthy();
|
expect(paymentLink).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should patch payment link, isMock: %p", async (isMock): Promise<void> => {
|
test("should patch payment link", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expiresAt = "2019-12-17T10:05:29Z";
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
const paymentLinkSuccess: PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt);
|
||||||
|
|
||||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||||
|
|
||||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest());
|
||||||
|
|
||||||
scope.patch(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, { ...paymentLinkSuccess, status: "expired" });
|
scope.patch(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, { ...paymentLinkSuccess, status: "expired" });
|
||||||
const paymentLink = await checkout.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired");
|
const paymentLink = await checkoutService.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired");
|
||||||
expect(paymentLink.status).toEqual("expired");
|
expect(paymentLink.status).toEqual("expired");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should have payment details, isMock: %p", async (isMock): Promise<void> => {
|
test("should have payment details", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/payments/details")
|
scope.post("/payments/details")
|
||||||
.reply(200, paymentDetailsSuccess);
|
.reply(200, paymentDetailsSuccess);
|
||||||
|
|
||||||
const paymentsResponse = await checkout.paymentsDetails(createPaymentsDetailsRequest());
|
const paymentsResponse = await checkoutService.paymentsDetails(createPaymentsDetailsRequest());
|
||||||
expect(paymentsResponse.resultCode).toEqual("Authorised");
|
expect(paymentsResponse.resultCode).toEqual("Authorised");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should have payment session success, isMock: %p", async (isMock): Promise<void> => {
|
test("should have payment session success", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/paymentSession")
|
scope.post("/paymentSession")
|
||||||
.reply(200, paymentSessionSuccess);
|
.reply(200, paymentSessionSuccess);
|
||||||
const paymentSessionRequest: PaymentSetupRequest = createPaymentSessionRequest();
|
const paymentSessionRequest: checkout.PaymentSetupRequest = createPaymentSessionRequest();
|
||||||
const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest);
|
const paymentSessionResponse = await checkoutService.paymentSession(paymentSessionRequest);
|
||||||
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
|
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should have payments result, isMock: %p", async (isMock): Promise<void> => {
|
test("should have payments result", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/payments/result")
|
scope.post("/payments/result")
|
||||||
.reply(200, paymentsResultSuccess);
|
.reply(200, paymentsResultSuccess);
|
||||||
const paymentResultRequest: PaymentVerificationRequest = {
|
const paymentResultRequest: checkout.PaymentVerificationRequest = {
|
||||||
payload: "This is a test payload",
|
payload: "This is a test payload",
|
||||||
};
|
};
|
||||||
const paymentResultResponse = await checkout.paymentResult(paymentResultRequest);
|
const paymentResultResponse = await checkoutService.paymentResult(paymentResultRequest);
|
||||||
expect(paymentResultResponse.resultCode).toEqual("Authorised");
|
expect(paymentResultResponse.resultCode).toEqual("Authorised");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should have missing identifier on live, isMock: %p", async (isMock): Promise<void> => {
|
test("should have missing identifier on live", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
client.setEnvironment("LIVE");
|
client.setEnvironment("LIVE");
|
||||||
try {
|
try {
|
||||||
new Checkout(client);
|
new Checkout(client);
|
||||||
fail();
|
fail();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
|
if(e instanceof Error) {
|
||||||
|
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test.each([false, true])("should succeed on multibanco payment, isMock: %p", async (isMock): Promise<void> => {
|
test("should succeed on multibanco payment", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/payments")
|
scope.post("/payments")
|
||||||
.reply(200, paymentsResultMultibancoSuccess);
|
.reply(200, paymentsResultMultibancoSuccess);
|
||||||
|
|
||||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||||
const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest);
|
const paymentsResponse: checkout.PaymentResponse = await checkoutService.payments(paymentsRequest);
|
||||||
|
|
||||||
expect(paymentsResponse.pspReference).toBeTruthy();
|
expect(paymentsResponse.pspReference).toBeTruthy();
|
||||||
expect(paymentsResponse.additionalData).toBeTruthy();
|
expect(paymentsResponse.additionalData).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should get origin keys. isMock: %p", async (isMock): Promise<void> => {
|
test("should get origin keys", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const checkoutUtility = new Checkout(client);
|
const checkoutUtility = new Checkout(client);
|
||||||
const originKeysRequest: CheckoutUtilityRequest = {
|
const originKeysRequest: checkout.CheckoutUtilityRequest = {
|
||||||
originDomains: ["https://www.your-domain.com"],
|
originDomains: ["https://www.your-domain.com"],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -308,76 +367,75 @@ describe("Checkout", (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO: add gift card to PaymentMethod and unmock test
|
// TODO: add gift card to PaymentMethod and unmock test
|
||||||
test.each([true, true])("should get payment methods balance", async (isMock): Promise<void> => {
|
test("should get payment methods balance", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
const paymentMethodsRequest: checkout.CheckoutBalanceCheckRequest = {
|
||||||
const paymentMethodsRequest: CheckoutBalanceCheckRequest = {
|
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
paymentMethod: { },
|
paymentMethod: { },
|
||||||
reference: "mocked_reference"
|
reference: "mocked_reference"
|
||||||
};
|
};
|
||||||
|
|
||||||
const paymentMethodsBalanceResponse: CheckoutBalanceCheckResponse = {
|
const paymentMethodsBalanceResponse: checkout.CheckoutBalanceCheckResponse = {
|
||||||
balance: {currency: "USD", value: 1000},
|
balance: {currency: "USD", value: 1000},
|
||||||
resultCode: CheckoutBalanceCheckResponse.ResultCodeEnum.Success
|
resultCode: checkout.CheckoutBalanceCheckResponse.ResultCodeEnum.Success
|
||||||
};
|
};
|
||||||
scope.post("/paymentMethods/balance")
|
scope.post("/paymentMethods/balance")
|
||||||
.reply(200, paymentMethodsBalanceResponse);
|
.reply(200, paymentMethodsBalanceResponse);
|
||||||
|
|
||||||
const paymentsResponse: CheckoutBalanceCheckResponse = await checkout.paymentMethodsBalance(paymentMethodsRequest);
|
const paymentsResponse: checkout.CheckoutBalanceCheckResponse = await checkoutService.paymentMethodsBalance(paymentMethodsRequest);
|
||||||
expect(paymentsResponse.balance.value).toEqual(1000);
|
expect(paymentsResponse.balance.value).toEqual(1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should create order", async (isMock): Promise<void> => {
|
test("should create order", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expiresAt = "2019-12-17T10:05:29Z";
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
const orderRequest: CheckoutCreateOrderRequest = {
|
const orderRequest: checkout.CheckoutCreateOrderRequest = {
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
reference
|
reference
|
||||||
};
|
};
|
||||||
|
|
||||||
const orderResponse: CheckoutCreateOrderResponse = {
|
const orderResponse: checkout.CheckoutCreateOrderResponse = {
|
||||||
expiresAt,
|
expiresAt,
|
||||||
|
amount: createAmountObject("USD", 500),
|
||||||
orderData: "mocked_order_data",
|
orderData: "mocked_order_data",
|
||||||
remainingAmount: {currency: "USD", value: 500} ,
|
remainingAmount: {currency: "USD", value: 500} ,
|
||||||
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
resultCode: checkout.CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
||||||
};
|
};
|
||||||
scope.post("/orders")
|
scope.post("/orders")
|
||||||
.reply(200, orderResponse);
|
.reply(200, orderResponse);
|
||||||
|
|
||||||
const response: CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
|
const response: checkout.CheckoutCreateOrderResponse = await checkoutService.orders(orderRequest);
|
||||||
expect(response).toBeTruthy();
|
expect(response).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should cancel order", async (isMock): Promise<void> => {
|
test("should cancel order", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const expiresAt = "2019-12-17T10:05:29Z";
|
const expiresAt = "2019-12-17T10:05:29Z";
|
||||||
const orderRequest: CheckoutCreateOrderRequest = {
|
const orderRequest: checkout.CheckoutCreateOrderRequest = {
|
||||||
amount: createAmountObject("USD", 1000),
|
amount: createAmountObject("USD", 1000),
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
reference
|
reference
|
||||||
};
|
};
|
||||||
|
|
||||||
const orderResponse: CheckoutCreateOrderResponse = {
|
const orderResponse: checkout.CheckoutCreateOrderResponse = {
|
||||||
expiresAt,
|
expiresAt,
|
||||||
|
amount: createAmountObject("USD", 500),
|
||||||
orderData: "mocked_order_data",
|
orderData: "mocked_order_data",
|
||||||
remainingAmount: {currency: "USD", value: 500},
|
remainingAmount: {currency: "USD", value: 500},
|
||||||
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
resultCode: checkout.CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
||||||
};
|
};
|
||||||
scope.post("/orders")
|
scope.post("/orders")
|
||||||
.reply(200, orderResponse);
|
.reply(200, orderResponse);
|
||||||
|
|
||||||
const createOrderResponse: CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
|
const createOrderResponse: checkout.CheckoutCreateOrderResponse = await checkoutService.orders(orderRequest);
|
||||||
|
|
||||||
const orderCancelResponse: CheckoutCancelOrderResponse = {
|
const orderCancelResponse: checkout.CheckoutCancelOrderResponse = {
|
||||||
pspReference: "mocked_psp_ref",
|
pspReference: "mocked_psp_ref",
|
||||||
resultCode: CheckoutCancelOrderResponse.ResultCodeEnum.Received
|
resultCode: checkout.CheckoutCancelOrderResponse.ResultCodeEnum.Received
|
||||||
};
|
};
|
||||||
scope.post("/orders/cancel")
|
scope.post("/orders/cancel")
|
||||||
.reply(200, orderCancelResponse);
|
.reply(200, orderCancelResponse);
|
||||||
|
|
||||||
const response: CheckoutCancelOrderResponse = await checkout.ordersCancel({
|
const response: checkout.CheckoutCancelOrderResponse = await checkoutService.ordersCancel({
|
||||||
order: {
|
order: {
|
||||||
orderData: createOrderResponse.orderData,
|
orderData: createOrderResponse.orderData,
|
||||||
pspReference: createOrderResponse.pspReference!
|
pspReference: createOrderResponse.pspReference!
|
||||||
@@ -386,4 +444,34 @@ describe("Checkout", (): void => {
|
|||||||
});
|
});
|
||||||
expect(response).toBeTruthy();
|
expect(response).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should create a session.", async (): Promise<void> => {
|
||||||
|
scope.post("/sessions")
|
||||||
|
.reply(200, sessionsSuccess);
|
||||||
|
|
||||||
|
const sessionsRequest: checkout.CreateCheckoutSessionRequest = createSessionRequest();
|
||||||
|
const sessionsResponse: checkout.CreateCheckoutSessionResponse = await checkoutService.sessions(sessionsRequest);
|
||||||
|
expect(sessionsResponse.sessionData).toBeTruthy();
|
||||||
|
expect(sessionsResponse.expiresAt).toBeInstanceOf(Date);
|
||||||
|
expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should get card details", async (): Promise<void> => {
|
||||||
|
scope.post("/cardDetails")
|
||||||
|
.reply(200, {
|
||||||
|
"brands": [
|
||||||
|
{
|
||||||
|
"supported": true,
|
||||||
|
"type": "visa"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const cardDetailsRequest: checkout.CardDetailsRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"cardNumber": "411111"
|
||||||
|
};
|
||||||
|
const cardDetailsReponse: checkout.CardDetailsResponse = await checkoutService.cardDetails(cardDetailsRequest);
|
||||||
|
expect(cardDetailsReponse?.brands?.length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
293
src/__tests__/classicIntegration.spec.ts
Normal file
293
src/__tests__/classicIntegration.spec.ts
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import {createClient} from "../__mocks__/base";
|
||||||
|
import Client from "../client";
|
||||||
|
import ClassicIntegration from "../services/classicIntegration";
|
||||||
|
import { payments } from "../typings";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let classicIntegration: ClassicIntegration;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.paymentEndpoint}/${Client.PAYMENT_API_VERSION}`);
|
||||||
|
classicIntegration = new ClassicIntegration(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Classic Integration", (): void => {
|
||||||
|
test("Should authorise payment", async (): Promise<void> => {
|
||||||
|
scope.post("/authorise")
|
||||||
|
.reply(200, {
|
||||||
|
"additionalData": {
|
||||||
|
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||||
|
"checkout.cardAddedBrand": "visa"
|
||||||
|
},
|
||||||
|
"pspReference": "JVBXGSDM53RZNN82",
|
||||||
|
"resultCode": "Authorised",
|
||||||
|
"authCode": "011381"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const paymentRequest: payments.PaymentRequest = {
|
||||||
|
"card": {
|
||||||
|
"number": "4111111111111111",
|
||||||
|
"expiryMonth": "03",
|
||||||
|
"expiryYear": "2030",
|
||||||
|
"cvc": "737",
|
||||||
|
"holderName": "John Smith"
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"value": 1500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const paymentResult: payments.PaymentResult = await classicIntegration.authorise(paymentRequest);
|
||||||
|
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should complete 3DS authorisation", async (): Promise<void> => {
|
||||||
|
scope.post("/authorise3d")
|
||||||
|
.reply(200, {
|
||||||
|
"additionalData": {
|
||||||
|
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||||
|
"checkout.cardAddedBrand": "visa"
|
||||||
|
},
|
||||||
|
"pspReference": "JVBXGSDM53RZNN82",
|
||||||
|
"resultCode": "Authorised",
|
||||||
|
"authCode": "011381"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const paymentRequest: payments.PaymentRequest3d = {
|
||||||
|
"md": "31h..........vOXek7w",
|
||||||
|
"paResponse": "eNqtmF........wGVA4Ch",
|
||||||
|
"shopperIP": "61.294.12.12",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const paymentResult: payments.PaymentResult = await classicIntegration.authorise3d(paymentRequest);
|
||||||
|
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should complete 3DS2 authorisation", async (): Promise<void> => {
|
||||||
|
scope.post("/authorise3ds2")
|
||||||
|
.reply(200, {
|
||||||
|
"additionalData": {
|
||||||
|
"scaExemptionRequested": "transactionRiskAnalysis",
|
||||||
|
"checkout.cardAddedBrand": "visa"
|
||||||
|
},
|
||||||
|
"pspReference": "JVBXGSDM53RZNN82",
|
||||||
|
"resultCode": "Authorised",
|
||||||
|
"authCode": "011381"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const paymentRequest: payments.PaymentRequest3ds2 = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"amount": {
|
||||||
|
"value": 1500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE",
|
||||||
|
"threeDS2RequestData": {
|
||||||
|
"threeDSCompInd": "Y",
|
||||||
|
"deviceChannel": "testDeviceChannel"
|
||||||
|
},
|
||||||
|
"threeDS2Token": "— - BINARY DATA - -"
|
||||||
|
};
|
||||||
|
|
||||||
|
const paymentResult: payments.PaymentResult = await classicIntegration.authorise3ds2(paymentRequest);
|
||||||
|
expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should get auth result after 3DS authentication", async (): Promise<void> => {
|
||||||
|
scope.post("/getAuthenticationResult").reply(200, {
|
||||||
|
"threeDS2Result": { "authenticationValue": "THREEDS2RESULT"}
|
||||||
|
});
|
||||||
|
|
||||||
|
const getAuthenticationResultrequest: payments.AuthenticationResultRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"pspReference": "9935272408535455"
|
||||||
|
};
|
||||||
|
|
||||||
|
const getAuthenticationResultResponse: payments.AuthenticationResultResponse = await classicIntegration.getAuthenticationResult(getAuthenticationResultrequest);
|
||||||
|
expect(getAuthenticationResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should retrieve 3DS2 result", async (): Promise<void> => {
|
||||||
|
scope.post("/retrieve3ds2Result").reply(200, {
|
||||||
|
"threeDS2Result": { "authenticationValue": "THREEDS2RESULT"}
|
||||||
|
});
|
||||||
|
const retrieve3ds2ResultRequest: payments.ThreeDS2ResultRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"pspReference": "9935272408535455"
|
||||||
|
};
|
||||||
|
|
||||||
|
const retrieve3ds2ResultResponse: payments.ThreeDS2ResultResponse = await classicIntegration.retrieve3ds2Result(retrieve3ds2ResultRequest);
|
||||||
|
expect(retrieve3ds2ResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send Capture request", async (): Promise<void> => {
|
||||||
|
scope.post("/capture")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[capture-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.CaptureRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"modificationAmount": {
|
||||||
|
"value": 500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.capture(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CaptureReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send Cancel request", async (): Promise<void> => {
|
||||||
|
scope.post("/cancel")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[cancel-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.CancelRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.cancel(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CancelReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send Refund request", async (): Promise<void> => {
|
||||||
|
scope.post("/refund")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[refund-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.RefundRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"modificationAmount": {
|
||||||
|
"value": 500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.refund(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.RefundReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send CancelOrRefund request", async (): Promise<void> => {
|
||||||
|
scope.post("/cancelOrRefund")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[cancelOrRefund-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.CancelOrRefundRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.cancelOrRefund(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CancelOrRefundReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send TechnicalCancel request", async (): Promise<void> => {
|
||||||
|
scope.post("/technicalCancel")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[technical-cancel-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.TechnicalCancelRequest = {
|
||||||
|
"originalMerchantReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"modificationAmount": {
|
||||||
|
"value": 500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.technicalCancel(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.TechnicalCancelReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send AdjustAuthorisation request", async (): Promise<void> => {
|
||||||
|
scope.post("/adjustAuthorisation")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[adjustAuthorisation-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.AdjustAuthorisationRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"modificationAmount": {
|
||||||
|
"value": 500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YourModificationReference",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.adjustAuthorisation(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.AdjustAuthorisationReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send Donate request", async (): Promise<void> => {
|
||||||
|
scope.post("/donate")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[donation-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.DonationRequest = {
|
||||||
|
"originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
|
||||||
|
"modificationAmount": {
|
||||||
|
"value": 500,
|
||||||
|
"currency": "EUR"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_DONATION_REFERENCE",
|
||||||
|
"donationAccount": "AdyenGivingDemo",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.donate(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.DonationReceived);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should succesfully send VoidPendingRefund request", async (): Promise<void> => {
|
||||||
|
scope.post("/voidPendingRefund")
|
||||||
|
.reply(200, {
|
||||||
|
"pspReference": "YOUR_REFERENCE",
|
||||||
|
"response": "[voidPendingRefund-received]"
|
||||||
|
});
|
||||||
|
|
||||||
|
const modificationRequest: payments.VoidPendingRefundRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"tenderReference": "5Iw8001176969533005",
|
||||||
|
"uniqueTerminalId": "VX820-123456789"
|
||||||
|
};
|
||||||
|
|
||||||
|
const modificationResult: payments.ModificationResult = await classicIntegration.voidPendingRefund(modificationRequest);
|
||||||
|
expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.VoidPendingRefundReceived);
|
||||||
|
});
|
||||||
|
});
|
||||||
11
src/__tests__/client.spec.ts
Normal file
11
src/__tests__/client.spec.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import Client from "../client";
|
||||||
|
|
||||||
|
describe("API Client", function (): void {
|
||||||
|
test("should be able to make a request using basic auth", async function (): Promise<void> {
|
||||||
|
new Client({
|
||||||
|
username: process.env.ADYEN_USER!,
|
||||||
|
password: process.env.ADYEN_PASSWORD!,
|
||||||
|
environment: "TEST"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
59
src/__tests__/dataProtection.spec.ts
Normal file
59
src/__tests__/dataProtection.spec.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import { createClient } from "../__mocks__/base";
|
||||||
|
import { DataProtection } from "../services";
|
||||||
|
import Client from "../client";
|
||||||
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
import { dataProtection } from "../typings";
|
||||||
|
|
||||||
|
let client: Client,
|
||||||
|
dataProtectionService: DataProtection,
|
||||||
|
scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if(!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
dataProtectionService = new DataProtection(client);
|
||||||
|
scope = nock(`${client.config.dataProtectionEndpoint}/${Client.DATA_PROTECTION_API_VERSION}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("DataProtection", (): void => {
|
||||||
|
test("should make succesful subjectErasure call", async (): Promise<void> => {
|
||||||
|
const requestSubjectErasureSuccess: dataProtection.SubjectErasureResponse = {
|
||||||
|
"result": dataProtection.SubjectErasureResponse.ResultEnum.Success,
|
||||||
|
};
|
||||||
|
|
||||||
|
const requestSubjectErasureRequest: dataProtection.SubjectErasureByPspReferenceRequest = {
|
||||||
|
"merchantAccount": "MY_MERCHANT_ACCOUNT",
|
||||||
|
"forceErasure": true,
|
||||||
|
"pspReference": "0123456789"
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.post("/requestSubjectErasure")
|
||||||
|
.reply(200, requestSubjectErasureSuccess);
|
||||||
|
|
||||||
|
const response: dataProtection.SubjectErasureResponse = await dataProtectionService.requestSubjectErasure(requestSubjectErasureRequest);
|
||||||
|
expect(response.result).toEqual(dataProtection.SubjectErasureResponse.ResultEnum.Success);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should return correct Exception", async (): Promise<void> => {
|
||||||
|
try {
|
||||||
|
scope.post("/requestSubjectErasure")
|
||||||
|
.reply(401);
|
||||||
|
|
||||||
|
const requestSubjectErasureRequest: dataProtection.SubjectErasureByPspReferenceRequest = {
|
||||||
|
"merchantAccount": "MY_MERCHANT_ACCOUNT",
|
||||||
|
"forceErasure": true,
|
||||||
|
"pspReference": "0123456789"
|
||||||
|
};
|
||||||
|
await dataProtectionService.requestSubjectErasure(requestSubjectErasureRequest);
|
||||||
|
} catch (e) {
|
||||||
|
expect(e instanceof HttpClientException).toBeTruthy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import HmacValidator from "../utils/hmacValidator";
|
import HmacValidator from "../utils/hmacValidator";
|
||||||
import { AdditionalData, NotificationItem, NotificationRequestItem } from "../typings/notification/models";
|
import { AdditionalData, NotificationItem, NotificationRequestItem } from "../typings/notification/models";
|
||||||
import { ApiConstants } from "../constants/apiConstants";
|
import { ApiConstants } from "../constants/apiConstants";
|
||||||
@@ -101,8 +82,12 @@ describe("HMAC Validator", function (): void {
|
|||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
hmacValidator.validateHMAC(notificationRequestItemNoAdditionalData, key);
|
hmacValidator.validateHMAC(notificationRequestItemNoAdditionalData, key);
|
||||||
} catch(error: any) {
|
} catch(error) {
|
||||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
if(error instanceof Error) {
|
||||||
|
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock, { Interceptor } from "nock";
|
import nock, { Interceptor } from "nock";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import Checkout from "../services/checkout";
|
import Checkout from "../services/checkout";
|
||||||
@@ -43,10 +24,14 @@ const getResponse = async ({apiKey , environment }: { apiKey: string; environmen
|
|||||||
try {
|
try {
|
||||||
await checkout.payments(createPaymentsCheckoutRequest());
|
await checkout.payments(createPaymentsCheckoutRequest());
|
||||||
fail("request should fail");
|
fail("request should fail");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e instanceof ErrorException).toBeTruthy();
|
if(e instanceof ErrorException){
|
||||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
326
src/__tests__/legalEntityManagement.spec.ts
Normal file
326
src/__tests__/legalEntityManagement.spec.ts
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import Client from "../client";
|
||||||
|
import {createClient} from "../__mocks__/base";
|
||||||
|
import * as models from "../typings/legalEntityManagement/models";
|
||||||
|
import {Document, LegalEntityInfo, OnboardingLinkInfo, TransferInstrumentInfo} from "../typings/legalEntityManagement/models";
|
||||||
|
import {DocumentUpdate} from "../services/legalEntityManagement/documents";
|
||||||
|
import {businessLine, businessLines, document, legalEntity, onboardingLink, onboardingTheme, onboardingThemes, transferInstrument} from "../__mocks__/legalEntityManagement/responses";
|
||||||
|
import TransferEnum = TransferInstrumentInfo.TypeEnum;
|
||||||
|
import TypeEnum = LegalEntityInfo.TypeEnum
|
||||||
|
import DocEnum = Document.TypeEnum
|
||||||
|
import {onboardingLinkInfo} from "../__mocks__/legalEntityManagement/requests";
|
||||||
|
import LegalEntityManagement from "../services/legalEntityManagement";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let legalEntityManagement: LegalEntityManagement;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.legalEntityManagementEndpoint}/${Client.LEGAL_ENTITY_MANAGEMENT_API_VERSION}`);
|
||||||
|
legalEntityManagement = new LegalEntityManagement(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Legal Entity Management", (): void => {
|
||||||
|
|
||||||
|
const id = "123456789"
|
||||||
|
|
||||||
|
describe("LegalEntities", (): void => {
|
||||||
|
it("should support POST /legalEntities", async (): Promise<void> => {
|
||||||
|
scope.post("/legalEntities")
|
||||||
|
.reply(200, legalEntity);
|
||||||
|
|
||||||
|
const request: models.LegalEntityInfo = {
|
||||||
|
type : TypeEnum.Individual,
|
||||||
|
individual : undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.LegalEntity = await legalEntityManagement.LegalEntities.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe("individual");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /legalEntities/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/legalEntities/${id}`)
|
||||||
|
.reply(200, legalEntity);
|
||||||
|
|
||||||
|
const response: models.LegalEntity = await legalEntityManagement.LegalEntities.retrieve("123456789");
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe("individual");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /legalEntities/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/legalEntities/${id}`)
|
||||||
|
.reply(200, legalEntity);
|
||||||
|
|
||||||
|
const request: models.LegalEntityInfo = {
|
||||||
|
type : TypeEnum.Individual,
|
||||||
|
individual : undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.LegalEntity = await legalEntityManagement.LegalEntities.update(id, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe("individual");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /legalEntities/{id}/BusinessLines", async (): Promise<void> => {
|
||||||
|
scope.get(`/legalEntities/${id}/businessLines`)
|
||||||
|
.reply(200, businessLines);
|
||||||
|
|
||||||
|
const response: models.BusinessLines = await legalEntityManagement.LegalEntities.listBusinessLines(id);
|
||||||
|
|
||||||
|
expect(response.businessLines).toEqual( [{
|
||||||
|
"capability": "receivePayments",
|
||||||
|
"id": "123456789",
|
||||||
|
"industryCode": "123456789",
|
||||||
|
"legalEntityId": "123456789",
|
||||||
|
"salesChannels": ["string"],
|
||||||
|
"sourceOfFunds": {
|
||||||
|
"acquiringBusinessLineId": "string",
|
||||||
|
"adyenProcessedFunds": false,
|
||||||
|
"description": "string",
|
||||||
|
"type": "business"
|
||||||
|
},
|
||||||
|
"webData": [{ "webAddress": "string" }],
|
||||||
|
"webDataExemption": { "reason": "noOnlinePresence" }
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Transfer Instruments", (): void => {
|
||||||
|
it("should support POST /transferInstruments", async (): Promise<void> => {
|
||||||
|
scope.post("/transferInstruments")
|
||||||
|
.reply(200, transferInstrument);
|
||||||
|
|
||||||
|
const request: models.TransferInstrumentInfo = {
|
||||||
|
type : TransferEnum.BankAccount,
|
||||||
|
legalEntityId : id,
|
||||||
|
bankAccount : {accountNumber: "string",
|
||||||
|
accountType: "string",
|
||||||
|
bankBicSwift: "string",
|
||||||
|
bankCity: "string",
|
||||||
|
bankCode: "string",
|
||||||
|
bankName: "string",
|
||||||
|
branchCode: "string",
|
||||||
|
checkCode: "string",
|
||||||
|
countryCode: "string",
|
||||||
|
currencyCode: "string",
|
||||||
|
iban: "string"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.TransferInstrument = await legalEntityManagement.TransferInstruments.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(TransferEnum.BankAccount);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /transferInstruments/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/transferInstruments/${id}`)
|
||||||
|
.reply(200, transferInstrument);
|
||||||
|
|
||||||
|
const response: models.TransferInstrument = await legalEntityManagement.TransferInstruments.retrieve(id);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(TransferEnum.BankAccount);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /transferInstruments/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/transferInstruments/${id}`)
|
||||||
|
.reply(200, transferInstrument);
|
||||||
|
|
||||||
|
const request: models.TransferInstrumentInfo = {
|
||||||
|
type : TransferEnum.BankAccount,
|
||||||
|
legalEntityId : id,
|
||||||
|
bankAccount : {accountNumber: "string",
|
||||||
|
accountType: "string",
|
||||||
|
bankBicSwift: "string",
|
||||||
|
bankCity: "string",
|
||||||
|
bankCode: "string",
|
||||||
|
bankName: "string",
|
||||||
|
branchCode: "string",
|
||||||
|
checkCode: "string",
|
||||||
|
countryCode: "string",
|
||||||
|
currencyCode: "string",
|
||||||
|
iban: "string"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.TransferInstrument = await legalEntityManagement.TransferInstruments.update(id, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(TransferEnum.BankAccount);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /transferInstruments/{id}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/transferInstruments/${id}`)
|
||||||
|
.reply(200);
|
||||||
|
|
||||||
|
await legalEntityManagement.TransferInstruments.delete(id);
|
||||||
|
|
||||||
|
expect(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Business Lines", (): void => {
|
||||||
|
it("should support POST /businessLines", async (): Promise<void> => {
|
||||||
|
scope.post("/businessLines")
|
||||||
|
.reply(200, businessLine);
|
||||||
|
|
||||||
|
const request: models.BusinessLineInfo = {
|
||||||
|
capability: "receivePayments",
|
||||||
|
industryCode: id,
|
||||||
|
legalEntityId: id };
|
||||||
|
|
||||||
|
const response: models.BusinessLine = await legalEntityManagement.BusinessLineService.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.capability).toBe("receivePayments");
|
||||||
|
expect(response.industryCode).toBe(id);
|
||||||
|
expect(response.legalEntityId).toBe(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /businessLines/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/businessLines/${id}`)
|
||||||
|
.reply(200, businessLine);
|
||||||
|
|
||||||
|
const response: models.BusinessLine = await legalEntityManagement.BusinessLineService.retrieve(id);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.capability).toBe("receivePayments");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /businessLines/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/businessLines/${id}`)
|
||||||
|
.reply(200, businessLine);
|
||||||
|
|
||||||
|
const request: models.BusinessLineInfo = {
|
||||||
|
capability: "receivePayments",
|
||||||
|
industryCode: id,
|
||||||
|
legalEntityId: id };
|
||||||
|
|
||||||
|
const response: models.BusinessLine = await legalEntityManagement.BusinessLineService.update(id, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.capability).toBe("receivePayments");
|
||||||
|
expect(response.industryCode).toBe(id);
|
||||||
|
expect(response.legalEntityId).toBe(id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Documents", (): void => {
|
||||||
|
it("should support POST /documents", async (): Promise<void> => {
|
||||||
|
scope.post("/documents")
|
||||||
|
.reply(200, document);
|
||||||
|
|
||||||
|
const request: DocumentUpdate = {
|
||||||
|
attachments: [{
|
||||||
|
content: "string",
|
||||||
|
contentType: "string",
|
||||||
|
filename: "string",
|
||||||
|
pageName: "string",
|
||||||
|
pageType: "string"
|
||||||
|
}],
|
||||||
|
description: "document",
|
||||||
|
owner: {
|
||||||
|
"id": "123456789",
|
||||||
|
"type": "passport"
|
||||||
|
},
|
||||||
|
type : DocEnum.DriversLicense
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.Document = await legalEntityManagement.Documents.create(request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(DocEnum.DriversLicense);
|
||||||
|
expect(response.owner).toEqual({id : "123456789", type : "passport" })
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /documents/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/documents/${id}`)
|
||||||
|
.reply(200, document);
|
||||||
|
|
||||||
|
const response: models.Document = await legalEntityManagement.Documents.retrieve(id);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(DocEnum.DriversLicense);
|
||||||
|
expect(response.owner).toEqual({id : "123456789", type : "passport" })
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /documents/{id}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/documents/${id}`)
|
||||||
|
.reply(200, document);
|
||||||
|
|
||||||
|
const request: DocumentUpdate = {
|
||||||
|
attachments: [{
|
||||||
|
content: "string",
|
||||||
|
contentType: "string",
|
||||||
|
filename: "string",
|
||||||
|
pageName: "string",
|
||||||
|
pageType: "string"
|
||||||
|
}],
|
||||||
|
description: "document",
|
||||||
|
owner: {
|
||||||
|
"id": "123456789",
|
||||||
|
"type": "passport"
|
||||||
|
},
|
||||||
|
type : DocEnum.DriversLicense
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: models.Document = await legalEntityManagement.Documents.update(id, request);
|
||||||
|
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
expect(response.type).toBe(DocEnum.DriversLicense);
|
||||||
|
expect(response.owner).toEqual({id : "123456789", type : "passport" })
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /documents/{id}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/documents/${id}`)
|
||||||
|
.reply(200);
|
||||||
|
|
||||||
|
await legalEntityManagement.Documents.delete(id);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("OnboardingLinks and Themes", (): void => {
|
||||||
|
it("should support POST /onboardingLinks", async (): Promise<void> => {
|
||||||
|
scope.post(`/legalEntities/${id}/onboardingLinks`)
|
||||||
|
.reply(200, onboardingLink);
|
||||||
|
|
||||||
|
const request: OnboardingLinkInfo = onboardingLinkInfo;
|
||||||
|
|
||||||
|
const response: models.OnboardingLink = await legalEntityManagement.HostedOnboardingPage.create(id, request);
|
||||||
|
|
||||||
|
expect(response.url).toBe("https://your.redirect-url.com");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /themes", async (): Promise<void> => {
|
||||||
|
scope.get(`/themes`)
|
||||||
|
.reply(200, onboardingThemes);
|
||||||
|
|
||||||
|
const response: models.OnboardingThemes = await legalEntityManagement.HostedOnboardingPage.listThemes();
|
||||||
|
|
||||||
|
expect(response.themes[0].id).toEqual(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /themes/{id}", async (): Promise<void> => {
|
||||||
|
scope.get(`/themes/${id}`)
|
||||||
|
.reply(200, onboardingTheme);
|
||||||
|
|
||||||
|
const response: models.OnboardingTheme = await legalEntityManagement.HostedOnboardingPage.retrieveTheme(id);
|
||||||
|
expect(response.id).toBe(id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
729
src/__tests__/management.spec.ts
Normal file
729
src/__tests__/management.spec.ts
Normal file
@@ -0,0 +1,729 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import Client from "../client";
|
||||||
|
import { createClient } from "../__mocks__/base";
|
||||||
|
import { Management } from "../services";
|
||||||
|
import { management } from "../typings";
|
||||||
|
import * as requests from "../__mocks__/management/requests";
|
||||||
|
import * as responses from "../__mocks__/management/responses";
|
||||||
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let managementService: Management;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
const merchantId = "merchantId";
|
||||||
|
const apiCredentialId = "apiCredentialId";
|
||||||
|
const originId = "originId";
|
||||||
|
const paymentMethodId = "paymentMethodId";
|
||||||
|
const payoutSettingsId = "payoutSettingsId";
|
||||||
|
const orderId = "orderId";
|
||||||
|
const userId = "userId";
|
||||||
|
const webhookId = "webhookId";
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.managementEndpoint}/${Client.MANAGEMENT_API_VERSION}`);
|
||||||
|
managementService = new Management(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Management", (): void => {
|
||||||
|
describe("Me", (): void => {
|
||||||
|
test("Should properly handle error responses from API", async (): Promise<void> => {
|
||||||
|
scope.post("/me/allowedOrigins")
|
||||||
|
.reply(422, {
|
||||||
|
"type": "https://docs.adyen.com/errors/not-found",
|
||||||
|
"title": "Entity was not found",
|
||||||
|
"status": 422,
|
||||||
|
"detail": "The origin id is invalid or does not exist.",
|
||||||
|
"requestId": "KQZ5LXK2VMPRMC82",
|
||||||
|
"errorCode": "30_112",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const createAllowedOriginRequest : management.CreateAllowedOriginRequest = {
|
||||||
|
domain: "test.com",
|
||||||
|
};
|
||||||
|
await managementService.Me.createAllowedOrigin(createAllowedOriginRequest);
|
||||||
|
fail("No exception was thrown");
|
||||||
|
} catch (error) {
|
||||||
|
expect(error instanceof HttpClientException).toBeTruthy();
|
||||||
|
if(error instanceof HttpClientException && error.responseBody) {
|
||||||
|
expect(JSON.parse(error.responseBody).requestId).toBe("KQZ5LXK2VMPRMC82");
|
||||||
|
} else {
|
||||||
|
fail("Error did not contain the expected data");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should get API credential details based on the API Key used in the request", async (): Promise<void> => {
|
||||||
|
scope.get("/me")
|
||||||
|
.reply(200, {
|
||||||
|
"id": "S2-6262224667",
|
||||||
|
"username": "ws_123456@Company.Test",
|
||||||
|
"clientKey": "test_UCP6BO23234FFEFE33E4GWX63",
|
||||||
|
"allowedIpAddresses": [],
|
||||||
|
"roles": [
|
||||||
|
"Management API - Users read and write",
|
||||||
|
"Management API - Accounts read",
|
||||||
|
"Trigger webhook notifications",
|
||||||
|
"Management API - Payout Account Settings Read And Write",
|
||||||
|
"Manage LegalEntities via API",
|
||||||
|
"Manage associated partner accounts via API",
|
||||||
|
"PSP Pos initial configuration",
|
||||||
|
|
||||||
|
],
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/me"
|
||||||
|
},
|
||||||
|
"allowedOrigins": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/me/allowedOrigins"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"companyName": "Test",
|
||||||
|
"active": true,
|
||||||
|
});
|
||||||
|
const meResponse: management.MeApiCredential = await managementService.Me.retrieve();
|
||||||
|
expect(meResponse.id).toEqual("S2-6262224667");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should add an allowed origin to the list of allowed origins", async (): Promise<void> => {
|
||||||
|
scope.post("/me/allowedOrigins")
|
||||||
|
.reply(200, {
|
||||||
|
"id": "S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921",
|
||||||
|
"domain": "https://www.us.mystore.com",
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const allowedOriginRequest: management.AllowedOrigin = {
|
||||||
|
"domain": "https://www.us.mystore.com"
|
||||||
|
};
|
||||||
|
|
||||||
|
const allowedOriginsResponse: management.AllowedOrigin = await managementService.Me.createAllowedOrigin(allowedOriginRequest);
|
||||||
|
expect(allowedOriginsResponse.domain).toEqual("https://www.us.mystore.com");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should get the list of allowed origins of a API credential based on the API key used in the request", async (): Promise<void> => {
|
||||||
|
scope.get("/me/allowedOrigins")
|
||||||
|
.reply(200, {
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921",
|
||||||
|
"domain": "https://www.us.mystore.com",
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-45597C41735B6D75433E2B396553453ertcdt347675B4E3B413B4C4571522A6B2921"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const allowedOriginsResponse: management.AllowedOriginsResponse = await managementService.Me.retrieveAllowedOrigins();
|
||||||
|
expect(allowedOriginsResponse.data?.length).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should retrieve the details of the allowed origin specified in the path", async () => {
|
||||||
|
scope.get("/me/allowedOrigins/S2-123123123123123")
|
||||||
|
.reply(200, {
|
||||||
|
"id": "S2-123123123123123",
|
||||||
|
"domain": "https://www.us.mystore.com",
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/me/allowedOrigins/S2-123123123123123"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const allowedOriginResponse: management.AllowedOrigin = await managementService.Me.retrieveAllowedOrigin("S2-123123123123123");
|
||||||
|
expect(allowedOriginResponse.id).toEqual("S2-123123123123123");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should remove the allowed origin specified in the path", async () => {
|
||||||
|
scope.delete("/me/allowedOrigins/S2-123123123123123").reply(204, {});
|
||||||
|
const allowedOriginResponse: Record<string, unknown> = await managementService.Me.deleteAllowerdOrigin("S2-123123123123123");
|
||||||
|
expect(scope.isDone()).toBe(true);
|
||||||
|
expect(Object.entries(allowedOriginResponse).length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantAccount", (): void => {
|
||||||
|
it("should support GET /merchants", async (): Promise<void> => {
|
||||||
|
scope.get("/merchants?pageNumber=1&pageSize=1")
|
||||||
|
.reply(200, responses.listMerchantResponse);
|
||||||
|
|
||||||
|
const response: management.ListMerchantResponse = await managementService.MerchantAccount.list({
|
||||||
|
params: {
|
||||||
|
"pageNumber": "1",
|
||||||
|
"pageSize": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants", async (): Promise<void> => {
|
||||||
|
scope.post("/merchants")
|
||||||
|
.reply(200, responses.createMerchantResponse);
|
||||||
|
|
||||||
|
const response: management.CreateMerchantResponse = await managementService.MerchantAccount.create(requests.createMerchantRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}`)
|
||||||
|
.reply(200, responses.merchant);
|
||||||
|
|
||||||
|
const response: management.Merchant = await managementService.MerchantAccount.retrieve(merchantId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/activate", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/activate`)
|
||||||
|
.reply(200, responses.requestActivationResponse);
|
||||||
|
|
||||||
|
const response: management.RequestActivationResponse = await managementService.MerchantAccount.activate(merchantId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantAllowedOrigins", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`)
|
||||||
|
.reply(200, responses.allowedOriginsResponse);
|
||||||
|
|
||||||
|
const response: management.AllowedOriginsResponse = await managementService.MerchantAllowedOrigins.list(merchantId, apiCredentialId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`)
|
||||||
|
.reply(200, responses.allowedOriginsResponse);
|
||||||
|
|
||||||
|
const response: management.AllowedOriginsResponse = await managementService.MerchantAllowedOrigins.create(merchantId, apiCredentialId, requests.allowedOrigin);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`)
|
||||||
|
.reply(204);
|
||||||
|
|
||||||
|
await managementService.MerchantAllowedOrigins.delete(merchantId, apiCredentialId, originId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`)
|
||||||
|
.reply(200, responses.allowedOrigin);
|
||||||
|
|
||||||
|
const response: management.AllowedOrigin = await managementService.MerchantAllowedOrigins.retrieve(merchantId, apiCredentialId, originId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantApiCredentials", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/apiCredentials", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/apiCredentials?pageNumber=1&pageSize=1`)
|
||||||
|
.reply(200, responses.listMerchantApiCredentialsResponse);
|
||||||
|
|
||||||
|
const response: management.ListMerchantApiCredentialsResponse = await managementService.MerchantApiCredentials.list(merchantId, {
|
||||||
|
params: {
|
||||||
|
"pageNumber": "1",
|
||||||
|
"pageSize": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/apiCredentials", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/apiCredentials`)
|
||||||
|
.reply(200, responses.createApiCredentialResponse);
|
||||||
|
|
||||||
|
const response: management.CreateApiCredentialResponse = await managementService.MerchantApiCredentials.create(merchantId, requests.createMerchantApiCredentialRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`)
|
||||||
|
.reply(200, responses.apiCredential);
|
||||||
|
|
||||||
|
const response: management.ApiCredential = await managementService.MerchantApiCredentials.retrieve(merchantId, apiCredentialId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/apiCredentials/{apiCredentialId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`)
|
||||||
|
.reply(200, responses.apiCredential);
|
||||||
|
|
||||||
|
const response: management.ApiCredential = await managementService.MerchantApiCredentials.update(merchantId, apiCredentialId, requests.updateMerchantApiCredentialRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantApiKey", (): void => {
|
||||||
|
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateApiKey", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`)
|
||||||
|
.reply(200, responses.generateApiKeyResponse);
|
||||||
|
|
||||||
|
const response: management.GenerateApiKeyResponse = await managementService.MerchantApiKey.create(merchantId, apiCredentialId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantClientKey", (): void => {
|
||||||
|
it("should support POST /merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateClientKey", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`)
|
||||||
|
.reply(200, responses.generateClientKeyResponse);
|
||||||
|
|
||||||
|
const response: management.GenerateClientKeyResponse = await managementService.MerchantClientKey.create(merchantId, apiCredentialId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantPaymentMethods", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/paymentMethodSettings", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/paymentMethodSettings?storeId=1&businessLineId=1&pageNumber=1&pageSize=1`)
|
||||||
|
.reply(200, responses.paymentMethodResponse);
|
||||||
|
|
||||||
|
const response: management.PaymentMethodResponse = await managementService.MerchantPaymentMethods.listPaymentMethodSettings(merchantId, {
|
||||||
|
params: {
|
||||||
|
"storeId": "1",
|
||||||
|
"businessLineId": "1",
|
||||||
|
"pageSize": "1",
|
||||||
|
"pageNumber": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/paymentMethodSettings", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/paymentMethodSettings`)
|
||||||
|
.reply(200, responses.paymentMethod);
|
||||||
|
|
||||||
|
const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.create(merchantId, {
|
||||||
|
...requests.paymentMethodSetupInfo,
|
||||||
|
type: management.PaymentMethodSetupInfo.TypeEnum.Ideal
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`)
|
||||||
|
.reply(200, responses.paymentMethod);
|
||||||
|
|
||||||
|
const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.retrieve(merchantId, paymentMethodId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`)
|
||||||
|
.reply(200, responses.paymentMethod);
|
||||||
|
|
||||||
|
const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.update(merchantId, paymentMethodId, requests.updatePaymentMethodInfo);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantPayoutSettings", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/payoutSettings", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/payoutSettings`)
|
||||||
|
.reply(200, responses.payoutSettingsResponse);
|
||||||
|
|
||||||
|
const response: management.PayoutSettingsResponse = await managementService.MerchantPayoutSettings.listPayoutSettings(merchantId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/payoutSettings", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/payoutSettings`)
|
||||||
|
.reply(200, responses.payoutSettings);
|
||||||
|
|
||||||
|
const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.create(merchantId, requests.payoutSettingsRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||||
|
.reply(200);
|
||||||
|
|
||||||
|
await managementService.MerchantPayoutSettings.delete(merchantId, payoutSettingsId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||||
|
.reply(200, responses.payoutSettings);
|
||||||
|
|
||||||
|
const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.retrieve(merchantId, payoutSettingsId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`)
|
||||||
|
.reply(200, responses.payoutSettings);
|
||||||
|
|
||||||
|
const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.update(merchantId, payoutSettingsId, requests.updatePayoutSettingsRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantTerminalOrders", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/billingEntities", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/billingEntities?name=bill`)
|
||||||
|
.reply(200, responses.billingEntitiesResponse);
|
||||||
|
|
||||||
|
const response: management.BillingEntitiesResponse = await managementService.MerchantTerminalOrders.listBillingEntities(merchantId, {
|
||||||
|
params: {
|
||||||
|
"name": "bill"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/shippingLocations", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/shippingLocations?name=1&offset=1&limit=1`)
|
||||||
|
.reply(200, responses.shippingLocationsResponse);
|
||||||
|
|
||||||
|
const response: management.ShippingLocationsResponse = await managementService.MerchantTerminalOrders.listShippingLocations(merchantId, {
|
||||||
|
params: {
|
||||||
|
"name": "1",
|
||||||
|
"offset": "1",
|
||||||
|
"limit": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/shippingLocations", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/shippingLocations`)
|
||||||
|
.reply(200, responses.shippingLocation);
|
||||||
|
|
||||||
|
const response: management.ShippingLocation = await managementService.MerchantTerminalOrders.createShippingLocation(merchantId, requests.shippingLocation);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalModels", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalModels`)
|
||||||
|
.reply(200, responses.terminalModelsResponse);
|
||||||
|
|
||||||
|
const response: management.TerminalModelsResponse = await managementService.MerchantTerminalOrders.listTerminalModels(merchantId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalOrders", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalOrders?customerOrderReference=1&status=1&offset=1&limit=1`)
|
||||||
|
.reply(200, responses.terminalOrdersResponse);
|
||||||
|
|
||||||
|
const response: management.TerminalOrdersResponse = await managementService.MerchantTerminalOrders.listTerminalOrders(merchantId, {
|
||||||
|
params: {
|
||||||
|
"customerOrderReference": "1",
|
||||||
|
"status": "1",
|
||||||
|
"offset": "1",
|
||||||
|
"limit": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/terminalOrders", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/terminalOrders`)
|
||||||
|
.reply(200, responses.terminalOrder);
|
||||||
|
|
||||||
|
const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.create(merchantId, requests.terminalOrderRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalOrders/{orderId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalOrders/${orderId}`)
|
||||||
|
.reply(200, responses.terminalOrder);
|
||||||
|
|
||||||
|
const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.retrieve(merchantId, orderId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/terminalOrders/{orderId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/terminalOrders/${orderId}`)
|
||||||
|
.reply(200, responses.terminalOrder);
|
||||||
|
|
||||||
|
const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.update(merchantId, orderId, requests.terminalOrderRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/terminalOrders/{orderId}/cancel", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/terminalOrders/${orderId}/cancel`)
|
||||||
|
.reply(200, responses.terminalOrder);
|
||||||
|
|
||||||
|
const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.cancel(merchantId, orderId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalProducts", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalProducts?country=1&terminalModelId=1&offset=1&limit=1`)
|
||||||
|
.reply(200, responses.terminalProductsResponse);
|
||||||
|
|
||||||
|
const response: management.TerminalProductsResponse = await managementService.MerchantTerminalOrders.listTerminalProducts(merchantId, {
|
||||||
|
params: {
|
||||||
|
"country": "1",
|
||||||
|
"terminalModelId": "1",
|
||||||
|
"offset": "1",
|
||||||
|
"limit": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantTerminalSettings", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalLogos", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalLogos?model=1`)
|
||||||
|
.reply(200, responses.logo);
|
||||||
|
|
||||||
|
const response: management.Logo = await managementService.MerchantTerminalSettings.retrieveLogo(merchantId, {
|
||||||
|
params: {
|
||||||
|
"model": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/terminalLogos", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/terminalLogos?model=1`)
|
||||||
|
.reply(200, responses.logo);
|
||||||
|
|
||||||
|
const response: management.Logo = await managementService.MerchantTerminalSettings.updateLogo(merchantId, requests.logo, {
|
||||||
|
params: {
|
||||||
|
"model": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/terminalSettings", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/terminalSettings`)
|
||||||
|
.reply(200, responses.terminalSettings);
|
||||||
|
|
||||||
|
const response: management.TerminalSettings = await managementService.MerchantTerminalSettings.retrieve(merchantId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/terminalSettings", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/terminalSettings`)
|
||||||
|
.reply(200, responses.terminalSettings);
|
||||||
|
|
||||||
|
const response: management.TerminalSettings = await managementService.MerchantTerminalSettings.update(merchantId, requests.terminalSettings);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantUsers", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/users", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/users?pageNumber=1&pageSize=1`)
|
||||||
|
.reply(200, responses.listMerchantUsersResponse);
|
||||||
|
|
||||||
|
const response: management.ListMerchantUsersResponse = await managementService.MerchantUsers.list(merchantId, {
|
||||||
|
params: {
|
||||||
|
"pageNumber": "1",
|
||||||
|
"pageSize": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/users", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/users`)
|
||||||
|
.reply(200, responses.createUserResponse);
|
||||||
|
|
||||||
|
const response: management.CreateUserResponse = await managementService.MerchantUsers.create(merchantId, requests.createMerchantUserRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/users/{userId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/users/${userId}`)
|
||||||
|
.reply(200, responses.user);
|
||||||
|
|
||||||
|
const response: management.User = await managementService.MerchantUsers.retrieve(merchantId, userId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/users/{userId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/users/${userId}`)
|
||||||
|
.reply(200, responses.user);
|
||||||
|
|
||||||
|
const response: management.User = await managementService.MerchantUsers.update(merchantId, userId, requests.updateMerchantUserRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("MerchantWebhooks", (): void => {
|
||||||
|
it("should support GET /merchants/{merchantId}/webhooks", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/webhooks?pageNumber=1&pageSize=1`)
|
||||||
|
.reply(200, responses.listWebhooksResponse);
|
||||||
|
|
||||||
|
const response: management.ListWebhooksResponse = await managementService.MerchantWebhooks.list(merchantId, {
|
||||||
|
params: {
|
||||||
|
"pageNumber": "1",
|
||||||
|
"pageSize": "1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/webhooks", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/webhooks`)
|
||||||
|
.reply(200, responses.webhook);
|
||||||
|
|
||||||
|
const response: management.Webhook = await managementService.MerchantWebhooks.create(merchantId, {
|
||||||
|
...requests.createMerchantWebhookRequest,
|
||||||
|
communicationFormat: management.CreateMerchantWebhookRequest.CommunicationFormatEnum.Json,
|
||||||
|
networkType: management.CreateMerchantWebhookRequest.NetworkTypeEnum.Public,
|
||||||
|
sslVersion: management.CreateMerchantWebhookRequest.SslVersionEnum.Tls
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support DELETE /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||||
|
scope.delete(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||||
|
.reply(204);
|
||||||
|
|
||||||
|
await managementService.MerchantWebhooks.delete(merchantId, webhookId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support GET /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||||
|
scope.get(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||||
|
.reply(200, responses.webhook);
|
||||||
|
|
||||||
|
const response: management.Webhook = await managementService.MerchantWebhooks.retrieve(merchantId, webhookId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support PATCH /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise<void> => {
|
||||||
|
scope.patch(`/merchants/${merchantId}/webhooks/${webhookId}`)
|
||||||
|
.reply(200, responses.webhook);
|
||||||
|
|
||||||
|
const response: management.Webhook = await managementService.MerchantWebhooks.update(merchantId, webhookId, {
|
||||||
|
...requests.updateMerchantWebhookRequest,
|
||||||
|
communicationFormat: management.CreateMerchantWebhookRequest.CommunicationFormatEnum.Soap,
|
||||||
|
networkType: management.CreateMerchantWebhookRequest.NetworkTypeEnum.Local,
|
||||||
|
sslVersion: management.CreateMerchantWebhookRequest.SslVersionEnum.Sslv3
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/webhooks/{webhookId}/generateHmac", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`)
|
||||||
|
.reply(200, responses.generateHmacKeyResponse);
|
||||||
|
|
||||||
|
const response: management.GenerateHmacKeyResponse = await managementService.MerchantWebhooks.generateHmac(merchantId, webhookId);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support POST /merchants/{merchantId}/webhooks/{webhookId}/test", async (): Promise<void> => {
|
||||||
|
scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/test`)
|
||||||
|
.reply(200, responses.testWebhookResponse);
|
||||||
|
|
||||||
|
const testWebhookRequest: management.TestWebhookRequest = {
|
||||||
|
"notification": {
|
||||||
|
"amount": {
|
||||||
|
"currency": "string",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"eventCode": "string",
|
||||||
|
"eventDate": new Date(2022, 6, 15),
|
||||||
|
"merchantReference": "string",
|
||||||
|
"paymentMethod": "string",
|
||||||
|
"reason": "string",
|
||||||
|
"success": false
|
||||||
|
},
|
||||||
|
"types": ["string"]
|
||||||
|
};
|
||||||
|
const response: management.TestWebhookResponse = await managementService.MerchantWebhooks.test(merchantId, webhookId, testWebhookRequest);
|
||||||
|
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("AllowedOriginsMerchantLevelApi", (): void => {
|
||||||
|
test("Delete an allowed origin", async () => {
|
||||||
|
scope.delete("/merchants/foo/apiCredentials/BAR123/allowedOrigins/fishy%20one").reply(204);
|
||||||
|
|
||||||
|
await managementService.AllowedOriginsMerchantLevelApi
|
||||||
|
.deleteAllowedOrigin("foo", "BAR123", "fishy one");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Create an allowed origin", async () => {
|
||||||
|
const requestBody = {
|
||||||
|
"domain": "https://www.eu.mystore.com"
|
||||||
|
};
|
||||||
|
scope.post("/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins", requestBody)
|
||||||
|
.reply(200, {
|
||||||
|
"id": "YOUR_ALLOWED_ORIGIN",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"domain": "https://www.eu.mystore.com",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins/YOUR_ALLOWED_ORIGIN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response: management.AllowedOriginsResponse = await managementService.AllowedOriginsMerchantLevelApi
|
||||||
|
.createAllowedOrigin("YOUR_MERCHANT_ACCOUNT", "YOUR_API_CREDENTIAL", {
|
||||||
|
domain: "https://www.eu.mystore.com",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.data![0].domain).toEqual("https://www.eu.mystore.com");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,25 +1,6 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2021 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import {createClient} from "../__mocks__/base";
|
import {createClient} from "../__mocks__/base";
|
||||||
import Modification from "../services/modification";
|
import Checkout from "../services/checkout";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import {
|
import {
|
||||||
CreatePaymentAmountUpdateRequest,
|
CreatePaymentAmountUpdateRequest,
|
||||||
@@ -32,6 +13,7 @@ import {
|
|||||||
PaymentCaptureResource, PaymentRefundResource, PaymentReversalResource,
|
PaymentCaptureResource, PaymentRefundResource, PaymentReversalResource,
|
||||||
StandalonePaymentCancelResource
|
StandalonePaymentCancelResource
|
||||||
} from "../typings/checkout/models";
|
} from "../typings/checkout/models";
|
||||||
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
|
||||||
const invalidModificationResult = {
|
const invalidModificationResult = {
|
||||||
"status": 422,
|
"status": 422,
|
||||||
@@ -168,18 +150,17 @@ const createReversalsResponse = (): PaymentReversalResource => {
|
|||||||
|
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let modification: Modification;
|
let checkout: Checkout;
|
||||||
let scope: nock.Scope;
|
let scope: nock.Scope;
|
||||||
const paymentPspReference = "863620292981235A";
|
const paymentPspReference = "863620292981235A";
|
||||||
const invalidPaymentPspReference = "invalid_psp_reference";
|
const invalidPaymentPspReference = "invalid_psp_reference";
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
if (!nock.isActive()) {
|
if (!nock.isActive()) {
|
||||||
nock.activate();
|
nock.activate();
|
||||||
}
|
}
|
||||||
client = createClient();
|
client = createClient();
|
||||||
modification = new Modification(client);
|
checkout = new Checkout(client);
|
||||||
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,152 +169,185 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Modification", (): void => {
|
describe("Modification", (): void => {
|
||||||
test.each([isCI, true])("should perform an amount update request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform an amount update request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createAmountUpdateRequest();
|
const request = createAmountUpdateRequest();
|
||||||
scope.post(`/payments/${paymentPspReference}/amountUpdates`)
|
scope.post(`/payments/${paymentPspReference}/amountUpdates`)
|
||||||
.reply(200, createAmountUpdateResponse());
|
.reply(200, createAmountUpdateResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.amountUpdates(paymentPspReference, request);
|
const result = await checkout.amountUpdates(paymentPspReference, request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail to perform an amount update request, isMock: %p", async (isMock): Promise<void> => {
|
test("should fail to perform an amount update request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const request = createAmountUpdateRequest();
|
const request = createAmountUpdateRequest();
|
||||||
scope.post(`/payments/${invalidPaymentPspReference}/amountUpdates`)
|
scope.post(`/payments/${invalidPaymentPspReference}/amountUpdates`)
|
||||||
.reply(422, invalidModificationResult);
|
.reply(422, invalidModificationResult);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await modification.amountUpdates(invalidPaymentPspReference, request);
|
await checkout.amountUpdates(invalidPaymentPspReference, request);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.statusCode).toBe(422);
|
if(e instanceof HttpClientException) {
|
||||||
expect(e.message).toContain("Original pspReference required for this operation");
|
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||||
|
expect(e.message).toContain("Original pspReference required for this operation");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should perform a cancels request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform a cancels request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createCancelsRequest();
|
const request = createCancelsRequest();
|
||||||
scope.post(`/payments/${paymentPspReference}/cancels`)
|
scope.post(`/payments/${paymentPspReference}/cancels`)
|
||||||
.reply(200, createCancelsResponse());
|
.reply(200, createCancelsResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.cancels(paymentPspReference, request);
|
const result = await checkout.cancels(paymentPspReference, request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail to perform a cancels request, isMock: %p", async (isMock): Promise<void> => {
|
test("should fail to perform a cancels request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const request = createCancelsRequest();
|
const request = createCancelsRequest();
|
||||||
scope.post(`/payments/${invalidPaymentPspReference}/cancels`)
|
scope.post(`/payments/${invalidPaymentPspReference}/cancels`)
|
||||||
.reply(422, invalidModificationResult);
|
.reply(422, invalidModificationResult);
|
||||||
try {
|
try {
|
||||||
await modification.cancels(invalidPaymentPspReference, request);
|
await checkout.cancels(invalidPaymentPspReference, request);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.statusCode).toBe(422);
|
if(e instanceof HttpClientException) {
|
||||||
expect(e.message).toContain("Original pspReference required for this operation");
|
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||||
|
expect(e.message).toContain("Original pspReference required for this operation");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should perform a standalone cancels request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform a standalone cancels request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createStandaloneCancelsRequest();
|
const request = createStandaloneCancelsRequest();
|
||||||
scope.post("/cancels")
|
scope.post("/cancels")
|
||||||
.reply(200, createStandaloneCancelsResponse());
|
.reply(200, createStandaloneCancelsResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.cancelsStandalone(request);
|
const result = await checkout.cancelsStandalone(request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should perform a captures request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform a captures request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createCapturesRequest();
|
const request = createCapturesRequest();
|
||||||
scope.post(`/payments/${paymentPspReference}/captures`)
|
scope.post(`/payments/${paymentPspReference}/captures`)
|
||||||
.reply(200, createCapturesResponse());
|
.reply(200, createCapturesResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.captures(paymentPspReference, request);
|
const result = await checkout.captures(paymentPspReference, request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail to perform a captures request, isMock: %p", async (isMock): Promise<void> => {
|
test("should fail to perform a captures request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const request = createCapturesRequest();
|
const request = createCapturesRequest();
|
||||||
scope.post(`/payments/${invalidPaymentPspReference}/captures`)
|
scope.post(`/payments/${invalidPaymentPspReference}/captures`)
|
||||||
.reply(422, invalidModificationResult);
|
.reply(422, invalidModificationResult);
|
||||||
try {
|
try {
|
||||||
await modification.captures(invalidPaymentPspReference, request);
|
await checkout.captures(invalidPaymentPspReference, request);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.statusCode).toBe(422);
|
if(e instanceof HttpClientException) {
|
||||||
expect(e.message).toContain("Original pspReference required for this operation");
|
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||||
|
expect(e.message).toContain("Original pspReference required for this operation");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should perform a refunds request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform a refunds request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createRefundsRequest();
|
const request = createRefundsRequest();
|
||||||
scope.post(`/payments/${paymentPspReference}/refunds`)
|
scope.post(`/payments/${paymentPspReference}/refunds`)
|
||||||
.reply(200, createRefundsResponse());
|
.reply(200, createRefundsResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.refunds(paymentPspReference, request);
|
const result = await checkout.refunds(paymentPspReference, request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail to perform a refunds request, isMock: %p", async (isMock): Promise<void> => {
|
test("should fail to perform a refunds request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const request = createRefundsRequest();
|
const request = createRefundsRequest();
|
||||||
scope.post(`/payments/${invalidPaymentPspReference}/refunds`)
|
scope.post(`/payments/${invalidPaymentPspReference}/refunds`)
|
||||||
.reply(422, invalidModificationResult);
|
.reply(422, invalidModificationResult);
|
||||||
try {
|
try {
|
||||||
await modification.refunds(invalidPaymentPspReference, request);
|
await checkout.refunds(invalidPaymentPspReference, request);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.statusCode).toBe(422);
|
if(e instanceof HttpClientException) {
|
||||||
expect(e.message).toContain("Original pspReference required for this operation");
|
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||||
|
expect(e.message).toContain("Original pspReference required for this operation");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should perform a reversals request, isMock: %p", async (isMock): Promise<void> => {
|
test("should perform a reversals request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
const request = createReversalsRequest();
|
const request = createReversalsRequest();
|
||||||
scope.post(`/payments/${paymentPspReference}/reversals`)
|
scope.post(`/payments/${paymentPspReference}/reversals`)
|
||||||
.reply(200, createReversalsResponse());
|
.reply(200, createReversalsResponse());
|
||||||
try {
|
try {
|
||||||
const result = await modification.reversals(paymentPspReference, request);
|
const result = await checkout.reversals(paymentPspReference, request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
if(e instanceof Error) {
|
||||||
|
if(e.message) fail(e.message);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should fail to perform a reversals request, isMock: %p", async (isMock): Promise<void> => {
|
test("should fail to perform a reversals request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
const request = createReversalsRequest();
|
const request = createReversalsRequest();
|
||||||
scope.post(`/payments/${invalidPaymentPspReference}/reversals`)
|
scope.post(`/payments/${invalidPaymentPspReference}/reversals`)
|
||||||
.reply(422, invalidModificationResult);
|
.reply(422, invalidModificationResult);
|
||||||
try {
|
try {
|
||||||
await modification.reversals(invalidPaymentPspReference, request);
|
await checkout.reversals(invalidPaymentPspReference, request);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e.statusCode).toBe(422);
|
if(e instanceof HttpClientException) {
|
||||||
expect(e.message).toContain("Original pspReference required for this operation");
|
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||||
|
expect(e.message).toContain("Original pspReference required for this operation");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import authorisationTrue from "../__mocks__/notification/authorisationTrue.json";
|
import authorisationTrue from "../__mocks__/notification/authorisationTrue.json";
|
||||||
import captureTrue from "../__mocks__/notification/captureTrue.json";
|
import captureTrue from "../__mocks__/notification/captureTrue.json";
|
||||||
import captureFalse from "../__mocks__/notification/captureFalse.json";
|
import captureFalse from "../__mocks__/notification/captureFalse.json";
|
||||||
@@ -37,6 +18,7 @@ describe("Notification Test", function (): void {
|
|||||||
expect(NotificationEnum.Authorisation).toEqual(notificationRequestItem.eventCode);
|
expect(NotificationEnum.Authorisation).toEqual(notificationRequestItem.eventCode);
|
||||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
||||||
expect(notificationRequestItem.pspReference).toEqual("123456789");
|
expect(notificationRequestItem.pspReference).toEqual("123456789");
|
||||||
|
expect(notificationRequestItem.additionalData!.paymentLinkId).toEqual("ABCDEFG");
|
||||||
} else {
|
} else {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createClient } from "../__mocks__/base";
|
import { createClient } from "../__mocks__/base";
|
||||||
import Payout from "../services/payout";
|
import Payout from "../services/payout";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import StoreDetailRequest = IPayouts.StoreDetailRequest;
|
import { payouts } from "../typings";
|
||||||
import { ApiConstants } from "../constants/apiConstants";
|
import { ApiConstants } from "../constants/apiConstants";
|
||||||
|
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
const storeDetailAndSubmitThirdParty = JSON.stringify({
|
const storeDetailAndSubmitThirdParty = JSON.stringify({
|
||||||
additionalData: {
|
additionalData: {
|
||||||
fraudResultType: "GREEN",
|
fraudResultType: "GREEN",
|
||||||
@@ -50,13 +30,13 @@ const amountAndReference = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const defaultData = {
|
const defaultData = {
|
||||||
dateOfBirth: (new Date()).toISOString(),
|
dateOfBirth: new Date(),
|
||||||
nationality: "NL",
|
nationality: "NL",
|
||||||
shopperEmail: "johndoe@email.com",
|
shopperEmail: "johndoe@email.com",
|
||||||
shopperReference: "shopperReference",
|
shopperReference: "shopperReference",
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.StoreDetailRequest => ({
|
const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.StoreDetailRequest => ({
|
||||||
...defaultData,
|
...defaultData,
|
||||||
card: {
|
card: {
|
||||||
cvc: "737",
|
cvc: "737",
|
||||||
@@ -65,29 +45,29 @@ const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERC
|
|||||||
number: "4111111111111111",
|
number: "4111111111111111",
|
||||||
holderName: "John Smith"
|
holderName: "John Smith"
|
||||||
},
|
},
|
||||||
entityType: "Company",
|
entityType: payouts.StoreDetailRequest.EntityTypeEnum.Company,
|
||||||
recurring: {
|
recurring: {
|
||||||
contract: "PAYOUT"
|
contract: payouts.Recurring.ContractEnum.Payout,
|
||||||
},
|
},
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.SubmitRequest => ({
|
const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.SubmitRequest => ({
|
||||||
selectedRecurringDetailReference: "LATEST",
|
selectedRecurringDetailReference: "LATEST",
|
||||||
recurring: {
|
recurring: {
|
||||||
contract: "PAYOUT"
|
contract: payouts.Recurring.ContractEnum.Payout
|
||||||
},
|
},
|
||||||
...defaultData,
|
...defaultData,
|
||||||
...amountAndReference,
|
...amountAndReference,
|
||||||
merchantAccount,
|
merchantAccount,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): IPayouts.StoreDetailAndSubmitRequest => ({
|
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): payouts.StoreDetailAndSubmitRequest => ({
|
||||||
...amountAndReference,
|
...amountAndReference,
|
||||||
...(mockStoreDetailRequest(merchantAccount)),
|
...(mockStoreDetailRequest(merchantAccount)),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.PayoutRequest => ({
|
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.PayoutRequest => ({
|
||||||
...amountAndReference,
|
...amountAndReference,
|
||||||
...defaultData,
|
...defaultData,
|
||||||
card: {
|
card: {
|
||||||
@@ -102,7 +82,7 @@ const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!
|
|||||||
let client: Client;
|
let client: Client;
|
||||||
let clientStore: Client;
|
let clientStore: Client;
|
||||||
let clientReview: Client;
|
let clientReview: Client;
|
||||||
let payout: Payout;
|
let payoutService: Payout;
|
||||||
let scope: nock.Scope;
|
let scope: nock.Scope;
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
@@ -113,7 +93,7 @@ beforeEach((): void => {
|
|||||||
clientStore = createClient(process.env.ADYEN_STOREPAYOUT_APIKEY);
|
clientStore = createClient(process.env.ADYEN_STOREPAYOUT_APIKEY);
|
||||||
clientReview = createClient(process.env.ADYEN_REVIEWPAYOUT_APIKEY);
|
clientReview = createClient(process.env.ADYEN_REVIEWPAYOUT_APIKEY);
|
||||||
scope = nock(`${client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}`);
|
scope = nock(`${client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}`);
|
||||||
payout = new Payout(client);
|
payoutService = new Payout(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach((): void => {
|
afterEach((): void => {
|
||||||
@@ -121,60 +101,56 @@ afterEach((): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("PayoutTest", function (): void {
|
describe("PayoutTest", function (): void {
|
||||||
test.each([isCI, true])("should succeed on store detail and submit third party, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on store detail and submit third party", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
payoutService = new Payout(clientStore);
|
||||||
payout = new Payout(clientStore);
|
const request: payouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest();
|
||||||
const request: IPayouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest();
|
|
||||||
scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||||
|
|
||||||
const result = await payout.storeDetailAndSubmitThirdParty(request);
|
const result = await payoutService.storeDetailAndSubmitThirdParty(request);
|
||||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should succeed on store detail, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on store detail", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
payoutService = new Payout(clientStore);
|
||||||
payout = new Payout(clientStore);
|
|
||||||
scope.post("/storeDetail").reply(200, storeDetail);
|
scope.post("/storeDetail").reply(200, storeDetail);
|
||||||
const request: StoreDetailRequest = mockStoreDetailRequest();
|
const request: payouts.StoreDetailRequest = mockStoreDetailRequest();
|
||||||
const result = await payout.storeDetail(request);
|
const result = await payoutService.storeDetail(request);
|
||||||
|
|
||||||
expect("Success").toEqual(result.resultCode);
|
expect("Success").toEqual(result.resultCode);
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
expect(result.recurringDetailReference).toBeTruthy();
|
expect(result.recurringDetailReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should succeed on confirm third party, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on confirm third party", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
payoutService = new Payout(clientStore);
|
||||||
payout = new Payout(clientStore);
|
|
||||||
scope.post("/storeDetail").reply(200, storeDetail);
|
scope.post("/storeDetail").reply(200, storeDetail);
|
||||||
const storeRequest: StoreDetailRequest = mockStoreDetailRequest();
|
const storeRequest: payouts.StoreDetailRequest = mockStoreDetailRequest();
|
||||||
const storeResult = await payout.storeDetail(storeRequest);
|
const storeResult = await payoutService.storeDetail(storeRequest);
|
||||||
|
|
||||||
payout = new Payout(clientReview);
|
payoutService = new Payout(clientReview);
|
||||||
scope.post("/confirmThirdParty")
|
scope.post("/confirmThirdParty")
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
pspReference: "8815131762537886",
|
pspReference: "8815131762537886",
|
||||||
response: "[payout-confirm-received]"
|
response: "[payout-confirm-received]"
|
||||||
});
|
});
|
||||||
|
|
||||||
const request: IPayouts.ModifyRequest = {
|
const request: payouts.ModifyRequest = {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
originalReference: storeResult.pspReference
|
originalReference: storeResult.pspReference
|
||||||
};
|
};
|
||||||
const result = await payout.confirmThirdParty(request);
|
const result = await payoutService.confirmThirdParty(request);
|
||||||
|
|
||||||
expect(result.response).toEqual("[payout-confirm-received]");
|
expect(result.response).toEqual("[payout-confirm-received]");
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should succeed on submit third party, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on submit third party", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
payoutService = new Payout(clientStore);
|
||||||
payout = new Payout(clientStore);
|
|
||||||
scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||||
|
|
||||||
const request: IPayouts.SubmitRequest = mockSubmitRequest();
|
const request: payouts.SubmitRequest = mockSubmitRequest();
|
||||||
const result = await payout.submitThirdparty(request);
|
const result = await payoutService.submitThirdparty(request);
|
||||||
|
|
||||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
@@ -185,15 +161,14 @@ describe("PayoutTest", function (): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([false, true])("should succeed on decline third party, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on decline third party", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
payoutService = new Payout(clientStore);
|
||||||
payout = new Payout(clientStore);
|
|
||||||
scope.post("/storeDetail").reply(200, storeDetail);
|
scope.post("/storeDetail").reply(200, storeDetail);
|
||||||
const storeRequest: StoreDetailRequest = mockStoreDetailRequest();
|
const storeRequest: payouts.StoreDetailRequest = mockStoreDetailRequest();
|
||||||
const storeResult = await payout.storeDetail(storeRequest);
|
const storeResult = await payoutService.storeDetail(storeRequest);
|
||||||
|
|
||||||
payout = new Payout(clientReview);
|
payoutService = new Payout(clientReview);
|
||||||
const request: IPayouts.ModifyRequest = {
|
const request: payouts.ModifyRequest = {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
originalReference: storeResult.pspReference
|
originalReference: storeResult.pspReference
|
||||||
};
|
};
|
||||||
@@ -202,23 +177,22 @@ describe("PayoutTest", function (): void {
|
|||||||
pspReference: "8815131762537886",
|
pspReference: "8815131762537886",
|
||||||
response: "[payout-decline-received]"
|
response: "[payout-decline-received]"
|
||||||
});
|
});
|
||||||
const result = await payout.declineThirdParty(request);
|
const result = await payoutService.declineThirdParty(request);
|
||||||
|
|
||||||
expect(result.response).toEqual("[payout-decline-received]");
|
expect(result.response).toEqual("[payout-decline-received]");
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should succeed on payout, isMock: %p", async function (isMock): Promise<void> {
|
test("should succeed on payout", async function (): Promise<void> {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/payout").reply(200, {
|
scope.post("/payout").reply(200, {
|
||||||
pspReference: "8815131762537886",
|
pspReference: "8815131762537886",
|
||||||
resultCode: "Received",
|
resultCode: "Received",
|
||||||
});
|
});
|
||||||
|
|
||||||
const request = mockPayoutRequest();
|
const request = mockPayoutRequest();
|
||||||
const result = await payout.payout(request);
|
const result = await payoutService.payout(request);
|
||||||
|
|
||||||
expect(result.resultCode).toEqual("Received");
|
expect(result.resultCode).toEqual("Received");
|
||||||
expect(result.pspReference).toBeTruthy();
|
expect(result.pspReference).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createMock } from "ts-auto-mock";
|
import { createMock } from "ts-auto-mock";
|
||||||
import { createBasicAuthClient } from "../__mocks__/base";
|
import { createBasicAuthClient } from "../__mocks__/base";
|
||||||
@@ -26,10 +7,11 @@ import { Client, Platforms } from "../index";
|
|||||||
import * as A from "../typings/platformsAccount/models";
|
import * as A from "../typings/platformsAccount/models";
|
||||||
import F = IPlatformsFund;
|
import F = IPlatformsFund;
|
||||||
import N = IPlatformsNotificationConfiguration;
|
import N = IPlatformsNotificationConfiguration;
|
||||||
import H = IPlatformsHostedOnboardingPage;
|
|
||||||
import AccountHolderDetails = A.AccountHolderDetails;
|
import AccountHolderDetails = A.AccountHolderDetails;
|
||||||
import NotificationConfigurationDetails = N.NotificationConfigurationDetails;
|
import NotificationConfigurationDetails = N.NotificationConfigurationDetails;
|
||||||
import HttpClientException from "../httpClient/httpClientException";
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
import { GetOnboardingUrlRequest, GetOnboardingUrlResponse, GetPciUrlRequest, GetPciUrlResponse } from "../typings/platformsHostedOnboardingPage/models";
|
||||||
|
import { DebitAccountHolderRequest, DebitAccountHolderResponse } from "../typings/platformsFund/models";
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let platforms: Platforms;
|
let platforms: Platforms;
|
||||||
@@ -115,6 +97,7 @@ describe("Platforms Test", function () {
|
|||||||
["suspendAccountHolder", createMock<A.SuspendAccountHolderRequest>(), createMock<A.SuspendAccountHolderResponse>()],
|
["suspendAccountHolder", createMock<A.SuspendAccountHolderRequest>(), createMock<A.SuspendAccountHolderResponse>()],
|
||||||
["unSuspendAccountHolder", createMock<A.UnSuspendAccountHolderRequest>(), createMock<A.UnSuspendAccountHolderResponse>()],
|
["unSuspendAccountHolder", createMock<A.UnSuspendAccountHolderRequest>(), createMock<A.UnSuspendAccountHolderResponse>()],
|
||||||
["closeAccountHolder", createMock<A.CloseAccountHolderRequest>(), createMock<A.CloseAccountResponse>()],
|
["closeAccountHolder", createMock<A.CloseAccountHolderRequest>(), createMock<A.CloseAccountResponse>()],
|
||||||
|
["getTaxForm", createMock<A.GetTaxFormRequest>(), createMock<A.GetTaxFormResponse>()],
|
||||||
];
|
];
|
||||||
test.each(cases)(
|
test.each(cases)(
|
||||||
"should %p",
|
"should %p",
|
||||||
@@ -137,6 +120,7 @@ describe("Platforms Test", function () {
|
|||||||
["refundFundsTransfer", createMock<F.RefundFundsTransferRequest>(), createMock<F.RefundFundsTransferResponse>()],
|
["refundFundsTransfer", createMock<F.RefundFundsTransferRequest>(), createMock<F.RefundFundsTransferResponse>()],
|
||||||
["setupBeneficiary", createMock<F.SetupBeneficiaryRequest>(), createMock<F.SetupBeneficiaryResponse>()],
|
["setupBeneficiary", createMock<F.SetupBeneficiaryRequest>(), createMock<F.SetupBeneficiaryResponse>()],
|
||||||
["refundNotPaidOutTransfers", createMock<F.RefundNotPaidOutTransfersRequest>(), createMock<F.RefundNotPaidOutTransfersResponse>()],
|
["refundNotPaidOutTransfers", createMock<F.RefundNotPaidOutTransfersRequest>(), createMock<F.RefundNotPaidOutTransfersResponse>()],
|
||||||
|
["debitAccountHolder", createMock<DebitAccountHolderRequest>(), createMock<DebitAccountHolderResponse>()],
|
||||||
];
|
];
|
||||||
test.each(cases)(
|
test.each(cases)(
|
||||||
"should %p",
|
"should %p",
|
||||||
@@ -174,7 +158,8 @@ describe("Platforms Test", function () {
|
|||||||
|
|
||||||
describe("Hop", function () {
|
describe("Hop", function () {
|
||||||
const cases = [
|
const cases = [
|
||||||
["getOnboardingUrl", createMock<H.GetOnboardingUrlRequest>(), createMock<H.GetOnboardingUrlResponse>()]
|
["getOnboardingUrl", createMock<GetOnboardingUrlRequest>(), createMock<GetOnboardingUrlResponse>()],
|
||||||
|
["getPciQuestionnaireUrl", createMock<GetPciUrlRequest>(), createMock<GetPciUrlResponse>()],
|
||||||
];
|
];
|
||||||
test.each(cases)(
|
test.each(cases)(
|
||||||
"should %p",
|
"should %p",
|
||||||
@@ -243,8 +228,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
nock.restore();
|
nock.restore();
|
||||||
try {
|
try {
|
||||||
expect(accountHolder.pspReference).toBeDefined();
|
expect(accountHolder.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("should get account holder", async function() {
|
it("should get account holder", async function() {
|
||||||
@@ -254,8 +243,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: accountHolder.accountHolderCode,
|
accountHolderCode: accountHolder.accountHolderCode,
|
||||||
});
|
});
|
||||||
expect(result.accountHolderDetails.email).toEqual("random_email@example.com");
|
expect(result.accountHolderDetails.email).toEqual("random_email@example.com");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -272,8 +265,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
expect(result.accountHolderDetails!.address?.country).toEqual("BE");
|
expect(result.accountHolderDetails!.address?.country).toEqual("BE");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -286,8 +283,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
tier: 2
|
tier: 2
|
||||||
});
|
});
|
||||||
expect(result.resultCode).toEqual("Success");
|
expect(result.resultCode).toEqual("Success");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -295,8 +296,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
nock.restore();
|
nock.restore();
|
||||||
try {
|
try {
|
||||||
expect(account.pspReference).toBeDefined();
|
expect(account.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -313,8 +318,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -334,8 +343,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: account.accountHolderCode,
|
accountHolderCode: account.accountHolderCode,
|
||||||
});
|
});
|
||||||
expect(result.documentDetails![0].filename).toEqual("IDCardFront.png");
|
expect(result.documentDetails![0].filename).toEqual("IDCardFront.png");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -346,8 +359,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountCode: accountToClose.accountCode
|
accountCode: accountToClose.accountCode
|
||||||
});
|
});
|
||||||
expect(result.status).toEqual("Closed");
|
expect(result.status).toEqual("Closed");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -358,8 +375,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: accountHolderToSuspend.accountHolderCode,
|
accountHolderCode: accountHolderToSuspend.accountHolderCode,
|
||||||
});
|
});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -368,8 +389,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
try {
|
try {
|
||||||
const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode });
|
const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode });
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -382,8 +407,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
stateType: A.UpdateAccountHolderStateRequest.StateTypeEnum.Payout
|
stateType: A.UpdateAccountHolderStateRequest.StateTypeEnum.Payout
|
||||||
});
|
});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -394,12 +423,32 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: accountHolderToClose.accountHolderCode
|
accountHolderCode: accountHolderToClose.accountHolderCode
|
||||||
});
|
});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should get tax form", async function() {
|
||||||
|
nock.restore();
|
||||||
|
try {
|
||||||
|
const result = await platforms.Account.getTaxForm({
|
||||||
|
accountHolderCode: accountHolder.accountHolderCode,
|
||||||
|
formType: "1099-K",
|
||||||
|
year: 2020
|
||||||
|
});
|
||||||
|
expect(result.content).toBeDefined();
|
||||||
|
} catch (e) {
|
||||||
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("Fund", function () {
|
describe("Fund", function () {
|
||||||
@@ -410,8 +459,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: generateRandomCode()
|
accountHolderCode: generateRandomCode()
|
||||||
});
|
});
|
||||||
expect(result.balancePerAccount![0].detailBalance).toBeDefined();
|
expect(result.balancePerAccount![0].detailBalance).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -422,8 +475,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
accountHolderCode: generateRandomCode()
|
accountHolderCode: generateRandomCode()
|
||||||
});
|
});
|
||||||
expect(result.accountTransactionLists![0].transactions).toBeDefined();
|
expect(result.accountTransactionLists![0].transactions).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -440,8 +497,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
transferCode: "SUBSCRIPTION"
|
transferCode: "SUBSCRIPTION"
|
||||||
});
|
});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -455,8 +516,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({});
|
const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({});
|
||||||
const resultStr = JSON.stringify(result);
|
const resultStr = JSON.stringify(result);
|
||||||
expect(resultStr.includes("pspReference")).toBeTruthy();
|
expect(resultStr.includes("pspReference")).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -470,8 +535,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
expect(result.configurationDetails.active).toBeTruthy();
|
expect(result.configurationDetails.active).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -483,8 +552,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
notificationId: configurationID
|
notificationId: configurationID
|
||||||
});
|
});
|
||||||
expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler");
|
expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -509,8 +582,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
});
|
});
|
||||||
const accountHolderVerification = result.configurationDetails.eventConfigs.filter(event => event.eventType === "ACCOUNT_HOLDER_VERIFICATION")[0];
|
const accountHolderVerification = result.configurationDetails.eventConfigs.filter(event => event.eventType === "ACCOUNT_HOLDER_VERIFICATION")[0];
|
||||||
expect(accountHolderVerification.includeMode).toEqual("EXCLUDE");
|
expect(accountHolderVerification.includeMode).toEqual("EXCLUDE");
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -521,10 +598,14 @@ describe.skip("Platforms Test E2E", function(): void {
|
|||||||
try {
|
try {
|
||||||
const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds});
|
const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds});
|
||||||
expect(result.pspReference).toBeDefined();
|
expect(result.pspReference).toBeDefined();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
assertError(e);
|
if(e instanceof HttpClientException) {
|
||||||
}
|
assertError(e);
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createClient } from "../__mocks__/base";
|
import { createClient } from "../__mocks__/base";
|
||||||
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
||||||
@@ -24,31 +5,21 @@ import { listRecurringDetailsSuccess } from "../__mocks__/recurring/listRecurrin
|
|||||||
import { notifyShopperSuccess } from "../__mocks__/recurring/notifyShopperSuccess";
|
import { notifyShopperSuccess } from "../__mocks__/recurring/notifyShopperSuccess";
|
||||||
import RecurringService from "../services/recurring";
|
import RecurringService from "../services/recurring";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess";
|
import { recurring } from "../typings";
|
||||||
import { createPaymentsCheckoutRequest } from "./checkout.spec";
|
import {Permit} from "../typings/recurring/permit";
|
||||||
import Checkout from "../services/checkout";
|
import {CreatePermitRequest} from "../typings/recurring/createPermitRequest";
|
||||||
import { PaymentRequest } from "../typings/checkout/models";
|
import {ObjectSerializer} from "../typings/recurring/models";
|
||||||
import {
|
|
||||||
ScheduleAccountUpdaterRequest,
|
|
||||||
ScheduleAccountUpdaterResult,
|
|
||||||
DisableRequest,
|
|
||||||
RecurringDetailsRequest,
|
|
||||||
Recurring,
|
|
||||||
NotifyShopperRequest
|
|
||||||
} from "../typings/recurring/models";
|
|
||||||
|
|
||||||
const createRecurringDetailsRequest = (): RecurringDetailsRequest => {
|
const createRecurringDetailsRequest = (): recurring.RecurringDetailsRequest => {
|
||||||
return {
|
return {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
recurring: { contract: Recurring.ContractEnum.Recurring },
|
recurring: { contract: recurring.Recurring.ContractEnum.Recurring },
|
||||||
shopperReference: "shopperReference",
|
shopperReference: "shopperReference",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let recurring: RecurringService;
|
let recurringService: RecurringService;
|
||||||
let checkout: Checkout;
|
|
||||||
let scope: nock.Scope;
|
let scope: nock.Scope;
|
||||||
|
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
@@ -56,8 +27,7 @@ beforeEach((): void => {
|
|||||||
nock.activate();
|
nock.activate();
|
||||||
}
|
}
|
||||||
client = createClient();
|
client = createClient();
|
||||||
recurring = new RecurringService(client);
|
recurringService = new RecurringService(client);
|
||||||
checkout = new Checkout(client);
|
|
||||||
scope = nock(`${client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}`);
|
scope = nock(`${client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,51 +36,40 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Recurring", (): void => {
|
describe("Recurring", (): void => {
|
||||||
test.each([false, true])("should test have recurring details list, isMock: %p", async (isMock): Promise<void> => {
|
test("should list recurring details", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/listRecurringDetails")
|
scope.post("/listRecurringDetails")
|
||||||
.reply(200, listRecurringDetailsSuccess);
|
.reply(200, listRecurringDetailsSuccess);
|
||||||
|
|
||||||
const request = createRecurringDetailsRequest();
|
const request = createRecurringDetailsRequest();
|
||||||
try {
|
|
||||||
const result = await recurring.listRecurringDetails(request);
|
const result = await recurringService.listRecurringDetails(request);
|
||||||
expect(result).toBeTruthy();
|
|
||||||
} catch (e: any) {
|
expect(result).toBeTruthy();
|
||||||
fail(e.message);
|
expect(result.details?.[0].recurringDetailReference).toBe("recurringReference");
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should disable, isMock: %p", async (isMock): Promise<void> => {
|
test("should disable", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/payments")
|
|
||||||
.reply(200, paymentsSuccess);
|
|
||||||
|
|
||||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
|
||||||
const res = await checkout.payments(paymentsRequest);
|
|
||||||
|
|
||||||
scope.post("/disable")
|
scope.post("/disable")
|
||||||
.reply(200, disableSuccess);
|
.reply(200, disableSuccess);
|
||||||
|
|
||||||
const request: DisableRequest = {
|
const request: recurring.DisableRequest = {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
shopperReference: "shopperReference",
|
shopperReference: "shopperReference",
|
||||||
recurringDetailReference: res.additionalData!["recurring.recurringDetailReference"]
|
recurringDetailReference: "recurring.recurringDetailReference",
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await recurring.disable(request);
|
const result = await recurringService.disable(request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
fail(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should send pre-debit Notification, isMock %p", async (isMock): Promise<void> => {
|
test("should send pre-debit Notification", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/notifyShopper")
|
scope.post("/notifyShopper")
|
||||||
.reply(200, notifyShopperSuccess);
|
.reply(200, notifyShopperSuccess);
|
||||||
|
|
||||||
const notifyShopperRequest: NotifyShopperRequest = {
|
const notifyShopperRequest: recurring.NotifyShopperRequest = {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
shopperReference: "shopperReference",
|
shopperReference: "shopperReference",
|
||||||
storedPaymentMethodId: "8415995487234100",
|
storedPaymentMethodId: "8415995487234100",
|
||||||
@@ -124,18 +83,16 @@ describe("Recurring", (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await recurring.notifyShopper(notifyShopperRequest);
|
const result = await recurringService.notifyShopper(notifyShopperRequest);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
fail(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// TODO: register account for AccountUpdater and unmock test
|
test("should schedule account updater", async (): Promise<void> => {
|
||||||
test.each([true])("should schedule account updater, isMock: %p", async (isMock): Promise<void> => {
|
const scheduleAccountUpdaterSuccess: recurring.ScheduleAccountUpdaterResult = {
|
||||||
!isMock && nock.restore();
|
|
||||||
const scheduleAccountUpdaterSuccess: ScheduleAccountUpdaterResult = {
|
|
||||||
pspReference: "mocked_psp",
|
pspReference: "mocked_psp",
|
||||||
result: "SUCCESS"
|
result: "SUCCESS"
|
||||||
};
|
};
|
||||||
@@ -143,7 +100,7 @@ describe("Recurring", (): void => {
|
|||||||
scope.post("/scheduleAccountUpdater")
|
scope.post("/scheduleAccountUpdater")
|
||||||
.reply(200, scheduleAccountUpdaterSuccess);
|
.reply(200, scheduleAccountUpdaterSuccess);
|
||||||
|
|
||||||
const request: ScheduleAccountUpdaterRequest = {
|
const request: recurring.ScheduleAccountUpdaterRequest = {
|
||||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
reference: "ref",
|
reference: "ref",
|
||||||
card: {
|
card: {
|
||||||
@@ -155,10 +112,63 @@ describe("Recurring", (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await recurring.scheduleAccountUpdater(request);
|
const result = await recurringService.scheduleAccountUpdater(request);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
fail(e.message);
|
fail(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should do a createPermit request", async (): Promise<void> => {
|
||||||
|
const createPermitResultSuccess: recurring.CreatePermitResult = {
|
||||||
|
pspReference: "1234567890"
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.post("/createPermit")
|
||||||
|
.reply(200, createPermitResultSuccess);
|
||||||
|
|
||||||
|
const permit: Permit = {
|
||||||
|
validTillDate: new Date("2022-03-25"),
|
||||||
|
partnerId: "partnerID"
|
||||||
|
};
|
||||||
|
|
||||||
|
const request: recurring.CreatePermitRequest = {
|
||||||
|
permits: [permit],
|
||||||
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
|
shopperReference: "shopperRef",
|
||||||
|
recurringDetailReference: "recurringRef",
|
||||||
|
};
|
||||||
|
|
||||||
|
const serializedRequest: CreatePermitRequest = ObjectSerializer.serialize(request, "CreatePermitRequest");
|
||||||
|
expect(serializedRequest.permits[0].validTillDate?.toString()).toBe("2022-03-25T00:00:00.000Z");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await recurringService.createPermit(request);
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
} catch (e) {
|
||||||
|
fail(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should do a disablePermit request", async (): Promise<void> => {
|
||||||
|
const disablePermitResultSuccess: recurring.DisablePermitResult = {
|
||||||
|
pspReference: "1234567890",
|
||||||
|
status: "disabled",
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.post("/disablePermit")
|
||||||
|
.reply(200, disablePermitResultSuccess);
|
||||||
|
|
||||||
|
const request: recurring.DisablePermitRequest = {
|
||||||
|
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||||
|
token: "permitToken"
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await recurringService.disablePermit(request);
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
} catch (e) {
|
||||||
|
fail(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
255
src/__tests__/storedValue.spec.ts
Normal file
255
src/__tests__/storedValue.spec.ts
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import Client from "../client";
|
||||||
|
import {createClient} from "../__mocks__/base";
|
||||||
|
import {StoredValue} from "../services";
|
||||||
|
import { storedValue } from "../typings";
|
||||||
|
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let storedValueService: StoredValue;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}`);
|
||||||
|
storedValueService = new StoredValue(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("StoredValue", (): void => {
|
||||||
|
test("Should issue Givex card", async (): Promise<void> => {
|
||||||
|
scope.post("/issue")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"pspReference": "851564651069192J",
|
||||||
|
"resultCode": "Success",
|
||||||
|
"paymentMethod": {
|
||||||
|
"number": "7219627091701347",
|
||||||
|
"securityCode": "0140",
|
||||||
|
"type": "givex"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const issueRequest: storedValue.StoredValueIssueRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store": "YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "givex"
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const issueResponse: storedValue.StoredValueIssueResponse = await storedValueService.issue(issueRequest);
|
||||||
|
expect(issueResponse.pspReference).toEqual("851564651069192J");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should issue virtual Fiserv card", async (): Promise<void> => {
|
||||||
|
scope.post("/issue")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"pspReference": "851564651069192J",
|
||||||
|
"resultCode": "Success",
|
||||||
|
"paymentMethod": {
|
||||||
|
"number": "7219627091701347",
|
||||||
|
"securityCode": "0140",
|
||||||
|
"type": "givex"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const issueRequest: storedValue.StoredValueIssueRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store": "YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "valuelink"
|
||||||
|
},
|
||||||
|
// "giftCardPromoCode": "1324",
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const issueResponse: storedValue.StoredValueIssueResponse = await storedValueService.issue(issueRequest);
|
||||||
|
expect(issueResponse.pspReference).toEqual("851564651069192J");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should activate card", async (): Promise<void> => {
|
||||||
|
scope.post("/changeStatus")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"pspReference": "851564652149588K",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusRequest: storedValue.StoredValueStatusChangeRequest = {
|
||||||
|
"status": storedValue.StoredValueStatusChangeRequest.StatusEnum.Active,
|
||||||
|
"amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store":"YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "svs",
|
||||||
|
"number": "6006491286999921374",
|
||||||
|
"securityCode": "1111"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const changeStatusResponse: storedValue.StoredValueStatusChangeResponse = await storedValueService.changeStatus(statusRequest);
|
||||||
|
expect(changeStatusResponse.pspReference).toEqual("851564652149588K");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should deactivate card", async (): Promise<void> => {
|
||||||
|
scope.post("/changeStatus")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": 1000
|
||||||
|
},
|
||||||
|
"pspReference": "851564652149588K",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusRequest: storedValue.StoredValueStatusChangeRequest = {
|
||||||
|
"status": storedValue.StoredValueStatusChangeRequest.StatusEnum.Inactive,
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store":"YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "givex",
|
||||||
|
},
|
||||||
|
"recurringDetailReference": "7219627091701347",
|
||||||
|
"shopperReference": "YOUR_UNIQUE_SHOPPER_ID_P3fW3k9D2tvXFu6l",
|
||||||
|
"shopperInteraction": storedValue.StoredValueStatusChangeRequest.ShopperInteractionEnum.Ecommerce,
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const changeStatusResponse: storedValue.StoredValueStatusChangeResponse = await storedValueService.changeStatus(statusRequest);
|
||||||
|
expect(changeStatusResponse.pspReference).toEqual("851564652149588K");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should load funds to card", async (): Promise<void> => {
|
||||||
|
scope.post("/load")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": 30000
|
||||||
|
},
|
||||||
|
"pspReference": "851564654294247B",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadRequest: storedValue.StoredValueLoadRequest = {
|
||||||
|
"amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": 2000
|
||||||
|
},
|
||||||
|
"loadType": storedValue.StoredValueLoadRequest.LoadTypeEnum.MerchandiseReturn,
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store":"YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "svs",
|
||||||
|
"number": "6006491286999921374",
|
||||||
|
"securityCode": "1111"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadResponse: storedValue.StoredValueLoadResponse = await storedValueService.load(loadRequest);
|
||||||
|
expect(loadResponse.pspReference).toEqual("851564654294247B");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should check remaining balance of card", async (): Promise<void> => {
|
||||||
|
scope.post("/checkBalance")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 5600
|
||||||
|
},
|
||||||
|
"pspReference": "881564657480267D",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkBalanceRequest: storedValue.StoredValueBalanceCheckRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store":"YOUR_STORE_ID",
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "svs",
|
||||||
|
"number": "603628672882001915092",
|
||||||
|
"securityCode": "5754"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkBalanceResponse: storedValue.StoredValueBalanceCheckResponse = await storedValueService.checkBalance(checkBalanceRequest);
|
||||||
|
expect(checkBalanceResponse.pspReference).toEqual("881564657480267D");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should transfer full value from one card to another", async (): Promise<void> => {
|
||||||
|
scope.post("/mergeBalance")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 5600
|
||||||
|
},
|
||||||
|
"pspReference": "881564657480267D",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const mergeBalanceRequest: storedValue.StoredValueBalanceMergeRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"store":"YOUR_STORE_ID",
|
||||||
|
"sourcePaymentMethod": {
|
||||||
|
"number": "7777182708544835",
|
||||||
|
"securityCode": "2329"
|
||||||
|
},
|
||||||
|
"paymentMethod": {
|
||||||
|
"type": "valuelink",
|
||||||
|
"number": "8888182708544836",
|
||||||
|
"securityCode": "2330"
|
||||||
|
},
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const mergeBalanceResponse: storedValue.StoredValueBalanceMergeResponse = await storedValueService.mergebalance(mergeBalanceRequest);
|
||||||
|
expect(mergeBalanceResponse.pspReference).toEqual("881564657480267D");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should undo transaction on card", async (): Promise<void> => {
|
||||||
|
scope.post("/voidTransaction")
|
||||||
|
.reply(200, {
|
||||||
|
"currentBalance": {
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": 120000
|
||||||
|
},
|
||||||
|
"pspReference": "851564673300692A",
|
||||||
|
"resultCode": "Success"
|
||||||
|
});
|
||||||
|
|
||||||
|
const voidTransactionRequest: storedValue.StoredValueVoidRequest = {
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"originalReference": "851564654294247B",
|
||||||
|
"reference": "YOUR_REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
const voidTransactionResponse: storedValue.StoredValueVoidResponse = await storedValueService.voidTransaction(voidTransactionRequest);
|
||||||
|
expect(voidTransactionResponse.pspReference).toEqual("851564673300692A");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,29 +1,10 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2021 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createClient, createTerminalAPIPaymentRequest, createTerminalAPIRefundRequest } from "../__mocks__/base";
|
import { createClient, createTerminalAPIPaymentRequest, createTerminalAPIRefundRequest } from "../__mocks__/base";
|
||||||
import { asyncRes } from "../__mocks__/terminalApi/async";
|
import { asyncRes } from "../__mocks__/terminalApi/async";
|
||||||
import { syncRefund, syncRes } from "../__mocks__/terminalApi/sync";
|
import { syncRefund, syncRes, syncResEventNotification } from "../__mocks__/terminalApi/sync";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
||||||
import { TerminalApiResponse } from "../typings/terminal/models";
|
import { terminal} from "../typings";
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
let terminalCloudAPI: TerminalCloudAPI;
|
let terminalCloudAPI: TerminalCloudAPI;
|
||||||
@@ -44,10 +25,8 @@ afterEach((): void => {
|
|||||||
nock.cleanAll();
|
nock.cleanAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
describe("Terminal Cloud API", (): void => {
|
describe("Terminal Cloud API", (): void => {
|
||||||
test.each([isCI, true])("should make an async payment request, isMock: %p", async (isMock): Promise<void> => {
|
test("should make an async payment request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/async").reply(200, asyncRes);
|
scope.post("/async").reply(200, asyncRes);
|
||||||
|
|
||||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
@@ -57,34 +36,45 @@ describe("Terminal Cloud API", (): void => {
|
|||||||
expect(requestResponse).toEqual("ok");
|
expect(requestResponse).toEqual("ok");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should make a sync payment request, isMock: %p", async (isMock): Promise<void> => {
|
test("should make a sync payment request", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/sync").reply(200, syncRes);
|
scope.post("/sync").reply(200, syncRes);
|
||||||
|
|
||||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||||
|
|
||||||
expect(terminalAPIResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined();
|
expect(terminalAPIResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined();
|
||||||
expect(terminalAPIResponse.SaleToPOIResponse?.MessageHeader).toBeDefined();
|
expect(terminalAPIResponse.SaleToPOIResponse?.MessageHeader).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should make an async refund request, isMock: %p", async (isMock): Promise<void> => {
|
test("should return event notification if response contains it", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
|
scope.post("/sync").reply(200, syncResEventNotification);
|
||||||
|
|
||||||
|
const terminalAPIResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||||
|
|
||||||
|
expect(terminalAPIResponse.SaleToPOIRequest?.EventNotification).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should make an async refund request", async (): Promise<void> => {
|
||||||
scope.post("/sync").reply(200, syncRes);
|
scope.post("/sync").reply(200, syncRes);
|
||||||
|
|
||||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||||
|
|
||||||
|
const pOITransactionId = terminalAPIResponse.SaleToPOIResponse!.PaymentResponse!.POIData!.POITransactionID;
|
||||||
|
expect(pOITransactionId).toBeTruthy();
|
||||||
|
|
||||||
scope.post("/sync").reply(200, syncRefund);
|
scope.post("/sync").reply(200, syncRefund);
|
||||||
|
|
||||||
const pOITransactionId = terminalAPIResponse.SaleToPOIResponse?.PaymentResponse?.POIData!.POITransactionID;
|
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(pOITransactionId);
|
||||||
if(pOITransactionId) {
|
const id = Math.floor(Math.random() * Math.floor(10000000)).toString();
|
||||||
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(pOITransactionId);
|
terminalAPIRefundRequest.SaleToPOIRequest.MessageHeader.ServiceID = id;
|
||||||
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
const saleToAcquirerData: terminal.SaleToAcquirerData = new terminal.SaleToAcquirerData();
|
||||||
|
saleToAcquirerData.currency = "EUR";
|
||||||
|
terminalAPIRefundRequest.SaleToPOIRequest.ReversalRequest!.SaleData!.SaleToAcquirerData = saleToAcquirerData;
|
||||||
|
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
||||||
|
|
||||||
expect(terminalAPIRefundResponse.SaleToPOIResponse?.ReversalResponse).toBeDefined();
|
expect(terminalAPIRefundResponse.SaleToPOIResponse?.ReversalResponse?.Response.Result).toBe("Success");
|
||||||
} else {
|
}, 20000);
|
||||||
fail();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,28 +1,9 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2021 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import { createClient, createTerminalAPIPaymentRequest } from "../__mocks__/base";
|
import { createClient, createTerminalAPIPaymentRequest } from "../__mocks__/base";
|
||||||
import { localEncRes, wrongEncRes } from "../__mocks__/terminalApi/local";
|
import { localEncRes, wrongEncRes } from "../__mocks__/terminalApi/local";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import TerminalLocalAPI from "../services/terminalLocalAPI";
|
import TerminalLocalAPI from "../services/terminalLocalAPI";
|
||||||
import { SecurityKey, TerminalApiResponse } from "../typings/terminal/models";
|
import { terminal } from "../typings";
|
||||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
@@ -43,34 +24,30 @@ afterEach((): void => {
|
|||||||
nock.cleanAll();
|
nock.cleanAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
|
||||||
|
|
||||||
describe("Terminal Local API", (): void => {
|
describe("Terminal Local API", (): void => {
|
||||||
test.each([isCI, true])("should make a local payment, isMock: %p", async (isMock): Promise<void> => {
|
test("should make a local payment", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/").reply(200, localEncRes);
|
scope.post("/").reply(200, localEncRes);
|
||||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
|
|
||||||
const securityKey: SecurityKey = {
|
const securityKey: terminal.SecurityKey = {
|
||||||
AdyenCryptoVersion: 0,
|
AdyenCryptoVersion: 0,
|
||||||
KeyIdentifier: "CryptoKeyIdentifier12345",
|
KeyIdentifier: "CryptoKeyIdentifier12345",
|
||||||
KeyVersion: 0,
|
KeyVersion: 0,
|
||||||
Passphrase: "p@ssw0rd123456",
|
Passphrase: "p@ssw0rd123456",
|
||||||
};
|
};
|
||||||
|
|
||||||
const terminalApiResponse: TerminalApiResponse =
|
const terminalApiResponse: terminal.TerminalApiResponse =
|
||||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||||
|
|
||||||
expect(terminalApiResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined();
|
expect(terminalApiResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined();
|
||||||
expect(terminalApiResponse.SaleToPOIResponse?.MessageHeader).toBeDefined();
|
expect(terminalApiResponse.SaleToPOIResponse?.MessageHeader).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([isCI, true])("should return NexoCryptoException, isMock: %p", async (isMock: boolean): Promise<void> => {
|
test("should return NexoCryptoException", async (): Promise<void> => {
|
||||||
!isMock && nock.restore();
|
|
||||||
scope.post("/").reply(200, wrongEncRes);
|
scope.post("/").reply(200, wrongEncRes);
|
||||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||||
|
|
||||||
const securityKey: SecurityKey = {
|
const securityKey: terminal.SecurityKey = {
|
||||||
AdyenCryptoVersion: 0,
|
AdyenCryptoVersion: 0,
|
||||||
KeyIdentifier: "CryptoKeyIdentifier12345",
|
KeyIdentifier: "CryptoKeyIdentifier12345",
|
||||||
KeyVersion: 0,
|
KeyVersion: 0,
|
||||||
@@ -79,9 +56,13 @@ describe("Terminal Local API", (): void => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
expect(e instanceof NexoCryptoException);
|
if(e instanceof NexoCryptoException) {
|
||||||
expect(e.message).toEqual("Hmac validation failed");
|
expect(e.message).toEqual("Hmac validation failed");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
146
src/__tests__/terminalManagement.spec.ts
Normal file
146
src/__tests__/terminalManagement.spec.ts
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import Client from "../client";
|
||||||
|
import { createClient } from "../__mocks__/base";
|
||||||
|
import TerminalManagement from "../services/terminalManagement";
|
||||||
|
import { terminalManagement } from "../typings";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let terminalManagementService: TerminalManagement;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
scope = nock(`${client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}`);
|
||||||
|
terminalManagementService = new TerminalManagement(client);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("POS Terminal Management API", (): void => {
|
||||||
|
test("Should support /assignTerminals", async (): Promise<void> => {
|
||||||
|
scope.post("/assignTerminals")
|
||||||
|
.reply(200, {
|
||||||
|
"results": {
|
||||||
|
"P400Plus-275479597": "RemoveConfigScheduled"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const request: terminalManagement.AssignTerminalsRequest = {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||||
|
"terminals": [
|
||||||
|
"P400Plus-275479597"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: terminalManagement.AssignTerminalsResponse = await terminalManagementService.assignTerminals(request);
|
||||||
|
|
||||||
|
expect(response.results["P400Plus-275479597"]).toEqual("RemoveConfigScheduled");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should support /findTerminal", async (): Promise<void> => {
|
||||||
|
scope.post("/findTerminal")
|
||||||
|
.reply(200, {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"merchantInventory": false,
|
||||||
|
"terminal": "P400Plus-275479597"
|
||||||
|
});
|
||||||
|
const request: terminalManagement.FindTerminalRequest = {
|
||||||
|
"terminal": "P400Plus-275479597"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: terminalManagement.FindTerminalResponse = await terminalManagementService.findTerminal(request);
|
||||||
|
|
||||||
|
expect(response.terminal).toEqual("P400Plus-275479597");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should support /getStoresUnderAccount", async (): Promise<void> => {
|
||||||
|
scope.post("/getStoresUnderAccount")
|
||||||
|
.reply(200, {
|
||||||
|
"stores": [
|
||||||
|
{
|
||||||
|
"store": "YOUR_STORE",
|
||||||
|
"description": "YOUR_STORE",
|
||||||
|
"address": {
|
||||||
|
"city": "The City",
|
||||||
|
"countryCode": "NL",
|
||||||
|
"postalCode": "1234",
|
||||||
|
"streetAddress": "The Street"
|
||||||
|
},
|
||||||
|
"status": "Active",
|
||||||
|
"merchantAccountCode": "YOUR_MERCHANT_ACCOUNT"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const request: terminalManagement.GetStoresUnderAccountRequest = {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: terminalManagement.GetStoresUnderAccountResponse = await terminalManagementService.getStoresUnderAccount(request);
|
||||||
|
|
||||||
|
expect(response.stores).toHaveLength(1);
|
||||||
|
expect(response.stores![0].status).toEqual("Active");
|
||||||
|
expect(response.stores![0].address?.countryCode).toEqual("NL");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Should support /getTerminalDetails", async (): Promise<void> => {
|
||||||
|
scope.post("/getTerminalDetails")
|
||||||
|
.reply(200, {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"merchantInventory": false,
|
||||||
|
"terminal": "P400Plus-275479597",
|
||||||
|
"deviceModel": "P400Plus",
|
||||||
|
"serialNumber": "275-479-597",
|
||||||
|
"permanentTerminalId": "75479597",
|
||||||
|
"terminalStatus": "ReAssignToInventoryPending",
|
||||||
|
"firmwareVersion": "Verifone_VOS 1.57.6",
|
||||||
|
"country": "NETHERLANDS",
|
||||||
|
"dhcpEnabled": false
|
||||||
|
});
|
||||||
|
const request: terminalManagement.GetTerminalDetailsRequest = {
|
||||||
|
"terminal": "P400Plus-275479597"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: terminalManagement.GetTerminalDetailsResponse = await terminalManagementService.getTerminalDetails(request);
|
||||||
|
|
||||||
|
expect(response.deviceModel).toBe("P400Plus");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test("Should support /getTerminalsUnderAccount", async (): Promise<void> => {
|
||||||
|
scope.post("/getTerminalsUnderAccount")
|
||||||
|
.reply(200, {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT",
|
||||||
|
"merchantAccounts": [
|
||||||
|
{
|
||||||
|
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
|
||||||
|
"inStoreTerminals": [
|
||||||
|
"P400Plus-275479597"
|
||||||
|
],
|
||||||
|
"stores": [
|
||||||
|
{
|
||||||
|
"store": "YOUR_STORE",
|
||||||
|
"inStoreTerminals": [
|
||||||
|
"M400-401972715"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const request: terminalManagement.GetTerminalsUnderAccountRequest = {
|
||||||
|
"companyAccount": "YOUR_COMPANY_ACCOUNT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const response: terminalManagement.GetTerminalsUnderAccountResponse = await terminalManagementService.getTerminalsUnderAccount(request);
|
||||||
|
|
||||||
|
expect(response.merchantAccounts).toHaveLength(1);
|
||||||
|
expect(response.merchantAccounts![0].stores).toHaveLength(1);
|
||||||
|
expect(response.merchantAccounts![0].stores![0].inStoreTerminals).toEqual(["M400-401972715"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
68
src/__tests__/transfers.spec.ts
Normal file
68
src/__tests__/transfers.spec.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import nock from "nock";
|
||||||
|
import { createClient } from "../__mocks__/base";
|
||||||
|
import { transfersSuccess, getTransactionSuccess, listTransactionsSuccess } from "../__mocks__/transfers/responses";
|
||||||
|
import Client from "../client";
|
||||||
|
import { Transfers } from "../services";
|
||||||
|
import { transfer} from "../typings";
|
||||||
|
|
||||||
|
let client: Client;
|
||||||
|
let transferService: Transfers;
|
||||||
|
let scope: nock.Scope;
|
||||||
|
|
||||||
|
beforeEach((): void => {
|
||||||
|
if (!nock.isActive()) {
|
||||||
|
nock.activate();
|
||||||
|
}
|
||||||
|
client = createClient();
|
||||||
|
transferService = new Transfers(client);
|
||||||
|
scope = nock(`https://balanceplatform-api-test.adyen.com/btl/${Client.TRANSFERS_API_VERSION}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Transfers", (): void => {
|
||||||
|
test("should transfer fund", async (): Promise<void> => {
|
||||||
|
scope.post("/transfers")
|
||||||
|
.reply(200, transfersSuccess);
|
||||||
|
const request = new transfer.TransferInfo();
|
||||||
|
request.amount = { currency: "EUR", value: 1000};
|
||||||
|
request.category = transfer.TransferInfo.CategoryEnum.Bank;
|
||||||
|
request.counterparty = {
|
||||||
|
balanceAccountId: "123",
|
||||||
|
transferInstrumentId: "transfer_id",
|
||||||
|
bankAccount: {
|
||||||
|
accountHolder: {
|
||||||
|
fullName: "Wally Bizzle"
|
||||||
|
},
|
||||||
|
accountIdentification: {
|
||||||
|
iban: "NLRABO12321",
|
||||||
|
type: transfer.IbanAccountIdentification.TypeEnum.Iban
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
const response: transfer.Transfer = await transferService.transfers(request);
|
||||||
|
expect(response.id).toEqual("1W1UG35U8A9J5ZLG");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should get transaction", async (): Promise<void> => {
|
||||||
|
scope.get("/transactions/123")
|
||||||
|
.reply(200, getTransactionSuccess);
|
||||||
|
const response: transfer.Transaction = await transferService.getTransaction("123");
|
||||||
|
expect(response.id).toEqual("IZK7C25U7DYVX03Y");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should list transactions", async (): Promise<void> => {
|
||||||
|
scope.get("/transactions")
|
||||||
|
.reply(200, listTransactionsSuccess);
|
||||||
|
const response: transfer.TransactionSearchResponse = await transferService.listTransactions();
|
||||||
|
expect(response.data?.length).toEqual(3);
|
||||||
|
if(response.data && response.data?.length > 0) {
|
||||||
|
expect(response?.data[0]?.id).toEqual("1VVF0D5U66PIUIVP");
|
||||||
|
} else {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
import HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
|
import HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
|
||||||
import { version } from "../package.json";
|
import { version } from "../package.json";
|
||||||
@@ -25,6 +6,10 @@ import ClientInterface from "./httpClient/clientInterface";
|
|||||||
type ClientParametersOverload =
|
type ClientParametersOverload =
|
||||||
| { config: Config }
|
| { config: Config }
|
||||||
| { config: Config; httpClient: ClientInterface }
|
| { config: Config; httpClient: ClientInterface }
|
||||||
|
| { username: string; password: string; environment: Environment}
|
||||||
|
| { username: string; password: string; environment: Environment; httpClient: ClientInterface }
|
||||||
|
| { username: string; password: string; environment: Environment; liveEndpointUrlPrefix: string }
|
||||||
|
| { username: string; password: string; environment: Environment; liveEndpointUrlPrefix: string; httpClient: ClientInterface }
|
||||||
| { username: string; password: string; environment: Environment; applicationName: string }
|
| { username: string; password: string; environment: Environment; applicationName: string }
|
||||||
| { username: string; password: string; environment: Environment; applicationName: string; httpClient: ClientInterface }
|
| { username: string; password: string; environment: Environment; applicationName: string; httpClient: ClientInterface }
|
||||||
| { username: string; password: string; environment: Environment; applicationName: string; liveEndpointUrlPrefix: string }
|
| { username: string; password: string; environment: Environment; applicationName: string; liveEndpointUrlPrefix: string }
|
||||||
@@ -52,14 +37,18 @@ class Client {
|
|||||||
public static HPP_LIVE = "https://live.adyen.com/hpp";
|
public static HPP_LIVE = "https://live.adyen.com/hpp";
|
||||||
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
|
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
|
||||||
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
|
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
|
||||||
public static CHECKOUT_API_VERSION = "v67";
|
public static CHECKOUT_API_VERSION = "v69";
|
||||||
public static API_VERSION = "v64";
|
public static API_VERSION = "v68";
|
||||||
public static RECURRING_API_VERSION = "v49";
|
public static RECURRING_API_VERSION = "v68";
|
||||||
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";
|
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";
|
||||||
public static MARKETPAY_FUND_API_VERSION = "v6";
|
public static MARKETPAY_FUND_API_VERSION = "v6";
|
||||||
public static MARKETPAY_HOP_API_VERSION = "v6";
|
public static MARKETPAY_HOP_API_VERSION = "v6";
|
||||||
public static MARKETPAY_NOTIFICATION_API_VERSION = "v5";
|
public static MARKETPAY_NOTIFICATION_API_VERSION = "v5";
|
||||||
public static MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION = "v6";
|
public static MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION = "v6";
|
||||||
|
public static PAYMENT_API_VERSION = "v68";
|
||||||
|
public static STOREDVALUE_API_VERSION = "v46";
|
||||||
|
public static TERMINAL_MANAGEMENT_API_VERSION = "v1";
|
||||||
|
public static MANAGEMENT_API_VERSION = "v1";
|
||||||
public static LIB_NAME = "adyen-node-api-library";
|
public static LIB_NAME = "adyen-node-api-library";
|
||||||
public static LIB_VERSION: string = version;
|
public static LIB_VERSION: string = version;
|
||||||
public static CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
|
public static CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
|
||||||
@@ -69,6 +58,27 @@ class Client {
|
|||||||
public static TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com";
|
public static TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com";
|
||||||
public static TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com";
|
public static TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com";
|
||||||
public static ENDPOINT_PROTOCOL = "https://";
|
public static ENDPOINT_PROTOCOL = "https://";
|
||||||
|
public static PAYMENT_API_ENDPOINT_TEST = "https://pal-test.adyen.com/pal/servlet/Payment";
|
||||||
|
public static PAYMENT_API_ENDPOINT_LIVE = "https://pal-live.adyen.com/pal/servlet/Payment";
|
||||||
|
public static STOREDVALUE_API_ENDPOINT_TEST = "https://pal-test.adyen.com/pal/servlet/StoredValue";
|
||||||
|
public static STOREDVALUE_API_ENDPOINT_LIVE = "https://pal-live.adyen.com/pal/servlet/StoredValue";
|
||||||
|
public static TERMINAL_MANAGEMENT_API_ENDPOINT_TEST = "https://postfmapi-test.adyen.com/postfmapi/terminal";
|
||||||
|
public static TERMINAL_MANAGEMENT_API_ENDPOINT_LIVE = "https://postfmapi-live.adyen.com/postfmapi/terminal";
|
||||||
|
public static MANAGEMENT_API_ENDPOINT_TEST = "https://management-test.adyen.com";
|
||||||
|
public static MANAGEMENT_API_ENDPOINT_LIVE = "https://management-live.adyen.com";
|
||||||
|
public static BALANCE_PLATFORM_API_VERSION = "v2";
|
||||||
|
public static BALANCE_PLATFORM_API_ENDPOINT_TEST = "https://balanceplatform-api-test.adyen.com/bcl";
|
||||||
|
public static BALANCE_PLATFORM_API_ENDPOINT_LIVE = "https://balanceplatform-api-live.adyen.com/bcl";
|
||||||
|
public static LEGAL_ENTITY_MANAGEMENT_API_VERSION = "v2";
|
||||||
|
public static LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST = "https://kyc-test.adyen.com/lem";
|
||||||
|
public static LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_LIVE = "https://kyc-live.adyen.com/lem";
|
||||||
|
public static TRANSFERS_API_VERSION = "v3";
|
||||||
|
public static TRANSFERS_API_ENDPOINT_TEST = "https://balanceplatform-api-test.adyen.com/btl";
|
||||||
|
public static TRANSFERS_API_ENDPOINT_LIVE = "https://balanceplatform-api-live.adyen.com/btl";
|
||||||
|
public static DATA_PROTECTION_API_VERSION = "v1";
|
||||||
|
public static DATA_PROTECTION_API_ENDPOINT_TEST = "https://ca-test.adyen.com/ca/services/DataProtectionService";
|
||||||
|
public static DATA_PROTECTION_API_ENDPOINT_LIVE = "https://ca-live.adyen.com/ca/services/DataProtectionService";
|
||||||
|
|
||||||
|
|
||||||
private _httpClient!: ClientInterface;
|
private _httpClient!: ClientInterface;
|
||||||
public config: Config;
|
public config: Config;
|
||||||
@@ -84,10 +94,12 @@ class Client {
|
|||||||
const environment = options.environment || this.config.environment;
|
const environment = options.environment || this.config.environment;
|
||||||
if (environment) {
|
if (environment) {
|
||||||
this.setEnvironment(environment, options.liveEndpointUrlPrefix);
|
this.setEnvironment(environment, options.liveEndpointUrlPrefix);
|
||||||
if (options.username && options.password && options.applicationName) {
|
if (options.username && options.password) {
|
||||||
this.config.username = options.username;
|
this.config.username = options.username;
|
||||||
this.config.password = options.password;
|
this.config.password = options.password;
|
||||||
this.config.applicationName = options.applicationName;
|
if(options.applicationName) {
|
||||||
|
this.config.applicationName = options.applicationName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.apiKey) {
|
if (options.apiKey) {
|
||||||
@@ -107,11 +119,28 @@ class Client {
|
|||||||
this.config.hppEndpoint = Client.HPP_TEST;
|
this.config.hppEndpoint = Client.HPP_TEST;
|
||||||
this.config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
this.config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
||||||
|
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
|
||||||
|
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
|
||||||
|
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;
|
||||||
|
this.config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST;
|
||||||
|
this.config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_TEST;
|
||||||
|
this.config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_TEST;
|
||||||
} else if (environment === "LIVE") {
|
} else if (environment === "LIVE") {
|
||||||
this.config.endpoint = Client.ENDPOINT_LIVE;
|
this.config.endpoint = Client.ENDPOINT_LIVE;
|
||||||
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
|
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
|
||||||
this.config.hppEndpoint = Client.HPP_LIVE;
|
this.config.hppEndpoint = Client.HPP_LIVE;
|
||||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_LIVE;
|
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_LIVE;
|
||||||
|
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_LIVE;
|
||||||
|
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_LIVE;
|
||||||
|
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_LIVE;
|
||||||
|
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_LIVE;
|
||||||
|
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_LIVE;
|
||||||
|
this.config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_LIVE;
|
||||||
|
this.config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_LIVE;
|
||||||
|
this.config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_LIVE;
|
||||||
|
|
||||||
if (liveEndpointUrlPrefix) {
|
if (liveEndpointUrlPrefix) {
|
||||||
this.config.endpoint =
|
this.config.endpoint =
|
||||||
`${Client.ENDPOINT_PROTOCOL}${liveEndpointUrlPrefix}${Client.ENDPOINT_LIVE_SUFFIX}`;
|
`${Client.ENDPOINT_PROTOCOL}${liveEndpointUrlPrefix}${Client.ENDPOINT_LIVE_SUFFIX}`;
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ interface ConfigConstructor {
|
|||||||
checkoutEndpoint?: string;
|
checkoutEndpoint?: string;
|
||||||
terminalApiCloudEndpoint?: string;
|
terminalApiCloudEndpoint?: string;
|
||||||
terminalApiLocalEndpoint?: string;
|
terminalApiLocalEndpoint?: string;
|
||||||
|
paymentEndpoint?: string;
|
||||||
|
storedValueEndpoint?: string;
|
||||||
|
terminalManagementEndpoint?: string;
|
||||||
|
managementEndpoint?: string;
|
||||||
|
balancePlatformEndpoint?: string;
|
||||||
|
legalEntityManagementEndpoint?: string;
|
||||||
|
transfersEndpoint?: string;
|
||||||
|
dataProtectionEndpoint?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
@@ -58,6 +66,15 @@ class Config {
|
|||||||
public terminalApiCloudEndpoint?: string;
|
public terminalApiCloudEndpoint?: string;
|
||||||
public terminalApiLocalEndpoint?: string;
|
public terminalApiLocalEndpoint?: string;
|
||||||
|
|
||||||
|
public paymentEndpoint?: string;
|
||||||
|
public storedValueEndpoint?: string;
|
||||||
|
public terminalManagementEndpoint?: string;
|
||||||
|
public managementEndpoint?: string;
|
||||||
|
public balancePlatformEndpoint?: string;
|
||||||
|
public legalEntityManagementEndpoint?: string;
|
||||||
|
public transfersEndpoint?: string;
|
||||||
|
public dataProtectionEndpoint?: string;
|
||||||
|
|
||||||
public constructor(options: ConfigConstructor = {}) {
|
public constructor(options: ConfigConstructor = {}) {
|
||||||
if (options.username) this.username = options.username;
|
if (options.username) this.username = options.username;
|
||||||
if (options.password) this.password = options.password;
|
if (options.password) this.password = options.password;
|
||||||
@@ -76,6 +93,14 @@ class Config {
|
|||||||
if (options.checkoutEndpoint) this._checkoutEndpoint = options.checkoutEndpoint;
|
if (options.checkoutEndpoint) this._checkoutEndpoint = options.checkoutEndpoint;
|
||||||
if (options.terminalApiCloudEndpoint) this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
if (options.terminalApiCloudEndpoint) this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
||||||
if (options.terminalApiLocalEndpoint) this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
if (options.terminalApiLocalEndpoint) this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
||||||
|
if (options.paymentEndpoint) this.paymentEndpoint = options.paymentEndpoint;
|
||||||
|
if (options.storedValueEndpoint) this.storedValueEndpoint = options.storedValueEndpoint;
|
||||||
|
if (options.terminalManagementEndpoint) this.terminalManagementEndpoint = options.terminalManagementEndpoint;
|
||||||
|
if (options.managementEndpoint) this.managementEndpoint = options.managementEndpoint;
|
||||||
|
if (options.balancePlatformEndpoint) this.balancePlatformEndpoint = options.balancePlatformEndpoint;
|
||||||
|
if (options.legalEntityManagementEndpoint) this.legalEntityManagementEndpoint = options.legalEntityManagementEndpoint;
|
||||||
|
if (options.transfersEndpoint) this.transfersEndpoint = options.transfersEndpoint;
|
||||||
|
if (options.dataProtectionEndpoint) this.dataProtectionEndpoint = options.dataProtectionEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
|
public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { Agent, AgentOptions, request as httpsRequest } from "https";
|
|||||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||||
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { URL } from "url";
|
import { URL, URLSearchParams } from "url";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import HttpClientException from "./httpClientException";
|
import HttpClientException from "./httpClientException";
|
||||||
@@ -87,6 +87,10 @@ class HttpURLConnectionClient implements ClientInterface {
|
|||||||
requestOptions.port = url.port;
|
requestOptions.port = url.port;
|
||||||
requestOptions.path = url.pathname;
|
requestOptions.path = url.pathname;
|
||||||
|
|
||||||
|
if (requestOptions.params) {
|
||||||
|
requestOptions.path += "?" + new URLSearchParams(requestOptions.params).toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (requestOptions && requestOptions.idempotencyKey) {
|
if (requestOptions && requestOptions.idempotencyKey) {
|
||||||
requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
|
requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
|
||||||
delete requestOptions.idempotencyKey;
|
delete requestOptions.idempotencyKey;
|
||||||
@@ -195,8 +199,9 @@ class HttpURLConnectionClient implements ClientInterface {
|
|||||||
checkServerIdentity,
|
checkServerIdentity,
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${e.message}` }));
|
const message = e instanceof Error ? e.message: "undefined";
|
||||||
|
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${message}` }));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
52
src/services/balancePlaftform/accountHolders.ts
Normal file
52
src/services/balancePlaftform/accountHolders.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { AccountHolder, AccountHolderInfo, ObjectSerializer, PaginatedBalanceAccountsResponse } from "../../typings/balancePlatform/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
// @TODO PW-7013: make this change at the spec level?
|
||||||
|
export type AccountHolderUpdate = Omit<AccountHolder, "id">;
|
||||||
|
|
||||||
|
class AccountHolders extends Service {
|
||||||
|
public async create(request: AccountHolderInfo): Promise<AccountHolder> {
|
||||||
|
const resource = new BalancePlatformResource(this, "/accountHolders");
|
||||||
|
const response = await getJsonResponse<AccountHolderInfo, AccountHolder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<AccountHolder> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
|
||||||
|
const response = await getJsonResponse<string, AccountHolder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: AccountHolderUpdate): Promise<AccountHolder> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
|
||||||
|
const response = await getJsonResponse<AccountHolderUpdate, AccountHolder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AccountHolder");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listBalanceAccounts(id: string, requestOptions?: IRequest.Options): Promise<PaginatedBalanceAccountsResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/accountHolders/${id}/balanceAccounts`);
|
||||||
|
const response = await getJsonResponse<string, PaginatedBalanceAccountsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaginatedBalanceAccountsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AccountHolders;
|
||||||
103
src/services/balancePlaftform/balanceAccounts.ts
Normal file
103
src/services/balancePlaftform/balanceAccounts.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { BalanceAccount, BalanceAccountInfo, BalanceAccountUpdateRequest, BalanceSweepConfigurationsResponse, ObjectSerializer, PaginatedPaymentInstrumentsResponse, SweepConfigurationV2 } from "../../typings/balancePlatform/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
// @TODO PW-7013: make this change at the spec level?
|
||||||
|
export type SweepConfigurationV2Create = Omit<SweepConfigurationV2, "id">;
|
||||||
|
export type SweepConfigurationV2Update = Partial<SweepConfigurationV2>;
|
||||||
|
|
||||||
|
class BalanceAccounts extends Service {
|
||||||
|
public async create(request: BalanceAccountInfo): Promise<BalanceAccount> {
|
||||||
|
const resource = new BalancePlatformResource(this, "/balanceAccounts");
|
||||||
|
const response = await getJsonResponse<BalanceAccountInfo, BalanceAccount>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listSweeps(balanceAccountId: string, requestOptions?: IRequest.Options): Promise<BalanceSweepConfigurationsResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
|
||||||
|
const response = await getJsonResponse<string, BalanceSweepConfigurationsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BalanceSweepConfigurationsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async createSweep(balanceAccountId: string, request: SweepConfigurationV2Create): Promise<SweepConfigurationV2> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
|
||||||
|
const response = await getJsonResponse<SweepConfigurationV2Create, SweepConfigurationV2>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteSweep(balanceAccountId: string, sweepId: string): Promise<void> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||||
|
await getJsonResponse<string, string>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieveSweep(balanceAccountId: string, sweepId: string): Promise<SweepConfigurationV2> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||||
|
const response = await getJsonResponse<string, SweepConfigurationV2>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updateSweep(balanceAccountId: string, sweepId: string, request: SweepConfigurationV2Update): Promise<SweepConfigurationV2> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
|
||||||
|
const response = await getJsonResponse<SweepConfigurationV2Update, SweepConfigurationV2>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<BalanceAccount> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
|
||||||
|
const response = await getJsonResponse<string, BalanceAccount>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: BalanceAccountUpdateRequest): Promise<BalanceAccount> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
|
||||||
|
const response = await getJsonResponse<BalanceAccountUpdateRequest, BalanceAccount>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BalanceAccount");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listPaymentInstruments(id: string, requestOptions?: IRequest.Options): Promise<PaginatedPaymentInstrumentsResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}/paymentInstruments`);
|
||||||
|
const response = await getJsonResponse<string, PaginatedPaymentInstrumentsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaginatedPaymentInstrumentsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BalanceAccounts;
|
||||||
29
src/services/balancePlaftform/general.ts
Normal file
29
src/services/balancePlaftform/general.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { BalancePlatform, ObjectSerializer, PaginatedAccountHoldersResponse } from "../../typings/balancePlatform/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
class General extends Service {
|
||||||
|
public async retrieve(id: string): Promise<BalancePlatform> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}`);
|
||||||
|
const response = await getJsonResponse<string, BalancePlatform>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BalancePlatform");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listAccountHolders(id: string, requestOptions?: IRequest.Options): Promise<PaginatedAccountHoldersResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}/accountHolders`);
|
||||||
|
const response = await getJsonResponse<string, PaginatedAccountHoldersResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaginatedAccountHoldersResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default General;
|
||||||
39
src/services/balancePlaftform/paymentInstrumentGroups.ts
Normal file
39
src/services/balancePlaftform/paymentInstrumentGroups.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ObjectSerializer, PaymentInstrumentGroup, PaymentInstrumentGroupInfo, TransactionRulesResponse } from "../../typings/balancePlatform/models";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
class PaymentInstrumentGroups extends Service {
|
||||||
|
public async create(request: PaymentInstrumentGroupInfo): Promise<PaymentInstrumentGroup> {
|
||||||
|
const resource = new BalancePlatformResource(this, "/paymentInstrumentGroups");
|
||||||
|
const response = await getJsonResponse<PaymentInstrumentGroupInfo, PaymentInstrumentGroup>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<PaymentInstrumentGroup> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}`);
|
||||||
|
const response = await getJsonResponse<string, PaymentInstrumentGroup>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}/transactionRules`);
|
||||||
|
const response = await getJsonResponse<string, TransactionRulesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PaymentInstrumentGroups;
|
||||||
|
|
||||||
48
src/services/balancePlaftform/paymentInstruments.ts
Normal file
48
src/services/balancePlaftform/paymentInstruments.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ObjectSerializer, PaymentInstrument, PaymentInstrumentInfo, PaymentInstrumentUpdateRequest, TransactionRulesResponse } from "../../typings/balancePlatform/models";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
class PaymentInstruments extends Service {
|
||||||
|
public async create(request: PaymentInstrumentInfo): Promise<PaymentInstrument> {
|
||||||
|
const resource = new BalancePlatformResource(this, "/paymentInstruments");
|
||||||
|
const response = await getJsonResponse<PaymentInstrumentInfo, PaymentInstrument>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<PaymentInstrument> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
|
||||||
|
const response = await getJsonResponse<string, PaymentInstrument>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: PaymentInstrumentUpdateRequest): Promise<PaymentInstrument> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
|
||||||
|
const response = await getJsonResponse<PaymentInstrumentUpdateRequest, PaymentInstrument>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}/transactionRules`);
|
||||||
|
const response = await getJsonResponse<string, TransactionRulesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PaymentInstruments;
|
||||||
50
src/services/balancePlaftform/transactionRules.ts
Normal file
50
src/services/balancePlaftform/transactionRules.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ObjectSerializer, TransactionRule, TransactionRuleInfo, TransactionRuleResponse } from "../../typings/balancePlatform/models";
|
||||||
|
import BalancePlatformResource from "../resource/balancePlaftformResource";
|
||||||
|
|
||||||
|
// @TODO PW-7013: make this change at the spec level?
|
||||||
|
export type TransactionRuleInfoUpdate = Partial<TransactionRuleInfo>;
|
||||||
|
|
||||||
|
class TransactionRules extends Service {
|
||||||
|
public async create(request: TransactionRuleInfo): Promise<TransactionRule> {
|
||||||
|
const resource = new BalancePlatformResource(this, "/transactionRules");
|
||||||
|
const response = await getJsonResponse<TransactionRuleInfo, TransactionRule>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||||
|
}
|
||||||
|
public async retrieve(transactionRuleId: string): Promise<TransactionRuleResponse> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||||
|
const response = await getJsonResponse<string, TransactionRuleResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRuleResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(transactionRuleId: string, request: TransactionRuleInfoUpdate): Promise<TransactionRule> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||||
|
const response = await getJsonResponse<TransactionRuleInfoUpdate, TransactionRule>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(transactionRuleId: string): Promise<TransactionRule> {
|
||||||
|
const resource = new BalancePlatformResource(this, `/transactionRules/${transactionRuleId}`);
|
||||||
|
const response = await getJsonResponse<string, TransactionRule>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransactionRule");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TransactionRules;
|
||||||
40
src/services/balancePlatform.ts
Normal file
40
src/services/balancePlatform.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import Service from "../service";
|
||||||
|
import Client from "../client";
|
||||||
|
import AccountHolders from "./balancePlaftform/accountHolders";
|
||||||
|
import BalanceAccounts from "./balancePlaftform/balanceAccounts";
|
||||||
|
import General from "./balancePlaftform/general";
|
||||||
|
import PaymentInstruments from "./balancePlaftform/paymentInstruments";
|
||||||
|
import PaymentInstrumentGroups from "./balancePlaftform/paymentInstrumentGroups";
|
||||||
|
import TransactionRules from "./balancePlaftform/transactionRules";
|
||||||
|
|
||||||
|
class BalancePlatform extends Service {
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get General() {
|
||||||
|
return new General(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get AccountHolders() {
|
||||||
|
return new AccountHolders(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get BalanceAccounts() {
|
||||||
|
return new BalanceAccounts(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get PaymentInstruments() {
|
||||||
|
return new PaymentInstruments(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get PaymentInstrumentGroups() {
|
||||||
|
return new PaymentInstrumentGroups(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get TransactionRules() {
|
||||||
|
return new TransactionRules(this.client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BalancePlatform;
|
||||||
@@ -1,26 +1,14 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import GetCostEstimate from "./resource/binLookup/getCostEstimate";
|
import GetCostEstimate from "./resource/binLookup/getCostEstimate";
|
||||||
import Get3dsAvailability from "./resource/binLookup/get3dsAvailability";
|
import Get3dsAvailability from "./resource/binLookup/get3dsAvailability";
|
||||||
import getJsonResponse from "../helpers/getJsonResponse";
|
import getJsonResponse from "../helpers/getJsonResponse";
|
||||||
|
import {
|
||||||
|
ThreeDSAvailabilityRequest,
|
||||||
|
ThreeDSAvailabilityResponse,
|
||||||
|
CostEstimateRequest,
|
||||||
|
CostEstimateResponse,
|
||||||
|
} from "../typings/binlookup/models";
|
||||||
|
|
||||||
class BinLookup extends ApiKeyAuthenticatedService {
|
class BinLookup extends ApiKeyAuthenticatedService {
|
||||||
private readonly _get3dsAvailability: Get3dsAvailability;
|
private readonly _get3dsAvailability: Get3dsAvailability;
|
||||||
@@ -32,15 +20,15 @@ class BinLookup extends ApiKeyAuthenticatedService {
|
|||||||
this._getCostEstimate = new GetCostEstimate(this);
|
this._getCostEstimate = new GetCostEstimate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse> {
|
public get3dsAvailability(request: ThreeDSAvailabilityRequest): Promise<ThreeDSAvailabilityResponse> {
|
||||||
return getJsonResponse<IBinLookup.ThreeDSAvailabilityRequest, IBinLookup.ThreeDSAvailabilityResponse>(
|
return getJsonResponse<ThreeDSAvailabilityRequest, ThreeDSAvailabilityResponse>(
|
||||||
this._get3dsAvailability,
|
this._get3dsAvailability,
|
||||||
request
|
request
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse> {
|
public getCostEstimate(request: CostEstimateRequest): Promise<CostEstimateResponse> {
|
||||||
return getJsonResponse<IBinLookup.CostEstimateRequest, IBinLookup.CostEstimateResponse>(
|
return getJsonResponse<CostEstimateRequest, CostEstimateResponse>(
|
||||||
this._getCostEstimate,
|
this._getCostEstimate,
|
||||||
request
|
request
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||||
import Client from "../client";
|
import Client from "../client";
|
||||||
import getJsonResponse from "../helpers/getJsonResponse";
|
import getJsonResponse from "../helpers/getJsonResponse";
|
||||||
@@ -28,13 +9,19 @@ import PaymentsResult from "./resource/checkout/paymentsResult";
|
|||||||
import PaymentLinks from "./resource/checkout/paymentLinks";
|
import PaymentLinks from "./resource/checkout/paymentLinks";
|
||||||
import OriginKeys from "./resource/checkout/originKeys";
|
import OriginKeys from "./resource/checkout/originKeys";
|
||||||
import setApplicationInfo from "../helpers/setApplicationInfo";
|
import setApplicationInfo from "../helpers/setApplicationInfo";
|
||||||
|
import AmountUpdates from "./resource/checkout/amountUpdates";
|
||||||
|
import Cancels from "./resource/checkout/cancels";
|
||||||
|
import Captures from "./resource/checkout/captures";
|
||||||
|
import Refunds from "./resource/checkout/refunds";
|
||||||
|
import Reversals from "./resource/checkout/reversals";
|
||||||
|
import CancelsStandalone from "./resource/checkout/cancelsStandalone";
|
||||||
import { IRequest } from "../typings/requestOptions";
|
import { IRequest } from "../typings/requestOptions";
|
||||||
import {
|
import {
|
||||||
PaymentRequest,
|
PaymentRequest,
|
||||||
PaymentResponse,
|
PaymentResponse,
|
||||||
PaymentMethodsRequest,
|
PaymentMethodsRequest,
|
||||||
PaymentMethodsResponse,
|
PaymentMethodsResponse,
|
||||||
PaymentLinkResource,
|
PaymentLinkResponse,
|
||||||
CreatePaymentLinkRequest,
|
CreatePaymentLinkRequest,
|
||||||
DetailsRequest,
|
DetailsRequest,
|
||||||
PaymentSetupRequest,
|
PaymentSetupRequest,
|
||||||
@@ -48,13 +35,35 @@ import {
|
|||||||
CheckoutCreateOrderRequest,
|
CheckoutCreateOrderRequest,
|
||||||
CheckoutCreateOrderResponse,
|
CheckoutCreateOrderResponse,
|
||||||
CheckoutCancelOrderRequest,
|
CheckoutCancelOrderRequest,
|
||||||
CheckoutCancelOrderResponse
|
CheckoutCancelOrderResponse,
|
||||||
|
CreateCheckoutSessionRequest,
|
||||||
|
CreateCheckoutSessionResponse,
|
||||||
|
PaymentDonationRequest,
|
||||||
|
DonationResponse,
|
||||||
|
CardDetailsRequest,
|
||||||
|
CardDetailsResponse,
|
||||||
|
CreatePaymentAmountUpdateRequest,
|
||||||
|
CreatePaymentCancelRequest,
|
||||||
|
CreatePaymentCaptureRequest,
|
||||||
|
CreatePaymentRefundRequest,
|
||||||
|
CreatePaymentReversalRequest,
|
||||||
|
CreateStandalonePaymentCancelRequest,
|
||||||
|
PaymentAmountUpdateResource,
|
||||||
|
PaymentCancelResource,
|
||||||
|
PaymentCaptureResource,
|
||||||
|
PaymentRefundResource,
|
||||||
|
PaymentReversalResource,
|
||||||
|
StandalonePaymentCancelResource,
|
||||||
|
ObjectSerializer
|
||||||
} from "../typings/checkout/models";
|
} from "../typings/checkout/models";
|
||||||
|
|
||||||
import PaymentLinksId from "./resource/checkout/paymentLinksId";
|
import PaymentLinksId from "./resource/checkout/paymentLinksId";
|
||||||
import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance";
|
import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance";
|
||||||
import Orders from "./resource/checkout/orders";
|
import Orders from "./resource/checkout/orders";
|
||||||
import OrdersCancel from "./resource/checkout/ordersCancel";
|
import OrdersCancel from "./resource/checkout/ordersCancel";
|
||||||
|
import Sessions from "./resource/checkout/sessions";
|
||||||
|
import Donations from "./resource/checkout/donations";
|
||||||
|
import CardDetails from "./resource/checkout/cardDetails";
|
||||||
|
|
||||||
class Checkout extends ApiKeyAuthenticatedService {
|
class Checkout extends ApiKeyAuthenticatedService {
|
||||||
private readonly _payments: Payments;
|
private readonly _payments: Payments;
|
||||||
@@ -63,11 +72,13 @@ class Checkout extends ApiKeyAuthenticatedService {
|
|||||||
private readonly _paymentSession: PaymentSession;
|
private readonly _paymentSession: PaymentSession;
|
||||||
private readonly _paymentsResult: PaymentsResult;
|
private readonly _paymentsResult: PaymentsResult;
|
||||||
private readonly _paymentLinks: PaymentLinks;
|
private readonly _paymentLinks: PaymentLinks;
|
||||||
private readonly _paymentLinksId: PaymentLinksId;
|
|
||||||
private readonly _originKeys: OriginKeys;
|
private readonly _originKeys: OriginKeys;
|
||||||
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
|
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
|
||||||
private readonly _orders: Orders;
|
private readonly _orders: Orders;
|
||||||
private readonly _ordersCancel: OrdersCancel;
|
private readonly _ordersCancel: OrdersCancel;
|
||||||
|
private readonly _sessions: Sessions;
|
||||||
|
private readonly _donations: Donations;
|
||||||
|
private readonly _cardDetails: CardDetails;
|
||||||
|
|
||||||
public constructor(client: Client) {
|
public constructor(client: Client) {
|
||||||
super(client);
|
super(client);
|
||||||
@@ -77,105 +88,248 @@ class Checkout extends ApiKeyAuthenticatedService {
|
|||||||
this._paymentSession = new PaymentSession(this);
|
this._paymentSession = new PaymentSession(this);
|
||||||
this._paymentsResult = new PaymentsResult(this);
|
this._paymentsResult = new PaymentsResult(this);
|
||||||
this._paymentLinks = new PaymentLinks(this);
|
this._paymentLinks = new PaymentLinks(this);
|
||||||
this._paymentLinksId = new PaymentLinksId(this);
|
|
||||||
this._originKeys = new OriginKeys(this);
|
this._originKeys = new OriginKeys(this);
|
||||||
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
|
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
|
||||||
this._orders = new Orders(this);
|
this._orders = new Orders(this);
|
||||||
this._ordersCancel = new OrdersCancel(this);
|
this._ordersCancel = new OrdersCancel(this);
|
||||||
|
this._sessions = new Sessions(this);
|
||||||
|
this._donations = new Donations(this);
|
||||||
|
this._cardDetails = new CardDetails(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
// Payments
|
||||||
return getJsonResponse<PaymentRequest, PaymentResponse>(
|
|
||||||
|
public async sessions(checkoutSessionRequest: CreateCheckoutSessionRequest, requestOptions?: IRequest.Options): Promise<CreateCheckoutSessionResponse> {
|
||||||
|
const response = await getJsonResponse<CreateCheckoutSessionRequest, CreateCheckoutSessionResponse>(
|
||||||
|
this._sessions,
|
||||||
|
checkoutSessionRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateCheckoutSessionResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async paymentMethods(paymentMethodsRequest: PaymentMethodsRequest, requestOptions?: IRequest.Options): Promise<PaymentMethodsResponse> {
|
||||||
|
const response = await getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
||||||
|
this._paymentMethods,
|
||||||
|
paymentMethodsRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethodsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async payments(paymentsRequest: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||||
|
const response = await getJsonResponse<PaymentRequest, PaymentResponse>(
|
||||||
this._payments,
|
this._payments,
|
||||||
setApplicationInfo(paymentsRequest),
|
setApplicationInfo(paymentsRequest),
|
||||||
requestOptions,
|
requestOptions,
|
||||||
);
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
public paymentMethods(paymentMethodsRequest: PaymentMethodsRequest): Promise<PaymentMethodsResponse> {
|
public async paymentsDetails(paymentsDetailsRequest: DetailsRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||||
return getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
const response = await getJsonResponse<DetailsRequest, PaymentResponse>(
|
||||||
this._paymentMethods,
|
|
||||||
paymentMethodsRequest,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public paymentLinks(paymentLinkRequest: CreatePaymentLinkRequest): Promise<PaymentLinkResource> {
|
|
||||||
return getJsonResponse<CreatePaymentLinkRequest, PaymentLinkResource>(
|
|
||||||
this._paymentLinks,
|
|
||||||
paymentLinkRequest
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getPaymentLinks(linkId: string): Promise<PaymentLinkResource> {
|
|
||||||
this._paymentLinksId.id = linkId;
|
|
||||||
return getJsonResponse<Record<string, never>, PaymentLinkResource>(
|
|
||||||
this._paymentLinksId,
|
|
||||||
{},
|
|
||||||
{ method: "GET" }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public updatePaymentLinks(linkId: string, status: "expired"): Promise<PaymentLinkResource> {
|
|
||||||
this._paymentLinksId.id = linkId;
|
|
||||||
return getJsonResponse<Record<string, unknown>, PaymentLinkResource>(
|
|
||||||
this._paymentLinksId,
|
|
||||||
{ status },
|
|
||||||
{ method: "PATCH" }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public paymentsDetails(paymentsDetailsRequest: DetailsRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
|
||||||
return getJsonResponse<DetailsRequest, PaymentResponse>(
|
|
||||||
this._paymentsDetails,
|
this._paymentsDetails,
|
||||||
paymentsDetailsRequest,
|
paymentsDetailsRequest,
|
||||||
requestOptions
|
requestOptions,
|
||||||
);
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
public paymentSession(
|
public async donations(donationRequest: PaymentDonationRequest, requestOptions?: IRequest.Options): Promise<DonationResponse> {
|
||||||
|
const response = await getJsonResponse<PaymentDonationRequest, DonationResponse>(
|
||||||
|
this._donations,
|
||||||
|
donationRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "DonationResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async cardDetails(cardDetailsRequest: CardDetailsRequest, requestOptions?: IRequest.Options): Promise<CardDetailsResponse> {
|
||||||
|
const response = await getJsonResponse<CardDetailsRequest, CardDetailsResponse>(
|
||||||
|
this._cardDetails,
|
||||||
|
cardDetailsRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CardDetailsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payment Links
|
||||||
|
|
||||||
|
public async paymentLinks(paymentLinkRequest: CreatePaymentLinkRequest, requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||||
|
const response = await getJsonResponse<CreatePaymentLinkRequest, PaymentLinkResponse>(
|
||||||
|
this._paymentLinks,
|
||||||
|
paymentLinkRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getPaymentLinks(linkId: string, requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||||
|
const paymentLinksId = new PaymentLinksId(this, linkId);
|
||||||
|
const response = await getJsonResponse<Record<string, never>, PaymentLinkResponse>(
|
||||||
|
paymentLinksId,
|
||||||
|
{},
|
||||||
|
{...{ method: "GET" }, ...requestOptions},
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updatePaymentLinks(linkId: string, status: "expired", requestOptions?: IRequest.Options): Promise<PaymentLinkResponse> {
|
||||||
|
const paymentLinksId = new PaymentLinksId(this, linkId);
|
||||||
|
const response = await getJsonResponse<Record<string, unknown>, PaymentLinkResponse>(
|
||||||
|
paymentLinksId,
|
||||||
|
{ status },
|
||||||
|
{...{ method: "PATCH" }, ...requestOptions},
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentLinkResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifications
|
||||||
|
|
||||||
|
public async amountUpdates(
|
||||||
|
paymentPspReference: string,
|
||||||
|
amountUpdatesRequest: CreatePaymentAmountUpdateRequest,
|
||||||
|
requestOptions?: IRequest.Options,
|
||||||
|
): Promise<PaymentAmountUpdateResource> {
|
||||||
|
const amountUpdates = new AmountUpdates(this, paymentPspReference);
|
||||||
|
const response = await getJsonResponse<CreatePaymentAmountUpdateRequest, PaymentAmountUpdateResource>(
|
||||||
|
amountUpdates,
|
||||||
|
amountUpdatesRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentAmountUpdateResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async cancelsStandalone(
|
||||||
|
cancelsStandaloneRequest: CreateStandalonePaymentCancelRequest,
|
||||||
|
requestOptions?: IRequest.Options
|
||||||
|
): Promise<StandalonePaymentCancelResource> {
|
||||||
|
const cancelsStandalone = new CancelsStandalone(this);
|
||||||
|
const response = await getJsonResponse<CreateStandalonePaymentCancelRequest, StandalonePaymentCancelResource>(
|
||||||
|
cancelsStandalone,
|
||||||
|
cancelsStandaloneRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "StandalonePaymentCancelResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async cancels(
|
||||||
|
paymentPspReference: string,
|
||||||
|
cancelsRequest: CreatePaymentCancelRequest,
|
||||||
|
requestOptions?: IRequest.Options,
|
||||||
|
): Promise<PaymentCancelResource> {
|
||||||
|
const cancels = new Cancels(this, paymentPspReference);
|
||||||
|
const response = await getJsonResponse<CreatePaymentCancelRequest, PaymentCancelResource>(
|
||||||
|
cancels,
|
||||||
|
cancelsRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentCancelResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async captures(
|
||||||
|
paymentPspReference: string,
|
||||||
|
capturesRequest: CreatePaymentCaptureRequest,
|
||||||
|
requestOptions?: IRequest.Options
|
||||||
|
): Promise<PaymentCaptureResource> {
|
||||||
|
const captures = new Captures(this, paymentPspReference);
|
||||||
|
const response = await getJsonResponse<CreatePaymentCaptureRequest, PaymentCaptureResource>(
|
||||||
|
captures,
|
||||||
|
capturesRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentCaptureResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async refunds(
|
||||||
|
paymentPspReference: string,
|
||||||
|
refundsRequest: CreatePaymentRefundRequest,
|
||||||
|
requestOptions?: IRequest.Options
|
||||||
|
): Promise<PaymentRefundResource> {
|
||||||
|
const refunds = new Refunds(this, paymentPspReference);
|
||||||
|
const response = await getJsonResponse<CreatePaymentRefundRequest, PaymentRefundResource>(
|
||||||
|
refunds,
|
||||||
|
refundsRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentRefundResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async reversals(
|
||||||
|
paymentPspReference: string,
|
||||||
|
reversalsRequest: CreatePaymentReversalRequest,
|
||||||
|
requestOptions?: IRequest.Options
|
||||||
|
): Promise<PaymentReversalResource> {
|
||||||
|
const refunds = new Reversals(this, paymentPspReference);
|
||||||
|
const response = await getJsonResponse<CreatePaymentReversalRequest, PaymentReversalResource>(
|
||||||
|
refunds,
|
||||||
|
reversalsRequest,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentReversalResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Orders
|
||||||
|
|
||||||
|
public async paymentMethodsBalance(paymentMethodsBalanceRequest: CheckoutBalanceCheckRequest, requestOptions?: IRequest.Options): Promise<CheckoutBalanceCheckResponse> {
|
||||||
|
const response = await getJsonResponse<CheckoutBalanceCheckRequest, CheckoutBalanceCheckResponse>(
|
||||||
|
this._paymentMethodsBalance,
|
||||||
|
paymentMethodsBalanceRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CheckoutBalanceCheckResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async orders(ordersRequest: CheckoutCreateOrderRequest, requestOptions?: IRequest.Options): Promise<CheckoutCreateOrderResponse> {
|
||||||
|
const response = await getJsonResponse<CheckoutCreateOrderRequest, CheckoutCreateOrderResponse>(
|
||||||
|
this._orders,
|
||||||
|
ordersRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CheckoutCreateOrderResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ordersCancel(ordersCancelRequest: CheckoutCancelOrderRequest, requestOptions?: IRequest.Options): Promise<CheckoutCancelOrderResponse> {
|
||||||
|
const response = await getJsonResponse<CheckoutCancelOrderRequest, CheckoutCancelOrderResponse>(
|
||||||
|
this._ordersCancel,
|
||||||
|
ordersCancelRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CheckoutCancelOrderResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classic Checkout SDK
|
||||||
|
|
||||||
|
public async paymentSession(
|
||||||
paymentSessionRequest: PaymentSetupRequest,
|
paymentSessionRequest: PaymentSetupRequest,
|
||||||
requestOptions?: IRequest.Options,
|
requestOptions?: IRequest.Options,
|
||||||
): Promise<PaymentSetupResponse> {
|
): Promise<PaymentSetupResponse> {
|
||||||
return getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
const response = await getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
||||||
this._paymentSession,
|
this._paymentSession,
|
||||||
paymentSessionRequest,
|
paymentSessionRequest,
|
||||||
requestOptions,
|
requestOptions,
|
||||||
);
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentSetupResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
public paymentResult(paymentResultRequest: PaymentVerificationRequest): Promise<PaymentVerificationResponse> {
|
public async paymentResult(paymentResultRequest: PaymentVerificationRequest, requestOptions?: IRequest.Options): Promise<PaymentVerificationResponse> {
|
||||||
return getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
const response = await getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
||||||
this._paymentsResult,
|
this._paymentsResult,
|
||||||
paymentResultRequest,
|
paymentResultRequest,
|
||||||
|
requestOptions,
|
||||||
);
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentVerificationResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
public originKeys(originKeysRequest: CheckoutUtilityRequest): Promise<CheckoutUtilityResponse> {
|
//Utility
|
||||||
return getJsonResponse<CheckoutUtilityRequest, CheckoutUtilityResponse>(
|
|
||||||
|
public async originKeys(originKeysRequest: CheckoutUtilityRequest, requestOptions?: IRequest.Options): Promise<CheckoutUtilityResponse> {
|
||||||
|
const response = await getJsonResponse<CheckoutUtilityRequest, CheckoutUtilityResponse>(
|
||||||
this._originKeys,
|
this._originKeys,
|
||||||
originKeysRequest,
|
originKeysRequest,
|
||||||
|
requestOptions,
|
||||||
);
|
);
|
||||||
}
|
return ObjectSerializer.deserialize(response, "CheckoutUtilityResponse");
|
||||||
|
|
||||||
public paymentMethodsBalance(paymentMethodsBalanceRequest: CheckoutBalanceCheckRequest): Promise<CheckoutBalanceCheckResponse> {
|
|
||||||
return getJsonResponse<CheckoutBalanceCheckRequest, CheckoutBalanceCheckResponse>(
|
|
||||||
this._paymentMethodsBalance,
|
|
||||||
paymentMethodsBalanceRequest,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public orders(ordersRequest: CheckoutCreateOrderRequest): Promise<CheckoutCreateOrderResponse> {
|
|
||||||
return getJsonResponse<CheckoutCreateOrderRequest, CheckoutCreateOrderResponse>(
|
|
||||||
this._orders,
|
|
||||||
ordersRequest,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ordersCancel(ordersCancelRequest: CheckoutCancelOrderRequest): Promise<CheckoutCancelOrderResponse> {
|
|
||||||
return getJsonResponse<CheckoutCancelOrderRequest, CheckoutCancelOrderResponse>(
|
|
||||||
this._ordersCancel,
|
|
||||||
ordersCancelRequest,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
171
src/services/classicIntegration.ts
Normal file
171
src/services/classicIntegration.ts
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||||
|
import Client from "../client";
|
||||||
|
import getJsonResponse from "../helpers/getJsonResponse";
|
||||||
|
import Authorise from "./resource/payment/authorise";
|
||||||
|
import Authorise3d from "./resource/payment/authorise3d";
|
||||||
|
import Authorise3ds2 from "./resource/payment/authorise3ds2";
|
||||||
|
import GetAuthenticationResult from "./resource/payment/getAuthenticationResult";
|
||||||
|
import Retrieve3ds2Result from "./resource/payment/retrieve3ds2Result";
|
||||||
|
import Capture from "./resource/payment/capture";
|
||||||
|
import Cancel from "./resource/payment/cancel";
|
||||||
|
import Refund from "./resource/payment/refund";
|
||||||
|
import CancelOrRefund from "./resource/payment/cancelOrRefund";
|
||||||
|
import TechnicalCancel from "./resource/payment/technicalCancel";
|
||||||
|
import AdjustAuthorisation from "./resource/payment/adjustAuthorisation";
|
||||||
|
import Donate from "./resource/payment/donate";
|
||||||
|
import VoidPendingRefund from "./resource/payment/voidPendingRefund";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AdjustAuthorisationRequest,
|
||||||
|
AuthenticationResultRequest,
|
||||||
|
AuthenticationResultResponse,
|
||||||
|
CancelOrRefundRequest,
|
||||||
|
CancelRequest,
|
||||||
|
CaptureRequest,
|
||||||
|
DonationRequest,
|
||||||
|
ModificationResult,
|
||||||
|
PaymentRequest,
|
||||||
|
PaymentRequest3d,
|
||||||
|
PaymentRequest3ds2,
|
||||||
|
PaymentResult,
|
||||||
|
RefundRequest,
|
||||||
|
TechnicalCancelRequest,
|
||||||
|
ThreeDS2ResultRequest,
|
||||||
|
ThreeDS2ResultResponse,
|
||||||
|
VoidPendingRefundRequest,
|
||||||
|
} from "../typings/payments/models";
|
||||||
|
|
||||||
|
|
||||||
|
class ClassicIntegration extends ApiKeyAuthenticatedService {
|
||||||
|
private readonly _authorise;
|
||||||
|
private readonly _authorise3d;
|
||||||
|
private readonly _authorise3ds2;
|
||||||
|
private readonly _getAuthenticationResult;
|
||||||
|
private readonly _retrieve3ds2Result;
|
||||||
|
private readonly _capture;
|
||||||
|
private readonly _cancel;
|
||||||
|
private readonly _refund;
|
||||||
|
private readonly _cancelOrRefund;
|
||||||
|
private readonly _technicalCancel;
|
||||||
|
private readonly _adjustAuthorisation;
|
||||||
|
private readonly _donate;
|
||||||
|
private readonly _voidPendingRefund;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this._authorise = new Authorise(this);
|
||||||
|
this._authorise3d = new Authorise3d(this);
|
||||||
|
this._authorise3ds2 = new Authorise3ds2(this);
|
||||||
|
this._getAuthenticationResult = new GetAuthenticationResult(this);
|
||||||
|
this._retrieve3ds2Result = new Retrieve3ds2Result(this);
|
||||||
|
this._capture = new Capture(this);
|
||||||
|
this._cancel = new Cancel(this);
|
||||||
|
this._refund = new Refund(this);
|
||||||
|
this._cancelOrRefund = new CancelOrRefund(this);
|
||||||
|
this._technicalCancel = new TechnicalCancel(this);
|
||||||
|
this._adjustAuthorisation = new AdjustAuthorisation(this);
|
||||||
|
this._donate = new Donate(this);
|
||||||
|
this._voidPendingRefund = new VoidPendingRefund(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// General
|
||||||
|
|
||||||
|
public authorise(paymentRequest: PaymentRequest): Promise<PaymentResult> {
|
||||||
|
return getJsonResponse<PaymentRequest, PaymentResult>(
|
||||||
|
this._authorise,
|
||||||
|
paymentRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public authorise3d(paymentRequest3d: PaymentRequest3d): Promise<PaymentResult> {
|
||||||
|
return getJsonResponse<PaymentRequest3d, PaymentResult>(
|
||||||
|
this._authorise3d,
|
||||||
|
paymentRequest3d,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public authorise3ds2(paymentRequest3ds2: PaymentRequest3ds2): Promise<PaymentResult> {
|
||||||
|
return getJsonResponse<PaymentRequest3ds2, PaymentResult>(
|
||||||
|
this._authorise3ds2,
|
||||||
|
paymentRequest3ds2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAuthenticationResult(authenticationResultRequest: AuthenticationResultRequest): Promise<AuthenticationResultResponse> {
|
||||||
|
return getJsonResponse<AuthenticationResultRequest, AuthenticationResultResponse>(
|
||||||
|
this._getAuthenticationResult,
|
||||||
|
authenticationResultRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public retrieve3ds2Result(threeDs2ResultRequest: ThreeDS2ResultRequest): Promise<ThreeDS2ResultResponse> {
|
||||||
|
return getJsonResponse<ThreeDS2ResultRequest, ThreeDS2ResultResponse>(
|
||||||
|
this._retrieve3ds2Result,
|
||||||
|
threeDs2ResultRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifications
|
||||||
|
|
||||||
|
public capture(captureRequest: CaptureRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<CaptureRequest, ModificationResult>(
|
||||||
|
this._capture,
|
||||||
|
captureRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public cancel(cancelRequest: CancelRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<CancelRequest, ModificationResult>(
|
||||||
|
this._cancel,
|
||||||
|
cancelRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public refund(refundRequest: RefundRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<RefundRequest, ModificationResult>(
|
||||||
|
this._refund,
|
||||||
|
refundRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public cancelOrRefund(cancelOrRefundRequest: CancelOrRefundRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<CancelOrRefundRequest, ModificationResult>(
|
||||||
|
this._cancelOrRefund,
|
||||||
|
cancelOrRefundRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public technicalCancel(technicalCancelRequest: TechnicalCancelRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<TechnicalCancelRequest, ModificationResult>(
|
||||||
|
this._technicalCancel,
|
||||||
|
technicalCancelRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public adjustAuthorisation(adjustAuthorisationRequest: AdjustAuthorisationRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<AdjustAuthorisationRequest, ModificationResult>(
|
||||||
|
this._adjustAuthorisation,
|
||||||
|
adjustAuthorisationRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public donate(donationRequest: DonationRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<DonationRequest, ModificationResult>(
|
||||||
|
this._donate,
|
||||||
|
donationRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public voidPendingRefund(voidPendingRefundRequest: VoidPendingRefundRequest): Promise<ModificationResult> {
|
||||||
|
return getJsonResponse<VoidPendingRefundRequest, ModificationResult>(
|
||||||
|
this._voidPendingRefund,
|
||||||
|
voidPendingRefundRequest,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ClassicIntegration;
|
||||||
|
|
||||||
25
src/services/dataProtection.ts
Normal file
25
src/services/dataProtection.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import Client from "../client";
|
||||||
|
import getJsonResponse from "../helpers/getJsonResponse";
|
||||||
|
import Service from "../service";
|
||||||
|
import { SubjectErasureByPspReferenceRequest, SubjectErasureResponse, ObjectSerializer } from "../typings/dataProtection/models";
|
||||||
|
import DataProtectionResource from "./resource/dataProtectionresource";
|
||||||
|
import { IRequest } from "../typings/requestOptions";
|
||||||
|
|
||||||
|
class DataProtection extends Service {
|
||||||
|
private readonly _dataProtectionResource: DataProtectionResource;
|
||||||
|
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this._dataProtectionResource = new DataProtectionResource(this, "/requestSubjectErasure");
|
||||||
|
}
|
||||||
|
public async requestSubjectErasure(subjectErasureByPspReferenceRequest: SubjectErasureByPspReferenceRequest, requestOptions?: IRequest.Options): Promise<SubjectErasureResponse> {
|
||||||
|
const response = await getJsonResponse<SubjectErasureByPspReferenceRequest, SubjectErasureResponse>(
|
||||||
|
this._dataProtectionResource,
|
||||||
|
subjectErasureByPspReferenceRequest,
|
||||||
|
requestOptions,
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "SubjectErasureResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DataProtection;
|
||||||
@@ -1,27 +1,15 @@
|
|||||||
/*
|
|
||||||
* ######
|
|
||||||
* ######
|
|
||||||
* ############ ####( ###### #####. ###### ############ ############
|
|
||||||
* ############# #####( ###### #####. ###### ############# #############
|
|
||||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
||||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
||||||
* ############# ############# ############# ############# ##### ######
|
|
||||||
* ############ ############ ############# ############ ##### ######
|
|
||||||
* ######
|
|
||||||
* #############
|
|
||||||
* ############
|
|
||||||
* Adyen NodeJS API Library
|
|
||||||
* Copyright (c) 2020 Adyen B.V.
|
|
||||||
* This file is open source and available under the MIT license.
|
|
||||||
* See the LICENSE file for more info.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export { default as TerminalLocalAPI } from "./terminalLocalAPI";
|
export { default as TerminalLocalAPI } from "./terminalLocalAPI";
|
||||||
export { default as TerminalCloudAPI } from "./terminalCloudAPI";
|
export { default as TerminalCloudAPI } from "./terminalCloudAPI";
|
||||||
export { default as CheckoutAPI } from "./checkout";
|
export { default as CheckoutAPI } from "./checkout";
|
||||||
|
export { default as ClassicIntegrationAPI } from "./classicIntegration";
|
||||||
export { default as Recurring } from "./recurring";
|
export { default as Recurring } from "./recurring";
|
||||||
export { default as Modification } from "./modification";
|
|
||||||
export { default as BinLookup } from "./binLookup";
|
export { default as BinLookup } from "./binLookup";
|
||||||
export { default as Payout } from "./payout";
|
export { default as Payout } from "./payout";
|
||||||
export { default as Platforms } from "./platforms";
|
export { default as Platforms } from "./platforms";
|
||||||
|
export { default as StoredValue} from "./storedValue";
|
||||||
|
export { default as TerminalManagement} from "./terminalManagement";
|
||||||
|
export { default as Management } from "./management";
|
||||||
|
export { default as LegalEntityManagement } from "./legalEntityManagement";
|
||||||
|
export { default as Transfers } from "./transfers";
|
||||||
|
export { default as BalancePlatform } from "./balancePlatform";
|
||||||
|
export { default as DataProtection } from "./dataProtection";
|
||||||
|
|||||||
36
src/services/legalEntityManagement.ts
Normal file
36
src/services/legalEntityManagement.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import Service from "../service";
|
||||||
|
import Client from "../client";
|
||||||
|
import LegalEntities from "./legalEntityManagement/legalEntities";
|
||||||
|
import OnboardingPage from "./legalEntityManagement/hostedOnboardingPage";
|
||||||
|
import TransferInstruments from "./legalEntityManagement/transferInstruments";
|
||||||
|
import BusinessLineService from "./legalEntityManagement/businessLineService";
|
||||||
|
import Documents from "./legalEntityManagement/documents";
|
||||||
|
|
||||||
|
class LegalEntityManagement extends Service {
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get LegalEntities() {
|
||||||
|
return new LegalEntities(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get TransferInstruments() {
|
||||||
|
return new TransferInstruments(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get BusinessLineService() {
|
||||||
|
return new BusinessLineService(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Documents() {
|
||||||
|
return new Documents(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get HostedOnboardingPage() {
|
||||||
|
return new OnboardingPage(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LegalEntityManagement;
|
||||||
42
src/services/legalEntityManagement/businessLineService.ts
Normal file
42
src/services/legalEntityManagement/businessLineService.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import LegalEntityManagementResource from "../resource/legalEntityManagementResource";
|
||||||
|
import {
|
||||||
|
BusinessLine,
|
||||||
|
BusinessLineInfo, BusinessLineInfoUpdate,
|
||||||
|
ObjectSerializer
|
||||||
|
} from "../../typings/legalEntityManagement/models";
|
||||||
|
|
||||||
|
class BusinessLineService extends Service {
|
||||||
|
public async create(request: BusinessLineInfo): Promise<BusinessLine> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, "/businessLines");
|
||||||
|
const response = await getJsonResponse<BusinessLineInfo, BusinessLine>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BusinessLine");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<BusinessLine> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/businessLines/${id}`);
|
||||||
|
const response = await getJsonResponse<string, BusinessLine>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BusinessLine");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: BusinessLineInfoUpdate): Promise<BusinessLine> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/businessLines/${id}`);
|
||||||
|
const response = await getJsonResponse<BusinessLineInfoUpdate, BusinessLine>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BusinessLine");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BusinessLineService;
|
||||||
49
src/services/legalEntityManagement/documents.ts
Normal file
49
src/services/legalEntityManagement/documents.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import LegalEntityManagementResource from "../resource/legalEntityManagementResource";
|
||||||
|
import {Document, ObjectSerializer} from "../../typings/legalEntityManagement/models";
|
||||||
|
|
||||||
|
export type DocumentUpdate = Omit<Document, "id">
|
||||||
|
|
||||||
|
class Documents extends Service {
|
||||||
|
public async create(request: DocumentUpdate): Promise<Document> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, "/documents");
|
||||||
|
const response = await getJsonResponse<DocumentUpdate, Document>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Document");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<Document> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/documents/${id}`);
|
||||||
|
const response = await getJsonResponse<string, Document>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Document");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: DocumentUpdate): Promise<Document> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/documents/${id}`);
|
||||||
|
const response = await getJsonResponse<DocumentUpdate, Document>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Document");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(id: string): Promise<void> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/documents/${id}`);
|
||||||
|
await getJsonResponse<string, string>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Documents;
|
||||||
40
src/services/legalEntityManagement/hostedOnboardingPage.ts
Normal file
40
src/services/legalEntityManagement/hostedOnboardingPage.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import LegalEntityManagementResource from "../resource/legalEntityManagementResource";
|
||||||
|
import {OnboardingLinkInfo} from "../../typings/legalEntityManagement/onboardingLinkInfo";
|
||||||
|
import {OnboardingLink} from "../../typings/legalEntityManagement/onboardingLink";
|
||||||
|
import {ObjectSerializer, OnboardingTheme, OnboardingThemes} from "../../typings/legalEntityManagement/models";
|
||||||
|
|
||||||
|
class HostedOnboardingPage extends Service {
|
||||||
|
public async create(id: string, request: OnboardingLinkInfo): Promise<OnboardingLink> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/legalEntities/${id}/onboardingLinks`);
|
||||||
|
const response = await getJsonResponse<OnboardingLinkInfo, OnboardingLink>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "OnboardingLink");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listThemes(): Promise<OnboardingThemes> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, "/themes");
|
||||||
|
const response = await getJsonResponse<string, OnboardingThemes>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "OnboardingThemes");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieveTheme(id: string): Promise<OnboardingTheme> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/themes/${id}`);
|
||||||
|
const response = await getJsonResponse<string, OnboardingTheme>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "OnboardingTheme");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HostedOnboardingPage;
|
||||||
50
src/services/legalEntityManagement/legalEntities.ts
Normal file
50
src/services/legalEntityManagement/legalEntities.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import LegalEntityManagementResource from "../resource/legalEntityManagementResource";
|
||||||
|
import {LegalEntity} from "../../typings/legalEntityManagement/legalEntity";
|
||||||
|
import {LegalEntityInfo} from "../../typings/legalEntityManagement/legalEntityInfo";
|
||||||
|
import {BusinessLines, ObjectSerializer} from "../../typings/legalEntityManagement/models";
|
||||||
|
|
||||||
|
class LegalEntities extends Service {
|
||||||
|
public async create(request: LegalEntityInfo): Promise<LegalEntity> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, "/legalEntities");
|
||||||
|
const response = await getJsonResponse<LegalEntityInfo, LegalEntity>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "LegalEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<LegalEntity> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/legalEntities/${id}`);
|
||||||
|
const response = await getJsonResponse<string, LegalEntity>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "LegalEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: LegalEntityInfo): Promise<LegalEntity> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/legalEntities/${id}`);
|
||||||
|
const response = await getJsonResponse<LegalEntityInfo, LegalEntity>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "LegalEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async listBusinessLines(id: string): Promise<BusinessLines> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/legalEntities/${id}/businessLines`);
|
||||||
|
const response = await getJsonResponse<string, BusinessLines>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BusinessLines");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LegalEntities;
|
||||||
49
src/services/legalEntityManagement/transferInstruments.ts
Normal file
49
src/services/legalEntityManagement/transferInstruments.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import LegalEntityManagementResource from "../resource/legalEntityManagementResource";
|
||||||
|
import {TransferInstrumentInfo} from "../../typings/legalEntityManagement/transferInstrumentInfo";
|
||||||
|
import {TransferInstrument} from "../../typings/legalEntityManagement/transferInstrument";
|
||||||
|
import {ObjectSerializer} from "../../typings/legalEntityManagement/models";
|
||||||
|
|
||||||
|
class TransferInstruments extends Service {
|
||||||
|
public async create(request: TransferInstrumentInfo): Promise<TransferInstrument> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, "/transferInstruments");
|
||||||
|
const response = await getJsonResponse<TransferInstrumentInfo, TransferInstrument>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransferInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async retrieve(id: string): Promise<TransferInstrument> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/transferInstruments/${id}`);
|
||||||
|
const response = await getJsonResponse<string, TransferInstrument>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransferInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(id: string, request: TransferInstrumentInfo): Promise<TransferInstrument> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/transferInstruments/${id}`);
|
||||||
|
const response = await getJsonResponse<TransferInstrumentInfo, TransferInstrument>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TransferInstrument");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(id: string): Promise<void> {
|
||||||
|
const resource = new LegalEntityManagementResource(this, `/transferInstruments/${id}`);
|
||||||
|
await getJsonResponse<string, string>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TransferInstruments;
|
||||||
222
src/services/management.ts
Normal file
222
src/services/management.ts
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
import Service from "../service";
|
||||||
|
import Client from "../client";
|
||||||
|
|
||||||
|
// Deprecated classes
|
||||||
|
import MeApi from "./management/meApi";
|
||||||
|
import MerchantAccount from "./management/merchantAccount";
|
||||||
|
import MerchantAllowedOrigins from "./management/merchantAllowedOrigins";
|
||||||
|
import MerchantApiCredentials from "./management/merchantApiCredentials";
|
||||||
|
import MerchantApiKey from "./management/merchantApiKey";
|
||||||
|
import MerchantClientKey from "./management/merchantClientKey";
|
||||||
|
import MerchantPaymentMethods from "./management/merchantPaymentMethods";
|
||||||
|
import MerchantPayoutSettings from "./management/merchantPayoutSettings";
|
||||||
|
import MerchantTerminalOrders from "./management/merchantTerminalOrders";
|
||||||
|
import MerchantTerminalSettings from "./management/merchantTerminalSettings";
|
||||||
|
import MerchantUsers from "./management/merchantUsers";
|
||||||
|
import MerchantWebhooks from "./management/merchantWebhooks";
|
||||||
|
|
||||||
|
// Recommended classes
|
||||||
|
import APICredentialsCompanyLevelApi from './management/aPICredentialsCompanyLevelApi';
|
||||||
|
import APICredentialsMerchantLevelApi from './management/aPICredentialsMerchantLevelApi';
|
||||||
|
import APIKeyCompanyLevelApi from './management/aPIKeyCompanyLevelApi';
|
||||||
|
import APIKeyMerchantLevelApi from './management/aPIKeyMerchantLevelApi';
|
||||||
|
import AccountCompanyLevelApi from './management/accountCompanyLevelApi';
|
||||||
|
import AccountMerchantLevelApi from './management/accountMerchantLevelApi';
|
||||||
|
import AccountStoreLevelApi from './management/accountStoreLevelApi';
|
||||||
|
import AllowedOriginsCompanyLevelApi from './management/allowedOriginsCompanyLevelApi';
|
||||||
|
import AllowedOriginsMerchantLevelApi from './management/allowedOriginsMerchantLevelApi';
|
||||||
|
import ClientKeyCompanyLevelApi from './management/clientKeyCompanyLevelApi';
|
||||||
|
import ClientKeyMerchantLevelApi from './management/clientKeyMerchantLevelApi';
|
||||||
|
import MyAPICredentialApi from './management/myAPICredentialApi';
|
||||||
|
import PaymentMethodsMerchantLevelApi from './management/paymentMethodsMerchantLevelApi';
|
||||||
|
import PayoutSettingsMerchantLevelApi from './management/payoutSettingsMerchantLevelApi';
|
||||||
|
import TerminalActionsCompanyLevelApi from './management/terminalActionsCompanyLevelApi';
|
||||||
|
import TerminalActionsTerminalLevelApi from './management/terminalActionsTerminalLevelApi';
|
||||||
|
import TerminalOrdersCompanyLevelApi from './management/terminalOrdersCompanyLevelApi';
|
||||||
|
import TerminalOrdersMerchantLevelApi from './management/terminalOrdersMerchantLevelApi';
|
||||||
|
import TerminalSettingsCompanyLevelApi from './management/terminalSettingsCompanyLevelApi';
|
||||||
|
import TerminalSettingsMerchantLevelApi from './management/terminalSettingsMerchantLevelApi';
|
||||||
|
import TerminalSettingsStoreLevelApi from './management/terminalSettingsStoreLevelApi';
|
||||||
|
import TerminalSettingsTerminalLevelApi from './management/terminalSettingsTerminalLevelApi';
|
||||||
|
import TerminalsTerminalLevelApi from './management/terminalsTerminalLevelApi';
|
||||||
|
import UsersCompanyLevelApi from './management/usersCompanyLevelApi';
|
||||||
|
import UsersMerchantLevelApi from './management/usersMerchantLevelApi';
|
||||||
|
import WebhooksCompanyLevelApi from './management/webhooksCompanyLevelApi';
|
||||||
|
import WebhooksMerchantLevelApi from './management/webhooksMerchantLevelApi';
|
||||||
|
|
||||||
|
class Management extends Service {
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get Me() {
|
||||||
|
const meApi = new MeApi(this.client);
|
||||||
|
return meApi.Me;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantAccount() {
|
||||||
|
return new MerchantAccount(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantAllowedOrigins() {
|
||||||
|
return new MerchantAllowedOrigins(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantApiCredentials() {
|
||||||
|
return new MerchantApiCredentials(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantApiKey() {
|
||||||
|
return new MerchantApiKey(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantClientKey() {
|
||||||
|
return new MerchantClientKey(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantPaymentMethods() {
|
||||||
|
return new MerchantPaymentMethods(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantPayoutSettings() {
|
||||||
|
return new MerchantPayoutSettings(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantTerminalOrders() {
|
||||||
|
return new MerchantTerminalOrders(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantTerminalSettings() {
|
||||||
|
return new MerchantTerminalSettings(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantUsers() {
|
||||||
|
return new MerchantUsers(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public get MerchantWebhooks() {
|
||||||
|
return new MerchantWebhooks(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ## Recommended classes
|
||||||
|
|
||||||
|
public get APICredentialsCompanyLevelApi() {
|
||||||
|
return new APICredentialsCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get APICredentialsMerchantLevelApi() {
|
||||||
|
return new APICredentialsMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get APIKeyCompanyLevelApi() {
|
||||||
|
return new APIKeyCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get APIKeyMerchantLevelApi() {
|
||||||
|
return new APIKeyMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get AccountCompanyLevelApi() {
|
||||||
|
return new AccountCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get AccountMerchantLevelApi() {
|
||||||
|
return new AccountMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get AccountStoreLevelApi() {
|
||||||
|
return new AccountStoreLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get AllowedOriginsCompanyLevelApi() {
|
||||||
|
return new AllowedOriginsCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get AllowedOriginsMerchantLevelApi() {
|
||||||
|
return new AllowedOriginsMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get ClientKeyCompanyLevelApi() {
|
||||||
|
return new ClientKeyCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get ClientKeyMerchantLevelApi() {
|
||||||
|
return new ClientKeyMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get MyAPICredentialApi() {
|
||||||
|
return new MyAPICredentialApi(this.client);
|
||||||
|
}
|
||||||
|
public get PaymentMethodsMerchantLevelApi() {
|
||||||
|
return new PaymentMethodsMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get PayoutSettingsMerchantLevelApi() {
|
||||||
|
return new PayoutSettingsMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalActionsCompanyLevelApi() {
|
||||||
|
return new TerminalActionsCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalActionsTerminalLevelApi() {
|
||||||
|
return new TerminalActionsTerminalLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalOrdersCompanyLevelApi() {
|
||||||
|
return new TerminalOrdersCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalOrdersMerchantLevelApi() {
|
||||||
|
return new TerminalOrdersMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalSettingsCompanyLevelApi() {
|
||||||
|
return new TerminalSettingsCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalSettingsMerchantLevelApi() {
|
||||||
|
return new TerminalSettingsMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalSettingsStoreLevelApi() {
|
||||||
|
return new TerminalSettingsStoreLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalSettingsTerminalLevelApi() {
|
||||||
|
return new TerminalSettingsTerminalLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get TerminalsTerminalLevelApi() {
|
||||||
|
return new TerminalsTerminalLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get UsersCompanyLevelApi() {
|
||||||
|
return new UsersCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get UsersMerchantLevelApi() {
|
||||||
|
return new UsersMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get WebhooksCompanyLevelApi() {
|
||||||
|
return new WebhooksCompanyLevelApi(this.client);
|
||||||
|
}
|
||||||
|
public get WebhooksMerchantLevelApi() {
|
||||||
|
return new WebhooksMerchantLevelApi(this.client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Management;
|
||||||
95
src/services/management/aPICredentialsCompanyLevelApi.ts
Normal file
95
src/services/management/aPICredentialsCompanyLevelApi.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { CompanyApiCredential } from '../../typings/management/models';
|
||||||
|
import { CreateCompanyApiCredentialRequest } from '../../typings/management/models';
|
||||||
|
import { CreateCompanyApiCredentialResponse } from '../../typings/management/models';
|
||||||
|
import { ListCompanyApiCredentialsResponse } from '../../typings/management/models';
|
||||||
|
import { UpdateCompanyApiCredentialRequest } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class APICredentialsCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of API credentials
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
*/
|
||||||
|
public async listApiCredentials(companyId: string, requestOptions?: IRequest.Options): Promise<ListCompanyApiCredentialsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListCompanyApiCredentialsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListCompanyApiCredentialsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an API credential
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async getApiCredential(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<CompanyApiCredential> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, CompanyApiCredential>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CompanyApiCredential");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update an API credential.
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param updateCompanyApiCredentialRequest
|
||||||
|
*/
|
||||||
|
public async updateApiCredential(companyId: string, apiCredentialId: string, updateCompanyApiCredentialRequest: UpdateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CompanyApiCredential> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdateCompanyApiCredentialRequest = ObjectSerializer.serialize(updateCompanyApiCredentialRequest, "UpdateCompanyApiCredentialRequest");
|
||||||
|
const response = await getJsonResponse<UpdateCompanyApiCredentialRequest, CompanyApiCredential>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CompanyApiCredential");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an API credential.
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param createCompanyApiCredentialRequest
|
||||||
|
*/
|
||||||
|
public async createApiCredential(companyId: string, createCompanyApiCredentialRequest: CreateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CreateCompanyApiCredentialResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: CreateCompanyApiCredentialRequest = ObjectSerializer.serialize(createCompanyApiCredentialRequest, "CreateCompanyApiCredentialRequest");
|
||||||
|
const response = await getJsonResponse<CreateCompanyApiCredentialRequest, CreateCompanyApiCredentialResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateCompanyApiCredentialResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/services/management/aPICredentialsMerchantLevelApi.ts
Normal file
95
src/services/management/aPICredentialsMerchantLevelApi.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { ApiCredential } from '../../typings/management/models';
|
||||||
|
import { CreateApiCredentialResponse } from '../../typings/management/models';
|
||||||
|
import { CreateMerchantApiCredentialRequest } from '../../typings/management/models';
|
||||||
|
import { ListMerchantApiCredentialsResponse } from '../../typings/management/models';
|
||||||
|
import { UpdateMerchantApiCredentialRequest } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class APICredentialsMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of API credentials
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
*/
|
||||||
|
public async listApiCredentials(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantApiCredentialsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantApiCredentialsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an API credential
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async getApiCredential(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<ApiCredential> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ApiCredential>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update an API credential
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param updateMerchantApiCredentialRequest
|
||||||
|
*/
|
||||||
|
public async updateApiCredential(merchantId: string, apiCredentialId: string, updateMerchantApiCredentialRequest: UpdateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise<ApiCredential> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdateMerchantApiCredentialRequest = ObjectSerializer.serialize(updateMerchantApiCredentialRequest, "UpdateMerchantApiCredentialRequest");
|
||||||
|
const response = await getJsonResponse<UpdateMerchantApiCredentialRequest, ApiCredential>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an API credential
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param createMerchantApiCredentialRequest
|
||||||
|
*/
|
||||||
|
public async createApiCredential(merchantId: string, createMerchantApiCredentialRequest: CreateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CreateApiCredentialResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: CreateMerchantApiCredentialRequest = ObjectSerializer.serialize(createMerchantApiCredentialRequest, "CreateMerchantApiCredentialRequest");
|
||||||
|
const response = await getJsonResponse<CreateMerchantApiCredentialRequest, CreateApiCredentialResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/services/management/aPIKeyCompanyLevelApi.ts
Normal file
38
src/services/management/aPIKeyCompanyLevelApi.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { GenerateApiKeyResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class APIKeyCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Generate new API key
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async generateNewApiKey(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<GenerateApiKeyResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/generateApiKey"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, GenerateApiKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/services/management/aPIKeyMerchantLevelApi.ts
Normal file
38
src/services/management/aPIKeyMerchantLevelApi.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { GenerateApiKeyResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class APIKeyMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Generate new API key
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async generateNewApiKey(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<GenerateApiKeyResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateApiKey"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, GenerateApiKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/services/management/accountCompanyLevelApi.ts
Normal file
70
src/services/management/accountCompanyLevelApi.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { Company } from '../../typings/management/models';
|
||||||
|
import { ListCompanyResponse } from '../../typings/management/models';
|
||||||
|
import { ListMerchantResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class AccountCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of company accounts
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
*/
|
||||||
|
public async listCompanyAccounts(requestOptions?: IRequest.Options): Promise<ListCompanyResponse> {
|
||||||
|
const localVarPath = "/companies";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListCompanyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListCompanyResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a company account
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
*/
|
||||||
|
public async getCompanyAccount(companyId: string, requestOptions?: IRequest.Options): Promise<Company> {
|
||||||
|
const localVarPath = "/companies/{companyId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Company>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Company");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of merchant accounts
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
*/
|
||||||
|
public async listMerchantAccounts(companyId: string, requestOptions?: IRequest.Options): Promise<ListMerchantResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/merchants"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
85
src/services/management/accountMerchantLevelApi.ts
Normal file
85
src/services/management/accountMerchantLevelApi.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { CreateMerchantRequest } from '../../typings/management/models';
|
||||||
|
import { CreateMerchantResponse } from '../../typings/management/models';
|
||||||
|
import { ListMerchantResponse } from '../../typings/management/models';
|
||||||
|
import { Merchant } from '../../typings/management/models';
|
||||||
|
import { RequestActivationResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class AccountMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of merchant accounts
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
*/
|
||||||
|
public async listMerchantAccounts(requestOptions?: IRequest.Options): Promise<ListMerchantResponse> {
|
||||||
|
const localVarPath = "/merchants";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a merchant account
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async getMerchantAccount(merchantId: string, requestOptions?: IRequest.Options): Promise<Merchant> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Merchant>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Merchant");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create a merchant account
|
||||||
|
* @param createMerchantRequest
|
||||||
|
*/
|
||||||
|
public async createMerchantAccount(createMerchantRequest: CreateMerchantRequest, requestOptions?: IRequest.Options): Promise<CreateMerchantResponse> {
|
||||||
|
const localVarPath = "/merchants";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: CreateMerchantRequest = ObjectSerializer.serialize(createMerchantRequest, "CreateMerchantRequest");
|
||||||
|
const response = await getJsonResponse<CreateMerchantRequest, CreateMerchantResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateMerchantResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Request to activate a merchant account
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async requestToActivateMerchantAccount(merchantId: string, requestOptions?: IRequest.Options): Promise<RequestActivationResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/activate"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, RequestActivationResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "RequestActivationResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
160
src/services/management/accountStoreLevelApi.ts
Normal file
160
src/services/management/accountStoreLevelApi.ts
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { ListStoresResponse } from '../../typings/management/models';
|
||||||
|
import { Store } from '../../typings/management/models';
|
||||||
|
import { StoreCreationRequest } from '../../typings/management/models';
|
||||||
|
import { StoreCreationWithMerchantCodeRequest } from '../../typings/management/models';
|
||||||
|
import { UpdateStoreRequest } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class AccountStoreLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of stores
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
* @param reference The reference of the store.
|
||||||
|
*/
|
||||||
|
public async listStoresByMerchantId(merchantId: string, requestOptions?: IRequest.Options): Promise<ListStoresResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/stores"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListStoresResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListStoresResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a store
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param storeId The unique identifier of the store.
|
||||||
|
*/
|
||||||
|
public async getStore(merchantId: string, storeId: string, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/stores/{storeId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Store>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of stores
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
* @param reference The reference of the store.
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async listStores(requestOptions?: IRequest.Options): Promise<ListStoresResponse> {
|
||||||
|
const localVarPath = "/stores";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListStoresResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListStoresResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a store
|
||||||
|
* @param storeId The unique identifier of the store.
|
||||||
|
*/
|
||||||
|
public async getStoreById(storeId: string, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/stores/{storeId}"
|
||||||
|
.replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Store>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update a store
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param storeId The unique identifier of the store.
|
||||||
|
* @param updateStoreRequest
|
||||||
|
*/
|
||||||
|
public async updateStore(merchantId: string, storeId: string, updateStoreRequest: UpdateStoreRequest, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/stores/{storeId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdateStoreRequest = ObjectSerializer.serialize(updateStoreRequest, "UpdateStoreRequest");
|
||||||
|
const response = await getJsonResponse<UpdateStoreRequest, Store>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update a store
|
||||||
|
* @param storeId The unique identifier of the store.
|
||||||
|
* @param updateStoreRequest
|
||||||
|
*/
|
||||||
|
public async updateStoreById(storeId: string, updateStoreRequest: UpdateStoreRequest, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/stores/{storeId}"
|
||||||
|
.replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdateStoreRequest = ObjectSerializer.serialize(updateStoreRequest, "UpdateStoreRequest");
|
||||||
|
const response = await getJsonResponse<UpdateStoreRequest, Store>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create a store
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param storeCreationRequest
|
||||||
|
*/
|
||||||
|
public async createStoreByMerchantId(merchantId: string, storeCreationRequest: StoreCreationRequest, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/stores"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: StoreCreationRequest = ObjectSerializer.serialize(storeCreationRequest, "StoreCreationRequest");
|
||||||
|
const response = await getJsonResponse<StoreCreationRequest, Store>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create a store
|
||||||
|
* @param storeCreationWithMerchantCodeRequest
|
||||||
|
*/
|
||||||
|
public async createStore(storeCreationWithMerchantCodeRequest: StoreCreationWithMerchantCodeRequest, requestOptions?: IRequest.Options): Promise<Store> {
|
||||||
|
const localVarPath = "/stores";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: StoreCreationWithMerchantCodeRequest = ObjectSerializer.serialize(storeCreationWithMerchantCodeRequest, "StoreCreationWithMerchantCodeRequest");
|
||||||
|
const response = await getJsonResponse<StoreCreationWithMerchantCodeRequest, Store>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Store");
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/services/management/allowedOriginsCompanyLevelApi.ts
Normal file
95
src/services/management/allowedOriginsCompanyLevelApi.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { AllowedOrigin } from '../../typings/management/models';
|
||||||
|
import { AllowedOriginsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class AllowedOriginsCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Delete an allowed origin
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async deleteAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<void> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of allowed origins
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async listAllowedOrigins(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an allowed origin
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async getAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<AllowedOrigin> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOrigin>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOrigin");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an allowed origin
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param allowedOrigin
|
||||||
|
*/
|
||||||
|
public async createAllowedOrigin(companyId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: AllowedOrigin = ObjectSerializer.serialize(allowedOrigin, "AllowedOrigin");
|
||||||
|
const response = await getJsonResponse<AllowedOrigin, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/services/management/allowedOriginsMerchantLevelApi.ts
Normal file
95
src/services/management/allowedOriginsMerchantLevelApi.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { AllowedOrigin } from '../../typings/management/models';
|
||||||
|
import { AllowedOriginsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class AllowedOriginsMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Delete an allowed origin
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async deleteAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<void> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of allowed origins
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async listAllowedOrigins(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an allowed origin
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async getAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<AllowedOrigin> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOrigin>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOrigin");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an allowed origin
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
* @param allowedOrigin
|
||||||
|
*/
|
||||||
|
public async createAllowedOrigin(merchantId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: AllowedOrigin = ObjectSerializer.serialize(allowedOrigin, "AllowedOrigin");
|
||||||
|
const response = await getJsonResponse<AllowedOrigin, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/services/management/clientKeyCompanyLevelApi.ts
Normal file
38
src/services/management/clientKeyCompanyLevelApi.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { GenerateClientKeyResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class ClientKeyCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Generate new client key
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async generateNewClientKey(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<GenerateClientKeyResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/generateClientKey"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, GenerateClientKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/services/management/clientKeyMerchantLevelApi.ts
Normal file
38
src/services/management/clientKeyMerchantLevelApi.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { GenerateClientKeyResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class ClientKeyMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Generate new client key
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param apiCredentialId Unique identifier of the API credential.
|
||||||
|
*/
|
||||||
|
public async generateNewClientKey(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<GenerateClientKeyResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateClientKey"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, GenerateClientKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
71
src/services/management/meApi.ts
Normal file
71
src/services/management/meApi.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import Client from "../../client";
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import {
|
||||||
|
AllowedOrigin,
|
||||||
|
AllowedOriginsResponse,
|
||||||
|
CreateAllowedOriginRequest,
|
||||||
|
MeApiCredential
|
||||||
|
} from "../../typings/management/models";
|
||||||
|
|
||||||
|
import Me from "../resource/management/me";
|
||||||
|
|
||||||
|
class MeApi extends Service {
|
||||||
|
//Me
|
||||||
|
private readonly _retrieveMe: Me;
|
||||||
|
private readonly _allowedOrigins: Me;
|
||||||
|
|
||||||
|
|
||||||
|
public constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this._retrieveMe = new Me(this, "");
|
||||||
|
this._allowedOrigins = new Me(this, "/allowedOrigins");
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Me(): {
|
||||||
|
retrieve:() => Promise<MeApiCredential>;
|
||||||
|
createAllowedOrigin: (allowedOriginRequest: CreateAllowedOriginRequest) => Promise<AllowedOrigin>;
|
||||||
|
retrieveAllowedOrigins: () => Promise<AllowedOriginsResponse>;
|
||||||
|
retrieveAllowedOrigin: (originId: string) => Promise<AllowedOrigin>;
|
||||||
|
deleteAllowerdOrigin: (originId: string) => Promise<Record<string, unknown>>;
|
||||||
|
} {
|
||||||
|
const retrieve = () => getJsonResponse<Record<string, never>, MeApiCredential>(
|
||||||
|
this._retrieveMe,
|
||||||
|
{},
|
||||||
|
{ method: "GET"}
|
||||||
|
);
|
||||||
|
|
||||||
|
const createAllowedOrigin = (allowedOriginRequest: CreateAllowedOriginRequest) => getJsonResponse<CreateAllowedOriginRequest, AllowedOrigin>(
|
||||||
|
this._allowedOrigins,
|
||||||
|
allowedOriginRequest,
|
||||||
|
);
|
||||||
|
|
||||||
|
const retrieveAllowedOrigins = () => getJsonResponse<Record<string, never>, AllowedOriginsResponse>(
|
||||||
|
this._allowedOrigins,
|
||||||
|
{},
|
||||||
|
{ method: "GET"}
|
||||||
|
);
|
||||||
|
|
||||||
|
const retrieveAllowedOrigin = (originId: string) => {
|
||||||
|
const allowedOrigin = new Me(this, `/allowedOrigins/${originId}`);
|
||||||
|
return getJsonResponse<Record<string, never>, AllowedOrigin>(
|
||||||
|
allowedOrigin,
|
||||||
|
{},
|
||||||
|
{ method: "GET"}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteAllowerdOrigin = (originId: string) => {
|
||||||
|
const allowedOrigin = new Me(this, `/allowedOrigins/${originId}`);
|
||||||
|
return getJsonResponse<Record<string, never>, Record<string, unknown>>(
|
||||||
|
allowedOrigin,
|
||||||
|
{},
|
||||||
|
{ method: "DELETE"}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return { retrieve, createAllowedOrigin, retrieveAllowedOrigins, retrieveAllowedOrigin, deleteAllowerdOrigin };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MeApi;
|
||||||
61
src/services/management/merchantAccount.ts
Normal file
61
src/services/management/merchantAccount.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { CreateMerchantRequest, CreateMerchantResponse, ListMerchantResponse, Merchant, ObjectSerializer, RequestActivationResponse } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantAccount extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of merchant accounts
|
||||||
|
*/
|
||||||
|
public async list(requestOptions?: IRequest.Options): Promise<ListMerchantResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants`);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a merchant account
|
||||||
|
*/
|
||||||
|
public async create(request: CreateMerchantRequest): Promise<CreateMerchantResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants`);
|
||||||
|
const response = await getJsonResponse<CreateMerchantRequest, CreateMerchantResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateMerchantResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a merchant account
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string): Promise<Merchant> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}`);
|
||||||
|
const response = await getJsonResponse<string, Merchant>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Merchant");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to activate a merchant account
|
||||||
|
*/
|
||||||
|
public async activate(merchantId: string): Promise<RequestActivationResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/activate`);
|
||||||
|
const response = await getJsonResponse<string, RequestActivationResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "RequestActivationResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantAccount;
|
||||||
59
src/services/management/merchantAllowedOrigins.ts
Normal file
59
src/services/management/merchantAllowedOrigins.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { AllowedOrigin, AllowedOriginsResponse, ObjectSerializer } from "../../typings/management/models";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantAllowedOrigins extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of allowed origins
|
||||||
|
*/
|
||||||
|
public async list(merchantId: string, apiCredentialId: string): Promise<AllowedOriginsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`);
|
||||||
|
const response = await getJsonResponse<string, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an allowed origin
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, apiCredentialId: string, request: AllowedOrigin): Promise<AllowedOriginsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`);
|
||||||
|
const response = await getJsonResponse<AllowedOrigin, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an allowed origin
|
||||||
|
*/
|
||||||
|
public async delete(merchantId: string, apiCredentialId: string, originId: string): Promise<void> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an allowed origin
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, apiCredentialId: string, originId: string): Promise<AllowedOrigin> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`);
|
||||||
|
const response = await getJsonResponse<string, AllowedOrigin>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOrigin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantAllowedOrigins;
|
||||||
61
src/services/management/merchantApiCredentials.ts
Normal file
61
src/services/management/merchantApiCredentials.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ApiCredential, CreateApiCredentialResponse, CreateMerchantApiCredentialRequest, ListMerchantApiCredentialsResponse, ObjectSerializer, UpdateMerchantApiCredentialRequest } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantApiCredentials extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of API credentials
|
||||||
|
*/
|
||||||
|
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantApiCredentialsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantApiCredentialsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an API credential
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: CreateMerchantApiCredentialRequest): Promise<CreateApiCredentialResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials`);
|
||||||
|
const response = await getJsonResponse<CreateMerchantApiCredentialRequest, CreateApiCredentialResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an API credential
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, apiCredentialId: string): Promise<ApiCredential> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`);
|
||||||
|
const response = await getJsonResponse<string, ApiCredential>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an API credential
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, apiCredentialId: string, request: UpdateMerchantApiCredentialRequest): Promise<ApiCredential> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}`);
|
||||||
|
const response = await getJsonResponse<UpdateMerchantApiCredentialRequest, ApiCredential>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ApiCredential");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantApiCredentials;
|
||||||
21
src/services/management/merchantApiKey.ts
Normal file
21
src/services/management/merchantApiKey.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { GenerateApiKeyResponse, ObjectSerializer } from "../../typings/management/models";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantApiKey extends Service {
|
||||||
|
/**
|
||||||
|
* Generate new API key
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, apiCredentialId: string): Promise<GenerateApiKeyResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`);
|
||||||
|
const response = await getJsonResponse<string, GenerateApiKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantApiKey;
|
||||||
21
src/services/management/merchantClientKey.ts
Normal file
21
src/services/management/merchantClientKey.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { GenerateClientKeyResponse, ObjectSerializer } from "../../typings/management/models";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantClientKey extends Service {
|
||||||
|
/**
|
||||||
|
* Generate new client key
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, apiCredentialId: string): Promise<GenerateClientKeyResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`);
|
||||||
|
const response = await getJsonResponse<string, GenerateClientKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantClientKey;
|
||||||
61
src/services/management/merchantPaymentMethods.ts
Normal file
61
src/services/management/merchantPaymentMethods.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ObjectSerializer, PaymentMethod, PaymentMethodResponse, PaymentMethodSetupInfo, UpdatePaymentMethodInfo } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantPaymentMethods extends Service {
|
||||||
|
/**
|
||||||
|
* Get all payment methods
|
||||||
|
*/
|
||||||
|
public async listPaymentMethodSettings(merchantId: string, requestOptions?: IRequest.Options): Promise<PaymentMethodResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`);
|
||||||
|
const response = await getJsonResponse<string, PaymentMethodResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethodResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request a payment method
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: PaymentMethodSetupInfo): Promise<PaymentMethod> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings`);
|
||||||
|
const response = await getJsonResponse<PaymentMethodSetupInfo, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get payment method details
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, paymentMethodId: string): Promise<PaymentMethod> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`);
|
||||||
|
const response = await getJsonResponse<string, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a payment method
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, paymentMethodId: string, request: UpdatePaymentMethodInfo): Promise<PaymentMethod> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`);
|
||||||
|
const response = await getJsonResponse<UpdatePaymentMethodInfo, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantPaymentMethods;
|
||||||
72
src/services/management/merchantPayoutSettings.ts
Normal file
72
src/services/management/merchantPayoutSettings.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { ObjectSerializer, PayoutSettings, PayoutSettingsRequest, PayoutSettingsResponse, UpdatePayoutSettingsRequest } from "../../typings/management/models";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantPayoutSettings extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of payout settings
|
||||||
|
*/
|
||||||
|
public async listPayoutSettings(merchantId: string): Promise<PayoutSettingsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`);
|
||||||
|
const response = await getJsonResponse<string, PayoutSettingsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettingsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a payout setting
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: PayoutSettingsRequest): Promise<PayoutSettings> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings`);
|
||||||
|
const response = await getJsonResponse<PayoutSettingsRequest, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a payout setting
|
||||||
|
*/
|
||||||
|
public async delete(merchantId: string, payoutSettingsId: string): Promise<void> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a payout setting
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, payoutSettingsId: string): Promise<PayoutSettings> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||||
|
const response = await getJsonResponse<string, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a payout setting
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, payoutSettingsId: string, request: UpdatePayoutSettingsRequest): Promise<PayoutSettings> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`);
|
||||||
|
const response = await getJsonResponse<UpdatePayoutSettingsRequest, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantPayoutSettings;
|
||||||
139
src/services/management/merchantTerminalOrders.ts
Normal file
139
src/services/management/merchantTerminalOrders.ts
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { BillingEntitiesResponse, ObjectSerializer, ShippingLocation, ShippingLocationsResponse, TerminalModelsResponse, TerminalOrder, TerminalOrderRequest, TerminalOrdersResponse, TerminalProductsResponse } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantTerminalOrders extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of billing entities
|
||||||
|
*/
|
||||||
|
public async listBillingEntities(merchantId: string, requestOptions?: IRequest.Options): Promise<BillingEntitiesResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/billingEntities`);
|
||||||
|
const response = await getJsonResponse<string, BillingEntitiesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BillingEntitiesResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of shipping locations
|
||||||
|
*/
|
||||||
|
public async listShippingLocations(merchantId: string, requestOptions?: IRequest.Options): Promise<ShippingLocationsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`);
|
||||||
|
const response = await getJsonResponse<string, ShippingLocationsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocationsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shipping location
|
||||||
|
*/
|
||||||
|
public async createShippingLocation(merchantId: string, request: ShippingLocation): Promise<ShippingLocation> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/shippingLocations`);
|
||||||
|
const response = await getJsonResponse<ShippingLocation, ShippingLocation>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocation");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of terminal models
|
||||||
|
*/
|
||||||
|
public async listTerminalModels(merchantId: string): Promise<TerminalModelsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalModels`);
|
||||||
|
const response = await getJsonResponse<string, TerminalModelsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalModelsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of orders
|
||||||
|
*/
|
||||||
|
public async listTerminalOrders(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalOrdersResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrdersResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrdersResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an order
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: TerminalOrderRequest): Promise<TerminalOrder> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders`);
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an order
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, orderId: string): Promise<TerminalOrder> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an order
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, orderId: string, request: TerminalOrderRequest): Promise<TerminalOrder> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}`);
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel an order
|
||||||
|
*/
|
||||||
|
public async cancel(merchantId: string, orderId: string): Promise<TerminalOrder> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalOrders/${orderId}/cancel`);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of terminal products
|
||||||
|
*/
|
||||||
|
public async listTerminalProducts(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalProductsResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalProducts`);
|
||||||
|
const response = await getJsonResponse<string, TerminalProductsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalProductsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantTerminalOrders;
|
||||||
61
src/services/management/merchantTerminalSettings.ts
Normal file
61
src/services/management/merchantTerminalSettings.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { Logo, ObjectSerializer, TerminalSettings } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantTerminalSettings extends Service {
|
||||||
|
/**
|
||||||
|
* Get the terminal logo
|
||||||
|
*/
|
||||||
|
public async retrieveLogo(merchantId: string, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`);
|
||||||
|
const response = await getJsonResponse<string, Logo>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the terminal logo
|
||||||
|
*/
|
||||||
|
public async updateLogo(merchantId: string, request: Logo, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalLogos`);
|
||||||
|
const response = await getJsonResponse<Logo, Logo>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get terminal settings
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string): Promise<TerminalSettings> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`);
|
||||||
|
const response = await getJsonResponse<string, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update terminal settings
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, request: TerminalSettings): Promise<TerminalSettings> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/terminalSettings`);
|
||||||
|
const response = await getJsonResponse<TerminalSettings, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantTerminalSettings;
|
||||||
61
src/services/management/merchantUsers.ts
Normal file
61
src/services/management/merchantUsers.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { CreateMerchantUserRequest, CreateUserResponse, ListMerchantUsersResponse, ObjectSerializer, UpdateMerchantUserRequest, User } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantUsers extends Service {
|
||||||
|
/**
|
||||||
|
* Get a list of users
|
||||||
|
*/
|
||||||
|
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantUsersResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/users`);
|
||||||
|
const response = await getJsonResponse<string, ListMerchantUsersResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListMerchantUsersResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: CreateMerchantUserRequest): Promise<CreateUserResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/users`);
|
||||||
|
const response = await getJsonResponse<CreateMerchantUserRequest, CreateUserResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "CreateUserResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user details
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, userId: string): Promise<User> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`);
|
||||||
|
const response = await getJsonResponse<string, User>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "User");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a user
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, userId: string, request: UpdateMerchantUserRequest): Promise<User> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/users/${userId}`);
|
||||||
|
const response = await getJsonResponse<UpdateMerchantUserRequest, User>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "User");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantUsers;
|
||||||
99
src/services/management/merchantWebhooks.ts
Normal file
99
src/services/management/merchantWebhooks.ts
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
import { CreateMerchantWebhookRequest, GenerateHmacKeyResponse, ListWebhooksResponse, ObjectSerializer, TestWebhookRequest, TestWebhookResponse, UpdateMerchantWebhookRequest, Webhook } from "../../typings/management/models";
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
|
||||||
|
class MerchantWebhooks extends Service {
|
||||||
|
/**
|
||||||
|
* List all webhooks
|
||||||
|
*/
|
||||||
|
public async list(merchantId: string, requestOptions?: IRequest.Options): Promise<ListWebhooksResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`);
|
||||||
|
const response = await getJsonResponse<string, ListWebhooksResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListWebhooksResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up a webhook
|
||||||
|
*/
|
||||||
|
public async create(merchantId: string, request: CreateMerchantWebhookRequest): Promise<Webhook> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks`);
|
||||||
|
const response = await getJsonResponse<CreateMerchantWebhookRequest, Webhook>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Webhook");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a webhook
|
||||||
|
*/
|
||||||
|
public async delete(merchantId: string, webhookId: string): Promise<void> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a webhook
|
||||||
|
*/
|
||||||
|
public async retrieve(merchantId: string, webhookId: string): Promise<Webhook> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||||
|
const response = await getJsonResponse<string, Webhook>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Webhook");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a webhook
|
||||||
|
*/
|
||||||
|
public async update(merchantId: string, webhookId: string, request: UpdateMerchantWebhookRequest): Promise<Webhook> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}`);
|
||||||
|
const response = await getJsonResponse<UpdateMerchantWebhookRequest, Webhook>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Webhook");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an HMAC key
|
||||||
|
*/
|
||||||
|
public async generateHmac(merchantId: string, webhookId: string): Promise<GenerateHmacKeyResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`);
|
||||||
|
const response = await getJsonResponse<string, GenerateHmacKeyResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "GenerateHmacKeyResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a webhook
|
||||||
|
*/
|
||||||
|
public async test(merchantId: string, webhookId: string, request: TestWebhookRequest): Promise<TestWebhookResponse> {
|
||||||
|
const resource = new ManagementResource(this, `/merchants/${merchantId}/webhooks/${webhookId}/test`);
|
||||||
|
const response = await getJsonResponse<TestWebhookRequest, TestWebhookResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TestWebhookResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MerchantWebhooks;
|
||||||
94
src/services/management/myAPICredentialApi.ts
Normal file
94
src/services/management/myAPICredentialApi.ts
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { AllowedOrigin } from '../../typings/management/models';
|
||||||
|
import { AllowedOriginsResponse } from '../../typings/management/models';
|
||||||
|
import { CreateAllowedOriginRequest } from '../../typings/management/models';
|
||||||
|
import { MeApiCredential } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class MyAPICredentialApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Remove allowed origin
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async removeAllowedOrigin(originId: string, requestOptions?: IRequest.Options): Promise<void> {
|
||||||
|
const localVarPath = "/me/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get API credential details
|
||||||
|
*/
|
||||||
|
public async getApiCredentialDetails(requestOptions?: IRequest.Options): Promise<MeApiCredential> {
|
||||||
|
const localVarPath = "/me";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, MeApiCredential>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "MeApiCredential");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get allowed origins
|
||||||
|
*/
|
||||||
|
public async getAllowedOrigins(requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/me/allowedOrigins";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get allowed origin details
|
||||||
|
* @param originId Unique identifier of the allowed origin.
|
||||||
|
*/
|
||||||
|
public async getAllowedOriginDetails(originId: string, requestOptions?: IRequest.Options): Promise<AllowedOrigin> {
|
||||||
|
const localVarPath = "/me/allowedOrigins/{originId}"
|
||||||
|
.replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AllowedOrigin>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOrigin");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Add allowed origin
|
||||||
|
* @param createAllowedOriginRequest
|
||||||
|
*/
|
||||||
|
public async addAllowedOrigin(createAllowedOriginRequest: CreateAllowedOriginRequest, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
|
||||||
|
const localVarPath = "/me/allowedOrigins";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: CreateAllowedOriginRequest = ObjectSerializer.serialize(createAllowedOriginRequest, "CreateAllowedOriginRequest");
|
||||||
|
const response = await getJsonResponse<CreateAllowedOriginRequest, AllowedOriginsResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
132
src/services/management/paymentMethodsMerchantLevelApi.ts
Normal file
132
src/services/management/paymentMethodsMerchantLevelApi.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { ApplePayInfo } from '../../typings/management/models';
|
||||||
|
import { PaymentMethod } from '../../typings/management/models';
|
||||||
|
import { PaymentMethodResponse } from '../../typings/management/models';
|
||||||
|
import { PaymentMethodSetupInfo } from '../../typings/management/models';
|
||||||
|
import { UpdatePaymentMethodInfo } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class PaymentMethodsMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get all payment methods
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param storeId The unique identifier of the store for which to return the payment methods.
|
||||||
|
* @param businessLineId The unique identifier of the Business Line for which to return the payment methods.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
*/
|
||||||
|
public async getAllPaymentMethods(merchantId: string, requestOptions?: IRequest.Options): Promise<PaymentMethodResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, PaymentMethodResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethodResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get payment method details
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param paymentMethodId The unique identifier of the payment method.
|
||||||
|
*/
|
||||||
|
public async getPaymentMethodDetails(merchantId: string, paymentMethodId: string, requestOptions?: IRequest.Options): Promise<PaymentMethod> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get Apple Pay domains
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param paymentMethodId The unique identifier of the payment method.
|
||||||
|
*/
|
||||||
|
public async getApplePayDomains(merchantId: string, paymentMethodId: string, requestOptions?: IRequest.Options): Promise<ApplePayInfo> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}/getApplePayDomains"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ApplePayInfo>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ApplePayInfo");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update a payment method
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param paymentMethodId The unique identifier of the payment method.
|
||||||
|
* @param updatePaymentMethodInfo
|
||||||
|
*/
|
||||||
|
public async updatePaymentMethod(merchantId: string, paymentMethodId: string, updatePaymentMethodInfo: UpdatePaymentMethodInfo, requestOptions?: IRequest.Options): Promise<PaymentMethod> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdatePaymentMethodInfo = ObjectSerializer.serialize(updatePaymentMethodInfo, "UpdatePaymentMethodInfo");
|
||||||
|
const response = await getJsonResponse<UpdatePaymentMethodInfo, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Request a payment method
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param paymentMethodSetupInfo
|
||||||
|
*/
|
||||||
|
public async requestPaymentMethod(merchantId: string, paymentMethodSetupInfo: PaymentMethodSetupInfo, requestOptions?: IRequest.Options): Promise<PaymentMethod> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: PaymentMethodSetupInfo = ObjectSerializer.serialize(paymentMethodSetupInfo, "PaymentMethodSetupInfo");
|
||||||
|
const response = await getJsonResponse<PaymentMethodSetupInfo, PaymentMethod>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PaymentMethod");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Add an Apple Pay domain
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param paymentMethodId The unique identifier of the payment method.
|
||||||
|
* @param applePayInfo
|
||||||
|
*/
|
||||||
|
public async addApplePayDomain(merchantId: string, paymentMethodId: string, applePayInfo: ApplePayInfo, requestOptions?: IRequest.Options): Promise<void> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}/addApplePayDomains"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: ApplePayInfo = ObjectSerializer.serialize(applePayInfo, "ApplePayInfo");
|
||||||
|
await getJsonResponse<ApplePayInfo, void>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
108
src/services/management/payoutSettingsMerchantLevelApi.ts
Normal file
108
src/services/management/payoutSettingsMerchantLevelApi.ts
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { PayoutSettings } from '../../typings/management/models';
|
||||||
|
import { PayoutSettingsRequest } from '../../typings/management/models';
|
||||||
|
import { PayoutSettingsResponse } from '../../typings/management/models';
|
||||||
|
import { UpdatePayoutSettingsRequest } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class PayoutSettingsMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Delete a payout setting
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param payoutSettingsId The unique identifier of the payout setting.
|
||||||
|
*/
|
||||||
|
public async deletePayoutSetting(merchantId: string, payoutSettingsId: string, requestOptions?: IRequest.Options): Promise<void> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
await getJsonResponse<string, void>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "DELETE" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of payout settings
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async listPayoutSettings(merchantId: string, requestOptions?: IRequest.Options): Promise<PayoutSettingsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/payoutSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, PayoutSettingsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettingsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a payout setting
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param payoutSettingsId The unique identifier of the payout setting.
|
||||||
|
*/
|
||||||
|
public async getPayoutSetting(merchantId: string, payoutSettingsId: string, requestOptions?: IRequest.Options): Promise<PayoutSettings> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update a payout setting
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param payoutSettingsId The unique identifier of the payout setting.
|
||||||
|
* @param updatePayoutSettingsRequest
|
||||||
|
*/
|
||||||
|
public async updatePayoutSetting(merchantId: string, payoutSettingsId: string, updatePayoutSettingsRequest: UpdatePayoutSettingsRequest, requestOptions?: IRequest.Options): Promise<PayoutSettings> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: UpdatePayoutSettingsRequest = ObjectSerializer.serialize(updatePayoutSettingsRequest, "UpdatePayoutSettingsRequest");
|
||||||
|
const response = await getJsonResponse<UpdatePayoutSettingsRequest, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Add a payout setting
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param payoutSettingsRequest
|
||||||
|
*/
|
||||||
|
public async addPayoutSetting(merchantId: string, payoutSettingsRequest: PayoutSettingsRequest, requestOptions?: IRequest.Options): Promise<PayoutSettings> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/payoutSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: PayoutSettingsRequest = ObjectSerializer.serialize(payoutSettingsRequest, "PayoutSettingsRequest");
|
||||||
|
const response = await getJsonResponse<PayoutSettingsRequest, PayoutSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "PayoutSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
94
src/services/management/terminalActionsCompanyLevelApi.ts
Normal file
94
src/services/management/terminalActionsCompanyLevelApi.ts
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { AndroidAppsResponse } from '../../typings/management/models';
|
||||||
|
import { AndroidCertificatesResponse } from '../../typings/management/models';
|
||||||
|
import { ExternalTerminalAction } from '../../typings/management/models';
|
||||||
|
import { ListExternalTerminalActionsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalActionsCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of Android apps
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page.
|
||||||
|
*/
|
||||||
|
public async listAndroidApps(companyId: string, requestOptions?: IRequest.Options): Promise<AndroidAppsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/androidApps"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AndroidAppsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AndroidAppsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of Android certificates
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page.
|
||||||
|
*/
|
||||||
|
public async listAndroidCertificates(companyId: string, requestOptions?: IRequest.Options): Promise<AndroidCertificatesResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/androidCertificates"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, AndroidCertificatesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "AndroidCertificatesResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of terminal actions
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param pageNumber The number of the page to fetch.
|
||||||
|
* @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page.
|
||||||
|
* @param status Returns terminal actions with the specified status. Allowed values: **pending**, **successful**, **failed**, **cancelled**, **tryLater**.
|
||||||
|
* @param type Returns terminal actions of the specified type. Allowed values: **InstallAndroidApp**, **UninstallAndroidApp**, **InstallAndroidCertificate**, **UninstallAndroidCertificate**.
|
||||||
|
*/
|
||||||
|
public async listTerminalActions(companyId: string, requestOptions?: IRequest.Options): Promise<ListExternalTerminalActionsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalActions"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ListExternalTerminalActionsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ListExternalTerminalActionsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get terminal action
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param actionId The unique identifier of the terminal action.
|
||||||
|
*/
|
||||||
|
public async getTerminalAction(companyId: string, actionId: string, requestOptions?: IRequest.Options): Promise<ExternalTerminalAction> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalActions/{actionId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'actionId' + '}', encodeURIComponent(String(actionId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ExternalTerminalAction>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ExternalTerminalAction");
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/services/management/terminalActionsTerminalLevelApi.ts
Normal file
37
src/services/management/terminalActionsTerminalLevelApi.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { ScheduleTerminalActionsRequest } from '../../typings/management/models';
|
||||||
|
import { ScheduleTerminalActionsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalActionsTerminalLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Create a terminal action
|
||||||
|
* @param scheduleTerminalActionsRequest
|
||||||
|
*/
|
||||||
|
public async createTerminalAction(scheduleTerminalActionsRequest: ScheduleTerminalActionsRequest, requestOptions?: IRequest.Options): Promise<ScheduleTerminalActionsResponse> {
|
||||||
|
const localVarPath = "/terminals/scheduleActions";
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: ScheduleTerminalActionsRequest = ObjectSerializer.serialize(scheduleTerminalActionsRequest, "ScheduleTerminalActionsRequest");
|
||||||
|
const response = await getJsonResponse<ScheduleTerminalActionsRequest, ScheduleTerminalActionsResponse>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ScheduleTerminalActionsResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
202
src/services/management/terminalOrdersCompanyLevelApi.ts
Normal file
202
src/services/management/terminalOrdersCompanyLevelApi.ts
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { BillingEntitiesResponse } from '../../typings/management/models';
|
||||||
|
import { ShippingLocation } from '../../typings/management/models';
|
||||||
|
import { ShippingLocationsResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalModelsResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalOrder } from '../../typings/management/models';
|
||||||
|
import { TerminalOrderRequest } from '../../typings/management/models';
|
||||||
|
import { TerminalOrdersResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalProductsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalOrdersCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of billing entities
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param name The name of the billing entity.
|
||||||
|
*/
|
||||||
|
public async listBillingEntities(companyId: string, requestOptions?: IRequest.Options): Promise<BillingEntitiesResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/billingEntities"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, BillingEntitiesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BillingEntitiesResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of shipping locations
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param name The name of the shipping location.
|
||||||
|
* @param offset The number of locations to skip.
|
||||||
|
* @param limit The number of locations to return.
|
||||||
|
*/
|
||||||
|
public async listShippingLocations(companyId: string, requestOptions?: IRequest.Options): Promise<ShippingLocationsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/shippingLocations"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ShippingLocationsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocationsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of terminal models
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
*/
|
||||||
|
public async listTerminalModels(companyId: string, requestOptions?: IRequest.Options): Promise<TerminalModelsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalModels"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalModelsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalModelsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of orders
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param customerOrderReference Your purchase order number.
|
||||||
|
* @param status The order status. Possible values (not case-sensitive): Placed, Confirmed, Cancelled, Shipped, Delivered.
|
||||||
|
* @param offset The number of orders to skip.
|
||||||
|
* @param limit The number of orders to return.
|
||||||
|
*/
|
||||||
|
public async listOrders(companyId: string, requestOptions?: IRequest.Options): Promise<TerminalOrdersResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalOrders"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrdersResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrdersResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an order
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
*/
|
||||||
|
public async getOrder(companyId: string, orderId: string, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of terminal products
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param country The country to return products for, in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. For example, **US**
|
||||||
|
* @param terminalModelId The terminal model to return products for. Use the ID returned in the [GET `/terminalModels`](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/terminalModels) response. For example, **Verifone.M400**
|
||||||
|
* @param offset The number of products to skip.
|
||||||
|
* @param limit The number of products to return.
|
||||||
|
*/
|
||||||
|
public async listTerminalProducts(companyId: string, requestOptions?: IRequest.Options): Promise<TerminalProductsResponse> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalProducts"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalProductsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalProductsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update an order
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
* @param terminalOrderRequest
|
||||||
|
*/
|
||||||
|
public async updateOrder(companyId: string, orderId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest");
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create a shipping location
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param shippingLocation
|
||||||
|
*/
|
||||||
|
public async createShippingLocation(companyId: string, shippingLocation: ShippingLocation, requestOptions?: IRequest.Options): Promise<ShippingLocation> {
|
||||||
|
const localVarPath = "/companies/{companyId}/shippingLocations"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: ShippingLocation = ObjectSerializer.serialize(shippingLocation, "ShippingLocation");
|
||||||
|
const response = await getJsonResponse<ShippingLocation, ShippingLocation>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocation");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an order
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param terminalOrderRequest
|
||||||
|
*/
|
||||||
|
public async createOrder(companyId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalOrders"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest");
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Cancel an order
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
*/
|
||||||
|
public async cancelOrder(companyId: string, orderId: string, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}/cancel"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
}
|
||||||
202
src/services/management/terminalOrdersMerchantLevelApi.ts
Normal file
202
src/services/management/terminalOrdersMerchantLevelApi.ts
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { BillingEntitiesResponse } from '../../typings/management/models';
|
||||||
|
import { ShippingLocation } from '../../typings/management/models';
|
||||||
|
import { ShippingLocationsResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalModelsResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalOrder } from '../../typings/management/models';
|
||||||
|
import { TerminalOrderRequest } from '../../typings/management/models';
|
||||||
|
import { TerminalOrdersResponse } from '../../typings/management/models';
|
||||||
|
import { TerminalProductsResponse } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalOrdersMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get a list of billing entities
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param name The name of the billing entity.
|
||||||
|
*/
|
||||||
|
public async listBillingEntities(merchantId: string, requestOptions?: IRequest.Options): Promise<BillingEntitiesResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/billingEntities"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, BillingEntitiesResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "BillingEntitiesResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of shipping locations
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param name The name of the shipping location.
|
||||||
|
* @param offset The number of locations to skip.
|
||||||
|
* @param limit The number of locations to return.
|
||||||
|
*/
|
||||||
|
public async listShippingLocations(merchantId: string, requestOptions?: IRequest.Options): Promise<ShippingLocationsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/shippingLocations"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, ShippingLocationsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocationsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of terminal models
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async listTerminalModels(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalModelsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalModels"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalModelsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalModelsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of orders
|
||||||
|
* @param merchantId
|
||||||
|
* @param customerOrderReference Your purchase order number.
|
||||||
|
* @param status The order status. Possible values (not case-sensitive): Placed, Confirmed, Cancelled, Shipped, Delivered.
|
||||||
|
* @param offset The number of orders to skip.
|
||||||
|
* @param limit The number of orders to return.
|
||||||
|
*/
|
||||||
|
public async listOrders(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalOrdersResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalOrders"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrdersResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrdersResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get an order
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
*/
|
||||||
|
public async getOrder(merchantId: string, orderId: string, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get a list of terminal products
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param country The country to return products for, in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. For example, **US**
|
||||||
|
* @param terminalModelId The terminal model to return products for. Use the ID returned in the [GET `/terminalModels`](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/terminalModels) response. For example, **Verifone.M400**
|
||||||
|
* @param offset The number of products to skip.
|
||||||
|
* @param limit The number of products to return.
|
||||||
|
*/
|
||||||
|
public async listTerminalProducts(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalProductsResponse> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalProducts"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalProductsResponse>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalProductsResponse");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update an order
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
* @param terminalOrderRequest
|
||||||
|
*/
|
||||||
|
public async updateOrder(merchantId: string, orderId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest");
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create a shipping location
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param shippingLocation
|
||||||
|
*/
|
||||||
|
public async createShippingLocation(merchantId: string, shippingLocation: ShippingLocation, requestOptions?: IRequest.Options): Promise<ShippingLocation> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/shippingLocations"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: ShippingLocation = ObjectSerializer.serialize(shippingLocation, "ShippingLocation");
|
||||||
|
const response = await getJsonResponse<ShippingLocation, ShippingLocation>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "ShippingLocation");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Create an order
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param terminalOrderRequest
|
||||||
|
*/
|
||||||
|
public async createOrder(merchantId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalOrders"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest");
|
||||||
|
const response = await getJsonResponse<TerminalOrderRequest, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Cancel an order
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param orderId The unique identifier of the order.
|
||||||
|
*/
|
||||||
|
public async cancelOrder(merchantId: string, orderId: string, requestOptions?: IRequest.Options): Promise<TerminalOrder> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}/cancel"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalOrder>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "POST" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalOrder");
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/services/management/terminalSettingsCompanyLevelApi.ts
Normal file
88
src/services/management/terminalSettingsCompanyLevelApi.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { Logo } from '../../typings/management/models';
|
||||||
|
import { TerminalSettings } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalSettingsCompanyLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get the terminal logo
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
|
||||||
|
*/
|
||||||
|
public async getTerminalLogo(companyId: string, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalLogos"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Logo>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get terminal settings
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
*/
|
||||||
|
public async getTerminalSettings(companyId: string, requestOptions?: IRequest.Options): Promise<TerminalSettings> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalSettings"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update the terminal logo
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
|
||||||
|
* @param logo
|
||||||
|
*/
|
||||||
|
public async updateTerminalLogo(companyId: string, logo: Logo, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalLogos"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: Logo = ObjectSerializer.serialize(logo, "Logo");
|
||||||
|
const response = await getJsonResponse<Logo, Logo>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update terminal settings
|
||||||
|
* @param companyId The unique identifier of the company account.
|
||||||
|
* @param terminalSettings
|
||||||
|
*/
|
||||||
|
public async updateTerminalSettings(companyId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise<TerminalSettings> {
|
||||||
|
const localVarPath = "/companies/{companyId}/terminalSettings"
|
||||||
|
.replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings");
|
||||||
|
const response = await getJsonResponse<TerminalSettings, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/services/management/terminalSettingsMerchantLevelApi.ts
Normal file
88
src/services/management/terminalSettingsMerchantLevelApi.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* The version of the OpenAPI document: v1
|
||||||
|
* Contact: developer-experience@adyen.com
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit this class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
||||||
|
import Service from "../../service";
|
||||||
|
/* tslint:disable:no-unused-locals */
|
||||||
|
import { Logo } from '../../typings/management/models';
|
||||||
|
import { TerminalSettings } from '../../typings/management/models';
|
||||||
|
import { IRequest } from "../../typings/requestOptions";
|
||||||
|
import ManagementResource from "../resource/management/managementResource";
|
||||||
|
import { ObjectSerializer } from "../../typings/management/models";
|
||||||
|
|
||||||
|
|
||||||
|
export default class TerminalSettingsMerchantLevelApi extends Service {
|
||||||
|
/**
|
||||||
|
* @summary Get the terminal logo
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
|
||||||
|
*/
|
||||||
|
public async getTerminalLogo(merchantId: string, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalLogos"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, Logo>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Get terminal settings
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
*/
|
||||||
|
public async getTerminalSettings(merchantId: string, requestOptions?: IRequest.Options): Promise<TerminalSettings> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const response = await getJsonResponse<string, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
"",
|
||||||
|
{ ...requestOptions, method: "GET" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update the terminal logo
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param model The terminal model. Allowed values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
|
||||||
|
* @param logo
|
||||||
|
*/
|
||||||
|
public async updateTerminalLogo(merchantId: string, logo: Logo, requestOptions?: IRequest.Options): Promise<Logo> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalLogos"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: Logo = ObjectSerializer.serialize(logo, "Logo");
|
||||||
|
const response = await getJsonResponse<Logo, Logo>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "Logo");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary Update terminal settings
|
||||||
|
* @param merchantId The unique identifier of the merchant account.
|
||||||
|
* @param terminalSettings
|
||||||
|
*/
|
||||||
|
public async updateTerminalSettings(merchantId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise<TerminalSettings> {
|
||||||
|
const localVarPath = "/merchants/{merchantId}/terminalSettings"
|
||||||
|
.replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
|
||||||
|
const resource = new ManagementResource(this, localVarPath);
|
||||||
|
const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings");
|
||||||
|
const response = await getJsonResponse<TerminalSettings, TerminalSettings>(
|
||||||
|
resource,
|
||||||
|
request,
|
||||||
|
{ ...requestOptions, method: "PATCH" }
|
||||||
|
);
|
||||||
|
return ObjectSerializer.deserialize(response, "TerminalSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user