diff --git a/composer.json b/composer.json index 5eb28cef..143ac29d 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,12 @@ } ], "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": { - "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": "*" @@ -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" + ] } } 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/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 806a2170..f151b9fa 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -28,15 +28,18 @@ 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; +use Adyen\Shopware\Models\PaymentRequest as IntegrationPaymentRequest; use Adyen\Model\Checkout\Address; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\BrowserInfo; use Adyen\Model\Checkout\Name; use Adyen\Model\Checkout\PaymentResponse; use Adyen\Service\Checkout\PaymentsApi; +use Adyen\Shopware\PaymentMethods\RatepayDirectdebitPaymentMethod; +use Adyen\Shopware\PaymentMethods\RatepayPaymentMethod; use Adyen\Shopware\Util\CheckoutStateDataValidator; use Adyen\Shopware\Exception\PaymentCancelledException; use Adyen\Shopware\Exception\PaymentFailedException; @@ -46,6 +49,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; @@ -112,6 +116,11 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle */ protected $checkoutStateDataValidator; + /** + * @var RatePayDeviceFingerprintParamsProvider + */ + protected $ratePayFingerprintParamsProvider; + /** * @var PaymentStateDataService */ @@ -203,6 +212,7 @@ public function __construct( ClientService $clientService, Currency $currency, CheckoutStateDataValidator $checkoutStateDataValidator, + RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider, PaymentStateDataService $paymentStateDataService, SalesChannelRepository $salesChannelRepository, PaymentResponseHandler $paymentResponseHandler, @@ -220,6 +230,7 @@ public function __construct( $this->currency = $currency; $this->configurationService = $configurationService; $this->checkoutStateDataValidator = $checkoutStateDataValidator; + $this->ratePayFingerprintParamsProvider = $ratePayFingerprintParamsProvider; $this->paymentStateDataService = $paymentStateDataService; $this->salesChannelRepository = $salesChannelRepository; $this->paymentResponseHandler = $paymentResponseHandler; @@ -280,6 +291,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 +311,8 @@ public function pay( $transaction, $stateData, $this->remainingAmount, - $this->orderRequestData + $this->orderRequestData, + $billieData ); //make /payments call $this->paymentsCall($salesChannelContext, $request, $transaction); @@ -300,6 +320,13 @@ public function pay( if ($storedStateData) { $this->paymentStateDataService->deletePaymentStateDataFromId($storedStateData['id']); } + + $paymentMethodType = $stateData['paymentMethod']['type']; + if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) { + $this->ratePayFingerprintParamsProvider->clear(); + } } $orderNumber = $transaction->getOrder()->getOrderNumber(); @@ -349,7 +376,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 ); } @@ -393,7 +424,7 @@ public function finalize( * @param array $request * @param int|null $partialAmount * @param array|null $adyenOrderData - * @return PaymentRequest + * @return IntegrationPaymentRequest */ protected function preparePaymentsRequest( SalesChannelContext $salesChannelContext, @@ -401,9 +432,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']; @@ -587,6 +618,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(), @@ -602,6 +646,12 @@ protected function preparePaymentsRequest( $paymentRequest->setMerchantAccount( $this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId()) ); + if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) { + $paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken()); + } + if ($paymentMethodType === 'bcmc_mobile') { $paymentRequest->setReturnUrl($this->getReturnUrl($transaction)); } else { @@ -719,9 +769,11 @@ private function getPaymentRequest( $transaction, $stateData, $partialAmount, - $orderRequestData + $orderRequestData, + $billieData = [] ) { $transactionId = $transaction->getOrderTransaction()->getId(); + $stateData['billieData'] = $billieData; try { $request = $this->preparePaymentsRequest( $salesChannelContext, @@ -747,7 +799,7 @@ private function getPaymentRequest( private function paymentsCall( SalesChannelContext $salesChannelContext, - PaymentRequest $request, + IntegrationPaymentRequest $request, AsyncPaymentTransactionStruct $transaction ): void { $transactionId = $transaction->getOrderTransaction()->getId(); diff --git a/src/Handlers/ResultHandler.php b/src/Handlers/ResultHandler.php index b36c2906..37d479f5 100644 --- a/src/Handlers/ResultHandler.php +++ b/src/Handlers/ResultHandler.php @@ -115,10 +115,15 @@ 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/Models/PaymentRequest.php b/src/Models/PaymentRequest.php new file mode 100755 index 00000000..f1d4d865 --- /dev/null +++ b/src/Models/PaymentRequest.php @@ -0,0 +1,616 @@ + '\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/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/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/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 + + 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 5d981b6a..c8d2117e 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 8521ca7d..aba25342 100644 --- a/src/Resources/config/services/checkout-api.xml +++ b/src/Resources/config/services/checkout-api.xml @@ -16,6 +16,10 @@ + + + + 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/config/services/payment-handlers.xml b/src/Resources/config/services/payment-handlers.xml index f0b39a00..4c8f714b 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/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/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..0859b253 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/billie-payment-method.html.twig @@ -0,0 +1,32 @@ +{% 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 05325ded..597b3ffc 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -17,5 +17,7 @@ {% if payment.id is same as(selectedPaymentMethodId) and 'handler_adyen_' in payment.formattedHandlerIdentifier %} {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-component.html.twig' %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/payment-ratepay.html.twig' %} + {% sw_include '@AdyenPaymentShopware6/storefront/component/payment/billie-payment-method.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..1acff3a0 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/payment-ratepay.html.twig @@ -0,0 +1,12 @@ +{% if payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaydirectdebitpaymentmethodhandler') + or payment.formattedHandlerIdentifier is same as('handler_adyen_ratepaypaymentmethodhandler') %} + + {# 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/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..f4e387c1 100644 --- a/src/Service/AdyenPaymentService.php +++ b/src/Service/AdyenPaymentService.php @@ -29,11 +29,14 @@ 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\AsyncPaymentTransactionStruct; +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; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; +use Shopware\Core\System\SalesChannel\SalesChannelContext; class AdyenPaymentService { @@ -168,4 +171,24 @@ 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'); + $criteria->addAssociation('stateMachineState'); + + /** @var OrderTransactionEntity|null $orderTransaction */ + $orderTransaction = $this->orderTransactionRepository->search($criteria, $context->getContext())->first(); + + if ($orderTransaction === null || $orderTransaction->getOrder() === null) { + throw new InvalidTransactionException($orderTransactionId); + } + + return new AsyncPaymentTransactionStruct($orderTransaction, $orderTransaction->getOrder(), ''); + } } 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..6d9a6f6d 100644 --- a/src/Service/PaymentMethodsFilterService.php +++ b/src/Service/PaymentMethodsFilterService.php @@ -30,6 +30,8 @@ use Adyen\Shopware\Handlers\GooglePayPaymentMethodHandler; use Adyen\Shopware\Handlers\OneClickPaymentMethodHandler; use Adyen\Shopware\Handlers\ApplePayPaymentMethodHandler; +use Adyen\Shopware\PaymentMethods\RatepayDirectdebitPaymentMethod; +use Adyen\Shopware\PaymentMethods\RatepayPaymentMethod; use Shopware\Core\Checkout\Payment\PaymentMethodCollection; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Checkout\Payment\SalesChannel\AbstractPaymentMethodRoute; @@ -42,6 +44,11 @@ class PaymentMethodsFilterService { + /** + * @var ConfigurationService + */ + private $configurationService; + /** * @var PaymentMethodsService */ @@ -56,15 +63,18 @@ class PaymentMethodsFilterService /** * PaymentMethodsFilterService constructor. * + * @param ConfigurationService $configurationService * @param PaymentMethodsService $paymentMethodsService * @param AbstractPaymentMethodRoute $paymentMethodRoute * @param EntityRepository $paymentMethodRepository */ public function __construct( + ConfigurationService $configurationService, PaymentMethodsService $paymentMethodsService, AbstractPaymentMethodRoute $paymentMethodRoute, $paymentMethodRepository ) { + $this->configurationService = $configurationService; $this->paymentMethodsService = $paymentMethodsService; $this->paymentMethodRoute = $paymentMethodRoute; $this->paymentMethodRepository = $paymentMethodRepository; @@ -106,6 +116,14 @@ function (PaymentMethodEntity $item) use ($adyenPluginId) { $pmCode = $pmHandlerIdentifier::getPaymentMethodCode(); $isSafari = preg_match('/^((?!chrome|android).)*safari/', strtolower($_SERVER['HTTP_USER_AGENT'])); + if (( + $pmCode === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE || + $pmCode === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE + ) && + !$this->configurationService->getDeviceFingerprintSnippetId()) { + $originalPaymentMethods->remove($paymentMethodEntity->getId()); + } + if ($pmCode == OneClickPaymentMethodHandler::getPaymentMethodCode()) { // For OneClick, remove it if /paymentMethod response has no stored payment methods if (empty($adyenPaymentMethods->getStoredPaymentMethods())) { diff --git a/src/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..777d2992 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; } @@ -215,19 +225,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; } @@ -405,7 +402,9 @@ public function onCheckoutConfirmLoaded(PageLoadedEvent $event) ), 'affiliateCode' => $affiliateCode, 'campaignCode' => $campaignCode, - ] + 'companyName' => $salesChannelContext->getCustomer()->getActiveBillingAddress()->getCompany(), + ], + $this->getFingerprintParametersForRatepayMethod($salesChannelContext, $selectedPaymentMethod) ) ) ); @@ -439,4 +438,25 @@ 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/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' ); /** diff --git a/src/Util/RatePayDeviceFingerprintParamsProvider.php b/src/Util/RatePayDeviceFingerprintParamsProvider.php new file mode 100644 index 00000000..03292848 --- /dev/null +++ b/src/Util/RatePayDeviceFingerprintParamsProvider.php @@ -0,0 +1,74 @@ +requestStack = $requestStack; + $this->configurationService = $configurationService; + } + + /** + * Provides fingerprint parameters + * + * @param string|null $salesChannelId + * @return array + */ + public function getFingerprintParams(string $salesChannelId = null): array + { + return [ + 'snippetId' => $this->configurationService->getDeviceFingerprintSnippetId($salesChannelId), + 'token' => $this->getToken(), + 'location' => 'Checkout' + ]; + } + + /** + * Creates token, set in session and retrieves it + * + * @return string + */ + public function getToken(): string + { + if (!$this->requestStack->getSession()->get(self::TOKEN_SESSION_KEY)) { + $this->requestStack->getSession()->set( + self::TOKEN_SESSION_KEY, + // This is excluded from Sonar analysis because md5 is used to generate a unique token. + md5($this->requestStack->getSession()->get('sessionId') . '_' . microtime())//NOSONAR + ); + } + + 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); + } +}