@Test public void testPaypalPaymentRequest() throws Exception { when(cartDataMock.getAdyenPaymentMethod()).thenReturn(PAYMENT_METHOD_PAYPAL); when(cartDataMock.getAdyenReturnUrl()).thenReturn(RETURN_URL); when(deliveryAddressMock.getFirstName()).thenReturn(FIRST_NAME); when(deliveryAddressMock.getLastName()).thenReturn(LAST_NAME); when(deliveryAddressMock.getTitleCode()).thenReturn(TITLE_CODE); PaymentsRequest paymentsRequest = adyenRequestFactory.createPaymentsRequest(MERCHANT_ACCOUNT, cartDataMock, new RequestInfo(requestMock), customerModelMock, null); assertNotNull(paymentsRequest); assertEquals(RETURN_URL, paymentsRequest.getReturnUrl()); assertNotNull(paymentsRequest.getPaymentMethod()); assertEquals(PAYMENT_METHOD_PAYPAL, paymentsRequest.getPaymentMethod().getType()); assertNotNull(paymentsRequest.getShopperName()); assertEquals(FIRST_NAME, paymentsRequest.getShopperName().getFirstName()); assertEquals(LAST_NAME, paymentsRequest.getShopperName().getLastName()); assertEquals(Name.GenderEnum.MALE, paymentsRequest.getShopperName().getGender()); }
public PaymentsRequest createPaymentsRequest(final String merchantAccount, final CartData cartData, final RequestInfo requestInfo, final CustomerModel customerModel, final RecurringContractMode recurringContractMode) { PaymentsRequest paymentsRequest = new PaymentsRequest(); String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); if (adyenPaymentMethod == null) { throw new IllegalArgumentException("Payment method is null"); } updatePaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); Boolean is3DS2allowed = is3DS2Allowed(); if (PAYMENT_METHOD_CC.equals(adyenPaymentMethod)) { if (CARD_TYPE_DEBIT.equals(cartData.getAdyenCardType())) { updatePaymentRequestForDC(paymentsRequest, cartData, recurringContractMode); } else { updatePaymentRequestForCC(paymentsRequest, cartData, recurringContractMode); } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } if (customerModel!=null && customerModel.getType() == CustomerType.GUEST) { paymentsRequest.setEnableOneClick(false); } } else if (adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) { String selectedReference = cartData.getAdyenSelectedReference(); if (selectedReference != null && ! selectedReference.isEmpty()) { paymentsRequest.addOneClickData(selectedReference, cartData.getAdyenEncryptedSecurityCode()); String cardBrand = cartData.getAdyenCardBrand(); if (cardBrand != null && cardBrand.equals(AdyenCardTypeEnum.BCMC.getCode())) { DefaultPaymentMethodDetails paymentMethodDetails = (DefaultPaymentMethodDetails) (paymentsRequest.getPaymentMethod()); paymentMethodDetails.setType(cardBrand); paymentsRequest.setPaymentMethod(paymentMethodDetails); } } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } } else if (cartData.getAdyenPaymentMethod().indexOf(PAYMENT_METHOD_BOLETO) == 0) { setBoletoData(paymentsRequest, cartData); } else if (PAYMENT_METHOD_SEPA_DIRECTDEBIT.equals(cartData.getAdyenPaymentMethod())) { setSepaDirectDebitData(paymentsRequest, cartData); } else { updatePaymentRequestForAlternateMethod(paymentsRequest, cartData, customerModel); } ApplicationInfo applicationInfo = updateApplicationInfoEcom(paymentsRequest.getApplicationInfo()); paymentsRequest.setApplicationInfo(applicationInfo); paymentsRequest.setReturnUrl(cartData.getAdyenReturnUrl()); paymentsRequest.setRedirectFromIssuerMethod(RequestMethod.GET.toString()); paymentsRequest.setRedirectToIssuerMethod(RequestMethod.POST.toString()); return paymentsRequest; }
AdyenRequestFactory { public PaymentsRequest createPaymentsRequest(final String merchantAccount, final CartData cartData, final RequestInfo requestInfo, final CustomerModel customerModel, final RecurringContractMode recurringContractMode) { PaymentsRequest paymentsRequest = new PaymentsRequest(); String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); if (adyenPaymentMethod == null) { throw new IllegalArgumentException("Payment method is null"); } updatePaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); Boolean is3DS2allowed = is3DS2Allowed(); if (PAYMENT_METHOD_CC.equals(adyenPaymentMethod)) { if (CARD_TYPE_DEBIT.equals(cartData.getAdyenCardType())) { updatePaymentRequestForDC(paymentsRequest, cartData, recurringContractMode); } else { updatePaymentRequestForCC(paymentsRequest, cartData, recurringContractMode); } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } if (customerModel!=null && customerModel.getType() == CustomerType.GUEST) { paymentsRequest.setEnableOneClick(false); } } else if (adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) { String selectedReference = cartData.getAdyenSelectedReference(); if (selectedReference != null && ! selectedReference.isEmpty()) { paymentsRequest.addOneClickData(selectedReference, cartData.getAdyenEncryptedSecurityCode()); String cardBrand = cartData.getAdyenCardBrand(); if (cardBrand != null && cardBrand.equals(AdyenCardTypeEnum.BCMC.getCode())) { DefaultPaymentMethodDetails paymentMethodDetails = (DefaultPaymentMethodDetails) (paymentsRequest.getPaymentMethod()); paymentMethodDetails.setType(cardBrand); paymentsRequest.setPaymentMethod(paymentMethodDetails); } } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } } else if (cartData.getAdyenPaymentMethod().indexOf(PAYMENT_METHOD_BOLETO) == 0) { setBoletoData(paymentsRequest, cartData); } else if (PAYMENT_METHOD_SEPA_DIRECTDEBIT.equals(cartData.getAdyenPaymentMethod())) { setSepaDirectDebitData(paymentsRequest, cartData); } else { updatePaymentRequestForAlternateMethod(paymentsRequest, cartData, customerModel); } ApplicationInfo applicationInfo = updateApplicationInfoEcom(paymentsRequest.getApplicationInfo()); paymentsRequest.setApplicationInfo(applicationInfo); paymentsRequest.setReturnUrl(cartData.getAdyenReturnUrl()); paymentsRequest.setRedirectFromIssuerMethod(RequestMethod.GET.toString()); paymentsRequest.setRedirectToIssuerMethod(RequestMethod.POST.toString()); return paymentsRequest; } }
AdyenRequestFactory { public PaymentsRequest createPaymentsRequest(final String merchantAccount, final CartData cartData, final RequestInfo requestInfo, final CustomerModel customerModel, final RecurringContractMode recurringContractMode) { PaymentsRequest paymentsRequest = new PaymentsRequest(); String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); if (adyenPaymentMethod == null) { throw new IllegalArgumentException("Payment method is null"); } updatePaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); Boolean is3DS2allowed = is3DS2Allowed(); if (PAYMENT_METHOD_CC.equals(adyenPaymentMethod)) { if (CARD_TYPE_DEBIT.equals(cartData.getAdyenCardType())) { updatePaymentRequestForDC(paymentsRequest, cartData, recurringContractMode); } else { updatePaymentRequestForCC(paymentsRequest, cartData, recurringContractMode); } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } if (customerModel!=null && customerModel.getType() == CustomerType.GUEST) { paymentsRequest.setEnableOneClick(false); } } else if (adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) { String selectedReference = cartData.getAdyenSelectedReference(); if (selectedReference != null && ! selectedReference.isEmpty()) { paymentsRequest.addOneClickData(selectedReference, cartData.getAdyenEncryptedSecurityCode()); String cardBrand = cartData.getAdyenCardBrand(); if (cardBrand != null && cardBrand.equals(AdyenCardTypeEnum.BCMC.getCode())) { DefaultPaymentMethodDetails paymentMethodDetails = (DefaultPaymentMethodDetails) (paymentsRequest.getPaymentMethod()); paymentMethodDetails.setType(cardBrand); paymentsRequest.setPaymentMethod(paymentMethodDetails); } } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } } else if (cartData.getAdyenPaymentMethod().indexOf(PAYMENT_METHOD_BOLETO) == 0) { setBoletoData(paymentsRequest, cartData); } else if (PAYMENT_METHOD_SEPA_DIRECTDEBIT.equals(cartData.getAdyenPaymentMethod())) { setSepaDirectDebitData(paymentsRequest, cartData); } else { updatePaymentRequestForAlternateMethod(paymentsRequest, cartData, customerModel); } ApplicationInfo applicationInfo = updateApplicationInfoEcom(paymentsRequest.getApplicationInfo()); paymentsRequest.setApplicationInfo(applicationInfo); paymentsRequest.setReturnUrl(cartData.getAdyenReturnUrl()); paymentsRequest.setRedirectFromIssuerMethod(RequestMethod.GET.toString()); paymentsRequest.setRedirectToIssuerMethod(RequestMethod.POST.toString()); return paymentsRequest; }  }
AdyenRequestFactory { public PaymentsRequest createPaymentsRequest(final String merchantAccount, final CartData cartData, final RequestInfo requestInfo, final CustomerModel customerModel, final RecurringContractMode recurringContractMode) { PaymentsRequest paymentsRequest = new PaymentsRequest(); String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); if (adyenPaymentMethod == null) { throw new IllegalArgumentException("Payment method is null"); } updatePaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); Boolean is3DS2allowed = is3DS2Allowed(); if (PAYMENT_METHOD_CC.equals(adyenPaymentMethod)) { if (CARD_TYPE_DEBIT.equals(cartData.getAdyenCardType())) { updatePaymentRequestForDC(paymentsRequest, cartData, recurringContractMode); } else { updatePaymentRequestForCC(paymentsRequest, cartData, recurringContractMode); } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } if (customerModel!=null && customerModel.getType() == CustomerType.GUEST) { paymentsRequest.setEnableOneClick(false); } } else if (adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) { String selectedReference = cartData.getAdyenSelectedReference(); if (selectedReference != null && ! selectedReference.isEmpty()) { paymentsRequest.addOneClickData(selectedReference, cartData.getAdyenEncryptedSecurityCode()); String cardBrand = cartData.getAdyenCardBrand(); if (cardBrand != null && cardBrand.equals(AdyenCardTypeEnum.BCMC.getCode())) { DefaultPaymentMethodDetails paymentMethodDetails = (DefaultPaymentMethodDetails) (paymentsRequest.getPaymentMethod()); paymentMethodDetails.setType(cardBrand); paymentsRequest.setPaymentMethod(paymentMethodDetails); } } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } } else if (cartData.getAdyenPaymentMethod().indexOf(PAYMENT_METHOD_BOLETO) == 0) { setBoletoData(paymentsRequest, cartData); } else if (PAYMENT_METHOD_SEPA_DIRECTDEBIT.equals(cartData.getAdyenPaymentMethod())) { setSepaDirectDebitData(paymentsRequest, cartData); } else { updatePaymentRequestForAlternateMethod(paymentsRequest, cartData, customerModel); } ApplicationInfo applicationInfo = updateApplicationInfoEcom(paymentsRequest.getApplicationInfo()); paymentsRequest.setApplicationInfo(applicationInfo); paymentsRequest.setReturnUrl(cartData.getAdyenReturnUrl()); paymentsRequest.setRedirectFromIssuerMethod(RequestMethod.GET.toString()); paymentsRequest.setRedirectToIssuerMethod(RequestMethod.POST.toString()); return paymentsRequest; }  PaymentRequest3d create3DAuthorizationRequest(final String merchantAccount, final HttpServletRequest request, final String md, final String paRes); @Deprecated PaymentRequest createAuthorizationRequest(final String merchantAccount,
                                                     final CartData cartData,
                                                     final HttpServletRequest request,
                                                     final CustomerModel customerModel,
                                                     final RecurringContractMode recurringContractMode); PaymentsDetailsRequest create3DPaymentsRequest(final String paymentData, final String md, final String paRes); PaymentsDetailsRequest create3DS2PaymentsRequest(final String paymentData, final String token, String type); PaymentsRequest createPaymentsRequest(final String merchantAccount,
                                                 final CartData cartData,
                                                 final RequestInfo requestInfo,
                                                 final CustomerModel customerModel,
                                                 final RecurringContractMode recurringContractMode); PaymentsRequest createPaymentsRequest(final String merchantAccount,
                                                 final CartData cartData,
                                                 final PaymentMethodDetails paymentMethodDetails,
                                                 final RequestInfo requestInfo,
                                                 final CustomerModel customerModel); PaymentsRequest enhanceForThreeDS2(PaymentsRequest paymentsRequest, CartData cartData); BrowserInfo updateBrowserInfoFromRequest(BrowserInfo browserInfo, PaymentsRequest paymentsRequest); ApplicationInfo updateApplicationInfoEcom(ApplicationInfo applicationInfo); ApplicationInfo updateApplicationInfoPos(ApplicationInfo applicationInfo); CaptureRequest createCaptureRequest(final String merchantAccount, final BigDecimal amount, final Currency currency, final String authReference, final String merchantReference); CancelOrRefundRequest createCancelOrRefundRequest(final String merchantAccount, final String authReference, final String merchantReference); RefundRequest createRefundRequest(final String merchantAccount, final BigDecimal amount, final Currency currency, final String authReference, final String merchantReference); RecurringDetailsRequest createListRecurringDetailsRequest(final String merchantAccount, final String customerId); DisableRequest createDisableRequest(final String merchantAccount, final String customerId, final String recurringReference); TerminalAPIRequest createTerminalAPIRequestForStatus(final CartData cartData, String originalServiceId); TerminalAPIRequest createTerminalAPIRequest(final CartData cartData, CustomerModel customer, RecurringContractMode recurringContractMode, String serviceId); void setOpenInvoiceData(PaymentRequest paymentRequest, CartData cartData, final CustomerModel customerModel); void setOpenInvoiceData(PaymentsRequest paymentsRequest, CartData cartData); ConfigurationService getConfigurationService(); void setConfigurationService(ConfigurationService configurationService); }
