From 2598c4cb2785236d1c16eac63f75b5f69e8eb959 Mon Sep 17 00:00:00 2001 From: Tamara Date: Tue, 3 Dec 2024 13:02:14 +0100 Subject: [PATCH 01/23] Ratepay payment method resolving issue ADCRSET24I-6 --- src/Handlers/AbstractPaymentMethodHandler.php | 40 +- src/Models/PaymentRequest.php | 619 ++++++++++++++++++ .../RatepayDirectdebitPaymentMethod.php | 2 + src/PaymentMethods/RatepayPaymentMethod.php | 2 + src/Resources/config/config.xml | 10 + src/Resources/config/services.xml | 1 + src/Resources/config/services/utils.xml | 4 + .../payment/payment-method.html.twig | 1 + .../payment/payment-ratepay.html.twig | 11 + src/Service/ConfigurationService.php | 12 + src/Service/PaymentMethodsFilterService.php | 19 + src/Subscriber/PaymentSubscriber.php | 35 +- ...RatePayDeviceFingerprintParamsProvider.php | 74 +++ 13 files changed, 822 insertions(+), 8 deletions(-) create mode 100755 src/Models/PaymentRequest.php create mode 100755 src/Resources/views/storefront/component/payment/payment-ratepay.html.twig create mode 100644 src/Util/RatePayDeviceFingerprintParamsProvider.php diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 90fa92059..a5d801d83 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -30,13 +30,15 @@ use Adyen\Model\Checkout\CheckoutPaymentMethod; use Adyen\Model\Checkout\EncryptedOrderData; use Adyen\Model\Checkout\LineItem; -use Adyen\Model\Checkout\PaymentRequest; +use Adyen\Shopware\Models\PaymentRequest as IntegrationPaymentRequest; use Adyen\Model\Checkout\Address; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\BrowserInfo; use Adyen\Model\Checkout\Name; use Adyen\Model\Checkout\PaymentResponse; use Adyen\Service\Checkout\PaymentsApi; +use Adyen\Shopware\PaymentMethods\RatepayDirectdebitPaymentMethod; +use Adyen\Shopware\PaymentMethods\RatepayPaymentMethod; use Adyen\Shopware\Util\CheckoutStateDataValidator; use Adyen\Shopware\Exception\PaymentCancelledException; use Adyen\Shopware\Exception\PaymentFailedException; @@ -46,6 +48,7 @@ use Adyen\Shopware\Service\PaymentStateDataService; use Adyen\Shopware\Service\Repository\SalesChannelRepository; use Adyen\Shopware\Util\Currency; +use Adyen\Shopware\Util\RatePayDeviceFingerprintParamsProvider; use Psr\Log\LoggerInterface; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; @@ -109,6 +112,11 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle */ protected CheckoutStateDataValidator $checkoutStateDataValidator; + /** + * @var RatePayDeviceFingerprintParamsProvider + */ + protected RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider; + /** * @var PaymentStateDataService */ @@ -181,10 +189,11 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle * AbstractPaymentMethodHandler constructor. * * @param OrdersService $ordersService - * @param ClientService $clientService * @param ConfigurationService $configurationService + * @param ClientService $clientService * @param Currency $currency * @param CheckoutStateDataValidator $checkoutStateDataValidator + * @param RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider * @param PaymentStateDataService $paymentStateDataService * @param SalesChannelRepository $salesChannelRepository * @param PaymentResponseHandler $paymentResponseHandler @@ -203,6 +212,7 @@ public function __construct( ClientService $clientService, Currency $currency, CheckoutStateDataValidator $checkoutStateDataValidator, + RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider, PaymentStateDataService $paymentStateDataService, SalesChannelRepository $salesChannelRepository, PaymentResponseHandler $paymentResponseHandler, @@ -220,6 +230,7 @@ public function __construct( $this->currency = $currency; $this->configurationService = $configurationService; $this->checkoutStateDataValidator = $checkoutStateDataValidator; + $this->ratePayFingerprintParamsProvider = $ratePayFingerprintParamsProvider; $this->paymentStateDataService = $paymentStateDataService; $this->salesChannelRepository = $salesChannelRepository; $this->paymentResponseHandler = $paymentResponseHandler; @@ -300,6 +311,14 @@ public function pay( if ($storedStateData) { $this->paymentStateDataService->deletePaymentStateDataFromId($storedStateData['id']); } + + $paymentMethodType = $stateData['paymentMethod']['type']; + if ( + $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) { + $this->ratePayFingerprintParamsProvider->clear(); + } } $orderNumber = $transaction->getOrder()->getOrderNumber(); @@ -397,7 +416,7 @@ public function finalize( * @param array $request * @param int|null $partialAmount * @param array|null $adyenOrderData - * @return PaymentRequest + * @return IntegrationPaymentRequest */ protected function preparePaymentsRequest( SalesChannelContext $salesChannelContext, @@ -405,9 +424,9 @@ protected function preparePaymentsRequest( array $request = [], ?int $partialAmount = null, ?array $adyenOrderData = [] - ): PaymentRequest { + ): IntegrationPaymentRequest { - $paymentRequest = new PaymentRequest($request); + $paymentRequest = new IntegrationPaymentRequest($request); if (!empty($request['additionalData'])) { $stateDataAdditionalData = $request['additionalData']; @@ -612,6 +631,13 @@ protected function preparePaymentsRequest( $paymentRequest->setReturnUrl($transaction->getReturnUrl()); } + if ( + $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) { + $paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken()); + } + if (static::$isOpenInvoice) { $orderLines = $transaction->getOrder()->getLineItems(); $lineItems = []; @@ -746,13 +772,13 @@ private function getPaymentRequest( /** * @param SalesChannelContext $salesChannelContext - * @param PaymentRequest $request + * @param IntegrationPaymentRequest $request * @param AsyncPaymentTransactionStruct $transaction * @return void */ private function paymentsCall( SalesChannelContext $salesChannelContext, - PaymentRequest $request, + IntegrationPaymentRequest $request, AsyncPaymentTransactionStruct $transaction ): void { $transactionId = $transaction->getOrderTransaction()->getId(); diff --git a/src/Models/PaymentRequest.php b/src/Models/PaymentRequest.php new file mode 100755 index 000000000..27bd87f0c --- /dev/null +++ b/src/Models/PaymentRequest.php @@ -0,0 +1,619 @@ + '\Adyen\Model\Checkout\AccountInfo', + 'bankAccount' => '\Adyen\Model\Checkout\BankAccount', + 'additionalAmount' => '\Adyen\Model\Checkout\Amount', + 'additionalData' => 'array', + 'amount' => '\Adyen\Model\Checkout\Amount', + 'applicationInfo' => '\Adyen\Model\Checkout\ApplicationInfo', + 'authenticationData' => '\Adyen\Model\Checkout\AuthenticationData', + 'billingAddress' => '\Adyen\Model\Checkout\BillingAddress', + 'browserInfo' => '\Adyen\Model\Checkout\BrowserInfo', + 'captureDelayHours' => 'int', + 'channel' => 'string', + 'checkoutAttemptId' => 'string', + 'company' => '\Adyen\Model\Checkout\Company', + 'conversionId' => 'string', + 'countryCode' => 'string', + 'dateOfBirth' => '\DateTime', + 'dccQuote' => '\Adyen\Model\Checkout\ForexQuote', + 'deliverAt' => '\DateTime', + 'deliveryAddress' => '\Adyen\Model\Checkout\DeliveryAddress', + 'deliveryDate' => '\DateTime', + 'deviceFingerprint' => 'string', + 'enableOneClick' => 'bool', + 'enablePayOut' => 'bool', + 'enableRecurring' => 'bool', + 'entityType' => 'string', + 'fraudOffset' => 'int', + 'fundOrigin' => '\Adyen\Model\Checkout\FundOrigin', + 'fundRecipient' => '\Adyen\Model\Checkout\FundRecipient', + 'industryUsage' => 'string', + 'installments' => '\Adyen\Model\Checkout\Installments', + 'lineItems' => '\Adyen\Model\Checkout\LineItem[]', + 'localizedShopperStatement' => 'array', + 'mandate' => '\Adyen\Model\Checkout\Mandate', + 'mcc' => 'string', + 'merchantAccount' => 'string', + 'merchantOrderReference' => 'string', + 'merchantRiskIndicator' => '\Adyen\Model\Checkout\MerchantRiskIndicator', + 'metadata' => 'array', + 'mpiData' => '\Adyen\Model\Checkout\ThreeDSecureData', + 'order' => '\Adyen\Model\Checkout\EncryptedOrderData', + 'orderReference' => 'string', + 'origin' => 'string', + 'paymentMethod' => '\Adyen\Model\Checkout\CheckoutPaymentMethod', + 'platformChargebackLogic' => '\Adyen\Model\Checkout\PlatformChargebackLogic', + 'recurringExpiry' => 'string', + 'recurringFrequency' => 'string', + 'recurringProcessingModel' => 'string', + 'redirectFromIssuerMethod' => 'string', + 'redirectToIssuerMethod' => 'string', + 'reference' => 'string', + 'returnUrl' => 'string', + 'riskData' => '\Adyen\Model\Checkout\RiskData', + 'sessionValidity' => 'string', + 'shopperEmail' => 'string', + 'shopperIP' => 'string', + 'shopperInteraction' => 'string', + 'shopperLocale' => 'string', + 'shopperName' => '\Adyen\Model\Checkout\Name', + 'shopperReference' => 'string', + 'shopperStatement' => 'string', + 'socialSecurityNumber' => 'string', + 'splits' => '\Adyen\Model\Checkout\Split[]', + 'store' => 'string', + 'storePaymentMethod' => 'bool', + 'subMerchants' => '\Adyen\Model\Checkout\SubMerchantInfo[]', + 'telephoneNumber' => 'string', + 'threeDS2RequestData' => '\Adyen\Model\Checkout\ThreeDS2RequestFields', + 'threeDSAuthenticationOnly' => 'bool', + 'trustedShopper' => 'bool' + ]; + + /** + * @inheritdoc + * + * Added bankAccount + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'accountInfo' => null, + 'bankAccount' => null, + 'additionalAmount' => null, + 'additionalData' => null, + 'amount' => null, + 'applicationInfo' => null, + 'authenticationData' => null, + 'billingAddress' => null, + 'browserInfo' => null, + 'captureDelayHours' => 'int32', + 'channel' => null, + 'checkoutAttemptId' => null, + 'company' => null, + 'conversionId' => null, + 'countryCode' => null, + 'dateOfBirth' => 'date-time', + 'dccQuote' => null, + 'deliverAt' => 'date-time', + 'deliveryAddress' => null, + 'deliveryDate' => 'date-time', + 'deviceFingerprint' => null, + 'enableOneClick' => null, + 'enablePayOut' => null, + 'enableRecurring' => null, + 'entityType' => null, + 'fraudOffset' => 'int32', + 'fundOrigin' => null, + 'fundRecipient' => null, + 'industryUsage' => null, + 'installments' => null, + 'lineItems' => null, + 'localizedShopperStatement' => null, + 'mandate' => null, + 'mcc' => null, + 'merchantAccount' => null, + 'merchantOrderReference' => null, + 'merchantRiskIndicator' => null, + 'metadata' => null, + 'mpiData' => null, + 'order' => null, + 'orderReference' => null, + 'origin' => null, + 'paymentMethod' => null, + 'platformChargebackLogic' => null, + 'recurringExpiry' => null, + 'recurringFrequency' => null, + 'recurringProcessingModel' => null, + 'redirectFromIssuerMethod' => null, + 'redirectToIssuerMethod' => null, + 'reference' => null, + 'returnUrl' => null, + 'riskData' => null, + 'sessionValidity' => null, + 'shopperEmail' => null, + 'shopperIP' => null, + 'shopperInteraction' => null, + 'shopperLocale' => null, + 'shopperName' => null, + 'shopperReference' => null, + 'shopperStatement' => null, + 'socialSecurityNumber' => null, + 'splits' => null, + 'store' => null, + 'storePaymentMethod' => null, + 'subMerchants' => null, + 'telephoneNumber' => null, + 'threeDS2RequestData' => null, + 'threeDSAuthenticationOnly' => null, + 'trustedShopper' => null + ]; + + /** + * @inheritdoc + * + * Added bankAccount + * + * @var boolean[] + */ + protected static $openAPINullables = [ + 'accountInfo' => false, + 'bankAccount' => false, + 'additionalAmount' => false, + 'additionalData' => false, + 'amount' => false, + 'applicationInfo' => false, + 'authenticationData' => false, + 'billingAddress' => false, + 'browserInfo' => false, + 'captureDelayHours' => true, + 'channel' => false, + 'checkoutAttemptId' => false, + 'company' => false, + 'conversionId' => false, + 'countryCode' => false, + 'dateOfBirth' => false, + 'dccQuote' => false, + 'deliverAt' => false, + 'deliveryAddress' => false, + 'deliveryDate' => false, + 'deviceFingerprint' => false, + 'enableOneClick' => false, + 'enablePayOut' => false, + 'enableRecurring' => false, + 'entityType' => false, + 'fraudOffset' => true, + 'fundOrigin' => false, + 'fundRecipient' => false, + 'industryUsage' => false, + 'installments' => false, + 'lineItems' => false, + 'localizedShopperStatement' => false, + 'mandate' => false, + 'mcc' => false, + 'merchantAccount' => false, + 'merchantOrderReference' => false, + 'merchantRiskIndicator' => false, + 'metadata' => false, + 'mpiData' => false, + 'order' => false, + 'orderReference' => false, + 'origin' => false, + 'paymentMethod' => false, + 'platformChargebackLogic' => false, + 'recurringExpiry' => false, + 'recurringFrequency' => false, + 'recurringProcessingModel' => false, + 'redirectFromIssuerMethod' => false, + 'redirectToIssuerMethod' => false, + 'reference' => false, + 'returnUrl' => false, + 'riskData' => false, + 'sessionValidity' => false, + 'shopperEmail' => false, + 'shopperIP' => false, + 'shopperInteraction' => false, + 'shopperLocale' => false, + 'shopperName' => false, + 'shopperReference' => false, + 'shopperStatement' => false, + 'socialSecurityNumber' => false, + 'splits' => false, + 'store' => false, + 'storePaymentMethod' => false, + 'subMerchants' => false, + 'telephoneNumber' => false, + 'threeDS2RequestData' => false, + 'threeDSAuthenticationOnly' => false, + 'trustedShopper' => false + ]; + + /** + * @inheritDoc + * + * @return string[] + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * @inheritDoc + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * @inheritDoc + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * @inheritdoc + * + * Added bankAccount + * + * @var string[] + */ + protected static $attributeMap = [ + 'accountInfo' => 'accountInfo', + 'bankAccount' => 'bankAccount', + 'additionalAmount' => 'additionalAmount', + 'additionalData' => 'additionalData', + 'amount' => 'amount', + 'applicationInfo' => 'applicationInfo', + 'authenticationData' => 'authenticationData', + 'billingAddress' => 'billingAddress', + 'browserInfo' => 'browserInfo', + 'captureDelayHours' => 'captureDelayHours', + 'channel' => 'channel', + 'checkoutAttemptId' => 'checkoutAttemptId', + 'company' => 'company', + 'conversionId' => 'conversionId', + 'countryCode' => 'countryCode', + 'dateOfBirth' => 'dateOfBirth', + 'dccQuote' => 'dccQuote', + 'deliverAt' => 'deliverAt', + 'deliveryAddress' => 'deliveryAddress', + 'deliveryDate' => 'deliveryDate', + 'deviceFingerprint' => 'deviceFingerprint', + 'enableOneClick' => 'enableOneClick', + 'enablePayOut' => 'enablePayOut', + 'enableRecurring' => 'enableRecurring', + 'entityType' => 'entityType', + 'fraudOffset' => 'fraudOffset', + 'fundOrigin' => 'fundOrigin', + 'fundRecipient' => 'fundRecipient', + 'industryUsage' => 'industryUsage', + 'installments' => 'installments', + 'lineItems' => 'lineItems', + 'localizedShopperStatement' => 'localizedShopperStatement', + 'mandate' => 'mandate', + 'mcc' => 'mcc', + 'merchantAccount' => 'merchantAccount', + 'merchantOrderReference' => 'merchantOrderReference', + 'merchantRiskIndicator' => 'merchantRiskIndicator', + 'metadata' => 'metadata', + 'mpiData' => 'mpiData', + 'order' => 'order', + 'orderReference' => 'orderReference', + 'origin' => 'origin', + 'paymentMethod' => 'paymentMethod', + 'platformChargebackLogic' => 'platformChargebackLogic', + 'recurringExpiry' => 'recurringExpiry', + 'recurringFrequency' => 'recurringFrequency', + 'recurringProcessingModel' => 'recurringProcessingModel', + 'redirectFromIssuerMethod' => 'redirectFromIssuerMethod', + 'redirectToIssuerMethod' => 'redirectToIssuerMethod', + 'reference' => 'reference', + 'returnUrl' => 'returnUrl', + 'riskData' => 'riskData', + 'sessionValidity' => 'sessionValidity', + 'shopperEmail' => 'shopperEmail', + 'shopperIP' => 'shopperIP', + 'shopperInteraction' => 'shopperInteraction', + 'shopperLocale' => 'shopperLocale', + 'shopperName' => 'shopperName', + 'shopperReference' => 'shopperReference', + 'shopperStatement' => 'shopperStatement', + 'socialSecurityNumber' => 'socialSecurityNumber', + 'splits' => 'splits', + 'store' => 'store', + 'storePaymentMethod' => 'storePaymentMethod', + 'subMerchants' => 'subMerchants', + 'telephoneNumber' => 'telephoneNumber', + 'threeDS2RequestData' => 'threeDS2RequestData', + 'threeDSAuthenticationOnly' => 'threeDSAuthenticationOnly', + 'trustedShopper' => 'trustedShopper' + ]; + + /** + * @inheritdoc + * + * Added bankAccount + * + * @var string[] + */ + protected static $setters = [ + 'accountInfo' => 'setAccountInfo', + 'bankAccount' => 'setBankAccount', + 'additionalAmount' => 'setAdditionalAmount', + 'additionalData' => 'setAdditionalData', + 'amount' => 'setAmount', + 'applicationInfo' => 'setApplicationInfo', + 'authenticationData' => 'setAuthenticationData', + 'billingAddress' => 'setBillingAddress', + 'browserInfo' => 'setBrowserInfo', + 'captureDelayHours' => 'setCaptureDelayHours', + 'channel' => 'setChannel', + 'checkoutAttemptId' => 'setCheckoutAttemptId', + 'company' => 'setCompany', + 'conversionId' => 'setConversionId', + 'countryCode' => 'setCountryCode', + 'dateOfBirth' => 'setDateOfBirth', + 'dccQuote' => 'setDccQuote', + 'deliverAt' => 'setDeliverAt', + 'deliveryAddress' => 'setDeliveryAddress', + 'deliveryDate' => 'setDeliveryDate', + 'deviceFingerprint' => 'setDeviceFingerprint', + 'enableOneClick' => 'setEnableOneClick', + 'enablePayOut' => 'setEnablePayOut', + 'enableRecurring' => 'setEnableRecurring', + 'entityType' => 'setEntityType', + 'fraudOffset' => 'setFraudOffset', + 'fundOrigin' => 'setFundOrigin', + 'fundRecipient' => 'setFundRecipient', + 'industryUsage' => 'setIndustryUsage', + 'installments' => 'setInstallments', + 'lineItems' => 'setLineItems', + 'localizedShopperStatement' => 'setLocalizedShopperStatement', + 'mandate' => 'setMandate', + 'mcc' => 'setMcc', + 'merchantAccount' => 'setMerchantAccount', + 'merchantOrderReference' => 'setMerchantOrderReference', + 'merchantRiskIndicator' => 'setMerchantRiskIndicator', + 'metadata' => 'setMetadata', + 'mpiData' => 'setMpiData', + 'order' => 'setOrder', + 'orderReference' => 'setOrderReference', + 'origin' => 'setOrigin', + 'paymentMethod' => 'setPaymentMethod', + 'platformChargebackLogic' => 'setPlatformChargebackLogic', + 'recurringExpiry' => 'setRecurringExpiry', + 'recurringFrequency' => 'setRecurringFrequency', + 'recurringProcessingModel' => 'setRecurringProcessingModel', + 'redirectFromIssuerMethod' => 'setRedirectFromIssuerMethod', + 'redirectToIssuerMethod' => 'setRedirectToIssuerMethod', + 'reference' => 'setReference', + 'returnUrl' => 'setReturnUrl', + 'riskData' => 'setRiskData', + 'sessionValidity' => 'setSessionValidity', + 'shopperEmail' => 'setShopperEmail', + 'shopperIP' => 'setShopperIP', + 'shopperInteraction' => 'setShopperInteraction', + 'shopperLocale' => 'setShopperLocale', + 'shopperName' => 'setShopperName', + 'shopperReference' => 'setShopperReference', + 'shopperStatement' => 'setShopperStatement', + 'socialSecurityNumber' => 'setSocialSecurityNumber', + 'splits' => 'setSplits', + 'store' => 'setStore', + 'storePaymentMethod' => 'setStorePaymentMethod', + 'subMerchants' => 'setSubMerchants', + 'telephoneNumber' => 'setTelephoneNumber', + 'threeDS2RequestData' => 'setThreeDS2RequestData', + 'threeDSAuthenticationOnly' => 'setThreeDSAuthenticationOnly', + 'trustedShopper' => 'setTrustedShopper' + ]; + + /** + * @inheritdoc + * + * Added bankAccount + * + * @var string[] + */ + protected static $getters = [ + 'accountInfo' => 'getAccountInfo', + 'bankAccount' => 'getBankAccount', + 'additionalAmount' => 'getAdditionalAmount', + 'additionalData' => 'getAdditionalData', + 'amount' => 'getAmount', + 'applicationInfo' => 'getApplicationInfo', + 'authenticationData' => 'getAuthenticationData', + 'billingAddress' => 'getBillingAddress', + 'browserInfo' => 'getBrowserInfo', + 'captureDelayHours' => 'getCaptureDelayHours', + 'channel' => 'getChannel', + 'checkoutAttemptId' => 'getCheckoutAttemptId', + 'company' => 'getCompany', + 'conversionId' => 'getConversionId', + 'countryCode' => 'getCountryCode', + 'dateOfBirth' => 'getDateOfBirth', + 'dccQuote' => 'getDccQuote', + 'deliverAt' => 'getDeliverAt', + 'deliveryAddress' => 'getDeliveryAddress', + 'deliveryDate' => 'getDeliveryDate', + 'deviceFingerprint' => 'getDeviceFingerprint', + 'enableOneClick' => 'getEnableOneClick', + 'enablePayOut' => 'getEnablePayOut', + 'enableRecurring' => 'getEnableRecurring', + 'entityType' => 'getEntityType', + 'fraudOffset' => 'getFraudOffset', + 'fundOrigin' => 'getFundOrigin', + 'fundRecipient' => 'getFundRecipient', + 'industryUsage' => 'getIndustryUsage', + 'installments' => 'getInstallments', + 'lineItems' => 'getLineItems', + 'localizedShopperStatement' => 'getLocalizedShopperStatement', + 'mandate' => 'getMandate', + 'mcc' => 'getMcc', + 'merchantAccount' => 'getMerchantAccount', + 'merchantOrderReference' => 'getMerchantOrderReference', + 'merchantRiskIndicator' => 'getMerchantRiskIndicator', + 'metadata' => 'getMetadata', + 'mpiData' => 'getMpiData', + 'order' => 'getOrder', + 'orderReference' => 'getOrderReference', + 'origin' => 'getOrigin', + 'paymentMethod' => 'getPaymentMethod', + 'platformChargebackLogic' => 'getPlatformChargebackLogic', + 'recurringExpiry' => 'getRecurringExpiry', + 'recurringFrequency' => 'getRecurringFrequency', + 'recurringProcessingModel' => 'getRecurringProcessingModel', + 'redirectFromIssuerMethod' => 'getRedirectFromIssuerMethod', + 'redirectToIssuerMethod' => 'getRedirectToIssuerMethod', + 'reference' => 'getReference', + 'returnUrl' => 'getReturnUrl', + 'riskData' => 'getRiskData', + 'sessionValidity' => 'getSessionValidity', + 'shopperEmail' => 'getShopperEmail', + 'shopperIP' => 'getShopperIP', + 'shopperInteraction' => 'getShopperInteraction', + 'shopperLocale' => 'getShopperLocale', + 'shopperName' => 'getShopperName', + 'shopperReference' => 'getShopperReference', + 'shopperStatement' => 'getShopperStatement', + 'socialSecurityNumber' => 'getSocialSecurityNumber', + 'splits' => 'getSplits', + 'store' => 'getStore', + 'storePaymentMethod' => 'getStorePaymentMethod', + 'subMerchants' => 'getSubMerchants', + 'telephoneNumber' => 'getTelephoneNumber', + 'threeDS2RequestData' => 'getThreeDS2RequestData', + 'threeDSAuthenticationOnly' => 'getThreeDSAuthenticationOnly', + 'trustedShopper' => 'getTrustedShopper' + ]; + + /** + * @inheritDoc + * + * @return string[] + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * @inheritDoc + * + * @return string[] + */ + public static function setters() + { + return self::$setters; + } + + /** + * @inheritDoc + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * @inheritdoc + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + parent::__construct($data); + + $data = $data ?? []; + if ( + self::isNullable('bankAccount') && + array_key_exists('bankAccount', $data) && + is_null($data['bankAccount']) + ) { + $this->openAPINullablesSetToNull[] = 'bankAccount'; + } + + $this->container['bankAccount'] = $data['bankAccount'] ?? null; + } + + /** + * Gets bankAccount + * + * @return BankAccount|null + */ + public function getBankAccount() + { + return $this->container['bankAccount']; + } + + /** + * Sets bankAccount + * + * @param BankAccount|null $bankAccount bankAccount + * + * @return self + */ + public function setBankAccount($bankAccount) + { + $this->container['bankAccount'] = $bankAccount; + + return $this; + } + + /** + * @inheritDoc + * + * Added bankAccount + * + */ + public function jsonSerialize() + { + $data = ObjectSerializer::sanitizeForSerialization($this); + if ($this->container["bankAccount"]) { + $data->bankAccount = $this->container["bankAccount"]; + } + + return $data; + } +} diff --git a/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php b/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php index d7b011bc4..54c3fe873 100755 --- a/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php +++ b/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php @@ -28,6 +28,8 @@ class RatepayDirectdebitPaymentMethod implements PaymentMethodInterface { + const RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE = 'ratepay_directdebit'; + /** * {@inheritDoc} * diff --git a/src/PaymentMethods/RatepayPaymentMethod.php b/src/PaymentMethods/RatepayPaymentMethod.php index c153b31a1..b07ea372d 100755 --- a/src/PaymentMethods/RatepayPaymentMethod.php +++ b/src/PaymentMethods/RatepayPaymentMethod.php @@ -28,6 +28,8 @@ class RatepayPaymentMethod implements PaymentMethodInterface { + const RATEPAY_PAYMENT_METHOD_TYPE = 'ratepay'; + /** * {@inheritDoc} * diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml index 2cd978a68..725637597 100644 --- a/src/Resources/config/config.xml +++ b/src/Resources/config/config.xml @@ -179,6 +179,16 @@ + + Ratepay payment methods configuration + + deviceFingerprintSnippetId + + + Set the device fingerprint snippet id provided by Ratepay. This value is required for the Ratepay payment methods to be available at checkout. + + + Adyen Giving diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 5d981b6a6..c8d2117e9 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -82,6 +82,7 @@ + diff --git a/src/Resources/config/services/utils.xml b/src/Resources/config/services/utils.xml index a26550ddc..f30e3a909 100644 --- a/src/Resources/config/services/utils.xml +++ b/src/Resources/config/services/utils.xml @@ -20,6 +20,10 @@ + + + + diff --git a/src/Resources/views/storefront/component/payment/payment-method.html.twig b/src/Resources/views/storefront/component/payment/payment-method.html.twig index 57e7d72c6..70b7085f4 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -17,5 +17,6 @@ {% if payment.id is same as(selectedPaymentMethodId) and 'handler_adyen_' in payment.formattedHandlerIdentifier %} {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-ratepay.html.twig' %} {% endif %} {% endblock %} diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig new file mode 100755 index 000000000..53ff0c93b --- /dev/null +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -0,0 +1,11 @@ +{% if payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaydirectdebitpaymentmethodhandler') + or payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaypaymentmethodhandler') %} + + +{% endif %} \ No newline at end of file diff --git a/src/Service/ConfigurationService.php b/src/Service/ConfigurationService.php index eb04c8dd6..ad0286526 100644 --- a/src/Service/ConfigurationService.php +++ b/src/Service/ConfigurationService.php @@ -259,6 +259,18 @@ public function getOrderState(string $salesChannelId = null) return $this->systemConfigService->get(self::BUNDLE_NAME . '.config.orderState', $salesChannelId); } + /** + * @param string|null $salesChannelId + * @return array|mixed|null + */ + public function getDeviceFingerprintSnippetId(string $salesChannelId = null) + { + return $this->systemConfigService->get( + self::BUNDLE_NAME . '.config.deviceFingerprintSnippetId', + $salesChannelId + ); + } + /** * @param string $salesChannelId * @return array|mixed|null diff --git a/src/Service/PaymentMethodsFilterService.php b/src/Service/PaymentMethodsFilterService.php index a47a0222e..926c21c4b 100644 --- a/src/Service/PaymentMethodsFilterService.php +++ b/src/Service/PaymentMethodsFilterService.php @@ -30,6 +30,8 @@ use Adyen\Shopware\Handlers\GooglePayPaymentMethodHandler; use Adyen\Shopware\Handlers\OneClickPaymentMethodHandler; use Adyen\Shopware\Handlers\ApplePayPaymentMethodHandler; +use Adyen\Shopware\PaymentMethods\RatepayDirectdebitPaymentMethod; +use Adyen\Shopware\PaymentMethods\RatepayPaymentMethod; use Shopware\Core\Checkout\Payment\PaymentMethodCollection; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Checkout\Payment\SalesChannel\AbstractPaymentMethodRoute; @@ -42,6 +44,11 @@ class PaymentMethodsFilterService { + /** + * @var ConfigurationService + */ + private $configurationService; + /** * @var PaymentMethodsService */ @@ -56,15 +63,18 @@ class PaymentMethodsFilterService /** * PaymentMethodsFilterService constructor. * + * @param ConfigurationService $configurationService * @param PaymentMethodsService $paymentMethodsService * @param AbstractPaymentMethodRoute $paymentMethodRoute * @param EntityRepository $paymentMethodRepository */ public function __construct( + ConfigurationService $configurationService, PaymentMethodsService $paymentMethodsService, AbstractPaymentMethodRoute $paymentMethodRoute, $paymentMethodRepository ) { + $this->configurationService = $configurationService; $this->paymentMethodsService = $paymentMethodsService; $this->paymentMethodRoute = $paymentMethodRoute; $this->paymentMethodRepository = $paymentMethodRepository; @@ -106,6 +116,15 @@ function (PaymentMethodEntity $item) use ($adyenPluginId) { $pmCode = $pmHandlerIdentifier::getPaymentMethodCode(); $isSafari = preg_match('/^((?!chrome|android).)*safari/', strtolower($_SERVER['HTTP_USER_AGENT'])); + if ( + ( + $pmCode === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $pmCode === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) && + !$this->configurationService->getDeviceFingerprintSnippetId()) { + $originalPaymentMethods->remove($paymentMethodEntity->getId()); + } + if ($pmCode == OneClickPaymentMethodHandler::getPaymentMethodCode()) { // For OneClick, remove it if /paymentMethod response has no stored payment methods if (empty($adyenPaymentMethods->getStoredPaymentMethods())) { diff --git a/src/Subscriber/PaymentSubscriber.php b/src/Subscriber/PaymentSubscriber.php index 875d509d8..a48dd3615 100644 --- a/src/Subscriber/PaymentSubscriber.php +++ b/src/Subscriber/PaymentSubscriber.php @@ -32,9 +32,11 @@ use Adyen\Shopware\Service\PaymentStateDataService; use Adyen\Shopware\Service\Repository\SalesChannelRepository; use Adyen\Shopware\Util\Currency; +use Adyen\Shopware\Util\RatePayDeviceFingerprintParamsProvider; use Shopware\Core\Checkout\Cart\AbstractCartPersister; use Shopware\Core\Checkout\Cart\CartCalculator; use Shopware\Core\Checkout\Cart\Exception\CartTokenNotFoundException; +use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; @@ -116,6 +118,11 @@ class PaymentSubscriber extends StorefrontSubscriber implements EventSubscriberI */ private $adyenPluginProvider; + /** + * @var RatePayDeviceFingerprintParamsProvider + */ + private RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider; + /** * @var AbstractContextSwitchRoute */ @@ -147,6 +154,7 @@ class PaymentSubscriber extends StorefrontSubscriber implements EventSubscriberI * @param AbstractContextSwitchRoute $contextSwitchRoute * @param AbstractSalesChannelContextFactory $salesChannelContextFactory * @param Currency $currency + * @param RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider * @param EntityRepository $paymentMethodRepository */ public function __construct( @@ -163,6 +171,7 @@ public function __construct( AbstractContextSwitchRoute $contextSwitchRoute, AbstractSalesChannelContextFactory $salesChannelContextFactory, Currency $currency, + RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider, EntityRepository $paymentMethodRepository ) { $this->adyenPluginProvider = $adyenPluginProvider; @@ -178,6 +187,7 @@ public function __construct( $this->contextSwitchRoute = $contextSwitchRoute; $this->salesChannelContextFactory = $salesChannelContextFactory; $this->currency = $currency; + $this->ratePayFingerprintParamsProvider = $ratePayFingerprintParamsProvider; $this->paymentMethodRepository = $paymentMethodRepository; } @@ -405,7 +415,8 @@ public function onCheckoutConfirmLoaded(PageLoadedEvent $event) ), 'affiliateCode' => $affiliateCode, 'campaignCode' => $campaignCode, - ] + ], + $this->getFingerprintParametersForRatepayMethod($salesChannelContext, $selectedPaymentMethod) ) ) ); @@ -439,4 +450,26 @@ public function onKernelRequest(RequestEvent $event) ); } } + + /** + * + * @param SalesChannelContext $salesChannelContext + * @param PaymentMethodEntity $paymentMethod + * @return array + */ + private function getFingerprintParametersForRatepayMethod( + SalesChannelContext $salesChannelContext, + PaymentMethodEntity $paymentMethod + ): array + { + if ( + $paymentMethod->getFormattedHandlerIdentifier() === 'handler_adyen_ratepaydirectdebitpaymentmethodhandler' || + $paymentMethod->getFormattedHandlerIdentifier() === 'handler_adyen_ratepaypaymentmethodhandler' + ) { + return ['ratepay' => $this->ratePayFingerprintParamsProvider + ->getFingerprintParams($salesChannelContext->getSalesChannelId())]; + } + + return []; + } } diff --git a/src/Util/RatePayDeviceFingerprintParamsProvider.php b/src/Util/RatePayDeviceFingerprintParamsProvider.php new file mode 100644 index 000000000..ba8fd00a4 --- /dev/null +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -0,0 +1,74 @@ +requestStack = $requestStack; + $this->configurationService = $configurationService; + } + + /** + * Provides fingerprint parameters + * + * @param string|null $salesChannelId + * @return array + */ + public function getFingerprintParams(string $salesChannelId = null): array + { + return [ + 'snippetId' => $this->configurationService->getDeviceFingerprintSnippetId($salesChannelId), + 'token' => $this->getToken(), + 'location' => 'Checkout' + ]; + } + + /** + * Creates token, set in session and retrieves it + * + * @return string + */ + public function getToken(): string + { + if (!$this->requestStack->getSession()->get(self::TOKEN_SESSION_KEY)) { + $this->requestStack->getSession()->set( + self::TOKEN_SESSION_KEY, + md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime()) + ); + } + + return (string)$this->requestStack->getSession()->get(self::TOKEN_SESSION_KEY); + } + + + /** + * Removes fingerprint token from session + * + * @return void + */ + public function clear(): void + { + $this->requestStack->getSession()->remove(self::TOKEN_SESSION_KEY); + } +} \ No newline at end of file From af9f62553f3ec86731b729b127ca67bc24056b24 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Tue, 3 Dec 2024 16:44:44 +0100 Subject: [PATCH 02/23] Implement Billie payment method ISSUE: ADCRSET24I-5 --- src/Handlers/AbstractPaymentMethodHandler.php | 29 ++++++++++++++++-- .../adyen-payment-shopware6.js | 2 +- .../src/checkout/confirm-order.plugin.js | 17 +++++++++++ .../payment/billie-payment-method.html.twig | 30 +++++++++++++++++++ .../payment/payment-method.html.twig | 1 + src/Subscriber/PaymentSubscriber.php | 1 + src/Util/CheckoutStateDataValidator.php | 3 +- 7 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 src/Resources/views/storefront/component/payment/billie-payment-method.html.twig diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 90fa92059..177409c30 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -28,6 +28,7 @@ use Adyen\AdyenException; use Adyen\Client; use Adyen\Model\Checkout\CheckoutPaymentMethod; +use Adyen\Model\Checkout\Company; use Adyen\Model\Checkout\EncryptedOrderData; use Adyen\Model\Checkout\LineItem; use Adyen\Model\Checkout\PaymentRequest; @@ -280,6 +281,14 @@ public function pay( */ $stateData = $requestStateData ?? $storedStateData ?? []; + $companyName = $dataBag->get('companyName'); + $registrationNumber = $dataBag->get('registrationNumber'); + + $billieData = [ + 'companyName' => $companyName, + 'registrationNumber' => $registrationNumber, + ]; + /* * If there are more than one stateData and /payments calls have been completed, * check the remaining order amount for final /payments call. @@ -292,7 +301,8 @@ public function pay( $transaction, $stateData, $this->remainingAmount, - $this->orderRequestData + $this->orderRequestData, + $billieData ); //make /payments call $this->paymentsCall($salesChannelContext, $request, $transaction); @@ -591,6 +601,19 @@ protected function preparePaymentsRequest( $paymentRequest->setShopperIP($shopperIp); $paymentRequest->setShopperReference($shopperReference); + if (!empty($request['billieData'])) { + $billieData = $request['billieData']; + + $companyName = $billieData['companyName'] ?? ''; + $registrationNumber = $billieData['registrationNumber'] ?? ''; + + $company = new Company(); + $company + ->setRegistrationNumber($registrationNumber) + ->setName($companyName); + $paymentRequest->setCompany($company); + } + //Building payment data $amount = $partialAmount ?: $this->currency->sanitize( $transaction->getOrder()->getPrice()->getTotalPrice(), @@ -718,9 +741,11 @@ private function getPaymentRequest( $transaction, $stateData, $partialAmount, - $orderRequestData + $orderRequestData, + $billieData = [] ) { $transactionId = $transaction->getOrderTransaction()->getId(); + $stateData['billieData'] = $billieData; try { $request = $this->preparePaymentsRequest( $salesChannelContext, diff --git a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js index d63d70b2d..e661b964a 100644 --- a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js +++ b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js @@ -1 +1 @@ -(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","dotpay","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",sofort:"handler_adyen_sofortpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",dotpay:"handler_adyen_dotpaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id);let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId})),y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file +(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#company-name"),n=e?e.value:"",a=r.querySelector(document,"#registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId})),y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file diff --git a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js index 0d475ee06..66ebb4237 100644 --- a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js +++ b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js @@ -62,6 +62,12 @@ export default class ConfirmOrderPlugin extends Plugin { // replaces confirm button with adyen pay button for paywithgoogle, applepay etc. this.initializeCustomPayButton(); } + + if (this.selectedAdyenPaymentMethod === "klarna_b2b") { + this.confirmFormSubmit.addEventListener('click', this.onConfirmOrderSubmit.bind(this)); + return; + } + if (adyenConfiguration.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod) && !this.stateData) { // create inline component for cards etc. and set event listener for submit button to confirm payment component this.renderPaymentComponent(this.selectedAdyenPaymentMethod); @@ -245,6 +251,17 @@ export default class ConfirmOrderPlugin extends Plugin { this.errorUrl = new URL( location.origin + adyenCheckoutOptions.paymentErrorUrl); this.errorUrl.searchParams.set('orderId', order.id); + + if (adyenCheckoutOptions.selectedPaymentMethodHandler === 'handler_adyen_billiepaymentmethodhandler') { + const companyNameElement = DomAccess.querySelector(document, '#company-name'); + const companyName = companyNameElement ? companyNameElement.value : ''; + const registrationNumberElement = DomAccess.querySelector(document, '#registration-number'); + const registrationNumber = registrationNumberElement ? registrationNumberElement.value : ''; + + extraParams.companyName = companyName; + extraParams.registrationNumber = registrationNumber; + } + let params = { 'orderId': this.orderId, 'finishUrl': this.finishUrl.toString(), diff --git a/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig new file mode 100644 index 000000000..e9aa05153 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig @@ -0,0 +1,30 @@ +{% if payment.formattedHandlerIdentifier == 'handler_adyen_billiepaymentmethodhandler' %} +
+

+ All fields are required unless marked otherwise. +

+
+ + +
+
+ + +
+
+{% endif %} diff --git a/src/Resources/views/storefront/component/payment/payment-method.html.twig b/src/Resources/views/storefront/component/payment/payment-method.html.twig index 57e7d72c6..6dd189307 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -17,5 +17,6 @@ {% if payment.id is same as(selectedPaymentMethodId) and 'handler_adyen_' in payment.formattedHandlerIdentifier %} {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/billie-payment-method.html.twig' %} {% endif %} {% endblock %} diff --git a/src/Subscriber/PaymentSubscriber.php b/src/Subscriber/PaymentSubscriber.php index 875d509d8..8be8bb61a 100644 --- a/src/Subscriber/PaymentSubscriber.php +++ b/src/Subscriber/PaymentSubscriber.php @@ -405,6 +405,7 @@ public function onCheckoutConfirmLoaded(PageLoadedEvent $event) ), 'affiliateCode' => $affiliateCode, 'campaignCode' => $campaignCode, + 'companyName' => $salesChannelContext->getCustomer()->getActiveBillingAddress()->getCompany(), ] ) ) diff --git a/src/Util/CheckoutStateDataValidator.php b/src/Util/CheckoutStateDataValidator.php index 7e6fdab6d..bd577bcd7 100644 --- a/src/Util/CheckoutStateDataValidator.php +++ b/src/Util/CheckoutStateDataValidator.php @@ -21,7 +21,8 @@ class CheckoutStateDataValidator 'conversionId', 'paymentData', 'details', - 'origin' + 'origin', + 'billieData' ); /** From 59a7b6de3694d97871b9023005236f1f9c9470d1 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 12:49:53 +0100 Subject: [PATCH 03/23] Fix reinstallation flow ISSUE: CS-6247 --- .../Migration1681716164AlterAdyenPayment.php | 15 +++++++++++++++ .../Migration1713255011AlterAdyenPayment.php | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Migration/Migration1681716164AlterAdyenPayment.php b/src/Migration/Migration1681716164AlterAdyenPayment.php index 49efa04ed..5d3d54a8a 100644 --- a/src/Migration/Migration1681716164AlterAdyenPayment.php +++ b/src/Migration/Migration1681716164AlterAdyenPayment.php @@ -14,6 +14,21 @@ public function getCreationTimestamp(): int public function update(Connection $connection): void { + $schemaManager = $connection->createSchemaManager(); + + // check if table exists + if (!$schemaManager->tablesExist(['adyen_payment'])) { + return; + } + + // check if index already exists + $indexes = $schemaManager->listTableIndexes('adyen_payment'); + foreach ($indexes as $index) { + if ($index->getName() === 'UQ_ADYEN_PAYMENT_PSPREFERENCE') { + return; + } + } + $query = <<createSchemaManager(); + + // check if table exists + if (!$schemaManager->tablesExist(['adyen_payment'])) { + return; + } + + // check if column already exists + $columns = $schemaManager->listTableColumns('adyen_payment'); + if (array_key_exists('total_refunded', $columns)) { + return; + } + $connection->executeStatement(<< Date: Wed, 4 Dec 2024 13:55:15 +0100 Subject: [PATCH 04/23] Fix reinstallation flow by deleting all plugin tables ISSUE: CS-6247 --- src/AdyenPaymentShopware6.php | 8 +++++++- .../Migration1681716164AlterAdyenPayment.php | 15 --------------- .../Migration1713255011AlterAdyenPayment.php | 13 ------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/AdyenPaymentShopware6.php b/src/AdyenPaymentShopware6.php index c11c93442..fb4eac659 100644 --- a/src/AdyenPaymentShopware6.php +++ b/src/AdyenPaymentShopware6.php @@ -25,9 +25,12 @@ namespace Adyen\Shopware; +use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntityDefinition; use Adyen\Shopware\Entity\Notification\NotificationEntityDefinition; +use Adyen\Shopware\Entity\PaymentCapture\PaymentCaptureEntityDefinition; use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition; use Adyen\Shopware\Entity\PaymentStateData\PaymentStateDataEntityDefinition; +use Adyen\Shopware\Entity\Refund\RefundEntityDefinition; use Adyen\Shopware\Handlers\KlarnaDebitRiskPaymentMethodHandler; use Adyen\Shopware\PaymentMethods\KlarnaDebitRiskPaymentMethod; use Adyen\Shopware\Service\ConfigurationService; @@ -278,7 +281,10 @@ private function removePluginData(): void $tables = [ NotificationEntityDefinition::ENTITY_NAME, PaymentStateDataEntityDefinition::ENTITY_NAME, - PaymentResponseEntityDefinition::ENTITY_NAME + PaymentResponseEntityDefinition::ENTITY_NAME, + AdyenPaymentEntityDefinition::ENTITY_NAME, + PaymentCaptureEntityDefinition::ENTITY_NAME, + RefundEntityDefinition::ENTITY_NAME ]; $connection = $this->container->get(Connection::class); foreach ($tables as $table) { diff --git a/src/Migration/Migration1681716164AlterAdyenPayment.php b/src/Migration/Migration1681716164AlterAdyenPayment.php index 5d3d54a8a..49efa04ed 100644 --- a/src/Migration/Migration1681716164AlterAdyenPayment.php +++ b/src/Migration/Migration1681716164AlterAdyenPayment.php @@ -14,21 +14,6 @@ public function getCreationTimestamp(): int public function update(Connection $connection): void { - $schemaManager = $connection->createSchemaManager(); - - // check if table exists - if (!$schemaManager->tablesExist(['adyen_payment'])) { - return; - } - - // check if index already exists - $indexes = $schemaManager->listTableIndexes('adyen_payment'); - foreach ($indexes as $index) { - if ($index->getName() === 'UQ_ADYEN_PAYMENT_PSPREFERENCE') { - return; - } - } - $query = <<createSchemaManager(); - - // check if table exists - if (!$schemaManager->tablesExist(['adyen_payment'])) { - return; - } - - // check if column already exists - $columns = $schemaManager->listTableColumns('adyen_payment'); - if (array_key_exists('total_refunded', $columns)) { - return; - } - $connection->executeStatement(<< Date: Wed, 4 Dec 2024 15:42:19 +0100 Subject: [PATCH 05/23] Change redirect url for Billie payment method ADCRSET24I-5 --- src/Handlers/AbstractPaymentMethodHandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 177409c30..c54d4ef02 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -343,8 +343,11 @@ public function pay( // Payment had no error, continue the process - // If Bancontact mobile payment is used, redirect to proxy finalize transaction endpoint - if ($stateData['paymentMethod']['type'] === 'bcmc_mobile') { + // If Bancontact mobile or Billie payment method is used, redirect to proxy finalize transaction endpoint + if ( + $stateData['paymentMethod']['type'] === 'bcmc_mobile' || + $stateData['paymentMethod']['type'] === 'klarna_b2b' + ) { return new RedirectResponse($this->getReturnUrl($transaction)); } @@ -629,7 +632,7 @@ protected function preparePaymentsRequest( $paymentRequest->setMerchantAccount( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); - if ($paymentMethodType === 'bcmc_mobile') { + if ($paymentMethodType === 'bcmc_mobile' || $paymentMethodType === 'klarna_b2b') { $paymentRequest->setReturnUrl($this->getReturnUrl($transaction)); } else { $paymentRequest->setReturnUrl($transaction->getReturnUrl()); From 13e2470eaaf1204d568d0428d46975c4a87169eb Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 4 Dec 2024 16:04:54 +0100 Subject: [PATCH 06/23] Revert "Change redirect url for Billie payment method" This reverts commit 101799bc7cd72f5a9e28df94b79edf6ccf6bb460. --- src/Handlers/AbstractPaymentMethodHandler.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index c54d4ef02..177409c30 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -343,11 +343,8 @@ public function pay( // Payment had no error, continue the process - // If Bancontact mobile or Billie payment method is used, redirect to proxy finalize transaction endpoint - if ( - $stateData['paymentMethod']['type'] === 'bcmc_mobile' || - $stateData['paymentMethod']['type'] === 'klarna_b2b' - ) { + // If Bancontact mobile payment is used, redirect to proxy finalize transaction endpoint + if ($stateData['paymentMethod']['type'] === 'bcmc_mobile') { return new RedirectResponse($this->getReturnUrl($transaction)); } @@ -632,7 +629,7 @@ protected function preparePaymentsRequest( $paymentRequest->setMerchantAccount( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); - if ($paymentMethodType === 'bcmc_mobile' || $paymentMethodType === 'klarna_b2b') { + if ($paymentMethodType === 'bcmc_mobile') { $paymentRequest->setReturnUrl($this->getReturnUrl($transaction)); } else { $paymentRequest->setReturnUrl($transaction->getReturnUrl()); From 1467a8d5a1dc3a2dbe016802b3d30dcb30b0029e Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 16:24:02 +0100 Subject: [PATCH 07/23] Add required fields and messages ISSUE: ADCRSET24I-5 --- .../src/checkout/confirm-order.plugin.js | 34 +++++++++++++++++-- .../payment/billie-payment-method.html.twig | 14 ++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js index 66ebb4237..bb5937605 100644 --- a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js +++ b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js @@ -131,6 +131,36 @@ export default class ConfirmOrderPlugin extends Plugin { if (!form.checkValidity()) { return; } + + if (this.selectedAdyenPaymentMethod === "klarna_b2b") { + const companyNameElement = DomAccess.querySelector(document, '#adyen-company-name'); + const registrationNumberElement = DomAccess.querySelector(document, '#adyen-registration-number'); + + const companyName = companyNameElement ? companyNameElement.value.trim() : ''; + const registrationNumber = registrationNumberElement ? registrationNumberElement.value.trim() : ''; + const companyNameError = DomAccess.querySelector(document, '#adyen-company-name-error'); + const registrationNumberError = DomAccess.querySelector(document, '#adyen-registration-number-error'); + companyNameError.style.display = 'none'; + registrationNumberError.style.display = 'none'; + + let hasError = false; + + if (!companyName) { + companyNameError.style.display = 'block'; + hasError = true; + } + + if (!registrationNumber) { + registrationNumberError.style.display = 'block'; + hasError = true; + } + + if (hasError) { + event.preventDefault(); + return; + } + } + event.preventDefault(); ElementLoadingIndicatorUtil.create(document.body); const formData = FormSerializeUtil.serialize(form); @@ -253,9 +283,9 @@ export default class ConfirmOrderPlugin extends Plugin { this.errorUrl.searchParams.set('orderId', order.id); if (adyenCheckoutOptions.selectedPaymentMethodHandler === 'handler_adyen_billiepaymentmethodhandler') { - const companyNameElement = DomAccess.querySelector(document, '#company-name'); + const companyNameElement = DomAccess.querySelector(document, '#adyen-company-name'); const companyName = companyNameElement ? companyNameElement.value : ''; - const registrationNumberElement = DomAccess.querySelector(document, '#registration-number'); + const registrationNumberElement = DomAccess.querySelector(document, '#adyen-registration-number'); const registrationNumber = registrationNumberElement ? registrationNumberElement.value : ''; extraParams.companyName = companyName; diff --git a/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig index e9aa05153..0859b2537 100644 --- a/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig @@ -3,11 +3,11 @@

All fields are required unless marked otherwise.

-
- +
+
-
- + +
+
+
{% endif %} From 92ad74eca7f7a2cf5de97db8a77eab2f8971fd48 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 4 Dec 2024 22:54:26 +0100 Subject: [PATCH 08/23] Fix Bancontact mobile behavior ADCRSET24I-7 --- src/Handlers/AbstractPaymentMethodHandler.php | 6 +- src/Handlers/ResultHandler.php | 14 ++-- src/Resources/config/services.xml | 1 + .../snippet/de_DE/messages.de-DE.json | 3 +- .../snippet/en_GB/messages.en-GB.json | 3 +- .../page/checkout/cart/index.html.twig | 26 +------- src/Service/AdyenPaymentService.php | 30 ++++++++- .../Controller/FrontendProxyController.php | 66 +++++++++---------- src/Subscriber/PaymentSubscriber.php | 13 ---- 9 files changed, 80 insertions(+), 82 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 90fa92059..bf367d3d5 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -349,7 +349,11 @@ private function getReturnUrl(AsyncPaymentTransactionStruct $transaction): strin return $this->symfonyRouter->generate( 'payment.adyen.proxy-finalize-transaction', - ['_sw_payment_token' => $token, 'orderId' => $transaction->getOrder()->getId()], + [ + '_sw_payment_token' => $token, + 'orderId' => $transaction->getOrder()->getId(), + 'transactionId' => $transaction->getOrderTransaction()->getId() + ], UrlGeneratorInterface::ABSOLUTE_URL ); } diff --git a/src/Handlers/ResultHandler.php b/src/Handlers/ResultHandler.php index b36c2906f..6b31be9fc 100644 --- a/src/Handlers/ResultHandler.php +++ b/src/Handlers/ResultHandler.php @@ -115,10 +115,16 @@ public function processResult( } $result = $this->paymentResponseHandlerResult->createFromPaymentResponse($paymentResponse); - - if ('RedirectShopper' === $result->getResultCode()) { - $requestResponse = $request->getMethod() === 'GET' ? $request->query->all() : $request->request->all(); - + $requestResponse = $request->getMethod() === 'GET' ? $request->query->all() : $request->request->all(); + + if ( + 'RedirectShopper' === $result->getResultCode() || + ( + $salesChannelContext->getPaymentMethod()->getFormattedHandlerIdentifier() === + 'handler_adyen_bancontactmobilepaymentmethodhandler' && + $requestResponse['redirectResult'] + ) + ) { $details = DataArrayValidator::getArrayOnlyWithApprovedKeys($requestResponse, [ self::PA_RES, self::MD, diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 5d981b6a6..c64225631 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -95,6 +95,7 @@ + diff --git a/src/Resources/snippet/de_DE/messages.de-DE.json b/src/Resources/snippet/de_DE/messages.de-DE.json index b5253ad89..4b108601c 100644 --- a/src/Resources/snippet/de_DE/messages.de-DE.json +++ b/src/Resources/snippet/de_DE/messages.de-DE.json @@ -10,7 +10,6 @@ "remainingBalance": "Verbleibendes guthaben der geschenkkarte", "remainingAmount": "Restbetrag", "discount": "Geschenkkarten-Rabatt" - }, - "unsuccessful_adyen_transaction": "Payment with Bancontact mobile was unsuccessful. Please change the payment method or try again." + } } } diff --git a/src/Resources/snippet/en_GB/messages.en-GB.json b/src/Resources/snippet/en_GB/messages.en-GB.json index da75f65f7..ae41ceaa1 100644 --- a/src/Resources/snippet/en_GB/messages.en-GB.json +++ b/src/Resources/snippet/en_GB/messages.en-GB.json @@ -11,7 +11,6 @@ "deductedAmount": "Deducted Amount", "remainingAmount": "Remaining amount", "discount": "Giftcard discount" - }, - "unsuccessful_adyen_transaction": "Payment with Bancontact mobile was unsuccessful. Please change the payment method or try again." + } } } diff --git a/src/Resources/views/storefront/page/checkout/cart/index.html.twig b/src/Resources/views/storefront/page/checkout/cart/index.html.twig index b5e3bb831..59d8e0851 100644 --- a/src/Resources/views/storefront/page/checkout/cart/index.html.twig +++ b/src/Resources/views/storefront/page/checkout/cart/index.html.twig @@ -6,28 +6,4 @@ {% sw_include '@AdyenPaymentShopware6/storefront/component/adyencheckout.html.twig' %} {% sw_include '@AdyenPaymentShopware6/storefront/component/checkout/cart/giftcards.html.twig' %} -{% endblock %} - -{% block page_checkout_container %} - {% if page.cart.lineItems.count is same as(0) %} - {{ parent() }} - {% if page.extensions['errorCodes'].errorCode == 'UNSUCCESSFUL_ADYEN_TRANSACTION'%} - {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with { - type: 'danger', - content: 'adyen.unsuccessful_adyen_transaction' | trans - } %} - {% endif %} - {% else %} - {{ parent() }} - {% endif %} -{% endblock %} - -{% block page_checkout_cart_header %} - {{ parent() }} - {% if page.extensions['errorCodes'].errorCode == 'UNSUCCESSFUL_ADYEN_TRANSACTION'%} - {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with { - type: 'danger', - content: 'adyen.unsuccessful_adyen_transaction' | trans - } %} - {% endif %} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index 019af8b02..54e85454f 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -29,11 +29,15 @@ use Adyen\Shopware\Service\Repository\AdyenPaymentRepository; use Adyen\Shopware\Util\Currency; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; +use Shopware\Core\Checkout\Payment\Cart\AbstractPaymentTransactionStructFactory; +use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; +use Shopware\Core\System\SalesChannel\SalesChannelContext; class AdyenPaymentService { @@ -43,12 +47,19 @@ class AdyenPaymentService protected AdyenPaymentRepository $adyenPaymentRepository; protected EntityRepository $orderTransactionRepository; + /** + * @var AbstractPaymentTransactionStructFactory + */ + private AbstractPaymentTransactionStructFactory $paymentTransactionStructFactory; + public function __construct( AdyenPaymentRepository $adyenPaymentRepository, - EntityRepository $orderTransactionRepository + EntityRepository $orderTransactionRepository, + AbstractPaymentTransactionStructFactory $paymentTransactionStructFactory ) { $this->adyenPaymentRepository = $adyenPaymentRepository; $this->orderTransactionRepository = $orderTransactionRepository; + $this->paymentTransactionStructFactory = $paymentTransactionStructFactory; } public function insertAdyenPayment( @@ -168,4 +179,21 @@ public function updateTotalRefundedAmount(AdyenPaymentEntity $adyenPaymentEntity ] ], Context::createDefaultContext()); } + + public function getPaymentTransactionStruct(string $orderTransactionId, SalesChannelContext $context): AsyncPaymentTransactionStruct + { + $criteria = new Criteria([$orderTransactionId]); + $criteria->setTitle('payment-service::load-transaction'); + $criteria->addAssociation('order'); + $criteria->addAssociation('paymentMethod.appPaymentMethod.app'); + + /** @var OrderTransactionEntity|null $orderTransaction */ + $orderTransaction = $this->orderTransactionRepository->search($criteria, $context->getContext())->first(); + + if ($orderTransaction === null || $orderTransaction->getOrder() === null) { + throw PaymentException::invalidTransaction($orderTransactionId); + } + + return $this->paymentTransactionStructFactory->async($orderTransaction, $orderTransaction->getOrder(), ''); + } } diff --git a/src/Storefront/Controller/FrontendProxyController.php b/src/Storefront/Controller/FrontendProxyController.php index e08b1ecf9..2a9f16401 100644 --- a/src/Storefront/Controller/FrontendProxyController.php +++ b/src/Storefront/Controller/FrontendProxyController.php @@ -28,11 +28,13 @@ use Adyen\Shopware\Controller\StoreApi\OrderApi\OrderApiController; use Adyen\Shopware\Controller\StoreApi\Payment\PaymentController; use Adyen\Shopware\Handlers\PaymentResponseHandler; +use Adyen\Shopware\Service\AdyenPaymentService; use Adyen\Shopware\Util\ShopwarePaymentTokenValidator; use Error; use Shopware\Core\Checkout\Cart\Exception\InvalidCartException; use Shopware\Core\Checkout\Cart\SalesChannel\AbstractCartOrderRoute; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates; use Shopware\Core\Checkout\Order\Exception\EmptyCartException; use Shopware\Core\Checkout\Order\SalesChannel\SetPaymentOrderRouteResponse; use Shopware\Core\Checkout\Payment\SalesChannel\AbstractHandlePaymentMethodRoute; @@ -96,6 +98,11 @@ class FrontendProxyController extends StorefrontController */ private ShopwarePaymentTokenValidator $paymentTokenValidator; + /** + * @var AdyenPaymentService + */ + private AdyenPaymentService $adyenPaymentService; + /** * @param AbstractCartOrderRoute $cartOrderRoute * @param AbstractHandlePaymentMethodRoute $handlePaymentMethodRoute @@ -106,6 +113,7 @@ class FrontendProxyController extends StorefrontController * @param OrderApiController $orderApiController * @param DonateController $donateController * @param ShopwarePaymentTokenValidator $paymentTokenValidator + * @param AdyenPaymentService $adyenPaymentService */ public function __construct(//NOSONAR AbstractCartOrderRoute $cartOrderRoute,//NOSONAR @@ -116,7 +124,8 @@ public function __construct(//NOSONAR PaymentController $paymentController,//NOSONAR OrderApiController $orderApiController,//NOSONAR DonateController $donateController,//NOSONAR - ShopwarePaymentTokenValidator $paymentTokenValidator//NOSONAR + ShopwarePaymentTokenValidator $paymentTokenValidator,//NOSONAR + AdyenPaymentService $adyenPaymentService ) {//NOSONAR $this->cartOrderRoute = $cartOrderRoute; $this->cartService = $cartService; @@ -127,6 +136,7 @@ public function __construct(//NOSONAR $this->orderApiController = $orderApiController; $this->donateController = $donateController; $this->paymentTokenValidator = $paymentTokenValidator; + $this->adyenPaymentService = $adyenPaymentService; } /** @@ -196,46 +206,34 @@ public function handlePayment(Request $request, SalesChannelContext $salesChanne public function finalizeTransaction(Request $request, SalesChannelContext $salesChannelContext): RedirectResponse { $paymentToken = $request->get('_sw_payment_token'); - $redirectResult = $request->get('redirectResult'); - - if ($this->paymentTokenValidator->validateToken($paymentToken) && !$redirectResult) { - return new RedirectResponse( - $this->router->generate( - 'payment.finalize.transaction', - ['_sw_payment_token' => $paymentToken], - UrlGeneratorInterface::ABSOLUTE_URL - ) + if ($this->paymentTokenValidator->validateToken($paymentToken)) { + return $this->redirectToRoute( + 'payment.finalize.transaction', + $request->query->all(), ); } + $transactionId = $request->get('transactionId'); $orderId = $request->get('orderId') ?? ''; - $stateData = ['details' => ['redirectResult' => $redirectResult]]; - $request->request->add(['stateData' => json_encode($stateData, JSON_THROW_ON_ERROR)]); - $request->request->add(['orderId' => $orderId]); - $response = $this->paymentController->postPaymentDetails($request, $salesChannelContext); - $resultCode = json_decode( - $response->getContent(), - false, - 512, - JSON_THROW_ON_ERROR - )->resultCode ?? ''; - - if ($resultCode === PaymentResponseHandler::AUTHORISED) { - return new RedirectResponse( - $this->router->generate( - 'frontend.checkout.finish.page', - ['orderId' => $orderId], - UrlGeneratorInterface::ABSOLUTE_URL - ) + $transaction = $this->adyenPaymentService->getPaymentTransactionStruct($transactionId, $salesChannelContext); + $transactionState = $transaction->getOrderTransaction()->getStateMachineState(); + $transactionStateTechnicalName = $transactionState ? + $transactionState->getTechnicalName() : OrderTransactionStates::STATE_FAILED; + + if ($transactionStateTechnicalName === OrderTransactionStates::STATE_FAILED || + $transactionStateTechnicalName === OrderTransactionStates::STATE_CANCELLED) { + return $this->redirectToRoute( + 'frontend.account.edit-order.page', + [ + 'orderId' => $orderId, + 'error-code' => 'CHECKOUT__UNKNOWN_ERROR', + ] ); } - return new RedirectResponse( - $this->router->generate( - 'frontend.checkout.cart.page', - ['errorCode' => 'UNSUCCESSFUL_ADYEN_TRANSACTION'], - UrlGeneratorInterface::ABSOLUTE_URL - ) + return $this->redirectToRoute( + 'frontend.checkout.finish.page', + ['orderId' => $orderId] ); } diff --git a/src/Subscriber/PaymentSubscriber.php b/src/Subscriber/PaymentSubscriber.php index 875d509d8..8b04500f8 100644 --- a/src/Subscriber/PaymentSubscriber.php +++ b/src/Subscriber/PaymentSubscriber.php @@ -215,19 +215,6 @@ public function onShoppingCartLoaded(PageLoadedEvent $event) { /** @var CheckoutCartPage|OffcanvasCartPage $page */ $page = $event->getPage(); - $errorCodes = []; - if ($event->getRequest()->get('errorCode') - && $event->getRequest()->get('errorCode') === 'UNSUCCESSFUL_ADYEN_TRANSACTION' - ) { - $errorCodes['errorCode'] = 'UNSUCCESSFUL_ADYEN_TRANSACTION'; - $page->addExtension( - 'errorCodes', - new ArrayEntity( - $errorCodes - ) - ); - } - if ($page->getCart()->getLineItems()->count() === 0) { return; } From 6bb85304fe7c4e3586dea3d764be549d6c2e957d Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 11:24:04 +0100 Subject: [PATCH 09/23] Fixing PHP code sniffer issues --- src/Handlers/AbstractPaymentMethodHandler.php | 6 ++---- src/Handlers/ResultHandler.php | 3 +-- src/Models/PaymentRequest.php | 3 +-- src/Service/AdyenPaymentService.php | 6 ++++-- src/Service/PaymentMethodsFilterService.php | 3 +-- src/Subscriber/PaymentSubscriber.php | 7 +++---- src/Util/RatePayDeviceFingerprintParamsProvider.php | 5 ++--- 7 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 36cfd8fea..363aa71fc 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -323,8 +323,7 @@ public function pay( } $paymentMethodType = $stateData['paymentMethod']['type']; - if ( - $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE ) { $this->ratePayFingerprintParamsProvider->clear(); @@ -658,8 +657,7 @@ protected function preparePaymentsRequest( $paymentRequest->setReturnUrl($transaction->getReturnUrl()); } - if ( - $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE ) { $paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken()); diff --git a/src/Handlers/ResultHandler.php b/src/Handlers/ResultHandler.php index 6b31be9fc..37d479f50 100644 --- a/src/Handlers/ResultHandler.php +++ b/src/Handlers/ResultHandler.php @@ -117,8 +117,7 @@ public function processResult( $result = $this->paymentResponseHandlerResult->createFromPaymentResponse($paymentResponse); $requestResponse = $request->getMethod() === 'GET' ? $request->query->all() : $request->request->all(); - if ( - 'RedirectShopper' === $result->getResultCode() || + if ('RedirectShopper' === $result->getResultCode() || ( $salesChannelContext->getPaymentMethod()->getFormattedHandlerIdentifier() === 'handler_adyen_bancontactmobilepaymentmethodhandler' && diff --git a/src/Models/PaymentRequest.php b/src/Models/PaymentRequest.php index 27bd87f0c..129c38aa0 100755 --- a/src/Models/PaymentRequest.php +++ b/src/Models/PaymentRequest.php @@ -566,8 +566,7 @@ public function __construct(array $data = null) parent::__construct($data); $data = $data ?? []; - if ( - self::isNullable('bankAccount') && + if (self::isNullable('bankAccount') && array_key_exists('bankAccount', $data) && is_null($data['bankAccount']) ) { diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index 54e85454f..b3e4f0e0f 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -180,8 +180,10 @@ public function updateTotalRefundedAmount(AdyenPaymentEntity $adyenPaymentEntity ], Context::createDefaultContext()); } - public function getPaymentTransactionStruct(string $orderTransactionId, SalesChannelContext $context): AsyncPaymentTransactionStruct - { + public function getPaymentTransactionStruct( + string $orderTransactionId, + SalesChannelContext $context + ): AsyncPaymentTransactionStruct { $criteria = new Criteria([$orderTransactionId]); $criteria->setTitle('payment-service::load-transaction'); $criteria->addAssociation('order'); diff --git a/src/Service/PaymentMethodsFilterService.php b/src/Service/PaymentMethodsFilterService.php index 926c21c4b..6d9a6f6dc 100644 --- a/src/Service/PaymentMethodsFilterService.php +++ b/src/Service/PaymentMethodsFilterService.php @@ -116,8 +116,7 @@ function (PaymentMethodEntity $item) use ($adyenPluginId) { $pmCode = $pmHandlerIdentifier::getPaymentMethodCode(); $isSafari = preg_match('/^((?!chrome|android).)*safari/', strtolower($_SERVER['HTTP_USER_AGENT'])); - if ( - ( + if (( $pmCode === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || $pmCode === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE ) && diff --git a/src/Subscriber/PaymentSubscriber.php b/src/Subscriber/PaymentSubscriber.php index 8c1921909..5bc5d7432 100644 --- a/src/Subscriber/PaymentSubscriber.php +++ b/src/Subscriber/PaymentSubscriber.php @@ -448,10 +448,9 @@ public function onKernelRequest(RequestEvent $event) private function getFingerprintParametersForRatepayMethod( SalesChannelContext $salesChannelContext, PaymentMethodEntity $paymentMethod - ): array - { - if ( - $paymentMethod->getFormattedHandlerIdentifier() === 'handler_adyen_ratepaydirectdebitpaymentmethodhandler' || + ): array { + if ($paymentMethod->getFormattedHandlerIdentifier() === + 'handler_adyen_ratepaydirectdebitpaymentmethodhandler' || $paymentMethod->getFormattedHandlerIdentifier() === 'handler_adyen_ratepaypaymentmethodhandler' ) { return ['ratepay' => $this->ratePayFingerprintParamsProvider diff --git a/src/Util/RatePayDeviceFingerprintParamsProvider.php b/src/Util/RatePayDeviceFingerprintParamsProvider.php index ba8fd00a4..12b3e9138 100644 --- a/src/Util/RatePayDeviceFingerprintParamsProvider.php +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -23,8 +23,7 @@ class RatePayDeviceFingerprintParamsProvider public function __construct( RequestStack $requestStack, ConfigurationService $configurationService - ) - { + ) { $this->requestStack = $requestStack; $this->configurationService = $configurationService; } @@ -71,4 +70,4 @@ public function clear(): void { $this->requestStack->getSession()->remove(self::TOKEN_SESSION_KEY); } -} \ No newline at end of file +} From 6692582acf36709e0b3a5719f8d4d00dc221473a Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 12:40:16 +0100 Subject: [PATCH 10/23] Build storefront assets ADCRSET24I-13 --- .../js/adyen-payment-shopware6/adyen-payment-shopware6.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js index e661b964a..0a3363530 100644 --- a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js +++ b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js @@ -1 +1 @@ -(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#company-name"),n=e?e.value:"",a=r.querySelector(document,"#registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId})),y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file +(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){let t=r.querySelector(document,"#adyen-company-name"),n=r.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",i=n?n.value.trim():"",o=r.querySelector(document,"#adyen-company-name-error"),s=r.querySelector(document,"#adyen-registration-number-error");o.style.display="none",s.style.display="none";let d=!1;if(a||(o.style.display="block",d=!0),i||(s.style.display="block",d=!0),d){e.preventDefault();return}}e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#adyen-company-name"),n=e?e.value:"",a=r.querySelector(document,"#adyen-registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId})),y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file From aa822a4f9ab97ed51865836dc603bfb4fc636139 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 12:40:51 +0100 Subject: [PATCH 11/23] Version bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7ed387ea4..799ea4ea1 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ } ], "description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen", - "version": "4.2.0", + "version": "4.2.1", "type": "shopware-platform-plugin", "license": "MIT", "require": { From 0c874e4c8c4dc165539a3c1e3ad0fe046c3d0191 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 16:17:24 +0100 Subject: [PATCH 12/23] Fix the issue with Bancontact mobile payments --- src/Service/AdyenPaymentService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index b3e4f0e0f..f159e2fc3 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -188,6 +188,7 @@ public function getPaymentTransactionStruct( $criteria->setTitle('payment-service::load-transaction'); $criteria->addAssociation('order'); $criteria->addAssociation('paymentMethod.appPaymentMethod.app'); + $criteria->addAssociation('stateMachineState'); /** @var OrderTransactionEntity|null $orderTransaction */ $orderTransaction = $this->orderTransactionRepository->search($criteria, $context->getContext())->first(); From b7ff4ffcb05f4ff60086ccb82e9a1c3a996c1c03 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Fri, 6 Dec 2024 12:29:29 +0100 Subject: [PATCH 13/23] Add scripts for deleting installed.php to composer.json ISSUE: CS-6204 --- composer.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/composer.json b/composer.json index 7ed387ea4..ac7b55e04 100644 --- a/composer.json +++ b/composer.json @@ -48,5 +48,13 @@ "allow-plugins": { "symfony/*": true } + }, + "scripts": { + "post-install-cmd": [ + "rm -f vendor/composer/installed.php" + ], + "post-update-cmd": [ + "rm -f vendor/composer/installed.php" + ] } } From 5e4908dcc5e8b3263e7990438fc56cadf0c9fa50 Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 13:19:57 +0100 Subject: [PATCH 14/23] Ignore SonarQube issue --- .../storefront/component/payment/payment-ratepay.html.twig | 4 ++++ src/Util/RatePayDeviceFingerprintParamsProvider.php | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig index 53ff0c93b..45dc61c29 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -7,5 +7,9 @@ l: '{{ adyenFrontendData.ratepay.location }}' }; + {# + NOSONAR: This block is excluded from Sonar analysis because the script is provided by + Device Fingerprinting method. + #} {% endif %} \ No newline at end of file diff --git a/src/Util/RatePayDeviceFingerprintParamsProvider.php b/src/Util/RatePayDeviceFingerprintParamsProvider.php index 12b3e9138..057356c0e 100644 --- a/src/Util/RatePayDeviceFingerprintParamsProvider.php +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -53,6 +53,7 @@ public function getToken(): string if (!$this->requestStack->getSession()->get(self::TOKEN_SESSION_KEY)) { $this->requestStack->getSession()->set( self::TOKEN_SESSION_KEY, + //NOSONAR This is excluded from Sonar analysis because md5 is used to generate a unique token. md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime()) ); } From 01f4e303f86273b153de1ad229dbc19792ebd21b Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 13:29:38 +0100 Subject: [PATCH 15/23] Update ignore SonarQube --- .../storefront/component/payment/payment-ratepay.html.twig | 7 ++----- src/Util/RatePayDeviceFingerprintParamsProvider.php | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig index 45dc61c29..018309aeb 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -7,9 +7,6 @@ l: '{{ adyenFrontendData.ratepay.location }}' }; - {# - NOSONAR: This block is excluded from Sonar analysis because the script is provided by - Device Fingerprinting method. - #} - + {# This block is excluded from Sonar analysis because the script is provided by Device Fingerprinting method. #} + {% endif %} \ No newline at end of file diff --git a/src/Util/RatePayDeviceFingerprintParamsProvider.php b/src/Util/RatePayDeviceFingerprintParamsProvider.php index 057356c0e..fe82a9d4d 100644 --- a/src/Util/RatePayDeviceFingerprintParamsProvider.php +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -53,8 +53,8 @@ public function getToken(): string if (!$this->requestStack->getSession()->get(self::TOKEN_SESSION_KEY)) { $this->requestStack->getSession()->set( self::TOKEN_SESSION_KEY, - //NOSONAR This is excluded from Sonar analysis because md5 is used to generate a unique token. - md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime()) + // This is excluded from Sonar analysis because md5 is used to generate a unique token. + md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime())//NOSONAR ); } From f45a5ae115fbe757d2d21a5beacd6b1580728f5f Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 13:36:26 +0100 Subject: [PATCH 16/23] Update ignore SonarQube --- .../storefront/component/payment/payment-ratepay.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig index 018309aeb..8940fc554 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -8,5 +8,5 @@ }; {# This block is excluded from Sonar analysis because the script is provided by Device Fingerprinting method. #} - + {% endif %} \ No newline at end of file From 35d4c0553b21799344b60d09636c0639dd8054f8 Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 13:38:17 +0100 Subject: [PATCH 17/23] Update ignore SonarQube --- .../storefront/component/payment/payment-ratepay.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig index 8940fc554..b149d7cca 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -8,5 +8,5 @@ }; {# This block is excluded from Sonar analysis because the script is provided by Device Fingerprinting method. #} - + {# //NOSONAR #} {% endif %} \ No newline at end of file From fe9d2887d7a1e977cd465b6189fa6dd03f60a4d9 Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 14:02:11 +0100 Subject: [PATCH 18/23] Update ignore SonarQube --- .../storefront/component/payment/payment-ratepay.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig index b149d7cca..1acff3a0f 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -8,5 +8,5 @@ }; {# This block is excluded from Sonar analysis because the script is provided by Device Fingerprinting method. #} - {# //NOSONAR #} + {% endif %} \ No newline at end of file From b1d0dec7f3226b200b73074e9a6d8b7aee9dce6b Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Mon, 9 Dec 2024 14:18:20 +0100 Subject: [PATCH 19/23] Fix handling for tax-free orders ISSUE: CS-6233 --- src/Service/CaptureService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/CaptureService.php b/src/Service/CaptureService.php index 1b704d5df..7ce4262cf 100644 --- a/src/Service/CaptureService.php +++ b/src/Service/CaptureService.php @@ -341,7 +341,7 @@ private function getLineItemsObjectArray( 'amountIncludingTax' => ceil($lineItem->getPrice()->getTotalPrice() * 100), 'description' => $lineItem->getLabel(), 'taxAmount' => intval($lineItem->getPrice()->getCalculatedTaxes()->getAmount() * 100), - 'taxPercentage' => $lineItem->getPrice()->getTaxRules()->highestRate()->getPercentage() * 10, + 'taxPercentage' => ($lineItem->getPrice()->getTaxRules()->highestRate()?->getPercentage() ?? 0) * 10, 'quantity' => $lineItem->getQuantity(), 'id' => $lineItem->getId() ]; From 07d92afc6d93268d3c741f8015623459bc0824a1 Mon Sep 17 00:00:00 2001 From: Marija Date: Wed, 11 Dec 2024 10:13:59 +0100 Subject: [PATCH 20/23] Fix issue when aborting paypal transaction CS-6300 --- .../adyen-payment-shopware6.js | 2 +- .../src/checkout/confirm-order.plugin.js | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js index 0a3363530..4b4596b01 100644 --- a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js +++ b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js @@ -1 +1 @@ -(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){let t=r.querySelector(document,"#adyen-company-name"),n=r.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",i=n?n.value.trim():"",o=r.querySelector(document,"#adyen-company-name-error"),s=r.querySelector(document,"#adyen-registration-number-error");o.style.display="none",s.style.display="none";let d=!1;if(a||(o.style.display="block",d=!0),i||(s.style.display="block",d=!0),d){e.preventDefault();return}}e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#adyen-company-name"),n=e?e.value:"",a=r.querySelector(document,"#adyen-registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId})),y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file +(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){let t=r.querySelector(document,"#adyen-company-name"),n=r.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",i=n?n.value.trim():"",o=r.querySelector(document,"#adyen-company-name-error"),s=r.querySelector(document,"#adyen-registration-number-error");o.style.display="none",s.style.display="none";let d=!1;if(a||(o.style.display="block",d=!0),i||(s.style.display="block",d=!0),d){e.preventDefault();return}}e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#adyen-company-name"),n=e?e.value:"",a=r.querySelector(document,"#adyen-registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{if("PayPal"===n.props.name){this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId}),()=>{y.remove(document.body),e.onError(t,n,this)});return}y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file diff --git a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js index bb5937605..d6598763d 100644 --- a/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js +++ b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js @@ -459,11 +459,17 @@ export default class ConfirmOrderPlugin extends Plugin { componentConfig.onCancel(data, component, this); }, onError: (error, component) => { - if (component.props.name === 'PayPal' && error.name === 'CANCEL') { + if (component.props.name === 'PayPal') { this._client.post( `${adyenCheckoutOptions.cancelOrderTransactionUrl}`, - JSON.stringify({orderId: this.orderId}) + JSON.stringify({orderId: this.orderId}), + () => { + ElementLoadingIndicatorUtil.remove(document.body); + componentConfig.onError(error, component, this); + } ); + + return; } ElementLoadingIndicatorUtil.remove(document.body); @@ -547,8 +553,8 @@ export default class ConfirmOrderPlugin extends Plugin { getSelectedPaymentMethodKey() { return Object.keys( adyenConfiguration.paymentMethodTypeHandlers).find( - key => adyenConfiguration.paymentMethodTypeHandlers[key] === - adyenCheckoutOptions.selectedPaymentMethodHandler); + key => adyenConfiguration.paymentMethodTypeHandlers[key] === + adyenCheckoutOptions.selectedPaymentMethodHandler); } mountCustomPayButton(paymentMethodInstance) { @@ -625,16 +631,16 @@ export default class ConfirmOrderPlugin extends Plugin { let shoppingCartSummaryDetails = '
' + - adyenCheckoutOptions.translationAdyenGiftcardDiscount + + adyenCheckoutOptions.translationAdyenGiftcardDiscount + '
' + '
' + - adyenCheckoutOptions.currencySymbol + giftcardDiscount + + adyenCheckoutOptions.currencySymbol + giftcardDiscount + '
' + '
' + - adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount + + adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount + '
' + '
' + - adyenCheckoutOptions.currencySymbol + remainingAmount + + adyenCheckoutOptions.currencySymbol + remainingAmount + '
'; this.shoppingCartSummaryBlock[0].innerHTML += shoppingCartSummaryDetails; From 1ddde3544aaf1091db4238acce6fa60c2cf5d815 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Tue, 17 Dec 2024 15:31:12 +0100 Subject: [PATCH 21/23] Fix bind error for donations ISSUE: CS-6219 --- src/Resources/app/storefront/src/finish/adyen-giving.plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Resources/app/storefront/src/finish/adyen-giving.plugin.js b/src/Resources/app/storefront/src/finish/adyen-giving.plugin.js index 2dbad7d5d..c4876201c 100644 --- a/src/Resources/app/storefront/src/finish/adyen-giving.plugin.js +++ b/src/Resources/app/storefront/src/finish/adyen-giving.plugin.js @@ -29,7 +29,8 @@ export default class AdyenGivingPlugin extends Plugin { init() { this._client = new HttpClient(); this.adyenCheckout = Promise; - this.initializeCheckoutComponent().bind(this); + let boundInitializeCheckout = this.initializeCheckoutComponent.bind(this); + boundInitializeCheckout(); } async initializeCheckoutComponent () { From 772fcd758c7fbe7620c2000b174f1394b238dcb3 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 18 Dec 2024 15:56:41 +0100 Subject: [PATCH 22/23] Version bump 4.2.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e2381602c..5cec821f4 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ } ], "description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen", - "version": "4.2.1", + "version": "4.2.2", "type": "shopware-platform-plugin", "license": "MIT", "require": { From b37331d64b680ab1eb8577a80deb85afebea9d3e Mon Sep 17 00:00:00 2001 From: Marija Date: Thu, 19 Dec 2024 13:44:06 +0100 Subject: [PATCH 23/23] Update storefront js CS-6233 --- .../js/adyen-payment-shopware6/adyen-payment-shopware6.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js index 4b4596b01..aacae9d99 100644 --- a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js +++ b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6/adyen-payment-shopware6.js @@ -1 +1 @@ -(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(0===Object.keys(n).length)return{};let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){let t=r.querySelector(document,"#adyen-company-name"),n=r.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",i=n?n.value.trim():"",o=r.querySelector(document,"#adyen-company-name-error"),s=r.querySelector(document,"#adyen-registration-number-error");o.style.display="none",s.style.display="none";let d=!1;if(a||(o.style.display="block",d=!0),i||(s.style.display="block",d=!0),d){e.preventDefault();return}}e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#adyen-company-name"),n=e?e.value:"",a=r.querySelector(document,"#adyen-registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{if("PayPal"===n.props.name){this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId}),()=>{y.remove(document.body),e.onError(t,n,this)});return}y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file +(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==n},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function r(e,t,n){return e.concat(t).map(function(e){return a(e,n)})}function i(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function s(e,n,d){(d=d||{}).arrayMerge=d.arrayMerge||r,d.isMergeableObject=d.isMergeableObject||t,d.cloneUnlessOtherwiseSpecified=a;var c,l,h=Array.isArray(n);return h!==Array.isArray(e)?a(n,d):h?d.arrayMerge(e,n,d):(l={},(c=d).isMergeableObject(e)&&i(e).forEach(function(t){l[t]=a(e[t],c)}),i(n).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(n[t])?l[t]=(function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s})(t,c)(e[t],n[t],c):l[t]=a(n[t],c))}),l)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},e.exports=s}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t}})(),(()=>{n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=n(857),t=n.n(e);class a{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let n=a.toUpperCamelCase(e,t);return a.lcFirst(n)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>a.ucFirst(e.toLowerCase())).join(""):a.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!1===r.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(n)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=t.replace(/^data(|-)/,""),o=a.toLowerCamelCase(i,"-");if(!r.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[o];if(void 0===s){if(n)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return a.parsePrimitive(s)}static querySelector(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelector(t)||!1;if(n&&!1===a)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return a}static querySelectorAll(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(n&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let a=e.querySelectorAll(t);if(0===a.length&&(a=!1),n&&!1===a)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return a}}class i{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=new CustomEvent(e,{detail:t,cancelable:n});return this.el.dispatchEvent(a),a}subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=this,r=e.split("."),i=n.scope?t.bind(n.scope):t;if(n.once&&!0===n.once){let t=i;i=function(n){a.unsubscribe(e),t(n)}}return this.el.addEventListener(r[0],i),this.listeners.push({splitEventName:r,opts:n,cb:i}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,n)=>([...n.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(n.splitEventName[0],n.cb):e.push(n),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let n=a.toDashCase(this._pluginName),i=r.getDataAttribute(this.el,"data-".concat(n,"-config"),!1),o=r.getAttribute(this.el,"data-".concat(n,"-options"),!1),s=[this.constructor.options,this.options,e];i&&s.push(window.PluginConfigManager.get(this._pluginName,i));try{o&&s.push(JSON.parse(o))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(n,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},n=!1){if(!r.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new i(this.el),this._pluginName=this._getPluginName(n),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",a=this._createPreparedRequest("GET",e,n);return this._sendRequest(a,null,t)}post(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("POST",e,a);return this._sendRequest(r,t,n)}delete(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("DELETE",e,a);return this._sendRequest(r,t,n)}patch(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";a=this._getContentType(t,a);let r=this._createPreparedRequest("PATCH",e,a);return this._sendRequest(r,t,n)}abort(){if(this._request)return this._request.abort()}_registerOnLoaded(e,t){t&&e.addEventListener("loadend",()=>{t(e.responseText,e)})}_sendRequest(e,t,n){return this._registerOnLoaded(e,n),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,n){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),n&&this._request.setRequestHeader("Content-type",n),this._request}constructor(){this._request=null}}class d{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var n of e.entries())t(n[1],n[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(n=>{t(e[n],n)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}let c="loader",l={BEFORE:"before",INNER:"inner"};class h{create(){if(!this.exists()){if(this.position===l.INNER){this.parent.innerHTML=h.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),h.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(c));d.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(c)).length>0}_getPosition(){return this.position===l.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'
\n Loading...\n
')}static SELECTOR_CLASS(){return c}constructor(e,t=l.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}let u="element-loader-backdrop";class y extends h{static create(e){e.classList.add("has-element-loader"),y.exists(e)||(y.appendLoader(e),setTimeout(()=>{let t=e.querySelector(".".concat(u));t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(".".concat(u));t&&t.remove()}static exists(e){return e.querySelectorAll(".".concat(u)).length>0}static getTemplate(){return'\n
\n
\n Loading...\n
\n
\n ')}static appendLoader(e){e.insertAdjacentHTML("beforeend",y.getTemplate())}}class m{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=m.serialize(e,t);if(n==={})return n;let a={};return d.iterate(n,(e,t)=>a[t]=e),a}}let p={updatablePaymentMethods:["scheme","ideal","sepadirectdebit","oneclick","bcmc","bcmc_mobile","blik","klarna_b2b","eps","facilypay_3x","facilypay_4x","facilypay_6x","facilypay_10x","facilypay_12x","afterpay_default","ratepay","ratepay_directdebit","giftcard","paybright","affirm","multibanco","mbway","vipps","mobilepay","wechatpayQR","wechatpayWeb","paybybank"],componentsWithPayButton:{applepay:{extra:{},onClick:(e,t,n)=>n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},googlepay:{extra:{buttonSizeMode:"fill"},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:function(e,t,n){"CANCELED"!==e.statusCode&&("statusMessage"in e?console.log(e.statusMessage):console.log(e.statusCode))}},paypal:{extra:{},onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()},onError:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},onCancel:function(e,t,n){t.setStatus("ready"),window.location.href=n.errorUrl.toString()},responseHandler:function(e,t){try{(t=JSON.parse(t)).isFinal&&(location.href=e.returnUrl),this.handleAction(t.action)}catch(e){console.error(e)}}},amazonpay:{extra:{productType:"PayAndShip",checkoutMode:"ProcessOrder",returnUrl:location.href},prePayRedirect:!0,sessionKey:"amazonCheckoutSessionId",onClick:function(e,t,n){return n.confirmOrderForm.checkValidity()?(e(),!0):(t(),!1)},onError:(e,t)=>{console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaymentmethodhandler",klarna_account:"handler_adyen_klarnaaccountpaymentmethodhandler",klarna_paynow:"handler_adyen_klarnapaynowpaymentmethodhandler",ratepay:"handler_adyen_ratepaypaymentmethodhandler",ratepay_directdebit:"handler_adyen_ratepaydirectdebitpaymentmethodhandler",sepadirectdebit:"handler_adyen_sepapaymentmethodhandler",directEbanking:"handler_adyen_klarnadebitriskpaymentmethodhandler",paypal:"handler_adyen_paypalpaymentmethodhandler",oneclick:"handler_adyen_oneclickpaymentmethodhandler",giropay:"handler_adyen_giropaypaymentmethodhandler",applepay:"handler_adyen_applepaypaymentmethodhandler",googlepay:"handler_adyen_googlepaypaymentmethodhandler",bcmc:"handler_adyen_bancontactcardpaymentmethodhandler",bcmc_mobile:"handler_adyen_bancontactmobilepaymentmethodhandler",amazonpay:"handler_adyen_amazonpaypaymentmethodhandler",twint:"handler_adyen_twintpaymentmethodhandler",eps:"handler_adyen_epspaymentmethodhandler",swish:"handler_adyen_swishpaymentmethodhandler",alipay:"handler_adyen_alipaypaymentmethodhandler",alipay_hk:"handler_adyen_alipayhkpaymentmethodhandler",blik:"handler_adyen_blikpaymentmethodhandler",clearpay:"handler_adyen_clearpaypaymentmethodhandler",facilypay_3x:"handler_adyen_facilypay3xpaymentmethodhandler",facilypay_4x:"handler_adyen_facilypay4xpaymentmethodhandler",facilypay_6x:"handler_adyen_facilypay6xpaymentmethodhandler",facilypay_10x:"handler_adyen_facilypay10xpaymentmethodhandler",facilypay_12x:"handler_adyen_facilypay12xpaymentmethodhandler",afterpay_default:"handler_adyen_afterpaydefaultpaymentmethodhandler",trustly:"handler_adyen_trustlypaymentmethodhandler",paysafecard:"handler_adyen_paysafecardpaymentmethodhandler",giftcard:"handler_adyen_giftcardpaymentmethodhandler",mbway:"handler_adyen_mbwaypaymentmethodhandler",multibanco:"handler_adyen_multibancopaymentmethodhandler",wechatpayQR:"handler_adyen_wechatpayqrpaymentmethodhandler",wechatpayWeb:"handler_adyen_wechatpaywebpaymentmethodhandler",mobilepay:"handler_adyen_mobilepaypaymentmethodhandler",vipps:"handler_adyen_vippspaymentmethodhandler",affirm:"handler_adyen_affirmpaymentmethodhandler",paybright:"handler_adyen_paybrightpaymentmethodhandler",paybybank:"handler_adyen_openbankingpaymentmethodhandler",klarna_b2b:"handler_adyen_billiepaymentmethodhandler",ebanking_FI:"handler_adyen_onlinebankingfinlandpaymentmethodhandler",onlineBanking_PL:"handler_adyen_onlinebankingpolandpaymentmethodhandler"}},f=window.PluginManager;f.register("CartPlugin",class extends o{init(){let e=this;this._client=new s,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then((function(){this.observeGiftcardSelection()}).bind(this)),this.adyenGiftcardDropDown=r.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=r.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=r.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=r.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=r.querySelector(document,".adyen-close-giftcard-component"),this.minorUnitsQuotient=adyenGiftcardsConfiguration.totalInMinorUnits/adyenGiftcardsConfiguration.totalPrice,this.giftcardDiscount=adyenGiftcardsConfiguration.giftcardDiscount,this.remainingAmount=(adyenGiftcardsConfiguration.totalPrice-this.giftcardDiscount).toFixed(2),this.remainingGiftcardBalance=(adyenGiftcardsConfiguration.giftcardBalance/this.minorUnitsQuotient).toFixed(2),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.offCanvasSummaryDetails=null,this.shoppingCartSummaryDetails=null,this.giftcardComponentClose.onclick=function(t){t.currentTarget.style.display="none",e.selectedGiftcard=null,e.giftcardItem.innerHTML="",e.giftcardHeader.innerHTML=" ",e.paymentMethodInstance&&e.paymentMethodInstance.unmount()},document.getElementById("showGiftcardButton").addEventListener("click",function(){this.style.display="none",document.getElementById("giftcardDropdown").style.display="block"}),"interactive"==document.readyState?(this.fetchGiftcardsOnPageLoad(),this.setGiftcardsRemovalEvent()):(window.addEventListener("DOMContentLoaded",this.fetchGiftcardsOnPageLoad()),window.addEventListener("DOMContentLoaded",this.setGiftcardsRemovalEvent()))}fetchGiftcardsOnPageLoad(){parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}setGiftcardsRemovalEvent(){document.getElementById("giftcardsContainer").addEventListener("click",e=>{if(e.target.classList.contains("adyen-remove-giftcard")){let t=e.target.getAttribute("dataid");this.removeGiftcard(t)}})}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,a={locale:e,clientKey:t,environment:n,amount:{currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}};this.adyenCheckout=await AdyenCheckout(a)}observeGiftcardSelection(){let e=this,t=document.getElementById("giftcardDropdown"),n=document.querySelector(".btn-outline-info");t.addEventListener("change",function(){t.value&&(e.selectedGiftcard=JSON.parse(event.currentTarget.options[event.currentTarget.selectedIndex].dataset.giftcard),e.mountGiftcardComponent(e.selectedGiftcard),t.value="",n.style.display="none")})}mountGiftcardComponent(e){this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardItem.innerHTML="",y.create(r.querySelector(document,"#adyen-giftcard-component"));var t=document.createElement("img");t.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",t.classList.add("adyen-giftcard-logo"),this.giftcardItem.insertBefore(t,this.giftcardItem.firstChild),this.giftcardHeader.innerHTML=e.name,this.giftcardComponentClose.style.display="block";let n=Object.assign({},e,{showPayButton:!0,onBalanceCheck:this.handleBalanceCheck.bind(this,e)});try{this.paymentMethodInstance=this.adyenCheckout.create("giftcard",n),this.paymentMethodInstance.mount("#adyen-giftcard-component")}catch(e){console.log("giftcard not available")}y.remove(r.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let r={};r.paymentMethod=JSON.stringify(a.paymentMethod),r.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post("".concat(adyenGiftcardsConfiguration.checkBalanceUrl),JSON.stringify(r),(function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){let n=t.transactionLimit?parseFloat(t.transactionLimit.value):parseFloat(t.balance.value);a.giftcard={currency:adyenGiftcardsConfiguration.currency,value:(n/this.minorUnitsQuotient).toFixed(2),title:e.name},this.saveGiftcardStateData(a)}else n(t.resultCode)}).bind(this))}fetchRedeemedGiftcards(){this._client.get(adyenGiftcardsConfiguration.fetchRedeemedGiftcardsUrl,(function(e){e=JSON.parse(e);let t=document.getElementById("giftcardsContainer"),n=document.querySelector(".btn-outline-info");t.innerHTML="",e.redeemedGiftcards.giftcards.forEach(function(e){let n=parseFloat(e.deductedAmount);n=n.toFixed(2);let a=adyenGiftcardsConfiguration.translationAdyenGiftcardDeductedBalance+": "+adyenGiftcardsConfiguration.currencySymbol+n,r=document.createElement("div");var i=document.createElement("img");i.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",i.classList.add("adyen-giftcard-logo");let o=document.createElement("a");o.href="#",o.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,o.setAttribute("dataid",e.stateDataId),o.classList.add("adyen-remove-giftcard"),o.style.display="block",r.appendChild(i),r.innerHTML+="".concat(e.title,""),r.appendChild(o),r.innerHTML+='

'.concat(a,"


"),t.appendChild(r)}),this.remainingAmount=e.redeemedGiftcards.remainingAmount,this.giftcardDiscount=e.redeemedGiftcards.totalDiscount,this.paymentMethodInstance&&this.paymentMethodInstance.unmount(),this.giftcardComponentClose.style.display="none",this.giftcardItem.innerHTML="",this.giftcardHeader.innerHTML=" ",this.appendGiftcardSummary(),this.remainingAmount>0?n.style.display="block":(this.adyenGiftcardDropDown.length>0&&(this.adyenGiftcardDropDown[0].style.display="none"),n.style.display="none"),document.getElementById("giftcardsContainer")}).bind(this))}saveGiftcardStateData(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),(function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))}).bind(this))}removeGiftcard(e){y.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),y.remove(document.body))})}appendGiftcardSummary(){if(this.shoppingCartSummaryBlock.length){let e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary");for(let t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+e+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}},"#adyen-giftcards-container"),f.register("ConfirmOrderPlugin",class extends o{init(){this._client=new s,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=r.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=r.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=r.querySelectorAll(document,".checkout-aside-summary-list"),this.minorUnitsQuotient=adyenCheckoutOptions.amount/adyenCheckoutOptions.totalPrice,this.giftcardDiscount=adyenCheckoutOptions.giftcardDiscount,this.remainingAmount=adyenCheckoutOptions.totalPrice-this.giftcardDiscount,this.responseHandler=this.handlePaymentAction,this.adyenCheckout=Promise,this.initializeCheckoutComponent().then((function(){if(adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId){if(!adyenCheckoutOptions||!adyenCheckoutOptions.paymentStatusUrl||!adyenCheckoutOptions.checkoutOrderUrl||!adyenCheckoutOptions.paymentHandleUrl){console.error("Adyen payment configuration missing.");return}if(this.selectedAdyenPaymentMethod in p.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"===this.selectedAdyenPaymentMethod){this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this));return}p.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))}}).bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,r=adyenCheckoutOptions.paymentMethodsResponse,i={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in p.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(r),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(i)}handleOnAdditionalDetails(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),(function(e){if(200!==this._client._request.status){location.href=this.errorUrl.toString();return}this.responseHandler(e)}).bind(this))}onConfirmOrderSubmit(e){let t=r.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){let t=r.querySelector(document,"#adyen-company-name"),n=r.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",i=n?n.value.trim():"",o=r.querySelector(document,"#adyen-company-name-error"),s=r.querySelector(document,"#adyen-registration-number-error");o.style.display="none",s.style.display="none";let d=!1;if(a||(o.style.display="block",d=!0),i||(s.style.display="block",d=!0),d){e.preventDefault();return}}e.preventDefault(),y.create(document.body);let n=m.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e){this.renderStoredPaymentMethodComponents();return}if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(function(t){return t.type===e});if(0===t.length){"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e);return}let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach(e=>{let t='[data-adyen-stored-payment-method-id="'.concat(e.id,'"]');this.mountPaymentComponent(e,!0,t)}),this.hideStorePaymentMethodComponents();let e=null;r.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach(t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))}),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;let n='[data-adyen-stored-payment-method-id="'.concat(t,'"]');r.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){r.querySelectorAll(document,".stored-payment-component").forEach(e=>{e.style.display="none"})}confirmOrder(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=adyenCheckoutOptions.orderId;e.set("affiliateCode",adyenCheckoutOptions.affiliateCode),e.set("campaignCode",adyenCheckoutOptions.campaignCode),n?this.updatePayment(e,n,t):this.createOrder(e,t)}updatePayment(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}createOrder(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}afterCreateOrder(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;try{e=JSON.parse(n)}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",n);return}if(e.url){location.href=e.url;return}if(this.orderId=e.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",e.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",e.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){let e=r.querySelector(document,"#adyen-company-name"),n=e?e.value:"",a=r.querySelector(document,"#adyen-registration-number"),i=a?a.value:"";t.companyName=n,t.registrationNumber=i}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(let e in t)a[e]=t[e];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){y.remove(document.body),console.log("Error: invalid response from Shopware API",t);return}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post("".concat(adyenCheckoutOptions.paymentStatusUrl),JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{let t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){let e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(t.action.type)&&(window.jQuery?$("[data-adyen-payment-action-modal]").modal({show:!0}):new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show())}}catch(e){console.log(e)}}initializeCustomPayButton(){let e=p.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,e);let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>e.type===this.selectedAdyenPaymentMethod);if(t.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter(e=>"paywithgoogle"===e.type)),t.length<1)return;let n=t[0];if(!adyenCheckoutOptions.amount){console.error("Failed to fetch Cart/Order total amount.");return}if(e.prePayRedirect){this.renderPrePaymentButton(e,n);return}let a=Object.assign(e.extra,n,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onSubmit:(function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},r=m.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(r,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}).bind(this),onCancel:(t,n)=>{y.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{if("PayPal"===n.props.name){this._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:this.orderId}),()=>{y.remove(document.body),e.onError(t,n,this)});return}y.remove(document.body),e.onError(t,n,this),console.log(t)}}),r=this.adyenCheckout.create(n.type,a);try{"isAvailable"in r?r.isAvailable().then((function(){this.mountCustomPayButton(r)}).bind(this)).catch(e=>{console.log(n.type+" is not available",e)}):this.mountCustomPayButton(r)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));let n=Object.assign(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:(t,n)=>{if(!e.onClick(t,n,this))return!1;y.create(document.body)},onError:(t,n)=>{y.remove(document.body),e.onError(t,n,this),console.log(t)}}),a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){let n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){y.create(document.body);let a=this.adyenCheckout.create(e,{[t.sessionKey]:n.searchParams.get(t.sessionKey),showOrderButton:!1,onSubmit:(function(e,t){if(e.isValid){let t={stateData:JSON.stringify(e.data)},n=m.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}).bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(p.paymentMethodTypeHandlers).find(e=>p.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler)}mountCustomPayButton(e){let t=document.querySelector("#confirmOrderForm");if(t){let n=t.querySelector("button[type=submit]");if(n&&!n.disabled){let a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}mountPaymentComponent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:(function(n,a){if(n.isValid){if(t){var r;n.data.paymentMethod.holderName=(r=e.holderName)!==null&&void 0!==r?r:""}let a={stateData:JSON.stringify(n.data)},i=m.serialize(this.confirmOrderForm);y.create(document.body),this.confirmOrder(i,a)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}).bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);let i=t?n:"#"+this.el.id;try{let t=this.adyenCheckout.create(e.type,a);t.mount(i),this.confirmFormSubmit.addEventListener("click",(function(e){r.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),t.submit())}).bind(this))}catch(t){return console.error(e.type,t),!1}}appendGiftcardSummary(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){let e=parseFloat(this.giftcardDiscount).toFixed(2),t=parseFloat(this.remainingAmount).toFixed(2),n='
'+adyenCheckoutOptions.translationAdyenGiftcardDiscount+'
'+adyenCheckoutOptions.currencySymbol+e+'
'+adyenCheckoutOptions.translationAdyenGiftcardRemainingAmount+'
'+adyenCheckoutOptions.currencySymbol+t+"
";this.shoppingCartSummaryBlock[0].innerHTML+=n}}setAddressDetails(e){return""!==activeShippingAddress.phoneNumber?e.addressDetails={name:shopperDetails.firstName+" "+shopperDetails.lastName,addressLine1:activeShippingAddress.street,city:activeShippingAddress.city,postalCode:activeShippingAddress.postalCode,countryCode:activeShippingAddress.country,phoneNumber:activeShippingAddress.phoneNumber}:e.productType="PayOnly",e}},"#adyen-payment-checkout-mask"),f.register("AdyenGivingPlugin",class extends o{init(){this._client=new s,this.adyenCheckout=Promise,this.initializeCheckoutComponent.bind(this)()}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:r,backgroundUrl:i,logoUrl:o,name:s,description:d,url:c}=adyenGivingConfiguration,l={amounts:{currency:a,values:r.split(",").map(e=>Number(e))},backgroundUrl:i,logoUrl:o,description:d,name:s,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.create("donation",l).mount("#donation-container")}handleOnDonate(e,t){let n=adyenGivingConfiguration.orderId,a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post("".concat(adyenGivingConfiguration.donationEndpointUrl),JSON.stringify({...a}),(function(e){200!==this._client._request.status?t.setStatus("error"):t.setStatus("success")}).bind(this))}handleOnCancel(){let e=adyenGivingConfiguration.continueActionUrl;window.location=e}},"#adyen-giving-container"),f.register("AdyenSuccessAction",class extends o{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){let{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration;this.adyenCheckout=await AdyenCheckout({locale:e,clientKey:t,environment:n}),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}},"#adyen-success-action-container")})()})(); \ No newline at end of file