From d0b4c274f9b4690174e093294546e44315aee6f7 Mon Sep 17 00:00:00 2001 From: Marija Date: Fri, 29 Nov 2024 13:51:09 +0100 Subject: [PATCH 01/23] Update supported version --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5eb28cef..e77a82b8 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ "type": "shopware-platform-plugin", "license": "MIT", "require": { - "shopware/core": "~6.4.0 || ~6.5.0", - "shopware/storefront": "~6.4.0 || ~6.5.0", + "shopware/core": "~6.4.11 || ~6.5.0", + "shopware/storefront": "~6.4.11 || ~6.5.0", "adyen/php-api-library": "^17.5.0", "adyen/php-webhook-module": "0.8.0", "ext-json": "*" From e1beaefde5998171e942643ceeda4aeef21c1677 Mon Sep 17 00:00:00 2001 From: Tamara Date: Fri, 29 Nov 2024 18:32:42 +0100 Subject: [PATCH 02/23] Ratepay payment method resolving issue ADCRSET24I-6 --- src/Handlers/AbstractPaymentMethodHandler.php | 30 +- src/Models/PaymentRequest.php | 617 ++++++++++++++++++ src/Resources/config/config.xml | 10 + src/Resources/config/services.xml | 1 + .../config/services/checkout-api.xml | 4 + .../config/services/payment-handlers.xml | 1 + src/Resources/config/services/subscribers.xml | 1 + .../payment/payment-method.html.twig | 4 + .../payment/payment-ratepay.html.twig | 8 + src/Service/ConfigurationService.php | 12 + src/Service/PaymentMethodsFilterService.php | 14 + src/Subscriber/PaymentSubscriber.php | 35 +- ...RatePayDeviceFingerprintParamsProvider.php | 76 +++ 13 files changed, 807 insertions(+), 6 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 ec756283..5091e2ac 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -30,7 +30,7 @@ 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; @@ -46,6 +46,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; @@ -111,6 +112,11 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle */ protected $checkoutStateDataValidator; + /** + * @var RatePayDeviceFingerprintParamsProvider + */ + protected $ratePayFingerprintParamsProvider; + /** * @var PaymentStateDataService */ @@ -202,6 +208,7 @@ public function __construct( ClientService $clientService, Currency $currency, CheckoutStateDataValidator $checkoutStateDataValidator, + RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider, PaymentStateDataService $paymentStateDataService, SalesChannelRepository $salesChannelRepository, PaymentResponseHandler $paymentResponseHandler, @@ -219,6 +226,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; @@ -299,6 +307,13 @@ public function pay( if ($storedStateData) { $this->paymentStateDataService->deletePaymentStateDataFromId($storedStateData['id']); } + + if ( + $stateData['paymentMethod']['type'] === 'ratepay' || + $stateData['paymentMethod']['type'] === 'ratepay_directdebit' + ) { + $this->ratePayFingerprintParamsProvider->clear(); + } } $orderNumber = $transaction->getOrder()->getOrderNumber(); @@ -373,7 +388,7 @@ public function finalize( * @param array $request * @param int|null $partialAmount * @param array|null $adyenOrderData - * @return PaymentRequest + * @return IntegrationPaymentRequest */ protected function preparePaymentsRequest( SalesChannelContext $salesChannelContext, @@ -381,9 +396,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']; @@ -582,6 +597,11 @@ protected function preparePaymentsRequest( $paymentRequest->setMerchantAccount( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); + + if($paymentMethodType === 'ratepay' || $paymentMethodType === 'ratepay_direct') { + $paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken()); + } + $paymentRequest->setReturnUrl($transaction->getReturnUrl()); if (static::$isOpenInvoice) { @@ -723,7 +743,7 @@ private function getPaymentRequest( 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 00000000..348f7c2b --- /dev/null +++ b/src/Models/PaymentRequest.php @@ -0,0 +1,617 @@ + '\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', + '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, + '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, + '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', + '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', + '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', + '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 \Adyen\Model\Checkout\BankAccount|null + */ + public function getBankAccount() + { + return $this->container['bankAccount']; + } + + /** + * Sets bankAccount + * + * @param \Adyen\Model\Checkout\BankAccount|null $bankAccount bankAccount + * + * @return self + */ + public function setBankAccount($bankAccount) + { + if (is_null($bankAccount)) { + throw new \InvalidArgumentException('non-nullable bankAccount cannot be null'); + } + + $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/Resources/config/config.xml b/src/Resources/config/config.xml index 2cd978a6..72563759 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 6dd9ffac..691ef97c 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -82,6 +82,7 @@ + diff --git a/src/Resources/config/services/checkout-api.xml b/src/Resources/config/services/checkout-api.xml index 26107f5c..3ea888d2 100644 --- a/src/Resources/config/services/checkout-api.xml +++ b/src/Resources/config/services/checkout-api.xml @@ -13,6 +13,10 @@ + + + + diff --git a/src/Resources/config/services/payment-handlers.xml b/src/Resources/config/services/payment-handlers.xml index 7fa8ee33..28be56ab 100644 --- a/src/Resources/config/services/payment-handlers.xml +++ b/src/Resources/config/services/payment-handlers.xml @@ -10,6 +10,7 @@ + diff --git a/src/Resources/config/services/subscribers.xml b/src/Resources/config/services/subscribers.xml index 37a1c794..b54227b8 100644 --- a/src/Resources/config/services/subscribers.xml +++ b/src/Resources/config/services/subscribers.xml @@ -19,6 +19,7 @@ + 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 05325ded..ed8d42d2 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -18,4 +18,8 @@ and 'handler_adyen_' in payment.formattedHandlerIdentifier %} {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} {% endif %} + {% if payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaydirectdebitpaymentmethodhandler') + or payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaypaymentmethodhandler') %} + {% 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 00000000..d86e2be4 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/src/Service/ConfigurationService.php b/src/Service/ConfigurationService.php index eb04c8dd..ad028652 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 a47a0222..c31bb07a 100644 --- a/src/Service/PaymentMethodsFilterService.php +++ b/src/Service/PaymentMethodsFilterService.php @@ -42,6 +42,11 @@ class PaymentMethodsFilterService { + /** + * @var ConfigurationService + */ + private $configurationService; + /** * @var PaymentMethodsService */ @@ -56,15 +61,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 +114,12 @@ function (PaymentMethodEntity $item) use ($adyenPluginId) { $pmCode = $pmHandlerIdentifier::getPaymentMethodCode(); $isSafari = preg_match('/^((?!chrome|android).)*safari/', strtolower($_SERVER['HTTP_USER_AGENT'])); + if ( + ($pmCode === 'ratepay' || $pmCode === 'ratepay_directdebit') && + !$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 18f20339..4fc4e60e 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 $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, $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; } @@ -392,7 +402,8 @@ public function onCheckoutConfirmLoaded(PageLoadedEvent $event) ), 'affiliateCode' => $affiliateCode, 'campaignCode' => $campaignCode, - ] + ], + $this->getFingerprintParametersForRatepayMethod($salesChannelContext, $selectedPaymentMethod) ) ) ); @@ -426,4 +437,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 00000000..31430a16 --- /dev/null +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -0,0 +1,76 @@ +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 c84ff7aaac57032ae11f5f2a0df24ed473df9eab Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 2 Dec 2024 10:49:31 +0100 Subject: [PATCH 03/23] Ratepay payment method resolving issue ADCRSET24I-6 --- .../payment/payment-method.html.twig | 3 --- .../payment/payment-ratepay.html.twig | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) 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 ed8d42d2..54a23d70 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -17,9 +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' %} - {% endif %} - {% if payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaydirectdebitpaymentmethodhandler') - or payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaypaymentmethodhandler') %} {% 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 index d86e2be4..058c1931 100755 --- a/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -1,8 +1,11 @@ - - \ No newline at end of file +{% 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 From 16fecd4524f6eef06acb1c05f25d876c4a80ca06 Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 2 Dec 2024 11:57:18 +0100 Subject: [PATCH 04/23] Ratepay payment method resolving issue ADCRSET24I-6 --- src/Handlers/AbstractPaymentMethodHandler.php | 12 +++++++++--- .../RatepayDirectdebitPaymentMethod.php | 2 ++ src/PaymentMethods/RatepayPaymentMethod.php | 2 ++ src/Service/PaymentMethodsFilterService.php | 7 ++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 5091e2ac..faa773f0 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -37,6 +37,8 @@ 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; @@ -308,9 +310,10 @@ public function pay( $this->paymentStateDataService->deletePaymentStateDataFromId($storedStateData['id']); } + $paymentMethodType = $stateData['paymentMethod']['type']; if ( - $stateData['paymentMethod']['type'] === 'ratepay' || - $stateData['paymentMethod']['type'] === 'ratepay_directdebit' + $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE ) { $this->ratePayFingerprintParamsProvider->clear(); } @@ -598,7 +601,10 @@ protected function preparePaymentsRequest( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); - if($paymentMethodType === 'ratepay' || $paymentMethodType === 'ratepay_direct') { + if ( + $paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) { $paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken()); } diff --git a/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php b/src/PaymentMethods/RatepayDirectdebitPaymentMethod.php index d7b011bc..54c3fe87 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 c153b31a..b07ea372 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/Service/PaymentMethodsFilterService.php b/src/Service/PaymentMethodsFilterService.php index c31bb07a..926c21c4 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; @@ -115,7 +117,10 @@ function (PaymentMethodEntity $item) use ($adyenPluginId) { $isSafari = preg_match('/^((?!chrome|android).)*safari/', strtolower($_SERVER['HTTP_USER_AGENT'])); if ( - ($pmCode === 'ratepay' || $pmCode === 'ratepay_directdebit') && + ( + $pmCode === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $pmCode === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) && !$this->configurationService->getDeviceFingerprintSnippetId()) { $originalPaymentMethods->remove($paymentMethodEntity->getId()); } From 5ebe70bb5a8d05a174b70ef56d76f6f87ef44057 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Mon, 2 Dec 2024 13:55:23 +0100 Subject: [PATCH 05/23] Add form fields for Billie ISSUE: ADCRSET24I-5 --- .../payment/billie-payment-method.html.twig | 28 +++++++++++++++++++ .../payment/payment-method.html.twig | 6 +++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Resources/views/storefront/component/payment/billie-payment-method.html.twig 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 00000000..77d91ef4 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig @@ -0,0 +1,28 @@ +
+

