diff --git a/Block/Form/InvoiceSecured.php b/Block/Form/InvoiceSecured.php deleted file mode 100644 index 9ed8078..0000000 --- a/Block/Form/InvoiceSecured.php +++ /dev/null @@ -1,90 +0,0 @@ -salutation = $salutation; - $this->birthDateFactory = $birthDateFactory; - } - - /** - * Get Salutation Options - * - * @return array - */ - public function getSalutationOptions(): array - { - return $this->salutation->toOptionArray(); - } - - /** - * Get BirthDate - * - * @return BirthDate - * @throws LocalizedException - */ - public function getBirthDate(): BirthDate - { - if ($this->birthDate === null) { - $this->birthDate = $this->birthDateFactory->create(); - $this->birthDate->setDate($this->getInfoData('birthDate')); - } - return $this->birthDate; - } - - /** - * Get Info Data - * - * @param string $field - * @return mixed - * @throws LocalizedException - */ - public function getInfoData($field) - { - return $this->getMethod()->getInfoInstance()->getData($field); - } -} diff --git a/Block/Info/Invoice.php b/Block/Info/Invoice.php index 70911fd..ae6370c 100644 --- a/Block/Info/Invoice.php +++ b/Block/Info/Invoice.php @@ -193,7 +193,7 @@ public function getOrder(): Order * @return string * @throws NoSuchEntityException */ - public function getStoreCode(string $storeId = null): string + public function getStoreCode(?string $storeId = null): string { return $this->_storeManager->getStore($storeId)->getCode(); } diff --git a/Block/Info/InvoiceSecured.php b/Block/Info/InvoiceSecured.php deleted file mode 100644 index 676ab9c..0000000 --- a/Block/Info/InvoiceSecured.php +++ /dev/null @@ -1,53 +0,0 @@ -setTemplate('Unzer_PAPI::info/pdf/invoice_secured.phtml'); - return $this->toHtml(); - } - - /** - * Get Customer Salutation - * - * @return string - * @throws LocalizedException - * @throws UnzerApiException - */ - public function getCustomerSalutation(): string - { - return $this->_getPayment()->getCustomer()->getSalutation(); - } - - /** - * Get Customer BirthDate - * - * @return string|null - * @throws LocalizedException - * @throws UnzerApiException - */ - public function getCustomerBirthdate(): ?string - { - return $this->_getPayment()->getCustomer()->getBirthDate(); - } -} diff --git a/Block/Info/InvoiceSecuredB2b.php b/Block/Info/InvoiceSecuredB2b.php deleted file mode 100644 index e401f7f..0000000 --- a/Block/Info/InvoiceSecuredB2b.php +++ /dev/null @@ -1,26 +0,0 @@ -setTemplate('Unzer_PAPI::info/pdf/invoice_secured_b2b.phtml'); - return $this->toHtml(); - } -} diff --git a/Block/Info/PaylaterDirectDebit.php b/Block/Info/PaylaterDirectDebit.php index c3844ee..b9d9cfb 100644 --- a/Block/Info/PaylaterDirectDebit.php +++ b/Block/Info/PaylaterDirectDebit.php @@ -98,7 +98,7 @@ protected function _getPayment(): Payment * @return string * @throws NoSuchEntityException */ - public function getStoreCode(string $storeId = null): string + public function getStoreCode(?string $storeId = null): string { return $this->_storeManager->getStore($storeId)->getCode(); } diff --git a/Block/Info/PaylaterInstallment.php b/Block/Info/PaylaterInstallment.php index 8c3f611..87ea5a9 100644 --- a/Block/Info/PaylaterInstallment.php +++ b/Block/Info/PaylaterInstallment.php @@ -98,7 +98,7 @@ protected function _getPayment(): Payment * @return string * @throws NoSuchEntityException */ - public function getStoreCode(string $storeId = null): string + public function getStoreCode(?string $storeId = null): string { return $this->_storeManager->getStore($storeId)->getCode(); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 642eda6..6c5a8d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [4.0.0](https://github.com/unzerdev/magento2/compare/3.2.9..4.0.0) +### Changed +* Migration from Unzer UI Component V1 to Unzer UI Component V2 +* Deprecated payment methods have been replaced with new ones, removed or renamed. For full list see https://docs.unzer.com/plugins/magento-2/magento2-migrate-v1-v2/#payment-methods-changes +### Added +* EAA Support + +For more information go to https://docs.unzer.com/plugins/magento-2/magento2-migrate-v1-v2/#page-title + + ## [3.2.9](https://github.com/unzerdev/magento2/compare/3.2.8..3.2.9) ### Changed * Hide first name, last name and email fields for Invoice B2B payment method diff --git a/Helper/Order.php b/Helper/Order.php index 74a49e7..19f03de 100644 --- a/Helper/Order.php +++ b/Helper/Order.php @@ -7,6 +7,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Module\ModuleListInterface; use Magento\Payment\Model\InfoInterface; use Magento\Payment\Model\MethodInterface; @@ -30,6 +31,8 @@ use UnzerSDK\Resources\EmbeddedResources\Address; use UnzerSDK\Resources\EmbeddedResources\BasketItem; use UnzerSDK\Resources\EmbeddedResources\BasketItemFactory; +use UnzerSDK\Resources\EmbeddedResources\CompanyInfo; +use UnzerSDK\Resources\EmbeddedResources\CompanyOwner; use UnzerSDK\Resources\Metadata; use UnzerSDK\Resources\PaymentTypes\BasePaymentType; @@ -83,6 +86,11 @@ class Order */ private CreateThreatMetrixId $createThreatMetrixId; + /** + * @var ResolverInterface + */ + private ResolverInterface $localeResolver; + /** * Constructor * @@ -94,6 +102,7 @@ class Order * @param BasketItemFactory $basketItemFactory * @param BirthDateFactory $birthDateFactory * @param CreateThreatMetrixId $createThreatMetrixId + * @param ResolverInterface $localeResolver */ public function __construct( Config $moduleConfig, @@ -103,7 +112,8 @@ public function __construct( BasketFactory $basketFactory, BasketItemFactory $basketItemFactory, BirthDateFactory $birthDateFactory, - CreateThreatMetrixId $createThreatMetrixId + CreateThreatMetrixId $createThreatMetrixId, + ResolverInterface $localeResolver ) { $this->_moduleConfig = $moduleConfig; $this->_moduleList = $moduleList; @@ -113,6 +123,7 @@ public function __construct( $this->basketItemFactory = $basketItemFactory; $this->birthDateFactory = $birthDateFactory; $this->createThreatMetrixId = $createThreatMetrixId; + $this->localeResolver = $localeResolver; } /** @@ -175,6 +186,7 @@ public function createBasketForOrder(OrderModel $order): Basket * Create Basket * * @param OrderModel $order + * * @return Basket */ protected function createBasket(OrderModel $order): Basket @@ -191,6 +203,7 @@ protected function createBasket(OrderModel $order): Basket * Create Shipping Item * * @param OrderModel $order + * * @return BasketItem */ protected function createShippingItem(OrderModel $order): BasketItem @@ -208,6 +221,7 @@ protected function createShippingItem(OrderModel $order): BasketItem * Create Basket Item * * @param Item $orderItem + * * @return BasketItem */ protected function createBasketItem(Item $orderItem): BasketItem @@ -246,6 +260,7 @@ private function createRoundingItem(float $amount): BasketItem * * @param OrderModel $order * @param float $vatRate + * * @return BasketItem */ protected function createVoucherItem(OrderModel $order, float $vatRate): BasketItem @@ -266,7 +281,7 @@ protected function createVoucherItem(OrderModel $order, float $vatRate): BasketI ); if ($taxAfterDiscount && !$pricesIncludeTax) { - $discount *= (1 + $vatRate/100); + $discount *= (1 + $vatRate / 100); } $basketVoucherItemDiscountAmount = $this->basketItemFactory->create(); @@ -287,6 +302,7 @@ protected function createVoucherItem(OrderModel $order, float $vatRate): BasketI * Returns metadata for the given order. * * @param OrderModel $order + * * @return Metadata */ public function createMetadataForOrder(OrderModel $order): Metadata @@ -330,6 +346,12 @@ public function createCustomerFromQuote(Quote $quote, string $email, bool $creat $customer->setPhone($billingAddress->getTelephone()); $customer->setBirthDate($quote->getCustomer()->getDob()); + $customerId = (string) $quote->getCustomerId() . '_' . $email; + + if(!$quote->getCustomerIsGuest()) { + $customer->setCustomerId($customerId); + } + $threatMetrixId = $this->createThreatMetrixId->execute($quote); if ($threatMetrixId !== null) { $customer->setThreatMetrixId($threatMetrixId); @@ -348,7 +370,7 @@ public function createCustomerFromQuote(Quote $quote, string $email, bool $creat $methodInstance = $quote->getPayment()->getMethod() ? $quote->getPayment()->getMethodInstance() : null; $client = $this->_moduleConfig->getUnzerClient($quote->getStore()->getCode(), $methodInstance); - return $createResource ? $client->createCustomer($customer) : $customer; + return $createResource ? $client->createOrUpdateCustomer($customer) : $customer; } /** @@ -357,12 +379,20 @@ public function createCustomerFromQuote(Quote $quote, string $email, bool $creat * @param OrderModel $order * @param string $email * @param bool $createResource + * @param string|null $customerType * * @return Customer|null - * @throws UnzerApiException|LocalizedException + * + * @throws LocalizedException + * @throws UnzerApiException */ - public function createCustomerFromOrder(OrderModel $order, string $email, bool $createResource = false): ?Customer - { + public function createCustomerFromOrder( + OrderModel $order, + string $email, + bool $createResource = false, + ?string $customerType = null + ): + ?Customer { $client = $this->_moduleConfig->getUnzerClient( $order->getStore()->getCode(), $order->getPayment()->getMethodInstance() @@ -370,6 +400,13 @@ public function createCustomerFromOrder(OrderModel $order, string $email, bool $ $billingAddress = $order->getBillingAddress(); $customer = new Customer(); + $birthDate = null; + + $currentLocale = $this->localeResolver->getLocale(); + $languageCode = strtok($currentLocale, '_-'); + if ($languageCode) { + $customer->setLanguage($languageCode); + } if ($billingAddress !== null) { $customer->setFirstname($billingAddress->getFirstname()) @@ -394,6 +431,12 @@ public function createCustomerFromOrder(OrderModel $order, string $email, bool $ } $customer->setEmail($email); + $customerId = (string) $order->getCustomerId() . '_' . $email; + + if(!$order->getCustomerIsGuest()) { + $customer->setCustomerId($customerId); + } + $this->updateGatewayAddressFromMagento($customer->getBillingAddress(), $billingAddress); } @@ -403,7 +446,21 @@ public function createCustomerFromOrder(OrderModel $order, string $email, bool $ $this->updateGatewayAddressFromMagento($customer->getShippingAddress(), $shippingAddress, $shippingType); } - return $createResource ? $client->createCustomer($customer) : $customer; + if ($customerType && $customerType !== 'b2c') { + $companyInfo = new CompanyInfo(); + $companyInfo->setCompanyType($customerType); + $companyInfo->setRegistrationType('not_registered'); + $companyInfo->setFunction('OWNER'); + $owner = new CompanyOwner(); + $owner->setFirstname($customer->getFirstname()); + $owner->setLastname($customer->getLastname()); + $birthDate && $owner->setBirthdate($birthDate); + $companyInfo->setOwner($owner); + + $customer->setCompanyInfo($companyInfo); + } + + return $createResource ? $client->createOrUpdateCustomer($customer) : $customer; } /** @@ -458,6 +515,7 @@ private function updateGatewayAddressFromMagento( * * @param $billingAddress * @param $shippingAddress + * * @return string */ public function getShippingType($billingAddress, $shippingAddress): string @@ -488,6 +546,7 @@ public function getShippingType($billingAddress, $shippingAddress): string * Convert Street Lines To String * * @param array $streetLines + * * @return string */ private function convertStreetLinesToString(array $streetLines): string @@ -502,6 +561,7 @@ private function convertStreetLinesToString(array $streetLines): string * * @param OrderModel $order * @param Customer $gatewayCustomer + * * @throws UnzerApiException|LocalizedException */ public function updateGatewayCustomerFromOrder(OrderModel $order, Customer $gatewayCustomer): void @@ -541,6 +601,7 @@ public function updateGatewayCustomerFromOrder(OrderModel $order, Customer $gate * * @param OrderModel $order * @param Customer $gatewayCustomer + * * @return bool */ public function validateGatewayCustomerAgainstOrder(OrderModel $order, Customer $gatewayCustomer): bool @@ -575,6 +636,7 @@ public function validateGatewayCustomerAgainstOrder(OrderModel $order, Customer * * @param Address $gatewayAddress * @param OrderAddressInterface $magentoAddress + * * @return bool */ private function validateGatewayAddressAgainstOrderAddress( @@ -596,6 +658,7 @@ private function validateGatewayAddressAgainstOrderAddress( * Default -> unknown * * @param Quote $quote + * * @return string */ protected function getSalutationFromQuote(Quote $quote): string @@ -607,6 +670,7 @@ protected function getSalutationFromQuote(Quote $quote): string * Get Salutation From Gender * * @param float|int $gender + * * @return string */ protected function getSalutationFromGender($gender): string @@ -628,6 +692,7 @@ protected function getSalutationFromGender($gender): string * Get Salutation From Payment * * @param InfoInterface $payment + * * @return string|null */ protected function getSalutationFromPayment(InfoInterface $payment): ?string @@ -639,6 +704,7 @@ protected function getSalutationFromPayment(InfoInterface $payment): ?string * Get Birthdate from Payment * * @param InfoInterface $payment + * * @return string|null */ protected function getBirthdateFromPayment(InfoInterface $payment): ?string diff --git a/Helper/Payment.php b/Helper/Payment.php index 359c26e..6a59a2c 100644 --- a/Helper/Payment.php +++ b/Helper/Payment.php @@ -22,6 +22,7 @@ use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\OrderRepository; +use Unzer\PAPI\Model\Command\TransactionSynchronizer; use Unzer\PAPI\Model\Method\Base; use Unzer\PAPI\Model\Vault\VaultDetailsHandlerManager; use UnzerSDK\Constants\PaymentState; @@ -94,6 +95,11 @@ class Payment */ private PaymentDataObjectFactoryInterface $paymentDataObjectFactory; + /** + * @var TransactionSynchronizer + */ + private TransactionSynchronizer $transactionSynchronizer; + /** * Constructor * @@ -108,6 +114,7 @@ class Payment * @param TransactionRepositoryInterface $transactionRepository * @param VaultDetailsHandlerManager $vaultDetailsHandlerManager * @param PaymentDataObjectFactoryInterface $paymentDataObjectFactory + * @param TransactionSynchronizer $transactionSynchronizer */ public function __construct( InvoiceRepositoryInterface $invoiceRepository, @@ -120,7 +127,8 @@ public function __construct( OrderPaymentRepositoryInterface $paymentRepository, TransactionRepositoryInterface $transactionRepository, VaultDetailsHandlerManager $vaultDetailsHandlerManager, - PaymentDataObjectFactoryInterface $paymentDataObjectFactory + PaymentDataObjectFactoryInterface $paymentDataObjectFactory, + TransactionSynchronizer $transactionSynchronizer ) { $this->_invoiceRepository = $invoiceRepository; $this->_invoiceSender = $invoiceSender; @@ -133,6 +141,7 @@ public function __construct( $this->_transactionRepository = $transactionRepository; $this->vaultDetailsHandlerManager = $vaultDetailsHandlerManager; $this->paymentDataObjectFactory = $paymentDataObjectFactory; + $this->transactionSynchronizer = $transactionSynchronizer; } /** @@ -140,6 +149,7 @@ public function __construct( * * @param OrderInterface $order * @param PaymentResource $payment + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -163,13 +173,13 @@ public function processState(OrderInterface $order, PaymentResource $payment): v switch ($payment->getState()) { case PaymentState::STATE_CANCELED: - $this->processCanceledState($order); + $this->processCanceledState($order, $payment); break; case PaymentState::STATE_COMPLETED: $this->processCompletedState($order, $payment); break; case PaymentState::STATE_CHARGEBACK: - $this->processChargebackState($order); + $this->processChargebackState($order, $payment); break; case PaymentState::STATE_PARTLY: $this->processPartlyState($order, $payment); @@ -190,13 +200,20 @@ public function processState(OrderInterface $order, PaymentResource $payment): v * Process canceled state * * @param OrderInterface $order + * @param PaymentResource $payment + * * @return void + * * @throws AlreadyExistsException * @throws InputException + * @throws LocalizedException * @throws NoSuchEntityException + * @throws UnzerApiException */ - private function processCanceledState(OrderInterface $order): void + private function processCanceledState(OrderInterface $order, PaymentResource $payment): void { + $this->transactionSynchronizer->applyCancellationOnMagento($order, $payment); + // Orders in payment_review can't be cancelled so we must manually // change the status so that we can cancel the Order. if ($order->isPaymentReview()) { @@ -219,12 +236,18 @@ private function processCanceledState(OrderInterface $order): void $this->_orderRepository->save($order); } } + + if ($payment->getAmount()->getTotal() && $payment->getAmount()->getTotal() === $payment->getAmount()->getCanceled()) { + $this->setOrderState($order, Order::STATE_CLOSED, Order::STATE_CLOSED); + $this->_orderRepository->save($order); + } } /** * Is order voided * * @param OrderInterface $order + * * @return bool * @throws InputException */ @@ -243,7 +266,9 @@ private function isOrderVoided(OrderInterface $order): bool * * @param OrderInterface $order * @param PaymentResource $payment + * * @return void + * * @throws AlreadyExistsException * @throws InputException * @throws LocalizedException @@ -252,14 +277,16 @@ private function isOrderVoided(OrderInterface $order): bool */ private function processCompletedState(OrderInterface $order, PaymentResource $payment): void { + $this->transactionSynchronizer->applyCaptureOnMagento($order, $payment); + $orderPayment = $order->getPayment(); - $transactionId = $payment->getChargeByIndex(0)->getId(); + $transactionId = $order->getPayment()->getLastTransId(); /** @var Order\Invoice $invoice */ $invoice = $order->getInvoiceCollection()->getItemByColumnValue('transaction_id', $transactionId); - if ((int)$invoice->getState() === Order\Invoice::STATE_OPEN) { + if ($invoice !== null && (int)$invoice->getState() === Order\Invoice::STATE_OPEN) { $invoice->pay(); $order = $invoice->getOrder(); @@ -277,13 +304,13 @@ private function processCompletedState(OrderInterface $order, PaymentResource $p $order->getId() ); - if (!$paymentTransaction->getIsClosed()) { + if ($paymentTransaction && !$paymentTransaction->getIsClosed()) { $paymentTransaction->setIsClosed(true); $this->_transactionRepository->save($paymentTransaction); $parentPaymentTransaction = $paymentTransaction->getParentTransaction(); - if ($parentPaymentTransaction !== null && + if (!empty($parentPaymentTransaction) && !$parentPaymentTransaction->getIsClosed() ) { $parentPaymentTransaction->setIsClosed(true); @@ -302,14 +329,14 @@ private function processCompletedState(OrderInterface $order, PaymentResource $p * Process chargeback state * * @param OrderInterface $order + * @param PaymentResource $payment + * * @return void - * @throws AlreadyExistsException - * @throws InputException - * @throws LocalizedException - * @throws NoSuchEntityException + * @throws Exception */ - private function processChargebackState(OrderInterface $order): void + private function processChargebackState(OrderInterface $order, PaymentResource $payment): void { + $this->transactionSynchronizer->applyChargebackOnMagento($order, $payment); if ($order->getState() !== Order::STATE_CANCELED && $order->getState() !== Order::STATE_CLOSED) { $this->setOrderState($order, Order::STATE_PAYMENT_REVIEW, Order::STATUS_FRAUD); @@ -321,6 +348,7 @@ private function processChargebackState(OrderInterface $order): void * * @param OrderInterface $order * @param PaymentResource $payment + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -330,13 +358,17 @@ private function processChargebackState(OrderInterface $order): void */ private function processPartlyState(OrderInterface $order, PaymentResource $payment): void { - $this->processPendingState($order, $payment); + $this->transactionSynchronizer->applyCancellationOnMagento($order, $payment); + $this->transactionSynchronizer->applyCaptureOnMagento($order, $payment); + + $this->setOrderState($order, Order::STATE_PROCESSING); } /** * Process payment review state * * @param OrderInterface $order + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -353,6 +385,7 @@ private function processPaymentReviewState(OrderInterface $order): void * * @param OrderInterface $order * @param PaymentResource $payment + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -377,6 +410,7 @@ private function processPendingState(OrderInterface $order, PaymentResource $pay * Set Invoice Type State * * @param OrderInterface $order + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -402,6 +436,7 @@ private function setInvoiceTypeState(OrderInterface $order): void * * @param OrderInterface $order * @param PaymentResource $payment + * * @return void * @throws InvalidArgumentException * @throws LocalizedException @@ -445,6 +480,7 @@ private function processVaultDetails(OrderInterface $order, PaymentResource $pay * @param OrderInterface $order * @param string|null $state * @param string|null $status + * * @return void * @throws AlreadyExistsException * @throws InputException @@ -487,6 +523,7 @@ public function setOrderState(OrderInterface $order, ?string $state = null, ?str * Send Emails * * @param OrderInterface $order + * * @return void * @throws LocalizedException * @throws Exception diff --git a/Model/Command/AbstractCommand.php b/Model/Command/AbstractCommand.php index 17fc28a..213aa24 100644 --- a/Model/Command/AbstractCommand.php +++ b/Model/Command/AbstractCommand.php @@ -105,9 +105,10 @@ protected function _getCallbackUrl(): string * * @param string|null $storeCode * @param MethodInterface|null $paymentMethodInstance + * * @return Unzer */ - protected function _getClient(string $storeCode = null, MethodInterface $paymentMethodInstance = null): Unzer + protected function _getClient(?string $storeCode = null, ?MethodInterface $paymentMethodInstance = null): Unzer { if ($this->_client === null) { $this->_client = $this->_config->getUnzerClient($storeCode, $paymentMethodInstance); @@ -129,6 +130,8 @@ protected function _getCustomerId(InfoInterface $payment, SalesOrder $order): ?s { /** @var string|null $customerId */ $customerId = (string)$payment->getAdditionalInformation(BaseDataAssignObserver::KEY_CUSTOMER_ID); + /** @var string|null $customerId */ + $customerType = (string)$payment->getAdditionalInformation(BaseDataAssignObserver::KEY_CUSTOMER_TYPE); $customer = $this->getCustomer( $customerId, @@ -138,7 +141,12 @@ protected function _getCustomerId(InfoInterface $payment, SalesOrder $order): ?s //customer not found on this account. create a new one... if ($customer === null) { - $customer = $this->_orderHelper->createCustomerFromOrder($order, $order->getCustomerEmail(), true); + $customer = $this->_orderHelper->createCustomerFromOrder( + $order, + $order->getCustomerEmail(), + true, + $customerType + ); $payment->setAdditionalInformation(BaseDataAssignObserver::KEY_CUSTOMER_ID, $customer->getId()); } @@ -156,6 +164,7 @@ protected function _getCustomerId(InfoInterface $payment, SalesOrder $order): ?s * @param string $customerId * @param string $storeCode * @param MethodInterface $paymentMethodInstance + * * @return Customer|null * @throws UnzerApiException */ @@ -187,6 +196,7 @@ protected function getCustomer( * * @param InfoInterface $payment * @param SalesOrder $order + * * @return string|null * @throws UnzerApiException|LocalizedException */ @@ -253,6 +263,7 @@ protected function addUnzerErrorToOrderHistory(SalesOrder $order, string $code, * Get Store Code * * @param int $storeId + * * @return string * @throws NoSuchEntityException */ @@ -265,6 +276,7 @@ public function getStoreCode(int $storeId): string * Is Vault Save Allowed * * @param MethodInterface $methodInstance + * * @return bool */ public function isVaultSaveAllowed(MethodInterface $methodInstance): bool diff --git a/Model/Command/Authorize.php b/Model/Command/Authorize.php index aab085a..f625a84 100644 --- a/Model/Command/Authorize.php +++ b/Model/Command/Authorize.php @@ -159,6 +159,7 @@ public function execute(array $commandSubject): ?ResultInterface * * @param Authorization $authorization * @param OrderPayment $payment + * * @return Authorization * @throws LocalizedException * @throws UnzerApiException @@ -186,6 +187,7 @@ protected function performAuthorization(Authorization $authorization, OrderPayme * * @param PaymentDataObjectInterface $paymentDataObject * @param Authorization $authorization + * * @return void * @throws LocalizedException * @throws UnzerApiException @@ -206,6 +208,7 @@ protected function processSaveToVault( * * @param OrderInterface $order * @param float $amount + * * @return Authorization */ protected function createAuthorization(OrderInterface $order, float $amount): Authorization diff --git a/Model/Command/Capture.php b/Model/Command/Capture.php index 17ac1d7..1f1fc61 100644 --- a/Model/Command/Capture.php +++ b/Model/Command/Capture.php @@ -132,7 +132,7 @@ public function execute(array $commandSubject): ?ResultInterface * @return Charge * @throws UnzerApiException|LocalizedException */ - protected function _chargeExisting(Order $order, string $paymentId, float $amount, string $storeId = null): Charge + protected function _chargeExisting(Order $order, string $paymentId, float $amount, ?string $storeId = null): Charge { $payment = $this->_getClient($storeId, $order->getPayment()->getMethodInstance()) ->fetchPayment($paymentId); diff --git a/Model/Command/TransactionSynchronizer.php b/Model/Command/TransactionSynchronizer.php new file mode 100644 index 0000000..d67893d --- /dev/null +++ b/Model/Command/TransactionSynchronizer.php @@ -0,0 +1,229 @@ +transactionRepository = $transactionRepository; + $this->paymentRepository = $paymentRepository; + } + + /** + * @param OrderInterface $order + * @param UnzerPayment $unzer + * + * @return void + * + * @throws UnzerApiException + */ + public function applyCaptureOnMagento(OrderInterface $order, UnzerPayment $unzer): void + { + $payment = $this->getOrderPayment($order); + $capture = array_last($unzer->getCharges()); + + if (!$payment || !$capture) { + return; + } + + $captureId = $capture->getId() ?? ''; + + if ($captureId === '') { + return; + } + + if ($this->hasTransaction($payment, $order, $captureId)) { + return; + } + + $parentTxnId = $this->resolveCaptureParentTxnId($unzer); + + if ($parentTxnId) { + $payment->setParentTransactionId($parentTxnId); + } + + $payment->setTransactionId($captureId); + + if ($capture->isSuccess()) { + $payment->registerCaptureNotification($capture->getAmount(), true); + $this->paymentRepository->save($payment); + } + $this->paymentRepository->save($payment); + } + + /** + * @param OrderInterface $order + * @param UnzerPayment $unzer + * + * @return void + * + * @throws UnzerApiException + */ + public function applyCancellationOnMagento(OrderInterface $order, UnzerPayment $unzer): void + { + $payment = $this->getOrderPayment($order); + $cancellation = array_last($unzer->getCancellations()); + + if (!$payment || !$cancellation) { + return; + } + + $cancelId = $cancellation->getId() ?? ''; + + if ($cancelId === '') { + return; + } + + if ($this->hasTransaction($payment, $order, $cancelId)) { + return; + } + + $parent = $cancellation->getParentResource(); + + if ($parent instanceof UnzerCharge && $parent->getId()) { + $parentTxnId = $parent->getId(); + + // prepayment + if ($unzer->getAmount()->getTotal() == 0) { + $cancelTxnId = $parentTxnId . '-void'; + $payment->setParentTransactionId($parentTxnId); + $payment->setTransactionId($cancelTxnId); + $payment->registerVoidNotification($cancellation->getAmount()); + + return; + } + + $refundTxnId = $parentTxnId . '-refund'; + + $payment->setParentTransactionId($parentTxnId); + $payment->setTransactionId($refundTxnId); + + $payment->registerRefundNotification($cancellation->getAmount()); + + $this->paymentRepository->save($payment); + + return; + } + + if ($parent instanceof UnzerAuthorization && $parent->getId()) { + $parentTxnId = $parent->getId(); + $cancelTxnId = $parentTxnId . '-void'; + + $payment->setParentTransactionId($parentTxnId); + $payment->setTransactionId($cancelTxnId); + + $payment->registerVoidNotification($cancellation->getAmount()); + + $this->paymentRepository->save($payment); + } + } + + /** + * @param OrderInterface $order + * @param UnzerPayment $unzer + * + * @return void + */ + public function applyChargebackOnMagento(OrderInterface $order, UnzerPayment $unzer): void + { + $payment = $this->getOrderPayment($order); + $chargeback = array_last($unzer->getChargebacks()); + + if (!$payment || !$chargeback) { + return; + } + + $chargebackId = $chargeback->getId() ?? ''; + + if ($chargebackId === '') { + return; + } + + if ($this->hasTransaction($payment, $order, $chargebackId)) { + return; + } + + $parent = $chargeback->getParentResource(); + + $parentTxnId = $parent->getId(); + $chargebackTxnId = $parentTxnId . '-' . $chargebackId; + + $payment->setParentTransactionId($parentTxnId); + $payment->setTransactionId($chargebackTxnId); + + $payment->registerRefundNotification($chargeback->getAmount()); + + $this->paymentRepository->save($payment); + } + + /** + * @param OrderInterface $order + * + * @return OrderPayment|null + */ + private function getOrderPayment(OrderInterface $order): ?OrderPayment + { + $payment = $order->getPayment(); + + return $payment instanceof OrderPayment ? $payment : null; + } + + /** + * @param OrderPayment $payment + * @param OrderInterface $order + * @param string $txnId + * + * @return bool + */ + private function hasTransaction(OrderPayment $payment, OrderInterface $order, string $txnId): bool + { + if ($txnId === '') { + return false; + } + try { + return (bool)$this->transactionRepository->getByTransactionId( + $txnId, + $payment->getId(), + $order->getId() + ); + } catch (\Throwable $ex) { + return false; + } + } + + /** + * @param UnzerPayment $unzer + * + * @return string|null + * + * @throws UnzerApiException + */ + private function resolveCaptureParentTxnId(UnzerPayment $unzer): ?string + { + $parent = $unzer->getAuthorization(true); + if ($parent instanceof UnzerAuthorization && $parent->getId()) { + return (string)$parent->getId(); + } + + return null; + } +} diff --git a/Model/Config.php b/Model/Config.php index db39d27..a627f14 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -35,31 +35,24 @@ class Config extends \Magento\Payment\Gateway\Config\Config public const METHOD_CARDS_VAULT = 'unzer_cards_vault'; public const METHOD_DIRECT_DEBIT = 'unzer_direct_debit'; - public const METHOD_DIRECT_DEBIT_SECURED = 'unzer_direct_debit_secured'; public const METHOD_EPS = 'unzer_eps'; - public const METHOD_GIROPAY = 'unzer_giropay'; - public const METHOD_BANK_TRANSFER = 'unzer_bank_transfer'; public const METHOD_IDEAL = 'unzer_ideal'; - public const METHOD_INVOICE = 'unzer_invoice'; public const METHOD_PAYLATER_INVOICE = 'unzer_paylater_invoice'; public const METHOD_PAYLATER_INVOICE_B2B = 'unzer_paylater_invoice_b2b'; public const METHOD_PAYLATER_INSTALLMENT = 'unzer_paylater_installment'; public const METHOD_PAYLATER_DIRECT_DEBIT = 'unzer_paylater_direct_debit'; - public const METHOD_INVOICE_SECURED_B2B = 'unzer_invoice_secured_b2b'; - public const METHOD_INVOICE_SECURED = 'unzer_invoice_secured'; public const METHOD_PAYPAL = 'unzer_paypal'; public const METHOD_PAYPAL_VAULT = 'unzer_paypal_vault'; - public const METHOD_SOFORT = 'unzer_sofort'; public const METHOD_ALIPAY = 'unzer_alipay'; public const METHOD_WECHATPAY = 'unzer_wechatpay'; public const METHOD_PRZELEWY24 = 'unzer_przelewy24'; public const METHOD_BANCONTACT = 'unzer_bancontact'; public const METHOD_PREPAYMENT = 'unzer_prepayment'; - public const METHOD_APPLEPAY = 'unzer_applepay'; public const METHOD_APPLEPAYV2 = 'unzer_applepayv2'; public const METHOD_GOOGLEPAY = 'unzer_googlepay'; public const METHOD_TWINT = 'unzer_twint'; public const METHOD_OPEN_BANKING = 'unzer_open_banking'; + public const METHOD_KLARNA = 'unzer_klarna'; /** * @var DebugHandler @@ -121,7 +114,7 @@ public function __construct( * @param string|null $storeId * @return bool */ - private function isDebugMode(string $storeId = null): bool + private function isDebugMode(?string $storeId = null): bool { return $this->_scopeConfig->isSetFlag( self::BASE_CONFIGURATION_PATH . self::KEY_LOGGING, @@ -137,7 +130,7 @@ private function isDebugMode(string $storeId = null): bool * @param MethodInterface|null $paymentMethodInstance * @return string|null */ - public function getPublicKey(string $storeId = null, MethodInterface $paymentMethodInstance = null): ?string + public function getPublicKey(?string $storeId = null, ?MethodInterface $paymentMethodInstance = null): ?string { if ($paymentMethodInstance instanceof OverrideApiCredentialInterface && $paymentMethodInstance->hasMethodValidOverrideKeys($storeId) @@ -159,7 +152,7 @@ public function getPublicKey(string $storeId = null, MethodInterface $paymentMet * @param MethodInterface|null $paymentMethodInstance * @return string|null */ - public function getPrivateKey(string $storeId = null, MethodInterface $paymentMethodInstance = null): ?string + public function getPrivateKey(?string $storeId = null, ?MethodInterface $paymentMethodInstance = null): ?string { if ($paymentMethodInstance instanceof OverrideApiCredentialInterface && $paymentMethodInstance->hasMethodValidOverrideKeys($storeId) @@ -181,7 +174,7 @@ public function getPrivateKey(string $storeId = null, MethodInterface $paymentMe * @param MethodInterface|null $paymentMethodInstance * @return Unzer */ - public function getUnzerClient(string $storeId = null, MethodInterface $paymentMethodInstance = null): Unzer + public function getUnzerClient(?string $storeId = null, ?MethodInterface $paymentMethodInstance = null): Unzer { $client = new Unzer( $this->getPrivateKey($storeId, $paymentMethodInstance), diff --git a/Model/Config/Provider.php b/Model/Config/Provider.php index b6ca67b..5396daa 100644 --- a/Model/Config/Provider.php +++ b/Model/Config/Provider.php @@ -22,32 +22,25 @@ class Provider implements ConfigProviderInterface * @var array */ protected array $_methodCodes = [ - Config::METHOD_BANK_TRANSFER, Config::METHOD_CARDS, Config::METHOD_DIRECT_DEBIT, - Config::METHOD_DIRECT_DEBIT_SECURED, Config::METHOD_EPS, - Config::METHOD_GIROPAY, Config::METHOD_IDEAL, - Config::METHOD_INVOICE, - Config::METHOD_INVOICE_SECURED, - Config::METHOD_INVOICE_SECURED_B2B, Config::METHOD_PAYLATER_INVOICE, Config::METHOD_PAYLATER_INVOICE_B2B, Config::METHOD_PAYLATER_INSTALLMENT, Config::METHOD_PAYLATER_DIRECT_DEBIT, Config::METHOD_PAYPAL, - Config::METHOD_SOFORT, Config::METHOD_ALIPAY, Config::METHOD_WECHATPAY, Config::METHOD_PRZELEWY24, Config::METHOD_BANCONTACT, Config::METHOD_PREPAYMENT, - Config::METHOD_APPLEPAY, Config::METHOD_APPLEPAYV2, Config::METHOD_GOOGLEPAY, Config::METHOD_TWINT, Config::METHOD_OPEN_BANKING, + Config::METHOD_KLARNA ]; /** diff --git a/Model/Method/Applepay.php b/Model/Method/Applepay.php deleted file mode 100644 index f29161d..0000000 --- a/Model/Method/Applepay.php +++ /dev/null @@ -1,28 +0,0 @@ -_scopeConfig->getValue('payment/unzer/applepay/supported_networks'); - $supportedNetworks = explode(',', $supportedNetworks); - - return [ - 'supportedNetworks' => $supportedNetworks, - 'merchantCapabilities' => ['supports3DS'], - 'label' => $this->_scopeConfig->getValue('payment/unzer_applepay/display_name') //label - ]; - } -} diff --git a/Model/Method/BankTransfer.php b/Model/Method/BankTransfer.php deleted file mode 100644 index 37d46a9..0000000 --- a/Model/Method/BankTransfer.php +++ /dev/null @@ -1,20 +0,0 @@ -_moduleConfig; if ($quote === null) { @@ -144,6 +144,10 @@ public function isAvailable(CartInterface $quote = null) return false; } + if ($hasCompany && $this->isB2cOnly()) { + return false; + } + return parent::isAvailable($quote); } @@ -201,7 +205,7 @@ public function hasRiskData(): bool * @param string|null $storeId * @return bool */ - public function hasMethodValidOverrideKeys(string $storeId = null): bool + public function hasMethodValidOverrideKeys(?string $storeId = null): bool { if (!$this->getConfigData(Config::OVERRIDE_API_KEYS, $storeId)) { return false; @@ -222,7 +226,7 @@ public function hasMethodValidOverrideKeys(string $storeId = null): bool * @param string|null $storeId * @return string */ - public function getMethodOverridePublicKey(string $storeId = null): string + public function getMethodOverridePublicKey(?string $storeId = null): string { return (string)$this->getConfigData(Config::KEY_PUBLIC_KEY, $storeId); } @@ -233,7 +237,7 @@ public function getMethodOverridePublicKey(string $storeId = null): string * @param string|null $storeId * @return string */ - public function getMethodOverridePrivateKey(string $storeId = null): string + public function getMethodOverridePrivateKey(?string $storeId = null): string { return (string)$this->getConfigData(Config::KEY_PRIVATE_KEY, $storeId); } diff --git a/Model/Method/Cards.php b/Model/Method/Cards.php index b482c60..25eed8f 100644 --- a/Model/Method/Cards.php +++ b/Model/Method/Cards.php @@ -12,6 +12,8 @@ class Cards extends Base { public const VAULT_CODE = 'unzer_cards_vault'; + public const ENABLE_CLICK_TO_PAY = 'enable_click_to_pay'; + /** * @inheritDoc */ @@ -30,6 +32,7 @@ public function getFrontendConfig(): array $parentConfig = parent::getFrontendConfig(); $parentConfig['vault_code'] = $this->getVaultCode(); + $parentConfig['enable_click_to_pay'] = $this->getConfigData(self::ENABLE_CLICK_TO_PAY); return $parentConfig; } diff --git a/Model/Method/DirectDebitSecured.php b/Model/Method/DirectDebitSecured.php deleted file mode 100644 index a74f986..0000000 --- a/Model/Method/DirectDebitSecured.php +++ /dev/null @@ -1,30 +0,0 @@ -getConfigData(self::CONFIG_MERCHANT_ID); $parentConfig['merchant_name'] = $this->getConfigData(self::CONFIG_MERCHANT_NAME); $parentConfig['country_code'] = $this->getConfigData(self::CONFIG_COUNTRY_CODE); - $parentConfig['allowed_card_networks'] = explode(',', $this->getConfigData(self::CONFIG_ALLOWED_CARD_NETWORKS)); + $parentConfig['allowed_card_networks'] = $this->getConfigData(self::CONFIG_ALLOWED_CARD_NETWORKS) ? + explode(',', $this->getConfigData(self::CONFIG_ALLOWED_CARD_NETWORKS)) : []; $parentConfig['allow_credit_cards'] = $this->getConfigData(self::CONFIG_ALLOW_CREDIT_CARDS); $parentConfig['allow_prepaid_cards'] = $this->getConfigData(self::CONFIG_ALLOW_PREPAID_CARDS); $parentConfig['button_color'] = $this->getConfigData(self::CONFIG_BUTTON_COLOR); diff --git a/Model/Method/Invoice.php b/Model/Method/Invoice.php index 49cc1fe..b92c496 100644 --- a/Model/Method/Invoice.php +++ b/Model/Method/Invoice.php @@ -52,19 +52,19 @@ class Invoice extends Base * @param LoggerInterface|null $logger */ public function __construct( - ManagerInterface $eventManager, + ManagerInterface $eventManager, ValueHandlerPoolInterface $valueHandlerPool, - PaymentDataObjectFactory $paymentDataObjectFactory, + PaymentDataObjectFactory $paymentDataObjectFactory, $code, $formBlockType, $infoBlockType, - ScopeConfigInterface $scopeConfig, - Config $moduleConfig, - PriceCurrencyInterface $priceCurrency, - CommandPoolInterface $commandPool = null, - ValidatorPoolInterface $validatorPool = null, - CommandManagerInterface $commandExecutor = null, - LoggerInterface $logger = null + ScopeConfigInterface $scopeConfig, + Config $moduleConfig, + PriceCurrencyInterface $priceCurrency, + ?CommandPoolInterface $commandPool = null, + ?ValidatorPoolInterface $validatorPool = null, + ?CommandManagerInterface $commandExecutor = null, + ?LoggerInterface $logger = null ) { parent::__construct( $eventManager, diff --git a/Model/Method/InvoiceSecured.php b/Model/Method/InvoiceSecured.php deleted file mode 100644 index 695d042..0000000 --- a/Model/Method/InvoiceSecured.php +++ /dev/null @@ -1,38 +0,0 @@ -getFileData(); if (!empty($file)) { - $uploadDir = $this->getUploadDirPath('.well-known/'); + $uploadDir = $this->getUploadDirPath(self::UPLOAD_DIR); try { $uploader = $this->_uploaderFactory->create(['fileId' => $file]); $uploader->setAllowRenameFiles(false); $uploader->addValidateCallback('size', $this, 'validateMaxSize'); $uploader->setFilesDispersion(false); - $domainAssocFileName = 'apple-developer-merchantid-domain-association'; + $domainAssocFileName = self::DOMAIN_ASSOCIATION_FILE_NAME; $result = $uploader->save($uploadDir, $domainAssocFileName); } catch (Exception $e) { @@ -67,7 +74,7 @@ public function beforeSave(): Upload } } else { if (is_array($value) && !empty($value['delete'])) { - $this->setValue(''); + $this->deleteDomainAssocFile(); } elseif (is_array($value) && !empty($value['value'])) { $this->setValue($value['value']); } else { @@ -77,4 +84,26 @@ public function beforeSave(): Upload return $this; } + + /** + * @return void + * + * @throws FileSystemException + * @throws LocalizedException + */ + private function deleteDomainAssocFile(): void + { + $uploadDir = $this->getUploadDirPath(self::UPLOAD_DIR); + $filePath = $uploadDir . DIRECTORY_SEPARATOR . self::DOMAIN_ASSOCIATION_FILE_NAME; + + if ($this->_mediaDirectory->isExist($filePath)) { + try { + $this->_mediaDirectory->delete($filePath); + } catch (Exception $e) { + throw new LocalizedException(__('Unable to delete file: %1', $e->getMessage())); + } + } + + $this->setValue(''); + } } diff --git a/composer.json b/composer.json index 956ad7c..2c4a1fc 100644 --- a/composer.json +++ b/composer.json @@ -2,11 +2,11 @@ "name": "unzerdev/magento2", "description": "This extension for Magento 2 provides a direct integration of the Unzer payment types to your Magento 2 shop via the Unzer Payment API (PAPI).", "type": "magento2-module", - "version": "3.2.9", + "version": "4.0.0", "license": "Apache-2.0", "require": { - "php": "~7.4.0|~8.1.0|~8.2.0|~8.3.0", - "unzerdev/php-sdk": "^3.11.0", + "php": "~7.4.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0", + "unzerdev/php-sdk": "^3.13.0", "ext-json": "*", "magento/framework": "*", "magento/module-backend": "*", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 42e1540..d325bdf 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -50,30 +50,23 @@ - - - - - - - - + diff --git a/etc/adminhtml/system/applepay.xml b/etc/adminhtml/system/applepay.xml deleted file mode 100644 index a6d9359..0000000 --- a/etc/adminhtml/system/applepay.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - -

Existing merchants:

-

We have updated our integration with Apple Pay, but since you already have it set up, you don't need to do anything just now.

-

However, when your Apple Pay certificates are about to expire, you can change to the new integration.

-

You can of course change to the new integration now, if you want, and then you don't have to worry about expiring certificates, changing integration, etc. in the future.

-
-

Existing and new both:

-

Before you activate Apple Pay, please make sure you have read our checklist.

- - ]]> -
-
- - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_applepay/active - - - - payment/unzer_applepay/title - - - - payment/unzer_applepay/order_payment_action - Unzer\PAPI\Model\System\Config\Source\PaymentAction - - - - payment/unzer_applepay/min_order_total - - - - payment/unzer_applepay/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_applepay/apple_pay_merchant_id - - - - payment/unzer_applepay/display_name - - - - payment/unzer_applepay/domain_name - - - - Unzer\PAPI\Model\System\Config\Backend\Upload - upload/applepay - - - - Unzer\PAPI\Model\System\Config\Backend\Upload - upload/applepay - - - - - Unzer\PAPI\Model\System\Config\Backend\Upload - upload/applepay_csr - - - - Unzer\PAPI\Model\System\Config\Backend\Upload - upload/applepay_csr - - - - - Unzer\PAPI\Block\System\Config\WebhooksApplepayButtons - - - - Unzer\PAPI\Model\Source\Applepay\SupportedNetworks - - - - payment/unzer_applepay/sort_order - -
-
diff --git a/etc/adminhtml/system/bank_transfer.xml b/etc/adminhtml/system/bank_transfer.xml deleted file mode 100644 index 4d5d8ba..0000000 --- a/etc/adminhtml/system/bank_transfer.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_bank_transfer/active - - - - payment/unzer_bank_transfer/title - - - - payment/unzer_bank_transfer/min_order_total - - - - payment/unzer_bank_transfer/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_bank_transfer/sort_order - - - diff --git a/etc/adminhtml/system/credit_card.xml b/etc/adminhtml/system/credit_card.xml index 1f6a227..a0275e5 100644 --- a/etc/adminhtml/system/credit_card.xml +++ b/etc/adminhtml/system/credit_card.xml @@ -52,5 +52,11 @@ 1 + + + Magento\Config\Model\Config\Source\Yesno + payment/unzer_cards/enable_click_to_pay +
diff --git a/etc/adminhtml/system/direct_debit_secured.xml b/etc/adminhtml/system/direct_debit_secured.xml deleted file mode 100644 index 2c26cb1..0000000 --- a/etc/adminhtml/system/direct_debit_secured.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_direct_debit_secured/active - - - - payment/unzer_direct_debit_secured/title - - - - Name of merchant for SEPA mandate. - payment/unzer_direct_debit_secured/merchant_name - required-entry - - 1 - - - - - payment/unzer_direct_debit_secured/min_order_total - - - - payment/unzer_direct_debit_secured/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_direct_debit_secured/sort_order - - - diff --git a/etc/adminhtml/system/giropay.xml b/etc/adminhtml/system/giropay.xml deleted file mode 100644 index 1b9bc58..0000000 --- a/etc/adminhtml/system/giropay.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_giropay/active - - - - payment/unzer_giropay/title - - - - payment/unzer_giropay/min_order_total - - - - payment/unzer_giropay/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_giropay/sort_order - - - diff --git a/etc/adminhtml/system/invoice.xml b/etc/adminhtml/system/invoice.xml deleted file mode 100644 index 5a08049..0000000 --- a/etc/adminhtml/system/invoice.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_invoice/active - - - - payment/unzer_invoice/title - - - - payment/unzer_invoice/min_order_total - - - - payment/unzer_invoice/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_invoice/sort_order - - - diff --git a/etc/adminhtml/system/invoice_secured.xml b/etc/adminhtml/system/invoice_secured.xml deleted file mode 100644 index 45cde8d..0000000 --- a/etc/adminhtml/system/invoice_secured.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_invoice_secured/active - - - - payment/unzer_invoice_secured/title - - - - payment/unzer_invoice_secured/min_order_total - - - - payment/unzer_invoice_secured/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_invoice_secured/sort_order - - - diff --git a/etc/adminhtml/system/invoice_secured_b2b.xml b/etc/adminhtml/system/invoice_secured_b2b.xml deleted file mode 100644 index 224221f..0000000 --- a/etc/adminhtml/system/invoice_secured_b2b.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Magento\Config\Model\Config\Source\Yesno - payment/unzer_invoice_secured_b2b/active - - - - payment/unzer_invoice_secured_b2b/title - - - - payment/unzer_invoice_secured_b2b/min_order_total - - - - payment/unzer_invoice_secured_b2b/max_order_total - Insert 0 to disable limit. - - - - payment/unzer_invoice_secured_b2b/sort_order - - - diff --git a/etc/adminhtml/system/sofort.xml b/etc/adminhtml/system/klarna.xml similarity index 75% rename from etc/adminhtml/system/sofort.xml rename to etc/adminhtml/system/klarna.xml index 84de9f3..4dfdc5e 100644 --- a/etc/adminhtml/system/sofort.xml +++ b/etc/adminhtml/system/klarna.xml @@ -1,34 +1,34 @@ - - + Magento\Config\Model\Config\Source\Yesno - payment/unzer_sofort/active + payment/unzer_klarna/active - payment/unzer_sofort/title + payment/unzer_klarna/title - payment/unzer_sofort/min_order_total + payment/unzer_klarna/min_order_total - payment/unzer_sofort/max_order_total + payment/unzer_klarna/max_order_total Insert 0 to disable limit. - payment/unzer_sofort/sort_order + payment/unzer_klarna/sort_order diff --git a/etc/config.xml b/etc/config.xml index 28ce7c0..2a97877 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -52,41 +52,9 @@ 0 1 0 + EUR Unzer\PAPI\Model\Method\DirectDebit - - 0 - authorize_capture - authorize_capture - <![CDATA[(Deprecated) SEPA Direct Debit Secured]]> - 0 - 0 - 0 - AT,CH,DE - 0 - 1 - 0 - 1 - 0 - Unzer\PAPI\Model\Method\DirectDebitSecured - - - 0 - order - authorize_capture - <![CDATA[Unzer Bank Transfer]]> - 0 - 0 - 0 - AT,DE - 0 - 1 - 1 - 1 - 1 - 0 - Unzer\PAPI\Model\Method\BankTransfer - 0 order @@ -96,6 +64,7 @@ 0 0 NL + EUR 0 1 1 @@ -103,53 +72,6 @@ 0 Unzer\PAPI\Model\Method\Ideal - - 0 - authorize_capture - authorize_capture - <![CDATA[(Deprecated) Unzer Invoice]]> - 0 - 0 - 0 - 0 - 0 - 1 - 0 - processing - Unzer\PAPI\Model\Method\Invoice - - - 0 - authorize_capture - authorize_capture - <![CDATA[(Deprecated) Unzer Invoice Secured]]> - 0 - 0 - 0 - AT,DE - 0 - 0 - 1 - 1 - processing - Unzer\PAPI\Model\Method\InvoiceSecured - - - 0 - authorize_capture - authorize_capture - <![CDATA[(Deprecated) Unzer Invoice Secured B2B]]> - 0 - 0 - 0 - AT,DE - 0 - 0 - 1 - 0 - processing - Unzer\PAPI\Model\Method\InvoiceSecuredB2b - 0 order @@ -159,6 +81,7 @@ 0 0 AT,DE,CH,NL + EUR, CHF 1 1 1 @@ -177,7 +100,8 @@ 0 0 0 - AT,DE,CH,NL + AT,DE,CH + EUR, CHF 1 1 1 @@ -197,6 +121,7 @@ 0 0 AT,DE,CH + EUR, CHF 1 1 1 @@ -216,6 +141,7 @@ 0 0 AT,DE + EUR 1 1 1 @@ -256,38 +182,6 @@ UnzerPaypalVault <![CDATA[Stored Paypal Account]]> - - 0 - order - authorize_capture - <![CDATA[Sofort]]> - 0 - 0 - 0 - 0 - 1 - 1 - 1 - 0 - AT,BE,CH,DE,ES,GB,IT,NL,PL - Unzer\PAPI\Model\Method\Sofort - - - 0 - order - authorize_capture - <![CDATA[(Deprecated) Giropay]]> - 0 - 0 - 0 - 0 - 1 - 1 - 0 - 0 - DE - Unzer\PAPI\Model\Method\Giropay - 0 order @@ -302,6 +196,7 @@ 1 0 AT + EUR Unzer\PAPI\Model\Method\EPS @@ -318,6 +213,7 @@ 1 0 DE,AT,BE,IT,ES,NL + AUD,CAD,CHF,CNY,EUR,GBP,HKD,NZD,SGD,USD Unzer\PAPI\Model\Method\Alipay @@ -334,6 +230,7 @@ 1 0 AT,BE,DK,FI,FR,DE,ES,GB,GR,HU,IE,IS,IT,LI,LU,MT,NL,NO,PT,SE + CHF,CNY,EUR,GBP,USD Unzer\PAPI\Model\Method\Wechatpay @@ -350,7 +247,7 @@ 1 0 PL - PLN + PLN,EUR Unzer\PAPI\Model\Method\Przelewy24 @@ -367,6 +264,7 @@ 1 0 BE + EUR Unzer\PAPI\Model\Method\Bancontact @@ -384,24 +282,9 @@ 1 0 1 + EUR Unzer\PAPI\Model\Method\Prepayment - - 0 - order - authorize_capture - <![CDATA[Apple Pay]]> - 0 - 0 - 0 - 1 - 1 - 1 - 1 - 1 - 0 - Unzer\PAPI\Model\Method\Applepay - 0 order @@ -466,7 +349,8 @@ 0 0 0 - AT,DE + DE + EUR 0 1 1 @@ -475,6 +359,23 @@ 0 Unzer\PAPI\Model\Method\OpenBanking + + 0 + order + authorize + <![CDATA[Klarna]]> + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + Unzer\PAPI\Model\Method\Klarna + diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml index bad29b1..5080909 100644 --- a/etc/csp_whitelist.xml +++ b/etc/csp_whitelist.xml @@ -1,7 +1,7 @@ - + - https://static.unzer.com @@ -10,58 +10,67 @@ https://code.jquery.com https://h.online-metrix.net https://h64.online-metrix.net + https://static-v2.unzer.com/v2/ui-components/ - - https://api.unzer.com https://api.heidelpay.com https://sbx-api.heidelpay.com https://sbx-api.unzer.com - - + https://payment.unzer.com https://payment.heidelpay.com https://sbx-payment.heidelpay.com https://sbx-payment.unzer.com - https://h.online-metrix.net https://h64.online-metrix.net - https://google.com/pay https://www.google.com/pay https://pay.google.com https://test-heidelpay.hpcgw.net/ https://sbx-api.heidelpay.com/ + + https://static-cc.test.unzer.com + https://static-v2.unzer.com/v2/ui-components/ + + + + + + https://sandbox.src.mastercard.com + https://static-v2.unzer.com/v2/ui-components/ - - https://payment.unzer.com https://payment.heidelpay.com https://sbx-payment.heidelpay.com https://sbx-payment.unzer.com - + https://static-cc.test.unzer.com + https://h.online-metrix.net - https://google.com/pay https://pay.google.com/ https://test-heidelpay.hpcgw.net/ https://sbx-api.heidelpay.com/ + + + https://sandbox.clicktopay.auth.visa.com + https://clicktopay.visa.com + https://sandbox.secure.checkout.visa.com + https://secure.checkout.visa.com - https://static.unzer.com @@ -69,7 +78,6 @@ - https://static.unzer.com @@ -78,4 +86,4 @@ - \ No newline at end of file + diff --git a/etc/di.xml b/etc/di.xml index 9b3f7a3..3a156cf 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -269,10 +269,18 @@ + + + UnzerDirectDebitConfig + + + UnzerDirectDebitValidatorCountry + UnzerDirectDebitValidatorCurrency @@ -288,110 +296,6 @@ - - - - Unzer\PAPI\Model\Config::METHOD_DIRECT_DEBIT_SECURED - - - - - - UnzerDirectDebitSecuredConfig - - - - - - - UnzerDirectDebitSecuredConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerDirectDebitSecuredConfig - - - - - - - UnzerDirectDebitSecuredValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_DIRECT_DEBIT_SECURED - Magento\Payment\Block\Form - Magento\Payment\Block\Info - UnzerDirectDebitSecuredValueHandlerPool - UnzerDirectDebitSecuredValidatorPool - UnzerCaptureCommandPool - - - - - - - Unzer\PAPI\Model\Config::METHOD_BANK_TRANSFER - - - - - - UnzerBankTransferConfig - - - - - - - UnzerBankTransferConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerBankTransferConfig - - - - - - - UnzerBankTransferValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_BANK_TRANSFER - Magento\Payment\Block\Form - Magento\Payment\Block\Info - UnzerBankTransferValueHandlerPool - UnzerBankTransferValidatorPool - UnzerCaptureCommandPool - - - @@ -424,10 +328,17 @@ + + + UnzerIdealConfig + + + UnzerIdealValidatorCountry + UnzerIdealValidatorCurrency @@ -443,165 +354,6 @@ - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE - - - - - - UnzerInvoiceConfig - - - - - - - UnzerInvoiceConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\InvoiceCaptureHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerInvoiceConfig - - - - - - - UnzerInvoiceValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE - Magento\Payment\Block\Form - Unzer\PAPI\Block\Info\Invoice - UnzerInvoiceValueHandlerPool - UnzerInvoiceValidatorPool - UnzerCaptureCommandPool - - - - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE_SECURED_B2B - - - - - - UnzerInvoiceSecuredB2bConfig - - - - - - - UnzerInvoiceSecuredB2bConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\InvoiceCaptureHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerInvoiceSecuredB2bConfig - - - - - - - UnzerInvoiceSecuredB2bValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE_SECURED_B2B - Magento\Payment\Block\Form - Unzer\PAPI\Block\Info\InvoiceSecuredB2b - UnzerInvoiceSecuredB2bValueHandlerPool - UnzerInvoiceSecuredB2bValidatorPool - UnzerCaptureCommandPool - - - - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE_SECURED - - - - - - UnzerInvoiceSecuredConfig - - - - - - - UnzerInvoiceSecuredConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\InvoiceCaptureHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerInvoiceSecuredConfig - - - - - - - UnzerInvoiceSecuredValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_INVOICE_SECURED - Unzer\PAPI\Block\Form\InvoiceSecured - Unzer\PAPI\Block\Info\InvoiceSecured - UnzerInvoiceSecuredValueHandlerPool - UnzerInvoiceSecuredValidatorPool - UnzerCaptureCommandPool - - - @@ -651,10 +403,18 @@ + + + UnzerPaylaterInvoiceConfig + + + UnzerPaylaterInvoiceValidatorCountry + UnzerPaylaterInvoiceValidatorCurrency @@ -704,10 +464,18 @@ + + + UnzerPaylaterInvoiceB2bConfig + + + UnzerPaylaterInvoiceB2bValidatorCountry + UnzerPaylaterInvoiceB2bValidatorCurrency @@ -757,10 +525,18 @@ + + + UnzerPaylaterInstallmentConfig + + + UnzerPaylaterInstallmentValidatorCountry + UnzerPaylaterInstallmentValidatorCurrency @@ -811,10 +587,18 @@ + + + UnzerPaylaterDirectDebitConfig + + + UnzerPaylaterDirectDebitValidatorCountry + UnzerPaylaterDirectDebitValidatorCurrency @@ -916,108 +700,6 @@ - - - - Unzer\PAPI\Model\Config::METHOD_SOFORT - - - - - - UnzerSofortConfig - - - - - - - UnzerSofortConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerSofortConfig - - - - - - - UnzerSofortValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_SOFORT - Magento\Payment\Block\Form - Magento\Payment\Block\Info - UnzerSofortValueHandlerPool - UnzerSofortValidatorPool - UnzerCaptureCommandPool - - - - - - - Unzer\PAPI\Model\Config::METHOD_GIROPAY - - - - - - UnzerGiropayConfig - - - - - - - UnzerGiropayConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerGiropayConfig - - - - - - - UnzerGiropayValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_GIROPAY - Magento\Payment\Block\Form - Magento\Payment\Block\Info - UnzerGiropayValueHandlerPool - UnzerGiropayValidatorPool - UnzerCaptureCommandPool - - - @@ -1050,10 +732,17 @@ + + + UnzerEPSConfig + + + UnzerEPSValidatorCountry + UnzerEPSValidatorCurrency @@ -1101,10 +790,17 @@ + + + UnzerAlipayConfig + + + UnzerAlipayValidatorCountry + UnzerAlipayValidatorCurrency @@ -1152,10 +848,17 @@ + + + UnzerWechatpayConfig + + + UnzerWechatpayValidatorCountry + UnzerWechatpayValidatorCurrency @@ -1261,10 +964,17 @@ + + + UnzerBancontactConfig + + + UnzerBancontactValidatorCountry + UnzerBancontactValidatorCurrency @@ -1312,10 +1022,18 @@ + + + + UnzerEPSConfig + + + UnzerPrepaymentValidatorCountry + UnzerPrepaymentValidatorCurrency @@ -1330,56 +1048,6 @@ UnzerCaptureCommandPool - - - - Unzer\PAPI\Model\Config::METHOD_APPLEPAY - - - - - - UnzerApplepayConfig - - - - - - - UnzerApplepayConfigValueHandler - Unzer\PAPI\Model\Config\CanCancelHandler - Unzer\PAPI\Model\Config\CanRefundHandler - Unzer\PAPI\Model\Config\CanRefundHandler - - Unzer\PAPI\Model\Config\CanVoidHandler - - - - - - - UnzerApplepayConfig - - - - - - - UnzerApplepayValidatorCountry - - - - - - - Unzer\PAPI\Model\Config::METHOD_APPLEPAY - Magento\Payment\Block\Form - Magento\Payment\Block\Info - UnzerApplepayValueHandlerPool - UnzerApplepayValidatorPool - UnzerAuthorizeAndCaptureCommandPool - - @@ -1570,12 +1238,20 @@ UnzerOpenBankingConfig + + + + + + UnzerOpenBankingConfig + UnzerOpenBankingValidatorCountry + UnzerOpenBankingValidatorCurrency @@ -1590,4 +1266,73 @@ UnzerCaptureCommandPool + + + + + Unzer\PAPI\Model\Config::METHOD_KLARNA + + + + + + UnzerKlarnaConfig + + + + + + + UnzerKlarnaConfigValueHandler + Unzer\PAPI\Model\Config\CanCancelHandler + Unzer\PAPI\Model\Config\CanRefundHandler + Unzer\PAPI\Model\Config\CanRefundHandler + + Unzer\PAPI\Model\Config\CanVoidHandler + + + + + + + UnzerKlarnaConfig + + + + + + + UnzerKlarnaValidatorCountry + + + + + + + + Unzer\PAPI\Model\Command\Authorize + Unzer\PAPI\Model\Command\CancelAuthorization + Unzer\PAPI\Model\Command\Capture + Unzer\PAPI\Model\Command\Order + Unzer\PAPI\Model\Command\RefundCharge + Unzer\PAPI\Model\Command\RefundCharge + Unzer\PAPI\Model\Command\CancelAuthorization + Unzer\PAPI\Model\Command\Authorize + Unzer\PAPI\Model\Command\Capture + Unzer\PAPI\Model\Command\Capture + + + + + + + + Unzer\PAPI\Model\Config::METHOD_KLARNA + Magento\Payment\Block\Form + Magento\Payment\Block\Info + UnzerKlarnaValueHandlerPool + UnzerKlarnaValidatorPool + UnzerAuthorizeAndCaptureKlarnaCommandPool + + diff --git a/etc/events.xml b/etc/events.xml index 44c24de..1454606 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -6,24 +6,9 @@ - - - - - - - - - - - - - - - @@ -39,12 +24,6 @@ - - - - - - @@ -63,9 +42,6 @@ - - - @@ -78,4 +54,7 @@ + + + diff --git a/etc/module.xml b/etc/module.xml index eb9c82b..d3dce32 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ - + diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index 5813e91..ad0180c 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -2,20 +2,13 @@ "UNZER_MAIN","Einstellungen" "UNZER_CARDS","Kreditkarte / Debitkarte" "UNZER_DIRECT_DEBIT","SEPA Lastschrift" -"UNZER_DIRECT_DEBIT_SECURED","(Veraltet) SEPA Lastschrift Gesichert" "UNZER_EPS","EPS" -"UNZER_GIROPAY","(Veraltet) Giropay" -"UNZER_BANK_TRANSFER","Unzer Direktüberweisung" "UNZER_IDEAL","iDEAL" -"UNZER_INVOICE","(Veraltet) Unzer Rechnungskauf" -"UNZER_INVOICE_SECURED","(Veraltet) Unzer Rechnungskauf Gesichert (B2C)" -"UNZER_INVOICE_SECURED_B2B","(Veraltet) Unzer Rechnungskauf Gesichert (B2B)" "UNZER_PAYLATER_INVOICE","Rechnungskauf (B2C)" "UNZER_PAYLATER_INVOICE_B2B","Rechnungskauf (B2B)" "UNZER_PAYLATER_INSTALLMENT","Ratenkauf" "UNZER_PAYLATER_DIRECT_DEBIT","Lastschrift" "UNZER_PAYPAL","PayPal" -"UNZER_SOFORT","Sofort" "UNZER_INFO_LABEL","Allgemeine Information" "UNZER_ALIPAY","Alipay" "UNZER_WECHATPAY","WeChat Pay" @@ -23,11 +16,11 @@ "UNZER_BANCONTACT","Bancontact" "UNZER_PREPAYMENT","Unzer Prepayment" "UNZER_ABOUT_US","Unzer ist eine innovative und modulare Plattform für den internationalen Zahlungsverkehr. Unternehmen aller Größen und Branchen vertrauen auf die datengetriebenen, sicheren und passgenauen Lösungen für mehr Wachstum – online, mobil oder am Point of Sale. Die einfach integrierbaren Module decken das gesamte Spektrum des Zahlungsmanagements ab: Von der Abwicklung verschiedener Zahlungsarten über automatisierte Analysen von Kundenverhalten und -bedürfnissen bis hin zum ganzheitlichen Risikomanagement.

