@@ -2,7 +2,9 @@ import nock from "nock";
2
2
import { createClient } from "../__mocks__/base" ;
3
3
import { paymentMethodsSuccess } from "../__mocks__/checkout/paymentMethodsSuccess" ;
4
4
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess" ;
5
+ import { paymentsRedirectAction } from "../__mocks__/checkout/paymentsRedirectAction" ;
5
6
import { paymentDetailsSuccess } from "../__mocks__/checkout/paymentsDetailsSuccess" ;
7
+ import { PaymentResponseActionClass } from "../typings/checkout/paymentResponseAction" ;
6
8
// import {paymentSessionSuccess} from "../__mocks__/checkout/paymentSessionSucess";
7
9
import { originKeysSuccess } from "../__mocks__/checkout/originkeysSuccess" ;
8
10
import { paymentsResultMultibancoSuccess } from "../__mocks__/checkout/paymentsResultMultibancoSuccess" ;
@@ -14,6 +16,8 @@ import HttpClientException from "../httpClient/httpClientException";
14
16
import { checkout } from "../typings" ;
15
17
import { IRequest } from "../typings/requestOptions" ;
16
18
import { SessionResultResponse } from "../typings/checkout/sessionResultResponse" ;
19
+ import { payments3DS2NativeAction } from "../__mocks__/checkout/payments3DS2NativeAction" ;
20
+ import { CheckoutThreeDS2Action } from "../typings/checkout/checkoutThreeDS2Action" ;
17
21
18
22
const merchantAccount = process . env . ADYEN_MERCHANT ! ;
19
23
const reference = "Your order number" ;
@@ -154,7 +158,7 @@ describe("Checkout", (): void => {
154
158
"returnUrl": "https://your-company.com/...",
155
159
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
156
160
}` ) ;
157
- const paymentRequest : checkout . PaymentRequest = await checkout . ObjectSerializer . deserialize ( requestJson , "PaymentRequest" ) ;
161
+ const paymentRequest : checkout . PaymentRequest = await checkout . ObjectSerializer . deserialize ( requestJson , "PaymentRequest" , " ") ;
158
162
expect ( paymentRequest . returnUrl ) . toEqual ( "https://your-company.com/..." ) ;
159
163
expect ( paymentRequest . amount . value ) . toBe ( 1000 ) ;
160
164
const paymentMethodDetails : checkout . ApplePayDetails = paymentRequest . paymentMethod as checkout . ApplePayDetails ;
@@ -239,7 +243,6 @@ describe("Checkout", (): void => {
239
243
240
244
} ) ;
241
245
242
-
243
246
test ( "should make a payment." , async ( ) : Promise < void > => {
244
247
scope . post ( "/payments" )
245
248
. reply ( 200 , paymentsSuccess ) ;
@@ -401,6 +404,46 @@ describe("Checkout", (): void => {
401
404
expect ( paymentsResponse . additionalData ) . toBeTruthy ( ) ;
402
405
} ) ;
403
406
407
+ test ( "should return shopper redirect with a card payment." , async ( ) : Promise < void > => {
408
+ scope . post ( "/payments" )
409
+ . reply ( 200 , paymentsRedirectAction ) ;
410
+
411
+ const paymentsRequest : checkout . PaymentRequest = createPaymentsCheckoutRequest ( ) ;
412
+ const paymentsResponse : checkout . PaymentResponse = await checkoutService . PaymentsApi . payments ( paymentsRequest ) ;
413
+
414
+ expect ( paymentsResponse . pspReference ) . toBeTruthy ( ) ;
415
+ expect ( paymentsResponse . resultCode ) . toBeTruthy ( ) ;
416
+ expect ( paymentsResponse . resultCode ) . toEqual ( "RedirectShopper" ) ;
417
+ // check action is polymorphic
418
+ expect ( paymentsResponse . action ) . toBeTruthy ( ) ;
419
+ expect ( paymentsResponse . action ) . toBeInstanceOf ( PaymentResponseActionClass ) ;
420
+ // check is redirect
421
+ expect ( paymentsResponse . action ?. type ) . toBeTruthy ( ) ;
422
+ expect ( paymentsResponse . action ?. type ) . toEqual ( "redirect" ) ;
423
+ expect ( paymentsResponse . action ?. url ) . toBe ( "https://checkoutshopper-test.adyen.com/checkoutshopper/threeDS/redirect..." ) ;
424
+
425
+ } ) ;
426
+
427
+ test . only ( "should return Native 3DS2 with a card payment." , async ( ) : Promise < void > => {
428
+ scope . post ( "/payments" )
429
+ . reply ( 200 , payments3DS2NativeAction ) ;
430
+
431
+ const paymentsRequest : checkout . PaymentRequest = createPaymentsCheckoutRequest ( ) ;
432
+ const paymentsResponse : checkout . PaymentResponse = await checkoutService . PaymentsApi . payments ( paymentsRequest ) ;
433
+
434
+ expect ( paymentsResponse . pspReference ) . toBeTruthy ( ) ;
435
+ expect ( paymentsResponse . resultCode ) . toBeTruthy ( ) ;
436
+ expect ( paymentsResponse . resultCode ) . toEqual ( "IdentifyShopper" ) ;
437
+ // check action is polymorphic
438
+ expect ( paymentsResponse . action ) . toBeTruthy ( ) ;
439
+ expect ( paymentsResponse . action ) . toBeInstanceOf ( CheckoutThreeDS2Action ) ;
440
+ // check is threeDS2
441
+ expect ( paymentsResponse . action ?. type ) . toBeTruthy ( ) ;
442
+ expect ( paymentsResponse . action ?. type ) . toEqual ( "threeDS2" ) ;
443
+ expect ( paymentsResponse . action ?. subtype ) . toEqual ( "threeDS2" ) ;
444
+
445
+ } ) ;
446
+
404
447
test ( "should get origin keys" , async ( ) : Promise < void > => {
405
448
const checkoutUtility = new CheckoutAPI ( client ) ;
406
449
const originKeysRequest : checkout . UtilityRequest = {
0 commit comments