+ All fields are required unless marked otherwise. +

+
+ + +
+
+ + +
+
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 05325ded..a3fc31a1 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -16,6 +16,10 @@ {{ parent() }} {% if payment.id is same as(selectedPaymentMethodId) and 'handler_adyen_' in payment.formattedHandlerIdentifier %} - {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} + {% if payment.formattedHandlerIdentifier == 'handler_adyen_billiepaymentmethodhandler' %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/billie-payment-method.html.twig' %} + {% else %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} + {% endif %} {% endif %} {% endblock %} From 5c0876f3dc19d549031022e48f8efaadc236ae4f Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Mon, 2 Dec 2024 14:13:31 +0100 Subject: [PATCH 06/23] Pass company name to frontend in subscriber method ISSUE: ADCRSET24I-5 --- src/Subscriber/PaymentSubscriber.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Subscriber/PaymentSubscriber.php b/src/Subscriber/PaymentSubscriber.php index 4c4549dd..d4474562 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(), ] ) ) From 78abbdb8f5bbc0f592c1211f18abc85aebd01af3 Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 2 Dec 2024 16:47:57 +0100 Subject: [PATCH 07/23] Ratepay payment method resolving issue ADCRSET24I-6 --- .../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 058c1931..53ff0c93 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,5 @@ l: '{{ adyenFrontendData.ratepay.location }}' }; - + {% endif %} \ No newline at end of file From 50ee327074b0ca20f1e1134e9a6b0792c0b802c6 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Tue, 3 Dec 2024 15:55:17 +0100 Subject: [PATCH 08/23] Implement Billie payment method ISSUE: ADCRSET24I-5 --- src/Handlers/AbstractPaymentMethodHandler.php | 29 +++++++++- .../src/checkout/confirm-order.plugin.js | 17 ++++++ .../payment/billie-payment-method.html.twig | 56 ++++++++++--------- .../payment/payment-method.html.twig | 5 +- src/Util/CheckoutStateDataValidator.php | 3 +- 5 files changed, 76 insertions(+), 34 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 806a2170..a6e3e40d 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); @@ -587,6 +597,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(), @@ -719,9 +742,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/src/checkout/confirm-order.plugin.js b/src/Resources/app/storefront/src/checkout/confirm-order.plugin.js index 5966ee94..1e0b35ef 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 index 77d91ef4..e9aa0515 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 @@ -1,28 +1,30 @@ -
-

- All fields are required unless marked otherwise. -

-
- - +{% 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 a3fc31a1..9d567e4e 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -16,10 +16,7 @@ {{ parent() }} {% if payment.id is same as(selectedPaymentMethodId) and 'handler_adyen_' in payment.formattedHandlerIdentifier %} - {% if payment.formattedHandlerIdentifier == 'handler_adyen_billiepaymentmethodhandler' %} - {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/billie-payment-method.html.twig' %} - {% else %} {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} - {% endif %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/billie-payment-method.html.twig' %} {% endif %} {% endblock %} diff --git a/src/Util/CheckoutStateDataValidator.php b/src/Util/CheckoutStateDataValidator.php index 7e6fdab6..bd577bcd 100644 --- a/src/Util/CheckoutStateDataValidator.php +++ b/src/Util/CheckoutStateDataValidator.php @@ -21,7 +21,8 @@ class CheckoutStateDataValidator 'conversionId', 'paymentData', 'details', - 'origin' + 'origin', + 'billieData' ); /** From b8e06c396fd5bdcccda130b72c692a1221bbe969 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 12:13:44 +0100 Subject: [PATCH 09/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 49efa04e..a7048cce 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->getSchemaManager(); + + // 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 = <<getSchemaManager(); + + // 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:38:41 +0100 Subject: [PATCH 10/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 696cc940..590a4bfa 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; @@ -318,7 +321,10 @@ private function removePluginData() $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 a7048cce..49efa04e 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->getSchemaManager(); - - // 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 = <<getSchemaManager(); - - // 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:44 +0100 Subject: [PATCH 11/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 a6e3e40d..237fa3af 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)); } @@ -625,7 +628,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 03b18a0f2b2a5a6348bd59f79505aee2b65e109e Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 15:47:53 +0100 Subject: [PATCH 12/23] Add required fields and messages ISSUE: ADCRSET24I-5 --- .../src/checkout/confirm-order.plugin.js | 34 +++++++++++++++++-- .../payment/billie-payment-method.html.twig | 10 +++--- 2 files changed, 38 insertions(+), 6 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 1e0b35ef..c3be6cab 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 e9aa0515..12ab1802 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 bd49d8e9d27a66dd179490179ddb87b7fb60a6e2 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 15:59:37 +0100 Subject: [PATCH 13/23] Fix label for fields ISSUE: ADCRSET24I-5 --- .../component/payment/billie-payment-method.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 12ab1802..0859b253 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 @@ -4,7 +4,7 @@ All fields are required unless marked otherwise.

- +
- + Date: Wed, 4 Dec 2024 16:04:08 +0100 Subject: [PATCH 14/23] Revert "Change redirect url for Billie payment method" This reverts commit 65c4d9c1370fa129d23ec84100858f974520c4f6. --- 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 237fa3af..a6e3e40d 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)); } @@ -628,7 +625,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 4ae5ed25dd7968110996ad90e89da91a173a3e96 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 4 Dec 2024 16:52:41 +0100 Subject: [PATCH 15/23] Fix Bancontact mobile behavior ADCRSET24I-7 --- src/Handlers/AbstractPaymentMethodHandler.php | 6 +- src/Handlers/ResultHandler.php | 14 ++-- src/Resources/config/services.xml | 1 + src/Resources/config/services/controllers.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 | 67 +++++++++---------- src/Subscriber/PaymentSubscriber.php | 13 ---- 10 files changed, 81 insertions(+), 83 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 806a2170..b14cb294 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 b36c2906..6b31be9f 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 5d981b6a..c6422563 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -95,6 +95,7 @@ + diff --git a/src/Resources/config/services/controllers.xml b/src/Resources/config/services/controllers.xml index 340e4f04..bf250130 100644 --- a/src/Resources/config/services/controllers.xml +++ b/src/Resources/config/services/controllers.xml @@ -55,6 +55,7 @@ + diff --git a/src/Resources/snippet/de_DE/messages.de-DE.json b/src/Resources/snippet/de_DE/messages.de-DE.json index b5253ad8..4b108601 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 da75f65f..ae41ceaa 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 b5e3bb83..59d8e085 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 019af8b0..54e85454 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 34124a2c..7adeee7e 100644 --- a/src/Storefront/Controller/FrontendProxyController.php +++ b/src/Storefront/Controller/FrontendProxyController.php @@ -30,11 +30,13 @@ use Adyen\Shopware\Controller\StoreApi\Payment\PaymentController; use Adyen\Shopware\Exception\ValidationException; 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; @@ -94,12 +96,16 @@ class FrontendProxyController extends StorefrontController * @var DonateController */ private DonateController $donateController; - /** * @var ShopwarePaymentTokenValidator */ private ShopwarePaymentTokenValidator $paymentTokenValidator; + /** + * @var AdyenPaymentService + */ + private AdyenPaymentService $adyenPaymentService; + /** * @param AbstractCartOrderRoute $cartOrderRoute * @param AbstractHandlePaymentMethodRoute $handlePaymentMethodRoute @@ -110,6 +116,7 @@ class FrontendProxyController extends StorefrontController * @param OrderApiController $orderApiController * @param DonateController $donateController * @param ShopwarePaymentTokenValidator $paymentTokenValidator + * @param AdyenPaymentService $adyenPaymentService */ public function __construct(//NOSONAR AbstractCartOrderRoute $cartOrderRoute,//NOSONAR @@ -120,7 +127,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; @@ -131,6 +139,7 @@ public function __construct(//NOSONAR $this->orderApiController = $orderApiController; $this->donateController = $donateController; $this->paymentTokenValidator = $paymentTokenValidator; + $this->adyenPaymentService = $adyenPaymentService; } /** @@ -206,46 +215,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 4c4549dd..18f20339 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 89b4bd4e0f11a783ccec1041294ecaf4cc1e9b19 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 11:29:10 +0100 Subject: [PATCH 16/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 | 7 ++----- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 890377c0..f151b9fa 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -322,8 +322,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(); @@ -647,8 +646,7 @@ protected function preparePaymentsRequest( $paymentRequest->setMerchantAccount( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); - 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 6b31be9f..37d479f5 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 348f7c2b..f1d4d865 100755 --- a/src/Models/PaymentRequest.php +++ b/src/Models/PaymentRequest.php @@ -560,8 +560,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 54e85454..b3e4f0e0 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 926c21c4..6d9a6f6d 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 e1e9cc20..777d2992 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 31430a16..a56625c1 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,6 +70,4 @@ public function clear(): void { $this->requestStack->getSession()->remove(self::TOKEN_SESSION_KEY); } - - -} \ No newline at end of file +} From 90b9ee91f4b88fffb214d07426fd887b3d25186f Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Thu, 5 Dec 2024 12:29:02 +0100 Subject: [PATCH 17/23] Build storefront js ISSUE: ADCRSET24I-5 --- .../storefront/dist/storefront/js/adyen-payment-shopware6.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js diff --git a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js old mode 100755 new mode 100644 index 49ebf9d6..feec2713 --- a/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js +++ b/src/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([["adyen-payment-shopware6"],{"4Gix":function(e,t,n){"use strict";t.a={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:function(e,t,n){return 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:function(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"}}},HbFT:function(e,t,n){"use strict";n.r(t);var a=n("FGIj"),o=n("gHbT"),r=n("k8s9"),i=n("u0Tz");function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t".concat(e.title,""),o.appendChild(i),o.innerHTML+='

'.concat(a,"


"),t.appendChild(o)})),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))}},{key:"saveGiftcardStateData",value:function(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),i.a.remove(document.body))}.bind(this))}},{key:"removeGiftcard",value:function(e){var t=this;i.a.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(function(e){"token"in(e=JSON.parse(e))&&(t.fetchRedeemedGiftcards(),i.a.remove(document.body))}))}},{key:"appendGiftcardSummary",value:function(){if(this.shoppingCartSummaryBlock.length)for(var e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary"),t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+n+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+a+"
";this.shoppingCartSummaryBlock[0].innerHTML+=o}}}])&&u(n.prototype,a),c&&u(n,c),t}(a.a),f=n("q5xn");function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t,n,a,o,r,i){try{var c=e[r](i),d=c.value}catch(e){return void n(e)}c.done?t(d):Promise.resolve(d).then(a,o)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var n=0;n0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}},{key:"initializeCheckoutComponent",value:(k=regeneratorRuntime.mark((function e(){var t,n,a,o,r,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=adyenCheckoutConfiguration,n=t.locale,a=t.clientKey,o=t.environment,r=t.merchantAccount,i=adyenCheckoutOptions.paymentMethodsResponse,c={locale:n,clientKey:a,environment:o,showPayButton:this.selectedAdyenPaymentMethod in s.a.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:r,shopperEmail:shopperDetails.shopperEmail}}}},e.next=5,AdyenCheckout(c);case 5:this.adyenCheckout=e.sent;case 6:case"end":return e.stop()}}),e,this)})),C=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=k.apply(e,t);function r(e){h(o,n,a,r,i,"next",e)}function i(e){h(o,n,a,r,i,"throw",e)}r(void 0)}))},function(){return C.apply(this,arguments)})},{key:"handleOnAdditionalDetails",value:function(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}},{key:"onConfirmOrderSubmit",value:function(e){var t=r.a.querySelector(document,"#confirmOrderForm");if(t.checkValidity()){e.preventDefault(),d.a.create(document.body);var n=c.a.serialize(t);this.confirmOrder(n)}}},{key:"renderPaymentComponent",value:function(e){if("oneclick"!==e){if("giftcard"!==e){var t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0!==t.length){var n=t[0];this.mountPaymentComponent(n,!1)}else"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e)}}else this.renderStoredPaymentMethodComponents()}},{key:"renderStoredPaymentMethodComponents",value:function(){var e=this;this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((function(t){var n='[data-adyen-stored-payment-method-id="'.concat(t.id,'"]');e.mountPaymentComponent(t,!0,n)})),this.hideStorePaymentMethodComponents();var t=null;r.a.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((function(n){t||(t=n.value),n.addEventListener("change",e.showSelectedStoredPaymentMethod.bind(e))})),this.showSelectedStoredPaymentMethod(null,t)}},{key:"showSelectedStoredPaymentMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;var n='[data-adyen-stored-payment-method-id="'.concat(t,'"]'),a=r.a.querySelector(document,n);a.style.display="block"}},{key:"hideStorePaymentMethodComponents",value:function(){r.a.querySelectorAll(document,".stored-payment-component").forEach((function(e){e.style.display="none"}))}},{key:"confirmOrder",value:function(e){var 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)}},{key:"updatePayment",value:function(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}},{key:"createOrder",value:function(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}},{key:"afterCreateOrder",value:function(){var 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){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",n)}if(e.url)location.href=e.url;else{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);var a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(var o in t)a[o]=t[o];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}}},{key:"afterSetPayment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var n=JSON.parse(t);n.success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}},{key:"afterPayOrder",value:function(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}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)}}},{key:"handlePaymentAction",value:function(t){try{var n=JSON.parse(t);if((n.isFinal||"voucher"===n.action.type)&&(location.href=this.returnUrl),n.action){var o={};"threeDS2"===n.action.type&&(o.challengeWindowSize="05"),this.adyenCheckout.createFromAction(n.action,o).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(n.action.type)&&(e?a("[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)}}},{key:"initializeCustomPayButton",value:function(){var e=this,t=s.a.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,t);var n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e.selectedAdyenPaymentMethod}));if(n.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(e){return"paywithgoogle"===e.type}))),!(n.length<1)){var a=n[0];if(adyenCheckoutOptions.amount)if(t.prePayRedirect)this.renderPrePaymentButton(t,a);else{var o=y(t.extra,a,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:function(n,a){if(!t.onClick(n,a,e))return!1;d.a.create(document.body)},onSubmit:function(e,n){if(e.isValid){var a={stateData:JSON.stringify(e.data)},o=c.a.serialize(this.confirmOrderForm);"responseHandler"in t&&(this.responseHandler=t.responseHandler.bind(n,this)),this.confirmOrder(o,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",e)}.bind(this),onCancel:function(n,a){d.a.remove(document.body),t.onCancel(n,a,e)},onError:function(n,a){"PayPal"===a.props.name&&"CANCEL"===n.name&&e._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:e.orderId})),d.a.remove(document.body),t.onError(n,a,e),console.log(n)}}),r=this.adyenCheckout.create(a.type,o);try{"isAvailable"in r?r.isAvailable().then(function(){this.mountCustomPayButton(r)}.bind(this)).catch((function(e){console.log(a.type+" is not available",e)})):this.mountCustomPayButton(r)}catch(e){console.log(e)}}else console.error("Failed to fetch Cart/Order total amount.")}}},{key:"renderPrePaymentButton",value:function(e,t){var n=this;"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));var a=y(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:function(t,a){if(!e.onClick(t,a,n))return!1;d.a.create(document.body)},onError:function(t,a){d.a.remove(document.body),e.onError(t,a,n),console.log(t)}}),o=this.adyenCheckout.create(t.type,a);this.mountCustomPayButton(o)}},{key:"completePendingPayment",value:function(e,t){var n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){var a;d.a.create(document.body);var o=this.adyenCheckout.create(e,(u(a={},t.sessionKey,n.searchParams.get(t.sessionKey)),u(a,"showOrderButton",!1),u(a,"onSubmit",function(e,t){if(e.isValid){var n={stateData:JSON.stringify(e.data)},a=c.a.serialize(this.confirmOrderForm);this.confirmOrder(a,n)}}.bind(this)),a));this.mountCustomPayButton(o),o.submit()}}},{key:"getSelectedPaymentMethodKey",value:function(){return Object.keys(s.a.paymentMethodTypeHandlers).find((function(e){return s.a.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler}))}},{key:"mountCustomPayButton",value:function(e){var t=document.querySelector("#confirmOrderForm");if(t){var n=t.querySelector("button[type=submit]");if(n&&!n.disabled){var a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}},{key:"mountPaymentComponent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=y({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);var o={stateData:JSON.stringify(n.data)},r=c.a.serialize(this.confirmOrderForm);d.a.create(document.body),this.confirmOrder(r,o)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);var o=t?n:"#"+this.el.id;try{var i=this.adyenCheckout.create(e.type,a);i.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){r.a.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),i.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}},{key:"appendGiftcardSummary",value:function(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){var 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}}},{key:"setAddressDetails",value:function(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}}])&&p(o.prototype,l),b&&p(o,b),n}(o.a)}).call(this,n("UoTJ"),n("UoTJ"))}},[["HbFT","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([["adyen-payment-shopware6"],{YcTq:function(e,t,n){"use strict";t.a={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:function(e,t,n){return 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:function(e,t){console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaaymentmethodhandler",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"}}},j5lx:function(e,t,n){"use strict";(function(e,a){n.d(t,"a",(function(){return b}));var o=n("FGIj"),r=n("gHbT"),i=n("k8s9"),c=n("2Y4b"),d=n("u0Tz"),s=n("YcTq");function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(){return(y=Object.assign||function(e){for(var t=1;t0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}},{key:"initializeCheckoutComponent",value:(k=regeneratorRuntime.mark((function e(){var t,n,a,o,r,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=adyenCheckoutConfiguration,n=t.locale,a=t.clientKey,o=t.environment,r=t.merchantAccount,i=adyenCheckoutOptions.paymentMethodsResponse,c={locale:n,clientKey:a,environment:o,showPayButton:this.selectedAdyenPaymentMethod in s.a.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:r,shopperEmail:shopperDetails.shopperEmail}}}},e.next=5,AdyenCheckout(c);case 5:this.adyenCheckout=e.sent;case 6:case"end":return e.stop()}}),e,this)})),C=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=k.apply(e,t);function r(e){h(o,n,a,r,i,"next",e)}function i(e){h(o,n,a,r,i,"throw",e)}r(void 0)}))},function(){return C.apply(this,arguments)})},{key:"handleOnAdditionalDetails",value:function(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}},{key:"onConfirmOrderSubmit",value:function(e){var t=r.a.querySelector(document,"#confirmOrderForm");if(t.checkValidity()){if("klarna_b2b"===this.selectedAdyenPaymentMethod){var n=r.a.querySelector(document,"#adyen-company-name"),a=r.a.querySelector(document,"#adyen-registration-number"),o=n?n.value.trim():"",i=a?a.value.trim():"",s=r.a.querySelector(document,"#adyen-company-name-error"),l=r.a.querySelector(document,"#adyen-registration-number-error");s.style.display="none",l.style.display="none";var u=!1;if(o||(s.style.display="block",u=!0),i||(l.style.display="block",u=!0),u)return void e.preventDefault()}e.preventDefault(),d.a.create(document.body);var y=c.a.serialize(t);this.confirmOrder(y)}}},{key:"renderPaymentComponent",value:function(e){if("oneclick"!==e){if("giftcard"!==e){var t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0!==t.length){var n=t[0];this.mountPaymentComponent(n,!1)}else"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e)}}else this.renderStoredPaymentMethodComponents()}},{key:"renderStoredPaymentMethodComponents",value:function(){var e=this;this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((function(t){var n='[data-adyen-stored-payment-method-id="'.concat(t.id,'"]');e.mountPaymentComponent(t,!0,n)})),this.hideStorePaymentMethodComponents();var t=null;r.a.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((function(n){t||(t=n.value),n.addEventListener("change",e.showSelectedStoredPaymentMethod.bind(e))})),this.showSelectedStoredPaymentMethod(null,t)}},{key:"showSelectedStoredPaymentMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;var n='[data-adyen-stored-payment-method-id="'.concat(t,'"]'),a=r.a.querySelector(document,n);a.style.display="block"}},{key:"hideStorePaymentMethodComponents",value:function(){r.a.querySelectorAll(document,".stored-payment-component").forEach((function(e){e.style.display="none"}))}},{key:"confirmOrder",value:function(e){var 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)}},{key:"updatePayment",value:function(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}},{key:"createOrder",value:function(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}},{key:"afterCreateOrder",value:function(){var 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){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",n)}if(e.url)location.href=e.url;else{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){var a=r.a.querySelector(document,"#adyen-company-name"),o=a?a.value:"",i=r.a.querySelector(document,"#adyen-registration-number"),c=i?i.value:"";t.companyName=o,t.registrationNumber=c}var s={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(var l in t)s[l]=t[l];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(s),this.afterPayOrder.bind(this,this.orderId))}}},{key:"afterSetPayment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var n=JSON.parse(t);n.success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}},{key:"afterPayOrder",value:function(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}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)}}},{key:"handlePaymentAction",value:function(t){try{var n=JSON.parse(t);if((n.isFinal||"voucher"===n.action.type)&&(location.href=this.returnUrl),n.action){var o={};"threeDS2"===n.action.type&&(o.challengeWindowSize="05"),this.adyenCheckout.createFromAction(n.action,o).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(n.action.type)&&(e?a("[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)}}},{key:"initializeCustomPayButton",value:function(){var e=this,t=s.a.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,t);var n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e.selectedAdyenPaymentMethod}));if(n.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(e){return"paywithgoogle"===e.type}))),!(n.length<1)){var a=n[0];if(adyenCheckoutOptions.amount)if(t.prePayRedirect)this.renderPrePaymentButton(t,a);else{var o=y(t.extra,a,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:function(n,a){if(!t.onClick(n,a,e))return!1;d.a.create(document.body)},onSubmit:function(e,n){if(e.isValid){var a={stateData:JSON.stringify(e.data)},o=c.a.serialize(this.confirmOrderForm);"responseHandler"in t&&(this.responseHandler=t.responseHandler.bind(n,this)),this.confirmOrder(o,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",e)}.bind(this),onCancel:function(n,a){d.a.remove(document.body),t.onCancel(n,a,e)},onError:function(n,a){"PayPal"===a.props.name&&"CANCEL"===n.name&&e._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:e.orderId})),d.a.remove(document.body),t.onError(n,a,e),console.log(n)}}),r=this.adyenCheckout.create(a.type,o);try{"isAvailable"in r?r.isAvailable().then(function(){this.mountCustomPayButton(r)}.bind(this)).catch((function(e){console.log(a.type+" is not available",e)})):this.mountCustomPayButton(r)}catch(e){console.log(e)}}else console.error("Failed to fetch Cart/Order total amount.")}}},{key:"renderPrePaymentButton",value:function(e,t){var n=this;"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));var a=y(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:function(t,a){if(!e.onClick(t,a,n))return!1;d.a.create(document.body)},onError:function(t,a){d.a.remove(document.body),e.onError(t,a,n),console.log(t)}}),o=this.adyenCheckout.create(t.type,a);this.mountCustomPayButton(o)}},{key:"completePendingPayment",value:function(e,t){var n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){var a;d.a.create(document.body);var o=this.adyenCheckout.create(e,(u(a={},t.sessionKey,n.searchParams.get(t.sessionKey)),u(a,"showOrderButton",!1),u(a,"onSubmit",function(e,t){if(e.isValid){var n={stateData:JSON.stringify(e.data)},a=c.a.serialize(this.confirmOrderForm);this.confirmOrder(a,n)}}.bind(this)),a));this.mountCustomPayButton(o),o.submit()}}},{key:"getSelectedPaymentMethodKey",value:function(){return Object.keys(s.a.paymentMethodTypeHandlers).find((function(e){return s.a.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler}))}},{key:"mountCustomPayButton",value:function(e){var t=document.querySelector("#confirmOrderForm");if(t){var n=t.querySelector("button[type=submit]");if(n&&!n.disabled){var a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}},{key:"mountPaymentComponent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=y({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);var o={stateData:JSON.stringify(n.data)},r=c.a.serialize(this.confirmOrderForm);d.a.create(document.body),this.confirmOrder(r,o)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);var o=t?n:"#"+this.el.id;try{var i=this.adyenCheckout.create(e.type,a);i.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){r.a.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),i.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}},{key:"appendGiftcardSummary",value:function(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){var 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}}},{key:"setAddressDetails",value:function(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}}])&&p(o.prototype,l),b&&p(o,b),n}(o.a)}).call(this,n("UoTJ"),n("UoTJ"))},jC4o:function(e,t,n){"use strict";n.r(t);var a=n("FGIj"),o=n("gHbT"),r=n("k8s9"),i=n("u0Tz");function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t".concat(e.title,""),o.appendChild(i),o.innerHTML+='

'.concat(a,"


"),t.appendChild(o)})),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))}},{key:"saveGiftcardStateData",value:function(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),i.a.remove(document.body))}.bind(this))}},{key:"removeGiftcard",value:function(e){var t=this;i.a.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(function(e){"token"in(e=JSON.parse(e))&&(t.fetchRedeemedGiftcards(),i.a.remove(document.body))}))}},{key:"appendGiftcardSummary",value:function(){if(this.shoppingCartSummaryBlock.length)for(var e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary"),t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+n+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+a+"
";this.shoppingCartSummaryBlock[0].innerHTML+=o}}}])&&u(n.prototype,a),c&&u(n,c),t}(a.a),f=n("j5lx");function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t,n,a,o,r,i){try{var c=e[r](i),d=c.value}catch(e){return void n(e)}c.done?t(d):Promise.resolve(d).then(a,o)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var n=0;n Date: Thu, 5 Dec 2024 13:45:01 +0100 Subject: [PATCH 18/23] Add support to Shopware 6.4.* versions --- src/Resources/config/services.xml | 1 - src/Service/AdyenPaymentService.php | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index bfde919e..c8d2117e 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -96,7 +96,6 @@ - diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index b3e4f0e0..4d70d548 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -29,9 +29,8 @@ 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\Checkout\Payment\Exception\InvalidTransactionException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -47,19 +46,12 @@ class AdyenPaymentService protected AdyenPaymentRepository $adyenPaymentRepository; protected EntityRepository $orderTransactionRepository; - /** - * @var AbstractPaymentTransactionStructFactory - */ - private AbstractPaymentTransactionStructFactory $paymentTransactionStructFactory; - public function __construct( AdyenPaymentRepository $adyenPaymentRepository, EntityRepository $orderTransactionRepository, - AbstractPaymentTransactionStructFactory $paymentTransactionStructFactory ) { $this->adyenPaymentRepository = $adyenPaymentRepository; $this->orderTransactionRepository = $orderTransactionRepository; - $this->paymentTransactionStructFactory = $paymentTransactionStructFactory; } public function insertAdyenPayment( @@ -193,9 +185,9 @@ public function getPaymentTransactionStruct( $orderTransaction = $this->orderTransactionRepository->search($criteria, $context->getContext())->first(); if ($orderTransaction === null || $orderTransaction->getOrder() === null) { - throw PaymentException::invalidTransaction($orderTransactionId); + throw new InvalidTransactionException($orderTransactionId); } - return $this->paymentTransactionStructFactory->async($orderTransaction, $orderTransaction->getOrder(), ''); + return new AsyncPaymentTransactionStruct($orderTransaction, $orderTransaction->getOrder(), ''); } } From fe671a71b1f953506cbbfb26d5d5b3162a2e7359 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 13:57:37 +0100 Subject: [PATCH 19/23] Version bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e77a82b8..55ee549b 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ } ], "description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen", - "version": "3.17.0", + "version": "3.17.1", "type": "shopware-platform-plugin", "license": "MIT", "require": { From b6e6581fefe719514adb7a3a9bd64db0f1d1f7dd Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 13:59:32 +0100 Subject: [PATCH 20/23] Add support to Shopware 6.4.* versions --- src/Service/AdyenPaymentService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index 4d70d548..d8059d1b 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -48,7 +48,7 @@ class AdyenPaymentService public function __construct( AdyenPaymentRepository $adyenPaymentRepository, - EntityRepository $orderTransactionRepository, + EntityRepository $orderTransactionRepository ) { $this->adyenPaymentRepository = $adyenPaymentRepository; $this->orderTransactionRepository = $orderTransactionRepository; From 203ed2458a2730cdb5d19f0b5da91801702842a7 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 5 Dec 2024 17:35:23 +0100 Subject: [PATCH 21/23] Fix the issue with no web components on the checkout ADCRSET24I-14 --- .../build/storefront/js/adyen-payment-shopware64.js.dist | 2 +- .../build/storefront/js/adyen-payment-shopware65.js.dist | 2 +- src/Service/AdyenPaymentService.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Resources/app/storefront/build/storefront/js/adyen-payment-shopware64.js.dist b/src/Resources/app/storefront/build/storefront/js/adyen-payment-shopware64.js.dist index f990e063..feec2713 100644 --- a/src/Resources/app/storefront/build/storefront/js/adyen-payment-shopware64.js.dist +++ b/src/Resources/app/storefront/build/storefront/js/adyen-payment-shopware64.js.dist @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([["adyen-payment-shopware6"],{HNRU:function(e,t,n){"use strict";t.a={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:function(e,t,n){return 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:function(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"}}},TVZM:function(e,t,n){"use strict";n.r(t);var a=n("FGIj"),o=n("gHbT"),r=n("k8s9"),i=n("u0Tz");function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t".concat(e.title,""),o.appendChild(i),o.innerHTML+='

'.concat(a,"


"),t.appendChild(o)})),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))}},{key:"saveGiftcardStateData",value:function(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),i.a.remove(document.body))}.bind(this))}},{key:"removeGiftcard",value:function(e){var t=this;i.a.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(function(e){"token"in(e=JSON.parse(e))&&(t.fetchRedeemedGiftcards(),i.a.remove(document.body))}))}},{key:"appendGiftcardSummary",value:function(){if(this.shoppingCartSummaryBlock.length)for(var e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary"),t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+n+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+a+"
";this.shoppingCartSummaryBlock[0].innerHTML+=o}}}])&&u(n.prototype,a),c&&u(n,c),t}(a.a),f=n("h8V8");function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t,n,a,o,r,i){try{var c=e[r](i),d=c.value}catch(e){return void n(e)}c.done?t(d):Promise.resolve(d).then(a,o)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var n=0;n0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}},{key:"initializeCheckoutComponent",value:(k=regeneratorRuntime.mark((function e(){var t,n,a,o,r,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=adyenCheckoutConfiguration,n=t.locale,a=t.clientKey,o=t.environment,r=t.merchantAccount,i=adyenCheckoutOptions.paymentMethodsResponse,c={locale:n,clientKey:a,environment:o,showPayButton:this.selectedAdyenPaymentMethod in s.a.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:r,shopperEmail:shopperDetails.shopperEmail}}}},e.next=5,AdyenCheckout(c);case 5:this.adyenCheckout=e.sent;case 6:case"end":return e.stop()}}),e,this)})),C=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=k.apply(e,t);function r(e){h(o,n,a,r,i,"next",e)}function i(e){h(o,n,a,r,i,"throw",e)}r(void 0)}))},function(){return C.apply(this,arguments)})},{key:"handleOnAdditionalDetails",value:function(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}},{key:"onConfirmOrderSubmit",value:function(e){var t=r.a.querySelector(document,"#confirmOrderForm");if(t.checkValidity()){e.preventDefault(),d.a.create(document.body);var n=c.a.serialize(t);this.confirmOrder(n)}}},{key:"renderPaymentComponent",value:function(e){if("oneclick"!==e){if("giftcard"!==e){var t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0!==t.length){var n=t[0];this.mountPaymentComponent(n,!1)}else"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e)}}else this.renderStoredPaymentMethodComponents()}},{key:"renderStoredPaymentMethodComponents",value:function(){var e=this;this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((function(t){var n='[data-adyen-stored-payment-method-id="'.concat(t.id,'"]');e.mountPaymentComponent(t,!0,n)})),this.hideStorePaymentMethodComponents();var t=null;r.a.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((function(n){t||(t=n.value),n.addEventListener("change",e.showSelectedStoredPaymentMethod.bind(e))})),this.showSelectedStoredPaymentMethod(null,t)}},{key:"showSelectedStoredPaymentMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;var n='[data-adyen-stored-payment-method-id="'.concat(t,'"]'),a=r.a.querySelector(document,n);a.style.display="block"}},{key:"hideStorePaymentMethodComponents",value:function(){r.a.querySelectorAll(document,".stored-payment-component").forEach((function(e){e.style.display="none"}))}},{key:"confirmOrder",value:function(e){var 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)}},{key:"updatePayment",value:function(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}},{key:"createOrder",value:function(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}},{key:"afterCreateOrder",value:function(){var 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){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",n)}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);var a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(var o in t)a[o]=t[o];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}},{key:"afterSetPayment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var n=JSON.parse(t);n.success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}},{key:"afterPayOrder",value:function(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}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)}}},{key:"handlePaymentAction",value:function(t){try{var n=JSON.parse(t);if((n.isFinal||"voucher"===n.action.type)&&(location.href=this.returnUrl),n.action){var o={};"threeDS2"===n.action.type&&(o.challengeWindowSize="05"),this.adyenCheckout.createFromAction(n.action,o).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(n.action.type)&&(e?a("[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)}}},{key:"initializeCustomPayButton",value:function(){var e=this,t=s.a.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,t);var n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e.selectedAdyenPaymentMethod}));if(n.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(e){return"paywithgoogle"===e.type}))),!(n.length<1)){var a=n[0];if(adyenCheckoutOptions.amount)if(t.prePayRedirect)this.renderPrePaymentButton(t,a);else{var o=y(t.extra,a,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:function(n,a){if(!t.onClick(n,a,e))return!1;d.a.create(document.body)},onSubmit:function(e,n){if(e.isValid){var a={stateData:JSON.stringify(e.data)},o=c.a.serialize(this.confirmOrderForm);"responseHandler"in t&&(this.responseHandler=t.responseHandler.bind(n,this)),this.confirmOrder(o,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",e)}.bind(this),onCancel:function(n,a){d.a.remove(document.body),t.onCancel(n,a,e)},onError:function(n,a){"PayPal"===a.props.name&&"CANCEL"===n.name&&e._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:e.orderId})),d.a.remove(document.body),t.onError(n,a,e),console.log(n)}}),r=this.adyenCheckout.create(a.type,o);try{"isAvailable"in r?r.isAvailable().then(function(){this.mountCustomPayButton(r)}.bind(this)).catch((function(e){console.log(a.type+" is not available",e)})):this.mountCustomPayButton(r)}catch(e){console.log(e)}}else console.error("Failed to fetch Cart/Order total amount.")}}},{key:"renderPrePaymentButton",value:function(e,t){var n=this;"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));var a=y(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:function(t,a){if(!e.onClick(t,a,n))return!1;d.a.create(document.body)},onError:function(t,a){d.a.remove(document.body),e.onError(t,a,n),console.log(t)}}),o=this.adyenCheckout.create(t.type,a);this.mountCustomPayButton(o)}},{key:"completePendingPayment",value:function(e,t){var n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){var a;d.a.create(document.body);var o=this.adyenCheckout.create(e,(u(a={},t.sessionKey,n.searchParams.get(t.sessionKey)),u(a,"showOrderButton",!1),u(a,"onSubmit",function(e,t){if(e.isValid){var n={stateData:JSON.stringify(e.data)},a=c.a.serialize(this.confirmOrderForm);this.confirmOrder(a,n)}}.bind(this)),a));this.mountCustomPayButton(o),o.submit()}}},{key:"getSelectedPaymentMethodKey",value:function(){return Object.keys(s.a.paymentMethodTypeHandlers).find((function(e){return s.a.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler}))}},{key:"mountCustomPayButton",value:function(e){var t=document.querySelector("#confirmOrderForm");if(t){var n=t.querySelector("button[type=submit]");if(n&&!n.disabled){var a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}},{key:"mountPaymentComponent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=y({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);var o={stateData:JSON.stringify(n.data)},r=c.a.serialize(this.confirmOrderForm);d.a.create(document.body),this.confirmOrder(r,o)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);var o=t?n:"#"+this.el.id;try{var i=this.adyenCheckout.create(e.type,a);i.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){r.a.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),i.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}},{key:"appendGiftcardSummary",value:function(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){var 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}}},{key:"setAddressDetails",value:function(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}}])&&p(o.prototype,l),b&&p(o,b),n}(o.a)}).call(this,n("UoTJ"),n("UoTJ"))}},[["TVZM","runtime","vendor-node","vendor-shared"]]]); +(window.webpackJsonp=window.webpackJsonp||[]).push([["adyen-payment-shopware6"],{YcTq:function(e,t,n){"use strict";t.a={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:function(e,t,n){return 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:function(e,t){console.log(e),t.setStatus("ready")}}},paymentMethodTypeHandlers:{scheme:"handler_adyen_cardspaymentmethodhandler",ideal:"handler_adyen_idealpaymentmethodhandler",klarna:"handler_adyen_klarnapaylaterpaaymentmethodhandler",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"}}},j5lx:function(e,t,n){"use strict";(function(e,a){n.d(t,"a",(function(){return b}));var o=n("FGIj"),r=n("gHbT"),i=n("k8s9"),c=n("2Y4b"),d=n("u0Tz"),s=n("YcTq");function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(){return(y=Object.assign||function(e){for(var t=1;t0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}},{key:"initializeCheckoutComponent",value:(k=regeneratorRuntime.mark((function e(){var t,n,a,o,r,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=adyenCheckoutConfiguration,n=t.locale,a=t.clientKey,o=t.environment,r=t.merchantAccount,i=adyenCheckoutOptions.paymentMethodsResponse,c={locale:n,clientKey:a,environment:o,showPayButton:this.selectedAdyenPaymentMethod in s.a.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:r,shopperEmail:shopperDetails.shopperEmail}}}},e.next=5,AdyenCheckout(c);case 5:this.adyenCheckout=e.sent;case 6:case"end":return e.stop()}}),e,this)})),C=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=k.apply(e,t);function r(e){h(o,n,a,r,i,"next",e)}function i(e){h(o,n,a,r,i,"throw",e)}r(void 0)}))},function(){return C.apply(this,arguments)})},{key:"handleOnAdditionalDetails",value:function(e){this._client.post("".concat(adyenCheckoutOptions.paymentDetailsUrl),JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}},{key:"onConfirmOrderSubmit",value:function(e){var t=r.a.querySelector(document,"#confirmOrderForm");if(t.checkValidity()){if("klarna_b2b"===this.selectedAdyenPaymentMethod){var n=r.a.querySelector(document,"#adyen-company-name"),a=r.a.querySelector(document,"#adyen-registration-number"),o=n?n.value.trim():"",i=a?a.value.trim():"",s=r.a.querySelector(document,"#adyen-company-name-error"),l=r.a.querySelector(document,"#adyen-registration-number-error");s.style.display="none",l.style.display="none";var u=!1;if(o||(s.style.display="block",u=!0),i||(l.style.display="block",u=!0),u)return void e.preventDefault()}e.preventDefault(),d.a.create(document.body);var y=c.a.serialize(t);this.confirmOrder(y)}}},{key:"renderPaymentComponent",value:function(e){if("oneclick"!==e){if("giftcard"!==e){var t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0!==t.length){var n=t[0];this.mountPaymentComponent(n,!1)}else"test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e)}}else this.renderStoredPaymentMethodComponents()}},{key:"renderStoredPaymentMethodComponents",value:function(){var e=this;this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((function(t){var n='[data-adyen-stored-payment-method-id="'.concat(t.id,'"]');e.mountPaymentComponent(t,!0,n)})),this.hideStorePaymentMethodComponents();var t=null;r.a.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((function(n){t||(t=n.value),n.addEventListener("change",e.showSelectedStoredPaymentMethod.bind(e))})),this.showSelectedStoredPaymentMethod(null,t)}},{key:"showSelectedStoredPaymentMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.hideStorePaymentMethodComponents(),t=e?e.target.value:t;var n='[data-adyen-stored-payment-method-id="'.concat(t,'"]'),a=r.a.querySelector(document,n);a.style.display="block"}},{key:"hideStorePaymentMethodComponents",value:function(){r.a.querySelectorAll(document,".stored-payment-component").forEach((function(e){e.style.display="none"}))}},{key:"confirmOrder",value:function(e){var 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)}},{key:"updatePayment",value:function(e,t,n){e.set("orderId",t),this._client.post(adyenCheckoutOptions.updatePaymentUrl,e,this.afterSetPayment.bind(this,n))}},{key:"createOrder",value:function(e,t){this._client.post(adyenCheckoutOptions.checkoutOrderUrl,e,this.afterCreateOrder.bind(this,t))}},{key:"afterCreateOrder",value:function(){var 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){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",n)}if(e.url)location.href=e.url;else{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){var a=r.a.querySelector(document,"#adyen-company-name"),o=a?a.value:"",i=r.a.querySelector(document,"#adyen-registration-number"),c=i?i.value:"";t.companyName=o,t.registrationNumber=c}var s={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(var l in t)s[l]=t[l];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(s),this.afterPayOrder.bind(this,this.orderId))}}},{key:"afterSetPayment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var n=JSON.parse(t);n.success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}},{key:"afterPayOrder",value:function(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return d.a.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}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)}}},{key:"handlePaymentAction",value:function(t){try{var n=JSON.parse(t);if((n.isFinal||"voucher"===n.action.type)&&(location.href=this.returnUrl),n.action){var o={};"threeDS2"===n.action.type&&(o.challengeWindowSize="05"),this.adyenCheckout.createFromAction(n.action,o).mount("[data-adyen-payment-action-container]"),["threeDS2","qrCode"].includes(n.action.type)&&(e?a("[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)}}},{key:"initializeCustomPayButton",value:function(){var e=this,t=s.a.componentsWithPayButton[this.selectedAdyenPaymentMethod];this.completePendingPayment(this.selectedAdyenPaymentMethod,t);var n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e.selectedAdyenPaymentMethod}));if(n.length<1&&"googlepay"===this.selectedAdyenPaymentMethod&&(n=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(e){return"paywithgoogle"===e.type}))),!(n.length<1)){var a=n[0];if(adyenCheckoutOptions.amount)if(t.prePayRedirect)this.renderPrePaymentButton(t,a);else{var o=y(t.extra,a,{amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onClick:function(n,a){if(!t.onClick(n,a,e))return!1;d.a.create(document.body)},onSubmit:function(e,n){if(e.isValid){var a={stateData:JSON.stringify(e.data)},o=c.a.serialize(this.confirmOrderForm);"responseHandler"in t&&(this.responseHandler=t.responseHandler.bind(n,this)),this.confirmOrder(o,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",e)}.bind(this),onCancel:function(n,a){d.a.remove(document.body),t.onCancel(n,a,e)},onError:function(n,a){"PayPal"===a.props.name&&"CANCEL"===n.name&&e._client.post("".concat(adyenCheckoutOptions.cancelOrderTransactionUrl),JSON.stringify({orderId:e.orderId})),d.a.remove(document.body),t.onError(n,a,e),console.log(n)}}),r=this.adyenCheckout.create(a.type,o);try{"isAvailable"in r?r.isAvailable().then(function(){this.mountCustomPayButton(r)}.bind(this)).catch((function(e){console.log(a.type+" is not available",e)})):this.mountCustomPayButton(r)}catch(e){console.log(e)}}else console.error("Failed to fetch Cart/Order total amount.")}}},{key:"renderPrePaymentButton",value:function(e,t){var n=this;"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));var a=y(e.extra,t,{configuration:t.configuration,amount:{value:adyenCheckoutOptions.amount,currency:adyenCheckoutOptions.currency},onClick:function(t,a){if(!e.onClick(t,a,n))return!1;d.a.create(document.body)},onError:function(t,a){d.a.remove(document.body),e.onError(t,a,n),console.log(t)}}),o=this.adyenCheckout.create(t.type,a);this.mountCustomPayButton(o)}},{key:"completePendingPayment",value:function(e,t){var n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){var a;d.a.create(document.body);var o=this.adyenCheckout.create(e,(u(a={},t.sessionKey,n.searchParams.get(t.sessionKey)),u(a,"showOrderButton",!1),u(a,"onSubmit",function(e,t){if(e.isValid){var n={stateData:JSON.stringify(e.data)},a=c.a.serialize(this.confirmOrderForm);this.confirmOrder(a,n)}}.bind(this)),a));this.mountCustomPayButton(o),o.submit()}}},{key:"getSelectedPaymentMethodKey",value:function(){return Object.keys(s.a.paymentMethodTypeHandlers).find((function(e){return s.a.paymentMethodTypeHandlers[e]===adyenCheckoutOptions.selectedPaymentMethodHandler}))}},{key:"mountCustomPayButton",value:function(e){var t=document.querySelector("#confirmOrderForm");if(t){var n=t.querySelector("button[type=submit]");if(n&&!n.disabled){var a=document.createElement("div");a.id="adyen-confirm-button",a.setAttribute("data-adyen-confirm-button",""),t.appendChild(a),e.mount(a),n.remove()}}}},{key:"mountPaymentComponent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=y({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);var o={stateData:JSON.stringify(n.data)},r=c.a.serialize(this.confirmOrderForm);d.a.create(document.body),this.confirmOrder(r,o)}else a.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",n)}.bind(this)});!t&&"scheme"===e.type&&adyenCheckoutOptions.displaySaveCreditCardOption&&(a.enableStoreDetails=!0);var o=t?n:"#"+this.el.id;try{var i=this.adyenCheckout.create(e.type,a);i.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){r.a.querySelector(document,"#confirmOrderForm").checkValidity()&&(e.preventDefault(),this.el.parentNode.scrollIntoView({behavior:"smooth",block:"start"}),i.submit())}.bind(this))}catch(t){return console.error(e.type,t),!1}}},{key:"appendGiftcardSummary",value:function(){if(parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.shoppingCartSummaryBlock.length){var 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}}},{key:"setAddressDetails",value:function(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}}])&&p(o.prototype,l),b&&p(o,b),n}(o.a)}).call(this,n("UoTJ"),n("UoTJ"))},jC4o:function(e,t,n){"use strict";n.r(t);var a=n("FGIj"),o=n("gHbT"),r=n("k8s9"),i=n("u0Tz");function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t".concat(e.title,""),o.appendChild(i),o.innerHTML+='