Mehr Informationen finden Sie auf www.unzer.com" -"UNZER_APPLEPAY","(Deprecated) Apple Pay" "UNZER_APPLEPAYV2","Apple Pay" "UNZER_GOOGLEPAY","Google Pay" "UNZER_TWINT","TWINT" "UNZER_OPEN_BANKING","Unzer Direktüberweisung" +"UNZER_KLARNA","Klarna" "MODULE_VERSION_LABEL","Modul-Version:" "ABOUT_UNZER_LABEL","Über Unzer:" @@ -50,27 +43,19 @@ "Credit Card / Debit Card","Kreditkarte / Debitkarte" "Credit Card / Debit Card, ","Kreditkarte / Debitkarte, " "SEPA Direct Debit","SEPA Lastschrift" -"(Deprecated) SEPA Direct Debit Secured","(Veraltet) SEPA Lastschrift Gesichert" "EPS","EPS" -"(Deprecated) Giropay","(Veraltet) Giropay" "iDEAL","iDEAL" -"(Deprecated) Unzer Invoice Secured B2B","(Veraltet) Rechnungskauf Gesichert B2B" -"(Deprecated) Unzer Invoice Secured","(Veraltet) Rechnungskauf Gesichert" -"(Deprecated) Unzer Invoice","(Veraltet) Rechnungskauf" "Paylater Invoice","Rechnungskauf" "Paylater Invoice B2B","Rechnungskauf B2B" "Unzer Installment","Ratenkauf" "Direct Debit","Lastschrift" "PayPal","PayPal" "PayPal Account","PayPal Konto" -"Sofort","Sofort" -"Unzer Bank Transfer","Unzer Direktüberweisung" "Alipay","Alipay" "WeChat Pay","WeChat Pay" "Przelewy24","Przelewy24" "Bancontact","Bancontact" "Unzer Prepayment","Unzer Vorkasse" -"ApplePay","ApplePay" "GooglePay","GooglePay" "TWINT","TWINT" @@ -101,3 +86,10 @@ "There will be no notification if the payment has been aborted.","Sollte die Zahlung abgebrochen worden sein, erfolgt keine weitere Mitteilung." "Please contact us for further information.","Bitte kontaktieren Sie uns für weitere Informationen." "Unknown Email Address","Unbekannte Email Adresse" + +"Company type","Art des Unternehmens" +"Other","Sonstige" +"Authority","Behörde" +"Association","Gesellschaft" +"Sole","Einzelunternehmen", +"Company","Firma" diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 3adacf2..30b4d4e 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -2,20 +2,13 @@ "UNZER_MAIN","Settings" "UNZER_CARDS","Credit Card / Debit Card" "UNZER_DIRECT_DEBIT","SEPA Direct Debit" -"UNZER_DIRECT_DEBIT_SECURED","(Deprecated) SEPA Direct Debit Secured" "UNZER_EPS","EPS" -"UNZER_GIROPAY","(Deprecated) Giropay" -"UNZER_BANK_TRANSFER","Unzer Bank Transfer" "UNZER_IDEAL","iDEAL" -"UNZER_INVOICE","(Deprecated) Unzer Invoice" -"UNZER_INVOICE_SECURED","(Deprecated) Unzer Invoice secured (B2C)" -"UNZER_INVOICE_SECURED_B2B","(Deprecated) Unzer Invoice secured (B2B)" "UNZER_PAYLATER_INVOICE","Invoice (B2C)" "UNZER_PAYLATER_INVOICE_B2B","Invoice (B2B)" "UNZER_PAYLATER_INSTALLMENT","Installment" "UNZER_PAYLATER_DIRECT_DEBIT","Direct Debit" "UNZER_PAYPAL","PayPal" -"UNZER_SOFORT","SOFORT" "UNZER_INFO_LABEL","General Information" "UNZER_ALIPAY","Alipay" "UNZER_WECHATPAY","WeChat Pay" @@ -23,11 +16,11 @@ "UNZER_BANCONTACT","Bancontact" "UNZER_PREPAYMENT","Unzer Prepayment" "UNZER_ABOUT_US","Unzer is an innovative and modular platform for international payment transactions. Companies of all sizes and from all sectors rely on the data-driven, secure and perfectly tailored solutions to help them drive growth – whether online, mobile or at the point of sale. The modules, which are easy to integrate, cover the entire spectrum of payment management: from processing of various payment types, through automated analytics of customer behaviour and requirements, all the way up to integrative risk management.

