@@ -2,8 +2,9 @@ import nock from "nock";
2
2
import { createClient } from "../__mocks__/base" ;
3
3
import Client from "../client" ;
4
4
import ClassicIntegration from "../services/paymentApi" ;
5
- import { payments } from "../typings" ;
5
+ import { payment } from "../typings" ;
6
6
import HttpClientException from "../httpClient/httpClientException" ;
7
+ import { PaymentResult } from "../typings/payment/paymentResult" ;
7
8
8
9
let client : Client ;
9
10
let classicIntegration : ClassicIntegration ;
@@ -35,7 +36,7 @@ describe("Classic Integration", (): void => {
35
36
"authCode" : "011381"
36
37
}
37
38
) ;
38
- const paymentRequest : payments . PaymentRequest = {
39
+ const paymentRequest : payment . PaymentRequest = {
39
40
"card" : {
40
41
"number" : "4111111111111111" ,
41
42
"expiryMonth" : "03" ,
@@ -51,7 +52,7 @@ describe("Classic Integration", (): void => {
51
52
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
52
53
} ;
53
54
54
- const paymentResult : payments . PaymentResult = await classicIntegration . authorise ( paymentRequest ) ;
55
+ const paymentResult : PaymentResult = await classicIntegration . authorise ( paymentRequest ) ;
55
56
expect ( paymentResult . pspReference ) . toEqual ( "JVBXGSDM53RZNN82" ) ;
56
57
} ) ;
57
58
@@ -65,7 +66,7 @@ describe("Classic Integration", (): void => {
65
66
"errorType" : "security"
66
67
}
67
68
) ;
68
- const paymentRequest : payments . PaymentRequest = {
69
+ const paymentRequest : payment . PaymentRequest = {
69
70
"card" : {
70
71
"number" : "4111111111111111" ,
71
72
"expiryMonth" : "03" ,
@@ -104,14 +105,14 @@ describe("Classic Integration", (): void => {
104
105
"authCode" : "011381"
105
106
}
106
107
) ;
107
- const paymentRequest : payments . PaymentRequest3d = {
108
+ const paymentRequest : payment . PaymentRequest3d = {
108
109
"md" : "31h..........vOXek7w" ,
109
110
"paResponse" : "eNqtmF........wGVA4Ch" ,
110
111
"shopperIP" : "61.294.12.12" ,
111
112
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
112
113
} ;
113
114
114
- const paymentResult : payments . PaymentResult = await classicIntegration . authorise3d ( paymentRequest ) ;
115
+ const paymentResult : payment . PaymentResult = await classicIntegration . authorise3d ( paymentRequest ) ;
115
116
expect ( paymentResult . pspReference ) . toEqual ( "JVBXGSDM53RZNN82" ) ;
116
117
} ) ;
117
118
@@ -127,7 +128,7 @@ describe("Classic Integration", (): void => {
127
128
"authCode" : "011381"
128
129
}
129
130
) ;
130
- const paymentRequest : payments . PaymentRequest3ds2 = {
131
+ const paymentRequest : payment . PaymentRequest3ds2 = {
131
132
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT" ,
132
133
"amount" : {
133
134
"value" : 1500 ,
@@ -141,7 +142,7 @@ describe("Classic Integration", (): void => {
141
142
"threeDS2Token" : "— - BINARY DATA - -"
142
143
} ;
143
144
144
- const paymentResult : payments . PaymentResult = await classicIntegration . authorise3ds2 ( paymentRequest ) ;
145
+ const paymentResult : payment . PaymentResult = await classicIntegration . authorise3ds2 ( paymentRequest ) ;
145
146
expect ( paymentResult . pspReference ) . toEqual ( "JVBXGSDM53RZNN82" ) ;
146
147
} ) ;
147
148
@@ -150,25 +151,25 @@ describe("Classic Integration", (): void => {
150
151
"threeDS2Result" : { "authenticationValue" : "THREEDS2RESULT" }
151
152
} ) ;
152
153
153
- const getAuthenticationResultrequest : payments . AuthenticationResultRequest = {
154
+ const getAuthenticationResultrequest : payment . AuthenticationResultRequest = {
154
155
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT" ,
155
156
"pspReference" : "9935272408535455"
156
157
} ;
157
158
158
- const getAuthenticationResultResponse : payments . AuthenticationResultResponse = await classicIntegration . getAuthenticationResult ( getAuthenticationResultrequest ) ;
159
+ const getAuthenticationResultResponse : payment . AuthenticationResultResponse = await classicIntegration . getAuthenticationResult ( getAuthenticationResultrequest ) ;
159
160
expect ( getAuthenticationResultResponse ?. threeDS2Result ?. authenticationValue ) . toEqual ( "THREEDS2RESULT" ) ;
160
161
} ) ;
161
162
162
163
test ( "Should retrieve 3DS2 result" , async ( ) : Promise < void > => {
163
164
scope . post ( "/retrieve3ds2Result" ) . reply ( 200 , {
164
165
"threeDS2Result" : { "authenticationValue" : "THREEDS2RESULT" }
165
166
} ) ;
166
- const retrieve3ds2ResultRequest : payments . ThreeDS2ResultRequest = {
167
+ const retrieve3ds2ResultRequest : payment . ThreeDS2ResultRequest = {
167
168
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT" ,
168
169
"pspReference" : "9935272408535455"
169
170
} ;
170
171
171
- const retrieve3ds2ResultResponse : payments . ThreeDS2ResultResponse = await classicIntegration . retrieve3ds2Result ( retrieve3ds2ResultRequest ) ;
172
+ const retrieve3ds2ResultResponse : payment . ThreeDS2ResultResponse = await classicIntegration . retrieve3ds2Result ( retrieve3ds2ResultRequest ) ;
172
173
expect ( retrieve3ds2ResultResponse ?. threeDS2Result ?. authenticationValue ) . toEqual ( "THREEDS2RESULT" ) ;
173
174
} ) ;
174
175
@@ -179,7 +180,7 @@ describe("Classic Integration", (): void => {
179
180
"response" : "[capture-received]"
180
181
} ) ;
181
182
182
- const modificationRequest : payments . CaptureRequest = {
183
+ const modificationRequest : payment . CaptureRequest = {
183
184
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
184
185
"modificationAmount" : {
185
186
"value" : 500 ,
@@ -189,8 +190,8 @@ describe("Classic Integration", (): void => {
189
190
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
190
191
} ;
191
192
192
- const modificationResult : payments . ModificationResult = await classicIntegration . capture ( modificationRequest ) ;
193
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . CaptureReceived ) ;
193
+ const modificationResult : payment . ModificationResult = await classicIntegration . capture ( modificationRequest ) ;
194
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . CaptureReceived ) ;
194
195
} ) ;
195
196
196
197
test ( "Should successfully send Cancel request" , async ( ) : Promise < void > => {
@@ -200,14 +201,14 @@ describe("Classic Integration", (): void => {
200
201
"response" : "[cancel-received]"
201
202
} ) ;
202
203
203
- const modificationRequest : payments . CancelRequest = {
204
+ const modificationRequest : payment . CancelRequest = {
204
205
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
205
206
"reference" : "YourModificationReference" ,
206
207
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
207
208
} ;
208
209
209
- const modificationResult : payments . ModificationResult = await classicIntegration . cancel ( modificationRequest ) ;
210
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . CancelReceived ) ;
210
+ const modificationResult : payment . ModificationResult = await classicIntegration . cancel ( modificationRequest ) ;
211
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . CancelReceived ) ;
211
212
} ) ;
212
213
213
214
test ( "Should successfully send Refund request" , async ( ) : Promise < void > => {
@@ -217,7 +218,7 @@ describe("Classic Integration", (): void => {
217
218
"response" : "[refund-received]"
218
219
} ) ;
219
220
220
- const modificationRequest : payments . RefundRequest = {
221
+ const modificationRequest : payment . RefundRequest = {
221
222
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
222
223
"modificationAmount" : {
223
224
"value" : 500 ,
@@ -227,8 +228,8 @@ describe("Classic Integration", (): void => {
227
228
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
228
229
} ;
229
230
230
- const modificationResult : payments . ModificationResult = await classicIntegration . refund ( modificationRequest ) ;
231
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . RefundReceived ) ;
231
+ const modificationResult : payment . ModificationResult = await classicIntegration . refund ( modificationRequest ) ;
232
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . RefundReceived ) ;
232
233
} ) ;
233
234
234
235
test ( "Should successfully send CancelOrRefund request" , async ( ) : Promise < void > => {
@@ -238,14 +239,14 @@ describe("Classic Integration", (): void => {
238
239
"response" : "[cancelOrRefund-received]"
239
240
} ) ;
240
241
241
- const modificationRequest : payments . CancelOrRefundRequest = {
242
+ const modificationRequest : payment . CancelOrRefundRequest = {
242
243
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
243
244
"reference" : "YourModificationReference" ,
244
245
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
245
246
} ;
246
247
247
- const modificationResult : payments . ModificationResult = await classicIntegration . cancelOrRefund ( modificationRequest ) ;
248
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . CancelOrRefundReceived ) ;
248
+ const modificationResult : payment . ModificationResult = await classicIntegration . cancelOrRefund ( modificationRequest ) ;
249
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . CancelOrRefundReceived ) ;
249
250
} ) ;
250
251
251
252
test ( "Should successfully send TechnicalCancel request" , async ( ) : Promise < void > => {
@@ -255,7 +256,7 @@ describe("Classic Integration", (): void => {
255
256
"response" : "[technical-cancel-received]"
256
257
} ) ;
257
258
258
- const modificationRequest : payments . TechnicalCancelRequest = {
259
+ const modificationRequest : payment . TechnicalCancelRequest = {
259
260
"originalMerchantReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
260
261
"modificationAmount" : {
261
262
"value" : 500 ,
@@ -265,8 +266,8 @@ describe("Classic Integration", (): void => {
265
266
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
266
267
} ;
267
268
268
- const modificationResult : payments . ModificationResult = await classicIntegration . technicalCancel ( modificationRequest ) ;
269
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . TechnicalCancelReceived ) ;
269
+ const modificationResult : payment . ModificationResult = await classicIntegration . technicalCancel ( modificationRequest ) ;
270
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . TechnicalCancelReceived ) ;
270
271
} ) ;
271
272
272
273
test ( "Should successfully send AdjustAuthorisation request" , async ( ) : Promise < void > => {
@@ -276,7 +277,7 @@ describe("Classic Integration", (): void => {
276
277
"response" : "[adjustAuthorisation-received]"
277
278
} ) ;
278
279
279
- const modificationRequest : payments . AdjustAuthorisationRequest = {
280
+ const modificationRequest : payment . AdjustAuthorisationRequest = {
280
281
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
281
282
"modificationAmount" : {
282
283
"value" : 500 ,
@@ -286,8 +287,8 @@ describe("Classic Integration", (): void => {
286
287
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
287
288
} ;
288
289
289
- const modificationResult : payments . ModificationResult = await classicIntegration . adjustAuthorisation ( modificationRequest ) ;
290
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . AdjustAuthorisationReceived ) ;
290
+ const modificationResult : payment . ModificationResult = await classicIntegration . adjustAuthorisation ( modificationRequest ) ;
291
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . AdjustAuthorisationReceived ) ;
291
292
} ) ;
292
293
293
294
test ( "Should successfully send Donate request" , async ( ) : Promise < void > => {
@@ -297,7 +298,7 @@ describe("Classic Integration", (): void => {
297
298
"response" : "[donation-received]"
298
299
} ) ;
299
300
300
- const modificationRequest : payments . DonationRequest = {
301
+ const modificationRequest : payment . DonationRequest = {
301
302
"originalReference" : "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE" ,
302
303
"modificationAmount" : {
303
304
"value" : 500 ,
@@ -308,8 +309,8 @@ describe("Classic Integration", (): void => {
308
309
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT"
309
310
} ;
310
311
311
- const modificationResult : payments . ModificationResult = await classicIntegration . donate ( modificationRequest ) ;
312
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . DonationReceived ) ;
312
+ const modificationResult : payment . ModificationResult = await classicIntegration . donate ( modificationRequest ) ;
313
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . DonationReceived ) ;
313
314
} ) ;
314
315
315
316
test ( "Should successfully send VoidPendingRefund request" , async ( ) : Promise < void > => {
@@ -319,13 +320,13 @@ describe("Classic Integration", (): void => {
319
320
"response" : "[voidPendingRefund-received]"
320
321
} ) ;
321
322
322
- const modificationRequest : payments . VoidPendingRefundRequest = {
323
+ const modificationRequest : payment . VoidPendingRefundRequest = {
323
324
"merchantAccount" : "YOUR_MERCHANT_ACCOUNT" ,
324
325
"tenderReference" : "5Iw8001176969533005" ,
325
326
"uniqueTerminalId" : "VX820-123456789"
326
327
} ;
327
328
328
- const modificationResult : payments . ModificationResult = await classicIntegration . voidPendingRefund ( modificationRequest ) ;
329
- expect ( modificationResult . response ) . toEqual ( payments . ModificationResult . ResponseEnum . VoidPendingRefundReceived ) ;
329
+ const modificationResult : payment . ModificationResult = await classicIntegration . voidPendingRefund ( modificationRequest ) ;
330
+ expect ( modificationResult . response ) . toEqual ( payment . ModificationResult . ResponseEnum . VoidPendingRefundReceived ) ;
330
331
} ) ;
331
332
} ) ;
0 commit comments