'.concat(a,"


"),t.appendChild(o)})),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))}},{key:"saveGiftcardStateData",value:function(e){e=JSON.stringify(e),this._client.post(adyenGiftcardsConfiguration.setGiftcardUrl,JSON.stringify({stateData:e}),function(e){"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),i.a.remove(document.body))}.bind(this))}},{key:"removeGiftcard",value:function(e){var t=this;i.a.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(function(e){"token"in(e=JSON.parse(e))&&(t.fetchRedeemedGiftcards(),i.a.remove(document.body))}))}},{key:"appendGiftcardSummary",value:function(){if(this.shoppingCartSummaryBlock.length)for(var e=this.shoppingCartSummaryBlock[0].querySelectorAll(".adyen-giftcard-summary"),t=0;t
'+adyenGiftcardsConfiguration.currencySymbol+n+'
'+adyenGiftcardsConfiguration.translationAdyenGiftcardRemainingAmount+'
'+adyenGiftcardsConfiguration.currencySymbol+a+"
";this.shoppingCartSummaryBlock[0].innerHTML+=o}}}])&&u(n.prototype,a),c&&u(n,c),t}(a.a),f=n("j5lx");function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t,n,a,o,r,i){try{var c=e[r](i),d=c.value}catch(e){return void n(e)}c.done?t(d):Promise.resolve(d).then(a,o)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var n=0;n{var a=n(6285),i=n(3206),o=n(8254),r=n(4690);class d extends a.Z{init(){let e=this;this._client=new o.Z,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then(function(){this.observeGiftcardSelection()}.bind(this)),this.adyenGiftcardDropDown=i.Z.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=i.Z.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=i.Z.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=i.Z.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=i.Z.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=i.Z.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"})),window.addEventListener("DOMContentLoaded",(()=>{document.getElementById("giftcardsContainer").addEventListener("click",(e=>{if(e.target.classList.contains("adyen-remove-giftcard")){const t=e.target.getAttribute("dataid");this.removeGiftcard(t)}}))})),window.addEventListener("DOMContentLoaded",(e=>{parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}))}async initializeCheckoutComponent(){const{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="",r.Z.create(i.Z.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";const 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")}r.Z.remove(i.Z.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let i={};i.paymentMethod=JSON.stringify(a.paymentMethod),i.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post(`${adyenGiftcardsConfiguration.checkBalanceUrl}`,JSON.stringify(i),function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){const 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,i=document.createElement("div");var o=document.createElement("img");o.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",o.classList.add("adyen-giftcard-logo");let r=document.createElement("a");r.href="#",r.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,r.setAttribute("dataid",e.stateDataId),r.classList.add("adyen-remove-giftcard"),r.style.display="block",i.appendChild(o),i.innerHTML+=`${e.title}`,i.appendChild(r),i.innerHTML+=`

${a}


`,t.appendChild(i)})),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(),r.Z.remove(document.body))}.bind(this))}removeGiftcard(e){r.Z.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),r.Z.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}}}var s=n(207);const c={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){return 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"}};class l extends a.Z{init(){this._client=new o.Z,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=i.Z.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=i.Z.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=i.Z.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(){adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId&&(adyenCheckoutOptions&&adyenCheckoutOptions.paymentStatusUrl&&adyenCheckoutOptions.checkoutOrderUrl&&adyenCheckoutOptions.paymentHandleUrl?(this.selectedAdyenPaymentMethod in c.componentsWithPayButton&&this.initializeCustomPayButton(),c.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))):console.error("Adyen payment configuration missing."))}.bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,i=adyenCheckoutOptions.paymentMethodsResponse,o={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in c.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(o)}handleOnAdditionalDetails(e){this._client.post(`${adyenCheckoutOptions.paymentDetailsUrl}`,JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}onConfirmOrderSubmit(e){const t=i.Z.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;e.preventDefault(),r.Z.create(document.body);const n=s.Z.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e)return void this.renderStoredPaymentMethodComponents();if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0===t.length)return void("test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e));let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((e=>{let t=`[data-adyen-stored-payment-method-id="${e.id}"]`;this.mountPaymentComponent(e,!0,t)})),this.hideStorePaymentMethodComponents();let e=null;i.Z.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))})),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e,t=null){this.hideStorePaymentMethodComponents();let n=`[data-adyen-stored-payment-method-id="${t=e?e.target.value:t}"]`;i.Z.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){i.Z.querySelectorAll(document,".stored-payment-component").forEach((e=>{e.style.display="none"}))}confirmOrder(e,t={}){const 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(e={},t){let n;try{n=JSON.parse(t)}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}this.orderId=n.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",n.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",n.id);let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(const t in e)a[t]=e[t];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(e={},t){try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post(`${adyenCheckoutOptions.paymentStatusUrl}`,JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{const t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){const e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]");if(["threeDS2","qrCode"].includes(t.action.type))if(window.jQuery)$("[data-adyen-payment-action-modal]").modal({show:!0});else new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show()}}catch(e){console.log(e)}}initializeCustomPayButton(){const e=c.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)return void console.error("Failed to fetch Cart/Order total amount.");if(e.prePayRedirect)return void this.renderPrePaymentButton(e,n);const 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;r.Z.create(document.body)},onSubmit:function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},i=s.Z.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(i,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}.bind(this),onCancel:(t,n)=>{r.Z.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post(`${adyenCheckoutOptions.cancelOrderTransactionUrl}`,JSON.stringify({orderId:this.orderId})),r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}}),i=this.adyenCheckout.create(n.type,a);try{"isAvailable"in i?i.isAvailable().then(function(){this.mountCustomPayButton(i)}.bind(this)).catch((e=>{console.log(n.type+" is not available",e)})):this.mountCustomPayButton(i)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));const 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;r.Z.create(document.body)},onError:(t,n)=>{r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}});let a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){const n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){r.Z.create(document.body);const 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=s.Z.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}.bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(c.paymentMethodTypeHandlers).find((e=>c.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,t=!1,n=null){const a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);let a={stateData:JSON.stringify(n.data)},i=s.Z.serialize(this.confirmOrderForm);r.Z.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 o=t?n:"#"+this.el.id;try{const t=this.adyenCheckout.create(e.type,a);t.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){i.Z.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}}class h extends a.Z{init(){this._client=new o.Z,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:i,backgroundUrl:o,logoUrl:r,name:d,description:s,url:c}=adyenGivingConfiguration,l={locale:e,clientKey:t,environment:n},h={amounts:{currency:a,values:i.split(",").map((e=>Number(e)))},backgroundUrl:o,logoUrl:r,description:s,name:d,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout(l),this.adyenCheckout.create("donation",h).mount("#donation-container")}handleOnDonate(e,t){const n=adyenGivingConfiguration.orderId;let a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post(`${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}}class y extends a.Z{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration,i={locale:e,clientKey:t,environment:n};this.adyenCheckout=await AdyenCheckout(i),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}}const m=window.PluginManager;m.register("CartPlugin",d,"#adyen-giftcards-container"),m.register("ConfirmOrderPlugin",l,"#adyen-payment-checkout-mask"),m.register("AdyenGivingPlugin",h,"#adyen-giving-container"),m.register("AdyenSuccessAction",y,"#adyen-success-action-container")}},e=>{e.O(0,["vendor-node","vendor-shared"],(()=>{return t=7815,e(e.s=t);var t}));e.O()}]); \ No newline at end of file +"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["adyen-payment-shopware6"],{6253:(e,t,n)=>{var a=n(6285),i=n(3206),o=n(8254),r=n(4690);class d extends a.Z{init(){let e=this;this._client=new o.Z,this.adyenCheckout=Promise,this.paymentMethodInstance=null,this.selectedGiftcard=null,this.initializeCheckoutComponent().then(function(){this.observeGiftcardSelection()}.bind(this)),this.adyenGiftcardDropDown=i.Z.querySelectorAll(document,"#giftcardDropdown"),this.adyenGiftcard=i.Z.querySelectorAll(document,".adyen-giftcard"),this.giftcardHeader=i.Z.querySelector(document,".adyen-giftcard-header"),this.giftcardItem=i.Z.querySelector(document,".adyen-giftcard-item"),this.giftcardComponentClose=i.Z.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=i.Z.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"})),window.addEventListener("DOMContentLoaded",(()=>{document.getElementById("giftcardsContainer").addEventListener("click",(e=>{if(e.target.classList.contains("adyen-remove-giftcard")){const t=e.target.getAttribute("dataid");this.removeGiftcard(t)}}))})),window.addEventListener("DOMContentLoaded",(e=>{parseInt(adyenGiftcardsConfiguration.giftcardDiscount,10)&&this.fetchRedeemedGiftcards()}))}async initializeCheckoutComponent(){const{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="",r.Z.create(i.Z.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";const 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")}r.Z.remove(i.Z.querySelector(document,"#adyen-giftcard-component"))}handleBalanceCheck(e,t,n,a){let i={};i.paymentMethod=JSON.stringify(a.paymentMethod),i.amount=JSON.stringify({currency:adyenGiftcardsConfiguration.currency,value:adyenGiftcardsConfiguration.totalInMinorUnits}),this._client.post(`${adyenGiftcardsConfiguration.checkBalanceUrl}`,JSON.stringify(i),function(t){if((t=JSON.parse(t)).hasOwnProperty("pspReference")){const 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,i=document.createElement("div");var o=document.createElement("img");o.src="https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/"+e.brand+".svg",o.classList.add("adyen-giftcard-logo");let r=document.createElement("a");r.href="#",r.textContent=adyenGiftcardsConfiguration.translationAdyenGiftcardRemove,r.setAttribute("dataid",e.stateDataId),r.classList.add("adyen-remove-giftcard"),r.style.display="block",i.appendChild(o),i.innerHTML+=`${e.title}`,i.appendChild(r),i.innerHTML+=`

