mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-04-05 08:01:20 +00:00
Compare commits
472 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd522b80f | ||
|
|
bd3c8a0f6b | ||
|
|
21892df7ff | ||
|
|
1721ab770f | ||
|
|
a1977ff4c5 | ||
|
|
2b2cfaa61e | ||
|
|
bae6ff9f25 | ||
|
|
d459f00871 | ||
|
|
ddf56999b4 | ||
|
|
0322f35e6b | ||
|
|
c35bd577a4 | ||
|
|
e2bb647e13 | ||
|
|
0debcaa793 | ||
|
|
9d0be96d8c | ||
|
|
a27b9b4c45 | ||
|
|
21700d8bb6 | ||
|
|
46a4918b6b | ||
|
|
06d46f81dd | ||
|
|
cf4e81a43b | ||
|
|
71306af9f8 | ||
|
|
32e9c38079 | ||
|
|
b4e5165e33 | ||
|
|
56646c2525 | ||
|
|
93e69d9255 | ||
|
|
6056b1f0be | ||
|
|
ec4f46aaf5 | ||
|
|
557d6893ba | ||
|
|
5ed66fd7eb | ||
|
|
ba2e24ebe5 | ||
|
|
514da2cab0 | ||
|
|
ec35545de0 | ||
|
|
830c87d61f | ||
|
|
c37f6f95df | ||
|
|
487edf3164 | ||
|
|
5003e70bf5 | ||
|
|
dd7be92a94 | ||
|
|
6e7e62b240 | ||
|
|
ea1da161d0 | ||
|
|
2ebd05f593 | ||
|
|
4128891d4e | ||
|
|
d8dbb2ebf0 | ||
|
|
a72692a82e | ||
|
|
6a9987d3e6 | ||
|
|
53815b0c43 | ||
|
|
b20f579cf0 | ||
|
|
5f54866a26 | ||
|
|
c3cc2d9773 | ||
|
|
7838bd06e5 | ||
|
|
df64578bd3 | ||
|
|
3d4de26368 | ||
|
|
c873bd4e57 | ||
|
|
57b7b6caff | ||
|
|
fea4634fce | ||
|
|
98b1da396d | ||
|
|
872f2302cd | ||
|
|
e9e75c379c | ||
|
|
8b63c8fe21 | ||
|
|
6f13cfcb50 | ||
|
|
d33b46c6a2 | ||
|
|
663a8cc6a6 | ||
|
|
009bc4db00 | ||
|
|
42a4958ae3 | ||
|
|
783df311ec | ||
|
|
84d1932e97 | ||
|
|
8c469e886d | ||
|
|
c5dcad9271 | ||
|
|
368db4455f | ||
|
|
40b6cd5f1e | ||
|
|
c60c4b7520 | ||
|
|
e391d8d995 | ||
|
|
955aea532c | ||
|
|
fb5128c636 | ||
|
|
164f6ca2b3 | ||
|
|
1d7c8edefe | ||
|
|
64c2f008c7 | ||
|
|
12223da1a3 | ||
|
|
9faef744ed | ||
|
|
17a60f6c1f | ||
|
|
db422acc71 | ||
|
|
e206679d45 | ||
|
|
fbe97cf919 | ||
|
|
e276cb8e24 | ||
|
|
b471905ac3 | ||
|
|
86b78c3f92 | ||
|
|
cfd92b904b | ||
|
|
e3cc8a6c00 | ||
|
|
60704022a1 | ||
|
|
a416d7b14a | ||
|
|
77d1cc7751 | ||
|
|
d56423560f | ||
|
|
ae2031fc5d | ||
|
|
1499559123 | ||
|
|
d003c45f85 | ||
|
|
eb13940cb5 | ||
|
|
ce91c512ae | ||
|
|
3a2b899136 | ||
|
|
36eb1476ac | ||
|
|
6b2e2dfb48 | ||
|
|
d1bd508ea8 | ||
|
|
69fbcb1f8c | ||
|
|
7f171af2e1 | ||
|
|
71748ed815 | ||
|
|
f3cb4cc120 | ||
|
|
2ce6878456 | ||
|
|
8ba580b119 | ||
|
|
ae45b10082 | ||
|
|
050763be7f | ||
|
|
eeaae2228a | ||
|
|
d0da1382f6 | ||
|
|
74c6f119a5 | ||
|
|
65d81d21ff | ||
|
|
e789cfe47e | ||
|
|
be6fc4dd3b | ||
|
|
0157efa658 | ||
|
|
c13abc979c | ||
|
|
293f7aab74 | ||
|
|
e8dc5a7030 | ||
|
|
09184486f5 | ||
|
|
4d34d3da6a | ||
|
|
51b998a933 | ||
|
|
b1bc56ebba | ||
|
|
b5b947af89 | ||
|
|
93c5dcde70 | ||
|
|
a9aedd1f41 | ||
|
|
a6008cf52e | ||
|
|
ba24d1b634 | ||
|
|
bca3432865 | ||
|
|
f21d26680d | ||
|
|
2bc18ccf0f | ||
|
|
1482aeecad | ||
|
|
6f562cfb32 | ||
|
|
077822ea5c | ||
|
|
45e1d2d5ab | ||
|
|
9f6e891c57 | ||
|
|
b637febde5 | ||
|
|
7456025d40 | ||
|
|
c8d2882299 | ||
|
|
ef490a5cdf | ||
|
|
650e7dc0a5 | ||
|
|
156d7fa8ea | ||
|
|
ec16ee9f79 | ||
|
|
74d6da71f8 | ||
|
|
c16c6eb367 | ||
|
|
ed2e6c62d9 | ||
|
|
041587e1bb | ||
|
|
02bab06c16 | ||
|
|
ca7ba4e7de | ||
|
|
30b0a52802 | ||
|
|
2531290761 | ||
|
|
62e83058da | ||
|
|
9b6469a228 | ||
|
|
b62e12da1c | ||
|
|
ddc9e58f72 | ||
|
|
0ef9b49c5d | ||
|
|
1a96f42b4e | ||
|
|
4f810936fe | ||
|
|
364da4ffde | ||
|
|
1f24e2a25b | ||
|
|
725c6d1395 | ||
|
|
771037b40f | ||
|
|
5e2094cac7 | ||
|
|
47515994ee | ||
|
|
f6b065c02e | ||
|
|
2c6a23522e | ||
|
|
c5cbda16c0 | ||
|
|
2dccd236f0 | ||
|
|
9a9168582f | ||
|
|
c48a39edfb | ||
|
|
4275dd882b | ||
|
|
2a86b795a0 | ||
|
|
c4c8a61db5 | ||
|
|
c66137c2eb | ||
|
|
3b2d20b38d | ||
|
|
657626a0d2 | ||
|
|
c0b8d3112b | ||
|
|
494f706b4c | ||
|
|
d39753c4e0 | ||
|
|
4b27e6a4ca | ||
|
|
2b98915e7f | ||
|
|
4805613d6f | ||
|
|
4f7a05591f | ||
|
|
c8b00bdce3 | ||
|
|
afdd88979a | ||
|
|
45f5622dcf | ||
|
|
1972bc281b | ||
|
|
d7314fc765 | ||
|
|
9a2ea8293c | ||
|
|
ec9d41b047 | ||
|
|
b48722a59f | ||
|
|
f5e73fdff8 | ||
|
|
99ae41c77e | ||
|
|
2617e732d3 | ||
|
|
6299ec0029 | ||
|
|
9cdb45ba14 | ||
|
|
098aaeba7d | ||
|
|
3a174185b4 | ||
|
|
989dc92583 | ||
|
|
2fe10e48f2 | ||
|
|
f91f2b8833 | ||
|
|
aff77ebe50 | ||
|
|
6079f82c2b | ||
|
|
10b3d148cb | ||
|
|
8cd4ffe093 | ||
|
|
f71b1004d2 | ||
|
|
1c961eac10 | ||
|
|
4ebc4caa53 | ||
|
|
8c6e961bc4 | ||
|
|
e00c43c4ae | ||
|
|
dda64f60bd | ||
|
|
f0e93cfaa1 | ||
|
|
43898a2006 | ||
|
|
26b8ace53f | ||
|
|
6746ce7234 | ||
|
|
da8bbd1e4a | ||
|
|
fbab4a3976 | ||
|
|
fd76bdcbea | ||
|
|
848a655210 | ||
|
|
21295f907b | ||
|
|
fa3997e61a | ||
|
|
5bc903a403 | ||
|
|
b12e5138fd | ||
|
|
ca3dfb5c05 | ||
|
|
a466c11577 | ||
|
|
d008b2c76b | ||
|
|
2b928554fe | ||
|
|
33738848f1 | ||
|
|
4006e2957b | ||
|
|
27092a0c47 | ||
|
|
1784fc7d2b | ||
|
|
b97d3965a3 | ||
|
|
cb176ac7d9 | ||
|
|
2971260609 | ||
|
|
184fc29bd2 | ||
|
|
2a9cc41463 | ||
|
|
561c5e644e | ||
|
|
b04dc8f5e0 | ||
|
|
f449ed060f | ||
|
|
8d2a8ef685 | ||
|
|
8b3cf9e818 | ||
|
|
c1cce25a93 | ||
|
|
33a0b5f2ad | ||
|
|
91f5025fc7 | ||
|
|
fbd496c6ae | ||
|
|
36cd082c70 | ||
|
|
c22825b14b | ||
|
|
cc4ba61db4 | ||
|
|
961a6fe6ac | ||
|
|
24770e6496 | ||
|
|
8ef214c04a | ||
|
|
9c53e68f5d | ||
|
|
509d9ff772 | ||
|
|
36ac1105f2 | ||
|
|
05a182e256 | ||
|
|
dfff25f2ef | ||
|
|
2b4b9755ae | ||
|
|
97de2e7a44 | ||
|
|
4a299cc2be | ||
|
|
03dfa166fd | ||
|
|
7c869292f2 | ||
|
|
91c0377764 | ||
|
|
3d7b1c1a5d | ||
|
|
03810191ca | ||
|
|
dfe9904318 | ||
|
|
3a5f877bb3 | ||
|
|
9ee89bf030 | ||
|
|
6c2e2eab8e | ||
|
|
74434bc2cc | ||
|
|
df18e6a15b | ||
|
|
0cd7e9b48a | ||
|
|
2ad8791312 | ||
|
|
e72ffdbd9d | ||
|
|
14bfc12d7b | ||
|
|
e39e962d5f | ||
|
|
a9ecf92d3a | ||
|
|
08181f943f | ||
|
|
818f739637 | ||
|
|
9bbf2d59ad | ||
|
|
d097d8192c | ||
|
|
ce60399f53 | ||
|
|
53aa0f2a67 | ||
|
|
4ce37d83cb | ||
|
|
a9cbef429e | ||
|
|
3334d4f361 | ||
|
|
bd87b04602 | ||
|
|
0ed0de56a6 | ||
|
|
fa9ea5e1c0 | ||
|
|
e675f9e87e | ||
|
|
30c80f34e9 | ||
|
|
a06d96cb6b | ||
|
|
3efeb339a7 | ||
|
|
5560a93c62 | ||
|
|
c10993c7b1 | ||
|
|
4dbd59139d | ||
|
|
2151034e49 | ||
|
|
bc4373545c | ||
|
|
0f92235ac5 | ||
|
|
e063a04762 | ||
|
|
35cb449930 | ||
|
|
5b852a8399 | ||
|
|
6a94c3309f | ||
|
|
90ba60e13b | ||
|
|
55f42bd089 | ||
|
|
ee6b50f75d | ||
|
|
6228bc12ef | ||
|
|
e521c53f2c | ||
|
|
90376b44d9 | ||
|
|
18b79b664e | ||
|
|
ad33e0b6db | ||
|
|
036fa9340b | ||
|
|
1e2b2c2498 | ||
|
|
bae5db690e | ||
|
|
bab5c24d4d | ||
|
|
8efe9b4fe4 | ||
|
|
1bb3c1f4ca | ||
|
|
323579492f | ||
|
|
563ebf3ad6 | ||
|
|
f00272cffd | ||
|
|
e5beed4179 | ||
|
|
6b15e36158 | ||
|
|
a0b2de3b27 | ||
|
|
f5bc92069b | ||
|
|
0c5df902d3 | ||
|
|
54cb4438f0 | ||
|
|
cbd0a60702 | ||
|
|
da8012ac17 | ||
|
|
96f730e8ae | ||
|
|
ddfe8b339a | ||
|
|
9442f9a097 | ||
|
|
b1593dacc8 | ||
|
|
6c739d0216 | ||
|
|
c7a359b5f0 | ||
|
|
2f40363fee | ||
|
|
2b4260fcd0 | ||
|
|
37edd9c412 | ||
|
|
f56e632d7f | ||
|
|
e22c7fa53c | ||
|
|
96e610db7f | ||
|
|
9d461481dc | ||
|
|
2cd3e93dfd | ||
|
|
43207db52b | ||
|
|
ffe6af1d97 | ||
|
|
b2a15bfd23 | ||
|
|
d8e31a3262 | ||
|
|
155a9b0a96 | ||
|
|
9229311175 | ||
|
|
724b9c8130 | ||
|
|
31ce0ac330 | ||
|
|
91f0252d33 | ||
|
|
968c60de65 | ||
|
|
608f4d9c69 | ||
|
|
969ff9c431 | ||
|
|
4bf7494989 | ||
|
|
7f8170575f | ||
|
|
756a59e31a | ||
|
|
4013f70205 | ||
|
|
6858c8a599 | ||
|
|
2854236720 | ||
|
|
3b95f067aa | ||
|
|
a621245ced | ||
|
|
1ce8877d87 | ||
|
|
964be24ba7 | ||
|
|
4bcfb1810f | ||
|
|
b781030260 | ||
|
|
fa767eea8e | ||
|
|
f40092f94f | ||
|
|
2401b27dd4 | ||
|
|
d03fd6502d | ||
|
|
ebc72005e6 | ||
|
|
57f3135dee | ||
|
|
b4e9e2f480 | ||
|
|
9c21109c83 | ||
|
|
64c086a760 | ||
|
|
e8f82c4a82 | ||
|
|
86a551c06e | ||
|
|
9272fff378 | ||
|
|
520e73b57f | ||
|
|
2291cfad85 | ||
|
|
f3f9976e68 | ||
|
|
d50f84b230 | ||
|
|
ffb236e9f8 | ||
|
|
937ddc5623 | ||
|
|
6c38e717d7 | ||
|
|
204e68aa1e | ||
|
|
caa7e3a311 | ||
|
|
2f70fa2caf | ||
|
|
a26c04d99d | ||
|
|
9ea38e7da8 | ||
|
|
dddf016c6c | ||
|
|
9d87c490d9 | ||
|
|
a2db9a4ba1 | ||
|
|
66042b92e7 | ||
|
|
026ed69203 | ||
|
|
a5264a1b40 | ||
|
|
30f895b758 | ||
|
|
56e1805701 | ||
|
|
ea771b274f | ||
|
|
a55e9a5cf1 | ||
|
|
4f640a05ea | ||
|
|
acaa98d100 | ||
|
|
4956c01bea | ||
|
|
559b7fc224 | ||
|
|
1842ea21f2 | ||
|
|
d2472dd1f2 | ||
|
|
1d957df35d | ||
|
|
79a518d133 | ||
|
|
0b76d344ff | ||
|
|
38c12702c9 | ||
|
|
9884955c71 | ||
|
|
663a0c0ec7 | ||
|
|
db34fc68c3 | ||
|
|
aff2527194 | ||
|
|
cf07545dda | ||
|
|
9c4ab30240 | ||
|
|
147cea2d5b | ||
|
|
cd6a07f7bd | ||
|
|
6798edad03 | ||
|
|
b2f1c8b28b | ||
|
|
c0a494a4bd | ||
|
|
fc1769c30c | ||
|
|
a6a9961679 | ||
|
|
93e1dde831 | ||
|
|
6b45af1cdb | ||
|
|
a87b109f63 | ||
|
|
5d08dded6e | ||
|
|
7fd8e5dbb0 | ||
|
|
bf0d3b8457 | ||
|
|
da87e71c9f | ||
|
|
6797c684f9 | ||
|
|
95260f0499 | ||
|
|
9e35478973 | ||
|
|
25aeee2076 | ||
|
|
5435669388 | ||
|
|
eeb963d36f | ||
|
|
f39932208d | ||
|
|
25ea679283 | ||
|
|
07ca079203 | ||
|
|
63f95a5002 | ||
|
|
3b5e3d121d | ||
|
|
ac601cff87 | ||
|
|
1c8f750ff1 | ||
|
|
35e870c150 | ||
|
|
ee902f97c1 | ||
|
|
3b328c54c8 | ||
|
|
14c6a71fe9 | ||
|
|
e53550df2a | ||
|
|
97db576e1f | ||
|
|
be0a10bd40 | ||
|
|
7556858aee | ||
|
|
3cb0f91ac1 | ||
|
|
10e06c2edb | ||
|
|
1f10c5e4bf | ||
|
|
fd437777e4 | ||
|
|
9ae07636c7 | ||
|
|
4f688db18e | ||
|
|
816e10de41 | ||
|
|
f7dd296d3b | ||
|
|
412cf2f739 | ||
|
|
c86597eee6 | ||
|
|
b03ab5b822 | ||
|
|
c18ed88e2e | ||
|
|
b26fde99b5 | ||
|
|
7045ad97c2 | ||
|
|
18d1d362ee | ||
|
|
e20b5146d7 | ||
|
|
9aa31b0278 | ||
|
|
a86bc8b9a8 | ||
|
|
f2f3571928 | ||
|
|
9615e66444 | ||
|
|
199c47568d | ||
|
|
4bdc49e3b5 | ||
|
|
880298d03e | ||
|
|
1099081ea3 |
22
.eslintrc.js
22
.eslintrc.js
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
@@ -23,7 +42,8 @@ module.exports = {
|
||||
],
|
||||
rules: {
|
||||
quotes: ["error", "double"],
|
||||
semi: ["error", "always"]
|
||||
semi: ["error", "always"],
|
||||
"@typescript-eslint/no-non-null-assertion": 0
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
||||
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -1 +1 @@
|
||||
* @KadoBOT @msilvagarcia @cyattilakiss @rkewlani @Aleffio @rikterbeek
|
||||
* @zaiddreakh @maassenbas @msilvagarcia @AlexandrosMor @peterojo
|
||||
|
||||
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
**Description**
|
||||
<!-- Please provide a description of the changes proposed in the Pull Request -->
|
||||
|
||||
**Tested scenarios**
|
||||
<!-- Description of tested scenarios -->
|
||||
|
||||
**Fixed issue**: <!-- #-prefixed issue number -->
|
||||
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "04:00"
|
||||
open-pull-requests-limit: 10
|
||||
reviewers:
|
||||
- KadoBOT
|
||||
11
.github/stale.yml
vendored
Normal file
11
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: wontfix
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
51
.github/workflows/codeql-analysis.yml
vendored
Normal file
51
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
name: "Code scanning - action"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 21 * * 4'
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, 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)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
50
.github/workflows/coveralls.yml
vendored
Normal file
50
.github/workflows/coveralls.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
on: ["push", "pull_request"]
|
||||
|
||||
name: Coveralls
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Use Node.js 12.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: npm install, npm test:coverage
|
||||
run: |
|
||||
npm install
|
||||
npm run test:coverage
|
||||
env:
|
||||
CI: true
|
||||
ADYEN_API_KEY: ${{ secrets.ADYEN_API_KEY }}
|
||||
ADYEN_MERCHANT: ${{ secrets.ADYEN_MERCHANT }}
|
||||
ADYEN_PASSWORD: ${{ secrets.ADYEN_PASSWORD }}
|
||||
ADYEN_REVIEWPAYOUT_APIKEY: ${{ secrets.ADYEN_REVIEWPAYOUT_APIKEY }}
|
||||
ADYEN_REVIEWPAYOUT_PASSWORD: ${{ secrets.ADYENREVIEWPAYOUT_PASSWORD }}
|
||||
ADYEN_REVIEWPAYOUT_USER: ${{ secrets.ADYENREVIEWPAYOUT_USER }}
|
||||
ADYEN_STOREPAYOUT_APIKEY: ${{ secrets.ADYEN_STOREPAYOUT_APIKEY }}
|
||||
ADYEN_STOREPAYOUT_PASSWORD: ${{ secrets.ADYEN_STOREPAYOUT_PASSWORD }}
|
||||
ADYEN_STOREPAYOUT_USER: ${{ secrets.ADYEN_STOREPAYOUT_USER }}
|
||||
ADYEN_USER: ${{ secrets.ADYEN_USER }}
|
||||
ADYEN_MARKETPLACE_USER: ${{ secrets.ADYEN_MARKETPLACE_USER }}
|
||||
ADYEN_MARKETPLACE_PASSWORD: ${{ secrets.ADYEN_MARKETPLACE_PASSWORD }}
|
||||
ADYEN_TERMINAL_APIKEY: ${{ secrets.ADYEN_TERMINAL_APIKEY }}
|
||||
ADYEN_TERMINAL_POIID: ${{ secrets.ADYEN_TERMINAL_POIID }}
|
||||
ADYEN_TERMINAL_MERCHANT: ${{ secrets.ADYEN_TERMINAL_MERCHANT }}
|
||||
|
||||
- name: Coveralls Parallel
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: ./coverage/lcov.info # optional (default value)
|
||||
|
||||
- name: Coveralls Finished
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
42
.github/workflows/nodejs.yml
vendored
Normal file
42
.github/workflows/nodejs.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Node.js CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 12.x, 13.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install, lint and test
|
||||
run: |
|
||||
npm install
|
||||
npm run lint:fix
|
||||
npm run lint
|
||||
npm test
|
||||
env:
|
||||
CI: true
|
||||
ADYEN_API_KEY: ${{ secrets.ADYEN_API_KEY }}
|
||||
ADYEN_MERCHANT: ${{ secrets.ADYEN_MERCHANT }}
|
||||
ADYEN_PASSWORD: ${{ secrets.ADYEN_PASSWORD }}
|
||||
ADYEN_REVIEWPAYOUT_APIKEY: ${{ secrets.ADYEN_REVIEWPAYOUT_APIKEY }}
|
||||
ADYEN_REVIEWPAYOUT_PASSWORD: ${{ secrets.ADYENREVIEWPAYOUT_PASSWORD }}
|
||||
ADYEN_REVIEWPAYOUT_USER: ${{ secrets.ADYENREVIEWPAYOUT_USER }}
|
||||
ADYEN_STOREPAYOUT_APIKEY: ${{ secrets.ADYEN_STOREPAYOUT_APIKEY }}
|
||||
ADYEN_STOREPAYOUT_PASSWORD: ${{ secrets.ADYEN_STOREPAYOUT_PASSWORD }}
|
||||
ADYEN_STOREPAYOUT_USER: ${{ secrets.ADYEN_STOREPAYOUT_USER }}
|
||||
ADYEN_USER: ${{ secrets.ADYEN_USER }}
|
||||
ADYEN_MARKETPLACE_USER: ${{ secrets.ADYEN_MARKETPLACE_USER }}
|
||||
ADYEN_MARKETPLACE_PASSWORD: ${{ secrets.ADYEN_MARKETPLACE_PASSWORD }}
|
||||
ADYEN_TERMINAL_APIKEY: ${{ secrets.ADYEN_TERMINAL_APIKEY }}
|
||||
ADYEN_TERMINAL_POIID: ${{ secrets.ADYEN_TERMINAL_POIID }}
|
||||
ADYEN_TERMINAL_MERCHANT: ${{ secrets.ADYEN_TERMINAL_MERCHANT }}
|
||||
22
.github/workflows/npmpublish.yml
vendored
Normal file
22
.github/workflows/npmpublish.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Node.js Package
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: |
|
||||
npm install
|
||||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
|
||||
npm run build
|
||||
npm publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,4 +11,5 @@ node_modules
|
||||
.ssh/
|
||||
.viminfo
|
||||
coverage/
|
||||
dist/
|
||||
.env
|
||||
lib/
|
||||
@@ -1,12 +1,20 @@
|
||||
{
|
||||
"git": {
|
||||
"tagName": "v${version}",
|
||||
"changelog": "npx auto-changelog --stdout --commit-limit false -u"
|
||||
"changelog": "npx auto-changelog --hide-credit --stdout --commit-limit false --unreleased-only -t keepachangelog",
|
||||
"commitMessage": "Release ${version}",
|
||||
"tag": true,
|
||||
"requireCleanWorkingDir": false
|
||||
},
|
||||
"github": {
|
||||
"release": true
|
||||
"release": true,
|
||||
"releaseName": "Adyen Node API Library v${version}"
|
||||
},
|
||||
"hooks": {
|
||||
"after:bump": "npx auto-changelog -p"
|
||||
"after:bump": [
|
||||
"npm run build",
|
||||
"npx auto-changelog -p"
|
||||
],
|
||||
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
||||
}
|
||||
}
|
||||
|
||||
25
.travis.yml
25
.travis.yml
@@ -1,25 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8"
|
||||
- stable
|
||||
cache: yarn
|
||||
script:
|
||||
- yarn run lint:fix
|
||||
- yarn run lint
|
||||
- yarn run test
|
||||
jobs:
|
||||
include:
|
||||
- stage: npm release
|
||||
if: tag IS present
|
||||
node_js: stable
|
||||
script: yarn run build
|
||||
deploy:
|
||||
provider: npm
|
||||
email: "$NPM_EMAIL"
|
||||
api_key: "$NPM_TOKEN"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
- stage: Produce Coverage
|
||||
node_js: stable
|
||||
script: jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Adyen
|
||||
Copyright (c) 2020 Adyen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
11
README.md
11
README.md
@@ -1,10 +1,12 @@
|
||||
# Adyen Node.js API Library
|
||||
[](https://travis-ci.org/Adyen/adyen-node-api-library)
|
||||

|
||||
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=master)
|
||||
[](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://lgtm.com/projects/g/Adyen/adyen-node-api-library/alerts/)
|
||||
[](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/context:javascript)
|
||||
|
||||
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
|
||||
|
||||
@@ -22,7 +24,7 @@ The Library supports all APIs under the following services:
|
||||
|
||||
## Requirements
|
||||
|
||||
* Node 8.1.1 or higher
|
||||
* Node 10 or higher
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -36,7 +38,7 @@ npm install --save @adyen/api-library
|
||||
|
||||
## Documentation
|
||||
* https://docs.adyen.com/developers/development-resources/libraries
|
||||
* https://docs.adyen.com/developers/checkout/api-integration
|
||||
* https://docs.adyen.com/developers/checkout
|
||||
|
||||
## HTTP Client Configuration
|
||||
|
||||
@@ -87,8 +89,7 @@ client.httpClient = httpClient;
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
If you have any problems, questions or suggestions, create an issue here or send your inquiry to 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://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420).
|
||||
|
||||
## Contributing
|
||||
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
"@babel/env",
|
||||
[
|
||||
"@babel/preset-typescript",
|
||||
{
|
||||
targets: {
|
||||
node: "current"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
plugins: [
|
||||
"@babel/proposal-class-properties",
|
||||
"@babel/proposal-object-rest-spread"
|
||||
],
|
||||
env: {
|
||||
test: {
|
||||
plugins: [
|
||||
"@babel/plugin-transform-runtime",
|
||||
"@babel/plugin-transform-typescript"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
config.ts
Normal file
20
config.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 "jest-ts-auto-mock"
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen Node API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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.
|
||||
*/
|
||||
@@ -28,14 +26,18 @@ module.exports = {
|
||||
coveragePathIgnorePatterns: [
|
||||
"<rootDir>/src/typings"
|
||||
],
|
||||
unmockedModulePathPatterns: [
|
||||
"/dist"
|
||||
],
|
||||
setupFiles: ["<rootDir>config.ts", "dotenv/config"],
|
||||
testMatch: [
|
||||
"**/__tests__/*.ts"
|
||||
"**/src/__tests__/**/*.spec.ts"
|
||||
],
|
||||
testPathIgnorePatterns : [
|
||||
"/node_modules",
|
||||
"/dist"
|
||||
]
|
||||
roots: ['<rootDir>/src'],
|
||||
transform: {
|
||||
".ts": "ts-jest"
|
||||
},
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
compiler: "ttypescript",
|
||||
transformIgnorePatterns: ['^.+\\\\.js$']
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
10754
package-lock.json
generated
10754
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
65
package.json
65
package.json
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "@adyen/api-library",
|
||||
"version": "2.2.1",
|
||||
"version": "7.0.0",
|
||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
|
||||
"main": "dist/lib/src/index.js",
|
||||
"types": "dist/lib/src/index.d.ts",
|
||||
"module": "dist/lib-esm/src/index.js",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=8.1.1"
|
||||
"node": ">=10"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -25,45 +24,41 @@
|
||||
},
|
||||
"homepage": "https://github.com/Adyen/adyen-node-api-library#readme",
|
||||
"scripts": {
|
||||
"clean": "rm -rf ./dist",
|
||||
"build": "npm run clean && tsc && tsc -m es6 --outDir dist/lib-esm && webpack",
|
||||
"build": "tsc",
|
||||
"lint": "eslint 'src/**/*.ts'",
|
||||
"lint:fix": "eslint --fix 'src/**/*.ts'",
|
||||
"test": "jest",
|
||||
"preversion": "npm test",
|
||||
"version": "npm run build && git add -A dist",
|
||||
"postversion": "git push && git push --tags && rm -rf build/temp",
|
||||
"release": "release-it --no-npm.publish"
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
"release": "release-it"
|
||||
},
|
||||
"author": "Ricardo Ambrogi",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.8.3",
|
||||
"@babel/plugin-proposal-class-properties": "7.8.3",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.8.3",
|
||||
"@babel/plugin-transform-runtime": "7.8.3",
|
||||
"@babel/plugin-transform-typescript": "7.8.3",
|
||||
"@babel/preset-env": "7.8.3",
|
||||
"@babel/preset-typescript": "7.8.3",
|
||||
"@babel/runtime": "7.8.3",
|
||||
"@types/nock": "10.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "2.16.0",
|
||||
"@typescript-eslint/parser": "2.16.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"coveralls": "3.0.9",
|
||||
"@types/jest": "26.0.15",
|
||||
"@types/nock": "11.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.34.0",
|
||||
"@typescript-eslint/parser": "2.34.0",
|
||||
"acorn": "^8.0.1",
|
||||
"coveralls": "3.1.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"eslint": "6.8.0",
|
||||
"jest": "24.9.0",
|
||||
"nock": "11.7.2",
|
||||
"release-it": "12.4.3",
|
||||
"ts-jest": "24.3.0",
|
||||
"ts-loader": "6.2.1",
|
||||
"typescript": "3.7.4",
|
||||
"webpack": "4.41.5",
|
||||
"webpack-cli": "3.3.10"
|
||||
"jest": "25.5.4",
|
||||
"jest-ts-auto-mock": "^1.0.11",
|
||||
"kind-of": "^6.0.3",
|
||||
"minimist": ">=1.2.3",
|
||||
"nock": "13.0.5",
|
||||
"release-it": "14.2.1",
|
||||
"ts-auto-mock": "^2.6.5",
|
||||
"ts-jest": "25.5.1",
|
||||
"ts-loader": "8.0.10",
|
||||
"ttypescript": "^1.5.10",
|
||||
"typescript": "3.9.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "13.1.7",
|
||||
"@types/jest": "24.0.25",
|
||||
"https-proxy-agent": "4.0.0"
|
||||
"https-proxy-agent": "5.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@types/node": "14.0.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -29,70 +27,104 @@ import {
|
||||
MessageType,
|
||||
PaymentRequest,
|
||||
PaymentTransaction,
|
||||
ReversalReasonType,
|
||||
ReversalRequest,
|
||||
SaleData,
|
||||
SaleToPoiRequest,
|
||||
SaleToPOIRequest,
|
||||
TerminalApiRequest,
|
||||
TransactionIdentification,
|
||||
} from "../typings/terminal";
|
||||
TransactionIdentification
|
||||
} from "../typings/terminal/models";
|
||||
|
||||
export const createMockClientFromResponse = (): Client => {
|
||||
export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
|
||||
const config: Config = new Config();
|
||||
config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
||||
config.terminalApiLocalEndpoint = "https://mocked_local_endpoint.com";
|
||||
config.hmacKey = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
|
||||
config.endpoint = Client.ENDPOINT_TEST;
|
||||
config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||
config.apiKey = "MOCKED_API_KEY";
|
||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
config.apiKey = apiKey;
|
||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
|
||||
const client: Client = new Client({ config });
|
||||
|
||||
return client;
|
||||
return new Client({ config });
|
||||
};
|
||||
|
||||
export const createBasicAuthClient = (): Client => {
|
||||
return new Client({
|
||||
username: process.env.ADYEN_USER!,
|
||||
password: process.env.ADYEN_PASSWORD!,
|
||||
environment: "TEST",
|
||||
applicationName: "adyen-node-api-library"
|
||||
});
|
||||
};
|
||||
|
||||
const id = Math.floor(Math.random() * Math.floor(10000000)).toString();
|
||||
const getMessageHeader = ({ messageCategory = MessageCategoryType.Payment }: { messageCategory?: MessageCategoryType } = {}): MessageHeader => ({
|
||||
messageCategory,
|
||||
messageClass: MessageClassType.Service,
|
||||
messageType: MessageType.Request,
|
||||
pOIID: process.env.ADYEN_TERMINAL_POIID!,
|
||||
protocolVersion: "3.0",
|
||||
saleID: id,
|
||||
serviceID: id,
|
||||
});
|
||||
|
||||
const timestamp = (): string => new Date().toISOString();
|
||||
const transactionIdentification: TransactionIdentification = {
|
||||
timeStamp: timestamp(),
|
||||
transactionID: id,
|
||||
};
|
||||
|
||||
const saleData: SaleData = {
|
||||
saleTransactionID: transactionIdentification,
|
||||
saleToAcquirerData: {
|
||||
applicationInfo: {
|
||||
merchantApplication: {
|
||||
version: "1",
|
||||
name: "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const amountsReq: AmountsReq = {
|
||||
currency: "EUR",
|
||||
requestedAmount: 1,
|
||||
};
|
||||
|
||||
const paymentTransaction: PaymentTransaction = {
|
||||
amountsReq,
|
||||
};
|
||||
|
||||
const paymentRequest: PaymentRequest = {
|
||||
paymentTransaction,
|
||||
saleData,
|
||||
};
|
||||
|
||||
const getReversalRequest = (poiTransaction: TransactionIdentification): ReversalRequest => ({
|
||||
originalPOITransaction: {
|
||||
pOITransactionID: {
|
||||
transactionID: poiTransaction.transactionID,
|
||||
timeStamp: poiTransaction.timeStamp
|
||||
},
|
||||
},
|
||||
reversalReason: ReversalReasonType.MerchantCancel
|
||||
});
|
||||
|
||||
const getSaleToPOIRequest = (messageHeader: MessageHeader, request: Partial<SaleToPOIRequest>): SaleToPOIRequest => ({
|
||||
messageHeader,
|
||||
...request
|
||||
});
|
||||
|
||||
|
||||
export const createTerminalAPIPaymentRequest = (): TerminalApiRequest => {
|
||||
|
||||
const messageHeader: MessageHeader = {
|
||||
messageCategory: MessageCategoryType.Payment,
|
||||
messageClass: MessageClassType.Service,
|
||||
messageType: MessageType.Request,
|
||||
poiid: "P400Plus-123456789",
|
||||
protocolVersion: "3.0",
|
||||
saleId: "001",
|
||||
serviceId: "001",
|
||||
};
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
const transactionIdentification: TransactionIdentification = {
|
||||
timeStamp: timestamp,
|
||||
transactionId: "001",
|
||||
};
|
||||
|
||||
const saleData: SaleData = {
|
||||
saleTransactionId: transactionIdentification,
|
||||
};
|
||||
|
||||
const amountsReq: AmountsReq = {
|
||||
currency: "EUR",
|
||||
requestedAmount: 1,
|
||||
};
|
||||
|
||||
const paymentTransaction: PaymentTransaction = {
|
||||
amountsReq: amountsReq,
|
||||
};
|
||||
|
||||
const paymentRequest: PaymentRequest = {
|
||||
paymentTransaction: paymentTransaction,
|
||||
saleData: saleData,
|
||||
};
|
||||
|
||||
const saleToPOIRequest: SaleToPoiRequest = {
|
||||
messageHeader: messageHeader,
|
||||
paymentRequest: paymentRequest,
|
||||
};
|
||||
|
||||
const terminalApiRequest: TerminalApiRequest = {
|
||||
saleToPoiRequest: saleToPOIRequest,
|
||||
};
|
||||
|
||||
return terminalApiRequest;
|
||||
const messageHeader = getMessageHeader();
|
||||
const saleToPOIRequest = getSaleToPOIRequest(messageHeader, { paymentRequest });
|
||||
return { saleToPOIRequest };
|
||||
};
|
||||
|
||||
export const createTerminalAPIRefundRequest = (transactionIdentification: TransactionIdentification): TerminalApiRequest => {
|
||||
const messageHeader = getMessageHeader({ messageCategory: MessageCategoryType.Reversal });
|
||||
const saleToPOIRequest = getSaleToPOIRequest(messageHeader, { reversalRequest: getReversalRequest(transactionIdentification) });
|
||||
return { saleToPOIRequest };
|
||||
};
|
||||
|
||||
26
src/__mocks__/checkout/originkeysSuccess.ts
Normal file
26
src/__mocks__/checkout/originkeysSuccess.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const originKeysSuccess = JSON.stringify({
|
||||
originKeys: {
|
||||
"https://www.your-domain.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI",
|
||||
"https://www.your-domain2.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4yLmNvbQ.EP6eXBJKk0t7-QIUl6e_b1qMuMHGepxG_SlUqxAYrfY",
|
||||
"https://www.your-domain3.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4zLmNvbQ.fUvflu-YIdZSsLEH8Qqmr7ksE4ag_NYiiMXK0s6aq_4",
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentMethodsSuccess = JSON.stringify({
|
||||
paymentMethods: [
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentSessionError = {
|
||||
statusCode: 422,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const paymentMethodsError = {
|
||||
errorCode: "901",
|
||||
errorType: "security",
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentDetailsError = {
|
||||
statusCode: 422,
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentDetailsSuccess = JSON.stringify({
|
||||
pspReference: "8515232733321252",
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentsError = JSON.stringify({
|
||||
statusCode: 422,
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentsResultError = JSON.stringify({
|
||||
statusCode: 422,
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentsResultMultibancoSuccess = {
|
||||
additionalData: {
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentsResultSuccess = JSON.stringify({
|
||||
pspReference: "8535253563623704",
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 paymentsSuccess = JSON.stringify({
|
||||
additionalData: {
|
||||
@@ -10,6 +29,7 @@ export const paymentsSuccess = JSON.stringify({
|
||||
alias: "H167852639363479",
|
||||
cardPaymentMethod: "visa",
|
||||
cardIssuingCountry: "NL",
|
||||
"recurring.recurringDetailReference": "8415883203388055",
|
||||
},
|
||||
fraudResult: {
|
||||
accountScore: 0,
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export const originKeysSuccess = JSON.stringify({
|
||||
originKeys: {
|
||||
"https://www.your-domain1.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI",
|
||||
"https://www.your-domain2.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4yLmNvbQ.EP6eXBJKk0t7-QIUl6e_b1qMuMHGepxG_SlUqxAYrfY",
|
||||
"https://www.your-domain3.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4zLmNvbQ.fUvflu-YIdZSsLEH8Qqmr7ksE4ag_NYiiMXK0s6aq_4",
|
||||
},
|
||||
});
|
||||
@@ -22,4 +22,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
2
src/__mocks__/platforms/documentContent.ts
Normal file
2
src/__mocks__/platforms/documentContent.ts
Normal file
File diff suppressed because one or more lines are too long
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const disableSuccess = {
|
||||
response: "[detail-successfully-disabled]",
|
||||
};
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const listRecurringDetailsSuccess = {
|
||||
creationDate: "2017-03-01T10:53:11.000",
|
||||
details: [
|
||||
|
||||
@@ -1 +1,20 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const asyncRes = "ok";
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
export const localSecuredRes = JSON.stringify({
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const localSecuredRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
@@ -9,326 +28,11 @@ export const localSecuredRes = JSON.stringify({
|
||||
SaleID: "325488592",
|
||||
ServiceID: "325488592"
|
||||
},
|
||||
paymentResponse: {
|
||||
paymentReceipt: [
|
||||
{
|
||||
documentQualifier: "CashierReceipt",
|
||||
outputContent: {
|
||||
outputFormat: "Text",
|
||||
outputText: [
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "key=header1"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "key=header2"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=MERCHANT%20COPY&key=merchantTitle"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Date&value=08%2f05%2f19&key=txdate"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Time&value=15%3a25%3a15&key=txtime"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Card&value=%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a0010&key=pan"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=PAN%20seq.&value=01&key=panSeq"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Pref.%20name&value=PPC%20MCD%2001%20v2%202&key=preferredName"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Card%20type&value=mc&key=cardType"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Payment%20method&value=mc&key=paymentMethod"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Payment%20variant&value=mc&key=paymentMethodVariant"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Entry%20mode&value=Contactless%20chip&key=posEntryMode"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=AID&value=A0000000041010&key=aid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=MID&value=1000&key=mid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=TID&value=P400Plus-275039202&key=tid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=PTID&value=75039202&key=ptid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Auth.%20code&value=123456&key=authCode"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Tender&value=4r7i001557325515012&key=txRef"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Reference&value=999&key=mref"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Type&value=GOODS_SERVICES&key=txtype"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=TOTAL&value=%e2%82%ac%c2%a01.00&key=totalAmount"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=APPROVED&key=approved"
|
||||
}
|
||||
]
|
||||
},
|
||||
requiredSignatureFlag: false
|
||||
},
|
||||
{
|
||||
documentQualifier: "CustomerReceipt",
|
||||
outputContent: {
|
||||
outputFormat: "Text",
|
||||
outputText: [
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "key=header1"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "key=header2"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=CARDHOLDER%20COPY&key=cardholderHeader"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Date&value=08%2f05%2f19&key=txdate"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Time&value=15%3a25%3a15&key=txtime"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Card&value=%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a0010&key=pan"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=PAN%20seq.&value=01&key=panSeq"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Pref.%20name&value=PPC%20MCD%2001%20v2%202&key=preferredName"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Card%20type&value=mc&key=cardType"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Payment%20method&value=mc&key=paymentMethod"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Payment%20variant&value=mc&key=paymentMethodVariant"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Entry%20mode&value=Contactless%20chip&key=posEntryMode"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=AID&value=A0000000041010&key=aid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=MID&value=1000&key=mid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=TID&value=P400Plus-275039202&key=tid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=PTID&value=75039202&key=ptid"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Auth.%20code&value=123456&key=authCode"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Tender&value=4r7i001557325515012&key=txRef"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Reference&value=999&key=mref"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Type&value=GOODS_SERVICES&key=txtype"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=TOTAL&value=%e2%82%ac%c2%a01.00&key=totalAmount"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
characterStyle: "Bold",
|
||||
endOfLineFlag: true,
|
||||
text: "name=APPROVED&key=approved"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "key=filler"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Please%20retain%20for%20your%20records&key=retain"
|
||||
},
|
||||
{
|
||||
endOfLineFlag: true,
|
||||
text: "name=Thank%20you&key=thanks"
|
||||
}
|
||||
]
|
||||
},
|
||||
requiredSignatureFlag: false
|
||||
}
|
||||
],
|
||||
paymentResult: {
|
||||
amountsResp: {
|
||||
authorizedAmount: 1,
|
||||
currency: "EUR"
|
||||
},
|
||||
onlineFlag: true,
|
||||
paymentAcquirerData: {
|
||||
acquirerPoiid: "P400Plus-275039202",
|
||||
acquirerTransactionId: {
|
||||
timeStamp: "2019-05-08T14:25:15.000Z",
|
||||
transactionId: "8815573255107661"
|
||||
},
|
||||
approvalCode: "123456",
|
||||
merchantId: "TestMerchantRenatoTest"
|
||||
},
|
||||
paymentInstrumentData: {
|
||||
cardData: {
|
||||
cardCountryCode: "056",
|
||||
entryMode: [
|
||||
"Contactless"
|
||||
],
|
||||
maskedPan: "541333 **** 0010",
|
||||
paymentBrand: "mc",
|
||||
sensitiveCardData: {
|
||||
cardSeqNumb: "01",
|
||||
expiryDate: "1225"
|
||||
}
|
||||
},
|
||||
paymentInstrumentType: "Card"
|
||||
}
|
||||
},
|
||||
poiData: {
|
||||
poiReconciliationId: "1000",
|
||||
poiTransactionId: {
|
||||
timeStamp: "2019-05-08T14:25:15.000Z",
|
||||
transactionId: "4r7i001557325515012.8815573255107661"
|
||||
}
|
||||
},
|
||||
response: {
|
||||
additionalResponse: "tid=75039202&AID=A0000000041010&transactionType=GOODS_SERVICES&backendGiftcardIndicator=false&expiryYear=2025&acquirerAccountCode=TestPmmAcquirerAccount&alias=K182596230843790&posOriginalAmountCurrency=EUR&giftcardIndicator=false&authorisedAmountValue=100&pspReference=8815573255107661&paymentMethodVariant=mc&cardHolderName=N%2fA&refusalReasonRaw=APPROVED&authorisationMid=1000&expiryDate=12%2f2025&applicationPreferredName=PPC%20MCD%2001%20v2%202&isCardCommercial=unknown&acquirerCode=TestPmmAcquirer&txtime=15%3a25%3a15&iso8601TxDate=2019-05-08T14%3a25%3a15.0000000%2b0000&cardType=mc&posOriginalAmountValue=100&offline=false&aliasType=Default&txdate=08-05-2019&paymentMethod=mc&cvcResult=0%20Unknown&startYear=2030&tc=A767D7547D930504&avsResult=0%20Unknown&cardIssueNumber=1&mid=1000&merchantReference=999&transactionReferenceNumber=8815573255107661&expiryMonth=12&cardSummary=0010&posTotalAmountValue=100&posAuthAmountCurrency=EUR&cardHolderVerificationMethodResults=1F0302&authCode=123456&cardIssuerCountryId=056&shopperCountry=NL&posEntryMode=CLESS_CHIP&startMonth=34&fundingSource=CREDIT&cardScheme=mc&cardBin=541333&posAuthAmountValue=100",
|
||||
result: "Success"
|
||||
},
|
||||
saleData: {
|
||||
saleTransactionId: {
|
||||
timeStamp: "2019-05-08T14:24:48.598Z",
|
||||
transactionId: "999"
|
||||
}
|
||||
}
|
||||
}
|
||||
PaymentResponse: {}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const localEncRes = JSON.stringify({
|
||||
export const localEncRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
@@ -434,9 +138,9 @@ export const localEncRes = JSON.stringify({
|
||||
Nonce: "9iiJMpzKfYs3106ozIKNFQ==",
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const wrongEncRes = JSON.stringify({
|
||||
export const wrongEncRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
@@ -542,4 +246,4 @@ export const wrongEncRes = JSON.stringify({
|
||||
Nonce: "9iiJMpzKfYs3106ozIKNFQ==",
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,32 @@
|
||||
export const syncRes = JSON.stringify({
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 const syncRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
MessageClass: "Service",
|
||||
MessageType: "Response",
|
||||
POIID: "P400Plus-123456789",
|
||||
POIID: process.env.ADYEN_TERMINAL_POIID,
|
||||
ProtocolVersion: "3.0",
|
||||
SaleID: "001",
|
||||
ServiceID: "1234567890",
|
||||
ServiceID: "001",
|
||||
},
|
||||
PaymentResponse: {
|
||||
POIData: {
|
||||
@@ -326,4 +345,23 @@ export const syncRes = JSON.stringify({
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const syncRefund = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
MessageClass: "Service",
|
||||
MessageType: "Response",
|
||||
POIID: process.env.ADYEN_TERMINAL_POIID,
|
||||
ProtocolVersion: "3.0",
|
||||
SaleID: "001",
|
||||
ServiceID: "001",
|
||||
},
|
||||
ReversalResponse: {
|
||||
Response: {
|
||||
Result: "Success"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,34 +11,24 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {createMockClientFromResponse} from "../__mocks__/base";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import BinLookup from "../services/binLookup";
|
||||
import Client from "../client";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
const threeDSAvailabilitySuccess = {
|
||||
dsPublicKeys: [{
|
||||
brand: "visa",
|
||||
directoryServerId: "F013371337",
|
||||
publicKey: "eyJrdHkiOiJSU0EiLCJlIjoiQVFBQiIsIm4iOiI4VFBxZkFOWk4xSUEzcHFuMkdhUVZjZ1g4LUpWZ1Y0M2diWURtYmdTY0N5SkVSN3lPWEJqQmQyaTBEcVFBQWpVUVBXVUxZU1FsRFRKYm91bVB1aXVoeVMxUHN2NTM4UHBRRnEySkNaSERkaV85WThVZG9hbmlrU095c2NHQWtBVmJJWHA5cnVOSm1wTTBwZ0s5VGxJSWVHYlE3ZEJaR01OQVJLQXRKeTY3dVlvbVpXV0ZBbWpwM2d4SDVzNzdCR2xkaE9RUVlQTFdybDdyS0pLQlUwNm1tZlktUDNpazk5MmtPUTNEak02bHR2WmNvLThET2RCR0RKYmdWRGFmb29LUnVNd2NUTXhDdTRWYWpyNmQyZkppVXlqNUYzcVBrYng4WDl6a1c3UmlxVno2SU1qdE54NzZicmg3aU9Vd2JiWmoxYWF6VG1GQ2xEb0dyY2JxOV80Nnc9PSJ9"
|
||||
}],
|
||||
binDetails: {
|
||||
issuerCountry: "NL"
|
||||
},
|
||||
threeDS1Supported: true,
|
||||
threeDS2CardRangeDetails: [{
|
||||
brandCode: "visa",
|
||||
endRange: "411111111111",
|
||||
startRange: "411111111111",
|
||||
threeDS2Version: "2.1.0",
|
||||
threeDSMethodURL: "https://pal-test.adyen.com/threeds2simulator/acs/startMethod.shtml"
|
||||
}],
|
||||
threeDS2supported: true
|
||||
threeDS2CardRangeDetails: [],
|
||||
threeDS2supported: false
|
||||
};
|
||||
|
||||
let client: Client;
|
||||
@@ -46,15 +36,23 @@ let binLookup: BinLookup;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
binLookup = new BinLookup(client);
|
||||
scope = nock(`${client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}`);
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Bin Lookup", function (): void {
|
||||
it("should succeed on get 3ds availability", async function (): Promise<void> {
|
||||
test.each([false, true])("should succeed on get 3ds availability. isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
const threeDSAvailabilityRequest: IBinLookup.ThreeDSAvailabilityRequest = {
|
||||
merchantAccount: "MOCK_MERCHANT_ACCOUNT",
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
brands: ["randomBrand"],
|
||||
cardNumber: "4111111111111111"
|
||||
};
|
||||
@@ -64,10 +62,11 @@ describe("Bin Lookup", function (): void {
|
||||
|
||||
const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
||||
|
||||
expect(response).toEqual(threeDSAvailabilitySuccess);
|
||||
expect(response).toEqual<IBinLookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
||||
});
|
||||
|
||||
it("should fail with invalid merchant", async function (): Promise<void> {
|
||||
test.each([false, true])("should fail with invalid merchant. isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
const threeDSAvailabilityRequest: { [key: string]: undefined|string|[] } = {
|
||||
merchantAccount: undefined,
|
||||
cardNumber: "4111111111111",
|
||||
@@ -85,9 +84,13 @@ describe("Bin Lookup", function (): void {
|
||||
}
|
||||
});
|
||||
|
||||
it("should succeed on get cost estimate", async function (): Promise<void> {
|
||||
const response = {
|
||||
cardBin: {summary: "1111"},
|
||||
test.each([false, true])("should succeed on get cost estimate. isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
const expected = {
|
||||
costEstimateAmount: {
|
||||
currency: "EUR",
|
||||
value: 10
|
||||
},
|
||||
resultCode: "Unsupported",
|
||||
surchargeType: "ZERO"
|
||||
};
|
||||
@@ -98,7 +101,7 @@ describe("Bin Lookup", function (): void {
|
||||
assume3DSecureAuthenticated: true
|
||||
},
|
||||
cardNumber: "411111111111",
|
||||
merchantAccount: "MOCKED_MERCHANT_ACC",
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
merchantDetails: {
|
||||
countryCode: "NL",
|
||||
mcc: "7411",
|
||||
@@ -108,9 +111,9 @@ describe("Bin Lookup", function (): void {
|
||||
};
|
||||
|
||||
scope.post("/getCostEstimate")
|
||||
.reply(200, response);
|
||||
.reply(200, expected);
|
||||
|
||||
const expected = await binLookup.getCostEstimate(costEstimateRequest);
|
||||
const response = await binLookup.getCostEstimate(costEstimateRequest);
|
||||
|
||||
expect(response).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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/camelcase */
|
||||
|
||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||
import {PeerCertificate} from "tls";
|
||||
import { PeerCertificate } from "tls";
|
||||
|
||||
const createMockedCertificate = (CN: string): PeerCertificate => ({
|
||||
subjectaltname: "Adyen B.V",
|
||||
@@ -29,6 +48,7 @@ const createMockedCertificate = (CN: string): PeerCertificate => ({
|
||||
valid_from: "Nov 19 15:03:32 2018 GMT",
|
||||
valid_to: "Nov 11 15:03:32 2048 GMT",
|
||||
fingerprint: "MOCKED_FINGERPRINT",
|
||||
fingerprint256: "MOCKED_FINGERPRINT_256",
|
||||
ext_key_usage: ["1.2.3.4.5.6.7.8"],
|
||||
serialNumber: "1000",
|
||||
raw: Buffer.from("test")
|
||||
|
||||
@@ -11,28 +11,28 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess";
|
||||
import {paymentsSuccess} from "../__mocks__/checkout/paymentsSuccess";
|
||||
import {paymentDetailsSuccess} from "../__mocks__/checkout/paymentsDetailsSuccess";
|
||||
import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess";
|
||||
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
|
||||
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import { paymentMethodsSuccess } from "../__mocks__/checkout/paymentMethodsSuccess";
|
||||
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess";
|
||||
import { paymentDetailsSuccess } from "../__mocks__/checkout/paymentsDetailsSuccess";
|
||||
import { paymentSessionSuccess } from "../__mocks__/checkout/paymentSessionSucess";
|
||||
import { originKeysSuccess } from "../__mocks__/checkout/originkeysSuccess";
|
||||
import { paymentsResultMultibancoSuccess } from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
|
||||
import { paymentsResultSuccess } from "../__mocks__/checkout/paymentsResultSucess";
|
||||
import Client from "../client";
|
||||
import Checkout from "../services/checkout";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
const merchantAccount = "MagentoMerchantTest";
|
||||
const merchantAccount = process.env.ADYEN_MERCHANT!;
|
||||
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): ICheckout.Amount {
|
||||
return {
|
||||
@@ -54,8 +54,8 @@ function createPaymentsDetailsRequest(): ICheckout.DetailsRequest {
|
||||
export function createPaymentsCheckoutRequest(): ICheckout.PaymentRequest {
|
||||
const paymentMethodDetails = {
|
||||
cvc: "737",
|
||||
expiryMonth: "10",
|
||||
expiryYear: "2018",
|
||||
expiryMonth: "03",
|
||||
expiryYear: "2030",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111",
|
||||
type: "scheme",
|
||||
@@ -67,6 +67,8 @@ export function createPaymentsCheckoutRequest(): ICheckout.PaymentRequest {
|
||||
paymentMethod: paymentMethodDetails,
|
||||
reference,
|
||||
returnUrl: "https://your-company.com/...",
|
||||
shopperReference: "shopperReference",
|
||||
storePaymentMethod: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,6 +79,48 @@ function createPaymentSessionRequest(): ICheckout.PaymentSetupRequest {
|
||||
merchantAccount,
|
||||
reference,
|
||||
returnUrl: "https://your-company.com/...",
|
||||
channel: "Web",
|
||||
sdkVersion: "3.7.0"
|
||||
};
|
||||
}
|
||||
function getPaymentLinkSuccess(expiresAt: string): ICheckout.PaymentLinkResource {
|
||||
return {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
expiresAt,
|
||||
reference,
|
||||
url: "paymentLinkResponse.url",
|
||||
id: "mocked_id",
|
||||
merchantAccount,
|
||||
status: "active"
|
||||
};
|
||||
}
|
||||
|
||||
function createPaymentLinkRequest(): ICheckout.CreatePaymentLinkRequest {
|
||||
return {
|
||||
allowedPaymentMethods: ["scheme", "boletobancario"],
|
||||
amount: createAmountObject("USD", 1000),
|
||||
countryCode: "BR",
|
||||
merchantAccount,
|
||||
shopperReference: "shopperReference",
|
||||
shopperEmail: "test@email.com",
|
||||
shopperLocale: "pt_BR",
|
||||
billingAddress: {
|
||||
street: "Roque Petroni Jr",
|
||||
postalCode: "59000060",
|
||||
city: "São Paulo",
|
||||
houseNumberOrName: "999",
|
||||
country: "BR",
|
||||
stateOrProvince: "SP"
|
||||
},
|
||||
deliveryAddress: {
|
||||
street: "Roque Petroni Jr",
|
||||
postalCode: "59000060",
|
||||
city: "São Paulo",
|
||||
houseNumberOrName: "999",
|
||||
country: "BR",
|
||||
stateOrProvince: "SP"
|
||||
},
|
||||
reference
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,22 +129,31 @@ let checkout: Checkout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`);
|
||||
checkout = new Checkout(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Checkout", (): void => {
|
||||
it("should make a payment", async (): Promise<void> => {
|
||||
test.each([false, true])("should make a payment. isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsSuccess);
|
||||
|
||||
const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments(paymentsRequest);
|
||||
expect(paymentsResponse.pspReference).toEqual("8535296650153317");
|
||||
expect(paymentsResponse.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should return correct Exception", async (): Promise<void> => {
|
||||
test.each([false, true])("should return correct Exception, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
try {
|
||||
scope.post("/payments")
|
||||
.reply(401);
|
||||
@@ -112,7 +165,8 @@ describe("Checkout", (): void => {
|
||||
}
|
||||
});
|
||||
|
||||
it("should have valid payment methods", async (): Promise<void> => {
|
||||
test.each([false, true])("should have valid payment methods, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const paymentMethodsRequest: ICheckout.PaymentMethodsRequest = {merchantAccount: "MagentoMerchantTest"};
|
||||
|
||||
scope.post("/paymentMethods")
|
||||
@@ -120,58 +174,53 @@ describe("Checkout", (): void => {
|
||||
|
||||
const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest);
|
||||
if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) {
|
||||
expect(paymentMethodsResponse.paymentMethods.length).toEqual(65);
|
||||
expect(paymentMethodsResponse.paymentMethods[0].name).toEqual("AliPay");
|
||||
expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should have valid payment link", async (): Promise<void> => {
|
||||
const amount = createAmountObject("BRL", 1000);
|
||||
test.each([false, true])("should have valid payment link, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const paymentLinkRequest: ICheckout.CreatePaymentLinkRequest = {
|
||||
allowedPaymentMethods: ["scheme", "boletobancario"],
|
||||
amount,
|
||||
countryCode: "BR",
|
||||
merchantAccount,
|
||||
shopperReference: "shopperReference",
|
||||
shopperEmail: "test@email.com",
|
||||
shopperLocale: "pt_BR",
|
||||
billingAddress: {
|
||||
street: "Roque Petroni Jr",
|
||||
postalCode: "59000060",
|
||||
city: "São Paulo",
|
||||
houseNumberOrName: "999",
|
||||
country: "BR",
|
||||
stateOrProvince: "SP"
|
||||
},
|
||||
deliveryAddress: {
|
||||
street: "Roque Petroni Jr",
|
||||
postalCode: "59000060",
|
||||
city: "São Paulo",
|
||||
houseNumberOrName: "999",
|
||||
country: "BR",
|
||||
stateOrProvince: "SP"
|
||||
},
|
||||
expiresAt,
|
||||
reference
|
||||
};
|
||||
|
||||
const paymentLinkSuccess: ICheckout.CreatePaymentLinkResponse = {
|
||||
amount,
|
||||
expiresAt,
|
||||
reference,
|
||||
url: "paymentLinkResponse.url"
|
||||
};
|
||||
const paymentLinkSuccess: ICheckout.PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
||||
|
||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||
|
||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(paymentLinkRequest);
|
||||
expect(paymentLinkSuccess).toEqual(paymentSuccessLinkResponse);
|
||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
||||
expect(paymentSuccessLinkResponse).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have payment details", async (): Promise<void> => {
|
||||
test.each([isCI, true])("should get payment link, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const paymentLinkSuccess: ICheckout.PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
||||
|
||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||
|
||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
||||
|
||||
scope.get(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, paymentLinkSuccess);
|
||||
const paymentLink = await checkout.getPaymentLinks(paymentSuccessLinkResponse.id);
|
||||
expect(paymentLink).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should patch payment link, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const paymentLinkSuccess: ICheckout.PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
||||
|
||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||
|
||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
||||
|
||||
scope.patch(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, { ...paymentLinkSuccess, status: "expired" });
|
||||
const paymentLink = await checkout.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired");
|
||||
expect(paymentLink.status).toEqual("expired");
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should have payment details, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments/details")
|
||||
.reply(200, paymentDetailsSuccess);
|
||||
|
||||
@@ -179,7 +228,8 @@ describe("Checkout", (): void => {
|
||||
expect(paymentsResponse.resultCode).toEqual("Authorised");
|
||||
});
|
||||
|
||||
it("should have payment session success", async (): Promise<void> => {
|
||||
test.each([false, true])("should have payment session success, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/paymentSession")
|
||||
.reply(200, paymentSessionSuccess);
|
||||
const paymentSessionRequest: ICheckout.PaymentSetupRequest = createPaymentSessionRequest();
|
||||
@@ -187,7 +237,8 @@ describe("Checkout", (): void => {
|
||||
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("should have payments result", async (): Promise<void> => {
|
||||
test.each([isCI, true])("should have payments result, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments/result")
|
||||
.reply(200, paymentsResultSuccess);
|
||||
const paymentResultRequest: ICheckout.PaymentVerificationRequest = {
|
||||
@@ -197,7 +248,8 @@ describe("Checkout", (): void => {
|
||||
expect(paymentResultResponse.resultCode).toEqual("Authorised");
|
||||
});
|
||||
|
||||
it("should have missing identifier on live", async (): Promise<void> => {
|
||||
test.each([false, true])("should have missing identifier on live, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
client.setEnvironment("LIVE");
|
||||
try {
|
||||
new Checkout(client);
|
||||
@@ -208,19 +260,100 @@ describe("Checkout", (): void => {
|
||||
});
|
||||
|
||||
|
||||
it("should succeed on multibanco payment", async (): Promise<void> => {
|
||||
test.each([false, true])("should succeed on multibanco payment, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsResultMultibancoSuccess);
|
||||
|
||||
const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments(paymentsRequest);
|
||||
expect(paymentsResponse.pspReference).toEqual("8111111111111111");
|
||||
|
||||
if (paymentsResponse.additionalData) {
|
||||
expect(paymentsResponse.additionalData["comprafacil.amount"]).toEqual("101.01");
|
||||
expect(paymentsResponse.additionalData["comprafacil.deadline"]).toEqual("3");
|
||||
expect(paymentsResponse.additionalData["comprafacil.entity"]).toEqual("12345");
|
||||
expect(paymentsResponse.pspReference).toBeTruthy();
|
||||
expect(paymentsResponse.additionalData).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([false, true])("should get origin keys. isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const checkoutUtility = new Checkout(client);
|
||||
const originKeysRequest: ICheckout.CheckoutUtilityRequest = {
|
||||
originDomains: ["https://www.your-domain.com"],
|
||||
};
|
||||
|
||||
nock(`${client.config.checkoutEndpoint}`)
|
||||
.post(`/${Client.CHECKOUT_API_VERSION}/originKeys`)
|
||||
.reply(200, originKeysSuccess);
|
||||
|
||||
const originKeysResponse = await checkoutUtility.originKeys(originKeysRequest);
|
||||
if (originKeysResponse.originKeys) {
|
||||
return expect(originKeysResponse.originKeys["https://www.your-domain.com"].startsWith("pub.v2")).toBeTruthy();
|
||||
}
|
||||
fail("Error: originKeysResponse.originKeys is empty");
|
||||
});
|
||||
|
||||
// TODO: add gift card to PaymentMethod and unmock test
|
||||
test.each([true, true])("should get payment methods balance", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const paymentMethodsRequest: ICheckout.CheckoutBalanceCheckRequest = {
|
||||
merchantAccount,
|
||||
amount: createAmountObject("USD", 1000),
|
||||
paymentMethod: { },
|
||||
reference: "mocked_reference"
|
||||
};
|
||||
|
||||
const paymentMethodsBalanceResponse: ICheckout.CheckoutBalanceCheckResponse = { balance: {currency: "USD", value: 1000}};
|
||||
scope.post("/paymentMethods/balance")
|
||||
.reply(200, paymentMethodsBalanceResponse);
|
||||
|
||||
const paymentsResponse: ICheckout.CheckoutBalanceCheckResponse = await checkout.paymentMethodsBalance(paymentMethodsRequest);
|
||||
expect(paymentsResponse.balance.value).toEqual(1000);
|
||||
});
|
||||
|
||||
test.each([false, true])("should create order", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const orderRequest: ICheckout.CheckoutCreateOrderRequest = {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount,
|
||||
reference
|
||||
};
|
||||
|
||||
const orderResponse: ICheckout.CheckoutCreateOrderResponse = {expiresAt, orderData: "mocked_order_data", remainingAmount: {currency: "USD", value: 500} };
|
||||
scope.post("/orders")
|
||||
.reply(200, orderResponse);
|
||||
|
||||
const response: ICheckout.CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([false, true])("should cancel order", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const expiresAt = "2019-12-17T10:05:29Z";
|
||||
const orderRequest: ICheckout.CheckoutCreateOrderRequest = {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount,
|
||||
reference
|
||||
};
|
||||
|
||||
const orderResponse: ICheckout.CheckoutCreateOrderResponse = {expiresAt, orderData: "mocked_order_data", remainingAmount: {currency: "USD", value: 500} };
|
||||
scope.post("/orders")
|
||||
.reply(200, orderResponse);
|
||||
|
||||
const createOrderResponse: ICheckout.CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
|
||||
|
||||
const orderCancelResponse: ICheckout.CheckoutCancelOrderResponse = {
|
||||
pspReference: "mocked_psp_ref",
|
||||
resultCode: "CANCELLED"
|
||||
};
|
||||
scope.post("/orders/cancel")
|
||||
.reply(200, orderCancelResponse);
|
||||
|
||||
const response: ICheckout.CheckoutCancelOrderResponse = await checkout.ordersCancel({
|
||||
order: {
|
||||
orderData: createOrderResponse.orderData,
|
||||
pspReference: createOrderResponse.pspReference!
|
||||
},
|
||||
merchantAccount
|
||||
});
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 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 { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import {originKeysSuccess} from "../__mocks__/checkoutUtility/originkeysSuccess";
|
||||
import CheckoutUtility from "../services/checkoutUtility";
|
||||
import Client from "../client";
|
||||
|
||||
describe("Checkout Utility", (): void => {
|
||||
it("should get origin keys", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse();
|
||||
const checkoutUtility = new CheckoutUtility(client);
|
||||
const originKeysRequest: ICheckoutUtility.CheckoutUtilityRequest = {
|
||||
originDomains: ["www.test.com", "https://www.your-domain2.com"],
|
||||
};
|
||||
|
||||
nock(`${client.config.checkoutEndpoint}`)
|
||||
.post(`/${Client.CHECKOUT_UTILITY_API_VERSION}/originKeys`)
|
||||
.reply(200, originKeysSuccess);
|
||||
|
||||
const originKeysResponse = await checkoutUtility.originKeys(originKeysRequest);
|
||||
if (originKeysResponse.originKeys) {
|
||||
return expect(originKeysResponse.originKeys["https://www.your-domain1.com"])
|
||||
.toEqual("pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI");
|
||||
}
|
||||
fail("Error: originKeysResponse.originKeys is empty");
|
||||
});
|
||||
});
|
||||
@@ -1,22 +1,49 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {NotificationRequestItem} from "../typings/notification";
|
||||
import {ApiConstants} from "../constants/apiConstants";
|
||||
import { AdditionalData, NotificationItem, NotificationRequestItem } from "../typings/notification/models";
|
||||
import { ApiConstants } from "../constants/apiConstants";
|
||||
import NotificationRequest from "../notification/notificationRequest";
|
||||
|
||||
const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
|
||||
const expectedSign = "ipnxGCaUZ4l8TUW75a71/ghd2Fe5ffvX0pV4TLTntIc=";
|
||||
const notificationRequestItem: NotificationRequestItem = {
|
||||
pspReference: "pspReference",
|
||||
originalReference: "originalReference",
|
||||
merchantAccountCode: "merchantAccount",
|
||||
merchantReference: "reference",
|
||||
amount: {currency: "EUR", value: 1000},
|
||||
eventCode: "EVENT",
|
||||
eventDate: new Date("01-01-1970"),
|
||||
paymentMethod: "VISA",
|
||||
reason: "reason",
|
||||
success: "true",
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE]: expectedSign },
|
||||
const expectedSign = "ZNBPtI+oDyyRrLyD1XirkKnQgIAlFc07Vj27TeHsDRE=";
|
||||
|
||||
const notificationRequestItem: { NotificationRequestItem: NotificationRequestItem } = {
|
||||
NotificationRequestItem : {
|
||||
pspReference: "pspReference",
|
||||
originalReference: "originalReference",
|
||||
merchantAccountCode: "merchantAccount",
|
||||
merchantReference: "reference",
|
||||
amount: {currency: "EUR", value: 1000},
|
||||
eventCode: NotificationRequestItem.EventCodeEnum.REPORTAVAILABLE,
|
||||
eventDate: "2019-09-21T11:45:24.637Z",
|
||||
paymentMethod: "VISA",
|
||||
reason: "reason",
|
||||
success: NotificationRequestItem.SuccessEnum.True,
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE]: expectedSign },
|
||||
}
|
||||
};
|
||||
const notification = new NotificationRequest({
|
||||
live: "false",
|
||||
notificationItems: [notificationRequestItem as unknown as NotificationItem]
|
||||
});
|
||||
|
||||
describe("HMAC Validator", function (): void {
|
||||
let hmacValidator: HmacValidator;
|
||||
@@ -38,22 +65,59 @@ describe("HMAC Validator", function (): void {
|
||||
expect(encrypted).toEqual("34oR8T1whkQWTv9P+SzKyp8zhusf9n0dpqrm9nsqSJs=");
|
||||
});
|
||||
it("should get correct data to sign", function (): void {
|
||||
const data = hmacValidator.getDataToSign(notificationRequestItem);
|
||||
expect(data).toEqual("pspReference:originalReference:merchantAccount:reference:1000:EUR:EVENT:true");
|
||||
const data = hmacValidator.getDataToSign(notification.notificationItems![0]);
|
||||
expect(data).toEqual("pspReference:originalReference:merchantAccount:reference:1000:EUR:REPORT_AVAILABLE:true");
|
||||
});
|
||||
|
||||
it("should have valid hmac", function (): void {
|
||||
const encrypted = hmacValidator.calculateHmac(notificationRequestItem, key);
|
||||
const encrypted = hmacValidator.calculateHmac(notification.notificationItems![0], key);
|
||||
expect(expectedSign).toEqual(encrypted);
|
||||
expect(hmacValidator.validateHMAC(notificationRequestItem, key)).toBeTruthy();
|
||||
expect(hmacValidator.validateHMAC(notification.notificationItems![0], key)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have invalid hmac", function (): void {
|
||||
const invalidNotification = {
|
||||
...notificationRequestItem,
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE]: "notValidSign" }
|
||||
...notification.notificationItems![0],
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE as keyof AdditionalData]: "notValidSign" }
|
||||
};
|
||||
const result = hmacValidator.validateHMAC(invalidNotification, key);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should test hmac", function () {
|
||||
const data = "countryCode:currencyCode:merchantAccount:merchantReference:paymentAmount:sessionValidity:skinCode:NL:EUR:MagentoMerchantTest2:TEST-PAYMENT-2017-02-01-14\\:02\\:05:199:2017-02-02T14\\:02\\:05+01\\:00:PKz2KML1";
|
||||
const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
|
||||
const hmacValidator = new HmacValidator();
|
||||
const encrypted = hmacValidator.calculateHmac(data, key);
|
||||
expect(encrypted).toEqual("34oR8T1whkQWTv9P+SzKyp8zhusf9n0dpqrm9nsqSJs=");
|
||||
});
|
||||
|
||||
it("should validate HMAC", function () {
|
||||
expect(hmacValidator.validateHMAC(notification.notificationItems![0], key)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have valid notification request item HMAC", function () {
|
||||
const expectedSign = "ipnxGCaUZ4l8TUW75a71/ghd2Fe5ffvX0pV4TLTntIc=";
|
||||
const notificationRequestItem = { NotificationRequestItem: {
|
||||
pspReference: "pspReference",
|
||||
originalReference: "originalReference",
|
||||
merchantAccountCode: "merchantAccount",
|
||||
merchantReference: "reference",
|
||||
amount: { currency: "EUR", value: 1000 },
|
||||
eventCode: "EVENT",
|
||||
success: "true",
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE]: expectedSign }
|
||||
}} as unknown as NotificationItem;
|
||||
const notification = new NotificationRequest({
|
||||
live: "false",
|
||||
notificationItems: [notificationRequestItem]
|
||||
});
|
||||
const data = hmacValidator.getDataToSign(notification.notificationItems![0]);
|
||||
expect("pspReference:originalReference:merchantAccount:reference:1000:EUR:EVENT:true").toEqual(data);
|
||||
const encrypted = hmacValidator.calculateHmac(notification.notificationItems![0], key);
|
||||
expect(expectedSign).toEqual(encrypted);
|
||||
expect(hmacValidator.validateHMAC(notification.notificationItems![0], key)).toBeTruthy();
|
||||
notification.notificationItems![0].additionalData![ApiConstants.HMAC_SIGNATURE] = "notValidSign";
|
||||
expect(hmacValidator.validateHMAC(notification.notificationItems![0], key)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,27 @@
|
||||
import nock, {Interceptor} from "nock";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 Client from "../client";
|
||||
import Checkout from "../services/checkout";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import {createPaymentsCheckoutRequest} from "./checkout.spec";
|
||||
import { createPaymentsCheckoutRequest } from "./checkout.spec";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
beforeEach((): void => {
|
||||
@@ -12,7 +31,7 @@ beforeEach((): void => {
|
||||
type errorType = "HttpClientException" | "ApiException";
|
||||
type testOptions = { errorType: errorType; errorMessageContains?: string; errorMessageEquals?: string };
|
||||
|
||||
const getResponse = async ({apiKey , environment }: { apiKey: string; environment: Environment}, cb: (scope: Interceptor) => testOptions) => {
|
||||
const getResponse = async ({apiKey , environment }: { apiKey: string; environment: Environment}, cb: (scope: Interceptor) => testOptions): Promise<void> => {
|
||||
const client = new Client({ apiKey, environment });
|
||||
const checkout = new Checkout(client);
|
||||
|
||||
@@ -26,14 +45,14 @@ const getResponse = async ({apiKey , environment }: { apiKey: string; environmen
|
||||
fail("request should fail");
|
||||
} catch (e) {
|
||||
expect(e instanceof ErrorException).toBeTruthy();
|
||||
if(errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if(errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
}
|
||||
};
|
||||
|
||||
describe("HTTP Client", function (): void {
|
||||
it.each`
|
||||
apiKey | environment | withError | args | errorType | contains | equals
|
||||
apiKey | environment | withError | args | errorType | contains | equals
|
||||
${""} | ${"TEST"} | ${true} | ${["mocked_error_response"]} | ${"ApiException"} | ${"x-api-key"} | ${""}
|
||||
${"MOCKED_API_KEY"} | ${"TEST"} | ${true} | ${["some_error"]} | ${"ApiException"} | ${""} | ${"some_error"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, { status: 401, message: "Invalid Request", errorCode: "171", errorType: "validationError"}]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null: Invalid Request"}
|
||||
@@ -47,4 +66,4 @@ describe("HTTP Client", function (): void {
|
||||
return { errorType, errorMessageContains: contains, errorMessageEquals: equals };
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 captureTrue from "../__mocks__/notification/captureTrue.json";
|
||||
import captureFalse from "../__mocks__/notification/captureFalse.json";
|
||||
import refundTrue from "../__mocks__/notification/refundTrue.json";
|
||||
import refundFalse from "../__mocks__/notification/refundFalse.json";
|
||||
import NotificationRequest from "../notification/notificationRequest";
|
||||
import {Notification, NotificationEnum, NotificationRequestItem} from "../typings/notification";
|
||||
import { Notification, NotificationRequestItem } from "../typings/notification/models";
|
||||
|
||||
import NotificationEnum = NotificationRequestItem.EventCodeEnum;
|
||||
import SuccessEnum = NotificationRequestItem.SuccessEnum;
|
||||
|
||||
describe("Notification Test", function (): void {
|
||||
it("should return authorisation success", function (): void {
|
||||
@@ -13,8 +35,8 @@ describe("Notification Test", function (): void {
|
||||
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem: NotificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_AUTHORISATION).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(NotificationEnum.AUTHORISATION).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("123456789");
|
||||
} else {
|
||||
fail();
|
||||
@@ -27,8 +49,8 @@ describe("Notification Test", function (): void {
|
||||
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(NotificationEnum.CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
} else {
|
||||
@@ -42,8 +64,8 @@ describe("Notification Test", function (): void {
|
||||
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeFalsy();
|
||||
expect(NotificationEnum.CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeFalsy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
} else {
|
||||
@@ -57,8 +79,8 @@ describe("Notification Test", function (): void {
|
||||
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(NotificationEnum.REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
expect(notificationRequestItem.eventDate).toBeDefined();
|
||||
@@ -73,8 +95,8 @@ describe("Notification Test", function (): void {
|
||||
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeFalsy();
|
||||
expect(NotificationEnum.REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeFalsy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
expect(notificationRequestItem.eventDate).toBeDefined();
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {createMockClientFromResponse} from "../__mocks__/base";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import Payout from "../services/payout";
|
||||
import Client from "../client";
|
||||
import StoreDetailRequest = IPayouts.StoreDetailRequest;
|
||||
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({
|
||||
additionalData: {
|
||||
fraudResultType: "GREEN",
|
||||
fraudManualReview: "false",
|
||||
|
||||
},
|
||||
pspReference: "8515131751004933",
|
||||
resultCode: "[payout-submit-received]"
|
||||
@@ -24,8 +43,8 @@ const storeDetail = JSON.stringify({
|
||||
|
||||
const amountAndReference = {
|
||||
amount: {
|
||||
value: 1000,
|
||||
currency: "USD"
|
||||
value: 100,
|
||||
currency: "EUR"
|
||||
},
|
||||
reference: "randomReference",
|
||||
};
|
||||
@@ -37,36 +56,43 @@ const defaultData = {
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
|
||||
const mockStoreDetailRequest = (merchantAccount: string): IPayouts.StoreDetailRequest => ({
|
||||
const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.StoreDetailRequest => ({
|
||||
...defaultData,
|
||||
entityType: "NaturalPerson",
|
||||
card: {
|
||||
cvc: "737",
|
||||
expiryMonth: "03",
|
||||
expiryYear: "2020",
|
||||
number: "4111111111111111",
|
||||
holderName: "John Smith"
|
||||
},
|
||||
entityType: "Company",
|
||||
recurring: {
|
||||
contract: "ONECLICK"
|
||||
contract: "PAYOUT"
|
||||
},
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
const mockSubmitRequest = (merchantAccount: string): IPayouts.SubmitRequest => ({
|
||||
const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.SubmitRequest => ({
|
||||
selectedRecurringDetailReference: "LATEST",
|
||||
recurring: {
|
||||
contract: "ONECLICK"
|
||||
contract: "PAYOUT"
|
||||
},
|
||||
...defaultData,
|
||||
...amountAndReference,
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
const mockStoreDetailAndSubmitRequest = (merchantAccount: string): IPayouts.StoreDetailAndSubmitRequest => ({
|
||||
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): IPayouts.StoreDetailAndSubmitRequest => ({
|
||||
...amountAndReference,
|
||||
...(mockStoreDetailRequest(merchantAccount)),
|
||||
});
|
||||
|
||||
const mockPayoutRequest = (merchantAccount: string): IPayouts.PayoutRequest => ({
|
||||
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.PayoutRequest => ({
|
||||
...amountAndReference,
|
||||
...defaultData,
|
||||
card: {
|
||||
expiryMonth: "10",
|
||||
expiryYear: "2020",
|
||||
expiryMonth: "03",
|
||||
expiryYear: "2030",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111",
|
||||
},
|
||||
@@ -74,41 +100,58 @@ const mockPayoutRequest = (merchantAccount: string): IPayouts.PayoutRequest => (
|
||||
});
|
||||
|
||||
let client: Client;
|
||||
let clientStore: Client;
|
||||
let clientReview: Client;
|
||||
let payout: Payout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
clientStore = createClient(process.env.ADYEN_STOREPAYOUT_APIKEY);
|
||||
clientReview = createClient(process.env.ADYEN_REVIEWPAYOUT_APIKEY);
|
||||
scope = nock(`${client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}`);
|
||||
payout = new Payout(client);
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("PayoutTest", function (): void {
|
||||
it("should succeed on store detail and submit third party", async function (): Promise<void> {
|
||||
const request: IPayouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest(`${client.config.merchantAccount}`);
|
||||
scope.post("/storeDetail").reply(200, storeDetailAndSubmitThirdParty);
|
||||
test.each([isCI, true])("should succeed on store detail and submit third party, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
const request: IPayouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest();
|
||||
scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||
|
||||
const result = await payout.storeDetail(request);
|
||||
const result = await payout.storeDetailAndSubmitThirdParty(request);
|
||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||
expect(result.pspReference).toEqual("8515131751004933");
|
||||
|
||||
if (result.additionalData) {
|
||||
expect(result.additionalData[ApiConstants.FRAUD_RESULT_TYPE]).toEqual("GREEN");
|
||||
expect(result.additionalData[ApiConstants.FRAUD_MANUAL_REVIEW]).toEqual("false");
|
||||
}
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should succeed on store detail", async function (): Promise<void> {
|
||||
test.each([false, true])("should succeed on store detail, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
scope.post("/storeDetail").reply(200, storeDetail);
|
||||
const request: StoreDetailRequest = mockStoreDetailRequest("MOCKED_MERCHANT_ACC");
|
||||
const request: StoreDetailRequest = mockStoreDetailRequest();
|
||||
const result = await payout.storeDetail(request);
|
||||
|
||||
expect("Success").toEqual(result.resultCode);
|
||||
expect("8515136787207087").toEqual(result.pspReference);
|
||||
expect("8415088571022720").toEqual(result.recurringDetailReference);
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
expect(result.recurringDetailReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should succeed on confirm third party", async function (): Promise<void> {
|
||||
test.each([isCI, true])("should succeed on confirm third party, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
scope.post("/storeDetail").reply(200, storeDetail);
|
||||
const storeRequest: StoreDetailRequest = mockStoreDetailRequest();
|
||||
const storeResult = await payout.storeDetail(storeRequest);
|
||||
|
||||
payout = new Payout(clientReview);
|
||||
scope.post("/confirmThirdParty")
|
||||
.reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
@@ -116,23 +159,25 @@ describe("PayoutTest", function (): void {
|
||||
});
|
||||
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
merchantAccount: "MOCKED_MERCHANT_ACCOUNT",
|
||||
originalReference: "reference"
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: storeResult.pspReference
|
||||
};
|
||||
const result = await payout.confirmThirdParty(request);
|
||||
|
||||
expect(result.response).toEqual("[payout-confirm-received]");
|
||||
expect(result.pspReference).toEqual("8815131762537886");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should succeed on submit third party", async function (): Promise<void> {
|
||||
test.each([isCI, true])("should succeed on submit third party, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty);
|
||||
|
||||
const request: IPayouts.SubmitRequest = mockSubmitRequest("MOCKED_MERCHANT_ACC");
|
||||
const request: IPayouts.SubmitRequest = mockSubmitRequest();
|
||||
const result = await payout.submitThirdparty(request);
|
||||
|
||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||
expect(result.pspReference).toEqual("8515131751004933");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
|
||||
if (result.additionalData) {
|
||||
expect(result.additionalData[ApiConstants.FRAUD_RESULT_TYPE]).toEqual("GREEN");
|
||||
@@ -140,32 +185,40 @@ describe("PayoutTest", function (): void {
|
||||
}
|
||||
});
|
||||
|
||||
it("should succeed on decline third party", async function (): Promise<void> {
|
||||
scope.post("/storeDetailAndSubmitThirdParty").reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
response: "[payout-confirm-received]"
|
||||
});
|
||||
test.each([false, true])("should succeed on decline third party, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
payout = new Payout(clientStore);
|
||||
scope.post("/storeDetail").reply(200, storeDetail);
|
||||
const storeRequest: StoreDetailRequest = mockStoreDetailRequest();
|
||||
const storeResult = await payout.storeDetail(storeRequest);
|
||||
|
||||
payout = new Payout(clientReview);
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
merchantAccount: "MOCKED_MERCHANT_ACC",
|
||||
originalReference: "reference"
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: storeResult.pspReference
|
||||
};
|
||||
scope.post("/declineThirdParty")
|
||||
.reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
response: "[payout-decline-received]"
|
||||
});
|
||||
const result = await payout.declineThirdParty(request);
|
||||
|
||||
expect(result.response).toEqual("[payout-confirm-received]");
|
||||
expect(result.pspReference).toEqual("8815131762537886");
|
||||
expect(result.response).toEqual("[payout-decline-received]");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should succeed on payout", async function (): Promise<void> {
|
||||
test.each([isCI, true])("should succeed on payout, isMock: %p", async function (isMock): Promise<void> {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payout").reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
resultCode: "Received",
|
||||
});
|
||||
|
||||
const request = mockPayoutRequest("MOCKED_MERCHANT_ACC");
|
||||
const request = mockPayoutRequest();
|
||||
const result = await payout.payout(request);
|
||||
|
||||
expect(result.resultCode).toEqual("Received");
|
||||
expect(result.pspReference).toEqual("8815131762537886");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
});
|
||||
532
src/__tests__/platforms.spec.ts
Normal file
532
src/__tests__/platforms.spec.ts
Normal file
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { createMock } from "ts-auto-mock";
|
||||
import { createBasicAuthClient } from "../__mocks__/base";
|
||||
import { documentContent } from "../__mocks__/platforms/documentContent";
|
||||
import { Client, Platforms } from "../index";
|
||||
|
||||
import A = IPlatformsAccount;
|
||||
import F = IPlatformsFund;
|
||||
import N = IPlatformsNotificationConfiguration;
|
||||
import H = IPlatformsHostedOnboardingPage;
|
||||
import AccountHolderDetails = A.AccountHolderDetails;
|
||||
import NotificationConfigurationDetails = N.NotificationConfigurationDetails;
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
let client: Client;
|
||||
let platforms: Platforms;
|
||||
let scope: nock.Scope;
|
||||
let accountHolder: A.CreateAccountHolderResponse;
|
||||
let account: A.CreateAccountResponse;
|
||||
let accountHolderToSuspend: A.CreateAccountHolderResponse;
|
||||
let accountToClose: A.CreateAccountResponse;
|
||||
let accountHolderToUnSuspend: A.CreateAccountHolderResponse;
|
||||
let accountHolderToClose: A.CreateAccountHolderResponse;
|
||||
let notificationConfigurationToRetrieve: N.GetNotificationConfigurationResponse;
|
||||
|
||||
const generateRandomCode = (): string => Math.floor(Math.random() * Date.now()).toString();
|
||||
const accountHolderDetails: AccountHolderDetails = {
|
||||
email: "random_email@example.com",
|
||||
fullPhoneNumber: "312030291928",
|
||||
webAddress: "http://example.com",
|
||||
individualDetails: {
|
||||
name: {
|
||||
firstName: "John",
|
||||
gender: "MALE",
|
||||
lastName: "Smith"
|
||||
}
|
||||
},
|
||||
address: {
|
||||
country: "NL"
|
||||
},
|
||||
};
|
||||
const notificationConfigurationDetails: NotificationConfigurationDetails = {
|
||||
active: true,
|
||||
notifyURL: "https://www.adyen.com/notification-handler",
|
||||
eventConfigs: [
|
||||
{
|
||||
eventType: "ACCOUNT_HOLDER_VERIFICATION",
|
||||
includeMode: "INCLUDE"
|
||||
}
|
||||
],
|
||||
sslProtocol: "SSL"
|
||||
};
|
||||
|
||||
const assertError = (e: HttpClientException): void => {
|
||||
if (e.responseBody?.includes("Account code does not exist or invalid") || e.responseBody?.includes("Failed to retrieve account holder")) {
|
||||
return;
|
||||
}
|
||||
fail(e);
|
||||
};
|
||||
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
|
||||
client = createBasicAuthClient();
|
||||
client.config.password = process.env.ADYEN_MARKETPLACE_PASSWORD;
|
||||
client.config.username = process.env.ADYEN_MARKETPLACE_USER;
|
||||
|
||||
scope = nock(client.config.marketPayEndpoint!);
|
||||
platforms = new Platforms(client);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Platforms Test", function () {
|
||||
describe("Account", function(): void {
|
||||
describe("Accounts", function () {
|
||||
const cases = [
|
||||
["closeAccount", createMock<A.CloseAccountRequest>(), createMock<A.CloseAccountResponse>()],
|
||||
["updateAccount", createMock<A.UpdateAccountRequest>(), createMock<A.UpdateAccountResponse>()],
|
||||
["createAccount", createMock<A.CreateAccountRequest>(), createMock<A.CreateAccountResponse>()],
|
||||
["uploadDocument", createMock<A.UploadDocumentRequest>(), createMock<A.GetUploadedDocumentsResponse>()],
|
||||
["getUploadedDocuments", createMock<A.GetUploadedDocumentsRequest>(), createMock<A.GetUploadedDocumentsResponse>()],
|
||||
["deleteBankAccounts", createMock<A.DeleteBankAccountRequest>(), createMock<A.GenericResponse>()],
|
||||
["deletePayoutMethods", createMock<A.DeletePayoutMethodRequest>(), createMock<A.GenericResponse>()],
|
||||
["deleteShareholders", createMock<A.DeleteShareholderRequest>(), createMock<A.GenericResponse>()],
|
||||
["checkAccountHolder", createMock<A.PerformVerificationRequest>(), createMock<A.GenericResponse>()],
|
||||
["createAccountHolder", createMock<A.CreateAccountRequest>(), createMock<A.CreateAccountHolderRequest>()],
|
||||
["getAccountHolder", createMock<A.GetAccountHolderRequest>(), createMock<A.GetAccountHolderRequest>()],
|
||||
["updateAccountHolder", createMock<A.UpdateAccountHolderRequest>(), createMock<A.UpdateAccountHolderResponse>()],
|
||||
["updateAccountHolderState", createMock<A.UpdateAccountHolderStateRequest>(), createMock<A.GetAccountHolderStatusResponse>()],
|
||||
["suspendAccountHolder", createMock<A.SuspendAccountHolderRequest>(), createMock<A.SuspendAccountHolderResponse>()],
|
||||
["unSuspendAccountHolder", createMock<A.UnSuspendAccountHolderRequest>(), createMock<A.UnSuspendAccountHolderResponse>()],
|
||||
["closeAccountHolder", createMock<A.CloseAccountHolderRequest>(), createMock<A.CloseAccountResponse>()],
|
||||
];
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
async (...args) => {
|
||||
const service = platforms.Account;
|
||||
scope.post(`/Account/${Client.MARKETPAY_ACCOUNT_API_VERSION}//${args[0]}`).reply(200, args[2]);
|
||||
const result = await service[args[0] as string](args[1] as never);
|
||||
expect(result).toMatchObject(args[2]);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Fund", function () {
|
||||
const cases = [
|
||||
["accountHolderBalance", createMock<F.AccountHolderBalanceRequest>(), createMock<F.AccountHolderBalanceResponse>()],
|
||||
["accountHolderTransactionList", createMock<F.AccountHolderTransactionListRequest>(), createMock<F.AccountHolderTransactionListResponse>()],
|
||||
["payoutAccountHolder", createMock<F.PayoutAccountHolderRequest>(), createMock<F.PayoutAccountHolderResponse>()],
|
||||
["transferFunds", createMock<F.TransferFundsRequest>(), createMock<F.TransferFundsResponse>()],
|
||||
["refundFundsTransfer", createMock<F.RefundFundsTransferRequest>(), createMock<F.RefundFundsTransferResponse>()],
|
||||
["setupBeneficiary", createMock<F.SetupBeneficiaryRequest>(), createMock<F.SetupBeneficiaryResponse>()],
|
||||
["refundNotPaidOutTransfers", createMock<F.RefundNotPaidOutTransfersRequest>(), createMock<F.RefundNotPaidOutTransfersResponse>()],
|
||||
];
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
async (...args) => {
|
||||
const fund = platforms.Fund;
|
||||
scope.post(`/Fund/${Client.MARKETPAY_FUND_API_VERSION}//${args[0]}`).reply(200, args[2]);
|
||||
|
||||
const result = await fund[args[0] as string](args[1] as never);
|
||||
expect(result).toMatchObject(args[2]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe("Notification Configuration", function() {
|
||||
const cases = [
|
||||
["createNotificationConfiguration", createMock<N.CreateNotificationConfigurationRequest>(), createMock<N.GetNotificationConfigurationResponse>()],
|
||||
["getNotificationConfiguration", createMock<N.GetNotificationConfigurationRequest>(), createMock<N.GetNotificationConfigurationResponse>()],
|
||||
["getNotificationConfigurationList", {}, createMock<N.GetNotificationConfigurationListResponse>()],
|
||||
["testNotificationConfiguration", createMock<N.TestNotificationConfigurationRequest>(), createMock<N.TestNotificationConfigurationResponse>()],
|
||||
["updateNotificationConfiguration", createMock<N.UpdateNotificationConfigurationRequest>(), createMock<N.GetNotificationConfigurationResponse>()],
|
||||
["deleteNotificationConfigurations", createMock<N.DeleteNotificationConfigurationRequest>(), createMock<N.GenericResponse>()],
|
||||
];
|
||||
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
async (...args) => {
|
||||
const notificationConfiguration = platforms.NotificationConfiguration;
|
||||
scope.post(`/Notification/${Client.MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION}//${args[0]}`).reply(200, args[2]);
|
||||
|
||||
const result = await notificationConfiguration[args[0] as string](args[1] as never);
|
||||
expect(result).toMatchObject(args[2]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe("Hop", function () {
|
||||
const cases = [
|
||||
["getOnboardingUrl", createMock<H.GetOnboardingUrlRequest>(), createMock<H.GetOnboardingUrlResponse>()]
|
||||
];
|
||||
test.each(cases)(
|
||||
"should %p",
|
||||
async (...args) => {
|
||||
const hostedOnboardingPage = platforms.HostedOnboardingPage;
|
||||
scope.post(`/Hop/${Client.MARKETPAY_HOP_API_VERSION}//${args[0]}`).reply(200, args[2]);
|
||||
|
||||
const result = await hostedOnboardingPage[args[0] as string](args[1] as never);
|
||||
expect(result).toMatchObject(args[2]);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip("Platforms Test E2E", function(): void {
|
||||
beforeAll(async (done) => {
|
||||
accountHolder = await platforms.Account.createAccountHolder({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
accountHolderDetails,
|
||||
legalEntity: "Individual",
|
||||
});
|
||||
|
||||
account = await platforms.Account.createAccount({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
description: "This is a new account",
|
||||
metadata: {meta: "data"},
|
||||
payoutSchedule: "WEEKLY"
|
||||
});
|
||||
|
||||
accountHolderToSuspend = await platforms.Account.createAccountHolder({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
accountHolderDetails,
|
||||
legalEntity: "Individual"
|
||||
});
|
||||
|
||||
accountToClose = await platforms.Account.createAccount({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
description: "This is a new account",
|
||||
metadata: {meta: "data"},
|
||||
payoutSchedule: "WEEKLY"
|
||||
});
|
||||
|
||||
accountHolderToUnSuspend = await platforms.Account.createAccountHolder({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
accountHolderDetails,
|
||||
legalEntity: "Individual"
|
||||
});
|
||||
await platforms.Account.suspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode});
|
||||
|
||||
accountHolderToClose = await platforms.Account.createAccountHolder({
|
||||
accountHolderCode: generateRandomCode(),
|
||||
accountHolderDetails,
|
||||
legalEntity: "Individual"
|
||||
});
|
||||
|
||||
notificationConfigurationToRetrieve = await platforms.NotificationConfiguration.createNotificationConfiguration({
|
||||
configurationDetails: {
|
||||
...notificationConfigurationDetails,
|
||||
description: `${generateRandomCode()}`
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
describe("Account", function(): void {
|
||||
describe("Accounts E2E", function () {
|
||||
it("should create account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(accountHolder.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
it("should get account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.getAccountHolder({
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
});
|
||||
expect(result.accountHolderDetails.email).toEqual("random_email@example.com");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should update account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.updateAccountHolder({
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
accountHolderDetails: {
|
||||
...accountHolderDetails,
|
||||
address: {
|
||||
country: "BE"
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(result.accountHolderDetails!.address?.country).toEqual("BE");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should check account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.checkAccountHolder({
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
accountStateType: "Processing",
|
||||
tier: 2
|
||||
});
|
||||
expect(result.resultCode).toEqual("Success");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should create an account", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(account.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should upload verification document", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.uploadDocument({
|
||||
documentContent,
|
||||
documentDetail: {
|
||||
accountHolderCode: account.accountHolderCode,
|
||||
documentType: "ID_CARD_FRONT",
|
||||
description: "test document 000",
|
||||
filename: "IDCardFront.png"
|
||||
}
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should get uploaded verification documents", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
await platforms.Account.uploadDocument({
|
||||
documentContent,
|
||||
documentDetail: {
|
||||
accountHolderCode: account.accountHolderCode,
|
||||
documentType: "ID_CARD_FRONT",
|
||||
description: "test document 000",
|
||||
filename: "IDCardFront.png"
|
||||
}
|
||||
});
|
||||
const result = await platforms.Account.getUploadedDocuments({
|
||||
accountHolderCode: account.accountHolderCode,
|
||||
});
|
||||
expect(result.documentDetails![0].filename).toEqual("IDCardFront.png");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should close account", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.closeAccount({
|
||||
accountCode: accountToClose.accountCode
|
||||
});
|
||||
expect(result.status).toEqual("Closed");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should suspend account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.suspendAccountHolder({
|
||||
accountHolderCode: accountHolderToSuspend.accountHolderCode,
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should unsuspend account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode });
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should update account holder state", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.updateAccountHolderState({
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
disable: false,
|
||||
stateType: "Payout"
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should close account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Account.closeAccountHolder({
|
||||
accountHolderCode: accountHolderToClose.accountHolderCode
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
describe("Fund", function () {
|
||||
it("should retrieve the balance of an account holder", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Fund.accountHolderBalance({
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.balancePerAccount![0].detailBalance).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should retrieve a list of transaction for an account holder's accounts", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Fund.accountHolderTransactionList({
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.accountTransactionLists![0].transactions).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should transfer funds between two accounts", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.Fund.transferFunds({
|
||||
sourceAccountCode: "8515883280985939",
|
||||
destinationAccountCode: "8815883278206345",
|
||||
amount: {
|
||||
currency: "EUR",
|
||||
value: 1
|
||||
},
|
||||
transferCode: "SUBSCRIPTION"
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
describe("Notification Configuration", function () {
|
||||
let configurationID: number;
|
||||
|
||||
it("should retrieve all Notification Configurations", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({});
|
||||
const resultStr = JSON.stringify(result);
|
||||
expect(resultStr.includes("pspReference")).toBeTruthy();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should create a Notification Configuration", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.createNotificationConfiguration({
|
||||
configurationDetails: {
|
||||
...notificationConfigurationDetails,
|
||||
description: `${generateRandomCode()}`
|
||||
}
|
||||
});
|
||||
expect(result.configurationDetails.active).toBeTruthy();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should retrieve a Notification Configuration", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
configurationID = notificationConfigurationToRetrieve.configurationDetails.notificationId!;
|
||||
const result = await platforms.NotificationConfiguration.getNotificationConfiguration({
|
||||
notificationId: configurationID
|
||||
});
|
||||
expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should update a Notification Configuration", async function() {
|
||||
nock.restore();
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.updateNotificationConfiguration({
|
||||
configurationDetails: {
|
||||
eventConfigs: [
|
||||
{
|
||||
eventType: "ACCOUNT_HOLDER_VERIFICATION",
|
||||
includeMode: "EXCLUDE"
|
||||
},
|
||||
{
|
||||
"eventType": "ACCOUNT_CREATED",
|
||||
"includeMode": "INCLUDE"
|
||||
}
|
||||
],
|
||||
notifyURL: "https://www.adyen.com/notification-handler",
|
||||
notificationId: configurationID
|
||||
}
|
||||
});
|
||||
const accountHolderVerification = result.configurationDetails.eventConfigs.filter(event => event.eventType === "ACCOUNT_HOLDER_VERIFICATION")[0];
|
||||
expect(accountHolderVerification.includeMode).toEqual("EXCLUDE");
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("should delete a Notification Configuration", async function() {
|
||||
nock.restore();
|
||||
const notificationIds = [];
|
||||
notificationIds.push(configurationID);
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,49 +1,128 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {createMockClientFromResponse} from "../__mocks__/base";
|
||||
import {disableSuccess} from "../__mocks__/recurring/disableSuccess";
|
||||
import {listRecurringDetailsSuccess} from "../__mocks__/recurring/listRecurringDetailsSuccess";
|
||||
import { createClient } from "../__mocks__/base";
|
||||
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
||||
import { listRecurringDetailsSuccess } from "../__mocks__/recurring/listRecurringDetailsSuccess";
|
||||
import Recurring from "../services/recurring";
|
||||
import Client from "../client";
|
||||
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess";
|
||||
import { createPaymentsCheckoutRequest } from "./checkout.spec";
|
||||
import Checkout from "../services/checkout";
|
||||
|
||||
const createRecurringDetailsRequest = (): IRecurring.RecurringDetailsRequest => {
|
||||
return {
|
||||
merchantAccount: "MerchantAccount",
|
||||
recurring: { contract: "ONECLICK" },
|
||||
shopperReference: "test-123",
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
recurring: { contract: "RECURRING" },
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
};
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
|
||||
let client: Client;
|
||||
let recurring: Recurring;
|
||||
let checkout: Checkout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
recurring = new Recurring(client);
|
||||
checkout = new Checkout(client);
|
||||
scope = nock(`${client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}`);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Recurring", (): void => {
|
||||
it("should test have recurring details list", async (): Promise<void> => {
|
||||
test.each([false, true])("should test have recurring details list, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/listRecurringDetails")
|
||||
.reply(200, listRecurringDetailsSuccess);
|
||||
|
||||
const request = createRecurringDetailsRequest();
|
||||
const result = await recurring.listRecurringDetails(request);
|
||||
|
||||
expect(result).toEqual(listRecurringDetailsSuccess);
|
||||
try {
|
||||
const result = await recurring.listRecurringDetails(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
it("should disable", async (): Promise<void> => {
|
||||
test.each([isCI, true])("should disable, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsSuccess);
|
||||
|
||||
const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const res = await checkout.payments(paymentsRequest);
|
||||
|
||||
scope.post("/disable")
|
||||
.reply(200, disableSuccess);
|
||||
|
||||
const request: IRecurring.DisableRequest = {
|
||||
merchantAccount: "MerchantAccount",
|
||||
recurringDetailReference: "reference",
|
||||
shopperReference: "test-123",
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
shopperReference: "shopperReference",
|
||||
recurringDetailReference: res.additionalData!["recurring.recurringDetailReference"]
|
||||
};
|
||||
|
||||
const result = await recurring.disable(request);
|
||||
expect(result).toEqual(disableSuccess);
|
||||
try {
|
||||
const result = await recurring.disable(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO: register account for AccountUpdater and unmock test
|
||||
test.each([true])("should schedule account updater, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const scheduleAccountUpdaterSuccess: IRecurring.ScheduleAccountUpdaterResult = {
|
||||
pspReference: "mocked_psp",
|
||||
result: "SUCCESS"
|
||||
};
|
||||
|
||||
scope.post("/scheduleAccountUpdater")
|
||||
.reply(200, scheduleAccountUpdaterSuccess);
|
||||
|
||||
const request: IRecurring.ScheduleAccountUpdaterRequest = {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
reference: "ref",
|
||||
card: {
|
||||
expiryMonth: "03",
|
||||
expiryYear: "2030",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111"
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await recurring.scheduleAccountUpdater(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,24 +1,53 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../__mocks__/base";
|
||||
import {asyncRes} from "../__mocks__/terminalApi/async";
|
||||
import {syncRes} from "../__mocks__/terminalApi/sync";
|
||||
import { createClient, createTerminalAPIPaymentRequest, createTerminalAPIRefundRequest } from "../__mocks__/base";
|
||||
import { asyncRes } from "../__mocks__/terminalApi/async";
|
||||
import { syncRefund, syncRes } from "../__mocks__/terminalApi/sync";
|
||||
import Client from "../client";
|
||||
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
||||
import {Convert, TerminalApiResponse} from "../typings/terminal";
|
||||
|
||||
import { TerminalApiResponse } from "../typings/terminal/models";
|
||||
|
||||
let client: Client;
|
||||
let terminalCloudAPI: TerminalCloudAPI;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient(process.env.ADYEN_TERMINAL_APIKEY);
|
||||
client.config.merchantAccount = process.env.ADYEN_TERMINAL_MERCHANT;
|
||||
|
||||
terminalCloudAPI = new TerminalCloudAPI(client);
|
||||
scope = nock(`${client.config.terminalApiCloudEndpoint}`);
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
describe("Terminal Cloud API", (): void => {
|
||||
it("should make an async payment request", async (): Promise<void> => {
|
||||
test.each([isCI, true])("should make an async payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/async").reply(200, asyncRes);
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
@@ -28,13 +57,29 @@ describe("Terminal Cloud API", (): void => {
|
||||
expect(requestResponse).toEqual("ok");
|
||||
});
|
||||
|
||||
it("should make a sync payment request", async (): Promise<void> => {
|
||||
const response = Convert.toTerminalApiResponse(syncRes);
|
||||
scope.post("/sync").reply(200, response);
|
||||
test.each([isCI, true])("should make a sync payment request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/sync").reply(200, syncRes);
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||
|
||||
expect(terminalAPIResponse).toEqual(response);
|
||||
expect(terminalAPIResponse.saleToPOIResponse?.paymentResponse).toBeDefined();
|
||||
expect(terminalAPIResponse.saleToPOIResponse?.messageHeader).toBeDefined();
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should make an async refund request, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/sync").reply(200, syncRes);
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||
|
||||
scope.post("/sync").reply(200, syncRefund);
|
||||
|
||||
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(terminalAPIResponse.saleToPOIResponse?.paymentResponse?.pOIData.pOITransactionID!);
|
||||
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
||||
|
||||
expect(terminalAPIRefundResponse.saleToPOIResponse?.reversalResponse).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../__mocks__/base";
|
||||
import {localEncRes, localSecuredRes, wrongEncRes} from "../__mocks__/terminalApi/local";
|
||||
import { createClient, createTerminalAPIPaymentRequest } from "../__mocks__/base";
|
||||
import { localEncRes, wrongEncRes } from "../__mocks__/terminalApi/local";
|
||||
import Client from "../client";
|
||||
import TerminalLocalAPI from "../services/terminalLocalAPI";
|
||||
import {Convert, SecurityKey, TerminalApiResponse} from "../typings/terminal";
|
||||
import { SecurityKey, TerminalApiResponse } from "../typings/terminal/models";
|
||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||
|
||||
let client: Client;
|
||||
@@ -11,42 +30,50 @@ let terminalLocalAPI: TerminalLocalAPI;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
client = createMockClientFromResponse();
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
|
||||
client = createClient();
|
||||
terminalLocalAPI = new TerminalLocalAPI(client);
|
||||
scope = nock(client.config.terminalApiLocalEndpoint + ":8443/nexo");
|
||||
});
|
||||
|
||||
describe("Terminal Local API", (): void => {
|
||||
it("should make a local payment", async (): Promise<void> => {
|
||||
const securedResponse = Convert.toTerminalApiSecuredResponse(localEncRes);
|
||||
const response = Convert.toTerminalApiResponse(localSecuredRes);
|
||||
afterEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
scope.post("/").reply(200, securedResponse);
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
|
||||
describe("Terminal Local API", (): void => {
|
||||
test.each([isCI, true])("should make a local payment, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/").reply(200, localEncRes);
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const securityKey: SecurityKey = {
|
||||
adyenCryptoVersion: 1,
|
||||
adyenCryptoVersion: 0,
|
||||
keyIdentifier: "CryptoKeyIdentifier12345",
|
||||
keyVersion: 1,
|
||||
keyVersion: 0,
|
||||
passphrase: "p@ssw0rd123456",
|
||||
};
|
||||
|
||||
const terminalApiResponse: TerminalApiResponse =
|
||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||
|
||||
expect(response).toEqual(terminalApiResponse);
|
||||
expect(terminalApiResponse.saleToPOIResponse?.paymentResponse).toBeDefined();
|
||||
expect(terminalApiResponse.saleToPOIResponse?.messageHeader).toBeDefined();
|
||||
});
|
||||
|
||||
it("should return NexoCryptoException", async (): Promise<void> => {
|
||||
const securedResponse = Convert.toTerminalApiSecuredResponse(wrongEncRes);
|
||||
|
||||
scope.post("/").reply(200, securedResponse);
|
||||
test.each([isCI, true])("should return NexoCryptoException, isMock: %p", async (isMock: boolean): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/").reply(200, wrongEncRes);
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const securityKey: SecurityKey = {
|
||||
adyenCryptoVersion: 1,
|
||||
adyenCryptoVersion: 0,
|
||||
keyIdentifier: "CryptoKeyIdentifier12345",
|
||||
keyVersion: 1,
|
||||
keyVersion: 0,
|
||||
passphrase: "p@ssw0rd123456",
|
||||
};
|
||||
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,17 +11,15 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
|
||||
import {version} from "../package.json";
|
||||
import { version } from "../package.json";
|
||||
import ClientInterface from "./httpClient/clientInterface";
|
||||
|
||||
type ClientParametersOverload =
|
||||
@@ -54,19 +52,20 @@ class Client {
|
||||
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_LIVE = "https://cal-live.adyen.com/cal/services";
|
||||
public static API_VERSION = "v51";
|
||||
public static CHECKOUT_API_VERSION = "v66";
|
||||
public static API_VERSION = "v64";
|
||||
public static RECURRING_API_VERSION = "v49";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION = "v5";
|
||||
public static MARKETPAY_FUND_API_VERSION = "v5";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION = "v6";
|
||||
public static MARKETPAY_FUND_API_VERSION = "v6";
|
||||
public static MARKETPAY_HOP_API_VERSION = "v6";
|
||||
public static MARKETPAY_NOTIFICATION_API_VERSION = "v5";
|
||||
public static MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION = "v6";
|
||||
public static LIB_NAME = "adyen-node-api-library";
|
||||
public static LIB_VERSION: string = version;
|
||||
public static CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
|
||||
public static CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
|
||||
public static CHECKOUT_API_VERSION = "v51";
|
||||
public static BIN_LOOKUP_PAL_SUFFIX = "/pal/servlet/BinLookup/";
|
||||
public static BIN_LOOKUP_API_VERSION = "v50";
|
||||
public static CHECKOUT_UTILITY_API_VERSION = "v1";
|
||||
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 ENDPOINT_PROTOCOL = "https://";
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
import {PeerCertificate} from "tls";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { PeerCertificate } from "tls";
|
||||
|
||||
export default function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined {
|
||||
const { subject: { CN }} = cert;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -22,7 +20,7 @@
|
||||
import Resource from "../services/resource";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<string>;
|
||||
async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<R>;
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
import {ApplicationInfo} from "../typings/applicationInfo";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { ApplicationInfo } from "../typings/applicationInfo";
|
||||
|
||||
interface AppInfo { applicationInfo?: ApplicationInfo }
|
||||
|
||||
|
||||
@@ -11,18 +11,16 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 { AgentOptions } from "https";
|
||||
import HttpClientException from "./httpClientException";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import {Config} from "../index";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { Config } from "../index";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
interface ClientInterface {
|
||||
request(
|
||||
|
||||
@@ -11,31 +11,37 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {IncomingHttpHeaders, IncomingMessage} from "http";
|
||||
import { IncomingHttpHeaders } from "http";
|
||||
|
||||
interface ExceptionInterface {
|
||||
message: string;
|
||||
statusCode?: number;
|
||||
errorCode?: string;
|
||||
responseHeaders?: IncomingHttpHeaders;
|
||||
responseBody?: string;
|
||||
}
|
||||
|
||||
class HttpClientException implements Error {
|
||||
public statusCode = 500;
|
||||
public errorCode: string | undefined;
|
||||
public responseHeaders: IncomingHttpHeaders | undefined;
|
||||
public errorCode?: string;
|
||||
public responseHeaders?: IncomingHttpHeaders;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
public responseBody: IncomingMessage | undefined;
|
||||
public responseBody?: string;
|
||||
|
||||
public constructor(message: string, statusCode?: number, errorCode?: string, responseHeaders?: IncomingHttpHeaders, responseBody?: IncomingMessage) {
|
||||
public constructor(props: ExceptionInterface) {
|
||||
this.name = "HttpClientException";
|
||||
this.message = message;
|
||||
if(errorCode) this.errorCode = errorCode;
|
||||
if(statusCode) this.statusCode = statusCode;
|
||||
if(responseHeaders) this.responseHeaders = responseHeaders;
|
||||
if(responseBody) this.responseBody = responseBody;
|
||||
this.message = props.message;
|
||||
if (props.responseHeaders) this.responseHeaders = props.responseHeaders;
|
||||
if (props.responseBody) this.responseBody = props.responseBody;
|
||||
if (props.errorCode) this.errorCode = props.errorCode;
|
||||
if (props.statusCode) this.statusCode = props.statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,29 +11,27 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {ClientRequest, IncomingMessage} from "http";
|
||||
import {Agent, AgentOptions, request as httpsRequest} from "https";
|
||||
import HttpsProxyAgent from "https-proxy-agent";
|
||||
import { ClientRequest, IncomingHttpHeaders, IncomingMessage } from "http";
|
||||
import { Agent, AgentOptions, request as httpsRequest } from "https";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
|
||||
import * as fs from "fs";
|
||||
import {URL} from "url";
|
||||
import { URL } from "url";
|
||||
import Client from "../client";
|
||||
import Config from "../config";
|
||||
import HttpClientException from "./httpClientException";
|
||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||
import {ApiError} from "../typings/apiError";
|
||||
import { ApiError } from "../typings/apiError";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import ClientInterface from "./clientInterface";
|
||||
import {ApiConstants} from "../constants/apiConstants";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { ApiConstants } from "../constants/apiConstants";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
class HttpURLConnectionClient implements ClientInterface {
|
||||
private static CHARSET = "utf-8";
|
||||
@@ -61,7 +59,7 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
requestOptions.headers[ApiConstants.API_KEY] = apiKey;
|
||||
} else {
|
||||
const authString = `${config.username}:${config.password}`;
|
||||
const authStringEnc = new Buffer(authString).toString("base64");
|
||||
const authStringEnc = Buffer.from(authString, "utf8").toString("base64");
|
||||
|
||||
requestOptions.headers.Authorization = `Basic ${authStringEnc}`;
|
||||
}
|
||||
@@ -102,7 +100,11 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
}
|
||||
|
||||
requestOptions.headers["Cache-Control"] = "no-cache";
|
||||
requestOptions.method = ApiConstants.METHOD_POST;
|
||||
|
||||
if (!requestOptions.method) {
|
||||
requestOptions.method = ApiConstants.METHOD_POST;
|
||||
}
|
||||
|
||||
requestOptions.headers[ApiConstants.ACCEPT_CHARSET] = HttpURLConnectionClient.CHARSET;
|
||||
requestOptions.headers[ApiConstants.USER_AGENT] = `${applicationName} ${Client.LIB_NAME}/${Client.LIB_VERSION}`;
|
||||
|
||||
@@ -118,33 +120,49 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
connectionRequest.flushHeaders();
|
||||
|
||||
connectionRequest.on("response", (res: IncomingMessage): void => {
|
||||
let resData = "";
|
||||
const getException = (): HttpClientException => new HttpClientException(
|
||||
`HTTP Exception: ${res.statusCode}. ${res.statusMessage}`,
|
||||
res.statusCode,
|
||||
undefined,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
let exception: HttpClientException | Error = getException();
|
||||
const response: { headers: IncomingHttpHeaders; body: string; statusCode: number | undefined } = {
|
||||
statusCode: res.statusCode,
|
||||
headers: res.headers,
|
||||
body: ""
|
||||
};
|
||||
|
||||
res.on("data", (data): void => {
|
||||
if (res.statusCode && res.statusCode !== 200) {
|
||||
const getException = (responseBody: string): HttpClientException => new HttpClientException({
|
||||
message: `HTTP Exception: ${response.statusCode}. ${res.statusMessage}`,
|
||||
statusCode: response.statusCode,
|
||||
errorCode: undefined,
|
||||
responseHeaders: response.headers,
|
||||
responseBody,
|
||||
});
|
||||
|
||||
let exception: HttpClientException | Error = getException(response.body.toString());
|
||||
|
||||
res.on("data", (chunk: string): void => {
|
||||
response.body += chunk;
|
||||
});
|
||||
|
||||
res.on("end", (): void => {
|
||||
if (!res.complete) {
|
||||
reject(new Error("The connection was terminated while the message was still being sent"));
|
||||
}
|
||||
|
||||
if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
|
||||
try {
|
||||
const formattedData: ApiError = JSON.parse(data.toString() as string);
|
||||
const formattedData: ApiError | {[key: string]: never} = JSON.parse(response.body);
|
||||
const isApiError = "status" in formattedData;
|
||||
const isRequestError = "errors" in formattedData;
|
||||
|
||||
if (isApiError) {
|
||||
exception = new HttpClientException(
|
||||
`HTTP Exception: ${formattedData.status}. ${res.statusMessage}: ${formattedData.message}`,
|
||||
formattedData.status,
|
||||
formattedData.errorCode,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
exception = new HttpClientException({
|
||||
message: `HTTP Exception: ${formattedData.status}. ${res.statusMessage}: ${formattedData.message}`,
|
||||
statusCode: formattedData.status,
|
||||
errorCode: formattedData.errorCode,
|
||||
responseHeaders: res.headers,
|
||||
responseBody: response.body,
|
||||
});
|
||||
} else if (isRequestError) {
|
||||
exception = new Error(data);
|
||||
exception = new Error(response.body);
|
||||
} else {
|
||||
exception = getException(response.body);
|
||||
}
|
||||
} catch (e) {
|
||||
reject(exception);
|
||||
@@ -153,14 +171,7 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
}
|
||||
}
|
||||
|
||||
resData += data;
|
||||
});
|
||||
|
||||
res.on("end", (): void => {
|
||||
if (!res.complete) {
|
||||
reject(new Error("The connection was terminated while the message was still being sent"));
|
||||
}
|
||||
resolve(resData);
|
||||
resolve(response.body as string);
|
||||
});
|
||||
|
||||
res.on("error", reject);
|
||||
@@ -185,7 +196,7 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
return Promise.reject(new HttpClientException(`Error loading certificate from path: ${e.message}`));
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${e.message}` }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,18 +11,21 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {Convert, Notification, NotificationItem, NotificationRequestItem} from "../typings/notification";
|
||||
import {
|
||||
Notification,
|
||||
NotificationItem,
|
||||
NotificationRequestItem,
|
||||
ObjectSerializer
|
||||
} from "../typings/notification/models";
|
||||
|
||||
class NotificationRequest {
|
||||
public constructor(json: Notification) {
|
||||
const notification = Convert.toNotification(JSON.stringify(json));
|
||||
const notification: Notification = ObjectSerializer.deserialize(json, "Notification");
|
||||
this.notificationItemContainers = notification.notificationItems;
|
||||
this.live = notification.live;
|
||||
}
|
||||
@@ -32,7 +35,7 @@ class NotificationRequest {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.notificationItemContainers.map((container): NotificationRequestItem => container.NotificationRequestItem);
|
||||
return this.notificationItemContainers.map((container): NotificationRequestItem => container.notificationRequestItem);
|
||||
}
|
||||
|
||||
public live: string;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,26 +11,24 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {Cipher, createCipheriv, createDecipheriv, createHmac, randomBytes} from "crypto";
|
||||
import { Cipher, createCipheriv, createDecipheriv, createHmac, randomBytes } from "crypto";
|
||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||
import {
|
||||
MessageHeader,
|
||||
NexoDerivedKey,
|
||||
SaleToPoiSecuredMessage,
|
||||
SaleToPOISecuredMessage,
|
||||
SecurityKey,
|
||||
SecurityTrailer,
|
||||
} from "../typings/terminal";
|
||||
} from "../typings/terminal/models";
|
||||
import InvalidSecurityKeyException from "./exception/invalidSecurityKeyException";
|
||||
import NexoDerivedKeyGenerator from "./nexoDerivedKeyGenerator";
|
||||
import {NexoEnum} from "../constants/nexoConstants";
|
||||
import { NexoEnum } from "../constants/nexoConstants";
|
||||
|
||||
enum Modes {
|
||||
ENCRYPT,
|
||||
@@ -42,7 +40,7 @@ class NexoCrypto {
|
||||
messageHeader: MessageHeader,
|
||||
saleToPoiMessageJson: string,
|
||||
securityKey: SecurityKey,
|
||||
): SaleToPoiSecuredMessage {
|
||||
): SaleToPOISecuredMessage {
|
||||
const derivedKey: NexoDerivedKey = NexoDerivedKeyGenerator.deriveKeyMaterial(securityKey.passphrase);
|
||||
const saleToPoiMessageByteArray = Buffer.from(saleToPoiMessageJson, "ascii");
|
||||
const ivNonce = NexoCrypto.generateRandomIvNonce();
|
||||
@@ -60,11 +58,11 @@ class NexoCrypto {
|
||||
return {
|
||||
messageHeader,
|
||||
nexoBlob: encryptedSaleToPoiMessage.toString("base64"),
|
||||
securityTrailer: securityTrailer,
|
||||
securityTrailer,
|
||||
};
|
||||
}
|
||||
|
||||
public decrypt(saleToPoiSecureMessage: SaleToPoiSecuredMessage, securityKey: SecurityKey): string {
|
||||
public decrypt(saleToPoiSecureMessage: SaleToPOISecuredMessage, securityKey: SecurityKey): string {
|
||||
NexoCrypto.validateSecurityKey(securityKey);
|
||||
|
||||
const encryptedSaleToPoiMessageByteArray = Buffer.from(saleToPoiSecureMessage.nexoBlob, "base64");
|
||||
@@ -83,8 +81,8 @@ class NexoCrypto {
|
||||
const isValid = securityKey
|
||||
&& securityKey.passphrase
|
||||
&& securityKey.keyIdentifier
|
||||
&& securityKey.keyVersion
|
||||
&& securityKey.adyenCryptoVersion;
|
||||
&& !isNaN(securityKey.keyVersion)
|
||||
&& !isNaN(securityKey.adyenCryptoVersion);
|
||||
if (!isValid) {
|
||||
throw new InvalidSecurityKeyException("Invalid Security Key");
|
||||
}
|
||||
|
||||
@@ -11,17 +11,15 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* 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 {pbkdf2Sync} from "crypto";
|
||||
import { NexoDerivedKey } from "../typings/terminal";
|
||||
import {NexoEnum} from "../constants/nexoConstants";
|
||||
import { pbkdf2Sync } from "crypto";
|
||||
import { NexoDerivedKey } from "../typings/terminal/models";
|
||||
import { NexoEnum } from "../constants/nexoConstants";
|
||||
|
||||
class NexoDerivedKeyGenerator {
|
||||
public static deriveKeyMaterial(passphrase: string): NexoDerivedKey {
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -28,8 +26,13 @@ import PaymentsDetails from "./resource/checkout/paymentsDetails";
|
||||
import PaymentSession from "./resource/checkout/paymentSession";
|
||||
import PaymentsResult from "./resource/checkout/paymentsResult";
|
||||
import PaymentLinks from "./resource/checkout/paymentLinks";
|
||||
import OriginKeys from "./resource/checkout/originKeys";
|
||||
import setApplicationInfo from "../helpers/setApplicationInfo";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
import PaymentLinksId from "./resource/checkout/paymentLinksId";
|
||||
import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance";
|
||||
import Orders from "./resource/checkout/orders";
|
||||
import OrdersCancel from "./resource/checkout/ordersCancel";
|
||||
|
||||
class Checkout extends ApiKeyAuthenticatedService {
|
||||
private readonly _payments: Payments;
|
||||
@@ -38,6 +41,11 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
private readonly _paymentSession: PaymentSession;
|
||||
private readonly _paymentsResult: PaymentsResult;
|
||||
private readonly _paymentLinks: PaymentLinks;
|
||||
private readonly _paymentLinksId: PaymentLinksId;
|
||||
private readonly _originKeys: OriginKeys;
|
||||
private readonly _paymentMethodsBalance: PaymentMethodsBalance;
|
||||
private readonly _orders: Orders;
|
||||
private readonly _ordersCancel: OrdersCancel;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
@@ -47,6 +55,11 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
this._paymentSession = new PaymentSession(this);
|
||||
this._paymentsResult = new PaymentsResult(this);
|
||||
this._paymentLinks = new PaymentLinks(this);
|
||||
this._paymentLinksId = new PaymentLinksId(this);
|
||||
this._originKeys = new OriginKeys(this);
|
||||
this._paymentMethodsBalance = new PaymentMethodsBalance(this);
|
||||
this._orders = new Orders(this);
|
||||
this._ordersCancel = new OrdersCancel(this);
|
||||
}
|
||||
|
||||
public payments(paymentsRequest: ICheckout.PaymentRequest, requestOptions?: IRequest.Options): Promise<ICheckout.PaymentResponse> {
|
||||
@@ -64,17 +77,36 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
);
|
||||
}
|
||||
|
||||
public paymentLinks(paymentLinkRequest: ICheckout.CreatePaymentLinkRequest): Promise<ICheckout.CreatePaymentLinkResponse> {
|
||||
return getJsonResponse<ICheckout.CreatePaymentLinkRequest, ICheckout.CreatePaymentLinkResponse>(
|
||||
public paymentLinks(paymentLinkRequest: ICheckout.CreatePaymentLinkRequest): Promise<ICheckout.PaymentLinkResource> {
|
||||
return getJsonResponse<ICheckout.CreatePaymentLinkRequest, ICheckout.PaymentLinkResource>(
|
||||
this._paymentLinks,
|
||||
paymentLinkRequest
|
||||
);
|
||||
}
|
||||
|
||||
public paymentsDetails(paymentsDetailsRequest: ICheckout.DetailsRequest): Promise<ICheckout.PaymentResponse> {
|
||||
public getPaymentLinks(linkId: string): Promise<ICheckout.PaymentLinkResource> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<{}, ICheckout.PaymentLinkResource>(
|
||||
this._paymentLinksId,
|
||||
{},
|
||||
{ method: "GET" }
|
||||
);
|
||||
}
|
||||
|
||||
public updatePaymentLinks(linkId: string, status: "expired"): Promise<ICheckout.PaymentLinkResource> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<{}, ICheckout.PaymentLinkResource>(
|
||||
this._paymentLinksId,
|
||||
{ status },
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
}
|
||||
|
||||
public paymentsDetails(paymentsDetailsRequest: ICheckout.DetailsRequest, requestOptions?: IRequest.Options): Promise<ICheckout.PaymentResponse> {
|
||||
return getJsonResponse<ICheckout.DetailsRequest, ICheckout.PaymentResponse>(
|
||||
this._paymentsDetails,
|
||||
paymentsDetailsRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,6 +127,34 @@ class Checkout extends ApiKeyAuthenticatedService {
|
||||
paymentResultRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public originKeys(originKeysRequest: ICheckout.CheckoutUtilityRequest): Promise<ICheckout.CheckoutUtilityResponse> {
|
||||
return getJsonResponse<ICheckout.CheckoutUtilityRequest, ICheckout.CheckoutUtilityResponse>(
|
||||
this._originKeys,
|
||||
originKeysRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentMethodsBalance(paymentMethodsBalanceRequest: ICheckout.CheckoutBalanceCheckRequest): Promise<ICheckout.CheckoutBalanceCheckResponse> {
|
||||
return getJsonResponse<ICheckout.CheckoutBalanceCheckRequest, ICheckout.CheckoutBalanceCheckResponse>(
|
||||
this._paymentMethodsBalance,
|
||||
paymentMethodsBalanceRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public orders(ordersRequest: ICheckout.CheckoutCreateOrderRequest): Promise<ICheckout.CheckoutCreateOrderResponse> {
|
||||
return getJsonResponse<ICheckout.CheckoutCreateOrderRequest, ICheckout.CheckoutCreateOrderResponse>(
|
||||
this._orders,
|
||||
ordersRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public ordersCancel(ordersCancelRequest: ICheckout.CheckoutCancelOrderRequest): Promise<ICheckout.CheckoutCancelOrderResponse> {
|
||||
return getJsonResponse<ICheckout.CheckoutCancelOrderRequest, ICheckout.CheckoutCancelOrderResponse>(
|
||||
this._ordersCancel,
|
||||
ordersCancelRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Checkout;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -22,8 +20,8 @@
|
||||
export { default as TerminalLocalAPI } from "./terminalLocalAPI";
|
||||
export { default as TerminalCloudAPI } from "./terminalCloudAPI";
|
||||
export { default as CheckoutAPI } from "./checkout";
|
||||
export { default as CheckoutUtility } from "./checkoutUtility";
|
||||
export { default as Recurring } from "./recurring";
|
||||
export { default as Modification } from "./modification";
|
||||
export { default as BinLookup } from "./binLookup";
|
||||
export { default as Payout } from "./payout";
|
||||
export { default as Platforms } from "./platforms";
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -28,8 +26,8 @@ import Capture from "./resource/modification/capture";
|
||||
import Refund from "./resource/modification/refund";
|
||||
import TechnicalCancel from "./resource/modification/technicalCancel";
|
||||
import setApplicationInfo from "../helpers/setApplicationInfo";
|
||||
import {ApplicationInfo} from "../typings/applicationInfo";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { ApplicationInfo } from "../typings/applicationInfo";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
interface AppInfo { applicationInfo?: ApplicationInfo }
|
||||
type GenericRequest<T> = T & AppInfo;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
217
src/services/platforms.ts
Normal file
217
src/services/platforms.ts
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 Service from "../service";
|
||||
import Client from "../client";
|
||||
import PlatformsAccount, { AccountTypesEnum } from "./resource/platforms/account";
|
||||
import getJsonResponse from "./../helpers/getJsonResponse";
|
||||
import PlatformsFund from "./resource/platforms/fund";
|
||||
import PlatformsHostedOnboardingPage from "./resource/platforms/hop";
|
||||
import PlatformsNotificationConfiguration from "./resource/platforms/notificationConfiguration";
|
||||
|
||||
type AccountType = AccountTypesEnum.Accounts;
|
||||
type VerificationType = AccountTypesEnum.Verification;
|
||||
type AccountHoldersType = AccountTypesEnum.AccountHolders;
|
||||
|
||||
type AccountsAccount = PlatformsAccount<AccountType>;
|
||||
type AccountsVerification = PlatformsAccount<VerificationType>;
|
||||
type AccountsAccountHolders = PlatformsAccount<AccountHoldersType>;
|
||||
type PlatformsTypes = AccountsAccount | AccountsVerification | AccountsAccountHolders | PlatformsFund | PlatformsHostedOnboardingPage;
|
||||
|
||||
class Platforms extends Service {
|
||||
/* PlatformsAccount */
|
||||
// Accounts
|
||||
private readonly _closeAccount: PlatformsAccount<AccountType>;
|
||||
private readonly _updateAccount: PlatformsAccount<AccountType>;
|
||||
private readonly _createAccount: PlatformsAccount<AccountType>;
|
||||
// Verification
|
||||
private readonly _uploadDocument: PlatformsAccount<VerificationType>;
|
||||
private readonly _getUploadedDocuments: PlatformsAccount<VerificationType>;
|
||||
private readonly _deleteBankAccounts: PlatformsAccount<VerificationType>;
|
||||
private readonly _deletePayoutMethods: PlatformsAccount<VerificationType>;
|
||||
private readonly _deleteShareholders: PlatformsAccount<VerificationType>;
|
||||
private readonly _checkAccountHolder: PlatformsAccount<VerificationType>;
|
||||
// Account Holders
|
||||
private readonly _createAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _getAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _updateAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _updateAccountHolderState: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _suspendAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _unSuspendAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
private readonly _closeAccountHolder: PlatformsAccount<AccountHoldersType>;
|
||||
|
||||
/* PlatformsFund */
|
||||
private readonly _accountHolderBalance: PlatformsFund;
|
||||
private readonly _accountHolderTransactionList: PlatformsFund;
|
||||
private readonly _payoutAccountHolder: PlatformsFund;
|
||||
private readonly _transferFunds: PlatformsFund;
|
||||
private readonly _refundFundsTransfer: PlatformsFund;
|
||||
private readonly _setupBeneficiary: PlatformsFund;
|
||||
private readonly _refundNotPaidOutTransfers: PlatformsFund;
|
||||
|
||||
/* HOP */
|
||||
private readonly _getOnboardingUrl: PlatformsHostedOnboardingPage;
|
||||
|
||||
/* Notification Configuration */
|
||||
private readonly _createNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
private readonly _getNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
private readonly _getNotificationConfigurationList: PlatformsNotificationConfiguration;
|
||||
private readonly _testNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
private readonly _updateNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
private readonly _deleteNotificationConfiguration: PlatformsNotificationConfiguration;
|
||||
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
|
||||
// Account
|
||||
this._closeAccount = new PlatformsAccount<AccountType>(this, "/closeAccount");
|
||||
this._updateAccount = new PlatformsAccount<AccountType>(this, "/updateAccount");
|
||||
this._createAccount = new PlatformsAccount<AccountType>(this, "/createAccount");
|
||||
this._uploadDocument = new PlatformsAccount<VerificationType>(this, "/uploadDocument");
|
||||
this._getUploadedDocuments = new PlatformsAccount<VerificationType>(this, "/getUploadedDocuments");
|
||||
this._deleteBankAccounts = new PlatformsAccount<VerificationType>(this, "/deleteBankAccounts");
|
||||
this._deletePayoutMethods = new PlatformsAccount<VerificationType>(this, "/deletePayoutMethods");
|
||||
this._deleteShareholders = new PlatformsAccount<VerificationType>(this, "/deleteShareholders");
|
||||
this._checkAccountHolder = new PlatformsAccount<VerificationType>(this, "/checkAccountHolder");
|
||||
this._createAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/createAccountHolder");
|
||||
this._getAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/getAccountHolder");
|
||||
this._updateAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/updateAccountHolder");
|
||||
this._updateAccountHolderState = new PlatformsAccount<AccountHoldersType>(this, "/updateAccountHolderState");
|
||||
this._suspendAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/suspendAccountHolder");
|
||||
this._unSuspendAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/unSuspendAccountHolder");
|
||||
this._closeAccountHolder = new PlatformsAccount<AccountHoldersType>(this, "/closeAccountHolder");
|
||||
|
||||
// Fund
|
||||
this._accountHolderBalance = new PlatformsFund(this, "/accountHolderBalance");
|
||||
this._accountHolderTransactionList = new PlatformsFund(this, "/accountHolderTransactionList");
|
||||
this._payoutAccountHolder = new PlatformsFund(this, "/payoutAccountHolder");
|
||||
this._transferFunds = new PlatformsFund(this, "/transferFunds");
|
||||
this._refundFundsTransfer = new PlatformsFund(this, "/refundFundsTransfer");
|
||||
this._setupBeneficiary = new PlatformsFund(this, "/setupBeneficiary");
|
||||
this._refundNotPaidOutTransfers = new PlatformsFund(this, "/refundNotPaidOutTransfers");
|
||||
|
||||
// HOP
|
||||
this._getOnboardingUrl = new PlatformsHostedOnboardingPage(this, "/getOnboardingUrl");
|
||||
|
||||
// Notification Configuration
|
||||
this._createNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/createNotificationConfiguration");
|
||||
this._getNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/getNotificationConfiguration");
|
||||
this._getNotificationConfigurationList = new PlatformsNotificationConfiguration(this, "/getNotificationConfigurationList");
|
||||
this._testNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/testNotificationConfiguration");
|
||||
this._updateNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/updateNotificationConfiguration");
|
||||
this._deleteNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/deleteNotificationConfigurations");
|
||||
}
|
||||
|
||||
createRequest = <T extends PlatformsTypes, U, V>(service: T) => {
|
||||
return (request: U): Promise<V> => getJsonResponse<U, V>(service, request);
|
||||
}
|
||||
|
||||
public get Account(): {
|
||||
getAccountHolder: (request: IPlatformsAccount.GetAccountHolderRequest) => Promise<IPlatformsAccount.GetAccountHolderResponse>;
|
||||
getUploadedDocuments: (request: IPlatformsAccount.GetUploadedDocumentsRequest) => Promise<IPlatformsAccount.GetUploadedDocumentsResponse>;
|
||||
createAccountHolder: (request: IPlatformsAccount.CreateAccountHolderRequest) => Promise<IPlatformsAccount.CreateAccountHolderResponse>;
|
||||
closeAccountHolder: (request: IPlatformsAccount.CloseAccountHolderRequest) => Promise<IPlatformsAccount.CloseAccountHolderResponse>;
|
||||
createAccount: (request: IPlatformsAccount.CreateAccountRequest) => Promise<IPlatformsAccount.CreateAccountResponse>;
|
||||
deleteBankAccounts: (request: IPlatformsAccount.DeleteBankAccountRequest) => Promise<IPlatformsAccount.GenericResponse>;
|
||||
deletePayoutMethods: (request: IPlatformsAccount.DeletePayoutMethodRequest) => Promise<IPlatformsAccount.GenericResponse>;
|
||||
updateAccount: (request: IPlatformsAccount.UpdateAccountRequest) => Promise<IPlatformsAccount.UpdateAccountResponse>;
|
||||
uploadDocument: (request: IPlatformsAccount.UploadDocumentRequest) => Promise<IPlatformsAccount.GetUploadedDocumentsResponse>;
|
||||
unSuspendAccountHolder: (request: IPlatformsAccount.UnSuspendAccountHolderRequest) => Promise<IPlatformsAccount.UnSuspendAccountHolderResponse>;
|
||||
closeAccount: (request: IPlatformsAccount.CloseAccountRequest) => Promise<IPlatformsAccount.CloseAccountResponse>;
|
||||
suspendAccountHolder: (request: IPlatformsAccount.SuspendAccountHolderRequest) => Promise<IPlatformsAccount.SuspendAccountHolderResponse>;
|
||||
updateAccountHolder: (request: IPlatformsAccount.UpdateAccountHolderRequest) => Promise<IPlatformsAccount.UpdateAccountHolderResponse>;
|
||||
deleteShareholders: (request: IPlatformsAccount.DeleteShareholderRequest) => Promise<IPlatformsAccount.GenericResponse>;
|
||||
checkAccountHolder: (request: IPlatformsAccount.PerformVerificationRequest) => Promise<IPlatformsAccount.GenericResponse>;
|
||||
updateAccountHolderState: (request: IPlatformsAccount.UpdateAccountHolderStateRequest) => Promise<IPlatformsAccount.GetAccountHolderStatusResponse>;
|
||||
} {
|
||||
const closeAccount = this.createRequest<AccountsAccount, IPlatformsAccount.CloseAccountRequest, IPlatformsAccount.CloseAccountResponse>(this._closeAccount);
|
||||
const updateAccount = this.createRequest<AccountsAccount, IPlatformsAccount.UpdateAccountRequest, IPlatformsAccount.UpdateAccountResponse>(this._updateAccount);
|
||||
const createAccount = this.createRequest<AccountsAccount, IPlatformsAccount.CreateAccountRequest, IPlatformsAccount.CreateAccountResponse>(this._createAccount);
|
||||
|
||||
const uploadDocument = this.createRequest<AccountsVerification, IPlatformsAccount.UploadDocumentRequest, IPlatformsAccount.GetUploadedDocumentsResponse>(this._uploadDocument);
|
||||
const getUploadedDocuments = this.createRequest<AccountsVerification, IPlatformsAccount.GetUploadedDocumentsRequest, IPlatformsAccount.GetUploadedDocumentsResponse>(this._getUploadedDocuments);
|
||||
const deleteBankAccounts = this.createRequest<AccountsVerification, IPlatformsAccount.DeleteBankAccountRequest, IPlatformsAccount.GenericResponse>(this._deleteBankAccounts);
|
||||
const deletePayoutMethods = this.createRequest<AccountsVerification, IPlatformsAccount.DeletePayoutMethodRequest, IPlatformsAccount.GenericResponse>(this._deletePayoutMethods);
|
||||
const deleteShareholders = this.createRequest<AccountsVerification, IPlatformsAccount.DeleteShareholderRequest, IPlatformsAccount.GenericResponse>(this._deleteShareholders);
|
||||
|
||||
const createAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.CreateAccountHolderRequest, IPlatformsAccount.CreateAccountHolderResponse>(this._createAccountHolder);
|
||||
const getAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.GetAccountHolderRequest, IPlatformsAccount.GetAccountHolderResponse>(this._getAccountHolder);
|
||||
const updateAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.UpdateAccountHolderRequest, IPlatformsAccount.UpdateAccountHolderResponse>(this._updateAccountHolder);
|
||||
const updateAccountHolderState = this.createRequest<AccountsAccountHolders, IPlatformsAccount.UpdateAccountHolderStateRequest, IPlatformsAccount.GetAccountHolderStatusResponse>(this._updateAccountHolderState);
|
||||
const suspendAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.SuspendAccountHolderRequest, IPlatformsAccount.SuspendAccountHolderResponse>(this._suspendAccountHolder);
|
||||
const unSuspendAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.UnSuspendAccountHolderRequest, IPlatformsAccount.UnSuspendAccountHolderResponse>(this._unSuspendAccountHolder);
|
||||
const closeAccountHolder = this.createRequest<AccountsAccountHolders, IPlatformsAccount.CloseAccountHolderRequest, IPlatformsAccount.CloseAccountHolderResponse>(this._closeAccountHolder);
|
||||
const checkAccountHolder = this.createRequest<AccountsVerification, IPlatformsAccount.PerformVerificationRequest, IPlatformsAccount.GenericResponse>(this._checkAccountHolder);
|
||||
|
||||
const accounts = { closeAccount, updateAccount, createAccount };
|
||||
const verification = { uploadDocument, getUploadedDocuments, deleteBankAccounts, deletePayoutMethods, deleteShareholders, checkAccountHolder };
|
||||
const accountHolders = { createAccountHolder, getAccountHolder, updateAccountHolder, updateAccountHolderState, suspendAccountHolder, unSuspendAccountHolder, closeAccountHolder};
|
||||
|
||||
return {...accounts, ...verification, ...accountHolders };
|
||||
}
|
||||
|
||||
public get Fund(): {
|
||||
refundNotPaidOutTransfers: (request: IPlatformsFund.RefundNotPaidOutTransfersRequest) => Promise<IPlatformsFund.RefundNotPaidOutTransfersResponse>;
|
||||
accountHolderTransactionList: (request: IPlatformsFund.AccountHolderTransactionListRequest) => Promise<IPlatformsFund.AccountHolderTransactionListResponse>;
|
||||
setupBeneficiary: (request: IPlatformsFund.SetupBeneficiaryRequest) => Promise<IPlatformsFund.SetupBeneficiaryResponse>;
|
||||
transferFunds: (request: IPlatformsFund.TransferFundsRequest) => Promise<IPlatformsFund.TransferFundsResponse>;
|
||||
refundFundsTransfer: (request: IPlatformsFund.RefundFundsTransferRequest) => Promise<IPlatformsFund.RefundFundsTransferResponse>;
|
||||
payoutAccountHolder: (request: IPlatformsFund.PayoutAccountHolderRequest) => Promise<IPlatformsFund.PayoutAccountHolderResponse>;
|
||||
accountHolderBalance: (request: IPlatformsFund.AccountHolderBalanceRequest) => Promise<IPlatformsFund.AccountHolderBalanceResponse>;
|
||||
} {
|
||||
const accountHolderBalance = this.createRequest<PlatformsFund, IPlatformsFund.AccountHolderBalanceRequest, IPlatformsFund.AccountHolderBalanceResponse>(this._accountHolderBalance);
|
||||
const accountHolderTransactionList = this.createRequest<PlatformsFund, IPlatformsFund.AccountHolderTransactionListRequest, IPlatformsFund.AccountHolderTransactionListResponse>(this._accountHolderTransactionList);
|
||||
const payoutAccountHolder = this.createRequest<PlatformsFund, IPlatformsFund.PayoutAccountHolderRequest, IPlatformsFund.PayoutAccountHolderResponse>(this._payoutAccountHolder);
|
||||
const transferFunds = this.createRequest<PlatformsFund, IPlatformsFund.TransferFundsRequest, IPlatformsFund.TransferFundsResponse>(this._transferFunds);
|
||||
const refundFundsTransfer = this.createRequest<PlatformsFund, IPlatformsFund.RefundFundsTransferRequest, IPlatformsFund.RefundFundsTransferResponse>(this._refundFundsTransfer);
|
||||
const setupBeneficiary = this.createRequest<PlatformsFund, IPlatformsFund.SetupBeneficiaryRequest, IPlatformsFund.SetupBeneficiaryResponse>(this._setupBeneficiary);
|
||||
const refundNotPaidOutTransfers = this.createRequest<PlatformsFund, IPlatformsFund.RefundNotPaidOutTransfersRequest, IPlatformsFund.RefundNotPaidOutTransfersResponse>(this._refundNotPaidOutTransfers);
|
||||
|
||||
return { accountHolderBalance, accountHolderTransactionList, payoutAccountHolder, refundFundsTransfer, transferFunds, setupBeneficiary, refundNotPaidOutTransfers };
|
||||
}
|
||||
|
||||
public get HostedOnboardingPage(): { getOnboardingUrl: (request: IPlatformsHostedOnboardingPage.GetOnboardingUrlRequest) => Promise<IPlatformsHostedOnboardingPage.GetOnboardingUrlResponse> } {
|
||||
const getOnboardingUrl = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsHostedOnboardingPage.GetOnboardingUrlRequest, IPlatformsHostedOnboardingPage.GetOnboardingUrlResponse>(this._getOnboardingUrl);
|
||||
|
||||
return { getOnboardingUrl };
|
||||
}
|
||||
|
||||
public get NotificationConfiguration(): {
|
||||
createNotificationConfiguration: (request: IPlatformsNotificationConfiguration.CreateNotificationConfigurationRequest) => Promise<IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>;
|
||||
updateNotificationConfiguration: (request: IPlatformsNotificationConfiguration.UpdateNotificationConfigurationRequest) => Promise<IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>;
|
||||
getNotificationConfiguration: (request: IPlatformsNotificationConfiguration.GetNotificationConfigurationRequest) => Promise<IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>;
|
||||
testNotificationConfiguration: (request: IPlatformsNotificationConfiguration.TestNotificationConfigurationRequest) => Promise<IPlatformsNotificationConfiguration.TestNotificationConfigurationResponse>;
|
||||
getNotificationConfigurationList: (request: {}) => Promise<IPlatformsNotificationConfiguration.GetNotificationConfigurationListResponse>;
|
||||
deleteNotificationConfigurations: (request: IPlatformsNotificationConfiguration.DeleteNotificationConfigurationRequest) => Promise<IPlatformsNotificationConfiguration.GenericResponse>;
|
||||
} {
|
||||
const createNotificationConfiguration = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsNotificationConfiguration.CreateNotificationConfigurationRequest, IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>(this._createNotificationConfiguration);
|
||||
const getNotificationConfiguration = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsNotificationConfiguration.GetNotificationConfigurationRequest, IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>(this._getNotificationConfiguration);
|
||||
const getNotificationConfigurationList = this.createRequest<PlatformsHostedOnboardingPage, {}, IPlatformsNotificationConfiguration.GetNotificationConfigurationListResponse>(this._getNotificationConfigurationList);
|
||||
const testNotificationConfiguration = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsNotificationConfiguration.TestNotificationConfigurationRequest, IPlatformsNotificationConfiguration.TestNotificationConfigurationResponse>(this._testNotificationConfiguration);
|
||||
const updateNotificationConfiguration = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsNotificationConfiguration.UpdateNotificationConfigurationRequest, IPlatformsNotificationConfiguration.GetNotificationConfigurationResponse>(this._updateNotificationConfiguration);
|
||||
const deleteNotificationConfigurations = this.createRequest<PlatformsHostedOnboardingPage, IPlatformsNotificationConfiguration.DeleteNotificationConfigurationRequest, IPlatformsNotificationConfiguration.GenericResponse>(this._deleteNotificationConfiguration);
|
||||
|
||||
return { createNotificationConfiguration, getNotificationConfiguration, getNotificationConfigurationList, testNotificationConfiguration, updateNotificationConfiguration, deleteNotificationConfigurations };
|
||||
}
|
||||
}
|
||||
|
||||
export default Platforms;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -24,15 +22,18 @@ import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
import Disable from "./resource/recurring/disable";
|
||||
import ListRecurringDetails from "./resource/recurring/listRecurringDetails";
|
||||
import ScheduleAccountUpdater from "./resource/recurring/scheduleAccountUpdater";
|
||||
|
||||
class Recurring extends Service {
|
||||
private readonly _listRecurringDetails: ListRecurringDetails;
|
||||
private readonly _disable: Disable;
|
||||
private readonly _scheduleAccountUpdater: ScheduleAccountUpdater;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._listRecurringDetails = new ListRecurringDetails(this);
|
||||
this._disable = new Disable(this);
|
||||
this._scheduleAccountUpdater = new ScheduleAccountUpdater(this);
|
||||
}
|
||||
|
||||
public listRecurringDetails(request: IRecurring.RecurringDetailsRequest): Promise<IRecurring.RecurringDetailsResult> {
|
||||
@@ -48,6 +49,13 @@ class Recurring extends Service {
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public scheduleAccountUpdater(request: IRecurring.ScheduleAccountUpdaterRequest): Promise<IRecurring.ScheduleAccountUpdaterResult> {
|
||||
return getJsonResponse<IRecurring.ScheduleAccountUpdaterRequest, IRecurring.ScheduleAccountUpdaterResult>(
|
||||
this._scheduleAccountUpdater,
|
||||
request,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Recurring;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -24,7 +22,7 @@ import Service from "../service";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "./exception/apiException";
|
||||
import ClientInterface from "../httpClient/clientInterface";
|
||||
import {IRequest} from "../typings/requestOptions";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
abstract class Resource {
|
||||
protected endpoint: string;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
33
src/services/resource/checkout/orders.ts
Normal file
33
src/services/resource/checkout/orders.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.
|
||||
*/
|
||||
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class Orders extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/orders`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Orders;
|
||||
33
src/services/resource/checkout/ordersCancel.ts
Normal file
33
src/services/resource/checkout/ordersCancel.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.
|
||||
*/
|
||||
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class OrdersCancel extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/orders/cancel`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default OrdersCancel;
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
@@ -27,7 +25,7 @@ class OriginKeys extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_UTILITY_API_VERSION}/originKeys`,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/originKeys`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
40
src/services/resource/checkout/paymentLinksId.ts
Normal file
40
src/services/resource/checkout/paymentLinksId.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class PaymentLinksId extends Resource {
|
||||
static _id: string;
|
||||
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks`,
|
||||
);
|
||||
}
|
||||
|
||||
public set id(id: string) {
|
||||
PaymentLinksId._id = id;
|
||||
this.endpoint = `${this.endpoint}/${PaymentLinksId._id}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentLinksId;
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
33
src/services/resource/checkout/paymentMethodsBalance.ts
Normal file
33
src/services/resource/checkout/paymentMethodsBalance.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.
|
||||
*/
|
||||
|
||||
import Client from "../../../client";
|
||||
import Service from "../../../service";
|
||||
import Resource from "../../resource";
|
||||
|
||||
class PaymentMethodsBalance extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentMethods/balance`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentMethodsBalance;
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* Adyen NodeJS API Library
|
||||
*
|
||||
* Copyright (c) 2019 Adyen B.V.
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user