From 7cbc307619e7c76126db097addc696c81307dcaf Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Wed, 13 Dec 2023 15:46:22 +0200 Subject: [PATCH 01/17] BP-3281 Add additional Software header (#20) Co-authored-by: Ivascu Madalin --- Model/Magewire/Payment/PlaceOrderService.php | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Model/Magewire/Payment/PlaceOrderService.php b/Model/Magewire/Payment/PlaceOrderService.php index 253d43d..3f9d4fd 100644 --- a/Model/Magewire/Payment/PlaceOrderService.php +++ b/Model/Magewire/Payment/PlaceOrderService.php @@ -3,12 +3,14 @@ namespace Buckaroo\HyvaCheckout\Model\Magewire\Payment; use Magento\Quote\Model\Quote; +use Composer\InstalledVersions; use Magento\Framework\Registry; use Magento\Quote\Api\CartManagementInterface; use Hyva\Checkout\Model\Magewire\Payment\AbstractPlaceOrderService; class PlaceOrderService extends AbstractPlaceOrderService { + private const COMPOSER_MODULE_NAME = 'buckaroo/magento2-hyva-checkout'; protected Registry $registry; @@ -19,6 +21,18 @@ public function __construct( $this->registry = $registry; parent::__construct($cartManagement); } + + + + /** + * @throws CouldNotSaveException + */ + public function placeOrder(Quote $quote): int + { + $this->setPlatformInfo($quote); + return parent::placeOrder($quote); + } + /** * Redirect to buckaroo payment engine * @@ -49,4 +63,24 @@ private function hasRedirect(): bool $response = $this->getResponse(); return !empty($response->RequiredAction->RedirectURL); } + + /** + * Set platform info to send over + * + * @param Quote $quote + * + * @return void + */ + private function setPlatformInfo(Quote $quote) + { + $version = 'unknown'; + + if (InstalledVersions::isInstalled(self::COMPOSER_MODULE_NAME)) { + $version = InstalledVersions::getVersion(self::COMPOSER_MODULE_NAME); + } + $quote->getPayment()->setAdditionalInformation( + 'buckaroo_platform_info', + " / Hyva Checkout (".$version.")" + ); + } } From 4d8263c83d4376bfdad7f1ae9e39b8aa8441a558 Mon Sep 17 00:00:00 2001 From: Rene <105488705+Buckaroo-Rene@users.noreply.github.com> Date: Thu, 2 May 2024 09:31:06 +0200 Subject: [PATCH 02/17] Update composer.json to v1.1.2 (#24) Update composer.json to v1.1.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c465e14..3f0a56a 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "docs": "https://support.buckaroo.nl" }, "homepage": "https://www.buckaroo.nl", - "version" : "v1.1.1", + "version" : "v1.1.2", "minimum-stability": "stable", "autoload": { "files": [ From 03373667d8d57f29bbb5a0c5234619813a0093d6 Mon Sep 17 00:00:00 2001 From: "a.baraliu" Date: Thu, 4 Jul 2024 16:54:03 +0200 Subject: [PATCH 03/17] BP-3546-Use-object-as-array-in-Buckaroo-HyvaCheckout-Block-Totals-Fee-getTotal-22 --- Block/Totals/Fee.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php index d956592..574fbc2 100644 --- a/Block/Totals/Fee.php +++ b/Block/Totals/Fee.php @@ -12,18 +12,20 @@ class Fee extends \Magento\Framework\View\Element\Template { protected PaymentFee $feeHelper; - protected SessionCheckout $sessionCheckout; + protected SessionCheckout $sessionCheckout; public function __construct( - Context $context, - array $data, - PaymentFee $feeHelper, + Context $context, + array $data, + PaymentFee $feeHelper, SessionCheckout $sessionCheckout - ) { + ) + { parent::__construct($context, $data); $this->feeHelper = $feeHelper; $this->sessionCheckout = $sessionCheckout; } + /** * Get title based on payment method config * @@ -33,8 +35,8 @@ public function getTitle(): string { try { $payment = $this->sessionCheckout - ->getQuote() - ->getPayment(); + ->getQuote() + ->getPayment(); return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod()); } catch (\Throwable $th) { return __('Fee'); @@ -50,11 +52,11 @@ public function getTitle(): string public function getTotal(): float { $totalData = $this->getSegment(); + $extensionAttributes = $totalData['extension_attributes'] ?? null; if ( - isset($totalData['extension_attributes']['buckaroo_fee']) && - is_scalar($totalData['extension_attributes']['buckaroo_fee']) + $extensionAttributes ) { - return floatval($totalData['extension_attributes']['buckaroo_fee']); + return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0])); } return 0; } From b3f8499eb9e74874c509d202d2713b15158540dc Mon Sep 17 00:00:00 2001 From: "a.baraliu" Date: Fri, 5 Jul 2024 15:16:21 +0200 Subject: [PATCH 04/17] BP-3546-Use-object-as-array-in-Buckaroo-HyvaCheckout-Block-Totals-Fee-getTotal-22 --- Block/Totals/Fee.php | 63 ------------------- .../layout/hyva_checkout_components.xml | 7 +-- .../templates/total-segments/fee.phtml | 10 +-- 3 files changed, 9 insertions(+), 71 deletions(-) delete mode 100644 Block/Totals/Fee.php diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php deleted file mode 100644 index 574fbc2..0000000 --- a/Block/Totals/Fee.php +++ /dev/null @@ -1,63 +0,0 @@ -feeHelper = $feeHelper; - $this->sessionCheckout = $sessionCheckout; - } - - /** - * Get title based on payment method config - * - * @return string - */ - public function getTitle(): string - { - try { - $payment = $this->sessionCheckout - ->getQuote() - ->getPayment(); - return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod()); - } catch (\Throwable $th) { - return __('Fee'); - } - return __('Fee'); - } - - /** - * Get total from array of data - * - * @return float - */ - public function getTotal(): float - { - $totalData = $this->getSegment(); - $extensionAttributes = $totalData['extension_attributes'] ?? null; - if ( - $extensionAttributes - ) { - return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0])); - } - return 0; - } -} diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 69f5457..5cbb3a2 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -202,9 +202,8 @@ - - \ No newline at end of file + diff --git a/view/frontend/templates/total-segments/fee.phtml b/view/frontend/templates/total-segments/fee.phtml index 77923b8..7cf866d 100644 --- a/view/frontend/templates/total-segments/fee.phtml +++ b/view/frontend/templates/total-segments/fee.phtml @@ -14,14 +14,16 @@ use Hyva\Checkout\ViewModel\Checkout\Formatter as FormatterViewModel; use Hyva\Theme\Model\ViewModelRegistry; $formatterViewModel = $viewModels->require(FormatterViewModel::class); -$total = $block->getTotal(); -if ($total != 0) { +$total = $block->getSegment(); + +if ($total['value'] != 0) { + ?>
- escapeHtml($block->getTitle()) ?> + escapeHtml($total['title']) ?> - currency($total ?? 0) ?> + currency($total['value'] ?? 0) ?>
Date: Wed, 21 Aug 2024 17:05:48 +0200 Subject: [PATCH 05/17] Revert "BP-3546-Use-object-as-array-in-Buckaroo-HyvaCheckout-Block-Totals-Fee-getTotal-22" This reverts commit b3f8499eb9e74874c509d202d2713b15158540dc. --- Block/Totals/Fee.php | 63 +++++++++++++++++++ .../layout/hyva_checkout_components.xml | 7 ++- .../templates/total-segments/fee.phtml | 10 ++- 3 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 Block/Totals/Fee.php diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php new file mode 100644 index 0000000..574fbc2 --- /dev/null +++ b/Block/Totals/Fee.php @@ -0,0 +1,63 @@ +feeHelper = $feeHelper; + $this->sessionCheckout = $sessionCheckout; + } + + /** + * Get title based on payment method config + * + * @return string + */ + public function getTitle(): string + { + try { + $payment = $this->sessionCheckout + ->getQuote() + ->getPayment(); + return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod()); + } catch (\Throwable $th) { + return __('Fee'); + } + return __('Fee'); + } + + /** + * Get total from array of data + * + * @return float + */ + public function getTotal(): float + { + $totalData = $this->getSegment(); + $extensionAttributes = $totalData['extension_attributes'] ?? null; + if ( + $extensionAttributes + ) { + return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0])); + } + return 0; + } +} diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 5cbb3a2..69f5457 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -202,8 +202,9 @@ - - + \ No newline at end of file diff --git a/view/frontend/templates/total-segments/fee.phtml b/view/frontend/templates/total-segments/fee.phtml index 7cf866d..77923b8 100644 --- a/view/frontend/templates/total-segments/fee.phtml +++ b/view/frontend/templates/total-segments/fee.phtml @@ -14,16 +14,14 @@ use Hyva\Checkout\ViewModel\Checkout\Formatter as FormatterViewModel; use Hyva\Theme\Model\ViewModelRegistry; $formatterViewModel = $viewModels->require(FormatterViewModel::class); -$total = $block->getSegment(); - -if ($total['value'] != 0) { - +$total = $block->getTotal(); +if ($total != 0) { ?>
- escapeHtml($total['title']) ?> + escapeHtml($block->getTitle()) ?> - currency($total['value'] ?? 0) ?> + currency($total ?? 0) ?>
Date: Wed, 21 Aug 2024 17:07:06 +0200 Subject: [PATCH 06/17] fix Fee.php --- Block/Totals/Fee.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php index 574fbc2..ecdabb0 100644 --- a/Block/Totals/Fee.php +++ b/Block/Totals/Fee.php @@ -52,12 +52,27 @@ public function getTitle(): string public function getTotal(): float { $totalData = $this->getSegment(); - $extensionAttributes = $totalData['extension_attributes'] ?? null; + if (false === is_array($totalData)) { + throw new \UnexpectedValueException('Expecting an array but getting '.gettype($totalData)); + } + + $extensionAttributes = $totalData['extension_attributes']; + if ( - $extensionAttributes + is_array($extensionAttributes) && + isset($extensionAttributes['buckaroo_fee']) && + is_scalar($extensionAttributes['buckaroo_fee']) ) { - return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0])); + return floatval($extensionAttributes['buckaroo_fee']); } + + if ($extensionAttributes instanceof \Magento\Quote\Api\Data\TotalSegmentExtension) { + /** @var \Magento\Quote\Api\Data\TotalSegmentExtension $extensionAttributes */ + if ($extensionAttributes->getBuckarooFee() !== null) { + return $extensionAttributes->getBuckarooFee(); + } + } + return 0; } } From ecea229c22dcc18a5a1eb5c0b70292b35b757a16 Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Thu, 22 Aug 2024 13:56:19 +0200 Subject: [PATCH 07/17] remove logger from MethodMetaData __construct, add image for paybybank --- Model/MethodMetaData.php | 2 +- Plugin/MethodList.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Model/MethodMetaData.php b/Model/MethodMetaData.php index f4b8c6e..5583303 100644 --- a/Model/MethodMetaData.php +++ b/Model/MethodMetaData.php @@ -23,7 +23,7 @@ public function __construct( Repository $assetRepository, array $data = [] ) { - parent::__construct($iconRenderer, $subtitleRenderer, $logger, $method, $systemConfigPayment, $data); + parent::__construct($iconRenderer, $subtitleRenderer, $method, $systemConfigPayment, $data); $this->assetRepository = $assetRepository; } public function renderIcon(): string diff --git a/Plugin/MethodList.php b/Plugin/MethodList.php index 29992a6..89efd80 100644 --- a/Plugin/MethodList.php +++ b/Plugin/MethodList.php @@ -66,11 +66,12 @@ private function getSvgLogo(string $methodCode): string "emandate" => "emandate.png", "pospayment" => "pos.png", "transfer" => "svg/sepa-credittransfer.svg", - "voucher" => "svg/vouchers.svg" + "voucher" => "svg/vouchers.svg", + "paybybank" => "paybybank.gif", ]; $name = "svg/{$method}.svg"; - + if(isset($mappings[$method])) { $name = $mappings[$method]; } From 278b58c29e764c38e37aef538164220fd467ae7f Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Thu, 22 Aug 2024 16:25:12 +0200 Subject: [PATCH 08/17] remove MethodMetaData and replace with IconRenderer to show icons --- Model/MethodMetaData.php | 39 --------------------------------------- Plugin/IconRenderer.php | 32 ++++++++++++++++++++++++++++++++ Plugin/MethodList.php | 2 +- etc/di.xml | 4 ++++ 4 files changed, 37 insertions(+), 40 deletions(-) delete mode 100644 Model/MethodMetaData.php create mode 100644 Plugin/IconRenderer.php diff --git a/Model/MethodMetaData.php b/Model/MethodMetaData.php deleted file mode 100644 index 5583303..0000000 --- a/Model/MethodMetaData.php +++ /dev/null @@ -1,39 +0,0 @@ -assetRepository = $assetRepository; - } - public function renderIcon(): string - { - $icon = parent::getData(self::ICON); - - if (!is_array($icon)) { - return ''; - } - $logoLink = $this->assetRepository->getUrl($icon['svg']); - return ''; - } -} diff --git a/Plugin/IconRenderer.php b/Plugin/IconRenderer.php new file mode 100644 index 0000000..04a328d --- /dev/null +++ b/Plugin/IconRenderer.php @@ -0,0 +1,32 @@ +assetRepository = $assetRepository; + } + + public function aroundRender( + IconRendererHyva $subject, + callable $proceed, + array $icon + ): string { + // Check if this is a Buckaroo method and handle it + if (isset($icon['svg']) && strpos($icon['svg'], 'Buckaroo_') !== false) { + $logoLink = $this->assetRepository->getUrl($icon['svg']); + return ''; + } + + // Otherwise, proceed with the default behavior + return $proceed($icon); + } +} diff --git a/Plugin/MethodList.php b/Plugin/MethodList.php index 89efd80..eb5f1e9 100644 --- a/Plugin/MethodList.php +++ b/Plugin/MethodList.php @@ -8,7 +8,7 @@ use Magento\Payment\Model\MethodInterface as PaymentMethodInterface; use Buckaroo\Magento2\Model\ConfigProvider\Method\ConfigProviderInterface; use Hyva\Checkout\ViewModel\Checkout\Payment\MethodList as HyvaMethodList; -use Buckaroo\HyvaCheckout\Model\MethodMetaDataFactory; +use Hyva\Checkout\Model\MethodMetaDataFactory; class MethodList implements \Magento\Framework\View\Element\Block\ArgumentInterface { diff --git a/etc/di.xml b/etc/di.xml index cfb41fd..35ef475 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -4,4 +4,8 @@ + + + + From cbe863291f3adf203545dc6dffe5b2111405682c Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Thu, 22 Aug 2024 17:00:32 +0200 Subject: [PATCH 09/17] remove extra return --- Block/Totals/Fee.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php index ecdabb0..06c612d 100644 --- a/Block/Totals/Fee.php +++ b/Block/Totals/Fee.php @@ -41,7 +41,6 @@ public function getTitle(): string } catch (\Throwable $th) { return __('Fee'); } - return __('Fee'); } /** From aeb051f5aa9362f5e018c9a1b67a82623f8e1eb3 Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Fri, 23 Aug 2024 11:06:56 +0200 Subject: [PATCH 10/17] update hyva version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6634f2e..9581614 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "docs": "https://support.buckaroo.nl" }, "homepage": "https://www.buckaroo.nl", - "version" : "v1.1.2", + "version" : "v1.1.3", "minimum-stability": "stable", "autoload": { "files": [ From 4ab5cc297df0d42284e665c29e2899585861582d Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Mon, 2 Sep 2024 14:30:32 +0200 Subject: [PATCH 11/17] hyva checkout fee calculation --- Block/Totals/Fee.php | 34 +------------------ .../layout/hyva_checkout_components.xml | 6 ++-- .../templates/total-segments/fee.phtml | 10 +++--- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/Block/Totals/Fee.php b/Block/Totals/Fee.php index 06c612d..0c2e5d7 100644 --- a/Block/Totals/Fee.php +++ b/Block/Totals/Fee.php @@ -39,39 +39,7 @@ public function getTitle(): string ->getPayment(); return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod()); } catch (\Throwable $th) { - return __('Fee'); + return __('Payment Fee'); } } - - /** - * Get total from array of data - * - * @return float - */ - public function getTotal(): float - { - $totalData = $this->getSegment(); - if (false === is_array($totalData)) { - throw new \UnexpectedValueException('Expecting an array but getting '.gettype($totalData)); - } - - $extensionAttributes = $totalData['extension_attributes']; - - if ( - is_array($extensionAttributes) && - isset($extensionAttributes['buckaroo_fee']) && - is_scalar($extensionAttributes['buckaroo_fee']) - ) { - return floatval($extensionAttributes['buckaroo_fee']); - } - - if ($extensionAttributes instanceof \Magento\Quote\Api\Data\TotalSegmentExtension) { - /** @var \Magento\Quote\Api\Data\TotalSegmentExtension $extensionAttributes */ - if ($extensionAttributes->getBuckarooFee() !== null) { - return $extensionAttributes->getBuckarooFee(); - } - } - - return 0; - } } diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 69f5457..3292516 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -202,9 +202,9 @@ - - \ No newline at end of file + diff --git a/view/frontend/templates/total-segments/fee.phtml b/view/frontend/templates/total-segments/fee.phtml index 77923b8..b00a1fa 100644 --- a/view/frontend/templates/total-segments/fee.phtml +++ b/view/frontend/templates/total-segments/fee.phtml @@ -14,14 +14,16 @@ use Hyva\Checkout\ViewModel\Checkout\Formatter as FormatterViewModel; use Hyva\Theme\Model\ViewModelRegistry; $formatterViewModel = $viewModels->require(FormatterViewModel::class); -$total = $block->getTotal(); -if ($total != 0) { +$segment = $block->getSegment(); +if ($segment['value'] != 0) { ?>
- + escapeHtml($block->getTitle()) ?> - currency($total ?? 0) ?> + + currency($segment['value'] ?? 0) ?> +
Date: Thu, 5 Sep 2024 14:30:44 +0200 Subject: [PATCH 12/17] BP-3735-Update-iDEAL-In3-logo --- Plugin/MethodList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugin/MethodList.php b/Plugin/MethodList.php index eb5f1e9..3134401 100644 --- a/Plugin/MethodList.php +++ b/Plugin/MethodList.php @@ -51,8 +51,8 @@ private function getSvgLogo(string $methodCode): string $mappings = [ "afterpay2" => "svg/afterpay.svg", "afterpay20" => "svg/afterpay.svg", - "capayablein3" => "svg/in3.svg", - "capayablepostpay" => "svg/in3.svg", + "capayablein3" => "svg/ideal-in3.svg", + "capayablepostpay" => "svg/ideal-in3.svg", "creditcard" => "svg/creditcards.svg", "creditcards" => "svg/creditcards.svg", "giftcards" => "svg/giftcards.svg", From e19091298e063e1fabb2894239505ea133dc2b57 Mon Sep 17 00:00:00 2001 From: "a.baraliu" Date: Wed, 11 Sep 2024 01:53:18 +0200 Subject: [PATCH 13/17] BP-3734-Add-support-for-PayByBank --- Magewire/Payment/Method/PayByBank.php | 184 ++++++++++++++++++ etc/frontend/di.xml | 4 +- .../layout/hyva_checkout_components.xml | 10 + .../component/payment/method/paybybank.phtml | 47 +++++ 4 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 Magewire/Payment/Method/PayByBank.php create mode 100644 view/frontend/templates/component/payment/method/paybybank.phtml diff --git a/Magewire/Payment/Method/PayByBank.php b/Magewire/Payment/Method/PayByBank.php new file mode 100644 index 0000000..916634d --- /dev/null +++ b/Magewire/Payment/Method/PayByBank.php @@ -0,0 +1,184 @@ + 'Saving Bank issuer' + ]; + + protected $rules = [ + 'issuer' => 'required' + ]; + + protected $messages = [ + 'issuer:required' => 'The bank issuer is required' + ]; + + protected SessionCheckout $sessionCheckout; + + protected CartRepositoryInterface $quoteRepository; + + protected Repository $assetRepo; + + protected ScopeConfigInterface $scopeConfig; + + + public function __construct( + Validator $validator, + SessionCheckout $sessionCheckout, + CartRepositoryInterface $quoteRepository, + Repository $assetRepo, + ScopeConfigInterface $scopeConfig, + + ) { + parent::__construct($validator); + + $this->sessionCheckout = $sessionCheckout; + $this->quoteRepository = $quoteRepository; + $this->assetRepo = $assetRepo; + $this->scopeConfig = $scopeConfig; + + } + + /** + * @throws LocalizedException + * @throws NoSuchEntityException + */ + public function mount(): void + { + $this->issuer = $this->getLastIssuer(); + } + + /** + * Listen for bank issuer been updated. + */ + public function updatedIssuer(string $value): ?string + { + $this->validateOnly(); + $value = empty($value) ? null : $value; + + try { + $quote = $this->sessionCheckout->getQuote(); + $quote->getPayment()->setAdditionalInformation('issuer', $value); + + $this->quoteRepository->save($quote); + } catch (LocalizedException $exception) { + $this->dispatchErrorMessage($exception->getMessage()); + } + + return $value; + } + + public function evaluateCompletion(EvaluationResultFactory $resultFactory): EvaluationResultInterface + { + if ($this->issuer === null) { + return $resultFactory->createErrorMessageEvent() + ->withCustomEvent('payment:method:error') + ->withMessage('The bank issuer is required'); + } + + return $resultFactory->createSuccess(); + } + + public function getIssuers(): array + { + return [ + [ + 'name' => 'ABN AMRO', + 'code' => 'ABNANL2A', + 'imgName' => 'abnamro' + ], + [ + 'name' => 'ASN Bank', + 'code' => 'ASNBNL21', + 'imgName' => 'asnbank' + ], + [ + 'name' => 'ING', + 'code' => 'INGBNL2A', + 'imgName' => 'ing' + ], + [ + 'name' => 'Knab Bank', + 'code' => 'KNABNL2H', + 'imgName' => 'knab' + ], + [ + 'name' => 'Rabobank', + 'code' => 'RABONL2U', + 'imgName' => 'rabobank' + ], + [ + 'name' => 'RegioBank', + 'code' => 'RBRBNL21', + 'imgName' => 'regiobank' + ], + [ + 'name' => 'SNS Bank', + 'code' => 'SNSBNL2A', + 'imgName' => 'sns' + ], + [ + 'name' => 'N26', + 'code' => 'NTSBDEB1', + 'imgName' => 'n26' + ] + ]; + } + + public function getLastIssuer() + { + + $quote = $this->sessionCheckout->getQuote(); + + $customerId = $quote->getCustomerId(); + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $customerRepository = $objectManager->get(\Magento\Customer\Api\CustomerRepositoryInterface::class); + + $customer = $customerRepository->getById($customerId); + + $customAttributes = $customer->getCustomAttributes(); + $issuerAttribute = $customAttributes['buckaroo_last_paybybank_issuer'] ?? null; + + if ($issuerAttribute) { + return $issuerAttribute->getValue(); + } else { + return $issuerAttribute; + } + + } + + public function getImageUrl(string $issuerImage): string + { + return $this->assetRepo->getUrl("Buckaroo_Magento2::images/ideal/{$issuerImage}.svg"); + } + + public function displayAsSelect($storeId = null): bool + { + return $this->scopeConfig->getValue( + MethodPayByBank::XPATH_PAYBYBANK_SELECTION_TYPE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ) === '2'; + } +} diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index a88943f..ddd9644 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -14,7 +14,7 @@ \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService - + \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService @@ -48,4 +48,4 @@ - \ No newline at end of file + diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 3292516..850d814 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -195,6 +195,16 @@
+ + + + \Buckaroo\HyvaCheckout\Magewire\Payment\Method\PayByBank + + + + diff --git a/view/frontend/templates/component/payment/method/paybybank.phtml b/view/frontend/templates/component/payment/method/paybybank.phtml new file mode 100644 index 0000000..1ad4044 --- /dev/null +++ b/view/frontend/templates/component/payment/method/paybybank.phtml @@ -0,0 +1,47 @@ +getIssuers(); + +?> +
+
+ displayAsSelect()) { ?> + + + + +

escapeHtml(__('Select a bank:')); ?>

+ +
+ issuer ? 'checked' : '' ?> + /> + +
+ + +
+
From 9de4ca3f0083c37a15d5798f978270106441ae49 Mon Sep 17 00:00:00 2001 From: "a.baraliu" Date: Wed, 11 Sep 2024 17:39:07 +0200 Subject: [PATCH 14/17] BP-3733-You-have-no-items-on-the-shopping-cart-appears-when-you-place-an-order --- etc/frontend/di.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index ddd9644..b8d65da 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -35,6 +35,10 @@ \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService + \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService + \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService + \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService + \Buckaroo\HyvaCheckout\Model\Magewire\Payment\PlaceOrderService From aefa0a4676f0e538536bd9beb49dfa27a13a9fd0 Mon Sep 17 00:00:00 2001 From: "a.baraliu" Date: Wed, 11 Sep 2024 17:46:18 +0200 Subject: [PATCH 15/17] BP-3737-Giropay-payment-is-not-working --- .../layout/hyva_checkout_components.xml | 10 ------- .../component/payment/method/giropay.phtml | 28 ------------------- 2 files changed, 38 deletions(-) delete mode 100644 view/frontend/templates/component/payment/method/giropay.phtml diff --git a/view/frontend/layout/hyva_checkout_components.xml b/view/frontend/layout/hyva_checkout_components.xml index 850d814..a14b10f 100644 --- a/view/frontend/layout/hyva_checkout_components.xml +++ b/view/frontend/layout/hyva_checkout_components.xml @@ -105,16 +105,6 @@
- - - - \Buckaroo\HyvaCheckout\Magewire\Payment\Method\Giropay - - - - diff --git a/view/frontend/templates/component/payment/method/giropay.phtml b/view/frontend/templates/component/payment/method/giropay.phtml deleted file mode 100644 index 5bcd288..0000000 --- a/view/frontend/templates/component/payment/method/giropay.phtml +++ /dev/null @@ -1,28 +0,0 @@ -getGenderList(); - -?> -
-
- - - hasError('bic')) : ?> -
escapeHtmlAttr($magewire->getError('bic')) ?>
- -
-
From 6516ea70a05890bae2d6fdbba05799689705c4ff Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Fri, 20 Sep 2024 17:18:30 +0200 Subject: [PATCH 16/17] update Grand Total --- Magewire/Payment/Method/Giftcards.php | 33 +++++++- .../templates/component/payment/after.phtml | 78 ++++++++++++------- 2 files changed, 82 insertions(+), 29 deletions(-) diff --git a/Magewire/Payment/Method/Giftcards.php b/Magewire/Payment/Method/Giftcards.php index 331620c..bc6ad1b 100644 --- a/Magewire/Payment/Method/Giftcards.php +++ b/Magewire/Payment/Method/Giftcards.php @@ -16,6 +16,7 @@ use Buckaroo\Magento2\Model\Giftcard\Response\Giftcard as GiftcardResponse; use Buckaroo\Magento2\Model\Giftcard\Request\GiftcardInterface as GiftcardRequest; use Buckaroo\Magento2\Model\ConfigProvider\Method\Giftcards as MethodConfigProvider; +use Magento\Framework\Pricing\Helper\Data as PricingHelper; class Giftcards extends Component\Form implements EvaluationInterface { @@ -34,6 +35,7 @@ class Giftcards extends Component\Form implements EvaluationInterface protected GiftcardResponse $giftcardResponse; protected Log $logger; + protected $pricingHelper; public function __construct( UrlInterface $urlBuilder, @@ -42,7 +44,8 @@ public function __construct( MethodConfigProvider $methodConfigProvider, GiftcardRequest $giftcardRequest, GiftcardResponse $giftcardResponse, - Log $logger + Log $logger, + PricingHelper $pricingHelper ) { $this->urlBuilder = $urlBuilder; $this->sessionCheckout = $sessionCheckout; @@ -51,6 +54,7 @@ public function __construct( $this->giftcardRequest = $giftcardRequest; $this->giftcardResponse = $giftcardResponse; $this->logger = $logger; + $this->pricingHelper = $pricingHelper; } /** @@ -150,7 +154,32 @@ public function applyGiftcard( } } + /** + * Convert and format price value for current store + * + * @param float $price + * @return float|string + */ + public function getFormattedPrice($price) + { + return $this->pricingHelper->currency($price, true, false); + } + public function getRemainingAmount() + { + $quote = $this->sessionCheckout->getQuote(); + + $grandTotal = round(floatval($quote->getGrandTotal()), 2); + + // Get the amount already paid through group transactions + $alreadyPaid = $this->groupTransaction->getAlreadyPaid($quote->getReservedOrderId()); + + // Calculate the remaining amount + $remainingAmount = $grandTotal - $alreadyPaid; + + // Ensure the remaining amount is never negative + $this->emit("remainingAmount", $this->getFormattedPrice($remainingAmount)); + } protected function getGiftcardResponse(Quote $quote, $response) { $this->giftcardResponse->set($response, $quote); @@ -183,8 +212,8 @@ protected function getGiftcardResponse(Quote $quote, $response) $this->giftcardResponse->getCurrency() ); } - return [ + 'remainder_amount_currency' => $this->getFormattedPrice($remainingAmount), 'remainder_amount' => $remainingAmount, 'already_paid' => $this->giftcardResponse->getAlreadyPaid($quote), 'remaining_amount_message' => $buttonMessage, diff --git a/view/frontend/templates/component/payment/after.phtml b/view/frontend/templates/component/payment/after.phtml index 8992e5f..02b78de 100644 --- a/view/frontend/templates/component/payment/after.phtml +++ b/view/frontend/templates/component/payment/after.phtml @@ -373,24 +373,59 @@ }, giftcards($el) { return Object.assign(hyva.formValidation($el), { - card:'', + card: '', pin: '', cardNumber: '', - canSubmit:false, + canSubmit: false, + + async update() { + await this.$wire.getRemainingAmount(); + }, + listenToUpdate(){ + this.$wire.on('remainingAmount', async (response) => { + this.updateGrandTotal(response); + }) + }, async formValid() { - try { - await this.validate(); - } catch (error) { - return false; - } - return true; + try { + await this.validate(); + } catch (error) { + return false; + } + return true; }, + async submit() { - if(!await this.formValid()) { + if (!await this.formValid()) { return; } await this.$wire.applyGiftcard(this.card, this.cardNumber, this.pin); }, + + listenToSubmit() { + this.$wire.on('giftcard_response', async (response) => { + if (response.error) { + this.displayError(response.error); + } else if (response.remainder_amount === undefined) { + this.displayError(response.message); + } else if (response.remainder_amount == 0) { + this.canSubmit = true; + await hyvaCheckout.order.place(); + } else if (response.remainder_amount != 0) { + this.displaySuccess(response); + this.updateGrandTotal(response.remainder_amount_currency); + } + }) + }, + updateGrandTotal(remainder_amount_currency) { + const grandTotalElement = document.querySelector('.grand_total .value'); + grandTotalElement.textContent = remainder_amount_currency + + setTimeout(function () { + grandTotalElement.textContent = remainder_amount_currency + + }, 2000); + }, displaySuccess(response) { window.dispatchEvent(new CustomEvent('buckaroo-modal-show', { detail: { @@ -405,6 +440,7 @@ } })); }, + displayError(message) { window.dispatchEvent(new CustomEvent('buckaroo-modal-show', { detail: { @@ -415,30 +451,18 @@ } })); }, - listenToSubmit() { - this.$wire.on('giftcard_response', async (response) => { - if (response.error) { - this.displayError(response.error); - } else if(response.remainder_amount === undefined) { - this.displayError(response.message); - } else if (response.remainder_amount == 0) { - this.canSubmit = true; - await hyvaCheckout.order.place(); - } else if (response.remainder_amount != 0) { - this.displaySuccess(response); - } - }) - }, + register() { this.listenToSubmit(); + this.update(); + this.listenToUpdate(); window.buckarooTask = async () => { - if(!this.canSubmit) { + if (!this.canSubmit) { await this.submit(); } }; }, - - }) + }); }, mrCash($el) { return Object.assign(hyva.formValidation($el), { @@ -566,4 +590,4 @@ } } - \ No newline at end of file + From a451b560c4db8f8a624faa66a561d4b6612e3fa8 Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Mon, 23 Sep 2024 14:08:57 +0200 Subject: [PATCH 17/17] Update test & release (1.2.0) --- README.md | 2 +- composer.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 109912f..f394bd9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Buckaroo has developed a cutting-edge Hyvä Checkout module as an extension for
## Requirements -* [Buckaroo Magento 2 plugin](https://github.com/buckaroo-it/Magento2/releases) version 1.46 or higher +* [Buckaroo Magento 2 plugin](https://github.com/buckaroo-it/Magento2/releases) version 1.50.1 or higher * Hyvä Checkout version 1.1.8 or higher
diff --git a/composer.json b/composer.json index 9581614..89b8c16 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "name": "buckaroo/magento2-hyva-checkout", "description": "Buckaroo Magento 2 hyva checkout extension", "require": { - "php": ">=8.1" + "php": ">=8.1", + "buckaroo/magento2": ">=1.50.1" }, "type": "magento2-module", "license": "CC-BY-NC-ND-3.0", @@ -20,7 +21,7 @@ "docs": "https://support.buckaroo.nl" }, "homepage": "https://www.buckaroo.nl", - "version" : "v1.1.3", + "version" : "v1.2.0", "minimum-stability": "stable", "autoload": { "files": [