mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-04-19 23:51:22 +00:00
Compare commits
827 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5f220bfb9 | ||
|
|
2656571798 | ||
|
|
06e82d3ea2 | ||
|
|
8e2591e8b4 | ||
|
|
bd2efdc25f | ||
|
|
7271586f83 | ||
|
|
3b7473089c | ||
|
|
6dfb8c4608 | ||
|
|
1d1b139170 | ||
|
|
85844dca28 | ||
|
|
4ae97882eb | ||
|
|
a426257011 | ||
|
|
115e156039 | ||
|
|
f9c140e5ad | ||
|
|
348747c5cf | ||
|
|
6a235ea765 | ||
|
|
7879c61e20 | ||
|
|
fdb6c9a9d5 | ||
|
|
64168e81f3 | ||
|
|
9df9d65ede | ||
|
|
ceb2a7024f | ||
|
|
4fc117b83b | ||
|
|
1a9b686f92 | ||
|
|
7d0accca2d | ||
|
|
33e02dda69 | ||
|
|
ef5ac43290 | ||
|
|
c9ab19fa02 | ||
|
|
5af7223368 | ||
|
|
ef25f08907 | ||
|
|
38664eb805 | ||
|
|
1bccc3669a | ||
|
|
6fa60b78a3 | ||
|
|
6ccee7a97c | ||
|
|
d914354d2b | ||
|
|
f5191e1ca0 | ||
|
|
78c2762639 | ||
|
|
4711ca629a | ||
|
|
3cde27162d | ||
|
|
34da0e2344 | ||
|
|
d51209559d | ||
|
|
5ed145542a | ||
|
|
a2b4465f66 | ||
|
|
b226ea13bb | ||
|
|
fb5bca50ff | ||
|
|
40e1ae5708 | ||
|
|
e3e95a0449 | ||
|
|
72348de349 | ||
|
|
83eb23be6e | ||
|
|
348077d331 | ||
|
|
cad082a28e | ||
|
|
96f4875a60 | ||
|
|
744a6b3326 | ||
|
|
58734d04a0 | ||
|
|
b91f9100b2 | ||
|
|
2ab7c65096 | ||
|
|
1a265f2e54 | ||
|
|
4c6978cf94 | ||
|
|
9db8ea9399 | ||
|
|
2def262914 | ||
|
|
9f67aef570 | ||
|
|
cb16293fd2 | ||
|
|
1150dfdc2b | ||
|
|
a809b74daf | ||
|
|
48699e7e77 | ||
|
|
df9a81cf6c | ||
|
|
bf5a6697e1 | ||
|
|
3b11ec3cfb | ||
|
|
843d33f5fd | ||
|
|
41dbb590e0 | ||
|
|
5fa5c33d6b | ||
|
|
989e8a3032 | ||
|
|
835638351f | ||
|
|
c4d8acd8e7 | ||
|
|
7b49208071 | ||
|
|
54bbb3858e | ||
|
|
6b17d1e8cb | ||
|
|
32c40b652d | ||
|
|
601e45d6fe | ||
|
|
19646f7c47 | ||
|
|
db5d40910c | ||
|
|
867649debf | ||
|
|
ecbc706777 | ||
|
|
9090dd5746 | ||
|
|
4c84199bcf | ||
|
|
207d66b915 | ||
|
|
642988a892 | ||
|
|
70756a512e | ||
|
|
000c3f8a8b | ||
|
|
92a5495fd8 | ||
|
|
086cf3767a | ||
|
|
7e1010f0e0 | ||
|
|
67cad90a22 | ||
|
|
75cbe49d79 | ||
|
|
aac4537961 | ||
|
|
b31dc8e237 | ||
|
|
e43f264e5d | ||
|
|
14fd047ca6 | ||
|
|
cf6fd2b4f7 | ||
|
|
05c39c762c | ||
|
|
db9362d69a | ||
|
|
62dcb76dfe | ||
|
|
d10588026c | ||
|
|
84b3cc3405 | ||
|
|
f1e13cf374 | ||
|
|
0f50ac7fdb | ||
|
|
63acc897a6 | ||
|
|
a97e9cb9e4 | ||
|
|
2fe5954559 | ||
|
|
85a3cab5e1 | ||
|
|
975cd6d020 | ||
|
|
112d9063e7 | ||
|
|
10ce6dff7b | ||
|
|
ea80034a46 | ||
|
|
8dc1c0eb60 | ||
|
|
8c7e045c17 | ||
|
|
fab95af3ea | ||
|
|
1908978e03 | ||
|
|
fda407dc93 | ||
|
|
92b9f346b7 | ||
|
|
0d36b0c140 | ||
|
|
c289d31469 | ||
|
|
b94018e6e3 | ||
|
|
da147aafa5 | ||
|
|
a11a62eb10 | ||
|
|
a49d273ea0 | ||
|
|
c5d4a200c8 | ||
|
|
b61624b392 | ||
|
|
4a3fb1b2bb | ||
|
|
3de6af6cdf | ||
|
|
54edffa5e3 | ||
|
|
033b5628f1 | ||
|
|
31437be75d | ||
|
|
a201f7e59a | ||
|
|
66bfceceec | ||
|
|
e676298654 | ||
|
|
5bd522b80f | ||
|
|
bd3c8a0f6b | ||
|
|
21892df7ff | ||
|
|
1721ab770f | ||
|
|
b671d126ac | ||
|
|
7170189560 | ||
|
|
95f0c56564 | ||
|
|
760807d978 | ||
|
|
a43473da45 | ||
|
|
d63d9fc8c6 | ||
|
|
28b52ecbb0 | ||
|
|
450c2c77cb | ||
|
|
8464c72aa4 | ||
|
|
3f1962c5e6 | ||
|
|
d01555af69 | ||
|
|
4f5e9ff799 | ||
|
|
1cdc125263 | ||
|
|
57b06ee000 | ||
|
|
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 | ||
|
|
bd8fa55cef | ||
|
|
6d9b17609c | ||
|
|
7f5f8cf2a2 | ||
|
|
6fbbff62fa | ||
|
|
2733ba9302 | ||
|
|
2e9e50bcc0 | ||
|
|
e11bdc2f93 | ||
|
|
05b06709f3 | ||
|
|
043c166fa6 | ||
|
|
edb56e3a2a | ||
|
|
d775655d86 | ||
|
|
5a8d3f0147 | ||
|
|
04747ce27f | ||
|
|
ef269b7ab1 | ||
|
|
4fbc665977 | ||
|
|
99edca9ad8 | ||
|
|
5e39f22b27 | ||
|
|
77d1175be1 | ||
|
|
395957d996 | ||
|
|
a9542bd568 | ||
|
|
bf4648af0f | ||
|
|
6208bd4b72 | ||
|
|
68431357b8 | ||
|
|
14dc2285bc | ||
|
|
75d056c1b1 | ||
|
|
7ca2c61b1a | ||
|
|
bb3874fc9c | ||
|
|
6377fe9f4d | ||
|
|
d2581b491c | ||
|
|
52ce784767 | ||
|
|
e69d27fa30 | ||
|
|
62497d123c | ||
|
|
5135a538e0 | ||
|
|
54e7b903bf | ||
|
|
6ad466654a | ||
|
|
d9457857cb | ||
|
|
cbfccd9d05 | ||
|
|
2ca3321605 | ||
|
|
53546d639e | ||
|
|
732752ee61 | ||
|
|
cb7dace017 | ||
|
|
11b21d03c2 | ||
|
|
4294caac37 | ||
|
|
7626667f99 | ||
|
|
554f8c8a01 | ||
|
|
4c528dbe71 | ||
|
|
0db48543f5 | ||
|
|
02796824cc | ||
|
|
a5259a443c | ||
|
|
4fe9e4f6a0 | ||
|
|
9f7d71759d | ||
|
|
9d98388b2a | ||
|
|
5d31670290 | ||
|
|
bdc7336b2f | ||
|
|
99a9b58528 | ||
|
|
0a2fcda73a | ||
|
|
fa19242b0c | ||
|
|
5f7ad68339 | ||
|
|
439e95b2f3 | ||
|
|
af9bbc5630 | ||
|
|
5f7a9b3611 | ||
|
|
a2447c6a09 | ||
|
|
0a4349b86d | ||
|
|
43556da382 | ||
|
|
b8062f7a94 | ||
|
|
2990f71d11 | ||
|
|
fbe374e394 | ||
|
|
5b28d9d806 | ||
|
|
d4891fe97d | ||
|
|
5be7c38302 | ||
|
|
fabd41584e | ||
|
|
98a7741107 | ||
|
|
b06c2ccf1b | ||
|
|
158843ec69 | ||
|
|
4b2f875c7a | ||
|
|
675377448a | ||
|
|
3e1042b4ce | ||
|
|
d9afdd2fe9 | ||
|
|
cb2c7d9872 | ||
|
|
30caa5a3c2 | ||
|
|
93f25fd687 | ||
|
|
5e09e336bc | ||
|
|
1dff362706 | ||
|
|
76e6904b89 | ||
|
|
d2819aa9e2 | ||
|
|
409f1fd405 | ||
|
|
b81e4a4e41 | ||
|
|
5594ff573c | ||
|
|
fff61d8eb7 | ||
|
|
15eddcbac2 | ||
|
|
0288acd7a3 | ||
|
|
98b55e9438 | ||
|
|
fae77fc1ca | ||
|
|
36f5d7e920 | ||
|
|
ff993a2e8d | ||
|
|
e5f60ecfed | ||
|
|
0d95a73f41 | ||
|
|
5ebf1966f2 | ||
|
|
63e6e1979c | ||
|
|
7231957e37 | ||
|
|
074a9d708d | ||
|
|
c0d6257573 | ||
|
|
8e3cb93756 | ||
|
|
427427619d | ||
|
|
2463523aaf | ||
|
|
0128f5f89a | ||
|
|
3799f21851 | ||
|
|
1bd4829b7a | ||
|
|
eb6577bb7c | ||
|
|
b7e14948ad | ||
|
|
b70dc70070 | ||
|
|
97f9a5a3bc | ||
|
|
68822e485a | ||
|
|
1ff792277a | ||
|
|
097a6c423b | ||
|
|
842fe1a50b | ||
|
|
11728b3db5 | ||
|
|
c171f7b674 | ||
|
|
431297593f | ||
|
|
0af9e8b589 | ||
|
|
71fd431c46 | ||
|
|
170685f6c4 | ||
|
|
f6a1716714 | ||
|
|
b3dc185851 | ||
|
|
57e3dccb11 | ||
|
|
9a194e7752 | ||
|
|
7e76d1b4c8 | ||
|
|
e5b8b70ecd | ||
|
|
90f0e664b9 | ||
|
|
f87c525cf8 | ||
|
|
61ef73c0d1 | ||
|
|
d89f0974a5 | ||
|
|
282fc30e28 | ||
|
|
8c635a7855 | ||
|
|
edbdd6cc7d | ||
|
|
2f5408d436 | ||
|
|
3ea6181d91 | ||
|
|
5d02fc148b | ||
|
|
8acd312ab0 | ||
|
|
f1e3848439 | ||
|
|
dd56326255 | ||
|
|
0d6406694b | ||
|
|
5742a463ae | ||
|
|
7c49bc466b | ||
|
|
ffa63e8204 | ||
|
|
91f38e0272 | ||
|
|
7cd93d6512 | ||
|
|
0facfe2419 | ||
|
|
37f6085d24 | ||
|
|
437c062788 | ||
|
|
780fb5bbf1 | ||
|
|
db6716a85a | ||
|
|
9e6c216aae | ||
|
|
7d3b2731f6 | ||
|
|
b1fd794054 | ||
|
|
af80b86594 | ||
|
|
fc5010078b | ||
|
|
5385ca5bb6 | ||
|
|
87f87d0181 | ||
|
|
42b71d41a2 | ||
|
|
ec0e711fd8 | ||
|
|
a61f51d43b | ||
|
|
5b8c2b2ff8 | ||
|
|
c30f290aef | ||
|
|
20874e0be1 | ||
|
|
e397e82837 | ||
|
|
b2e376f9ef | ||
|
|
db64524183 | ||
|
|
a838223d85 | ||
|
|
22b3304de8 | ||
|
|
cbdbf2e06c | ||
|
|
ea3cdc0ea1 | ||
|
|
a9a159dea1 | ||
|
|
72fde9df1e | ||
|
|
0f6df1f986 | ||
|
|
892e9c86a3 | ||
|
|
ac658aaa18 | ||
|
|
e0bade95d3 | ||
|
|
f4c62229ff | ||
|
|
07065c35cf | ||
|
|
b2b28a015f | ||
|
|
f037f82d0a | ||
|
|
b50ce4f3c0 | ||
|
|
48c432ea60 | ||
|
|
af7726e38a | ||
|
|
7d7cc553c0 | ||
|
|
b803ae3c99 | ||
|
|
8b63cf304a | ||
|
|
fcb7254fc2 | ||
|
|
ec9512cb46 | ||
|
|
5a6342ea8d | ||
|
|
a4c7eab0b9 | ||
|
|
9b3aa8654d | ||
|
|
7f211f9993 | ||
|
|
b48f918c8f | ||
|
|
0b5dc06a0f | ||
|
|
d45aafe5da | ||
|
|
eb91438565 | ||
|
|
eb8693828e | ||
|
|
bbb9ba61c5 | ||
|
|
1a72ded6a9 | ||
|
|
11be95449c | ||
|
|
6d4ec15049 | ||
|
|
0aa6a70122 | ||
|
|
ea211b0df4 | ||
|
|
5998794a98 |
22
.babelrc
22
.babelrc
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
56
.eslintrc.js
Normal file
56
.eslintrc.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint"],
|
||||
env: {
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 6,
|
||||
sourceType: "module",
|
||||
ecmaFeatures: {
|
||||
modules: true
|
||||
},
|
||||
project: path.resolve(__dirname, "./tsconfig.json"),
|
||||
tsconfigRootDir: __dirname
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
rules: {
|
||||
quotes: ["error", "double"],
|
||||
semi: ["error", "always"],
|
||||
"@typescript-eslint/no-non-null-assertion": 0
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.ts"],
|
||||
rules: {
|
||||
"no-dupe-class-members": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"modules": true
|
||||
},
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"quotes": ["error", "double"],
|
||||
"semi": ["error", "always"]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"rules": {
|
||||
"no-dupe-class-members": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @zaiddreakh @maassenbas @AlexandrosMor @peterojo @wboereboom
|
||||
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -3,7 +3,7 @@ name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: '[BUG]'
|
||||
labels: 'bug'
|
||||
assignees: 'KadoBOT'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -3,7 +3,7 @@ name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: '[FEATURE]'
|
||||
labels: 'feature'
|
||||
assignees: 'KadoBOT'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
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 -->
|
||||
15
.github/dependabot.yml
vendored
Normal file
15
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "04:00"
|
||||
open-pull-requests-limit: 10
|
||||
reviewers:
|
||||
- zaiddreakh
|
||||
maassenbas
|
||||
msilvagarcia
|
||||
AlexandrosMor
|
||||
peterojo
|
||||
wboereboom
|
||||
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.
|
||||
46
.github/workflows/codeql-analysis.yml
vendored
Normal file
46
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
|
||||
# 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@v2
|
||||
|
||||
- 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}}
|
||||
21
.github/workflows/sonarcloud.yml
vendored
Normal file
21
.github/workflows/sonarcloud.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: "Sonarcloud Analysis"
|
||||
|
||||
on: ["push", "pull_request"]
|
||||
|
||||
jobs:
|
||||
sonarcloud-analysis:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Disabling shallow clone to improve relevancy of SonarCloud reporting
|
||||
fetch-depth: 0
|
||||
|
||||
- name: SonarCloud integration
|
||||
uses: sonarsource/sonarcloud-github-action@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -10,6 +10,6 @@ node_modules
|
||||
.npm/
|
||||
.ssh/
|
||||
.viminfo
|
||||
local/
|
||||
coverage/
|
||||
dist/
|
||||
.env
|
||||
lib/
|
||||
@@ -7,4 +7,5 @@ src/
|
||||
tsconfig.json
|
||||
jest.config.js
|
||||
tslint.json
|
||||
webpack.config.js
|
||||
webpack.config.js
|
||||
.github
|
||||
|
||||
20
.release-it.json
Normal file
20
.release-it.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"git": {
|
||||
"tagName": "v${version}",
|
||||
"changelog": "npx auto-changelog --hide-credit --stdout --commit-limit false --unreleased-only -t keepachangelog",
|
||||
"commitMessage": "Release ${version}",
|
||||
"tag": true,
|
||||
"requireCleanWorkingDir": false
|
||||
},
|
||||
"github": {
|
||||
"release": true,
|
||||
"releaseName": "Adyen Node API Library v${version}"
|
||||
},
|
||||
"hooks": {
|
||||
"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
|
||||
20
CONTRIBUTING.md
Normal file
20
CONTRIBUTING.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Contribution guidelines
|
||||
|
||||
## How to contribute step-by-step
|
||||
|
||||
1. Fork the `Adyen/adyen-node-api-library` repository.
|
||||
2. Create a new branch from `develop` in your fork. This makes it easier for you to keep track of your changes.
|
||||
3. Make the desired changes to the code.
|
||||
* If you are adding new functionality or fixing a bug, we recommend you add unit tests that cover it.
|
||||
4. Push the changes to your fork.
|
||||
5. Create a pull request to the `Adyen/adyen-node-api-library` repository.
|
||||
6. In your pull request, please describe in detail:
|
||||
* What problem you’re solving
|
||||
* Your approach to fixing the problem
|
||||
* Any tests you wrote
|
||||
7. Check Allow edits from maintainers.
|
||||
8. Create the pull request.
|
||||
9. Ensure that all checks have passed.
|
||||
|
||||
After you create your pull request, one of the code owners will review your code.
|
||||
We aim to review your request within 2-3 business days.
|
||||
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
|
||||
|
||||
83
README.md
83
README.md
@@ -1,27 +1,35 @@
|
||||
# Adyen Node.js API Library
|
||||
[](https://travis-ci.org/Adyen/adyen-node-api-library)
|
||||
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=feature/add-coveralls)
|
||||

|
||||
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=master)
|
||||
[](https://www.npmjs.com/package/@adyen/api-library)
|
||||
[](https://npm.runkit.com/@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 and Hosted Payment Pages.
|
||||
This is the officially supported NodeJS library for using Adyen's APIs.
|
||||
|
||||
## Integration
|
||||
The Library supports all APIs under the following services:
|
||||
|
||||
* [x] checkout
|
||||
* [x] checkout utility
|
||||
* [x] payments
|
||||
* [x] modifications
|
||||
* [x] payouts
|
||||
* [x] recurring
|
||||
* [x] notifications
|
||||
* [x] BIN lookup
|
||||
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/overview): Our latest integration for accepting online payments. Current supported version: **v67**
|
||||
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
|
||||
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
|
||||
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
|
||||
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms.
|
||||
* [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
|
||||
* [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
|
||||
* [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
|
||||
* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration.
|
||||
* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v50**
|
||||
|
||||
## Requirements
|
||||
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
||||
|
||||
* Node 8.1.1 or higher
|
||||
## Prerequisites
|
||||
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
|
||||
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
|
||||
- Node 10 or higher
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -33,12 +41,28 @@ You can use NPM to add our library to your project
|
||||
npm install --save @adyen/api-library
|
||||
```
|
||||
|
||||
## Documentation
|
||||
* https://docs.adyen.com/developers/development-resources/libraries
|
||||
* https://docs.adyen.com/developers/checkout/api-integration
|
||||
Alternatively, you can download the [release on GitHub](https://github.com/Adyen/adyen-node-api-library/releases).
|
||||
|
||||
## HTTP Client Configuration
|
||||
|
||||
## Using the library
|
||||
|
||||
### General use with API key
|
||||
|
||||
Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen:
|
||||
|
||||
```typescript
|
||||
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
||||
```
|
||||
### General use with API key for live environment
|
||||
```typescript
|
||||
const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});
|
||||
```
|
||||
### General use with basic auth
|
||||
```typescript
|
||||
const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});
|
||||
```
|
||||
|
||||
### Custom HTTP Client Configuration
|
||||
By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`:
|
||||
|
||||
```javascript
|
||||
@@ -85,14 +109,23 @@ client.httpClient = httpClient;
|
||||
...
|
||||
```
|
||||
|
||||
## Support
|
||||
### Example integration
|
||||
|
||||
For a closer look at how our NodeJS library works, clone our [example integration](https://github.com/adyen-examples/adyen-node-online-payments). This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
|
||||
|
||||
If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com.
|
||||
## Contributing
|
||||
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
|
||||
* New features and functionality
|
||||
* Resolved bug fixes and issues
|
||||
* Any general improvements
|
||||
|
||||
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how to create a pull request.
|
||||
|
||||
## Support
|
||||
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/).
|
||||
|
||||
## Licence
|
||||
This repository is available under the [MIT license](LICENSE).
|
||||
|
||||
MIT license. For more information, see the LICENSE file.
|
||||
|
||||
## Other
|
||||
|
||||
You can find examples inside the `examples` folder in this repo.
|
||||
## See also
|
||||
* [example integration](https://github.com/adyen-examples/adyen-node-online-payments)
|
||||
|
||||
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"
|
||||
@@ -1,24 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const asyncPayment = async () => {
|
||||
console.log("Starting transaction...");
|
||||
const sentRequest = await terminalAPI.paymentRequestAsync();
|
||||
|
||||
console.log("Request sent. Waiting to retrieve status...");
|
||||
setTimeout(async () => {
|
||||
console.log("Retrieving status...");
|
||||
const statusResponse = await terminalAPI.transactionStatusRequestSync(sentRequest);
|
||||
|
||||
const {TransactionStatusResponse} = statusResponse.SaleToPOIResponse;
|
||||
if (TransactionStatusResponse && TransactionStatusResponse.Response.Result === 'Success') {
|
||||
console.log("Response [result:%s data:%s]",
|
||||
statusResponse.SaleToPOIResponse.TransactionStatusResponse.RepeatedMessageResponse.RepeatedResponseMessageBody.PaymentResponse.Response.Result,
|
||||
statusResponse.SaleToPOIResponse.TransactionStatusResponse.RepeatedMessageResponse.RepeatedResponseMessageBody.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
} else {
|
||||
console.log("Response [result:%s]", statusResponse.SaleToPOIResponse.TransactionStatusResponse.Response.Result)
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const localPayment = async () => {
|
||||
const paymentsResponse = await terminalAPI.paymentRequestLocal();
|
||||
|
||||
console.log("Response [result:%s data:%s]",
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.Result,
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
const TerminalAPI = require("./terminalApi");
|
||||
const terminalAPI = new TerminalAPI();
|
||||
|
||||
const syncPayment = async () => {
|
||||
console.log("Starting transaction...");
|
||||
const paymentsResponse = await terminalAPI.paymentRequestSync();
|
||||
|
||||
console.log("Response [result:%s data:%s]",
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.Result,
|
||||
paymentsResponse.SaleToPOIResponse.PaymentResponse.Response.AdditionalResponse
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
const {Client, Config, TerminalCloudAPI, TerminalLocalAPI} = require("../../src");
|
||||
|
||||
class TerminalApi {
|
||||
terminalCloudAPI;
|
||||
terminalLocalAPI;
|
||||
|
||||
constructor() {
|
||||
const merchantAccount = "[MERCHANT ACCOUNT]";
|
||||
const xApiKey = "[X_API_KEY]";
|
||||
|
||||
const config = new Config();
|
||||
config.merchantAccount = merchantAccount;
|
||||
config.apiKey = xApiKey; // alternatively you can authenticate with your username + password
|
||||
// config.username = "[USERNAME]"
|
||||
// config.password = "[PASSWORD]"
|
||||
|
||||
|
||||
const client = new Client({config});
|
||||
client.setEnvironment("[LIVE | TEST]");
|
||||
|
||||
this.terminalCloudAPI = new TerminalCloudAPI(client);
|
||||
|
||||
const localConfig = new Config();
|
||||
localConfig.merchantAccount = merchantAccount;
|
||||
localConfig.apiKey = xApiKey; // or username + password
|
||||
localConfig.terminalApiLocalEndpoint = "[PROTOCOL]//[TERMINAL_IP]:[PORT]";
|
||||
|
||||
const localClient = new Client({config: localConfig});
|
||||
this.terminalLocalAPI = new TerminalLocalAPI(localClient);
|
||||
}
|
||||
|
||||
async paymentRequestLocal() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
const securityKey = {
|
||||
keyVersion: 1,
|
||||
adyenCryptoVersion: 1,
|
||||
keyIdentifier: "[CRYPTO_KEY_IDENTIFIER]",
|
||||
passphrase: "[CRYPTO_KEY_PASSPHRASE]"
|
||||
};
|
||||
return this.terminalLocalAPI.request(paymentsRequest, securityKey);
|
||||
}
|
||||
|
||||
paymentRequestSync() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
|
||||
console.log(`Payment [poiId:${paymentsRequest.SaleToPOIRequest.MessageHeader.POIID} serviceId:${paymentsRequest.SaleToPOIRequest.MessageHeader.ServiceID} saleId:${paymentsRequest.SaleToPOIRequest.MessageHeader.SaleID} amount:${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.RequestedAmount} ${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.Currency}]`)
|
||||
|
||||
return this.terminalCloudAPI.sync(paymentsRequest);
|
||||
}
|
||||
|
||||
async paymentRequestAsync() {
|
||||
const paymentsRequest = this.createPaymentRequest();
|
||||
|
||||
console.log(`Payment [poiId:${paymentsRequest.SaleToPOIRequest.MessageHeader.POIID} serviceId:${paymentsRequest.SaleToPOIRequest.MessageHeader.ServiceID} saleId:${paymentsRequest.SaleToPOIRequest.MessageHeader.SaleID} amount:${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.RequestedAmount} ${paymentsRequest.SaleToPOIRequest.PaymentRequest.PaymentTransaction.AmountsReq.Currency}]`);
|
||||
|
||||
const response = await this.terminalCloudAPI.async(paymentsRequest);
|
||||
|
||||
return response === "ok" ? paymentsRequest : undefined;
|
||||
}
|
||||
|
||||
createPaymentRequest() {
|
||||
const saleToPOIRequest = {};
|
||||
|
||||
const messageHeader = this.createMessageHeader("Payment");
|
||||
saleToPOIRequest.MessageHeader = messageHeader;
|
||||
|
||||
const paymentRequest = {};
|
||||
|
||||
const saleData = {};
|
||||
const transactionIdentification = {};
|
||||
transactionIdentification.TransactionID = "[TRANSACTION_ID]";
|
||||
transactionIdentification.TimeStamp = new Date().toISOString();
|
||||
saleData.SaleTransactionID = transactionIdentification;
|
||||
|
||||
const paymentTransation = {};
|
||||
const amountsReq = {};
|
||||
amountsReq.Currency = "EUR";
|
||||
amountsReq.RequestedAmount = 1;
|
||||
paymentTransation.AmountsReq = amountsReq;
|
||||
|
||||
paymentRequest.SaleData = saleData;
|
||||
paymentRequest.PaymentTransaction = paymentTransation;
|
||||
|
||||
saleToPOIRequest.PaymentRequest = paymentRequest;
|
||||
|
||||
const terminalApiRequest = {};
|
||||
terminalApiRequest.SaleToPOIRequest = saleToPOIRequest;
|
||||
|
||||
return terminalApiRequest;
|
||||
}
|
||||
|
||||
createMessageHeader(messageCategoryType) {
|
||||
const id = new Date().getTime() % 1000000000;
|
||||
|
||||
const messageHeader = {};
|
||||
messageHeader.ProtocolVersion = "3.0";
|
||||
messageHeader.MessageClass = "Service";
|
||||
messageHeader.MessageCategory = messageCategoryType;
|
||||
messageHeader.MessageType = "Request";
|
||||
messageHeader.SaleID = id.toString();
|
||||
messageHeader.ServiceID = id.toString();
|
||||
messageHeader.POIID = "[POI_ID]";
|
||||
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
createTransactionStatusRequest(paymentRequest) {
|
||||
const saleToPOIRequest = {};
|
||||
|
||||
const messageHeader = this.createMessageHeader("TransactionStatus");
|
||||
saleToPOIRequest.MessageHeader = messageHeader;
|
||||
|
||||
const transactionStatusRequest = {};
|
||||
const messageReference = {};
|
||||
messageReference.MessageCategory = "Payment";
|
||||
messageReference.SaleID = paymentRequest.SaleToPOIRequest.MessageHeader.SaleID;
|
||||
messageReference.ServiceID = paymentRequest.SaleToPOIRequest.MessageHeader.ServiceID;
|
||||
|
||||
transactionStatusRequest.MessageReference = messageReference;
|
||||
|
||||
saleToPOIRequest.TransactionStatusRequest = transactionStatusRequest;
|
||||
|
||||
const terminalAPIRequest = {};
|
||||
terminalAPIRequest.SaleToPOIRequest = saleToPOIRequest;
|
||||
|
||||
return terminalAPIRequest;
|
||||
}
|
||||
|
||||
transactionStatusRequestSync(terminalAPIRequest) {
|
||||
const transactionStatusRequest = this.createTransactionStatusRequest(terminalAPIRequest);
|
||||
return this.terminalCloudAPI.sync(transactionStatusRequest);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TerminalApi;
|
||||
@@ -11,15 +11,14 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
moduleFileExtensions: [
|
||||
"ts",
|
||||
"js"
|
||||
@@ -27,10 +26,18 @@ module.exports = {
|
||||
coveragePathIgnorePatterns: [
|
||||
"<rootDir>/src/typings"
|
||||
],
|
||||
unmockedModulePathPatterns: [
|
||||
"/dist"
|
||||
],
|
||||
setupFiles: ["<rootDir>config.ts", "dotenv/config"],
|
||||
testMatch: [
|
||||
"**/__tests__/*.ts"
|
||||
]
|
||||
"**/src/__tests__/**/*.spec.ts"
|
||||
],
|
||||
roots: ['<rootDir>/src'],
|
||||
transform: {
|
||||
".ts": "ts-jest"
|
||||
},
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
compiler: "ttypescript",
|
||||
transformIgnorePatterns: ['^.+\\\\.js$']
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
7968
package-lock.json
generated
Normal file
7968
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
64
package.json
64
package.json
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "@adyen/api-library",
|
||||
"version": "1.0.1",
|
||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs and Hosted Payment Pages.",
|
||||
"main": "dist/lib/index.js",
|
||||
"types": "dist/lib/index.d.ts",
|
||||
"module": "dist/lib-esm/index.js",
|
||||
"version": "8.1.1",
|
||||
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=8.1.1"
|
||||
"node": ">=10"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -25,36 +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"
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
"release": "release-it"
|
||||
},
|
||||
"author": "Ricardo Ambrogi",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.5.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.5.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.5.2",
|
||||
"@babel/plugin-transform-runtime": "7.5.0",
|
||||
"@babel/preset-env": "7.5.2",
|
||||
"@babel/preset-typescript": "7.3.3",
|
||||
"@babel/runtime": "7.5.2",
|
||||
"@types/jest": "24.0.15",
|
||||
"@types/node": "11.13.17",
|
||||
"@typescript-eslint/eslint-plugin": "1.11.0",
|
||||
"@typescript-eslint/parser": "1.11.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"eslint": "6.0.1",
|
||||
"coveralls": "3.0.4",
|
||||
"jest": "24.8.0",
|
||||
"ts-loader": "6.0.4",
|
||||
"typescript": "3.5.3",
|
||||
"webpack": "4.35.3",
|
||||
"webpack-cli": "3.3.5"
|
||||
"@types/jest": "26.0.23",
|
||||
"@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": "^10.0.0",
|
||||
"eslint": "6.8.0",
|
||||
"jest": "25.5.4",
|
||||
"jest-ts-auto-mock": "^2.0.0",
|
||||
"kind-of": "^6.0.3",
|
||||
"minimist": ">=1.2.3",
|
||||
"nock": "13.1.0",
|
||||
"release-it": "14.7.0",
|
||||
"ts-auto-mock": "^2.6.5",
|
||||
"ts-jest": "25.5.1",
|
||||
"ts-loader": "8.0.10",
|
||||
"ttypescript": "^1.5.10",
|
||||
"typescript": "3.9.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"https-proxy-agent": "5.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@types/node": "14.0.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
||||
22
sonar-project.properties
Normal file
22
sonar-project.properties
Normal file
@@ -0,0 +1,22 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright Contributors to the ODPi Egeria project.
|
||||
|
||||
# General settings
|
||||
sonar.organization=adyen
|
||||
sonar.projectKey=Adyen_adyen-node-api-library
|
||||
|
||||
# Path to sources
|
||||
#sonar.sources=.
|
||||
sonar.exclusions=src/__mocks__/**/* , src/typings/**/* , src/__tests__/**/*
|
||||
#sonar.inclusions=
|
||||
|
||||
# Path to tests
|
||||
#sonar.tests=
|
||||
#sonar.test.exclusions=
|
||||
#sonar.test.inclusions=
|
||||
|
||||
# Source encoding
|
||||
#sonar.sourceEncoding=UTF-8
|
||||
|
||||
# Exclusions for copy-paste detection
|
||||
#sonar.cpd.exclusions=
|
||||
@@ -11,17 +11,14 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 Client from "../client";
|
||||
import Config from "../config";
|
||||
import HttpURLConnectionClient from "../httpClient/httpURLConnectionClient";
|
||||
import {
|
||||
AmountsReq,
|
||||
MessageCategoryType,
|
||||
@@ -30,91 +27,108 @@ import {
|
||||
MessageType,
|
||||
PaymentRequest,
|
||||
PaymentTransaction,
|
||||
ReversalReasonType,
|
||||
ReversalRequest,
|
||||
SaleData,
|
||||
SaleToPoiRequest,
|
||||
SaleToPOIRequest,
|
||||
TerminalApiRequest,
|
||||
TransactionIdentification,
|
||||
} from "../typings/terminal";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
jest.mock("../httpClient/httpURLConnectionClient");
|
||||
|
||||
interface Options { code: number }
|
||||
export const createMockClientFromResponse = (response: string, { code }: Options = {code: 200}): Client => {
|
||||
const httpURLConnectionClient: HttpURLConnectionClient = new HttpURLConnectionClient();
|
||||
// @ts-ignore
|
||||
httpURLConnectionClient.request.mockImplementation(
|
||||
(endpoint: string, json: string, config: Config, isApiRequired: boolean): Promise<string> => {
|
||||
if (
|
||||
typeof endpoint === "string" &&
|
||||
typeof json === "string" &&
|
||||
config instanceof Config &&
|
||||
(isApiRequired ? typeof isApiRequired === "boolean" : true) &&
|
||||
code >= 200 && code < 300
|
||||
) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new HttpClientException(response, code));
|
||||
}
|
||||
}
|
||||
);
|
||||
TransactionIdentification
|
||||
} from "../typings/terminal/models";
|
||||
|
||||
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.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
config.apiKey = apiKey;
|
||||
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
|
||||
const client: Client = new Client({ config });
|
||||
client.httpClient = httpURLConnectionClient;
|
||||
|
||||
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"
|
||||
}
|
||||
},
|
||||
metadata: {
|
||||
someMetaDataKey1: "YOUR_VALUE",
|
||||
someMetaDataKey2: "YOUR_VALUE"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
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,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.
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
export const paymentSessionError = JSON.stringify({
|
||||
status: 422,
|
||||
export const paymentSessionError = {
|
||||
statusCode: 422,
|
||||
errorCode: "14_012",
|
||||
message: "The provided SDK token could not be parsed.",
|
||||
errorType: "validation",
|
||||
});
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,25 @@
|
||||
export const paymentMethodsError = 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 paymentMethodsError = {
|
||||
errorCode: "901",
|
||||
errorType: "security",
|
||||
message: "Invalid Merchant Account",
|
||||
status: 403,
|
||||
});
|
||||
statusMessage: "Invalid Merchant Account",
|
||||
statusCode: 403,
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
export const paymentDetailsError = JSON.stringify({
|
||||
status: 422,
|
||||
export const paymentDetailsError = {
|
||||
statusCode: 422,
|
||||
errorCode: "101",
|
||||
message: "Invalid card number",
|
||||
errorType: "validation",
|
||||
});
|
||||
};
|
||||
@@ -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,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.
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
export const paymentsError = JSON.stringify({
|
||||
status: 422,
|
||||
statusCode: 422,
|
||||
errorCode: "130",
|
||||
message: "Reference Missing",
|
||||
statusMessage: "Reference Missing",
|
||||
errorType: "validation",
|
||||
});
|
||||
@@ -1,6 +1,25 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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({
|
||||
status: 422,
|
||||
statusCode: 422,
|
||||
errorCode: "14_018",
|
||||
message: "Invalid payload provided",
|
||||
errorType: "validation",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 = JSON.stringify({
|
||||
export const paymentsResultMultibancoSuccess = {
|
||||
additionalData: {
|
||||
"cvcResult": "0",
|
||||
"avsResult": "0",
|
||||
@@ -12,4 +31,4 @@ export const paymentsResultMultibancoSuccess = JSON.stringify({
|
||||
},
|
||||
pspReference: "8111111111111111",
|
||||
resultCode: "Received",
|
||||
});
|
||||
};
|
||||
@@ -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 @@
|
||||
export const disableSuccess = 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 disableSuccess = {
|
||||
response: "[detail-successfully-disabled]",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
export const listRecurringDetailsSuccess = JSON.stringify({
|
||||
creationDate: new Date("2017-03-01T11:53:11+01:00"),
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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: [
|
||||
{
|
||||
additionalData: {
|
||||
@@ -16,7 +35,7 @@ export const listRecurringDetailsSuccess = JSON.stringify({
|
||||
contractTypes: [
|
||||
"ONECLICK",
|
||||
],
|
||||
creationDate: new Date("2017-03-07T09:43:33+01:00"),
|
||||
creationDate: "2017-03-01T10:53:11.000",
|
||||
firstPspReference: "8524888762135795",
|
||||
paymentMethodVariant: "visa",
|
||||
recurringDetailReference: "recurringReference",
|
||||
@@ -34,7 +53,7 @@ export const listRecurringDetailsSuccess = JSON.stringify({
|
||||
contractTypes: [
|
||||
"RECURRING",
|
||||
],
|
||||
creationDate: new Date("2017-10-10T08:50:02+02:00"),
|
||||
creationDate: "2017-03-01T10:53:11.000",
|
||||
firstPspReference: "8515076181707110",
|
||||
paymentMethodVariant: "paypal",
|
||||
recurringDetailReference: "8315076181982020",
|
||||
@@ -49,4 +68,4 @@ export const listRecurringDetailsSuccess = JSON.stringify({
|
||||
variant: "paypal",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
28
src/__mocks__/recurring/notifyShopperSuccess.ts
Normal file
28
src/__mocks__/recurring/notifyShopperSuccess.ts
Normal file
@@ -0,0 +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.
|
||||
*/
|
||||
|
||||
export const notifyShopperSuccess = {
|
||||
"message": "Request Processed Successfully",
|
||||
"resultCode": "Success",
|
||||
"shopperNotificationReference": "9915003646742627",
|
||||
"storedPaymentMethodId": "8415995487234100",
|
||||
"pspReference": "9915003646742627",
|
||||
"reference": "Example reference",
|
||||
"displayedReference": "Example displayed reference"
|
||||
};
|
||||
@@ -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,38 @@
|
||||
export const localRes = 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",
|
||||
MessageClass: "Service",
|
||||
MessageType: "Response",
|
||||
POIID: "P400Plus-275039202",
|
||||
ProtocolVersion: "3.0",
|
||||
SaleID: "325488592",
|
||||
ServiceID: "325488592"
|
||||
},
|
||||
PaymentResponse: {}
|
||||
}
|
||||
};
|
||||
|
||||
export const localEncRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
@@ -104,4 +138,112 @@ export const localRes = JSON.stringify({
|
||||
Nonce: "9iiJMpzKfYs3106ozIKNFQ==",
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const wrongEncRes = {
|
||||
SaleToPOIResponse: {
|
||||
MessageHeader: {
|
||||
MessageCategory: "Payment",
|
||||
MessageClass: "Service",
|
||||
MessageType: "Response",
|
||||
POIID: "P400Plus-275039202",
|
||||
ProtocolVersion: "3.0",
|
||||
SaleID: "325488592",
|
||||
ServiceID: "325488592",
|
||||
},
|
||||
NexoBlob: `WRONG-LeXBRLw6yBzfG7gxinRqVqJB8RKvGRKK+vFmSwSzMtbb3ziiRBVAjgcdTHMoDUewrr56wIqVa1YWw/WexEm3XHbFxxE5in
|
||||
jBl+aXGbgGPEoByEbIYqY3gLOswp+VaDjqH6cocDNc482s+v1VvJOCCaOKqmKS28fqmKdq42NfdIS5vVqZ5ydUTnOMhiPWXkCYoDjbhaooLpeq/
|
||||
NDb7ZG9eu2KRfjLBWY0ohVUR7Mm8vD2CjVR4nFX7oyjKMvlkx7o3+ofo/EZJDLzuyxFvSi5sXznt5FMQC3YrtjF0kgU3XSNMfh4xm7rFVr8W0gE
|
||||
LPVnufSjbty3XlZw5w7nrp8FlHT79vnoo835cH2CQvfKteyxo1TMV2CIcalQx4304UKb485qHUh6jcD/vHemAhCnemufJNcQzkDHMAFh8jHkzsr
|
||||
9AweaRHjICxIWo+6neEzZpBvkztVKZcdIVV6YOb9cNklaHvxzfHPTfVA6GtHkvHd2a+SQRJFQJPxuCBX0J/wR6s+yDWZUjISPXwsgTp1xbq8egT
|
||||
tHZFniNduBuzB785UoR06Q66gv22nCetjrAz9gQehyU0jxeyb9D9+MmUCMPt7dMIseoacCWCk1C8naj1v4hdIjRimsgp4G9cs6csiqOwFcxYV0T
|
||||
Y0zKyDaUGoDd6nOajHQP9UkYrAMhYGPd6CwGTA9D/ERyAayt/SRT8Toq2NsJ1WX7O7JVcOVk1p40VPhk8f4IbL24TV0MyKu3Ms+dpjqbC4jecGK
|
||||
6RtShn6oDWfsmsg9AjLa1N8WYcyeiy9fCS6WVpC8aTGSlChcwQLsFc0SurFiyGYVOA/kterCUqrmguE4bVEX0qYHzTVWDsTzR2Kp6qO/Bf1NGwX
|
||||
silXNGkl645Ofn1RcpBfJybA14xoRtb3NUHTSiFd0iO1OTO0ntPd7S+9JoZvdgvYuHPhsSV2+w+yb80s/iquDkXkfLhCl06c/jthJEzOtxHbU93
|
||||
2cVQe/ZTIiqpZFVwl1iuWG14/MPBzZ/f45tSO8iSxGG7MBouWs2k5OlhaSysSA1i2rHiwglth9UIDngzOvaGX7HsfPExyKpDJmNxPdGiCaAfwbd
|
||||
ZBmVmBVf2gtaJw4Qqqwqsg6DjjkdrEzKnS3XsFRtW27c18QkKv+ZK5NDm8HbPeCDLhpFeo95BGI5isXRR/Ypv8DBwXWGRZlDY3dXFx0gnBfg9gY
|
||||
h22TQhsNg4FJPGFie/OkjKX0uwX74Ejg4ewbYRzx67iIFlz5trxeIVLhfh7cZxUkoFJ5rObKUpsw350L5ovH0GMqg8IKeo78X5JtwnTGX9Py900
|
||||
UlFNHdurXq3NuF1iU1O0NHqarQaWW9FS/BVR766OxChhKSQnbp28l36rWIkjwFh1PRskxx7OEIaJM28MbZ39eE8Ll8qrn+boH7vXLi0pP4eLJoO
|
||||
Cwo5PyRZs/lqAfGTNXlVpfYn4TBWtNxwSn/XV3xc3E7B80EUN+tDHKPtM3hmTwVSgIv5l+tyWhVaRqedOnthGjNJyIDPMk+g5A2LN/HBlUAEBoB
|
||||
5IS3TMtLJOsX86BSAQXyPTlFxVKsoed6MZkJAAofuKjdYWHyto2YwRwFGTifXThysohUOymxjBB4BFbRdjmw4eTKKCNobZc85LIutt7cD96CORz
|
||||
PjNnCy80GGO0a0QCZugi/q5nlFL4dpMzAgIFsmgOWL2dV6kZICm7N9hzKwI1q/72PfQNNsV5ERgIm1eSOKajV+en5mRtCHcpDxPUMSsXxGaHS4I
|
||||
VUwu6tj4sxzmSzgD0/hsRh+0kVprQBE7Lkxa5ylAOQ1TlG9fgKIDXTAmiB/23rsbvW9wHvjKRJcjhX8diaoOX22liYIIk6HNflDLCGJX09Ac52x
|
||||
j32VWT1niPTUMIcieo5fN4SfcD7DcZhShmAnToZxxEnRGq+sy7sxn5mh64o6ZGD++FFUryAp4QkbIs8oAU8/mDTc2YG18OuCE6+b70E5+lZwMLh
|
||||
U6iMhCndxAjHWexJZzO2DwRlJ9QBwOcLtOn+PL1Siruej761vrK6Et1ruhn0ddH8N/tH6CrKAL8o6d8Y/QNBLRTKJLWbka3MORTdNUniKJ8TFrr
|
||||
AcGP0NOsnTNMzU3sQDLHj7epwBFw/STVSu0f6YH/CDMZ7dhPkHM4WPfyzA5rBLfLw3EJ4wZh7l/KSA5xqS3rqKM/pJqp1tY8lQBCpv/C3Lc7arV
|
||||
0Qc+eb2vX4jVmjDzg+jtXQPwdsNqLbd41qnCSIdc4x8A3X84Li58byHDX4C5T/wRotZtC5HNWOeI47QONm4Yz/KuGBC5SseLQC+SwYACHPejyL2
|
||||
I465VyxbIZg6s7sK93mndc4u5QoSGbCeHGpmeWn/z6wX+PZV2eglnMNqPOoT9t/TvQrN5kiiPztZp/qTltmNK6eZZdubPFMxD92zFip2moLevdd
|
||||
arzV3rHsre5HRS3Fn/vqVxjdrtjEOfd+KXbNYhlZ2UidmsVilS1DX035HeoftQAP8+MGlGAEHcDERgdHWhHM83trDndRsF/mtx5gsH+VBHz6R2N
|
||||
UnXdzOVGf++6R/qli7D8N/KE1u7O6wV3U9O9wQAtn7Lw7Eg2hf634VcBftALmeyP0mAPoEGeo6264YZdeJbLcbs+Wqik8iyWsF7y5jrCah6vHNi
|
||||
2d9EFCATFFSJI24e/08n/nw8k7nh+6K/rgdg/ja0cLXQ4gUs8ewY3g48RjgaiLDKSMV1tzSJdxxvdgGbsSvdgbxkG3CXc2T9kJwWoSeGs8hdBNm
|
||||
B/nhqeCAB2obk/qp+ndMDVsg/1914khS6DIu/lqinnuJ8Rdemxrd7P/qXIZUN8acoJeCrqhCfxPQQlp7HW71JHdqaFRym0W3VYepoayRz85XtuL
|
||||
vAS8/jqxFIUpCRp3q5KSUY5LFMo75a/uvirhVH/h0bAYxOm42Y8er0dxhR7s/sZASIW3MGxHgYCQHneVqHBavSld9PkJvtgQa7mbMKHm9FAw0dg
|
||||
Le0ZXFOby3CWkzWOcHwOIVFvXuFLf3fjGZlbuFQ4aly/Xu0bnhfXFT0c3fcLb5yeTJWUtsLLLQVAqe/fkykYI4XCktkjmrfODfpXl5RTOUdRSYA
|
||||
CMNn/Wc6LGQk2yPT4b+GJvaIpzAo7tgXrK8EwGAH/xNeShDzZ/dxZsP2yfisccT2n/VxkpL4Usrrogwg1LoSLZljvADaLotIToFXxvSU2ySVVx8
|
||||
ctbXU8R2wd6s3N/wHQv/DRuGc7CWC7YUCVLL2xDgPyjkskc0vRSCB9KZBd7QFlt+wO621mM+YcrahNlggiuAsFnWQMzezQJJKkUfs1b/zT5dbtc
|
||||
npvUpA9ZK9chHMUfgVHu8OzH4xKiCxzX6WqnKNMJDbKeW7IDK6O5so5irlyFnoakT5JsafyxQINtvVViA/3xo7w8Xc3KUoiidF7xLQSj8ZG3PhF
|
||||
TyNi545ab5X4FuiAZoP6EDS9+fnB7c1HQlR8b5nw90tcvq2Jkc/j3QTRmUWqtaW/O6+rEQGmuGVLYdXPvVQpyyoex6p9ePo8o9tmTp8w9KXCaRv
|
||||
AR9GcRvQQgeJ04LFp8tEEkkSMcJtDd1ha8V+X0YhM1VBK69qGbRZh+ulXKxVUr8hy3A7w5+ia3IaIwLt3EABrsurgkxicJsma43u0A8bBKMDdaI
|
||||
y9MFHIv6Jx7s48eKafmxORCjVWLQzWDPiNy+Feqbbk2C4FJqnMkfpbTmE/t2Af1LcyhP0xEpbPVqcmkWJiXvyxiNQf0ozpjTXNYlHGopORbqolG
|
||||
WU+hVEeiyneuNI0LFyMveaPB7/fuXuo3kUYwjH5sEklU6kNzirF8ZJzXSVdvZ3ZWLywpJoQScLRgcXV/PKMCuwbkuTE8SuHggtBLuLTN+c+lmLZ
|
||||
pqXVn8dS3faATyug8itRdDmRhCFHYOM+907K+P9G4kcLbYeaZbOhW75Uzn1gwL3cMphc50OFk7E/pRRjB9IuouX3aLSrIjz18ZTf+2oiu1VW/Ah
|
||||
lMhdfcLrlDROT6Einsx3sHRipHNGa+LnwBYnF268t7klkljMFuS0iUCMZL1d+5tCy1PVrJqb9598l10Dyxcnnol2Vo+iQ6MIAt1v/HLslmUyhoH
|
||||
mPaXUZe7m5aHLM8XOd7CjVSTl6zly+ZvA7Fhvtv1ymU9gZfay5W7DiQTqFnoSa+O8hlHzpPn7Kw4WGXF+KpSZgvElt1B4FCUBmAuGq6D6QPrn6d
|
||||
EjponWYmV7h0DIApyRRpfbIFN9m662L/x6vOKgwe1Fj1zkEgQQtuxmfBzW/hbogHCuH3gkkfviAT9XNR9qhw38nTV9F/yaCn6X2t0QIRjRSVc6N
|
||||
4cy4V2uN+SYBSkgcX0P5J0eXsWuZgPDrF8fom/oKG7xWxLTvFpsOLvWNG9pySJxqMKJYVwrPM59gwrhvaSR40p4JfSYwvd1UVGZPzh5icuhNWj+
|
||||
W2M3vsXbhiy3B7cxzX8vcF45v2CqTRYz6WPw4U9rXgnXkFPZJo3f4g9WDf0LnlrZ0/hu/2RyBnKDkgdDdwUdzeEGToOnU8SOL/f/T9eBGnm7RWJ
|
||||
DvI0N7Bl7q2ovocqfr9+DHZHSOnoVHVwSIhJFwvTGn1pRPgMb8lVWu1rwIKNObQmYGPuKpv3WvPsQfFvwZGbK1uCIoXjId4OSvIOcC7tknKBUsx
|
||||
hI/eARn5m57WBR/O114F41CI7mRepeSvm/2NGx8u0V7VOdkMC92lEoi+cKNY+oKamFG9LMAiE9Y6niJ9XECRAzNG2lVnbvlcHrb9jAU1WtPWL05
|
||||
8I235LmfyhK/Qwp2ZE3EG4cie40AMO3LYhdEzGTuKlPkCAvrpaKs5skZ6b6Vn08Y01+XFGR6Ie9lOmvFF2VjWNdM4hIz/AQz0C6jUNDqPAkySr1
|
||||
OkCTznd+Eo2ol8G1HUb9JNYQs1GOE1OWO7+Cwy1oSvVlremvAAX1FGv8+n/1TMQKXfeH809gejMyzBio/9WOL4X5TBN0WILU2w4B1cU3ERLtzxC
|
||||
2zVEWPttb6HfxiMPw5kTd6rW4WjC1epwbUqz25P2RxBe0jQ37PSMpaUN/ZmEIYJ0yU6sqgl+xPBkfFTYEL6Vy2zlw/MgxogKzevgjiTh418v4F+
|
||||
ips65TdyKlOlo63h07kPlcpQw9wy+75xYlIRs2sTjvpdsvREzh2elMIP1qh2ezBxH3EIJyMQqTnptNqLKwGQCFs0Y06Fj6EQJrPyNfUW3kgfNB9
|
||||
T8nGJrQ2vly3MKvnods26WUdOSdtHNVd8P+7R+jj3QU/YmUig1C+oddspbd7oW526TCAE4qet60dqzMnGjBgdssMOHYz32WDdQ5yZwpkEYdSbAX
|
||||
6JKAN21n4NlbJKrfdb8qQCWYVvJ4ddGvPoVRgoMHBiIJymAwi4NyFiB6DsuFZZPVoJJxHhSNUHV+qoZzKifA8QxXKngv+RBrw2aGSBxpbVDWpo/
|
||||
nEOq4SHOly/OfxfW/z2FavkuCJahtrdwRyBYuOnJUwzbvsRICiZsJ8VvUnqy05b0CB8a3W3bSeR8uL4WFBuE4VS2vn1RxTR9I9fn/dpfzJpkNyg
|
||||
1irLrqyhWSuX4RzqS7pJnGUNj3bgZSGB9Ev7pxuvGKPPLK3Yb1Yt5IHZafqQxlPwStGmh7x5rMFe8q6cLVuq2ALwloVg0FFmST/uXkWSUJF3LRa
|
||||
olrhooxRGBUbQF0yOy8l1JFD5REfIoWzNTdM1d/lIm5m3b64aVEcU0Boq0wQ1DUxmGkaA/1ih874rhv5G954zSwS5RDYSYzPGRVNbtVcO7C8VnE
|
||||
U8vtbtEQv9ucM/RBBeCgaAGW9VuOlNk2A7KoBWSTYITmfH6WURrKv74U5wfX03frx9RKJBFf3gVU7uofnbKD8zfqCYrFvQj+vauHF4/3nWJa1ZL
|
||||
1RGAXML5gq1265S06CjvsM5dwFgGl0kw3Y2gIiulGPTZhh+zKvMPXUCjcdfCyDbd5QpRBikJEaIMlwvlyH7zCcGsbzViVTU5DBiOL9F8p5lvNI8
|
||||
disdEgDeL58n0YhLPd/vcndRcTmEwutK71ynu9fyRJrbAKGdFWbgGpOoOVsBeecn+/QtqD4Psk10R+9SMyj6hiQSYm/FkObmL5YrqZJSqjYEP59
|
||||
Lzc8Ms+5wv2U84JduUC0Is1HP2JsVNH8gn4wsj5zpSfxOHHIQZYcX/0FNXi1BOoF0UBo7avQgOCskvvyDLAwZRp9HGo71hASzxki0KgUj8r2Rpb
|
||||
e7svdD5dThLdzTQ5eTfLihUAuPSz2xaScYdtmd/vzJZS/AdeCXB+xD3xO+iZum4HkfQQF71auHLeBxjwU6qSqoJlB21yuzuM7nx1wk9/1hAu8W2
|
||||
RjdHrlKF3ycaG7QxZxbe+psb1lqb28QqAni/fc9RXWRVYitW6v4WPTUrNDswrOeVv0op8SKJaOPPYMERS/ujEWN+r6sAtZ5m5VB7VhdREkEF2HB
|
||||
AqIW8kocsBajpEZb3kdiR2vwasFRmoMV6oUYgIEhxQkXqNatcjdJuR3JcrkjN0ZdpZw5cMVaBYFCFq0B9bawas48Jag7WdbuiHc7PPqh76ZenGp
|
||||
yD3HCY8wsTq1kX81fEImZUXH25dYPQYKoLS6eGtNXWZKj4vOuig88zJF/gaZQv72Sv1Aimk0ZyRDVtOFsbzcjGdjER2UNlMd4jCLoT+qG0f6z6E
|
||||
ufS111BJhGlL+HPyEMtnx2ingFUVjixOo5ynGrbNuKXOTLFVbF8vzQKrjyVQLkshaYEP/wla6bVBp/jLFC5+k5FioyvJbSxDsV2LxpMSpqCJUUl
|
||||
BORwMoQezSjSObmy2g5U92U2p5eGALCvpw9Jyp7+qKOVeOUYDV4FNltdslsv9XpQj1uR3OUSG27ZSVZRIjG4gXjkA/xetsFCqP5fGbH4nsSb3/u
|
||||
tQO8FAw5jBm8qwFPArI15NlCrerAXs3ASwMzyFQGQR0njQQJkWMdqNJ/Jt2gRftnawu65WhuUQZfUY6EdTHpOWdB1LgEEctrpmA6PI+eXofWIrD
|
||||
GqInurgMx1yAcfzhI93kgMlhluKrGmhvHiiGWL79d1NhgAGLlxhAEC8ukZZc8BBspPVjoQC76ApiQeKJWJ+tIJgTn0M3IG0kRD8tAldVtuecJpR
|
||||
OTnyT/7zGSga3oPYD89PkeUYt5Hn9i6+jyd28d3c0tNcrMVR7bk0p0WMeAqMnCAQpiKB6Witpp1WioQMUH5n/idtigb6rlTSlBPnaonPDigdlqM
|
||||
k/FamqbacblZjDqylf717Ba+Cqg0ijCKC3QghfnxnZMic7bm1mEP8gKpfLvPj/K4GOC1cYRUGyi+sRIxziI+2gAEfjoZ8ACHm09tMdS2VOB2ps/
|
||||
HN5dVt2OHRmArhlbRl+eCyakF/AiP+DkSs+tXDNJQrjKCNpumkbKodi51AWP8MXww6gQulxwBgE4V6L1TAadzCAUOPlJEPcVssf9m2cn5htMnIX
|
||||
vnWN8FKh3mrbOQdLHX0QRxT64qQdcOpNtdDS5DXFG5QtFvCnDSPTQPa38t39mUzEAAtPkZnTJp1eF4fGOILgsceW084SNMUjuVrU6yCe9LjT6GJ
|
||||
V3BGFl1ByDV5Rs2vuq/g7oIdf7E/stskOS//6ypWAQ2Yutyw5aHoNYeRf4eWf+dE0hVbzmCcTOO8rZmkvpYxiHf3YplEPuAe86ZSrCBMiAF2gMO
|
||||
ffWvEEELhFU4BlSNIkLbBZz6s9rHT9X/MtuQb9UVqGoawWPgaSgCuskgTQwioBr3p2p8shGDSEOdkkdfnmPvkM/bvXv5/yxQDKcY4dBDZHnwNNB
|
||||
7iaQlBShqRKTntjF5hCP9m0SsbCThV8JCRveLvgKffC2KeW5RAJgRD8aMso9BkewEvBj9tdss9thUj/lGG+b/rY6rzQvO6dHdeUrCOlURa4vCiJ
|
||||
CZIBEJPrC7zs/+vm/lH14WKe7vl1I7c6bygDdjpVXe0cLYkrjuMl2EqAKId16MeznAodNwAVWiCq5J0AYJ6GNWTVNnqOl1ftUFWeMkcS8w/787O
|
||||
nNaIVk5xrHbZz6J7GfqnmKW28ZuLammVGERWePxc7aIYE6Wd0bnZK3NVuFkbZHMxRrTHnhHT28dunqjfBuGPPDaBsWDD+xqq5OD1Hlg3SHOcIfK
|
||||
x2UWJ9lB8/xi+0JUYHJ6Q3HNIB/jLIOHR+TNhnjF8FPCsxxzEOU8QYGWPCpl5P+mvCYOR5M/mf0sCLoIEX1n+CymLqMFP9XqYmtGlKtZlW/kQc6
|
||||
8c/GKLOXPZtxF2VngIxHmE8uytuOVL4z8Y1EtXNHuvaCJHoK6UW12/Emu0L1GBo3ASv1xIi2PR1+ZFcco3oZRcL48h7/32tm9FPSf+6yFrXjoGz
|
||||
jTIUakuk+Id02wwbpYZN1zNkf8nXI3ACnVJfoaNseYXheGwPOcwIjJl+eYbQ8V0QJqzKFnBAbbctx0Vw8RBRFQMTH22b6n0UAJ7YqknnTzPxiEW
|
||||
/h3VjcD74Khb5Hie2+C42MWcADzuUlg5jWTjsWfgqWkU1P+GtT9iJwfL346E9CU6u6FQNXSi7G1z88nTbYxN+hfyOA3iJE/hc9swDVCUYL8ZyQe
|
||||
4jL3NwgAgrwVyY7bYkpaNDxCa+qpow5+uAZdoub5skT4fKrVc6affNBRIKWGQunPYam4kNUwwV7P9FQPn3YgZ7DYF/EGo6hMea8pOW/ac0Fb3nG
|
||||
+tvIqdFosDuD2NNgQGL8Qu5cnJzPLC/h2xS0JSdilWIkhZ3O5ec9A3ijeTmmzUHKYUA4j3ERISQCmD04Diyge1W19Olrsl4Z/V7/rq5jkQiG0ZK
|
||||
wa0lgLsJYZwIuG82xMzJjebzc6KrjrmyC1449zeBBWDxd4GumU5NuUzuN6jsAFdefTU2TAz5DOS0lotOOCRdqW45yFYwMLDyFWXmYgXbvHNrH6p
|
||||
KZsqE7EfwMP1ErmZOlncL4PzuT521F1Ui+2dEob9RK0g1mCuYSjHf0RMgjLSmVCiqwFoS882xvvlCqKlbnaDHlIdFBztwCr+pFj3r59b7p+1BmL
|
||||
k1BRWBbIqlqCEVJm0oqkL5y4H28FWWwZxlFN9zbl73gQbPVHX3dhoPnjoxwYxgCaHR3OrS4uri6DLPykGNJePHWdKOn9is8ueMJmocH35eIYCUO
|
||||
IAFEey5GfFAFfbvzV0m6BUmL1IBDngs5uIUrcpZ6FTAYgpYcIfvjJcEv7lMERQgyCXM3/RCOJE61oaDssneYU18TJYsHI8b7zopMLyTDb/RfuxM
|
||||
A1L5CVRKZ4niiU07GGjnSDy/W6n9nmmXNC129ZsP+M7+W+kJzp+laHq/OHWeDUhJ9OiIqhG8TjMVgeM1j00X8Ve0ASHwC/Rb0RlOAqOPpT7rqhn
|
||||
FS4QDeLgLYVLtlxlLoTu2VXkpTchHxbg55oKFaAyg7ULzovZ7b8YfEEnvNLbObf9KYqKGwNZGVzT7ZXT/GCUsD62iiL9ey/J1bVevmz2QRQ3cpG
|
||||
NtMy602cc73PVofnvhRkX3HBJrrx24KKAJdf8Jh/KlvpiFrwmfsiFFIBV/HpJnXpfO78iO6DvxOYopU2O6zFpok6UiDUF5j2x/p3e0A/hO/jmpJ
|
||||
wfTX9+q35vzFfexggzH0KA7aG8i5DaE+E2qrgras6dpwRWmpzVyX1hNbV8ZENNnTz`,
|
||||
SecurityTrailer: {
|
||||
AdyenCryptoVersion: 1,
|
||||
Hmac: "l+5/pYiAbC0V9Xx78ELNDcLMaqTlqx2OyGha37i/g5g=",
|
||||
KeyIdentifier: "CryptoKeyIdentifier12345",
|
||||
KeyVersion: 1,
|
||||
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,94 +11,97 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import BinLookup from "../service/binLookup";
|
||||
import {CostEstimateRequest, ThreeDSAvailabilityRequest, ThreeDSAvailabilityResponse} from "../typings/binLookup";
|
||||
import nock from "nock";
|
||||
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
|
||||
};
|
||||
|
||||
describe("Bin Lookup", function (): void {
|
||||
it("should succeed on get 3ds availability", async function (): Promise<void> {
|
||||
const client = createMockClientFromResponse(JSON.stringify(threeDSAvailabilitySuccess));
|
||||
const binLookup = new BinLookup(client);
|
||||
let client: Client;
|
||||
let binLookup: BinLookup;
|
||||
let scope: nock.Scope;
|
||||
|
||||
const threeDSAvailabilityRequest: ThreeDSAvailabilityRequest = {
|
||||
merchantAccount: client.config.merchantAccount,
|
||||
beforeEach((): void => {
|
||||
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 {
|
||||
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: process.env.ADYEN_MERCHANT!,
|
||||
brands: ["randomBrand"],
|
||||
cardNumber: "4111111111111111"
|
||||
};
|
||||
|
||||
const {
|
||||
dsPublicKeys,
|
||||
threeDS2CardRangeDetails,
|
||||
threeDS1Supported
|
||||
}: ThreeDSAvailabilityResponse = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
||||
expect(dsPublicKeys[0].brand).toEqual("visa");
|
||||
expect(threeDS2CardRangeDetails[0].brandCode).toEqual("visa");
|
||||
expect(threeDS1Supported).toEqual(true);
|
||||
scope.post("/get3dsAvailability")
|
||||
.reply(200, threeDSAvailabilitySuccess);
|
||||
|
||||
const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
||||
|
||||
expect(response).toEqual<IBinLookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
|
||||
});
|
||||
|
||||
it("should have invalid merchant", async function (): Promise<void> {
|
||||
const client = createMockClientFromResponse(JSON.stringify({
|
||||
status: 403,
|
||||
errorCode: "901",
|
||||
message: "Invalid Merchant Account",
|
||||
errorType: "security"
|
||||
}), {code: 403});
|
||||
const binLookup = new BinLookup(client);
|
||||
|
||||
const threeDSAvailabilityRequest: ThreeDSAvailabilityRequest = {
|
||||
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",
|
||||
brands: []
|
||||
};
|
||||
|
||||
scope.post("/get3dsAvailability")
|
||||
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
|
||||
|
||||
try {
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest);
|
||||
fail("Expected request to fail");
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toEqual(403);
|
||||
expect(JSON.parse(e.message).errorCode).toEqual("901");
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it("should succeed on get cost estimate", async function (): Promise<void> {
|
||||
const client = createMockClientFromResponse(JSON.stringify({
|
||||
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"
|
||||
}));
|
||||
const binLookup = new BinLookup(client);
|
||||
const costEstimateRequest: CostEstimateRequest = {
|
||||
};
|
||||
const costEstimateRequest: IBinLookup.CostEstimateRequest = {
|
||||
amount: { currency: "EUR", value: 1000 },
|
||||
assumptions: {
|
||||
assumeLevel3Data: true,
|
||||
assume3DSecureAuthenticated: true
|
||||
},
|
||||
cardNumber: "411111111111",
|
||||
merchantAccount: client.config.merchantAccount,
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
merchantDetails: {
|
||||
countryCode: "NL",
|
||||
mcc: "7411",
|
||||
@@ -107,10 +110,11 @@ describe("Bin Lookup", function (): void {
|
||||
shopperInteraction: "Ecommerce"
|
||||
};
|
||||
|
||||
const {cardBin, resultCode, surchargeType} = await binLookup.getCostEstimate(costEstimateRequest);
|
||||
scope.post("/getCostEstimate")
|
||||
.reply(200, expected);
|
||||
|
||||
expect(cardBin.summary).toEqual("1111");
|
||||
expect(resultCode).toEqual("Unsupported");
|
||||
expect(surchargeType).toEqual("ZERO");
|
||||
const response = await binLookup.getCostEstimate(costEstimateRequest);
|
||||
|
||||
expect(response).toEqual(expected);
|
||||
});
|
||||
});
|
||||
106
src/__tests__/checkServerIdentity.spec.ts
Normal file
106
src/__tests__/checkServerIdentity.spec.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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";
|
||||
|
||||
const createMockedCertificate = (CN: string): PeerCertificate => ({
|
||||
subjectaltname: "Adyen B.V",
|
||||
infoAccess: {mock: ["any"]},
|
||||
subject:
|
||||
{
|
||||
C: "AB",
|
||||
ST: "AB",
|
||||
L: "City",
|
||||
O: "Company Name",
|
||||
OU: "Mocked Value",
|
||||
CN,
|
||||
},
|
||||
issuer:
|
||||
{
|
||||
C: "AB",
|
||||
ST: "AB",
|
||||
L: "City",
|
||||
O: "Issuer Name",
|
||||
OU: "Issuer",
|
||||
CN: "Issuer CN",
|
||||
},
|
||||
modulus: "ABC123",
|
||||
exponent: "01010101",
|
||||
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")
|
||||
});
|
||||
|
||||
describe("Certificate Server Identiy", function () {
|
||||
test.each([
|
||||
["legacy-terminal-certificate", "live"],
|
||||
["legacy-terminal-certificate", "test"],
|
||||
["P400-3123123", "live"],
|
||||
["P400-3123123", "test"],
|
||||
["MODEL-SN", "live"],
|
||||
["MODEL-SN", "test"],
|
||||
])("it should be valid: %s.%s", (prefix, environment) => {
|
||||
const cn = `${prefix}.${environment}.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate)).toBeUndefined();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"INVALID.adyen.com",
|
||||
"terminal.INVALID.com",
|
||||
"terminal.adyen.org",
|
||||
"google.com",
|
||||
"",
|
||||
])("it should fail because invalid domain: %s", (domain) => {
|
||||
const cn = `P400-123123.live.${domain}`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"liive", "teest", "lve", "tst", "ANY", "invalid",
|
||||
])("it should fail because invalid environment: %s", (environment) => {
|
||||
const cn = `P400-123123.${environment}.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
test.each([
|
||||
"legacyy-terminal-certificate", "legacy-terminaal-certificate",
|
||||
"legacy-terminal-certificatee", "P400-", "-123123", "P400--123123", "P400123123",
|
||||
"ANY-ANY-ANY", "ANY", ""
|
||||
])("it should fail because invalid prefix: %s", (prefix) => {
|
||||
const cn = `${prefix}.test.terminal.adyen.com`;
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should fail if no first part on CN", function () {
|
||||
const cn = "live.terminal.adyen.com";
|
||||
const mockedCertificate = createMockedCertificate(cn);
|
||||
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -11,37 +11,45 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import {paymentMethodsError} from "../__mocks__/checkout/paymentmethodsErrorForbidden403";
|
||||
import nock from "nock";
|
||||
import {createClient} from "../__mocks__/base";
|
||||
import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess";
|
||||
import {paymentsError} from "../__mocks__/checkout/paymentsErrorInvalidData422";
|
||||
import {paymentsSuccess} from "../__mocks__/checkout/paymentsSuccess";
|
||||
import {paymentDetailsError} from "../__mocks__/checkout/paymentsDetailsErrorInvalidData422";
|
||||
import {paymentDetailsSuccess} from "../__mocks__/checkout/paymentsDetailsSuccess";
|
||||
import {paymentSessionError} from "../__mocks__/checkout/paymentSessionErrorInvalidData422";
|
||||
import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess";
|
||||
import {paymentsResultError} from "../__mocks__/checkout/paymentsResultErrorInvalidDataPayload422";
|
||||
import {originKeysSuccess} from "../__mocks__/checkout/originkeysSuccess";
|
||||
import {paymentsResultMultibancoSuccess} from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
|
||||
import {paymentsResultSuccess} from "../__mocks__/checkout/paymentsResultSucess";
|
||||
import Client from "../client";
|
||||
import { TYPE_SCHEME } from "../typings/constants/apiConstants";
|
||||
import Checkout from "../service/checkout";
|
||||
import Checkout from "../services/checkout";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import {
|
||||
Amount,
|
||||
CheckoutBalanceCheckRequest,
|
||||
CheckoutBalanceCheckResponse,
|
||||
CheckoutCancelOrderResponse,
|
||||
CheckoutCreateOrderRequest,
|
||||
CheckoutCreateOrderResponse,
|
||||
CheckoutUtilityRequest,
|
||||
CreatePaymentLinkRequest,
|
||||
DetailsRequest,
|
||||
PaymentLinkResource,
|
||||
PaymentMethodsRequest,
|
||||
PaymentRequest,
|
||||
PaymentResponse,
|
||||
PaymentSetupRequest, PaymentVerificationRequest
|
||||
} from "../typings/checkout";
|
||||
PaymentSetupRequest,
|
||||
PaymentVerificationRequest,
|
||||
} from "../typings/checkout/models";
|
||||
|
||||
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): Amount {
|
||||
return {
|
||||
@@ -60,22 +68,23 @@ function createPaymentsDetailsRequest(): DetailsRequest {
|
||||
};
|
||||
}
|
||||
|
||||
function createPaymentsCheckoutRequest(): PaymentRequest {
|
||||
export function createPaymentsCheckoutRequest(): PaymentRequest {
|
||||
const paymentMethodDetails = {
|
||||
cvc: "737",
|
||||
expiryMonth: "10",
|
||||
expiryYear: "2018",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111",
|
||||
type: TYPE_SCHEME,
|
||||
type: "scheme",
|
||||
encryptedCardNumber: "test_4111111111111111",
|
||||
encryptedExpiryMonth: "test_03",
|
||||
encryptedExpiryYear: "test_2030",
|
||||
encryptedSecurityCode: "test_737"
|
||||
};
|
||||
|
||||
return {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount: "MagentoMerchantTest",
|
||||
merchantAccount,
|
||||
paymentMethod: paymentMethodDetails,
|
||||
reference: "Your order number",
|
||||
reference,
|
||||
returnUrl: "https://your-company.com/...",
|
||||
shopperReference: "shopperReference",
|
||||
storePaymentMethod: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,83 +92,171 @@ function createPaymentSessionRequest(): PaymentSetupRequest {
|
||||
return {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
countryCode: "NL",
|
||||
merchantAccount: "MagentoMerchantTest",
|
||||
reference: "Your order number",
|
||||
merchantAccount,
|
||||
reference,
|
||||
returnUrl: "https://your-company.com/...",
|
||||
channel: PaymentSetupRequest.ChannelEnum.Web,
|
||||
sdkVersion: "3.7.0"
|
||||
};
|
||||
}
|
||||
function getPaymentLinkSuccess(expiresAt: string): PaymentLinkResource {
|
||||
return {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
expiresAt,
|
||||
reference,
|
||||
url: "paymentLinkResponse.url",
|
||||
id: "mocked_id",
|
||||
merchantAccount,
|
||||
status: PaymentLinkResource.StatusEnum.Active
|
||||
};
|
||||
}
|
||||
|
||||
function createPaymentLinkRequest(): 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
|
||||
};
|
||||
}
|
||||
|
||||
let client: Client;
|
||||
let checkout: Checkout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
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> => {
|
||||
const client: Client = createMockClientFromResponse(paymentsSuccess);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
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: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest);
|
||||
expect(paymentsResponse.pspReference).toEqual("8535296650153317");
|
||||
expect(paymentsResponse.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should not make a payment", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentsError);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest);
|
||||
expect(paymentsResponse.pspReference).toBeUndefined();
|
||||
test.each([false, true])("should return correct Exception, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
try {
|
||||
scope.post("/payments")
|
||||
.reply(401);
|
||||
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
await checkout.payments(paymentsRequest);
|
||||
} catch (e) {
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it("should have valid payment methods", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(paymentMethodsSuccess);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentMethodsRequest: PaymentMethodsRequest = {
|
||||
merchantAccount: "MagentoMerchantTest",
|
||||
};
|
||||
test.each([false, true])("should have valid payment methods, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const paymentMethodsRequest: PaymentMethodsRequest = {merchantAccount: "MagentoMerchantTest"};
|
||||
|
||||
scope.post("/paymentMethods")
|
||||
.reply(200, paymentMethodsSuccess);
|
||||
|
||||
const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest);
|
||||
expect(paymentMethodsResponse.paymentMethods.length).toEqual(65);
|
||||
expect(paymentMethodsResponse.paymentMethods[0].name).toEqual("AliPay");
|
||||
if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) {
|
||||
expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should not have valid payment methods", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(paymentMethodsError);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentMethodsRequest: PaymentMethodsRequest = {
|
||||
merchantAccount: "MagentoMerchantTest",
|
||||
};
|
||||
const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest);
|
||||
expect(paymentMethodsResponse.paymentMethods).toBeUndefined();
|
||||
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 paymentLinkSuccess: PaymentLinkResource = getPaymentLinkSuccess(expiresAt);
|
||||
|
||||
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
|
||||
|
||||
const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest());
|
||||
expect(paymentSuccessLinkResponse).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have payment details", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentDetailsSuccess);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
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: 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: 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);
|
||||
|
||||
const paymentsResponse = await checkout.paymentsDetails(createPaymentsDetailsRequest());
|
||||
expect(paymentsResponse.resultCode).toEqual("Authorised");
|
||||
});
|
||||
|
||||
it("should not have payment details", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentDetailsError);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentsResponse = await checkout.paymentsDetails(createPaymentsDetailsRequest());
|
||||
expect(paymentsResponse.resultCode).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should have payment session success", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentSessionSuccess);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
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: PaymentSetupRequest = createPaymentSessionRequest();
|
||||
const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest);
|
||||
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("should not have payment session success", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentSessionError);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentSessionRequest: PaymentSetupRequest = createPaymentSessionRequest();
|
||||
const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest);
|
||||
expect(paymentSessionResponse.paymentSession).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should have payments result", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(paymentsResultSuccess);
|
||||
const checkout = new Checkout(client);
|
||||
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: PaymentVerificationRequest = {
|
||||
payload: "This is a test payload",
|
||||
};
|
||||
@@ -167,101 +264,125 @@ describe("Checkout", (): void => {
|
||||
expect(paymentResultResponse.resultCode).toEqual("Authorised");
|
||||
});
|
||||
|
||||
it("should not have payments result", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(paymentsResultError);
|
||||
const checkout = new Checkout(client);
|
||||
const paymentResultRequest: PaymentVerificationRequest = {
|
||||
payload: "This is a test payload",
|
||||
};
|
||||
const paymentResultResponse = await checkout.paymentResult(paymentResultRequest);
|
||||
expect(paymentResultResponse.resultCode).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should have missing identifier on live", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(paymentsResultError);
|
||||
client.setEnvironment("TEST");
|
||||
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);
|
||||
fail();
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
|
||||
}
|
||||
});
|
||||
|
||||
it("should have custom payment details", async (): Promise<void> => {
|
||||
const paymentsRequest = createPaymentsCheckoutRequest();
|
||||
expect(JSON.parse("{\n"
|
||||
+ " \"amount\": {\n"
|
||||
+ " \"value\": 1000,\n"
|
||||
+ " \"currency\": \"USD\"\n"
|
||||
+ " },\n"
|
||||
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
|
||||
+ " \"paymentMethod\": {\n"
|
||||
+ " \"type\": \"scheme\",\n"
|
||||
+ " \"number\": \"4111111111111111\",\n"
|
||||
+ " \"expiryMonth\": \"10\",\n"
|
||||
+ " \"expiryYear\": \"2018\",\n"
|
||||
+ " \"holderName\": \"John Smith\",\n"
|
||||
+ " \"cvc\": \"737\"\n"
|
||||
+ " },\n"
|
||||
+ " \"reference\": \"Your order number\",\n"
|
||||
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
|
||||
+ "}")).toEqual(paymentsRequest);
|
||||
|
||||
paymentsRequest.paymentMethod = {
|
||||
testKey: "testValue",
|
||||
type: "testType",
|
||||
};
|
||||
test.each([false, true])("should succeed on multibanco payment, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsResultMultibancoSuccess);
|
||||
|
||||
expect(JSON.parse("{\n"
|
||||
+ " \"amount\": {\n"
|
||||
+ " \"value\": 1000,\n"
|
||||
+ " \"currency\": \"USD\"\n"
|
||||
+ " },\n"
|
||||
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
|
||||
+ " \"paymentMethod\": {\n"
|
||||
+ " \"testKey\": \"testValue\",\n"
|
||||
+ " \"type\": \"testType\"\n"
|
||||
+ " },\n"
|
||||
+ " \"reference\": \"Your order number\",\n"
|
||||
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
|
||||
+ "}")).toEqual(JSON.parse(JSON.stringify(paymentsRequest)));
|
||||
});
|
||||
|
||||
it("should succeed on multibanco payment", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(paymentsResultMultibancoSuccess);
|
||||
const checkout: Checkout = new Checkout(client);
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest);
|
||||
expect(paymentsResponse.pspReference).toEqual("8111111111111111");
|
||||
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();
|
||||
});
|
||||
|
||||
it("should return sepa payment method details", async (): Promise<void> => {
|
||||
const defaultPaymentMethods = {
|
||||
sepaIbanNumber: "DE87123456781234567890",
|
||||
sepaOwnerName: "A. Schneider",
|
||||
type: "sepadirectdebit",
|
||||
test.each([false, true])("should get origin keys. isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
const checkoutUtility = new Checkout(client);
|
||||
const originKeysRequest: CheckoutUtilityRequest = {
|
||||
originDomains: ["https://www.your-domain.com"],
|
||||
};
|
||||
|
||||
const paymentsRequest = createPaymentsCheckoutRequest();
|
||||
paymentsRequest.paymentMethod = defaultPaymentMethods;
|
||||
nock(`${client.config.checkoutEndpoint}`)
|
||||
.post(`/${Client.CHECKOUT_API_VERSION}/originKeys`)
|
||||
.reply(200, originKeysSuccess);
|
||||
|
||||
expect(JSON.parse("{\n"
|
||||
+ " \"amount\": {\n"
|
||||
+ " \"value\": 1000,\n"
|
||||
+ " \"currency\": \"USD\"\n"
|
||||
+ " },\n"
|
||||
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
|
||||
+ " \"paymentMethod\": {\n"
|
||||
+ " \"type\": \"sepadirectdebit\",\n"
|
||||
+ " \"sepaOwnerName\": \"A. Schneider\",\n"
|
||||
+ " \"sepaIbanNumber\": \"DE87123456781234567890\"\n"
|
||||
+ " },\n"
|
||||
+ " \"reference\": \"Your order number\",\n"
|
||||
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
|
||||
+ "}")).toEqual(JSON.parse(JSON.stringify(paymentsRequest)));
|
||||
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: CheckoutBalanceCheckRequest = {
|
||||
merchantAccount,
|
||||
amount: createAmountObject("USD", 1000),
|
||||
paymentMethod: { },
|
||||
reference: "mocked_reference"
|
||||
};
|
||||
|
||||
const paymentMethodsBalanceResponse: CheckoutBalanceCheckResponse = {
|
||||
balance: {currency: "USD", value: 1000},
|
||||
resultCode: CheckoutBalanceCheckResponse.ResultCodeEnum.Success
|
||||
};
|
||||
scope.post("/paymentMethods/balance")
|
||||
.reply(200, paymentMethodsBalanceResponse);
|
||||
|
||||
const paymentsResponse: 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: CheckoutCreateOrderRequest = {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount,
|
||||
reference
|
||||
};
|
||||
|
||||
const orderResponse: CheckoutCreateOrderResponse = {
|
||||
expiresAt,
|
||||
orderData: "mocked_order_data",
|
||||
remainingAmount: {currency: "USD", value: 500} ,
|
||||
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
||||
};
|
||||
scope.post("/orders")
|
||||
.reply(200, orderResponse);
|
||||
|
||||
const response: 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: CheckoutCreateOrderRequest = {
|
||||
amount: createAmountObject("USD", 1000),
|
||||
merchantAccount,
|
||||
reference
|
||||
};
|
||||
|
||||
const orderResponse: CheckoutCreateOrderResponse = {
|
||||
expiresAt,
|
||||
orderData: "mocked_order_data",
|
||||
remainingAmount: {currency: "USD", value: 500},
|
||||
resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success
|
||||
};
|
||||
scope.post("/orders")
|
||||
.reply(200, orderResponse);
|
||||
|
||||
const createOrderResponse: CheckoutCreateOrderResponse = await checkout.orders(orderRequest);
|
||||
|
||||
const orderCancelResponse: CheckoutCancelOrderResponse = {
|
||||
pspReference: "mocked_psp_ref",
|
||||
resultCode: CheckoutCancelOrderResponse.ResultCodeEnum.Received
|
||||
};
|
||||
scope.post("/orders/cancel")
|
||||
.reply(200, orderCancelResponse);
|
||||
|
||||
const response: CheckoutCancelOrderResponse = await checkout.ordersCancel({
|
||||
order: {
|
||||
orderData: createOrderResponse.orderData,
|
||||
pspReference: createOrderResponse.pspReference!
|
||||
},
|
||||
merchantAccount
|
||||
});
|
||||
expect(response).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import {originKeysSuccess} from "../__mocks__/checkoutUtility/originkeysSuccess";
|
||||
import CheckoutUtility from "../service/checkoutUtility";
|
||||
import {CheckoutUtilityRequest} from "../typings/checkoutUtility";
|
||||
|
||||
describe("Checkout Utility", (): void => {
|
||||
it("should get origin keys", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(originKeysSuccess);
|
||||
const checkoutUtility = new CheckoutUtility(client);
|
||||
const originKeysRequest: CheckoutUtilityRequest = {
|
||||
originDomains: ["www.test.com", "https://www.your-domain2.com"],
|
||||
};
|
||||
const originKeysResponse = await checkoutUtility.originKeys(originKeysRequest);
|
||||
expect(originKeysResponse.originKeys["https://www.your-domain1.com"])
|
||||
.toEqual("pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI");
|
||||
});
|
||||
});
|
||||
145
src/__tests__/hmacValidator.spec.ts
Normal file
145
src/__tests__/hmacValidator.spec.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { AdditionalData, NotificationItem, NotificationRequestItem } from "../typings/notification/models";
|
||||
import { ApiConstants } from "../constants/apiConstants";
|
||||
import NotificationRequest from "../notification/notificationRequest";
|
||||
|
||||
const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
|
||||
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;
|
||||
beforeEach(() => {
|
||||
hmacValidator = new HmacValidator();
|
||||
});
|
||||
|
||||
it("should get correct data", function (): void {
|
||||
const dataToSign = hmacValidator.getDataToSign({merchantAccount: "ACC", currencyCode: "EUR"});
|
||||
expect(dataToSign).toEqual("currencyCode:merchantAccount:EUR:ACC");
|
||||
});
|
||||
it("should get correct data with escaped characters", function (): void {
|
||||
const dataToSign = hmacValidator.getDataToSign({currencyCode: "EUR", merchantAccount: "ACC:\\", sessionValidity: "2019-09-21T11:45:24.637Z"});
|
||||
expect(dataToSign).toEqual("currencyCode:merchantAccount:sessionValidity:EUR:ACC\\:\\\\:2019-09-21T11\\:45\\:24.637Z");
|
||||
});
|
||||
it("should encrypt correctly", function (): void {
|
||||
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 encrypted = hmacValidator.calculateHmac(data, "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00");
|
||||
expect(encrypted).toEqual("34oR8T1whkQWTv9P+SzKyp8zhusf9n0dpqrm9nsqSJs=");
|
||||
});
|
||||
it("should get correct data to sign", function (): void {
|
||||
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(notification.notificationItems![0], key);
|
||||
expect(expectedSign).toEqual(encrypted);
|
||||
expect(hmacValidator.validateHMAC(notification.notificationItems![0], key)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have invalid hmac", function (): void {
|
||||
const invalidNotification = {
|
||||
...notification.notificationItems![0],
|
||||
additionalData: { [ApiConstants.HMAC_SIGNATURE as keyof AdditionalData]: "notValidSign" }
|
||||
};
|
||||
const result = hmacValidator.validateHMAC(invalidNotification, key);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should throw error with missing hmac signature", function(): void {
|
||||
expect.assertions(1);
|
||||
const notificationRequestItemNoAdditionalData: 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: { },
|
||||
};
|
||||
try {
|
||||
hmacValidator.validateHMAC(notificationRequestItemNoAdditionalData, key);
|
||||
} catch(error) {
|
||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
69
src/__tests__/httpClient.spec.ts
Normal file
69
src/__tests__/httpClient.spec.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
beforeEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
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): Promise<void> => {
|
||||
const client = new Client({ apiKey, environment });
|
||||
const checkout = new Checkout(client);
|
||||
|
||||
const scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`)
|
||||
.post("/payments");
|
||||
const { errorMessageContains, errorMessageEquals, errorType } = cb(scope);
|
||||
const ErrorException = errorType === "ApiException" ? ApiException : HttpClientException;
|
||||
|
||||
try {
|
||||
await checkout.payments(createPaymentsCheckoutRequest());
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
describe("HTTP Client", function (): void {
|
||||
it.each`
|
||||
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"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, {}]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null"}
|
||||
${"API_KEY"} | ${"TEST"} | ${false} | ${[401, "fail"]} | ${"HttpClientException"} | ${""} | ${"HTTP Exception: 401. null"}
|
||||
`("Should return $errorType, $contains, $equals", async ({ apiKey, environment, withError, args, errorType, contains, equals }) => {
|
||||
await getResponse({ apiKey, environment }, (scope) => {
|
||||
if (withError) scope.replyWithError(args[0]);
|
||||
else scope.reply(args[0], args[1]);
|
||||
|
||||
return { errorType, errorMessageContains: contains, errorMessageEquals: equals };
|
||||
});
|
||||
});
|
||||
});
|
||||
264
src/__tests__/modification.spec.ts
Normal file
264
src/__tests__/modification.spec.ts
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { createClient } from "../__mocks__/base";
|
||||
import Modification from "../services/modification";
|
||||
import Client from "../client";
|
||||
|
||||
const modificationResult: IPayouts.ModifyResponse = {
|
||||
pspReference: "1234567890987654",
|
||||
response: "[refund-received]"
|
||||
};
|
||||
|
||||
const invalidModificationResult = {
|
||||
"status": 422,
|
||||
"errorCode": "167",
|
||||
"message": "Original pspReference required for this operation",
|
||||
"errorType": "validation"
|
||||
};
|
||||
|
||||
const createModificationRequest = (): IPayments.ModificationRequest => {
|
||||
return {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: "863620292981235A",
|
||||
modificationAmount: {
|
||||
value: 500 ,
|
||||
currency: "EUR"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const createInvalidModificationRequest = (): IPayments.ModificationRequest => {
|
||||
return {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: "invalidPspReference",
|
||||
modificationAmount: {
|
||||
value: 500 ,
|
||||
currency: "EUR"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const createCancelRequest = (): IPayments.ModificationRequest => {
|
||||
return {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: "862615382016087C"
|
||||
};
|
||||
};
|
||||
|
||||
const createInvalidCancelRequest = (): IPayments.ModificationRequest => {
|
||||
return {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
originalReference: "invalidPspReference"
|
||||
};
|
||||
};
|
||||
|
||||
let client: Client;
|
||||
let modification: Modification;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
modification = new Modification(client);
|
||||
scope = nock(`${client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}`);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
describe("Modification", (): void => {
|
||||
test.each([false, true])("should perform a refund, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/refund")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createModificationRequest();
|
||||
try {
|
||||
const result = await modification.refund(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a refund, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/refund")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidModificationRequest();
|
||||
try {
|
||||
await modification.refund(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should perform a capture, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/capture")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createModificationRequest();
|
||||
try {
|
||||
const result = await modification.capture(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a capture, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/capture")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidModificationRequest();
|
||||
try {
|
||||
await modification.capture(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should perform a cancelOrRefund, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/cancelOrRefund")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createCancelRequest();
|
||||
try {
|
||||
const result = await modification.cancelOrRefund(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a cancelOrRefund, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/cancelOrRefund")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidCancelRequest();
|
||||
try {
|
||||
await modification.cancelOrRefund(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should perform a cancel, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/cancel")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createCancelRequest();
|
||||
try {
|
||||
const result = await modification.cancel(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a cancel, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/cancel")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidCancelRequest();
|
||||
try {
|
||||
await modification.cancel(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should perform a technicalCancel, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/technicalCancel")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createCancelRequest();
|
||||
try {
|
||||
const result = await modification.technicalCancel(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a technicalCancel, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/technicalCancel")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidCancelRequest();
|
||||
try {
|
||||
await modification.technicalCancel(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should perform a adjustAuthorisation, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/adjustAuthorisation")
|
||||
.reply(200, modificationResult);
|
||||
|
||||
const request = createModificationRequest();
|
||||
try {
|
||||
const result = await modification.adjustAuthorisation(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([false, true])("should fail to perform a adjustAuthorisation, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
expect.assertions(2);
|
||||
scope.post("/adjustAuthorisation")
|
||||
.reply(422, invalidModificationResult);
|
||||
|
||||
const request = createInvalidModificationRequest();
|
||||
try {
|
||||
await modification.adjustAuthorisation(request);
|
||||
} catch (e) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,65 +1,107 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 {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 {
|
||||
const notificationRequest = new NotificationRequest(authorisationTrue);
|
||||
const notificationRequest = new NotificationRequest(authorisationTrue as unknown as Notification);
|
||||
expect(notificationRequest.notificationItems).toHaveLength(1);
|
||||
|
||||
const notificationRequestItem: NotificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_AUTHORISATION).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("123456789");
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem: NotificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.AUTHORISATION).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === SuccessEnum.True).toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("123456789");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should return capture success", function (): void {
|
||||
const notificationRequest = new NotificationRequest(captureTrue);
|
||||
const notificationRequest = new NotificationRequest(captureTrue as unknown as Notification);
|
||||
expect(notificationRequest.notificationItems).toHaveLength(1);
|
||||
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
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 {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should return capture fail", function (): void {
|
||||
const notificationRequest = new NotificationRequest(captureFalse);
|
||||
const notificationRequest = new NotificationRequest(captureFalse as unknown as Notification);
|
||||
expect(notificationRequest.notificationItems).toHaveLength(1);
|
||||
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_CAPTURE).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeFalsy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
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 {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should return refund success", function (): void {
|
||||
const notificationRequest = new NotificationRequest(refundTrue);
|
||||
const notificationRequest = new NotificationRequest(refundTrue as unknown as Notification);
|
||||
expect(notificationRequest.notificationItems).toHaveLength(1);
|
||||
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeTruthy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
expect(notificationRequestItem.eventDate).toBeDefined();
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
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();
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it("should return refund fail", function (): void {
|
||||
const notificationRequest = new NotificationRequest(refundFalse);
|
||||
const notificationRequest = new NotificationRequest(refundFalse as unknown as Notification);
|
||||
expect(notificationRequest.notificationItems).toHaveLength(1);
|
||||
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
expect(NotificationEnum.EVENT_CODE_REFUND).toEqual(notificationRequestItem.eventCode);
|
||||
expect(notificationRequestItem.success === "true").toBeFalsy();
|
||||
expect(notificationRequestItem.pspReference).toEqual("PSP_REFERENCE");
|
||||
expect(notificationRequestItem.originalReference).toEqual("ORIGINAL_PSP");
|
||||
expect(notificationRequestItem.eventDate).toBeDefined();
|
||||
if (notificationRequest.notificationItems) {
|
||||
const notificationRequestItem = notificationRequest.notificationItems[0];
|
||||
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();
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,17 +1,34 @@
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
import Payout from "../service/payout";
|
||||
import {
|
||||
ModifyRequest,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailRequest, SubmitRequest
|
||||
} from "../typings/payout";
|
||||
import { FRAUD_MANUAL_REVIEW, FRAUD_RESULT_TYPE } from "../typings/constants/apiConstants";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { createClient } from "../__mocks__/base";
|
||||
import Payout from "../services/payout";
|
||||
import Client from "../client";
|
||||
import StoreDetailRequest = IPayouts.StoreDetailRequest;
|
||||
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]"
|
||||
@@ -26,114 +43,182 @@ const storeDetail = JSON.stringify({
|
||||
|
||||
const amountAndReference = {
|
||||
amount: {
|
||||
value: 1000,
|
||||
currency: "USD"
|
||||
value: 100,
|
||||
currency: "EUR"
|
||||
},
|
||||
reference: "randomReference",
|
||||
};
|
||||
|
||||
const defaultData = {
|
||||
dateOfBirth: new Date(),
|
||||
dateOfBirth: (new Date()).toISOString(),
|
||||
nationality: "NL",
|
||||
shopperEmail: "johndoe@email.com",
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
|
||||
const mockStoreDetailRequest = (merchantAccount: string): 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): 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): StoreDetailAndSubmitRequest => ({
|
||||
const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): IPayouts.StoreDetailAndSubmitRequest => ({
|
||||
...amountAndReference,
|
||||
...(mockStoreDetailRequest(merchantAccount)),
|
||||
});
|
||||
|
||||
const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): IPayouts.PayoutRequest => ({
|
||||
...amountAndReference,
|
||||
...defaultData,
|
||||
card: {
|
||||
expiryMonth: "03",
|
||||
expiryYear: "2030",
|
||||
holderName: "John Smith",
|
||||
number: "4111111111111111",
|
||||
},
|
||||
merchantAccount,
|
||||
});
|
||||
|
||||
let client: Client;
|
||||
let clientStore: Client;
|
||||
let clientReview: Client;
|
||||
let payout: Payout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
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 client = createMockClientFromResponse(storeDetailAndSubmitThirdParty);
|
||||
const payout = new Payout(client);
|
||||
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 request: StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest(client.config.merchantAccount);
|
||||
|
||||
const result = await payout.storeDetail(request);
|
||||
const result = await payout.storeDetailAndSubmitThirdParty(request);
|
||||
expect(result.resultCode).toEqual("[payout-submit-received]");
|
||||
expect(result.pspReference).toEqual("8515131751004933");
|
||||
expect(result.additionalData[FRAUD_RESULT_TYPE]).toEqual("GREEN");
|
||||
expect(result.additionalData[FRAUD_MANUAL_REVIEW]).toEqual("false");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should succeed on store detail", async function (): Promise<void> {
|
||||
const client = createMockClientFromResponse(storeDetail);
|
||||
const payout = new Payout(client);
|
||||
|
||||
const request: StoreDetailRequest = mockStoreDetailRequest(client.config.merchantAccount);
|
||||
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();
|
||||
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> {
|
||||
const client = createMockClientFromResponse(JSON.stringify({
|
||||
pspReference: "8815131762537886",
|
||||
response: "[payout-confirm-received]"
|
||||
}));
|
||||
const payout = new Payout(client);
|
||||
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);
|
||||
|
||||
const request: ModifyRequest = {
|
||||
merchantAccount: client.config.merchantAccount,
|
||||
originalReference: "reference"
|
||||
payout = new Payout(clientReview);
|
||||
scope.post("/confirmThirdParty")
|
||||
.reply(200, {
|
||||
pspReference: "8815131762537886",
|
||||
response: "[payout-confirm-received]"
|
||||
});
|
||||
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
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> {
|
||||
const client = createMockClientFromResponse(storeDetailAndSubmitThirdParty);
|
||||
const payout = new Payout(client);
|
||||
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: SubmitRequest = mockSubmitRequest(client.config.merchantAccount);
|
||||
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.additionalData[FRAUD_RESULT_TYPE]).toEqual("GREEN");
|
||||
expect(result.additionalData[FRAUD_MANUAL_REVIEW]).toEqual("false");
|
||||
expect(result.pspReference).toBeTruthy();
|
||||
|
||||
if (result.additionalData) {
|
||||
expect(result.additionalData[ApiConstants.FRAUD_RESULT_TYPE]).toEqual("GREEN");
|
||||
expect(result.additionalData[ApiConstants.FRAUD_MANUAL_REVIEW]).toEqual("false");
|
||||
}
|
||||
});
|
||||
|
||||
it("should succeed on decline third party", async function (): Promise<void> {
|
||||
const client = createMockClientFromResponse(JSON.stringify({
|
||||
pspReference: "8815131762537886",
|
||||
response: "[payout-confirm-received]"
|
||||
}));
|
||||
const payout = new Payout(client);
|
||||
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);
|
||||
|
||||
const request: ModifyRequest = {
|
||||
merchantAccount: client.config.merchantAccount,
|
||||
originalReference: "reference"
|
||||
payout = new Payout(clientReview);
|
||||
const request: IPayouts.ModifyRequest = {
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
const result = await payout.payout(request);
|
||||
|
||||
expect(result.resultCode).toEqual("Received");
|
||||
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,40 +1,164 @@
|
||||
import { createMockClientFromResponse } from "../__mocks__/base";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { createClient } from "../__mocks__/base";
|
||||
import { disableSuccess } from "../__mocks__/recurring/disableSuccess";
|
||||
import { listRecurringDetailsSuccess } from "../__mocks__/recurring/listRecurringDetailsSuccess";
|
||||
import Recurring from "../service/recurring";
|
||||
import { DisableRequest, RecurringDetailsRequest } from "../typings/recurring";
|
||||
import { notifyShopperSuccess } from "../__mocks__/recurring/notifyShopperSuccess";
|
||||
import RecurringService from "../services/recurring";
|
||||
import Client from "../client";
|
||||
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess";
|
||||
import { createPaymentsCheckoutRequest } from "./checkout.spec";
|
||||
import Checkout from "../services/checkout";
|
||||
import { PaymentRequest } from "../typings/checkout/models";
|
||||
import {
|
||||
ScheduleAccountUpdaterRequest,
|
||||
ScheduleAccountUpdaterResult,
|
||||
DisableRequest,
|
||||
RecurringDetailsRequest,
|
||||
Recurring,
|
||||
NotifyShopperRequest
|
||||
} from "../typings/recurring/models";
|
||||
|
||||
const createRecurringDetailsRequest = (): RecurringDetailsRequest => {
|
||||
return {
|
||||
merchantAccount: "MerchantAccount",
|
||||
recurring: {contract: "ONECLICK"},
|
||||
shopperReference: "test-123",
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
recurring: { contract: Recurring.ContractEnum.Recurring },
|
||||
shopperReference: "shopperReference",
|
||||
};
|
||||
};
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
|
||||
let client: Client;
|
||||
let recurring: RecurringService;
|
||||
let checkout: Checkout;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
client = createClient();
|
||||
recurring = new RecurringService(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> => {
|
||||
const client = createMockClientFromResponse(listRecurringDetailsSuccess);
|
||||
const recurring = new Recurring(client);
|
||||
const request = createRecurringDetailsRequest();
|
||||
const result = await recurring.listRecurringDetails(request);
|
||||
expect(result.details).toHaveLength(2);
|
||||
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 [recurringDetail] = result.details;
|
||||
expect(recurringDetail.recurringDetailReference).toEqual("recurringReference");
|
||||
expect(recurringDetail.alias).toEqual("cardAlias");
|
||||
expect(recurringDetail.card.number).toEqual("1111");
|
||||
const request = createRecurringDetailsRequest();
|
||||
try {
|
||||
const result = await recurring.listRecurringDetails(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
it("should disable", async (): Promise<void> => {
|
||||
const client = createMockClientFromResponse(disableSuccess);
|
||||
const recurring = new Recurring(client);
|
||||
test.each([isCI, true])("should disable, isMock: %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/payments")
|
||||
.reply(200, paymentsSuccess);
|
||||
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
const res = await checkout.payments(paymentsRequest);
|
||||
|
||||
scope.post("/disable")
|
||||
.reply(200, disableSuccess);
|
||||
|
||||
const request: 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.response).toEqual("[detail-successfully-disabled]");
|
||||
|
||||
try {
|
||||
const result = await recurring.disable(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e) {
|
||||
fail(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
test.each([isCI, true])("should send pre-debit Notification, isMock %p", async (isMock): Promise<void> => {
|
||||
!isMock && nock.restore();
|
||||
scope.post("/notifyShopper")
|
||||
.reply(200, notifyShopperSuccess);
|
||||
|
||||
const notifyShopperRequest: NotifyShopperRequest = {
|
||||
merchantAccount: process.env.ADYEN_MERCHANT!,
|
||||
shopperReference: "shopperReference",
|
||||
storedPaymentMethodId: "8415995487234100",
|
||||
amount: {
|
||||
currency: "INR",
|
||||
value: 1000
|
||||
},
|
||||
billingDate: "2021-03-16",
|
||||
reference: "Example reference",
|
||||
displayedReference: "Example displayed reference"
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await recurring.notifyShopper(notifyShopperRequest);
|
||||
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: ScheduleAccountUpdaterResult = {
|
||||
pspReference: "mocked_psp",
|
||||
result: "SUCCESS"
|
||||
};
|
||||
|
||||
scope.post("/scheduleAccountUpdater")
|
||||
.reply(200, scheduleAccountUpdaterSuccess);
|
||||
|
||||
const request: 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,69 +1,85 @@
|
||||
import {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../__mocks__/base";
|
||||
import {asyncRes} from "../__mocks__/terminalApi/async";
|
||||
import {syncRes} from "../__mocks__/terminalApi/sync";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { 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 "../service/terminalCloudAPI";
|
||||
import {MessageHeader, SaleToPoiResponse, TerminalApiRequest, TerminalApiResponse} from "../typings/terminal";
|
||||
import TerminalCloudAPI from "../services/terminalCloudAPI";
|
||||
import { TerminalApiResponse } from "../typings/terminal/models";
|
||||
|
||||
let client: Client;
|
||||
let terminalCloudAPI: TerminalCloudAPI;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
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> => {
|
||||
const client: Client = createMockClientFromResponse(asyncRes);
|
||||
const terminalCloudAPI: TerminalCloudAPI = new TerminalCloudAPI(client);
|
||||
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: TerminalApiRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
|
||||
const requestResponse: string = await terminalCloudAPI.async(terminalAPIPaymentRequest);
|
||||
|
||||
expect(requestResponse).toEqual("ok");
|
||||
});
|
||||
|
||||
it("should make a sync payment request", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(syncRes);
|
||||
const terminalCloudAPI: TerminalCloudAPI = new TerminalCloudAPI(client);
|
||||
const terminalAPIPaymentRequest: TerminalApiRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
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);
|
||||
|
||||
const saleToPoiResponse: SaleToPoiResponse = terminalAPIResponse.saleToPoiResponse;
|
||||
expect(terminalAPIResponse.saleToPOIResponse?.paymentResponse).toBeDefined();
|
||||
expect(terminalAPIResponse.saleToPOIResponse?.messageHeader).toBeDefined();
|
||||
});
|
||||
|
||||
const messageHeader: MessageHeader = saleToPoiResponse.messageHeader;
|
||||
expect(messageHeader.messageType).toEqual("Response");
|
||||
expect(messageHeader.messageClass).toEqual("Service");
|
||||
expect(messageHeader.messageCategory).toEqual("Payment");
|
||||
expect(messageHeader.protocolVersion).toEqual("3.0");
|
||||
expect(messageHeader.saleId).toEqual("001");
|
||||
expect(messageHeader.serviceId).toEqual("1234567890");
|
||||
expect(messageHeader.poiid).toEqual("P400Plus-123456789");
|
||||
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 response = saleToPoiResponse.paymentResponse.response;
|
||||
expect(response.result).toEqual("Success");
|
||||
expect(response.additionalResponse).toBeTruthy();
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest();
|
||||
const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest);
|
||||
|
||||
const poiData = saleToPoiResponse.paymentResponse.poiData;
|
||||
expect(poiData.poiReconciliationId).toEqual("1000");
|
||||
expect(poiData.poiTransactionId.transactionId).toEqual("4r7i001556529591000.8515565295894301");
|
||||
expect(poiData.poiTransactionId.timeStamp).toEqual("2019-04-29T00:00:00.000Z");
|
||||
scope.post("/sync").reply(200, syncRefund);
|
||||
|
||||
const saleData = saleToPoiResponse.paymentResponse.saleData;
|
||||
expect(saleData.saleTransactionId.transactionId).toEqual("001");
|
||||
expect(saleData.saleTransactionId.timeStamp).toEqual("2019-04-29T00:00:00.000Z");
|
||||
const terminalAPIRefundRequest = createTerminalAPIRefundRequest(terminalAPIResponse.saleToPOIResponse?.paymentResponse?.pOIData.pOITransactionID!);
|
||||
const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest);
|
||||
|
||||
expect(saleToPoiResponse.paymentResponse.paymentReceipt.length).toBeGreaterThan(0);
|
||||
saleToPoiResponse.paymentResponse.paymentReceipt.forEach((receipt): void => {
|
||||
expect(receipt.outputContent.outputFormat).toEqual("Text");
|
||||
expect(receipt.outputContent.outputText.length).toBeGreaterThan(0);
|
||||
receipt.outputContent.outputText.forEach((outputText): void => {
|
||||
expect(outputText.text).toBeTruthy();
|
||||
});
|
||||
});
|
||||
const {paymentResult} = saleToPoiResponse.paymentResponse;
|
||||
expect(paymentResult.onlineFlag).toBeTruthy();
|
||||
expect(paymentResult.paymentAcquirerData.acquirerPoiid).toEqual("P400Plus-123456789");
|
||||
expect(paymentResult.paymentAcquirerData.approvalCode).toEqual("123456");
|
||||
expect(paymentResult.paymentAcquirerData.merchantId).toEqual("TestMerchant");
|
||||
expect(paymentResult.paymentInstrumentData.cardData.paymentBrand).toEqual("mc");
|
||||
expect(paymentResult.paymentInstrumentData.cardData.maskedPan).toEqual("411111 **** 1111");
|
||||
expect(paymentResult.paymentInstrumentData.paymentInstrumentType).toEqual("Card");
|
||||
expect(paymentResult.amountsResp.currency).toEqual("EUR");
|
||||
expect(paymentResult.amountsResp.authorizedAmount).toEqual(1);
|
||||
expect(terminalAPIRefundResponse.saleToPOIResponse?.reversalResponse).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,67 +1,87 @@
|
||||
import {createMockClientFromResponse, createTerminalAPIPaymentRequest} from "../__mocks__/base";
|
||||
import {localRes} from "../__mocks__/terminalApi/local";
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 { createClient, createTerminalAPIPaymentRequest } from "../__mocks__/base";
|
||||
import { localEncRes, wrongEncRes } from "../__mocks__/terminalApi/local";
|
||||
import Client from "../client";
|
||||
import TerminalLocalAPI from "../service/terminalLocalAPI";
|
||||
import {SecurityKey, TerminalApiRequest, TerminalApiResponse} from "../typings/terminal";
|
||||
import TerminalLocalAPI from "../services/terminalLocalAPI";
|
||||
import { SecurityKey, TerminalApiResponse } from "../typings/terminal/models";
|
||||
import NexoCryptoException from "../services/exception/nexoCryptoException";
|
||||
|
||||
let client: Client;
|
||||
let terminalLocalAPI: TerminalLocalAPI;
|
||||
let scope: nock.Scope;
|
||||
|
||||
beforeEach((): void => {
|
||||
if (!nock.isActive()) {
|
||||
nock.activate();
|
||||
}
|
||||
|
||||
client = createClient();
|
||||
terminalLocalAPI = new TerminalLocalAPI(client);
|
||||
scope = nock(client.config.terminalApiLocalEndpoint + ":8443/nexo");
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI);
|
||||
|
||||
describe("Terminal Local API", (): void => {
|
||||
it("should make a local payment", async (): Promise<void> => {
|
||||
const client: Client = createMockClientFromResponse(localRes);
|
||||
const terminalLocalAPI: TerminalLocalAPI = new TerminalLocalAPI(client);
|
||||
|
||||
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest() as TerminalApiRequest;
|
||||
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);
|
||||
const saleToPoiResponse = terminalApiResponse.saleToPoiResponse;
|
||||
const messageHeader = saleToPoiResponse.messageHeader;
|
||||
|
||||
expect(messageHeader.messageType).toEqual("Response");
|
||||
expect(messageHeader.messageClass).toEqual("Service");
|
||||
expect(messageHeader.messageCategory).toEqual("Payment");
|
||||
expect(messageHeader.protocolVersion).toEqual("3.0");
|
||||
expect(messageHeader.saleId).toEqual("325488592");
|
||||
expect(messageHeader.serviceId).toEqual("325488592");
|
||||
expect(messageHeader.poiid).toEqual("P400Plus-275039202");
|
||||
expect(terminalApiResponse.saleToPOIResponse?.paymentResponse).toBeDefined();
|
||||
expect(terminalApiResponse.saleToPOIResponse?.messageHeader).toBeDefined();
|
||||
});
|
||||
|
||||
const response = saleToPoiResponse.paymentResponse.response;
|
||||
expect(response.result).toEqual("Success");
|
||||
expect(response.additionalResponse).toBeTruthy();
|
||||
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 poiData = saleToPoiResponse.paymentResponse.poiData;
|
||||
expect(poiData.poiReconciliationId).toEqual("1000");
|
||||
expect(poiData.poiTransactionId.transactionId).toEqual("4r7i001557325515012.8815573255107661");
|
||||
expect(poiData.poiTransactionId.timeStamp).toEqual("2019-05-08T14:25:15.000Z");
|
||||
const securityKey: SecurityKey = {
|
||||
adyenCryptoVersion: 0,
|
||||
keyIdentifier: "CryptoKeyIdentifier12345",
|
||||
keyVersion: 0,
|
||||
passphrase: "p@ssw0rd123456",
|
||||
};
|
||||
|
||||
const saleData = saleToPoiResponse.paymentResponse.saleData;
|
||||
expect(saleData.saleTransactionId.transactionId).toEqual("999");
|
||||
expect(saleData.saleTransactionId.timeStamp).toEqual("2019-05-08T14:24:48.598Z");
|
||||
|
||||
expect(saleToPoiResponse.paymentResponse.paymentReceipt.length).toBeGreaterThan(0);
|
||||
saleToPoiResponse.paymentResponse.paymentReceipt.forEach((receipt): void => {
|
||||
expect(receipt.outputContent.outputFormat).toEqual("Text");
|
||||
expect(receipt.outputContent.outputText.length).toBeGreaterThan(0);
|
||||
receipt.outputContent.outputText.forEach((outputText): void => {
|
||||
expect(outputText.text).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
const paymentResult = saleToPoiResponse.paymentResponse.paymentResult;
|
||||
expect(paymentResult.onlineFlag).toBeTruthy();
|
||||
expect(paymentResult.paymentAcquirerData.acquirerPoiid).toEqual("P400Plus-275039202");
|
||||
expect(paymentResult.paymentAcquirerData.approvalCode).toEqual("123456");
|
||||
expect(paymentResult.paymentAcquirerData.merchantId).toEqual("TestMerchantRenatoTest");
|
||||
expect(paymentResult.paymentInstrumentData.cardData.paymentBrand).toEqual("mc");
|
||||
expect(paymentResult.paymentInstrumentData.cardData.maskedPan).toEqual("541333 **** 0010");
|
||||
expect(paymentResult.paymentInstrumentData.paymentInstrumentType).toEqual("Card");
|
||||
expect(paymentResult.amountsResp.currency).toEqual("EUR");
|
||||
expect(paymentResult.amountsResp.authorizedAmount).toEqual(1);
|
||||
try {
|
||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||
} catch (e) {
|
||||
expect(e instanceof NexoCryptoException);
|
||||
expect(e.message).toEqual("Hmac validation failed");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 Client from "./client";
|
||||
import Service from "./service";
|
||||
|
||||
class ApiKeyAuthenticatedService extends Service {
|
||||
abstract class ApiKeyAuthenticatedService extends Service {
|
||||
protected constructor(client: Client) {
|
||||
super(client);
|
||||
this.apiKeyRequired = true;
|
||||
|
||||
108
src/client.ts
108
src/client.ts
@@ -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 Config from "./config";
|
||||
import ClientInterface from "./httpClient/clientInterface";
|
||||
import HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
|
||||
import { Environment } from "./typings/enums/environment";
|
||||
import { version } from "../package.json";
|
||||
import ClientInterface from "./httpClient/clientInterface";
|
||||
|
||||
type ClientParametersOverload =
|
||||
| { config: Config }
|
||||
@@ -47,51 +45,53 @@ interface ClientParameters {
|
||||
}
|
||||
|
||||
class Client {
|
||||
public static ENDPOINT_TEST: string = "https://pal-test.adyen.com";
|
||||
public static ENDPOINT_LIVE: string = "https://pal-live.adyen.com";
|
||||
public static ENDPOINT_LIVE_SUFFIX: string = "-pal-live.adyenpayments.com";
|
||||
public static HPP_TEST: string = "https://test.adyen.com/hpp";
|
||||
public static HPP_LIVE: string = "https://live.adyen.com/hpp";
|
||||
public static MARKETPAY_ENDPOINT_TEST: string = "https://cal-test.adyen.com/cal/services";
|
||||
public static MARKETPAY_ENDPOINT_LIVE: string = "https://cal-live.adyen.com/cal/services";
|
||||
public static API_VERSION: string = "v49";
|
||||
public static RECURRING_API_VERSION: string = "v30";
|
||||
public static MARKETPAY_ACCOUNT_API_VERSION: string = "v4";
|
||||
public static MARKETPAY_FUND_API_VERSION: string = "v3";
|
||||
public static MARKETPAY_NOTIFICATION_API_VERSION: string = "v1";
|
||||
public static LIB_NAME: string = "adyen-node-api-library";
|
||||
public static LIB_VERSION: string = "1.0.1";
|
||||
public static CHECKOUT_ENDPOINT_TEST: string = "https://checkout-test.adyen.com/checkout";
|
||||
public static CHECKOUT_ENDPOINT_LIVE_SUFFIX: string = "-checkout-live.adyenpayments.com/checkout";
|
||||
public static CHECKOUT_API_VERSION: string = "v49";
|
||||
public static ENDPOINT_TEST = "https://pal-test.adyen.com";
|
||||
public static ENDPOINT_LIVE = "https://pal-live.adyen.com";
|
||||
public static ENDPOINT_LIVE_SUFFIX = "-pal-live.adyenpayments.com";
|
||||
public static HPP_TEST = "https://test.adyen.com/hpp";
|
||||
public static HPP_LIVE = "https://live.adyen.com/hpp";
|
||||
public static MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
|
||||
public static MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
|
||||
public static CHECKOUT_API_VERSION = "v67";
|
||||
public static API_VERSION = "v64";
|
||||
public static RECURRING_API_VERSION = "v49";
|
||||
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 BIN_LOOKUP_PAL_SUFFIX = "/pal/servlet/BinLookup/";
|
||||
public static BIN_LOOKUP_API_VERSION = "v40";
|
||||
public static CHECKOUT_UTILITY_API_VERSION: string = "v1";
|
||||
public static TERMINAL_API_ENDPOINT_TEST: string = "https://terminal-api-test.adyen.com";
|
||||
public static TERMINAL_API_ENDPOINT_LIVE: string = "https://terminal-api-live.adyen.com";
|
||||
public static ENDPOINT_PROTOCOL: string = "https://";
|
||||
public static BIN_LOOKUP_API_VERSION = "v50";
|
||||
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://";
|
||||
|
||||
private _httpClient: ClientInterface;
|
||||
private _config: Config;
|
||||
private _httpClient!: ClientInterface;
|
||||
public config: Config;
|
||||
|
||||
public constructor(clientParameters: ClientParametersOverload);
|
||||
public constructor(options: ClientParameters) {
|
||||
if (options.config) {
|
||||
this._config = options.config;
|
||||
this.config = options.config;
|
||||
} else {
|
||||
this._config = new Config();
|
||||
this.config = new Config();
|
||||
}
|
||||
|
||||
if (options.environment) {
|
||||
this.setEnvironment(options.environment, options.liveEndpointUrlPrefix);
|
||||
const environment = options.environment || this.config.environment;
|
||||
if (environment) {
|
||||
this.setEnvironment(environment, options.liveEndpointUrlPrefix);
|
||||
if (options.username && options.password && options.applicationName) {
|
||||
this._config.username = options.username;
|
||||
this._config.password = options.password;
|
||||
this._config.applicationName = options.applicationName;
|
||||
this.config.username = options.username;
|
||||
this.config.password = options.password;
|
||||
this.config.applicationName = options.applicationName;
|
||||
}
|
||||
|
||||
if (options.apiKey) {
|
||||
this._config.apiKey = options.apiKey;
|
||||
this.config.apiKey = options.apiKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,25 +101,25 @@ class Client {
|
||||
}
|
||||
|
||||
public setEnvironment(environment: Environment, liveEndpointUrlPrefix?: string): void {
|
||||
this._config.environment = environment;
|
||||
if (environment === "TEST") {
|
||||
this._config.endpoint = Client.ENDPOINT_TEST;
|
||||
this._config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
this._config.hppEndpoint = Client.HPP_TEST;
|
||||
this._config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||
this._config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
||||
this.config.endpoint = Client.ENDPOINT_TEST;
|
||||
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
|
||||
this.config.hppEndpoint = Client.HPP_TEST;
|
||||
this.config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
|
||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
|
||||
} else if (environment === "LIVE") {
|
||||
this._config.endpoint = Client.ENDPOINT_LIVE;
|
||||
this._config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
|
||||
this._config.hppEndpoint = Client.HPP_LIVE;
|
||||
this.config.endpoint = Client.ENDPOINT_LIVE;
|
||||
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
|
||||
this.config.hppEndpoint = Client.HPP_LIVE;
|
||||
this.config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_LIVE;
|
||||
if (liveEndpointUrlPrefix) {
|
||||
this._config.endpoint =
|
||||
this.config.endpoint =
|
||||
`${Client.ENDPOINT_PROTOCOL}${liveEndpointUrlPrefix}${Client.ENDPOINT_LIVE_SUFFIX}`;
|
||||
this._config.checkoutEndpoint =
|
||||
this.config.checkoutEndpoint =
|
||||
`${Client.ENDPOINT_PROTOCOL}${liveEndpointUrlPrefix}${Client.CHECKOUT_ENDPOINT_LIVE_SUFFIX}`;
|
||||
} else {
|
||||
this._config.endpoint = Client.ENDPOINT_LIVE;
|
||||
this._config.checkoutEndpoint = undefined;
|
||||
this.config.endpoint = Client.ENDPOINT_LIVE;
|
||||
this.config.checkoutEndpoint = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,14 +136,6 @@ class Client {
|
||||
this._httpClient = httpClient;
|
||||
}
|
||||
|
||||
public get config(): Config {
|
||||
return this._config;
|
||||
}
|
||||
|
||||
public set config(config: Config) {
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
public setApplicationName(applicationName: string): void {
|
||||
this.config.applicationName = applicationName;
|
||||
}
|
||||
|
||||
217
src/config.ts
217
src/config.ts
@@ -11,15 +11,11 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 { Environment } from "./typings/enums/environment";
|
||||
|
||||
interface ConfigConstructor {
|
||||
username?: string;
|
||||
password?: string;
|
||||
@@ -41,185 +37,58 @@ interface ConfigConstructor {
|
||||
}
|
||||
|
||||
class Config {
|
||||
protected _username: string;
|
||||
protected _password: string;
|
||||
protected _merchantAccount: string;
|
||||
protected _environment: Environment;
|
||||
protected _endpoint: string;
|
||||
protected _marketPayEndpoint: string;
|
||||
protected _applicationName: string;
|
||||
protected _apiKey: string;
|
||||
protected _connectionTimeoutMillis: number;
|
||||
protected _readTimeoutMillis: number;
|
||||
protected _certificatePath: string;
|
||||
public username?: string;
|
||||
public password?: string;
|
||||
public merchantAccount?: string;
|
||||
public environment?: Environment;
|
||||
public endpoint?: string;
|
||||
public marketPayEndpoint?: string;
|
||||
public applicationName?: string;
|
||||
public apiKey?: string;
|
||||
public connectionTimeoutMillis?: number;
|
||||
public readTimeoutMillis?: number;
|
||||
public certificatePath?: string;
|
||||
|
||||
protected _hppEndpoint: string;
|
||||
protected _skinCode: string;
|
||||
protected _hmacKey: string;
|
||||
public hppEndpoint?: string;
|
||||
public skinCode?: string;
|
||||
public hmacKey?: string;
|
||||
|
||||
protected _checkoutEndpoint: string;
|
||||
protected _checkoutEndpoint?: string;
|
||||
|
||||
protected _terminalApiCloudEndpoint: string;
|
||||
protected _terminalApiLocalEndpoint: string;
|
||||
public terminalApiCloudEndpoint?: string;
|
||||
public terminalApiLocalEndpoint?: string;
|
||||
|
||||
public constructor(options: ConfigConstructor = {}) {
|
||||
this._username = options.username;
|
||||
this._password = options.password;
|
||||
this._merchantAccount = options.merchantAccount;
|
||||
this._environment = options.environment;
|
||||
this._endpoint = options.endpoint;
|
||||
this._marketPayEndpoint = options.marketPayEndpoint;
|
||||
this._applicationName = options.applicationName;
|
||||
this._apiKey = options.apiKey;
|
||||
this._connectionTimeoutMillis = options.connectionTimeoutMillis || 30000;
|
||||
this._readTimeoutMillis = options.readTimeoutMillis || 3000;
|
||||
this._certificatePath = options.certificatePath;
|
||||
this._hppEndpoint = options.hppEndpoint;
|
||||
this._skinCode = options.skinCode;
|
||||
this._hmacKey = options.hmacKey;
|
||||
this._checkoutEndpoint = options.checkoutEndpoint;
|
||||
this._terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
||||
this._terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
||||
if (options.username) this.username = options.username;
|
||||
if (options.password) this.password = options.password;
|
||||
if (options.merchantAccount) this.merchantAccount = options.merchantAccount;
|
||||
if (options.environment) this.environment = options.environment;
|
||||
if (options.endpoint) this.endpoint = options.endpoint;
|
||||
if (options.marketPayEndpoint) this.marketPayEndpoint = options.marketPayEndpoint;
|
||||
if (options.applicationName) this.applicationName = options.applicationName;
|
||||
if (options.apiKey) this.apiKey = options.apiKey;
|
||||
if (options.connectionTimeoutMillis) this.connectionTimeoutMillis = options.connectionTimeoutMillis || 30000;
|
||||
if (options.readTimeoutMillis) this.readTimeoutMillis = options.readTimeoutMillis || 3000;
|
||||
if (options.certificatePath) this.certificatePath = options.certificatePath;
|
||||
if (options.hppEndpoint) this.hppEndpoint = options.hppEndpoint;
|
||||
if (options.skinCode) this.skinCode = options.skinCode;
|
||||
if (options.hmacKey) this.hmacKey = options.hmacKey;
|
||||
if (options.checkoutEndpoint) this._checkoutEndpoint = options.checkoutEndpoint;
|
||||
if (options.terminalApiCloudEndpoint) this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
||||
if (options.terminalApiLocalEndpoint) this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
||||
}
|
||||
|
||||
public get username(): string {
|
||||
return this._username;
|
||||
}
|
||||
|
||||
public set username(username: string) {
|
||||
this._username = username;
|
||||
}
|
||||
|
||||
public get password(): string {
|
||||
return this._password;
|
||||
}
|
||||
|
||||
public set password(password: string) {
|
||||
this._password = password;
|
||||
}
|
||||
|
||||
public get merchantAccount(): string {
|
||||
return this._merchantAccount;
|
||||
}
|
||||
|
||||
public set merchantAccount(merchantAccount: string) {
|
||||
this._merchantAccount = merchantAccount;
|
||||
}
|
||||
|
||||
public get environment(): Environment {
|
||||
return this._environment;
|
||||
}
|
||||
|
||||
public set environment(environment: Environment) {
|
||||
this._environment = environment;
|
||||
}
|
||||
|
||||
public get endpoint(): string {
|
||||
return this._endpoint;
|
||||
}
|
||||
|
||||
public set endpoint(endpoint: string) {
|
||||
this._endpoint = endpoint;
|
||||
}
|
||||
|
||||
public get marketPayEndpoint(): string {
|
||||
return this._marketPayEndpoint;
|
||||
}
|
||||
|
||||
public set marketPayEndpoint(marketPayEndpoint: string) {
|
||||
this._marketPayEndpoint = marketPayEndpoint;
|
||||
}
|
||||
|
||||
public get applicationName(): string {
|
||||
return this._applicationName;
|
||||
}
|
||||
|
||||
public set applicationName(applicationName: string) {
|
||||
this._applicationName = applicationName;
|
||||
}
|
||||
|
||||
public get apiKey(): string {
|
||||
return this._apiKey;
|
||||
}
|
||||
|
||||
public set apiKey(apiKey: string) {
|
||||
this._apiKey = apiKey;
|
||||
}
|
||||
|
||||
public get hppEndpoint(): string {
|
||||
return this._hppEndpoint;
|
||||
}
|
||||
|
||||
public set hppEndpoint(hppEndpoint: string) {
|
||||
this._hppEndpoint = hppEndpoint;
|
||||
}
|
||||
|
||||
public get skinCode(): string {
|
||||
return this._skinCode;
|
||||
}
|
||||
|
||||
public set skinCode(skinCode: string) {
|
||||
this._skinCode = skinCode;
|
||||
}
|
||||
|
||||
public get hmacKey(): string {
|
||||
return this._hmacKey;
|
||||
}
|
||||
|
||||
public set hmacKey(hmacKey: string) {
|
||||
this._hmacKey = hmacKey;
|
||||
}
|
||||
|
||||
public get checkoutEndpoint(): string {
|
||||
if (!this._checkoutEndpoint) {
|
||||
const message = "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.";
|
||||
throw new Error(message);
|
||||
}
|
||||
return this._checkoutEndpoint;
|
||||
}
|
||||
|
||||
public set checkoutEndpoint(checkoutEndpoint: string) {
|
||||
public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
|
||||
this._checkoutEndpoint = checkoutEndpoint;
|
||||
}
|
||||
|
||||
public get terminalApiCloudEndpoint(): string {
|
||||
return this._terminalApiCloudEndpoint;
|
||||
}
|
||||
|
||||
public set terminalApiCloudEndpoint(terminalApiCloudEndpoint: string) {
|
||||
this._terminalApiCloudEndpoint = terminalApiCloudEndpoint;
|
||||
}
|
||||
|
||||
public get terminalApiLocalEndpoint(): string {
|
||||
return this._terminalApiLocalEndpoint;
|
||||
}
|
||||
|
||||
public set terminalApiLocalEndpoint(terminalApiLocalEndpoint: string) {
|
||||
this._terminalApiLocalEndpoint = terminalApiLocalEndpoint;
|
||||
}
|
||||
|
||||
public get connectionTimeoutMillis(): number {
|
||||
return this._connectionTimeoutMillis;
|
||||
}
|
||||
|
||||
public set connectionTimeoutMillis(connectionTimeoutMillis: number) {
|
||||
this._connectionTimeoutMillis = connectionTimeoutMillis;
|
||||
}
|
||||
|
||||
public get readTimeoutMillis(): number {
|
||||
return this._readTimeoutMillis;
|
||||
}
|
||||
|
||||
public set readTimeoutMillis(readTimeoutMillis: number) {
|
||||
this._readTimeoutMillis = readTimeoutMillis;
|
||||
}
|
||||
|
||||
public set certificatePath(certificatePath: string) {
|
||||
this._certificatePath = certificatePath;
|
||||
}
|
||||
|
||||
public get certificatePath(): string {
|
||||
return this._certificatePath;
|
||||
public get checkoutEndpoint(): string | undefined {
|
||||
if (!this._checkoutEndpoint) {
|
||||
const message = "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.";
|
||||
throw new Error(message);
|
||||
} else {
|
||||
return this._checkoutEndpoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
83
src/constants/apiConstants.ts
Normal file
83
src/constants/apiConstants.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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 enum ApiConstants {
|
||||
TRANSACTION_NOT_PERMITTED = "Transaction Not Permitted",
|
||||
CVC_DECLINED = "CVC Declined",
|
||||
RESTRICTED_CARD = "Restricted Card",
|
||||
PAYMENT_DETAIL_NOT_FOUND = "803 PaymentDetail not found",
|
||||
REFUSED = "Refused",
|
||||
|
||||
REFUSAL_REASON_RAW = "refusalReasonRaw",
|
||||
PAYMENT_METHOD = "paymentMethod",
|
||||
EXPIRY_DATE = "expiryDate",
|
||||
CARD_BIN = "cardBin",
|
||||
CARD_HOLDER_NAME = "cardHolderName",
|
||||
CARD_SUMMARY = "cardSummary",
|
||||
THREE_D_OFFERERED = "threeDOffered",
|
||||
THREE_D_AUTHENTICATED = "threeDAuthenticated",
|
||||
AVS_RESULT = "avsResult",
|
||||
PAYMENT_TOKEN = "payment.token",
|
||||
FRAUD_RESULT_TYPE = "fraudResultType",
|
||||
FRAUD_MANUAL_REVIEW = "fraudManualReview",
|
||||
AUTH_CODE = "authCode",
|
||||
|
||||
BOLETO_BARCODE_REFERENCE = "boletobancario.barCodeReference",
|
||||
BOLETO_DATA = "boletobancario.data",
|
||||
BOLETO_DUE_DATE = "boletobancario.dueDate",
|
||||
BOLETO_URL = "boletobancario.url",
|
||||
BOLETO_EXPIRATION_DATE = "boletobancario.expirationDate",
|
||||
|
||||
MULTIBANCO_ENTITY = "comprafacil.entity",
|
||||
MULTIBANCO_AMOUNT = "comprafacil.amount",
|
||||
MULTIBANCO_DEADLINE = "comprafacil.deadline",
|
||||
MULTIBANCO_REFERENCE = "comprafacil.reference",
|
||||
|
||||
HMAC_SIGNATURE = "hmacSignature",
|
||||
|
||||
JSON = "card.encrypted.json",
|
||||
|
||||
BOLETO_SANTANDER = "boletobancario_santander",
|
||||
|
||||
NUMBER = "number",
|
||||
EXPIRY_MONTH = "expiryMonth",
|
||||
EXPIRY_YEAR = "expiryYear",
|
||||
CVC = "cvc",
|
||||
ENCRYPTED_CARD_NUMBER = "encryptedCardNumber",
|
||||
ENCRYPTED_EXPIRY_MONTH = "encryptedExpiryMonth",
|
||||
ENCRYPTED_EXPIRY_YEAR = "encryptedExpiryYear",
|
||||
ENCRYPTED_SECURITY_CODE = "encryptedSecurityCode",
|
||||
METHOD_TYPE = "type",
|
||||
HOLDER_NAME = "holderName",
|
||||
RECURRING_DETAIL_REFERENCE = "recurringDetailReference",
|
||||
STORE_DETAILS = "storeDetails",
|
||||
|
||||
MD = "MD",
|
||||
PAREQ = "PaReq",
|
||||
|
||||
TYPE_SCHEME = "scheme",
|
||||
|
||||
IDEMPOTENCY_KEY = "Idempotency-Key",
|
||||
ACCEPT_CHARSET = "Accept-Charset",
|
||||
USER_AGENT = "User-Agent",
|
||||
METHOD_POST = "POST",
|
||||
CONTENT_TYPE = "Content-Type",
|
||||
API_KEY = "X-API-Key",
|
||||
APPLICATION_JSON_TYPE = "application/json",
|
||||
}
|
||||
@@ -11,14 +11,14 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const NEXO_HMAC_KEY_LENGTH = 32;
|
||||
export const NEXO_CIPHER_KEY_LENGTH = 32;
|
||||
export const NEXO_IV_LENGTH = 16;
|
||||
export enum NexoEnum {
|
||||
HMAC_KEY_LENGTH = 32,
|
||||
CIPHER_KEY_LENGTH = 32,
|
||||
IV_LENGTH = 16
|
||||
}
|
||||
29
src/helpers/checkServerIdentity.ts
Normal file
29
src/helpers/checkServerIdentity.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* 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;
|
||||
const re = /^(([a-zA-Z0-9]+-[a-zA-Z0-9]+)|legacy-terminal-certificate)\.(live|test)\.terminal\.adyen\.com$/;
|
||||
const isValid = re.test(CN);
|
||||
const error = new Error("Couldn't verify certificate");
|
||||
|
||||
return isValid ? undefined : error;
|
||||
}
|
||||
@@ -11,30 +11,29 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 Resource from "../service/resource";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import Resource from "../services/resource";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: RequestOptions): Promise<string>;
|
||||
async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: RequestOptions): Promise<R>;
|
||||
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>;
|
||||
|
||||
async function getJsonResponse<T, R>(
|
||||
resource: Resource,
|
||||
jsonRequest: T | string,
|
||||
requestOptions: RequestOptions = {},
|
||||
): Promise<R | string> {
|
||||
const response = await resource.request(
|
||||
typeof jsonRequest === "string" ? jsonRequest : JSON.stringify(jsonRequest),
|
||||
requestOptions);
|
||||
requestOptions: IRequest.Options = {},
|
||||
): Promise<R | string | HttpClientException | ApiException> {
|
||||
const request = typeof jsonRequest === "string" ? jsonRequest : JSON.stringify(jsonRequest);
|
||||
const response = await resource.request(request, requestOptions);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
return typeof response === "string" ? JSON.parse(response) : response;
|
||||
} catch (e) {
|
||||
return response;
|
||||
}
|
||||
|
||||
32
src/helpers/setApplicationInfo.ts
Normal file
32
src/helpers/setApplicationInfo.ts
Normal file
@@ -0,0 +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 { ApplicationInfo } from "../typings/applicationInfo";
|
||||
|
||||
interface AppInfo { applicationInfo?: ApplicationInfo }
|
||||
|
||||
function setApplicationInfo<T extends AppInfo>(request: T): T {
|
||||
const hasApplicationInfo = "applicationInfo" in request;
|
||||
const requestAppInfo = hasApplicationInfo && request.applicationInfo;
|
||||
const applicationInfo = new ApplicationInfo();
|
||||
return {...request, applicationInfo: {...requestAppInfo, ...applicationInfo}};
|
||||
}
|
||||
|
||||
|
||||
export default setApplicationInfo;
|
||||
@@ -11,22 +11,22 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 { RequestOptions } from "../typings/requestOptions";
|
||||
import { AgentOptions } from "https";
|
||||
import HttpClientException from "./httpClientException";
|
||||
import ApiException from "../services/exception/apiException";
|
||||
import { Config } from "../index";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
interface ClientInterface {
|
||||
request(
|
||||
endpoint: string, json: string, config: Config, isApiKeyRequired: boolean, requestOptions?: RequestOptions,
|
||||
): Promise<string>;
|
||||
post(endpoint: string, postParameters: [string, string][], config: Config): Promise<string>;
|
||||
endpoint: string, json: string, config: Config, isApiKeyRequired: boolean, requestOptions?: IRequest.Options,
|
||||
): Promise<string | HttpClientException | ApiException>;
|
||||
post(endpoint: string, postParameters: [string, string][], config: Config): Promise<HttpClientException | string>;
|
||||
proxy?: AgentOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,61 +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 {
|
||||
private _code: number = 0;
|
||||
private _responseHeaders: IncomingHttpHeaders;
|
||||
private readonly _message: string;
|
||||
private readonly _name: string;
|
||||
private _responseBody: IncomingMessage;
|
||||
public statusCode = 500;
|
||||
public errorCode?: string;
|
||||
public responseHeaders?: IncomingHttpHeaders;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
public responseBody?: string;
|
||||
|
||||
public constructor(message: string, code?: number, responseHeaders?: IncomingHttpHeaders, responseBody?: IncomingMessage) {
|
||||
this._name = "HttpClientException";
|
||||
this._message = message;
|
||||
this._code = code;
|
||||
this._responseHeaders = responseHeaders;
|
||||
this._responseBody = responseBody;
|
||||
}
|
||||
|
||||
public get message(): string {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public get name(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public get code(): number {
|
||||
return this._code;
|
||||
}
|
||||
|
||||
public set code(value: number) {
|
||||
this._code = value;
|
||||
}
|
||||
|
||||
public get responseHeaders(): IncomingHttpHeaders {
|
||||
return this._responseHeaders;
|
||||
}
|
||||
|
||||
public set responseHeaders(value: IncomingHttpHeaders) {
|
||||
this._responseHeaders = value;
|
||||
}
|
||||
|
||||
public get responseBody(): IncomingMessage {
|
||||
return this._responseBody;
|
||||
}
|
||||
|
||||
public set responseBody(value: IncomingMessage) {
|
||||
this._responseBody = value;
|
||||
public constructor(props: ExceptionInterface) {
|
||||
this.name = "HttpClientException";
|
||||
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,43 +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 {ClientRequest, IncomingMessage} from "http";
|
||||
import { Agent, AgentOptions, request as httpRequest } from "https";
|
||||
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 {
|
||||
ACCEPT_CHARSET,
|
||||
API_KEY,
|
||||
APPLICATION_JSON_TYPE,
|
||||
CONTENT_TYPE,
|
||||
IDEMPOTENCY_KEY,
|
||||
METHOD_POST,
|
||||
USER_AGENT,
|
||||
} from "../typings/constants/apiConstants";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import ClientInterface from "./clientInterface";
|
||||
import HttpClientException from "./httpClientException";
|
||||
import checkServerIdentity from "../helpers/checkServerIdentity";
|
||||
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";
|
||||
|
||||
class HttpURLConnectionClient implements ClientInterface {
|
||||
private static CHARSET: string = "utf-8";
|
||||
private _proxy: AgentOptions;
|
||||
private agentOptions: AgentOptions;
|
||||
private static CHARSET = "utf-8";
|
||||
public proxy?: AgentOptions;
|
||||
private agentOptions!: AgentOptions;
|
||||
|
||||
public request(
|
||||
endpoint: string, json: string, config: Config, isApiRequired: boolean,
|
||||
requestOptions: RequestOptions = {},
|
||||
): Promise<string> {
|
||||
requestOptions: IRequest.Options,
|
||||
): Promise<string | HttpClientException | ApiException> {
|
||||
requestOptions.headers = {};
|
||||
requestOptions.timeout = config.connectionTimeoutMillis;
|
||||
|
||||
@@ -57,124 +51,155 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
|
||||
const apiKey = config.apiKey;
|
||||
|
||||
if (isApiRequired || apiKey) {
|
||||
requestOptions.headers[API_KEY] = apiKey;
|
||||
if (isApiRequired && !apiKey) {
|
||||
return Promise.reject(new ApiException("Invalid X-API-Key was used", 401));
|
||||
}
|
||||
|
||||
if (apiKey) {
|
||||
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}`;
|
||||
}
|
||||
|
||||
requestOptions.headers[CONTENT_TYPE] = APPLICATION_JSON_TYPE;
|
||||
const httpConnection: ClientRequest = this.createRequest(endpoint, config.applicationName, requestOptions);
|
||||
requestOptions.headers[ApiConstants.CONTENT_TYPE] = ApiConstants.APPLICATION_JSON_TYPE;
|
||||
|
||||
const httpConnection: ClientRequest = this.createRequest(endpoint, requestOptions, config.applicationName);
|
||||
return this.doPostRequest(httpConnection, json);
|
||||
}
|
||||
|
||||
public post(endpoint: string, postParameters: [string, string][], config: Config): Promise<string> {
|
||||
public post(endpoint: string, postParameters: [string, string][], config: Config): Promise<HttpClientException | string> {
|
||||
const postQuery: string = this.getQuery(postParameters);
|
||||
const httpConnection: ClientRequest = this.createRequest(endpoint, config.applicationName, {});
|
||||
return this.doPostRequest(httpConnection, postQuery);
|
||||
const connectionRequest: ClientRequest = this.createRequest(endpoint, {}, config.applicationName);
|
||||
return this.doPostRequest(connectionRequest, postQuery);
|
||||
}
|
||||
|
||||
public set proxy(agentOptions: AgentOptions) {
|
||||
this._proxy = agentOptions;
|
||||
}
|
||||
private createRequest(endpoint: string, requestOptions: IRequest.Options, applicationName?: string): ClientRequest {
|
||||
if (!requestOptions.headers) {
|
||||
requestOptions.headers = {};
|
||||
}
|
||||
|
||||
private createRequest(endpoint: string, applicationName: string, requestOptions: RequestOptions): ClientRequest {
|
||||
const url = new URL(endpoint);
|
||||
requestOptions.hostname = url.hostname;
|
||||
requestOptions.protocol = url.protocol;
|
||||
requestOptions.port = url.port;
|
||||
requestOptions.path = url.pathname;
|
||||
|
||||
if (this._proxy) {
|
||||
this.agentOptions = {...this._proxy, ...this.agentOptions};
|
||||
}
|
||||
|
||||
if (requestOptions && requestOptions.idempotencyKey) {
|
||||
requestOptions.headers[IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
|
||||
requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
|
||||
delete requestOptions.idempotencyKey;
|
||||
}
|
||||
|
||||
requestOptions.agent = new Agent(this.agentOptions);
|
||||
requestOptions.headers["Cache-Control"] = "no-cache";
|
||||
requestOptions.method = METHOD_POST;
|
||||
requestOptions.headers[ACCEPT_CHARSET] = HttpURLConnectionClient.CHARSET;
|
||||
requestOptions.headers[USER_AGENT] = `${applicationName} ${Client.LIB_NAME}/${Client.LIB_VERSION}`;
|
||||
if (this.proxy && this.proxy.host) {
|
||||
const { host, port, ...options } = this.proxy;
|
||||
requestOptions.agent = new HttpsProxyAgent({ host, port: port || 443, ...options });
|
||||
} else {
|
||||
requestOptions.agent = new Agent(this.agentOptions);
|
||||
}
|
||||
|
||||
return httpRequest(requestOptions);
|
||||
requestOptions.headers["Cache-Control"] = "no-cache";
|
||||
|
||||
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}`;
|
||||
|
||||
return httpsRequest(requestOptions);
|
||||
}
|
||||
|
||||
private getQuery(params: [string, string][]): string {
|
||||
return params.map(([key, value]): string => `${key}=${value}`).join("&");
|
||||
}
|
||||
|
||||
private doPostRequest(httpConnection: ClientRequest, json: string): Promise<string> {
|
||||
private doPostRequest(connectionRequest: ClientRequest, json: string): Promise<HttpClientException | string> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
httpConnection.flushHeaders();
|
||||
connectionRequest.flushHeaders();
|
||||
|
||||
httpConnection.on("response", (res: IncomingMessage): void => {
|
||||
let resData = "";
|
||||
if (res.statusCode && res.statusCode !== 200) {
|
||||
const exception = new HttpClientException(
|
||||
`HTTP Exception: ${res.statusCode}. ${res.statusMessage}`,
|
||||
res.statusCode,
|
||||
res.headers,
|
||||
res,
|
||||
);
|
||||
reject(exception);
|
||||
}
|
||||
res.on("data", (data): void => {
|
||||
resData += data;
|
||||
connectionRequest.on("response", (res: IncomingMessage): void => {
|
||||
const response: { headers: IncomingHttpHeaders; body: string; statusCode: number | undefined } = {
|
||||
statusCode: res.statusCode,
|
||||
headers: res.headers,
|
||||
body: ""
|
||||
};
|
||||
|
||||
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"));
|
||||
}
|
||||
resolve(resData);
|
||||
|
||||
if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
|
||||
try {
|
||||
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({
|
||||
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(response.body);
|
||||
} else {
|
||||
exception = getException(response.body);
|
||||
}
|
||||
} catch (e) {
|
||||
reject(exception);
|
||||
} finally {
|
||||
reject(exception);
|
||||
}
|
||||
}
|
||||
|
||||
resolve(response.body as string);
|
||||
});
|
||||
|
||||
res.on("error", reject);
|
||||
});
|
||||
|
||||
httpConnection.on("timeout", (): void => {
|
||||
httpConnection.abort();
|
||||
connectionRequest.on("timeout", (): void => {
|
||||
connectionRequest.abort();
|
||||
});
|
||||
httpConnection.on("error", reject);
|
||||
httpConnection.write(Buffer.from(json));
|
||||
httpConnection.end();
|
||||
connectionRequest.on("error", (e) => reject(new ApiException(e.message)));
|
||||
connectionRequest.write(Buffer.from(json));
|
||||
connectionRequest.end();
|
||||
});
|
||||
}
|
||||
|
||||
private static setBasicAuthentication(httpConnection: ClientRequest, username: string, password: string): ClientRequest {
|
||||
const authString = `${username}:${password}`;
|
||||
const authEncBytes = new Buffer(authString);
|
||||
const authStringEnc = authEncBytes.toString();
|
||||
|
||||
httpConnection.setHeader("Authorization", `Basic ${authStringEnc}`);
|
||||
return httpConnection;
|
||||
}
|
||||
|
||||
private installCertificateVerifier(terminalCertificatePath: string): void {
|
||||
private installCertificateVerifier(terminalCertificatePath: string): void | Promise<HttpClientException> {
|
||||
try {
|
||||
const certificateInput = fs.readFileSync(terminalCertificatePath);
|
||||
|
||||
this.agentOptions = {
|
||||
ca: certificateInput,
|
||||
checkServerIdentity: (): undefined => {
|
||||
return undefined;
|
||||
},
|
||||
checkServerIdentity,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
throw new HttpClientException(`Error loading certificate from path: ${e.message}`);
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${e.message}` }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default HttpURLConnectionClient;
|
||||
|
||||
@@ -11,15 +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 "./typings";
|
||||
|
||||
export { default as Client } from "./client";
|
||||
export { default as Config } from "./config";
|
||||
export * from "./service/";
|
||||
export * from "./services/";
|
||||
export { hmacValidator } from "./utils";
|
||||
export { default as HttpURLConnectionClient } from "./httpClient/httpURLConnectionClient";
|
||||
|
||||
@@ -11,48 +11,35 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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));
|
||||
this._notificationItemContainers = notification.notificationItems;
|
||||
this._live = notification.live;
|
||||
const notification: Notification = ObjectSerializer.deserialize(json, "Notification");
|
||||
this.notificationItemContainers = notification.notificationItems;
|
||||
this.live = notification.live;
|
||||
}
|
||||
|
||||
public get notificationItemContainers(): NotificationItem[] {
|
||||
return this._notificationItemContainers;
|
||||
}
|
||||
|
||||
public set notificationItemContainers(value: NotificationItem[]) {
|
||||
this._notificationItemContainers = value;
|
||||
}
|
||||
|
||||
public get live(): string {
|
||||
return this._live;
|
||||
}
|
||||
|
||||
public set live(value: string) {
|
||||
this._live = value;
|
||||
}
|
||||
|
||||
public get notificationItems(): NotificationRequestItem[] {
|
||||
if (!this._notificationItemContainers) {
|
||||
return null;
|
||||
public get notificationItems(): NotificationRequestItem[] | undefined {
|
||||
if (!this.notificationItemContainers) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this._notificationItemContainers.map((container): NotificationRequestItem => container.notificationRequestItem);
|
||||
return this.notificationItemContainers.map((container): NotificationRequestItem => container.notificationRequestItem);
|
||||
}
|
||||
|
||||
private _live: string;
|
||||
private _notificationItemContainers: NotificationItem[];
|
||||
public live: string;
|
||||
public notificationItemContainers: NotificationItem[];
|
||||
}
|
||||
|
||||
export default NotificationRequest;
|
||||
@@ -11,29 +11,19 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class InvalidSecurityKeyException implements Error {
|
||||
private readonly _message: string;
|
||||
private readonly _name: string;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
|
||||
public constructor(message: string) {
|
||||
this._message = message;
|
||||
this._name = "InvalidSecurityKeyException";
|
||||
}
|
||||
|
||||
public get message(): string {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public get name(): string {
|
||||
return this._name;
|
||||
this.message = message;
|
||||
this.name = "InvalidSecurityKeyException";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 NexoCryptoException from "../service/exception/nexoCryptoException";
|
||||
import {NEXO_IV_LENGTH} from "../typings/constants/nexoConstants";
|
||||
import { Cipher, createCipheriv, createDecipheriv, createHmac, randomBytes, timingSafeEqual } 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";
|
||||
|
||||
enum Modes {
|
||||
ENCRYPT,
|
||||
@@ -42,9 +40,9 @@ class NexoCrypto {
|
||||
messageHeader: MessageHeader,
|
||||
saleToPoiMessageJson: string,
|
||||
securityKey: SecurityKey,
|
||||
): SaleToPoiSecuredMessage {
|
||||
): SaleToPOISecuredMessage {
|
||||
const derivedKey: NexoDerivedKey = NexoDerivedKeyGenerator.deriveKeyMaterial(securityKey.passphrase);
|
||||
const saleToPoiMessageByteArray = Buffer.from(saleToPoiMessageJson, "ascii");
|
||||
const saleToPoiMessageByteArray = Buffer.from(saleToPoiMessageJson, "utf-8");
|
||||
const ivNonce = NexoCrypto.generateRandomIvNonce();
|
||||
const encryptedSaleToPoiMessage = NexoCrypto.crypt(saleToPoiMessageByteArray, derivedKey, ivNonce, Modes.ENCRYPT);
|
||||
const encryptedSaleToPoiMessageHmac = NexoCrypto.hmac(saleToPoiMessageByteArray, derivedKey);
|
||||
@@ -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");
|
||||
@@ -76,23 +74,23 @@ class NexoCrypto {
|
||||
const receivedHmac = Buffer.from(saleToPoiSecureMessage.securityTrailer.hmac, "base64");
|
||||
this.validateHmac(receivedHmac, decryptedSaleToPoiMessageByteArray, derivedKey);
|
||||
|
||||
return decryptedSaleToPoiMessageByteArray.toString("ascii");
|
||||
return decryptedSaleToPoiMessageByteArray.toString("utf-8");
|
||||
}
|
||||
|
||||
private static validateSecurityKey(securityKey: SecurityKey): void {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
private static crypt(bytes: Buffer, dk: NexoDerivedKey, ivNonce: Buffer, mode: Modes): Buffer {
|
||||
const actualIV = Buffer.alloc(NEXO_IV_LENGTH);
|
||||
for (let i = 0; i < NEXO_IV_LENGTH; i++) {
|
||||
const actualIV = Buffer.alloc(NexoEnum.IV_LENGTH);
|
||||
for (let i = 0; i < NexoEnum.IV_LENGTH; i++) {
|
||||
actualIV[i] = dk.iv[i] ^ ivNonce[i];
|
||||
}
|
||||
|
||||
@@ -111,15 +109,13 @@ class NexoCrypto {
|
||||
}
|
||||
|
||||
private static generateRandomIvNonce(): Buffer {
|
||||
return randomBytes(NEXO_IV_LENGTH);
|
||||
return randomBytes(NexoEnum.IV_LENGTH);
|
||||
}
|
||||
|
||||
private validateHmac(receivedHmac: Buffer, decryptedMessage: Buffer, derivedKey: NexoDerivedKey): void {
|
||||
const hmac = NexoCrypto.hmac(decryptedMessage, derivedKey);
|
||||
|
||||
const isValid = hmac.every((item, index): boolean => item === receivedHmac[index]);
|
||||
|
||||
if (!isValid) {
|
||||
if (!timingSafeEqual(hmac, receivedHmac)) {
|
||||
throw new NexoCryptoException("Hmac validation failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,35 +11,33 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 {NEXO_CIPHER_KEY_LENGTH, NEXO_HMAC_KEY_LENGTH, NEXO_IV_LENGTH} from "../typings/constants/nexoConstants";
|
||||
import { NexoDerivedKey } from "../typings/terminal";
|
||||
import { pbkdf2Sync } from "crypto";
|
||||
import { NexoDerivedKey } from "../typings/terminal/models";
|
||||
import { NexoEnum } from "../constants/nexoConstants";
|
||||
|
||||
class NexoDerivedKeyGenerator {
|
||||
public static deriveKeyMaterial(passphrase: string): NexoDerivedKey {
|
||||
const pass = Buffer.from(passphrase, "binary");
|
||||
const salt = Buffer.from("AdyenNexoV1Salt", "binary");
|
||||
const iterations = 4000;
|
||||
const keylen = NEXO_CIPHER_KEY_LENGTH + NEXO_HMAC_KEY_LENGTH + NEXO_IV_LENGTH;
|
||||
const keylen = NexoEnum.CIPHER_KEY_LENGTH + NexoEnum.HMAC_KEY_LENGTH + NexoEnum.IV_LENGTH;
|
||||
const key = pbkdf2Sync(pass, salt, iterations, keylen * 8, "sha1");
|
||||
return NexoDerivedKeyGenerator.readKeyData(key);
|
||||
}
|
||||
|
||||
private static readKeyData(key: Buffer): NexoDerivedKey {
|
||||
return {
|
||||
cipherKey: key.slice(NEXO_HMAC_KEY_LENGTH, NEXO_HMAC_KEY_LENGTH + NEXO_CIPHER_KEY_LENGTH),
|
||||
hmacKey: key.slice(0, NEXO_HMAC_KEY_LENGTH),
|
||||
cipherKey: key.slice(NexoEnum.HMAC_KEY_LENGTH, NexoEnum.HMAC_KEY_LENGTH + NexoEnum.CIPHER_KEY_LENGTH),
|
||||
hmacKey: key.slice(0, NexoEnum.HMAC_KEY_LENGTH),
|
||||
iv: key.slice(
|
||||
NEXO_HMAC_KEY_LENGTH + NEXO_CIPHER_KEY_LENGTH,
|
||||
NEXO_CIPHER_KEY_LENGTH + NEXO_HMAC_KEY_LENGTH + NEXO_IV_LENGTH,
|
||||
NexoEnum.HMAC_KEY_LENGTH + NexoEnum.CIPHER_KEY_LENGTH,
|
||||
NexoEnum.CIPHER_KEY_LENGTH + NexoEnum.HMAC_KEY_LENGTH + NexoEnum.IV_LENGTH,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,27 +20,11 @@
|
||||
import Client from "./client";
|
||||
|
||||
class Service {
|
||||
protected _apiKeyRequired: boolean = false;
|
||||
private _client: Client;
|
||||
public apiKeyRequired = false;
|
||||
public client: Client;
|
||||
|
||||
protected constructor(client: Client) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
public get client(): Client {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
public set client(client: Client) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
public get apiKeyRequired(): boolean {
|
||||
return this._apiKeyRequired;
|
||||
}
|
||||
|
||||
public set apiKeyRequired(apiKeyRequired: boolean) {
|
||||
this._apiKeyRequired = apiKeyRequired;
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,96 +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 ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import {
|
||||
DetailsRequest, PaymentMethodsRequest, PaymentMethodsResponse, PaymentRequest, PaymentResponse, PaymentSetupRequest,
|
||||
PaymentSetupResponse, PaymentVerificationRequest, PaymentVerificationResponse,
|
||||
} from "../typings/checkout";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import PaymentMethods from "./resource/checkout/paymentMethods";
|
||||
import Payments from "./resource/checkout/payments";
|
||||
import PaymentsDetails from "./resource/checkout/paymentsDetails";
|
||||
import PaymentSession from "./resource/checkout/paymentSession";
|
||||
import PaymentsResult from "./resource/checkout/paymentsResult";
|
||||
|
||||
class Checkout extends ApiKeyAuthenticatedService {
|
||||
private readonly _payments: Payments;
|
||||
private readonly _paymentMethods: PaymentMethods;
|
||||
private readonly _paymentsDetails: PaymentsDetails;
|
||||
private readonly _paymentSession: PaymentSession;
|
||||
private readonly _paymentsResult: PaymentsResult;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._payments = new Payments(this);
|
||||
this._paymentMethods = new PaymentMethods(this);
|
||||
this._paymentsDetails = new PaymentsDetails(this);
|
||||
this._paymentSession = new PaymentSession(this);
|
||||
this._paymentsResult = new PaymentsResult(this);
|
||||
}
|
||||
|
||||
public async payments(
|
||||
paymentsRequest: PaymentRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<PaymentResponse> {
|
||||
return getJsonResponse<PaymentRequest, PaymentResponse>(
|
||||
this._payments,
|
||||
paymentsRequest,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async paymentMethods(paymentMethodsRequest: PaymentMethodsRequest): Promise<PaymentMethodsResponse> {
|
||||
return getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
||||
this._paymentMethods,
|
||||
paymentMethodsRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public async paymentsDetails(paymentsDetailsRequest: DetailsRequest): Promise<PaymentResponse> {
|
||||
return getJsonResponse<DetailsRequest, PaymentResponse>(
|
||||
this._paymentsDetails,
|
||||
paymentsDetailsRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public async paymentSession(
|
||||
paymentSessionRequest: PaymentSetupRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<PaymentSetupResponse> {
|
||||
return getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
||||
this._paymentSession,
|
||||
paymentSessionRequest,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async paymentResult(paymentResultRequest: PaymentVerificationRequest): Promise<PaymentVerificationResponse> {
|
||||
return getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
||||
this._paymentsResult,
|
||||
paymentResultRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
@@ -22,12 +20,6 @@ import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import GetCostEstimate from "./resource/binLookup/getCostEstimate";
|
||||
import Get3dsAvailability from "./resource/binLookup/get3dsAvailability";
|
||||
import {
|
||||
CostEstimateRequest,
|
||||
CostEstimateResponse,
|
||||
ThreeDSAvailabilityRequest,
|
||||
ThreeDSAvailabilityResponse
|
||||
} from "../typings/binLookup";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
|
||||
class BinLookup extends ApiKeyAuthenticatedService {
|
||||
@@ -40,15 +32,15 @@ class BinLookup extends ApiKeyAuthenticatedService {
|
||||
this._getCostEstimate = new GetCostEstimate(this);
|
||||
}
|
||||
|
||||
public async get3dsAvailability(request: ThreeDSAvailabilityRequest): Promise<ThreeDSAvailabilityResponse> {
|
||||
return await getJsonResponse<ThreeDSAvailabilityRequest, ThreeDSAvailabilityResponse>(
|
||||
public get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse> {
|
||||
return getJsonResponse<IBinLookup.ThreeDSAvailabilityRequest, IBinLookup.ThreeDSAvailabilityResponse>(
|
||||
this._get3dsAvailability,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async getCostEstimate(request: CostEstimateRequest): Promise<CostEstimateResponse> {
|
||||
return await getJsonResponse<CostEstimateRequest, CostEstimateResponse>(
|
||||
public getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse> {
|
||||
return getJsonResponse<IBinLookup.CostEstimateRequest, IBinLookup.CostEstimateResponse>(
|
||||
this._getCostEstimate,
|
||||
request
|
||||
);
|
||||
182
src/services/checkout.ts
Normal file
182
src/services/checkout.ts
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* ######
|
||||
* ######
|
||||
* ############ ####( ###### #####. ###### ############ ############
|
||||
* ############# #####( ###### #####. ###### ############# #############
|
||||
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
||||
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
||||
* ############# ############# ############# ############# ##### ######
|
||||
* ############ ############ ############# ############ ##### ######
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
* Adyen NodeJS API Library
|
||||
* Copyright (c) 2020 Adyen B.V.
|
||||
* This file is open source and available under the MIT license.
|
||||
* See the LICENSE file for more info.
|
||||
*/
|
||||
|
||||
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import PaymentMethods from "./resource/checkout/paymentMethods";
|
||||
import Payments from "./resource/checkout/payments";
|
||||
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 {
|
||||
PaymentRequest,
|
||||
PaymentResponse,
|
||||
PaymentMethodsRequest,
|
||||
PaymentMethodsResponse,
|
||||
PaymentLinkResource,
|
||||
CreatePaymentLinkRequest,
|
||||
DetailsRequest,
|
||||
PaymentSetupRequest,
|
||||
PaymentSetupResponse,
|
||||
PaymentVerificationRequest,
|
||||
PaymentVerificationResponse,
|
||||
CheckoutUtilityRequest,
|
||||
CheckoutUtilityResponse,
|
||||
CheckoutBalanceCheckRequest,
|
||||
CheckoutBalanceCheckResponse,
|
||||
CheckoutCreateOrderRequest,
|
||||
CheckoutCreateOrderResponse,
|
||||
CheckoutCancelOrderRequest,
|
||||
CheckoutCancelOrderResponse
|
||||
} from "../typings/checkout/models";
|
||||
|
||||
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;
|
||||
private readonly _paymentMethods: PaymentMethods;
|
||||
private readonly _paymentsDetails: PaymentsDetails;
|
||||
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);
|
||||
this._payments = new Payments(this);
|
||||
this._paymentMethods = new PaymentMethods(this);
|
||||
this._paymentsDetails = new PaymentsDetails(this);
|
||||
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: PaymentRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
return getJsonResponse<PaymentRequest, PaymentResponse>(
|
||||
this._payments,
|
||||
setApplicationInfo(paymentsRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentMethods(paymentMethodsRequest: PaymentMethodsRequest): Promise<PaymentMethodsResponse> {
|
||||
return getJsonResponse<PaymentMethodsRequest, PaymentMethodsResponse>(
|
||||
this._paymentMethods,
|
||||
paymentMethodsRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentLinks(paymentLinkRequest: CreatePaymentLinkRequest): Promise<PaymentLinkResource> {
|
||||
return getJsonResponse<CreatePaymentLinkRequest, PaymentLinkResource>(
|
||||
this._paymentLinks,
|
||||
paymentLinkRequest
|
||||
);
|
||||
}
|
||||
|
||||
public getPaymentLinks(linkId: string): Promise<PaymentLinkResource> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<{}, PaymentLinkResource>(
|
||||
this._paymentLinksId,
|
||||
{},
|
||||
{ method: "GET" }
|
||||
);
|
||||
}
|
||||
|
||||
public updatePaymentLinks(linkId: string, status: "expired"): Promise<PaymentLinkResource> {
|
||||
this._paymentLinksId.id = linkId;
|
||||
return getJsonResponse<{}, PaymentLinkResource>(
|
||||
this._paymentLinksId,
|
||||
{ status },
|
||||
{ method: "PATCH" }
|
||||
);
|
||||
}
|
||||
|
||||
public paymentsDetails(paymentsDetailsRequest: DetailsRequest, requestOptions?: IRequest.Options): Promise<PaymentResponse> {
|
||||
return getJsonResponse<DetailsRequest, PaymentResponse>(
|
||||
this._paymentsDetails,
|
||||
paymentsDetailsRequest,
|
||||
requestOptions
|
||||
);
|
||||
}
|
||||
|
||||
public paymentSession(
|
||||
paymentSessionRequest: PaymentSetupRequest,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<PaymentSetupResponse> {
|
||||
return getJsonResponse<PaymentSetupRequest, PaymentSetupResponse>(
|
||||
this._paymentSession,
|
||||
paymentSessionRequest,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentResult(paymentResultRequest: PaymentVerificationRequest): Promise<PaymentVerificationResponse> {
|
||||
return getJsonResponse<PaymentVerificationRequest, PaymentVerificationResponse>(
|
||||
this._paymentsResult,
|
||||
paymentResultRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public originKeys(originKeysRequest: CheckoutUtilityRequest): Promise<CheckoutUtilityResponse> {
|
||||
return getJsonResponse<CheckoutUtilityRequest, CheckoutUtilityResponse>(
|
||||
this._originKeys,
|
||||
originKeysRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public paymentMethodsBalance(paymentMethodsBalanceRequest: CheckoutBalanceCheckRequest): Promise<CheckoutBalanceCheckResponse> {
|
||||
return getJsonResponse<CheckoutBalanceCheckRequest, CheckoutBalanceCheckResponse>(
|
||||
this._paymentMethodsBalance,
|
||||
paymentMethodsBalanceRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public orders(ordersRequest: CheckoutCreateOrderRequest): Promise<CheckoutCreateOrderResponse> {
|
||||
return getJsonResponse<CheckoutCreateOrderRequest, CheckoutCreateOrderResponse>(
|
||||
this._orders,
|
||||
ordersRequest,
|
||||
);
|
||||
}
|
||||
|
||||
public ordersCancel(ordersCancelRequest: CheckoutCancelOrderRequest): Promise<CheckoutCancelOrderResponse> {
|
||||
return getJsonResponse<CheckoutCancelOrderRequest, CheckoutCancelOrderResponse>(
|
||||
this._ordersCancel,
|
||||
ordersCancelRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
@@ -22,39 +20,15 @@
|
||||
import { ApiError } from "../../typings/apiError";
|
||||
|
||||
class ApiException implements Error {
|
||||
private _error: ApiError;
|
||||
private _statusCode: number;
|
||||
private readonly _message: string;
|
||||
private readonly _name: string;
|
||||
public error!: ApiError;
|
||||
public statusCode: number;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
|
||||
public constructor(message: string, statusCode: number) {
|
||||
this._name = "ApiException";
|
||||
this._message = message;
|
||||
this._statusCode = statusCode;
|
||||
}
|
||||
|
||||
public get error(): ApiError {
|
||||
return this._error;
|
||||
}
|
||||
|
||||
public set error(error: ApiError) {
|
||||
this._error = error;
|
||||
}
|
||||
|
||||
public get statusCode(): number {
|
||||
return this._statusCode;
|
||||
}
|
||||
|
||||
public set statusCode(statusCode: number) {
|
||||
this._statusCode = statusCode;
|
||||
}
|
||||
|
||||
public get message(): string {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public get name(): string {
|
||||
return this._name;
|
||||
public constructor(message: string, statusCode = 500) {
|
||||
this.name = "ApiException";
|
||||
this.message = message;
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,29 +11,19 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class NexoCryptoException implements Error {
|
||||
private readonly _message: string;
|
||||
private readonly _name: string;
|
||||
public readonly message: string;
|
||||
public readonly name: string;
|
||||
|
||||
public constructor(message: string) {
|
||||
this._name = "NexoCryptoException";
|
||||
this._message = message;
|
||||
}
|
||||
|
||||
public get message(): string {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public get name(): string {
|
||||
return this._name;
|
||||
this.name = "NexoCryptoException";
|
||||
this.message = 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.
|
||||
*/
|
||||
@@ -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,24 +11,26 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
import { ModificationRequest, ModificationResult } from "../typings/payments";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import AdjustAuthorisation from "./resource/modification/adjustAuthorisation";
|
||||
import Cancel from "./resource/modification/cancel";
|
||||
import CancelOrRefund from "./resource/modification/cancelOrRefund";
|
||||
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";
|
||||
|
||||
interface AppInfo { applicationInfo?: ApplicationInfo }
|
||||
type GenericRequest<T> = T & AppInfo;
|
||||
|
||||
class Modification extends Service {
|
||||
private readonly _cancelOrRefund: CancelOrRefund;
|
||||
@@ -48,68 +50,68 @@ class Modification extends Service {
|
||||
this._technicalCancel = new TechnicalCancel(this);
|
||||
}
|
||||
|
||||
public async capture(
|
||||
captureRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public capture(
|
||||
captureRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._capture,
|
||||
captureRequest,
|
||||
setApplicationInfo(captureRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async cancelOrRefund(
|
||||
cancelOrRefundRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public cancelOrRefund(
|
||||
cancelOrRefundRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._cancelOrRefund,
|
||||
cancelOrRefundRequest,
|
||||
setApplicationInfo(cancelOrRefundRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async refund(
|
||||
refundRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public refund(
|
||||
refundRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._refund,
|
||||
refundRequest,
|
||||
setApplicationInfo(refundRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async cancel(
|
||||
cancelRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public cancel(
|
||||
cancelRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._cancel,
|
||||
cancelRequest,
|
||||
setApplicationInfo(cancelRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async technicalCancel(
|
||||
technicalCancelRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public technicalCancel(
|
||||
technicalCancelRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._technicalCancel,
|
||||
technicalCancelRequest,
|
||||
setApplicationInfo(technicalCancelRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public async adjustAuthorisation(
|
||||
adjustAuthorisationRequest: ModificationRequest,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<ModificationResult> {
|
||||
return await getJsonResponse<ModificationRequest, ModificationResult>(
|
||||
public adjustAuthorisation(
|
||||
adjustAuthorisationRequest: GenericRequest<IPayments.ModificationRequest>,
|
||||
requestOptions?: IRequest.Options,
|
||||
): Promise<IPayments.ModificationResult> {
|
||||
return getJsonResponse<IPayments.ModificationRequest, IPayments.ModificationResult>(
|
||||
this._adjustAuthorisation,
|
||||
adjustAuthorisationRequest,
|
||||
setApplicationInfo(adjustAuthorisationRequest),
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
@@ -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,13 +22,8 @@ import DeclineThirdParty from "./resource/payout/declineThirdParty";
|
||||
import StoreDetail from "./resource/payout/storeDetail";
|
||||
import SubmitThirdParty from "./resource/payout/submitThirdParty";
|
||||
import ConfirmThirdParty from "./resource/payout/confirmThirdParty";
|
||||
import PayoutResource from "./resource/payout/payout";
|
||||
import StoreDetailAndSubmitThirdParty from "./resource/payout/storeDetailAndSubmitThirdParty";
|
||||
import {
|
||||
ModifyRequest,
|
||||
ModifyResponse,
|
||||
StoreDetailAndSubmitRequest,
|
||||
StoreDetailAndSubmitResponse, StoreDetailRequest, StoreDetailResponse, SubmitRequest, SubmitResponse
|
||||
} from "../typings/payout";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
|
||||
class Payout extends Service {
|
||||
@@ -39,6 +32,7 @@ class Payout extends Service {
|
||||
private readonly _declineThirdParty: DeclineThirdParty;
|
||||
private readonly _storeDetail: StoreDetail;
|
||||
private readonly _submitThirdParty: SubmitThirdParty;
|
||||
private readonly _payout: PayoutResource;
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
@@ -48,42 +42,50 @@ class Payout extends Service {
|
||||
this._declineThirdParty = new DeclineThirdParty(this);
|
||||
this._storeDetail = new StoreDetail(this);
|
||||
this._submitThirdParty = new SubmitThirdParty(this);
|
||||
this._payout = new PayoutResource(this);
|
||||
}
|
||||
|
||||
public async storeDetailAndSubmitThirdParty(request: StoreDetailAndSubmitRequest): Promise<StoreDetailAndSubmitResponse> {
|
||||
return await getJsonResponse<StoreDetailAndSubmitRequest, StoreDetailAndSubmitResponse>(
|
||||
public storeDetailAndSubmitThirdParty(request: IPayouts.StoreDetailAndSubmitRequest): Promise<IPayouts.StoreDetailAndSubmitResponse> {
|
||||
return getJsonResponse<IPayouts.StoreDetailAndSubmitRequest, IPayouts.StoreDetailAndSubmitResponse>(
|
||||
this._storeDetailAndSubmitThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async confirmThirdParty(request: ModifyRequest): Promise<ModifyResponse> {
|
||||
return await getJsonResponse<ModifyRequest, ModifyResponse>(
|
||||
public confirmThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse> {
|
||||
return getJsonResponse<IPayouts.ModifyRequest, IPayouts.ModifyResponse>(
|
||||
this._confirmThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async declineThirdParty(request: ModifyRequest): Promise<ModifyResponse> {
|
||||
return await getJsonResponse<ModifyRequest, ModifyResponse>(
|
||||
public declineThirdParty(request: IPayouts.ModifyRequest): Promise<IPayouts.ModifyResponse> {
|
||||
return getJsonResponse<IPayouts.ModifyRequest, IPayouts.ModifyResponse>(
|
||||
this._declineThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async storeDetail(request: StoreDetailRequest): Promise<StoreDetailResponse> {
|
||||
return await getJsonResponse<StoreDetailRequest, StoreDetailResponse>(
|
||||
public storeDetail(request: IPayouts.StoreDetailRequest): Promise<IPayouts.StoreDetailResponse> {
|
||||
return getJsonResponse<IPayouts.StoreDetailRequest, IPayouts.StoreDetailResponse>(
|
||||
this._storeDetail,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public async submitThirdparty(request: SubmitRequest): Promise<SubmitResponse> {
|
||||
return await getJsonResponse<SubmitRequest, SubmitResponse>(
|
||||
public submitThirdparty(request: IPayouts.SubmitRequest): Promise<IPayouts.SubmitResponse> {
|
||||
return getJsonResponse<IPayouts.SubmitRequest, IPayouts.SubmitResponse>(
|
||||
this._submitThirdParty,
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
public payout(request: IPayouts.PayoutRequest): Promise<IPayouts.PayoutResponse> {
|
||||
return getJsonResponse<IPayouts.PayoutRequest, IPayouts.PayoutResponse>(
|
||||
this._payout,
|
||||
request
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Payout;
|
||||
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.
|
||||
*/
|
||||
@@ -22,33 +20,62 @@
|
||||
import Client from "../client";
|
||||
import getJsonResponse from "../helpers/getJsonResponse";
|
||||
import Service from "../service";
|
||||
import { DisableRequest, DisableResult, RecurringDetailsRequest, RecurringDetailsResult } from "../typings/recurring";
|
||||
import Disable from "./resource/recurring/disable";
|
||||
import ListRecurringDetails from "./resource/recurring/listRecurringDetails";
|
||||
import ScheduleAccountUpdater from "./resource/recurring/scheduleAccountUpdater";
|
||||
import NotifyShopper from "./resource/recurring/notifyShopper";
|
||||
import {
|
||||
RecurringDetailsRequest,
|
||||
RecurringDetailsResult,
|
||||
DisableRequest,
|
||||
DisableResult,
|
||||
ScheduleAccountUpdaterRequest,
|
||||
ScheduleAccountUpdaterResult,
|
||||
NotifyShopperRequest,
|
||||
NotifyShopperResult
|
||||
} from "../typings/recurring/models";
|
||||
|
||||
class Recurring extends Service {
|
||||
private readonly _listRecurringDetails: ListRecurringDetails;
|
||||
private readonly _disable: Disable;
|
||||
private readonly _scheduleAccountUpdater: ScheduleAccountUpdater;
|
||||
private readonly _notifyShopper: NotifyShopper
|
||||
|
||||
public constructor(client: Client) {
|
||||
super(client);
|
||||
this._listRecurringDetails = new ListRecurringDetails(this);
|
||||
this._disable = new Disable(this);
|
||||
this._scheduleAccountUpdater = new ScheduleAccountUpdater(this);
|
||||
this._notifyShopper = new NotifyShopper(this);
|
||||
}
|
||||
|
||||
public async listRecurringDetails(request: RecurringDetailsRequest): Promise<RecurringDetailsResult> {
|
||||
return await getJsonResponse<RecurringDetailsRequest, RecurringDetailsResult>(
|
||||
public listRecurringDetails(request: RecurringDetailsRequest): Promise<RecurringDetailsResult> {
|
||||
return getJsonResponse<RecurringDetailsRequest, RecurringDetailsResult>(
|
||||
this._listRecurringDetails,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public async disable(request: DisableRequest): Promise<DisableResult> {
|
||||
return await getJsonResponse<DisableRequest, DisableResult>(
|
||||
public disable(request: DisableRequest): Promise<DisableResult> {
|
||||
return getJsonResponse<DisableRequest, DisableResult>(
|
||||
this._disable,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public scheduleAccountUpdater(request: ScheduleAccountUpdaterRequest): Promise<ScheduleAccountUpdaterResult> {
|
||||
return getJsonResponse<ScheduleAccountUpdaterRequest, ScheduleAccountUpdaterResult>(
|
||||
this._scheduleAccountUpdater,
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
public notifyShopper(request: NotifyShopperRequest): Promise<NotifyShopperResult> {
|
||||
return getJsonResponse<NotifyShopperRequest, NotifyShopperResult>(
|
||||
this._notifyShopper,
|
||||
request
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Recurring;
|
||||
@@ -11,54 +11,38 @@
|
||||
* ######
|
||||
* #############
|
||||
* ############
|
||||
*
|
||||
* 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 ClientInterface from "../httpClient/clientInterface";
|
||||
import Service from "../service";
|
||||
import { RequestOptions } from "../typings/requestOptions";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
import ApiException from "./exception/apiException";
|
||||
import ClientInterface from "../httpClient/clientInterface";
|
||||
import { IRequest } from "../typings/requestOptions";
|
||||
|
||||
class Resource {
|
||||
abstract class Resource {
|
||||
protected endpoint: string;
|
||||
private service: Service;
|
||||
|
||||
public constructor(service: Service, endpoint: string) {
|
||||
protected constructor(service: Service, endpoint: string) {
|
||||
this.service = service;
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public async request(json: string, requestOptions?: RequestOptions): Promise<string> {
|
||||
public request(json: string, requestOptions?: IRequest.Options): Promise<string | HttpClientException | ApiException> {
|
||||
const clientInterface: ClientInterface = this.service.client.httpClient;
|
||||
const config: Config = this.service.client.config;
|
||||
let responseBody;
|
||||
let apiException: ApiException;
|
||||
|
||||
try {
|
||||
return await clientInterface.request(
|
||||
this.endpoint,
|
||||
json, config,
|
||||
this.service.apiKeyRequired,
|
||||
requestOptions,
|
||||
);
|
||||
} catch (e) {
|
||||
responseBody = e.responseBody;
|
||||
apiException = new ApiException(e.message, e.code);
|
||||
}
|
||||
|
||||
try {
|
||||
apiException.error = responseBody;
|
||||
} catch (e) {
|
||||
throw new ApiException("Invalid response or an invalid X-API-Key key was used", e.statusCode);
|
||||
}
|
||||
|
||||
throw apiException;
|
||||
return clientInterface.request(
|
||||
this.endpoint,
|
||||
json, config,
|
||||
this.service.apiKeyRequired,
|
||||
requestOptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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`,
|
||||
);
|
||||
}
|
||||
}
|
||||
33
src/services/resource/checkout/paymentLinks.ts
Normal file
33
src/services/resource/checkout/paymentLinks.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 PaymentLinks extends Resource {
|
||||
public constructor(service: Service) {
|
||||
super(
|
||||
service,
|
||||
`${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default PaymentLinks;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user