DefaultWorldpayDirectOrderFacade implements WorldpayDirectOrderFacade { @Override public DirectResponseData authoriseRecurringPayment(final WorldpayAdditionalInfoData worldpayAdditionalInfoData) throws WorldpayException, InvalidCartException { Preconditions.checkState(cartService.hasSessionCart(), CANNOT_AUTHORIZE_PAYMENT_WHERE_THERE_IS_NO_CART_MESSAGE); final CartModel cart = cartService.getSessionCart(); return internalAuthoriseRecurringPayment(cart, worldpayAdditionalInfoData); } DefaultWorldpayDirectOrderFacade(final WorldpayAuthenticatedShopperIdStrategy worldpayAuthenticatedShopperIdStrategy,
                                            final WorldpayDirectOrderService worldpayDirectOrderService,
                                            final CartService cartService,
                                            final AcceleratorCheckoutFacade acceleratorCheckoutFacade,
                                            final WorldpayPaymentInfoService worldpayPaymentInfoService,
                                            final WorldpayMerchantConfigDataFacade worldpayMerchantConfigDataFacade,
                                            final CartFacade cartFacade); @Override void tokenize(final CartModel cartModel, final CSEAdditionalAuthInfo cseAdditionalAuthInfo, final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override void tokenize(final CSEAdditionalAuthInfo cseAdditionalAuthInfo, final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override DirectResponseData authorise(final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override DirectResponseData authoriseRecurringPayment(final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override DirectResponseData authoriseRecurringPayment(final AbstractOrderModel abstractOrderModel,
                                                        final WorldpayAdditionalInfoData worldpayAdditionalInfoData,
                                                        final MerchantInfo merchantInfo); @Override String authoriseKlarnaRedirect(final WorldpayAdditionalInfoData worldpayAdditionalInfoData, final AdditionalAuthInfo additionalAuthInfo); @Override DirectResponseData authoriseApplePayDirect(final ApplePayAdditionalAuthInfo applePayAdditionalAuthInfo); @Override DirectResponseData authoriseGooglePayDirect(final GooglePayAdditionalAuthInfo googlePayAdditionalAuthInfo); @Override ApplePayOrderUpdate updatePaymentMethod(final ApplePayPaymentMethodUpdateRequest paymentMethodUpdateRequest); @Override String authoriseBankTransferRedirect(final BankTransferAdditionalAuthInfo bankTransferAdditionalAuthInfo,
                                                final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override DirectResponseData authorise3DSecure(final String paResponse, final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override DirectResponseData executeSecondPaymentAuthorisation3DSecure(); @Override DirectResponseData authoriseAndTokenize(final WorldpayAdditionalInfoData worldpayAdditionalInfoData, final CSEAdditionalAuthInfo cseAdditionalAuthInfo); CartService getCartService();  }
@Test public void shouldAuthoriseRecurringPayment() throws WorldpayException, InvalidCartException { final DirectResponseData result = testObj.authoriseRecurringPayment(worldpayAdditionalInfoDataMock); verify(worldpayAdditionalInfoDataMock).setAuthenticatedShopperId(AUTHENTICATED_SHOPPER_ID); verify(worldpayDirectOrderServiceMock).authoriseRecurringPayment(cartModelMock, worldpayAdditionalInfoDataMock); final InOrder inOrder = inOrder(acceleratorCheckoutFacadeMock, worldpayDirectOrderServiceMock); verify(worldpayDirectOrderServiceMock).authoriseRecurringPayment(cartModelMock, worldpayAdditionalInfoDataMock); inOrder.verify(worldpayDirectOrderServiceMock).completeAuthorise(directAuthoriseServiceResponseMock, cartModelMock); inOrder.verify(acceleratorCheckoutFacadeMock).placeOrder(); assertEquals(acceleratorCheckoutFacadeMock.placeOrder(), result.getOrderData()); assertEquals(AUTHORISED, result.getTransactionStatus()); }
@Test public void shouldRedirectTo3DSecureV1OnRecurringPayment() throws WorldpayException, InvalidCartException { when(directAuthoriseServiceResponseMock.getPaymentReply()).thenReturn(null); when(request3DInfoMock.getMajor3DSVersion()).thenReturn(THREEDS_V1); when(directAuthoriseServiceResponseMock.getRequest3DInfo()).thenReturn(request3DInfoMock); when(request3DInfoMock.getIssuerUrl()).thenReturn(ISSUER_URL); when(request3DInfoMock.getPaRequest()).thenReturn(PA_REQUEST); final DirectResponseData result = testObj.authoriseRecurringPayment(worldpayAdditionalInfoDataMock); verify(worldpayAdditionalInfoDataMock).setAuthenticatedShopperId(AUTHENTICATED_SHOPPER_ID); assertEquals(ISSUER_URL, result.getIssuerURL()); assertEquals(PA_REQUEST, result.getPaRequest()); assertEquals(AUTHENTICATION_REQUIRED, result.getTransactionStatus()); }