From 4f55cce2684cd9dcca78dbb01844516e3c193c24 Mon Sep 17 00:00:00 2001 From: kpieloch <113994423+kpieloch@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:04:25 +0100 Subject: [PATCH 1/3] AD-345: Add Click to Pay Functionality to Existing Checkout Using Web Components in SAP Commerce Accelerator Storefront --- .../common/js/adyen-checkout/package.json | 4 ++-- .../src/components/payment/Payment.tsx | 8 ++++++-- .../src/reducers/adyenConfigReducer.ts | 4 +++- .../src/types/adyenConfigData.ts | 2 ++ .../checkout/multi/selectPaymentMethodPage.jsp | 6 ++++-- .../_ui/responsive/common/js/adyen.checkout.js | 8 ++++++++ .../common/js/adyen_component_factory.js | 9 +++++++-- .../impl/DefaultAdyenRequestService.java | 1 + .../com/adyen/v6/dto/CheckoutConfigDTO.java | 18 ++++++++++++++++++ .../adyen/v6/dto/CheckoutConfigDTOBuilder.java | 10 ++++++++++ .../impl/DefaultAdyenCheckoutFacade.java | 10 ++++++++-- .../DefaultAdyenCheckoutApiService.java | 6 ++++++ 12 files changed, 75 insertions(+), 11 deletions(-) diff --git a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/package.json b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/package.json index 64d2db4c..484c0789 100644 --- a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/package.json +++ b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@adyen/adyen-web": "6.1.1", + "@adyen/adyen-web": "6.5.0", "@babel/core": "^7.16.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", "@reduxjs/toolkit": "^2.0.1", @@ -13,7 +13,7 @@ "@testing-library/user-event": "^13.5.0", "@types/react": "^18.2.47", "@types/react-dom": "^18.2.18", - "axios": "^1.6.2", + "axios": "1.7.4", "babel-jest": "^27.4.2", "babel-loader": "^8.2.3", "babel-plugin-named-asset-import": "^0.3.8", diff --git a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/components/payment/Payment.tsx b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/components/payment/Payment.tsx index 3f86d750..1e0860f6 100644 --- a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/components/payment/Payment.tsx +++ b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/components/payment/Payment.tsx @@ -40,7 +40,7 @@ interface ComponentProps { interface StoreProps { billingAddress: AddressModel, shippingAddressFromCart: AddressData, - adyenConfig: AdyenConfigData + adyenConfig: AdyenConfigData, } interface DispatchProps { @@ -133,7 +133,11 @@ class Payment extends React.Component { type: 'card', hasHolderName: true, holderNameRequired: this.props.adyenConfig.cardHolderNameRequired, - enableStoreDetails: this.props.adyenConfig.showRememberTheseDetails + enableStoreDetails: this.props.adyenConfig.showRememberTheseDetails, + clickToPayConfiguration: { + merchantDisplayName: this.props.adyenConfig.merchantDisplayName, + shopperEmail: this.props.adyenConfig.shopperEmail + } } } diff --git a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/reducers/adyenConfigReducer.ts b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/reducers/adyenConfigReducer.ts index 1a9e6668..c260fe30 100644 --- a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/reducers/adyenConfigReducer.ts +++ b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/reducers/adyenConfigReducer.ts @@ -26,7 +26,9 @@ export const adyenConfigInitialState : AdyenConfigData = { deviceFingerPrintUrl: "", issuerLists: undefined, sepaDirectDebit: undefined, - storedPaymentMethodList: [] + storedPaymentMethodList: [], + merchantDisplayName: "", + shopperEmail: "", } export function adyenConfigReducer(adyenConfig: AdyenConfigData, action: RootAction): AdyenConfigData { diff --git a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/types/adyenConfigData.ts b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/types/adyenConfigData.ts index 577ea8ce..8b3d1a61 100644 --- a/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/types/adyenConfigData.ts +++ b/adyencheckoutaddonspa/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen-checkout/src/types/adyenConfigData.ts @@ -26,6 +26,8 @@ export interface AdyenConfigData { countryCode: string; cardHolderNameRequired: boolean; sepaDirectDebit: boolean; + merchantDisplayName: string, + shopperEmail: string, } interface SessionData { diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/selectPaymentMethodPage.jsp b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/selectPaymentMethodPage.jsp index 5e915efd..398f5a08 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/selectPaymentMethodPage.jsp +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/selectPaymentMethodPage.jsp @@ -52,8 +52,10 @@ paymentMethodConfigs['createCard'] = { allowedCards, showRememberDetails: ${showRememberTheseDetails}, - cardHolderNameRequired: ${cardHolderNameRequired} - } + cardHolderNameRequired: ${cardHolderNameRequired}, + merchantDisplayName: "${merchantDisplayName}", + shopperEmail: "${shopperEmail}", + }; const adyenCheckout = new AdyenCheckoutHelper(); diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js index d0b4a143..5aac9af6 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js @@ -60,6 +60,14 @@ class AdyenCheckoutHelper { onError: (error, component) => { console.error(error.name, error.message, error.stack, component); }, + paymentMethodsConfiguration:{ + card: { + enableStoreDetails: true, + clickToPayConfiguration: { + merchantDisplayName: 'YOUR_MERCHANT_NAME' + } + }, + } }; console.log("Execution of initiateCheckout: ", this.i++); this.checkout = await AdyenCheckout(configuration); diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen_component_factory.js b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen_component_factory.js index fd4a4334..747b6dae 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen_component_factory.js +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen_component_factory.js @@ -49,7 +49,7 @@ class PaymentComponentFactory { } createCard(params) { - const {allowedCards, showRememberDetails, cardHolderNameRequired} = params; + const {allowedCards, showRememberDetails, cardHolderNameRequired,merchantDisplayName,shopperEmail} = params; const copyCardBrand= (event) => { context.selectedCardBrand = event.brand; @@ -60,9 +60,14 @@ class PaymentComponentFactory { type: 'card', hasHolderName: true, holderNameRequired: cardHolderNameRequired, + storePaymentMethod: showRememberDetails ? 'askForConsent': 'disabled', enableStoreDetails: showRememberDetails, brands: allowedCards, - onBrand: copyCardBrand + onBrand: copyCardBrand, + clickToPayConfiguration: { + merchantDisplayName: merchantDisplayName, + shopperEmail: shopperEmail + } }).mount("#card-div"); } diff --git a/adyenv6core/src/com/adyen/commerce/services/impl/DefaultAdyenRequestService.java b/adyenv6core/src/com/adyen/commerce/services/impl/DefaultAdyenRequestService.java index ba991ab4..23097bdf 100644 --- a/adyenv6core/src/com/adyen/commerce/services/impl/DefaultAdyenRequestService.java +++ b/adyenv6core/src/com/adyen/commerce/services/impl/DefaultAdyenRequestService.java @@ -112,6 +112,7 @@ protected boolean canL23EdsBeSent(PaymentRequest paymentsRequest, CartModel sess .map(method -> method.getActualInstance()) .filter(instance -> instance instanceof CardDetails) .map(instance -> (CardDetails) instance) + .filter(cardDetails -> cardDetails.getBrand() != null) .map(cardDetails -> getL2L3SupportedBrands().contains(cardDetails.getBrand())) .orElse(false) && Optional.ofNullable(sessionCart.getDeliveryAddress()) diff --git a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java index 19c26194..017f1957 100644 --- a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java +++ b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java @@ -42,6 +42,8 @@ public class CheckoutConfigDTO { private boolean sepaDirectDebit; private BigDecimal amountDecimal; private ExpressPaymentConfigDto expressPaymentConfig; + private String merchantDisplayName; + private String shopperEmail; // Getters and setters for the new field public ExpressPaymentConfigDto getExpressPaymentConfig() { @@ -270,4 +272,20 @@ public BigDecimal getAmountDecimal() { public void setAmountDecimal(BigDecimal amountDecimal) { this.amountDecimal = amountDecimal; } + + public String getMerchantDisplayName() { + return merchantDisplayName; + } + + public void setMerchantDisplayName(String merchantDisplayName) { + this.merchantDisplayName = merchantDisplayName; + } + + public String getShopperEmail() { + return shopperEmail; + } + + public void setShopperEmail(String shopperEmail) { + this.shopperEmail = shopperEmail; + } } \ No newline at end of file diff --git a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java index b49302c1..aff81b9f 100644 --- a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java +++ b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java @@ -159,6 +159,16 @@ public CheckoutConfigDTOBuilder setExpressPaymentConfig(ExpressPaymentConfigDto checkoutConfigDTO.setExpressPaymentConfig(expressPaymentConfigDto); return this; } + public CheckoutConfigDTOBuilder setMerchantDisplayName(String merchantDisplayName) { + checkoutConfigDTO.setMerchantDisplayName(merchantDisplayName); + return this; + } + + public CheckoutConfigDTOBuilder setShopperEmail(String shopperEmail) { + checkoutConfigDTO.setShopperEmail(shopperEmail); + return this; + } + public CheckoutConfigDTO build() { return checkoutConfigDTO; diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index 61d4c754..6551e2ba 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -662,6 +662,8 @@ public void initializeCheckoutData(Model model) throws ApiException { model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, checkoutConfigDTO.getCheckoutShopperHost()); model.addAttribute(MODEL_ENVIRONMENT_MODE, checkoutConfigDTO.getEnvironmentMode()); model.addAttribute(SHOPPER_LOCALE, checkoutConfigDTO.getShopperLocale()); + model.addAttribute("merchantDisplayName", checkoutConfigDTO.getMerchantDisplayName()); + model.addAttribute("shopperEmail", checkoutConfigDTO.getShopperEmail()); // OpenInvoice Methods model.addAttribute(MODEL_OPEN_INVOICE_METHODS, checkoutConfigDTO.getOpenInvoiceMethods()); @@ -786,7 +788,9 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException { .setImmediateCapture(isImmediateCapture()) .setCountryCode(cartData != null && cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : "") .setCardHolderNameRequired(getHolderNameRequired()) - .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()); + .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()) + .setMerchantDisplayName(baseStore.getName()) + .setShopperEmail(customerModel.getContactEmail()); ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig(); if (expressPaymentConfigModel != null) { @@ -930,7 +934,9 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException { .setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode()) .setCardHolderNameRequired(getHolderNameRequired()) .setSepaDirectDebit(sepaDirectDebit) - .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()); + .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()) + .setMerchantDisplayName(baseStore.getName()) + .setShopperEmail(customerModel.getContactEmail()); ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig(); if (expressPaymentConfigModel != null) { diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java index 01352f11..729f641f 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java @@ -77,6 +77,8 @@ import java.util.Optional; import java.util.stream.Collectors; +import static com.adyen.model.checkout.CreateCheckoutSessionRequest.StorePaymentMethodModeEnum.ASKFORCONSENT; + public class DefaultAdyenCheckoutApiService extends AbstractAdyenApiService implements AdyenCheckoutApiService { private static final Logger LOG = Logger.getLogger(DefaultAdyenCheckoutApiService.class); @@ -289,6 +291,10 @@ public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartDa } createCheckoutSessionRequest.returnUrl(Optional.ofNullable(cartData.getAdyenReturnUrl()).orElse("returnUrl")); createCheckoutSessionRequest.reference(cartData.getCode()); + createCheckoutSessionRequest.setStorePaymentMethod(true); + createCheckoutSessionRequest.setStorePaymentMethodMode(ASKFORCONSENT); + createCheckoutSessionRequest.enableOneClick(true); + createCheckoutSessionRequest.recurringProcessingModel(CreateCheckoutSessionRequest.RecurringProcessingModelEnum.CARDONFILE); return checkout.sessions(createCheckoutSessionRequest); } From 77b25c251ac4d31fd6c0b86baba2d36cb505fc0f Mon Sep 17 00:00:00 2001 From: kpieloch <113994423+kpieloch@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:02:16 +0100 Subject: [PATCH 2/3] AD-345: Click to pay --- .../web/webroot/_ui/responsive/common/js/adyen.checkout.js | 3 --- .../com/adyen/v6/service/DefaultAdyenCheckoutApiService.java | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js index 5aac9af6..3b0a93f0 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js @@ -63,9 +63,6 @@ class AdyenCheckoutHelper { paymentMethodsConfiguration:{ card: { enableStoreDetails: true, - clickToPayConfiguration: { - merchantDisplayName: 'YOUR_MERCHANT_NAME' - } }, } }; diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java index 729f641f..e08572a8 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java @@ -277,7 +277,6 @@ public PaymentDetailsResponse getPaymentDetailsFromPayload(PaymentDetailsRequest return paymentsResponse; } - @Override public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartData) throws IOException, ApiException { final PaymentsApi checkout = new PaymentsApi(client); @@ -294,8 +293,10 @@ public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartDa createCheckoutSessionRequest.setStorePaymentMethod(true); createCheckoutSessionRequest.setStorePaymentMethodMode(ASKFORCONSENT); createCheckoutSessionRequest.enableOneClick(true); + createCheckoutSessionRequest.shopperEmail(cartData.getUser().getUid()); createCheckoutSessionRequest.recurringProcessingModel(CreateCheckoutSessionRequest.RecurringProcessingModelEnum.CARDONFILE); - + createCheckoutSessionRequest.shopperReference(cartData.getUser().getUid()); + return checkout.sessions(createCheckoutSessionRequest); } From 83889e9fe251c136c63b36db0074499a5840a583 Mon Sep 17 00:00:00 2001 From: kpieloch <113994423+kpieloch@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:29:44 +0100 Subject: [PATCH 3/3] AD-354: Click to pay --- .../webroot/_ui/responsive/common/js/adyen.checkout.js | 2 +- .../v6/facades/impl/DefaultAdyenCheckoutFacade.java | 10 +++++----- .../com/adyen/v6/service/AdyenCheckoutApiService.java | 2 +- .../v6/service/DefaultAdyenCheckoutApiService.java | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js index 3b0a93f0..2227f89c 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js @@ -62,7 +62,7 @@ class AdyenCheckoutHelper { }, paymentMethodsConfiguration:{ card: { - enableStoreDetails: true, + enableStoreDetails: paymentMethodConfigs.enableStoreDetails, }, } }; diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index 6551e2ba..ecbb2086 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -774,7 +774,7 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException { .setAdyenClientKey(baseStore.getAdyenClientKey()) .setAdyenPaypalMerchantId(baseStore.getAdyenPaypalMerchantId()) .setDeviceFingerPrintUrl(adyenPaymentService.getDeviceFingerprintUrl()) - .setSessionData(getAdyenSessionData()) + .setSessionData(getAdyenSessionData(showRememberDetails())) .setSelectedPaymentMethod(cartData.getAdyenPaymentMethod()) .setShowRememberTheseDetails(showRememberDetails()) .setCheckoutShopperHost(getCheckoutShopperHost()) @@ -919,7 +919,7 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException { .setAdyenClientKey(baseStore.getAdyenClientKey()) .setAdyenPaypalMerchantId(baseStore.getAdyenPaypalMerchantId()) .setDeviceFingerPrintUrl(adyenCheckoutApiService.getDeviceFingerprintUrl()) - .setSessionData(getAdyenSessionData()) + .setSessionData(getAdyenSessionData(showRememberDetails())) .setSelectedPaymentMethod(cartData.getAdyenPaymentMethod()) .setShowRememberTheseDetails(showRememberDetails()) .setCheckoutShopperHost(getCheckoutShopperHost()) @@ -1029,10 +1029,10 @@ protected Map getApplePayConfigFromPaymentMethods(List(); } - protected CreateCheckoutSessionResponse getAdyenSessionData() throws ApiException { + protected CreateCheckoutSessionResponse getAdyenSessionData(final boolean storePaymentMethod) throws ApiException { try { final CartData cartData = getCheckoutFacade().getCheckoutCart(); - return getAdyenPaymentService().getPaymentSessionData(cartData); + return getAdyenPaymentService().getPaymentSessionData(cartData,storePaymentMethod); } catch (JsonProcessingException e) { LOGGER.error("Processing json failed. ", e); return null; @@ -1084,7 +1084,7 @@ public void initializeSummaryData(Model model) throws ApiException { model.addAttribute(MODEL_AMAZONPAY_CONFIGURATION, gson.toJson(cartData.getAdyenAmazonPayConfiguration())); model.addAttribute(MODEL_COUNTRY_CODE, countryCode); model.addAttribute(MODEL_DELIVERY_ADDRESS, gson.toJson(cartData.getDeliveryAddress())); - model.addAttribute(SESSION_DATA, getAdyenSessionData()); + model.addAttribute(SESSION_DATA, getAdyenSessionData(showRememberDetails())); model.addAttribute(LOCALE, gson.toJson(setLocale(cartData.getAdyenAmazonPayConfiguration(), shopperLocale))); } diff --git a/adyenv6core/src/com/adyen/v6/service/AdyenCheckoutApiService.java b/adyenv6core/src/com/adyen/v6/service/AdyenCheckoutApiService.java index b1b3135a..4a3a8275 100644 --- a/adyenv6core/src/com/adyen/v6/service/AdyenCheckoutApiService.java +++ b/adyenv6core/src/com/adyen/v6/service/AdyenCheckoutApiService.java @@ -104,7 +104,7 @@ public interface AdyenCheckoutApiService { */ TerminalAPIResponse sendSyncPosStatusRequest(CartData cartData, String serviceId) throws Exception; - CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartData) throws IOException, ApiException; + CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartData, final boolean storePaymentMethod) throws IOException, ApiException; CreateCheckoutSessionResponse getPaymentSessionData(final Amount amount) throws IOException, ApiException; } diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java index e08572a8..c02cc3a1 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenCheckoutApiService.java @@ -278,7 +278,7 @@ public PaymentDetailsResponse getPaymentDetailsFromPayload(PaymentDetailsRequest } @Override - public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartData) throws IOException, ApiException { + public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartData, final boolean storePaymentMethod) throws IOException, ApiException { final PaymentsApi checkout = new PaymentsApi(client); final PriceData totalPriceWithTax = cartData.getTotalPriceWithTax(); @@ -290,7 +290,7 @@ public CreateCheckoutSessionResponse getPaymentSessionData(final CartData cartDa } createCheckoutSessionRequest.returnUrl(Optional.ofNullable(cartData.getAdyenReturnUrl()).orElse("returnUrl")); createCheckoutSessionRequest.reference(cartData.getCode()); - createCheckoutSessionRequest.setStorePaymentMethod(true); + createCheckoutSessionRequest.setStorePaymentMethod(storePaymentMethod); createCheckoutSessionRequest.setStorePaymentMethodMode(ASKFORCONSENT); createCheckoutSessionRequest.enableOneClick(true); createCheckoutSessionRequest.shopperEmail(cartData.getUser().getUid());