${a}


`,t.appendChild(i)})),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(),r.Z.remove(document.body))}.bind(this))}removeGiftcard(e){r.Z.create(document.body),this._client.post(adyenGiftcardsConfiguration.removeGiftcardUrl,JSON.stringify({stateDataId:e}),(e=>{"token"in(e=JSON.parse(e))&&(this.fetchRedeemedGiftcards(),r.Z.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}}}var s=n(207);const c={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){return 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_klarnapaylaterpaaymentmethodhandler",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"}};class l extends a.Z{init(){this._client=new o.Z,this.selectedAdyenPaymentMethod=this.getSelectedPaymentMethodKey(),this.confirmOrderForm=i.Z.querySelector(document,"#confirmOrderForm"),this.confirmFormSubmit=i.Z.querySelector(document,'#confirmOrderForm button[type="submit"]'),this.shoppingCartSummaryBlock=i.Z.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(){adyenCheckoutOptions.selectedPaymentMethodPluginId===adyenCheckoutOptions.adyenPluginId&&(adyenCheckoutOptions&&adyenCheckoutOptions.paymentStatusUrl&&adyenCheckoutOptions.checkoutOrderUrl&&adyenCheckoutOptions.paymentHandleUrl?(this.selectedAdyenPaymentMethod in c.componentsWithPayButton&&this.initializeCustomPayButton(),"klarna_b2b"!==this.selectedAdyenPaymentMethod&&c.updatablePaymentMethods.includes(this.selectedAdyenPaymentMethod)&&!this.stateData?this.renderPaymentComponent(this.selectedAdyenPaymentMethod):this.confirmFormSubmit.addEventListener("click",this.onConfirmOrderSubmit.bind(this))):console.error("Adyen payment configuration missing."))}.bind(this)),adyenCheckoutOptions.payInFullWithGiftcard>0?parseInt(adyenCheckoutOptions.giftcardDiscount,10)&&this.appendGiftcardSummary():this.appendGiftcardSummary()}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n,merchantAccount:a}=adyenCheckoutConfiguration,i=adyenCheckoutOptions.paymentMethodsResponse,o={locale:e,clientKey:t,environment:n,showPayButton:this.selectedAdyenPaymentMethod in c.componentsWithPayButton,hasHolderName:!0,paymentMethodsResponse:JSON.parse(i),onAdditionalDetails:this.handleOnAdditionalDetails.bind(this),countryCode:activeShippingAddress.country,paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,clickToPayConfiguration:{merchantDisplayName:a,shopperEmail:shopperDetails.shopperEmail}}}};this.adyenCheckout=await AdyenCheckout(o)}handleOnAdditionalDetails(e){this._client.post(`${adyenCheckoutOptions.paymentDetailsUrl}`,JSON.stringify({orderId:this.orderId,stateData:JSON.stringify(e.data)}),function(e){200===this._client._request.status?this.responseHandler(e):location.href=this.errorUrl.toString()}.bind(this))}onConfirmOrderSubmit(e){const t=i.Z.querySelector(document,"#confirmOrderForm");if(!t.checkValidity())return;if("klarna_b2b"===this.selectedAdyenPaymentMethod){const t=i.Z.querySelector(document,"#adyen-company-name"),n=i.Z.querySelector(document,"#adyen-registration-number"),a=t?t.value.trim():"",o=n?n.value.trim():"",r=i.Z.querySelector(document,"#adyen-company-name-error"),d=i.Z.querySelector(document,"#adyen-registration-number-error");r.style.display="none",d.style.display="none";let s=!1;if(a||(r.style.display="block",s=!0),o||(d.style.display="block",s=!0),s)return void e.preventDefault()}e.preventDefault(),r.Z.create(document.body);const n=s.Z.serialize(t);this.confirmOrder(n)}renderPaymentComponent(e){if("oneclick"===e)return void this.renderStoredPaymentMethodComponents();if("giftcard"===e)return;let t=this.adyenCheckout.paymentMethodsResponse.paymentMethods.filter((function(t){return t.type===e}));if(0===t.length)return void("test"===this.adyenCheckout.options.environment&&console.error("Payment method configuration not found. ",e));let n=t[0];this.mountPaymentComponent(n,!1)}renderStoredPaymentMethodComponents(){this.adyenCheckout.paymentMethodsResponse.storedPaymentMethods.forEach((e=>{let t=`[data-adyen-stored-payment-method-id="${e.id}"]`;this.mountPaymentComponent(e,!0,t)})),this.hideStorePaymentMethodComponents();let e=null;i.Z.querySelectorAll(document,"[name=adyenStoredPaymentMethodId]").forEach((t=>{e||(e=t.value),t.addEventListener("change",this.showSelectedStoredPaymentMethod.bind(this))})),this.showSelectedStoredPaymentMethod(null,e)}showSelectedStoredPaymentMethod(e,t=null){this.hideStorePaymentMethodComponents();let n=`[data-adyen-stored-payment-method-id="${t=e?e.target.value:t}"]`;i.Z.querySelector(document,n).style.display="block"}hideStorePaymentMethodComponents(){i.Z.querySelectorAll(document,".stored-payment-component").forEach((e=>{e.style.display="none"}))}confirmOrder(e,t={}){const 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(e={},t){let n;try{n=JSON.parse(t)}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}if(n.url)return void(location.href=n.url);if(this.orderId=n.id,this.finishUrl=new URL(location.origin+adyenCheckoutOptions.paymentFinishUrl),this.finishUrl.searchParams.set("orderId",n.id),this.errorUrl=new URL(location.origin+adyenCheckoutOptions.paymentErrorUrl),this.errorUrl.searchParams.set("orderId",n.id),"handler_adyen_billiepaymentmethodhandler"===adyenCheckoutOptions.selectedPaymentMethodHandler){const t=i.Z.querySelector(document,"#adyen-company-name"),n=t?t.value:"",a=i.Z.querySelector(document,"#adyen-registration-number"),o=a?a.value:"";e.companyName=n,e.registrationNumber=o}let a={orderId:this.orderId,finishUrl:this.finishUrl.toString(),errorUrl:this.errorUrl.toString()};for(const t in e)a[t]=e[t];this._client.post(adyenCheckoutOptions.paymentHandleUrl,JSON.stringify(a),this.afterPayOrder.bind(this,this.orderId))}afterSetPayment(e={},t){try{JSON.parse(t).success&&this.afterCreateOrder(e,JSON.stringify({id:adyenCheckoutOptions.orderId}))}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}}afterPayOrder(e,t){try{t=JSON.parse(t),this.returnUrl=t.redirectUrl}catch(e){return r.Z.remove(document.body),void console.log("Error: invalid response from Shopware API",t)}this.returnUrl===this.errorUrl.toString()&&(location.href=this.returnUrl);try{this._client.post(`${adyenCheckoutOptions.paymentStatusUrl}`,JSON.stringify({orderId:e}),this.responseHandler.bind(this))}catch(e){console.log(e)}}handlePaymentAction(e){try{const t=JSON.parse(e);if((t.isFinal||"voucher"===t.action.type)&&(location.href=this.returnUrl),t.action){const e={};"threeDS2"===t.action.type&&(e.challengeWindowSize="05"),this.adyenCheckout.createFromAction(t.action,e).mount("[data-adyen-payment-action-container]");if(["threeDS2","qrCode"].includes(t.action.type))if(window.jQuery)$("[data-adyen-payment-action-modal]").modal({show:!0});else new bootstrap.Modal(document.getElementById("adyen-payment-action-modal"),{keyboard:!1}).show()}}catch(e){console.log(e)}}initializeCustomPayButton(){const e=c.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)return void console.error("Failed to fetch Cart/Order total amount.");if(e.prePayRedirect)return void this.renderPrePaymentButton(e,n);const 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;r.Z.create(document.body)},onSubmit:function(t,n){if(t.isValid){let a={stateData:JSON.stringify(t.data)},i=s.Z.serialize(this.confirmOrderForm);"responseHandler"in e&&(this.responseHandler=e.responseHandler.bind(n,this)),this.confirmOrder(i,a)}else n.showValidation(),"test"===this.adyenCheckout.options.environment&&console.log("Payment failed: ",t)}.bind(this),onCancel:(t,n)=>{r.Z.remove(document.body),e.onCancel(t,n,this)},onError:(t,n)=>{"PayPal"===n.props.name&&"CANCEL"===t.name&&this._client.post(`${adyenCheckoutOptions.cancelOrderTransactionUrl}`,JSON.stringify({orderId:this.orderId})),r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}}),i=this.adyenCheckout.create(n.type,a);try{"isAvailable"in i?i.isAvailable().then(function(){this.mountCustomPayButton(i)}.bind(this)).catch((e=>{console.log(n.type+" is not available",e)})):this.mountCustomPayButton(i)}catch(e){console.log(e)}}renderPrePaymentButton(e,t){"amazonpay"===t.type&&(e.extra=this.setAddressDetails(e.extra));const 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;r.Z.create(document.body)},onError:(t,n)=>{r.Z.remove(document.body),e.onError(t,n,this),console.log(t)}});let a=this.adyenCheckout.create(t.type,n);this.mountCustomPayButton(a)}completePendingPayment(e,t){const n=new URL(location.href);if(n.searchParams.has(t.sessionKey)){r.Z.create(document.body);const 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=s.Z.serialize(this.confirmOrderForm);this.confirmOrder(n,t)}}.bind(this)});this.mountCustomPayButton(a),a.submit()}}getSelectedPaymentMethodKey(){return Object.keys(c.paymentMethodTypeHandlers).find((e=>c.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,t=!1,n=null){const a=Object.assign({},e,{data:{personalDetails:shopperDetails,billingAddress:activeBillingAddress,deliveryAddress:activeShippingAddress},onSubmit:function(n,a){if(n.isValid){t&&void 0!==e.holderName&&(n.data.paymentMethod.holderName=e.holderName);let a={stateData:JSON.stringify(n.data)},i=s.Z.serialize(this.confirmOrderForm);r.Z.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 o=t?n:"#"+this.el.id;try{const t=this.adyenCheckout.create(e.type,a);t.mount(o),this.confirmFormSubmit.addEventListener("click",function(e){i.Z.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}}class y extends a.Z{init(){this._client=new o.Z,this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{currency:a,values:i,backgroundUrl:o,logoUrl:r,name:d,description:s,url:c}=adyenGivingConfiguration,l={locale:e,clientKey:t,environment:n},y={amounts:{currency:a,values:i.split(",").map((e=>Number(e)))},backgroundUrl:o,logoUrl:r,description:s,name:d,url:c,showCancelButton:!0,onDonate:this.handleOnDonate.bind(this),onCancel:this.handleOnCancel.bind(this)};this.adyenCheckout=await AdyenCheckout(l),this.adyenCheckout.create("donation",y).mount("#donation-container")}handleOnDonate(e,t){const n=adyenGivingConfiguration.orderId;let a={stateData:JSON.stringify(e.data),orderId:n};a.returnUrl=window.location.href,this._client.post(`${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}}class h extends a.Z{init(){this.adyenCheckout=Promise,this.initializeCheckoutComponent().bind(this)}async initializeCheckoutComponent(){const{locale:e,clientKey:t,environment:n}=adyenCheckoutConfiguration,{action:a}=adyenSuccessActionConfiguration,i={locale:e,clientKey:t,environment:n};this.adyenCheckout=await AdyenCheckout(i),this.adyenCheckout.createFromAction(JSON.parse(a)).mount("#success-action-container")}}const m=window.PluginManager;m.register("CartPlugin",d,"#adyen-giftcards-container"),m.register("ConfirmOrderPlugin",l,"#adyen-payment-checkout-mask"),m.register("AdyenGivingPlugin",y,"#adyen-giving-container"),m.register("AdyenSuccessAction",h,"#adyen-success-action-container")}},e=>{e.O(0,["vendor-node","vendor-shared"],(()=>{return t=6253,e(e.s=t);var t}));e.O()}]); \ No newline at end of file diff --git a/src/Service/AdyenPaymentService.php b/src/Service/AdyenPaymentService.php index d8059d1b..f4e387c1 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -180,6 +180,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 56273bfeb995f60f5ceeb1f449d7db7afe11cf5a Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Fri, 6 Dec 2024 12:24:42 +0100 Subject: [PATCH 22/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 5eb28cef..43e63496 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 efc1045b22460ea0cdbf2e3df1c0ddf0228c393b Mon Sep 17 00:00:00 2001 From: Tamara Date: Mon, 9 Dec 2024 14:22:05 +0100 Subject: [PATCH 23/23] Ignore SonarQube issues --- .../storefront/component/payment/payment-ratepay.html.twig | 3 ++- src/Util/RatePayDeviceFingerprintParamsProvider.php | 3 ++- 2 files changed, 4 insertions(+), 2 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 53ff0c93..1acff3a0 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,6 @@ l: '{{ adyenFrontendData.ratepay.location }}' }; - + {# 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 a56625c1..03292848 100644 --- a/src/Util/RatePayDeviceFingerprintParamsProvider.php +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -53,7 +53,8 @@ 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()) + // This is excluded from Sonar analysis because md5 is used to generate a unique token. + md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime())//NOSONAR ); }