AdyenRequestFactory { public PaymentsRequest createPaymentsRequest(final String merchantAccount, final CartData cartData, final RequestInfo requestInfo, final CustomerModel customerModel, final RecurringContractMode recurringContractMode) { PaymentsRequest paymentsRequest = new PaymentsRequest(); String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); if (adyenPaymentMethod == null) { throw new IllegalArgumentException("Payment method is null"); } updatePaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); Boolean is3DS2allowed = is3DS2Allowed(); if (PAYMENT_METHOD_CC.equals(adyenPaymentMethod)) { if (CARD_TYPE_DEBIT.equals(cartData.getAdyenCardType())) { updatePaymentRequestForDC(paymentsRequest, cartData, recurringContractMode); } else { updatePaymentRequestForCC(paymentsRequest, cartData, recurringContractMode); } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } if (customerModel!=null && customerModel.getType() == CustomerType.GUEST) { paymentsRequest.setEnableOneClick(false); } } else if (adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) { String selectedReference = cartData.getAdyenSelectedReference(); if (selectedReference != null && ! selectedReference.isEmpty()) { paymentsRequest.addOneClickData(selectedReference, cartData.getAdyenEncryptedSecurityCode()); String cardBrand = cartData.getAdyenCardBrand(); if (cardBrand != null && cardBrand.equals(AdyenCardTypeEnum.BCMC.getCode())) { DefaultPaymentMethodDetails paymentMethodDetails = (DefaultPaymentMethodDetails) (paymentsRequest.getPaymentMethod()); paymentMethodDetails.setType(cardBrand); paymentsRequest.setPaymentMethod(paymentMethodDetails); } } if (is3DS2allowed) { paymentsRequest = enhanceForThreeDS2(paymentsRequest, cartData); } } else if (cartData.getAdyenPaymentMethod().indexOf(PAYMENT_METHOD_BOLETO) == 0) { setBoletoData(paymentsRequest, cartData); } else if (PAYMENT_METHOD_SEPA_DIRECTDEBIT.equals(cartData.getAdyenPaymentMethod())) { setSepaDirectDebitData(paymentsRequest, cartData); } else { updatePaymentRequestForAlternateMethod(paymentsRequest, cartData, customerModel); } ApplicationInfo applicationInfo = updateApplicationInfoEcom(paymentsRequest.getApplicationInfo()); paymentsRequest.setApplicationInfo(applicationInfo); paymentsRequest.setReturnUrl(cartData.getAdyenReturnUrl()); paymentsRequest.setRedirectFromIssuerMethod(RequestMethod.GET.toString()); paymentsRequest.setRedirectToIssuerMethod(RequestMethod.POST.toString()); return paymentsRequest; }  PaymentRequest3d create3DAuthorizationRequest(final String merchantAccount, final HttpServletRequest request, final String md, final String paRes); @Deprecated PaymentRequest createAuthorizationRequest(final String merchantAccount,
                                                     final CartData cartData,
                                                     final HttpServletRequest request,
                                                     final CustomerModel customerModel,
                                                     final RecurringContractMode recurringContractMode); PaymentsDetailsRequest create3DPaymentsRequest(final String paymentData, final String md, final String paRes); PaymentsDetailsRequest create3DS2PaymentsRequest(final String paymentData, final String token, String type); PaymentsRequest createPaymentsRequest(final String merchantAccount,
                                                 final CartData cartData,
                                                 final RequestInfo requestInfo,
                                                 final CustomerModel customerModel,
                                                 final RecurringContractMode recurringContractMode); PaymentsRequest createPaymentsRequest(final String merchantAccount,
                                                 final CartData cartData,
                                                 final PaymentMethodDetails paymentMethodDetails,
                                                 final RequestInfo requestInfo,
                                                 final CustomerModel customerModel); PaymentsRequest enhanceForThreeDS2(PaymentsRequest paymentsRequest, CartData cartData); BrowserInfo updateBrowserInfoFromRequest(BrowserInfo browserInfo, PaymentsRequest paymentsRequest); ApplicationInfo updateApplicationInfoEcom(ApplicationInfo applicationInfo); ApplicationInfo updateApplicationInfoPos(ApplicationInfo applicationInfo); CaptureRequest createCaptureRequest(final String merchantAccount, final BigDecimal amount, final Currency currency, final String authReference, final String merchantReference); CancelOrRefundRequest createCancelOrRefundRequest(final String merchantAccount, final String authReference, final String merchantReference); RefundRequest createRefundRequest(final String merchantAccount, final BigDecimal amount, final Currency currency, final String authReference, final String merchantReference); RecurringDetailsRequest createListRecurringDetailsRequest(final String merchantAccount, final String customerId); DisableRequest createDisableRequest(final String merchantAccount, final String customerId, final String recurringReference); TerminalAPIRequest createTerminalAPIRequestForStatus(final CartData cartData, String originalServiceId); TerminalAPIRequest createTerminalAPIRequest(final CartData cartData, CustomerModel customer, RecurringContractMode recurringContractMode, String serviceId); void setOpenInvoiceData(PaymentRequest paymentRequest, CartData cartData, final CustomerModel customerModel); void setOpenInvoiceData(PaymentsRequest paymentsRequest, CartData cartData); ConfigurationService getConfigurationService(); void setConfigurationService(ConfigurationService configurationService);  }