For more information please visit www.unzer.com" -"UNZER_APPLEPAY","(Deprecated) Apple Pay" "UNZER_APPLEPAYV2","Apple Pay" "UNZER_GOOGLEPAY","Google Pay" "UNZER_TWINT","TWINT" "UNZER_OPEN_BANKING","Direct Bank Transfer" +"UNZER_KLARNA","Klarna" "MODULE_VERSION_LABEL","Module version:" "ABOUT_UNZER_LABEL","About Unzer:" @@ -50,27 +43,19 @@ "Credit Card / Debit Card","Credit Card / Debit Card" "Credit Card / Debit Card, ","Credit Card / Debit Card, " "SEPA Direct Debit","SEPA Direct Debit" -"(Deprecated) SEPA Direct Debit Secured","(Deprecated) SEPA Direct Debit Secured" -"Unzer Bank Transfer","Unzer Bank Transfer" "iDEAL","iDEAL" -"(Deprecated) Unzer Invoice Secured B2B","(Deprecated) Invoice Secured B2B" -"(Deprecated) Unzer Invoice Secured","(Deprecated) Invoice Secured" -"(Deprecated) Unzer Invoice","(Deprecated) Invoice" "Paylater Invoice","Invoice" "Paylater Invoice B2B","Invoice B2B" "Unzer Installment","Installment" "Direct Debit","Direct Debit" "PayPal","PayPal" "PayPal Account","PayPal Account" -"Sofort","Sofort" -"(Deprecated) Giropay","(Veraltet) Giropay" "EPS","EPS" "Alipay","Alipay" "WeChat Pay","WeChat Pay" "Przelewy24","Przelewy24" "Bancontact","Bancontact" "Unzer Prepayment","Unzer Prepayment" -"ApplePay","ApplePay" "GooglePay","GooglePay" "TWINT","TWINT" @@ -101,3 +86,10 @@ "There will be no notification if the payment has been aborted. Please contact us for further information.","There will be no notification if the payment has been aborted." "Please contact us for further information.","Please contact us for further information." "Unknown Email Address","Unknown Email Address" + +"Company type","Company type" +"Other","Other" +"Authority","Authority" +"Association","Association" +"Sole","Sole", +"Company","Company" diff --git a/view/adminhtml/layout/sales_order_create_index.xml b/view/adminhtml/layout/sales_order_create_index.xml index 5e0c620..f0332a6 100644 --- a/view/adminhtml/layout/sales_order_create_index.xml +++ b/view/adminhtml/layout/sales_order_create_index.xml @@ -3,8 +3,6 @@ - unzer_invoice_secured - Unzer_PAPI::form/invoice_secured.phtml diff --git a/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml b/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml index 79f477d..d385fe4 100644 --- a/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml +++ b/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml @@ -3,8 +3,6 @@ - unzer_invoice_secured - Unzer_PAPI::form/invoice_secured.phtml diff --git a/view/adminhtml/templates/form/invoice_secured.phtml b/view/adminhtml/templates/form/invoice_secured.phtml deleted file mode 100644 index 9d18733..0000000 --- a/view/adminhtml/templates/form/invoice_secured.phtml +++ /dev/null @@ -1,115 +0,0 @@ -escapeHtml($block->getMethodCode()); -$birthDateDay = $block->getBirthDate()->getDay(); -$birthDateMonth = $block->getBirthDate()->getMonth(); -$birthDateYear = $block->getBirthDate()->getYear(); -$salutation = $block->getInfoData('salutation'); -?> -
-
- -
- -
-
- -
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-renderStyleAsTag( - "display:none", - 'fieldset#payment_form_' . /* @noEscape */ $code); -} -?> diff --git a/view/adminhtml/templates/info/invoice_secured.phtml b/view/adminhtml/templates/info/invoice_secured.phtml deleted file mode 100644 index 97d334a..0000000 --- a/view/adminhtml/templates/info/invoice_secured.phtml +++ /dev/null @@ -1,54 +0,0 @@ - -
- escapeHtml($block->getMethod()->getTitle()); ?> -
-hasAccountData()): ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - getCustomerBirthdate()): ?> - - - - - -
- escapeHtml(__('Unzer Payment Information')); ?> -
escapeHtml(__('Account Holder')); ?>:escapeHtml($block->getAccountHolder()); ?>
escapeHtml(__('IBAN')); ?>:escapeHtml($block->getAccountIban()); ?>
escapeHtml(__('BIC')); ?>:escapeHtml($block->getAccountBic()); ?>
escapeHtml(__('Reference')); ?>:escapeHtml($block->getReference()); ?>
- escapeHtml(__('Customer Information')); ?> -
escapeHtml(__('Salutation')); ?>:escapeHtml(__($block->getCustomerSalutation())); ?>
escapeHtml(__('Birthdate')); ?>:escapeHtml($block->getCustomerBirthdate()); ?>
- diff --git a/view/adminhtml/templates/info/invoice_secured_b2b.phtml b/view/adminhtml/templates/info/invoice_secured_b2b.phtml deleted file mode 100644 index 902b3de..0000000 --- a/view/adminhtml/templates/info/invoice_secured_b2b.phtml +++ /dev/null @@ -1,54 +0,0 @@ - -
- escapeHtml($block->getMethod()->getTitle()); ?> -
-hasAccountData()): ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - getCustomerBirthdate()): ?> - - - - - -
- escapeHtml(__('Unzer Payment Information')); ?> -
escapeHtml(__('Account Holder')); ?>:escapeHtml($block->getAccountHolder()); ?>
escapeHtml(__('IBAN')); ?>:escapeHtml($block->getAccountIban()); ?>
escapeHtml(__('BIC')); ?>:escapeHtml($block->getAccountBic()); ?>
escapeHtml(__('Reference')); ?>:escapeHtml($block->getReference()); ?>
- escapeHtml(__('Customer Information')); ?> -
escapeHtml(__('Salutation')); ?>:escapeHtml(__($block->getCustomerSalutation())); ?>
escapeHtml(__('Birthdate')); ?>:escapeHtml($block->getCustomerBirthdate()); ?>
- diff --git a/view/adminhtml/templates/info/pdf/invoice_secured.phtml b/view/adminhtml/templates/info/pdf/invoice_secured.phtml deleted file mode 100644 index 3a40305..0000000 --- a/view/adminhtml/templates/info/pdf/invoice_secured.phtml +++ /dev/null @@ -1,31 +0,0 @@ - -escapeHtml($block->getMethod()->getTitle()); ?> - -hasAccountData()): ?> - {{pdf_row_separator}} - escapeHtml(__('Account Holder')); ?> - - escapeHtml($block->getAccountHolder()) ?> - {{pdf_row_separator}} - escapeHtml(__('IBAN')); ?> - - escapeHtml($block->getAccountIban()) ?> - {{pdf_row_separator}} - escapeHtml(__('BIC')); ?> - - escapeHtml($block->getAccountBic()) ?> - {{pdf_row_separator}} - escapeHtml(__('Reference')); ?> - - escapeHtml($block->getReference()) ?> - diff --git a/view/adminhtml/templates/info/pdf/invoice_secured_b2b.phtml b/view/adminhtml/templates/info/pdf/invoice_secured_b2b.phtml deleted file mode 100644 index f93f5e1..0000000 --- a/view/adminhtml/templates/info/pdf/invoice_secured_b2b.phtml +++ /dev/null @@ -1,31 +0,0 @@ - -escapeHtml($block->getMethod()->getTitle()); ?> - -hasAccountData()): ?> - {{pdf_row_separator}} - escapeHtml(__('Account Holder')); ?> - - escapeHtml($block->getAccountHolder()) ?> - {{pdf_row_separator}} - escapeHtml(__('IBAN')); ?> - - escapeHtml($block->getAccountIban()) ?> - {{pdf_row_separator}} - escapeHtml(__('BIC')); ?> - - escapeHtml($block->getAccountBic()) ?> - {{pdf_row_separator}} - escapeHtml(__('Reference')); ?> - - escapeHtml($block->getReference()) ?> - diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 047fdfb..0bbb05b 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -32,24 +32,9 @@ true - - true - - - true - true - - true - - - true - - - true - true @@ -68,12 +53,6 @@ true - - true - - - true - true @@ -92,9 +71,6 @@ true - - true - true @@ -107,6 +83,9 @@ true + + true + diff --git a/view/frontend/templates/info/invoice_secured.phtml b/view/frontend/templates/info/invoice_secured.phtml deleted file mode 100644 index 70a326f..0000000 --- a/view/frontend/templates/info/invoice_secured.phtml +++ /dev/null @@ -1,21 +0,0 @@ - -
-
escapeHtml($block->getMethod()->getTitle()) ?>
- getMethod()->getAdditionalPaymentInformation($this->getOrder()); ?> - -
- escapeHtml(__('Payment information')) ?>
- -
- -
diff --git a/view/frontend/templates/info/invoice_secured_b2b.phtml b/view/frontend/templates/info/invoice_secured_b2b.phtml deleted file mode 100644 index 30e5703..0000000 --- a/view/frontend/templates/info/invoice_secured_b2b.phtml +++ /dev/null @@ -1,21 +0,0 @@ - -
-
escapeHtml($block->getMethod()->getTitle()) ?>
- getMethod()->getAdditionalPaymentInformation($this->getOrder()); ?> - -
- escapeHtml(__('Payment information')) ?>
- -
- -
diff --git a/view/frontend/web/css/unzer.css b/view/frontend/web/css/unzer.css index 9d589ca..86a10e6 100644 --- a/view/frontend/web/css/unzer.css +++ b/view/frontend/web/css/unzer.css @@ -5330,3 +5330,16 @@ i.h-iconideal-van-lanschot:before { .unzerChoices[data-type*=select-multiple] .unzerChoices__input.is-hidden, .unzerChoices[data-type*=select-one] .unzerChoices__input.is-hidden, .unzerChoices__input.is-hidden { display: none } + +.unzerPlaceOrderPadding { + margin: 12px; +} + +.unzerCompanyTypeSelect { + margin-bottom: 15px; +} + +.apple-pay-button { + width: 240px; + height: 40px; +} \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index 6fea36f..4986f49 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -17,30 +17,10 @@ define( type: 'unzer_direct_debit', component: 'Unzer_PAPI/js/view/payment/method-renderer/direct_debit' }, - { - type: 'unzer_direct_debit_secured', - component: 'Unzer_PAPI/js/view/payment/method-renderer/direct_debit_secured' - }, - { - type: 'unzer_bank_transfer', - component: 'Unzer_PAPI/js/view/payment/method-renderer/bank_transfer' - }, { type: 'unzer_ideal', component: 'Unzer_PAPI/js/view/payment/method-renderer/ideal' }, - { - type: 'unzer_invoice', - component: 'Unzer_PAPI/js/view/payment/method-renderer/invoice' - }, - { - type: 'unzer_invoice_secured', - component: 'Unzer_PAPI/js/view/payment/method-renderer/invoice_secured' - }, - { - type: 'unzer_invoice_secured_b2b', - component: 'Unzer_PAPI/js/view/payment/method-renderer/invoice_secured_b2b' - }, { type: 'unzer_paylater_invoice', component: 'Unzer_PAPI/js/view/payment/method-renderer/paylater_invoice' @@ -61,14 +41,6 @@ define( type: 'unzer_paypal', component: 'Unzer_PAPI/js/view/payment/method-renderer/paypal' }, - { - type: 'unzer_sofort', - component: 'Unzer_PAPI/js/view/payment/method-renderer/sofort' - }, - { - type: 'unzer_giropay', - component: 'Unzer_PAPI/js/view/payment/method-renderer/giropay' - }, { type: 'unzer_eps', component: 'Unzer_PAPI/js/view/payment/method-renderer/eps' @@ -93,10 +65,6 @@ define( type: 'unzer_prepayment', component: 'Unzer_PAPI/js/view/payment/method-renderer/prepayment' }, - { - type: 'unzer_applepay', - component: 'Unzer_PAPI/js/view/payment/method-renderer/applepay' - }, { type: 'unzer_applepayv2', component: 'Unzer_PAPI/js/view/payment/method-renderer/applepayv2' @@ -112,6 +80,10 @@ define( { type: 'unzer_open_banking', component: 'Unzer_PAPI/js/view/payment/method-renderer/open_banking' + }, + { + type: 'unzer_klarna', + component: 'Unzer_PAPI/js/view/payment/method-renderer/klarna' } ); return Component.extend({}); diff --git a/view/frontend/web/js/view/payment/method-renderer/alipay.js b/view/frontend/web/js/view/payment/method-renderer/alipay.js index 1ba9eb2..2b6f7e4 100644 --- a/view/frontend/web/js/view/payment/method-renderer/alipay.js +++ b/view/frontend/web/js/view/payment/method-renderer/alipay.js @@ -1,18 +1,17 @@ define( [ - 'Unzer_PAPI/js/view/payment/method-renderer/base' + 'Unzer_PAPI/js/view/payment/method-renderer/basev2' ], - function (Component) { + function ( + Component + ) { 'use strict'; return Component.extend({ defaults: { - template: 'Unzer_PAPI/payment/alipay' - }, - - initializeForm: function () { - this.resourceProvider = this.sdk.Alipay(); - }, + template: 'Unzer_PAPI/payment/alipay', + paymentCode: 'unzer-alipay', + } }); } ); diff --git a/view/frontend/web/js/view/payment/method-renderer/applepay.js b/view/frontend/web/js/view/payment/method-renderer/applepay.js deleted file mode 100644 index 5906181..0000000 --- a/view/frontend/web/js/view/payment/method-renderer/applepay.js +++ /dev/null @@ -1,108 +0,0 @@ -define( - [ - 'jquery', - 'Unzer_PAPI/js/view/payment/method-renderer/base', - 'Magento_Checkout/js/model/quote', - '//applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js' - ], - function ($, Component, quote) { - 'use strict'; - - return Component.extend({ - defaults: { - template: 'Unzer_PAPI/payment/applepay' - }, - - initializeForm: function () { - this.resourceProvider = this.sdk.ApplePay(); - }, - setupApplePaySession() { - this.startApplePaySession(this.resourceProvider) - }, - - startApplePaySession: function (resourceProvider) { - var self = this; - //console.log(window.checkoutConfig.quoteData); - window.checkoutConfig.quoteData.trigger_reload = new Date().getTime(); - let applePayPaymentRequest = { - countryCode: quote.billingAddress().countryId, - currencyCode: window.checkoutConfig.quoteData.quote_currency_code, - totalLabel: window.checkoutConfig.payment.unzer_applepay.label, //display_name - totalAmount: Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2), - supportedNetworks: window.checkoutConfig.payment.unzer_applepay.supportedNetworks, - merchantCapabilities: window.checkoutConfig.payment.unzer_applepay.merchantCapabilities, - requiredShippingContactFields: [], - requiredBillingContactFields: [], - total: { - label: window.checkoutConfig.payment.unzer_applepay.label, - amount: Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2) - } - }; - - if (window.ApplePaySession && ApplePaySession.canMakePayments()) { - const session = new ApplePaySession(6, applePayPaymentRequest); - - session.onvalidatemerchant = function (event) { - self.merchantValidationCallback(session, event); - }; - - session.onpaymentauthorized = function (event) { - self.applePayAuthorizedCallback(resourceProvider, event, session); - }; - - session.onpaymentmethodselected = function (event) { - const update = { - "newTotal": { - "label": window.checkoutConfig.payment.unzer_applepay.label, - "type": "final", - "amount": Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2) - } - }; - session.completePaymentMethodSelection(update); - }; - - session.oncancel = function (event) { - - }; - - session.begin(); - - } else { - self.handleError("This device does not support Apple Pay!"); - } - }, - - handleError: function (message) { - jQuery('#unzer-applepay-error').html(message); - }, - - merchantValidationCallback: function (session, event) { - jQuery.post('/unzer/applepay/merchantvalidation', JSON.stringify({"merchantValidationUrl": event.validationURL,"storeId" : window.checkoutConfig.quoteData.store_id}), null, 'json') - .done(function (validationResponse) { - try { - session.completeMerchantValidation(validationResponse); - } catch (e) { - self.handleError(JSON.stringify(e.message)); - session.abort(); - } - - }) - .fail(function (error) { - self.handleError(JSON.stringify(error.statusText)); - session.abort(); - }); - }, - - applePayAuthorizedCallback: function (resourceProvider, event, session) { - var self = this; - // Get payment data from event. "event.payment" also contains contact information, if they were set via Apple Pay. - const paymentData = event.payment.token.paymentData; - session.completePayment({status: window.ApplePaySession.STATUS_SUCCESS}); - this.paymentData = paymentData; - - self.placeOrder(); - } - }); - }, -); - diff --git a/view/frontend/web/js/view/payment/method-renderer/applepayv2.js b/view/frontend/web/js/view/payment/method-renderer/applepayv2.js index 9fa841b..9d300cd 100644 --- a/view/frontend/web/js/view/payment/method-renderer/applepayv2.js +++ b/view/frontend/web/js/view/payment/method-renderer/applepayv2.js @@ -1,84 +1,127 @@ define( [ 'jquery', - 'Unzer_PAPI/js/view/payment/method-renderer/base', - 'Magento_Checkout/js/model/quote', - '//applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js' + 'ko', + 'mage/translate', + 'Magento_Ui/js/model/messageList', + 'Magento_Checkout/js/action/place-order', + 'Unzer_PAPI/js/view/payment/method-renderer/basev2', + 'Magento_Checkout/js/model/quote' ], - function ($, Component, quote) { + function ($, + ko, + $t, + globalMessageList, + placeOrderAction, + Component, + quote) { + 'use strict'; return Component.extend({ defaults: { - template: 'Unzer_PAPI/payment/applepayv2' + template: 'Unzer_PAPI/payment/applepayv2', + buttonNeeded: false, + paymentCode: 'unzer-apple-pay' }, - initialize: function () { - this._super(); - - return this; + isApplePayAvailable: function () { + return window.ApplePaySession && ApplePaySession.canMakePayments(); }, - initializeForm: function () { - const self = this; - if (!this.isApplePayAvailable()) { - this.handleError("This device does not support Apple Pay!"); + selectPaymentMethod: function () { + let retVal = this._super(); + + const componentContainer = $('#unzer-component-' + this.getCode()); + if(this.isApplePayAvailable()){ + componentContainer.addClass('apple-pay-button'); } - self.resourceProvider = this.sdk.ApplePay(); - }, - isApplePayAvailable: function () { - return window.ApplePaySession && ApplePaySession.canMakePayments(); - }, + this.waitForSetApplePayData(); + const unzerCheckoutElementId = 'unzer-checkout-' + this.getCode(); - startApplePaySession: function () { - let self = this; - window.checkoutConfig.quoteData.trigger_reload = new Date().getTime(); - - const supportedNetworks = window.checkoutConfig.payment.unzer_applepayv2.supportedNetworks.map((network) => network.toLowerCase()) - - const applePayPaymentRequest = { - countryCode: quote.billingAddress().countryId, - currencyCode: window.checkoutConfig.quoteData.quote_currency_code, - totalLabel: window.checkoutConfig.payment.unzer_applepayv2.label, //display_name - totalAmount: Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2), - supportedNetworks: supportedNetworks, - merchantCapabilities: window.checkoutConfig.payment.unzer_applepayv2.merchantCapabilities, - requiredShippingContactFields: [], - requiredBillingContactFields: [], - total: { - label: window.checkoutConfig.payment.unzer_applepayv2.label, - amount: Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2) - }, - }; - - const session = this.resourceProvider.initApplePaySession(applePayPaymentRequest, 6); - - session.onpaymentauthorized = function(event) { - const paymentData = event.payment.token.paymentData; - session.completePayment({status: window.ApplePaySession.STATUS_SUCCESS}); - self.paymentData = paymentData; - - self.placeOrder(); - }; - - session.onpaymentmethodselected = function(event) { - let update = { - newTotal: { - label: window.checkoutConfig.payment.unzer_applepayv2.label, - type: "final", - amount: Number(window.checkoutConfig.quoteData.base_grand_total).toFixed(2) + const unzerCheckout = document.getElementById(unzerCheckoutElementId); + unzerCheckout.onPaymentSubmit = response => { + if (response.submitResponse && response.submitResponse.success) { + this.resourceId = response.submitResponse.data.id; + const result = this.placeOrder(); + if (result) { + return {status: 'success'}; } - }; + } + + return {status: 'error', message: 'Unexpected error'} + + } + return retVal; + }, - session.completePaymentMethodSelection(update); - }; + waitForSetApplePayData: function (maxRetries = 10, interval = 500) { + const unzerPaymentElement = document.getElementById('unzer-payment-' + this.getCode()); - session.begin(); + if (unzerPaymentElement && typeof unzerPaymentElement.setApplePayData === 'function') { + const supportedNetworks = window.checkoutConfig.payment.unzer_applepayv2.supportedNetworks.map((network) => network.toLowerCase()); + + const totals = quote.totals() ? quote.totals() : window.checkoutConfig.quoteData; + + unzerPaymentElement.setApplePayData({ + countryCode: quote.billingAddress().countryId, + currencyCode: window.checkoutConfig.quoteData.base_currency_code, + totalLabel: window.checkoutConfig.payment.unzer_applepayv2.label, + totalAmount: Number(totals['base_grand_total']).toFixed(2), + supportedNetworks: supportedNetworks, + merchantCapabilities: window.checkoutConfig.payment.unzer_applepayv2.merchantCapabilities, + requiredShippingContactFields: [], + requiredBillingContactFields: [], + total: { + label: window.checkoutConfig.payment.unzer_applepayv2.label, + amount: Number(totals['base_grand_total']).toFixed(2), + }, + }); + } else if (maxRetries > 0) { + console.log('Waiting for setApplePayData function to be available...'); + setTimeout(() => this.waitForSetApplePayData(maxRetries - 1, interval), interval); + } else { + console.error('setApplePayData is not available after multiple retries.'); + } }, - handleError: function (message) { - $('#unzer-applepay-error').html(message); + getPlaceOrderDeferredObject: function () { + let deferred = $.Deferred(), + self = this; + + Promise.all([ + customElements.whenDefined(this.paymentCode) + ]).then(() => { + placeOrderAction(self.getData(), self.messageContainer) + .done(function () { + deferred.resolve.apply(deferred, arguments); + }) + .fail(function (request) { + if (request.responseJSON && request.responseJSON.message) { + globalMessageList.addErrorMessage({ + message: request.responseJSON.message + }); + deferred.reject(request.responseJSON.message); + } else { + globalMessageList.addErrorMessage({ + message: 'An unknown error occurred. Please try again.' + }); + deferred.reject('An unknown error occurred.'); + } + }); + }).catch(error => { + globalMessageList.addErrorMessage({ + message: 'There was an error placing your order. ' + error + }); + deferred.reject($t('There was an error placing your order. ' + error)); + }); + + return deferred.fail(function (error) { + globalMessageList.addErrorMessage({ + message: error + }); + }); }, }); }, diff --git a/view/frontend/web/js/view/payment/method-renderer/bancontact.js b/view/frontend/web/js/view/payment/method-renderer/bancontact.js index 264f45b..cf113a2 100644 --- a/view/frontend/web/js/view/payment/method-renderer/bancontact.js +++ b/view/frontend/web/js/view/payment/method-renderer/bancontact.js @@ -1,18 +1,17 @@ define( [ - 'Unzer_PAPI/js/view/payment/method-renderer/base' + 'Unzer_PAPI/js/view/payment/method-renderer/basev2' ], - function (Component) { + function ( + Component + ) { 'use strict'; return Component.extend({ defaults: { - template: 'Unzer_PAPI/payment/bancontact' - }, - - initializeForm: function () { - this.resourceProvider = this.sdk.Bancontact(); - }, + template: 'Unzer_PAPI/payment/bancontact', + paymentCode: 'unzer-bancontact', + } }); } ); diff --git a/view/frontend/web/js/view/payment/method-renderer/bank_transfer.js b/view/frontend/web/js/view/payment/method-renderer/bank_transfer.js deleted file mode 100644 index 3704ce3..0000000 --- a/view/frontend/web/js/view/payment/method-renderer/bank_transfer.js +++ /dev/null @@ -1,18 +0,0 @@ -define( - [ - 'Unzer_PAPI/js/view/payment/method-renderer/base' - ], - function (Component) { - 'use strict'; - - return Component.extend({ - defaults: { - template: 'Unzer_PAPI/payment/bank_transfer' - }, - - initializeForm: function () { - this.resourceProvider = this.sdk.FlexiPayDirect(); - }, - }); - } -); diff --git a/view/frontend/web/js/view/payment/method-renderer/basev2.js b/view/frontend/web/js/view/payment/method-renderer/basev2.js new file mode 100644 index 0000000..bc37c4c --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/basev2.js @@ -0,0 +1,350 @@ +define( + [ + 'jquery', + 'ko', + 'mage/storage', + 'mage/translate', + 'mage/url', + 'Unzer_PAPI/js/model/checkout/customer-loader', + 'Unzer_PAPI/js/model/checkout/terms-checked', + 'Magento_Checkout/js/action/place-order', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Ui/js/model/messageList', + 'Magento_Checkout/js/model/quote' + ], + function ( + $, + ko, + storage, + $t, + url, + customerLoader, + termsChecked, + placeOrderAction, + fullScreenLoader, + Component, + globalMessageList, + quote + ) { + 'use strict'; + + return Component.extend({ + redirectAfterPlaceOrder: false, + redirectUrl: 'unzer/payment/redirect', + allTermsChecked: termsChecked.allTermsChecked, + isThreatMetrixNeeded: false, + buttonNeeded: true, + paymentCode: null, + customersBirthDayNeeded: false, + customerType: null, + threatMetrixId: null, + lastGrandTotal: null, + + defaults: { + config: null, + customer: null, + customerProvider: null, + customerSubscription: null, + customerType: 'b2c', + customerValid: null, + resourceId: null, + resourceProvider: null, + template: null, + customersBirthDay: null, + threatMetrixId: null + }, + + initialize: function () { + this._super(); + import('//static-v2.unzer.com/v2/ui-components/index.js') + .then(module => { + }) + .catch(error => { + console.error('Failed to load Unzer scripts: ' + error) + }); + + let self = this; + // Subscribe to the selected payment method observable + quote.paymentMethod.subscribe(function (newPaymentMethod) { + if (!newPaymentMethod || newPaymentMethod.method !== self.getCode()) { + self.onUnselected(); + } + }); + + this.lastGrandTotal = quote.totals() && typeof quote.totals()['base_grand_total'] !== 'undefined' + ? quote.totals()['base_grand_total'] + : null; + + quote.totals.subscribe((newTotals) => { + if (quote.paymentMethod() && quote.paymentMethod().method === this.getCode()) { + let currentTotal = newTotals['base_grand_total']; + + if (this.lastGrandTotal !== currentTotal) { + this.lastGrandTotal = currentTotal; + + self.onUnselected(); + this.selectPaymentMethod(); + } + } + }); + + return this; + }, + + selectPaymentMethod: function () { + let retVal = this._super(); + + termsChecked.init(this); + + const componentContainer = $('#unzer-component-' + this.getCode()); + componentContainer.empty(); + const unzerPayment = this.createUnzerPaymentElement(); + const specificPaymentElement = this.createSpecificPaymentElement(); + unzerPayment.append(specificPaymentElement); + const unzerCheckout = this.createUnzerCheckoutPaymentElement(); + + componentContainer.append(unzerPayment); + componentContainer.append(unzerCheckout); + + if (this.customersBirthDayNeeded) { + this.waitForSetBasketData(); + } + + return retVal; + }, + + createUnzerPaymentElement: function () { + const unzerPaymentElementId = 'unzer-payment-' + this.getCode(); + + return $('') + .attr('id', unzerPaymentElementId) + .attr('publicKey', this.getPublicKey()) + .attr('locale', window.checkoutConfig.payment.unzer.locale); + }, + + createSpecificPaymentElement: function () { + if (!this.paymentCode) { + console.error("Payment code is null or undefined"); + + return null; + } + + return $(`<${this.paymentCode}>`); + }, + + createUnzerCheckoutPaymentElement: function () { + const unzerCheckoutId = 'unzer-checkout-' + this.getCode(); + const unzerCheckout = $('') + .attr('id', unzerCheckoutId); + + if (this.buttonNeeded) { + const unzerPayButtonId = 'unzer-pay-button-' + this.getCode(); + const payButton = $(' - - +
+
diff --git a/view/frontend/web/template/payment/applepay.html b/view/frontend/web/template/payment/applepay.html deleted file mode 100644 index cccde29..0000000 --- a/view/frontend/web/template/payment/applepay.html +++ /dev/null @@ -1,88 +0,0 @@ -
-
- - -
-
-
- - - -
-
-
-
- - -
- -
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/applepayv2.html b/view/frontend/web/template/payment/applepayv2.html index 6fe3045..9285e70 100644 --- a/view/frontend/web/template/payment/applepayv2.html +++ b/view/frontend/web/template/payment/applepayv2.html @@ -15,56 +15,9 @@
-
-
-
- - -
-
+
+
diff --git a/view/frontend/web/template/payment/bancontact.html b/view/frontend/web/template/payment/bancontact.html index a3c9b72..a12f7f6 100644 --- a/view/frontend/web/template/payment/bancontact.html +++ b/view/frontend/web/template/payment/bancontact.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/bank_transfer.html b/view/frontend/web/template/payment/bank_transfer.html deleted file mode 100644 index a3c9b72..0000000 --- a/view/frontend/web/template/payment/bank_transfer.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
- -
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/cards.html b/view/frontend/web/template/payment/cards.html index 86f753e..3278f60 100644 --- a/view/frontend/web/template/payment/cards.html +++ b/view/frontend/web/template/payment/cards.html @@ -16,48 +16,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
- -
-
- +
+
diff --git a/view/frontend/web/template/payment/direct_debit.html b/view/frontend/web/template/payment/direct_debit.html index 3060f22..7641688 100644 --- a/view/frontend/web/template/payment/direct_debit.html +++ b/view/frontend/web/template/payment/direct_debit.html @@ -16,24 +16,7 @@
-
-
-
- -
-
-

-
-
+
diff --git a/view/frontend/web/template/payment/direct_debit_secured.html b/view/frontend/web/template/payment/direct_debit_secured.html deleted file mode 100644 index ec3ab80..0000000 --- a/view/frontend/web/template/payment/direct_debit_secured.html +++ /dev/null @@ -1,45 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
-
-
-
- -
-
-

-
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/eps.html b/view/frontend/web/template/payment/eps.html index a3c9b72..8a50cc0 100644 --- a/view/frontend/web/template/payment/eps.html +++ b/view/frontend/web/template/payment/eps.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/googlepay.html b/view/frontend/web/template/payment/googlepay.html index 4b44ff0..37d99ee 100644 --- a/view/frontend/web/template/payment/googlepay.html +++ b/view/frontend/web/template/payment/googlepay.html @@ -16,10 +16,8 @@
-
-
-
-
+
+
diff --git a/view/frontend/web/template/payment/ideal.html b/view/frontend/web/template/payment/ideal.html index 1d2b668..98d628d 100644 --- a/view/frontend/web/template/payment/ideal.html +++ b/view/frontend/web/template/payment/ideal.html @@ -16,21 +16,8 @@
-
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/invoice.html b/view/frontend/web/template/payment/invoice.html deleted file mode 100644 index a3c9b72..0000000 --- a/view/frontend/web/template/payment/invoice.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
- -
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/invoice_secured.html b/view/frontend/web/template/payment/invoice_secured.html deleted file mode 100644 index d805e9d..0000000 --- a/view/frontend/web/template/payment/invoice_secured.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
-
-
- -
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/invoice_secured_b2b.html b/view/frontend/web/template/payment/invoice_secured_b2b.html deleted file mode 100644 index 7736e48..0000000 --- a/view/frontend/web/template/payment/invoice_secured_b2b.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
-
-
- -
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/giropay.html b/view/frontend/web/template/payment/klarna.html similarity index 63% rename from view/frontend/web/template/payment/giropay.html rename to view/frontend/web/template/payment/klarna.html index a3c9b72..9b582a4 100644 --- a/view/frontend/web/template/payment/giropay.html +++ b/view/frontend/web/template/payment/klarna.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/open_banking.html b/view/frontend/web/template/payment/open_banking.html index 1378c8c..bf171ce 100644 --- a/view/frontend/web/template/payment/open_banking.html +++ b/view/frontend/web/template/payment/open_banking.html @@ -15,20 +15,8 @@
-
-
- -
-
+ +
diff --git a/view/frontend/web/template/payment/paylater_direct_debit.html b/view/frontend/web/template/payment/paylater_direct_debit.html index ba7ff30..a28c0db 100644 --- a/view/frontend/web/template/payment/paylater_direct_debit.html +++ b/view/frontend/web/template/payment/paylater_direct_debit.html @@ -16,23 +16,7 @@
-
-
-
-
-
- -
-
+
diff --git a/view/frontend/web/template/payment/paylater_installment.html b/view/frontend/web/template/payment/paylater_installment.html index 22fec12..06f5232 100644 --- a/view/frontend/web/template/payment/paylater_installment.html +++ b/view/frontend/web/template/payment/paylater_installment.html @@ -16,23 +16,8 @@
-
-
-
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/paylater_invoice.html b/view/frontend/web/template/payment/paylater_invoice.html index 9f1788a..525d823 100644 --- a/view/frontend/web/template/payment/paylater_invoice.html +++ b/view/frontend/web/template/payment/paylater_invoice.html @@ -16,22 +16,8 @@
-
-
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/paylater_invoice_b2b.html b/view/frontend/web/template/payment/paylater_invoice_b2b.html index 319ee7d..2177b0a 100644 --- a/view/frontend/web/template/payment/paylater_invoice_b2b.html +++ b/view/frontend/web/template/payment/paylater_invoice_b2b.html @@ -15,23 +15,19 @@
+
+ + +
+ +
-
-
-
-
- -
-
diff --git a/view/frontend/web/template/payment/paypal.html b/view/frontend/web/template/payment/paypal.html index 1d03504..d03f52f 100644 --- a/view/frontend/web/template/payment/paypal.html +++ b/view/frontend/web/template/payment/paypal.html @@ -16,33 +16,10 @@
-
- -
-
- - -
-
- -
- -
-
+
+
diff --git a/view/frontend/web/template/payment/prepayment.html b/view/frontend/web/template/payment/prepayment.html index a3c9b72..b0d213b 100644 --- a/view/frontend/web/template/payment/prepayment.html +++ b/view/frontend/web/template/payment/prepayment.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/przelewy24.html b/view/frontend/web/template/payment/przelewy24.html index a3c9b72..0cf276a 100644 --- a/view/frontend/web/template/payment/przelewy24.html +++ b/view/frontend/web/template/payment/przelewy24.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/sofort.html b/view/frontend/web/template/payment/sofort.html deleted file mode 100644 index a3c9b72..0000000 --- a/view/frontend/web/template/payment/sofort.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - -
-
-
- - - -
- -
-
- -
-
-
- - - -
-
-
diff --git a/view/frontend/web/template/payment/twint.html b/view/frontend/web/template/payment/twint.html index a3c9b72..8842b9f 100644 --- a/view/frontend/web/template/payment/twint.html +++ b/view/frontend/web/template/payment/twint.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+
diff --git a/view/frontend/web/template/payment/wechatpay.html b/view/frontend/web/template/payment/wechatpay.html index a3c9b72..168cf5b 100644 --- a/view/frontend/web/template/payment/wechatpay.html +++ b/view/frontend/web/template/payment/wechatpay.html @@ -16,20 +16,8 @@
-
-
- -
-
+
+