From de8c028d3a4ea07fab1e18ab519476659945de57 Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Mon, 10 Jul 2023 13:51:16 +0300 Subject: [PATCH] BP-2673 Add payment method: PayByBank (PaymentInitiation) (#749) * BP-2673 Add payment method: PayByBank (PaymentInitiation) * Add correct issuers * BP-2673 - code review * change logo n26 * Update module.xml * Update UpgradeData.php --------- Co-authored-by: Ivascu Madalin Co-authored-by: Lucian Turiac Co-authored-by: Lucian Turiac <106905746+LucianTuriacArnia@users.noreply.github.com> --- Block/Info.php | 3 +- Helper/Data.php | 6 +- .../Method/AbstractConfigProvider.php | 4 +- Model/ConfigProvider/Method/PayByBank.php | 212 ++++++++++++ Model/Method/PayByBank.php | 310 ++++++++++++++++++ Service/CustomerAttributes.php | 29 ++ Setup/UpgradeData.php | 42 ++- etc/adminhtml/system/payment_methods.xml | 3 + .../system/payment_methods/paybybank.xml | 164 +++++++++ etc/config.xml | 14 + etc/di.xml | 4 + etc/frontend/di.xml | 1 + etc/payment.xml | 3 + view/adminhtml/web/images/paybybank.gif | Bin 0 -> 3594 bytes view/frontend/layout/checkout_index_index.xml | 3 + view/frontend/web/css/styles.css | 101 +++++- view/frontend/web/images/ideal/n26.svg | 1 + view/frontend/web/images/paybybank.gif | Bin 0 -> 3594 bytes .../web/js/view/payment/buckaroo-payments.js | 8 +- .../view/payment/method-renderer/paybybank.js | 195 +++++++++++ .../payment/buckaroo_magento2_paybybank.html | 125 +++++++ 21 files changed, 1211 insertions(+), 17 deletions(-) create mode 100644 Model/ConfigProvider/Method/PayByBank.php create mode 100644 Model/Method/PayByBank.php create mode 100644 Service/CustomerAttributes.php create mode 100644 etc/adminhtml/system/payment_methods/paybybank.xml create mode 100644 view/adminhtml/web/images/paybybank.gif create mode 100644 view/frontend/web/images/ideal/n26.svg create mode 100644 view/frontend/web/images/paybybank.gif create mode 100644 view/frontend/web/js/view/payment/method-renderer/paybybank.js create mode 100644 view/frontend/web/template/payment/buckaroo_magento2_paybybank.html diff --git a/Block/Info.php b/Block/Info.php index 80251a103..788db0da4 100644 --- a/Block/Info.php +++ b/Block/Info.php @@ -104,7 +104,8 @@ public function getPaymentLogo(string $method): string "sofortbanking" => "svg/sofort.svg", "emandate" => "emandate.png", "pospayment" => "pos.png", - "transfer" => "svg/sepa-credittransfer.svg" + "transfer" => "svg/sepa-credittransfer.svg", + "paybybank" => "paybybank.gif" ]; $name = "svg/{$method}.svg"; diff --git a/Helper/Data.php b/Helper/Data.php index 8f88587ea..83a44f587 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -246,10 +246,10 @@ public function getMode($paymentMethod = null, $store = null) */ public function isMobile() { - $useragent = $_SERVER['HTTP_USER_AGENT']; + $userAgent = $this->httpHeader->getHttpUserAgent(); return preg_match( - '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', - substr($useragent,0,4) + '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$userAgent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', + substr($userAgent,0,4) ); } diff --git a/Model/ConfigProvider/Method/AbstractConfigProvider.php b/Model/ConfigProvider/Method/AbstractConfigProvider.php index 4693ec39b..ac497416b 100644 --- a/Model/ConfigProvider/Method/AbstractConfigProvider.php +++ b/Model/ConfigProvider/Method/AbstractConfigProvider.php @@ -181,7 +181,7 @@ public function getIssuers() */ protected function formatIssuers() { - $issuers = array_map( + return array_map( function ($issuer) { if(isset($issuer['imgName'])) { $issuer['img'] = $this->getImageUrl("ideal/{$issuer['imgName']}", "svg"); @@ -190,8 +190,6 @@ function ($issuer) { }, $this->getIssuers() ); - - return $issuers; } public function getCreditcardLogo(string $code): string diff --git a/Model/ConfigProvider/Method/PayByBank.php b/Model/ConfigProvider/Method/PayByBank.php new file mode 100644 index 000000000..a901d000c --- /dev/null +++ b/Model/ConfigProvider/Method/PayByBank.php @@ -0,0 +1,212 @@ + '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' + ] + ]; + + /** + * @var CustomerSession + */ + protected CustomerSession $customerSession; + + /** + * @param Repository $assetRepo + * @param ScopeConfigInterface $scopeConfig + * @param AllowedCurrencies $allowedCurrencies + * @param PaymentFee $paymentFeeHelper + * @param CustomerSession $customerSession + */ + public function __construct( + Repository $assetRepo, + ScopeConfigInterface $scopeConfig, + AllowedCurrencies $allowedCurrencies, + PaymentFee $paymentFeeHelper, + CustomerSession $customerSession + ) { + parent::__construct($assetRepo, $scopeConfig, $allowedCurrencies, $paymentFeeHelper); + $this->customerSession = $customerSession; + } + + /** + * @var array + */ + protected $allowedCurrencies = [ + 'EUR' + ]; + + /** + * @return array + */ + public function getConfig(): array + { + if (!$this->scopeConfig->getValue( + static::XPATH_PAYBYBANK_ACTIVE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )) { + return []; + } + + + $selectionType = $this->scopeConfig->getValue( + self::XPATH_PAYBYBANK_SELECTION_TYPE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + return [ + 'payment' => [ + 'buckaroo' => [ + 'paybybank' => [ + 'banks' => $this->getIssuersWithSelected(), + 'subtext' => $this->getSubtext(), + 'subtext_style' => $this->getSubtextStyle(), + 'subtext_color' => $this->getSubtextColor(), + 'allowedCurrencies' => $this->getAllowedCurrencies(), + 'selectionType' => $selectionType, + ], + ], + ], + ]; + } + + /** + * @param null|int $storeId + * + * @return float + */ + public function getPaymentFee($storeId = null) + { + return 0; + } + + /** + * @param null|int $storeId + * + * @return string + */ + public function getPaymentFeeLabel($storeId = null) + { + return $this->scopeConfig->getValue( + Account::XPATH_ACCOUNT_PAYMENT_FEE_LABEL, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Get bank issuers, move last saved bank issuer first, + * add selected property to the issuers array + * + * @return array + */ + public function getIssuersWithSelected() + { + $issuers = $this->formatIssuers(); + $customer = $this->customerSession->getCustomer(); + $savedBankIssuer = $customer->getData(PayByBankMethod::EAV_LAST_USED_ISSUER_ID); + + if ($savedBankIssuer !== null) { + $issuers = array_map(function ($issuer) use ($savedBankIssuer) { + $issuer['selected'] = is_scalar($savedBankIssuer) && isset($issuer['code']) && $issuer['code'] === $savedBankIssuer; + return $issuer; + }, $issuers); + + + $savedIssuer = array_filter($issuers, function ($issuer) { + return $issuer['selected']; + }); + $issuers = array_filter($issuers, function ($issuer) { + return !$issuer['selected']; + }); + + return array_merge($savedIssuer, $issuers); + } + + return $issuers; + } +} diff --git a/Model/Method/PayByBank.php b/Model/Method/PayByBank.php new file mode 100644 index 000000000..3f0d916b0 --- /dev/null +++ b/Model/Method/PayByBank.php @@ -0,0 +1,310 @@ +customerAttributes = $customerAttributes; + $this->payByBankConfig = $payByBankConfig; + } + + + /** + * {@inheritdoc} + */ + public function assignData(\Magento\Framework\DataObject $data) + { + parent::assignData($data); + $data = $this->assignDataConvertToArray($data); + + if (isset($data['additional_data']['buckaroo_skip_validation'])) { + $this->getInfoInstance()->setAdditionalInformation( + 'buckaroo_skip_validation', + $data['additional_data']['buckaroo_skip_validation'] + ); + } + + if (isset($data['additional_data']['issuer'])) { + $this->getInfoInstance()->setAdditionalInformation('issuer', $data['additional_data']['issuer']); + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getOrderTransactionBuilder($payment) + { + $this->saveLastUsedIssuer($payment); + $transactionBuilder = $this->transactionBuilderFactory->get('order'); + + $serviceName = 'paybybank'; + $issuer = $payment->getAdditionalInformation('issuer'); + if ($issuer === 'INGBNL2A' && $this->helper->isMobile()) { + $serviceName = 'ideal'; + } + + $services = [ + 'Name' => $serviceName, + 'Action' => $this->getPayRemainder($payment, $transactionBuilder), + 'Version' => 2, + 'RequestParameter' => [ + [ + '_' => $issuer, + 'Name' => 'issuer', + ], + ], + ]; + + /** + * @noinspection PhpUndefinedMethodInspection + */ + $transactionBuilder->setOrder($payment->getOrder()) + ->setServices($services) + ->setMethod('TransactionRequest'); + + return $transactionBuilder; + } + + /** + * @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment + * + * @return void + * @throws LocalizedException + */ + public function saveLastUsedIssuer($payment) + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $payment->getOrder(); + $customerId = $order->getCustomerId(); + + if ($customerId !== null) { + $this->customerAttributes->setAttribute( + $customerId, + self::EAV_LAST_USED_ISSUER_ID, + $this->getInfoInstance()->getAdditionalInformation('issuer') + ); + } + } + + /** + * {@inheritdoc} + */ + public function getCaptureTransactionBuilder($payment) + { + return false; + } + + /** + * {@inheritdoc} + */ + public function getAuthorizeTransactionBuilder($payment) + { + return false; + } + + /** + * {@inheritdoc} + */ + public function getVoidTransactionBuilder($payment) + { + return true; + } + + /** + * Validate that we received a valid issuer ID. + * + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function validate() + { + parent::validate(); + + $paymentInfo = $this->getInfoInstance(); + + $skipValidation = $paymentInfo->getAdditionalInformation('buckaroo_skip_validation'); + if ($skipValidation) { + return $this; + } + + $chosenIssuer = $paymentInfo->getAdditionalInformation('issuer'); + + if (!$chosenIssuer) { + if ($content = $this->request->getContent()) { + $jsonDecode = $this->helper->getJson()->unserialize($content); + if (!empty($jsonDecode['paymentMethod']['additional_data']['issuer'])) { + $chosenIssuer = $jsonDecode['paymentMethod']['additional_data']['issuer']; + $this->getInfoInstance()->setAdditionalInformation('issuer', $chosenIssuer); + } + } + } + + $valid = false; + foreach ($this->payByBankConfig->getIssuers() as $issuer) { + if ($issuer['code'] == $chosenIssuer) { + $valid = true; + break; + } + } + + if (!$valid) { + throw new \Magento\Framework\Exception\LocalizedException(__('Please select a issuer from the list')); + } + + return $this; + } + + /** + * @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment + * + * @return bool|string + */ + public function getPaymentMethodName($payment) + { + return $this->buckarooPaymentMethodCode; + } +} diff --git a/Service/CustomerAttributes.php b/Service/CustomerAttributes.php new file mode 100644 index 000000000..b25352f13 --- /dev/null +++ b/Service/CustomerAttributes.php @@ -0,0 +1,29 @@ +customerRepository = $customerRepository; + } + + public function setAttribute(int $customerId, string $attribute, string $value) + { + $customer = $this->customerRepository->getById($customerId); + $customer->setCustomAttribute($attribute, $value); + $this->customerRepository->save($customer); + } +} \ No newline at end of file diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php index ddcde6fc5..5aedf9c7e 100644 --- a/Setup/UpgradeData.php +++ b/Setup/UpgradeData.php @@ -20,16 +20,17 @@ namespace Buckaroo\Magento2\Setup; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Eav\Model\Config; use Magento\Store\Model\Store; - use Magento\Eav\Setup\EavSetup; -use Magento\Eav\Setup\EavSetupFactory; -use Magento\Eav\Model\Config; use Magento\Customer\Model\Customer; +use Magento\Eav\Setup\EavSetupFactory; +use Buckaroo\Magento2\Model\Method\PayByBank; +use Magento\Framework\Setup\ModuleContextInterface; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; + class UpgradeData implements \Magento\Framework\Setup\UpgradeDataInterface { /** @@ -562,6 +563,10 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $this->giftcardPartialRefund($setup); } + if (version_compare($context->getVersion(), '1.45.1', '<')) { + $this->addCustomerLastPayByBankIssuer($setup); + } + $this->setCustomerIDIN($setup); $this->setCustomerIsEighteenOrOlder($setup); @@ -1458,6 +1463,31 @@ protected function setCustomerIDIN(ModuleDataSetupInterface $setup) $buckarooIDIN->save(); } + protected function addCustomerLastPayByBankIssuer(ModuleDataSetupInterface $setup) + { + $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); + $eavSetup->addAttribute( + \Magento\Customer\Model\Customer::ENTITY, + PayByBank::EAV_LAST_USED_ISSUER_ID, + [ + 'type' => 'text', + 'label' => 'Last used Buckaroo PayByBank issuer', + 'input' => 'text', + 'default' => '', + 'required' => false, + 'visible' => false, + 'user_defined' => false, + 'position' => 999, + 'system' => 0, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE + ] + ); + + $buckarooLastPaybybank = $this->eavConfig->getAttribute(Customer::ENTITY, PayByBank::EAV_LAST_USED_ISSUER_ID); + + $buckarooLastPaybybank->save(); + } + protected function setCustomerIsEighteenOrOlder(ModuleDataSetupInterface $setup) { $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); diff --git a/etc/adminhtml/system/payment_methods.xml b/etc/adminhtml/system/payment_methods.xml index 6c4a40607..d4cd2a1ea 100644 --- a/etc/adminhtml/system/payment_methods.xml +++ b/etc/adminhtml/system/payment_methods.xml @@ -111,5 +111,8 @@ + + + diff --git a/etc/adminhtml/system/payment_methods/paybybank.xml b/etc/adminhtml/system/payment_methods/paybybank.xml new file mode 100644 index 000000000..61c7e3a6e --- /dev/null +++ b/etc/adminhtml/system/payment_methods/paybybank.xml @@ -0,0 +1,164 @@ + + + + + + + Buckaroo\Magento2\Block\Config\Form\Field\Fieldset + + + + + Buckaroo\Magento2\Model\Config\Source\Enablemode + payment/buckaroo_magento2_paybybank/active + + + + + + payment/buckaroo_magento2_paybybank/title + + + + + + payment/buckaroo_magento2_paybybank/subtext + + + + + + Buckaroo\Magento2\Model\Config\Source\SubtextStyle + payment/buckaroo_magento2_paybybank/subtext_style + + + + + + payment/buckaroo_magento2_paybybank/subtext_color + Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker + + + + + + + payment/buckaroo_magento2_paybybank/sort_order + + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/buckaroo_magento2_paybybank/order_email + + + + + + The payment method shows only for orders with an order amount greater than the minimum amount. + payment/buckaroo_magento2_paybybank/min_amount + Buckaroo\Magento2\Model\Config\Backend\Price + + + + + + The payment method shows only for orders with an order amount smaller than the maximum amount. + payment/buckaroo_magento2_paybybank/max_amount + Buckaroo\Magento2\Model\Config\Backend\Price + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/buckaroo_magento2_paybybank/active_status + + + + + + To make a new status available it needs to be assigned to the correct state. See Magento documentation about state and status. + Buckaroo\Magento2\Model\Config\Source\StatusesSuccess + payment/buckaroo_magento2_paybybank/order_status_success + + 1 + + + + + + + To make a new status available it needs to be assigned to the correct state. See Magento documentation about state and status. + Buckaroo\Magento2\Model\Config\Source\StatusesFailed + payment/buckaroo_magento2_paybybank/order_status_failed + + 1 + + + + + + + Your contract with Buckaroo must allow for the selected currencies to be used with this payment method. + payment/buckaroo_magento2_paybybank/allowed_currencies + Buckaroo\Magento2\Model\Config\Source\AllowedCurrencies::paybybank + Buckaroo\Magento2\Model\Config\Backend\AllowedCurrencies + + + + + Buckaroo\Magento2\Model\Config\Source\AllOrSpecificCountries + payment/buckaroo_magento2_paybybank/allowspecific + + + + + + Magento\Config\Model\Config\Source\Locale\Country + payment/buckaroo_magento2_paybybank/specificcountry + + 1 + + + + + + + Magento developer client restrictions. + Magento\Config\Model\Config\Source\Yesno + payment/buckaroo_magento2_paybybank/limit_by_ip + + + + + Buckaroo\Magento2\Model\Config\Source\SpecificCustomerGroups + 1 + payment/buckaroo_magento2_paybybank/specificcustomergroup + + + + diff --git a/etc/config.xml b/etc/config.xml index 124bba9a9..7efeea589 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -51,6 +51,20 @@ 0 + + 0 + Buckaroo\Magento2\Model\Method\PayByBank + pending + Buckaroo PayByBank + 0 + 350 + 1 + Fee + buckaroo_magento2 + order + 0 + + 0 Buckaroo\Magento2\Model\Method\IdealProcessing diff --git a/etc/di.xml b/etc/di.xml index de2bf44e1..03d639999 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -362,6 +362,10 @@ voucher Buckaroo\Magento2\Model\ConfigProvider\Method\Voucher + + paybybank + Buckaroo\Magento2\Model\ConfigProvider\Method\PayByBank + diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 54cd9859c..f60ea52b9 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -61,6 +61,7 @@ Buckaroo\Magento2\Model\ConfigProvider\Method\Pospayment Buckaroo\Magento2\Model\ConfigProvider\Method\Tinka Buckaroo\Magento2\Model\ConfigProvider\Method\Voucher + Buckaroo\Magento2\Model\ConfigProvider\Method\PayByBank diff --git a/etc/payment.xml b/etc/payment.xml index a30e41313..c69c3ca5a 100644 --- a/etc/payment.xml +++ b/etc/payment.xml @@ -132,5 +132,8 @@ 0 + + 0 + diff --git a/view/adminhtml/web/images/paybybank.gif b/view/adminhtml/web/images/paybybank.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d162829146115c1a2a74340cb9bc831987668a0 GIT binary patch literal 3594 zcmdUw=T{SGx5X0(5Q>Iiq$o%V2_UG5po|03Ayg38EZC6Y6-*)|G${chBhrF& zLHYm=U6W9xNk@vHlt_(3=eh6P4|o2Cd)8iOfBvnt&pxJRCR)FEc|wSgO~^k3ydmHk z9NZ8Cw~v6kQsBNUc!UN|@E}wLkTgKVML@j-q7A_dGmvNnQtSc45u~|-*WMt@A24r% zyt|6!6qsq3N^-Q`=IWL(_21^Y*HzqUuK&HaE48ni)ZarM z=%ozwMh*^8hX!7ZkHwFT(MLz($Hx*U##1II7?WS}M+fu9hwG-lWKK^N&3%14H(U1Y zTlK=Xmbsbk#rdA4g@GSSL(AOZW$xtK>h#9??8f>x-p0!A&c^O8@4wpH-Q3^XJ=h2S z5O6~X1d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a@rMUevSEaC{B#v1O#F47dfYKO22xog+IOL(|a`+ay zv6=odMp76Pi$a~i1WeoZL{e&J%pI~&_6|zI=0U>_iULG=%<56P2qC$cNIk_tmX9K$ zr-qpKr{w-Ny!XpNnG_~a&Y6vK-dE>%HSa;hu3ktJ5LQ#{-7*gg7sho)Me5mNyq8aT z+c+_5rJVFHy-7V9UviYM(>2n__En(!e}1;AI8Up;!O$sqw%O*pUo0HnN=FPLW~*ww z6$F$Aqwo|Z+nzI_EiDfER}8>$tUEiT0MDqTsgIi0e#V|4F7*7(vsc9>V$%Iw7 z6$b9xx?#MK+vMt|pPGc|dZc>PX|g1}=;2cJueM6bmQFUx$+Oov3JG*|5qv4vmZtQE zh-E9?lC12&#~B5gU8{EpD&*MTP%c-_wy}*qm296lqL|EFx9Dc!9oasYj|TF3iHaq> zKFbR~c>Ok}r+yCDI|gbF{MDH$qL?Pe$C3}7PxvVJc)+V#_Igg>BRSviSwiw*5Opfy zRlYj;j6qiqoA8WRkYFkoAar_biXwF)SndfA$s(k8+Vr1F_gyzV@j&|a_8jB5wdsj4 z-#+#!<)4}6gs0;P+Y9-5r?=#u`evIWWVdJ7=#b8=ogcMDmm*J)gGn`p=X}de=l+zs zqrLcmn?U;tFTui3d^A0yvlt977g2dOe0Klu@y9Fsn^Tcz4z^}f?;LE;=anApaBEf$ jc2`{w>+SszHPYSXpU5~c+WABG%E3PWq!Aw< true + + true + diff --git a/view/frontend/web/css/styles.css b/view/frontend/web/css/styles.css index 241f73482..7cc99846a 100644 --- a/view/frontend/web/css/styles.css +++ b/view/frontend/web/css/styles.css @@ -184,7 +184,8 @@ .buckaroo_magento2_capayablepostpay .payment-method-second-col, .buckaroo_magento2_tinka .payment-method-second-col, .buckaroo_magento2_mrcash .payment-method-second-col, - .buckaroo_magento2_voucher .payment-method-second-col + .buckaroo_magento2_voucher .payment-method-second-col, + .buckaroo_magento2_paybybank .payment-method-second-col { float:left; width: 50%; @@ -213,7 +214,8 @@ .buckaroo_magento2_capayablepostpay .payment-method-billing-address, .buckaroo_magento2_tinka .payment-method-billing-address, .buckaroo_magento2_mrcash .payment-method-billing-address, - .buckaroo_magento2_voucher .payment-method-billing-address + .buckaroo_magento2_voucher .payment-method-billing-address, + .buckaroo_magento2_paybybank .payment-method-billing-address { float:left; width: 50%; @@ -560,3 +562,98 @@ border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } + +/* paybybank */ + +.bk-toggle-down { + background-image: url("data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.293 9.293a1 1 0 0 1 1.414 0L12 14.586l5.293-5.293a1 1 0 1 1 1.414 1.414l-6 6a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414z' fill='%230D0D0D'/%3E%3C/svg%3E%0A"); +} +.bk-toggle-up { + background-image: url("data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.293 7.293a1 1 0 0 1 1.414 0l6 6a1 1 0 0 1-1.414 1.414L12 9.414l-5.293 5.293a1 1 0 0 1-1.414-1.414l6-6z' fill='%230D0D0D'/%3E%3C/svg%3E%0A"); +} +.bk-toggle { + height: 20px; + width: 20px; +} +.bk-toggle-wrap { + display: flex; + align-items: center; + cursor: pointer; +} +@media screen and (max-width: 768px) { + .bk-paybybank-selector .bank-method-label img { + max-width: 30px; + order: 0; + } + .bk-paybybank-selector strong { + order: 2; + } + .bk-paybybank-selector .bank-control { + display: flex; + margin:10px 0; + } + .bk-paybybank-selector .bank-method-label { + flex: 1; + display: flex; + align-items: center; + } + .fieldset > .field .addon .bk-paybybank-selector .bank-method-input { + order: 1; + margin:0 10px; + flex: 0; + } +} +@media screen and (min-width: 768px) { + .bk-paybybank-toggle-list { + display: flex; + justify-content: center; + height: 20px; + margin:10px 0; + width: 100%; + } + + .bk-toggle-text { + margin-left: 10px; + font-weight: bold; + } + .bk-paybybank-selector { + display: flex; + flex-wrap: wrap; + width: 100%; + } + .bk-paybybank-selector .radio-group-required { + display: flex; + flex-wrap: wrap; + margin-top: 10px; + } + .bk-paybybank-selector .bank-control { + flex: 25% 0; + min-width: 55px; + } + .bk-paybybank-selector .bank-method-label.bk-bank-selected { + background-color: #cdd905; + color: #fff; + border-radius: 5px; + } + .bk-paybybank-selector .bank-method-label { + padding-bottom: 5px; + cursor: pointer; + display: flex; + flex-direction: column; + padding-top: 5px; + align-items: center; + } + .bk-paybybank-selector .bank-method-label strong { + display: block; + text-align: center; + font-size: 12px; + flex: 100% 0 0; + } + .bk-paybybank-selector .bank-method-label img { + padding: 10px 20px; + } + + .fieldset > .field .addon .bk-paybybank-selector .bank-method-input { + display:none; + } +} \ No newline at end of file diff --git a/view/frontend/web/images/ideal/n26.svg b/view/frontend/web/images/ideal/n26.svg new file mode 100644 index 000000000..111fee760 --- /dev/null +++ b/view/frontend/web/images/ideal/n26.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/view/frontend/web/images/paybybank.gif b/view/frontend/web/images/paybybank.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d162829146115c1a2a74340cb9bc831987668a0 GIT binary patch literal 3594 zcmdUw=T{SGx5X0(5Q>Iiq$o%V2_UG5po|03Ayg38EZC6Y6-*)|G${chBhrF& zLHYm=U6W9xNk@vHlt_(3=eh6P4|o2Cd)8iOfBvnt&pxJRCR)FEc|wSgO~^k3ydmHk z9NZ8Cw~v6kQsBNUc!UN|@E}wLkTgKVML@j-q7A_dGmvNnQtSc45u~|-*WMt@A24r% zyt|6!6qsq3N^-Q`=IWL(_21^Y*HzqUuK&HaE48ni)ZarM z=%ozwMh*^8hX!7ZkHwFT(MLz($Hx*U##1II7?WS}M+fu9hwG-lWKK^N&3%14H(U1Y zTlK=Xmbsbk#rdA4g@GSSL(AOZW$xtK>h#9??8f>x-p0!A&c^O8@4wpH-Q3^XJ=h2S z5O6~X1d4)tN5B(#@H-BKDTC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#F47dfYKO22xog+IOL(|a`+ay zv6=odMp76Pi$a~i1WeoZL{e&J%pI~&_6|zI=0U>_iULG=%<56P2qC$cNIk_tmX9K$ zr-qpKr{w-Ny!XpNnG_~a&Y6vK-dE>%HSa;hu3ktJ5LQ#{-7*gg7sho)Me5mNyq8aT z+c+_5rJVFHy-7V9UviYM(>2n__En(!e}1;AI8Up;!O$sqw%O*pUo0HnN=FPLW~*ww z6$F$Aqwo|Z+nzI_EiDfER}8>$tUEiT0MDqTsgIi0e#V|4F7*7(vsc9>V$%Iw7 z6$b9xx?#MK+vMt|pPGc|dZc>PX|g1}=;2cJueM6bmQFUx$+Oov3JG*|5qv4vmZtQE zh-E9?lC12&#~B5gU8{EpD&*MTP%c-_wy}*qm296lqL|EFx9Dc!9oasYj|TF3iHaq> zKFbR~c>Ok}r+yCDI|gbF{MDH$qL?Pe$C3}7PxvVJc)+V#_Igg>BRSviSwiw*5Opfy zRlYj;j6qiqoA8WRkYFkoAar_biXwF)SndfA$s(k8+Vr1F_gyzV@j&|a_8jB5wdsj4 z-#+#!<)4}6gs0;P+Y9-5r?=#u`evIWWVdJ7=#b8=ogcMDmm*J)gGn`p=X}de=l+zs zqrLcmn?U;tFTui3d^A0yvlt977g2dOe0Klu@y9Fsn^Tcz4z^}f?;LE;=anApaBEf$ jc2`{w>+SszHPYSXpU5~c+WABG%E3PWq!Aw<= 768) { + self.isMobile(false); + } + }); + + this.bankTypes = ko.computed(function () { + const issuers = window.checkoutConfig.payment.buckaroo.paybybank.banks; + if (this.showAll() === false && !this.isMobile()) { + return issuers.slice(0, 4); + } + return issuers; + }, this); + + /** Check used to see form is valid **/ + this.buttoncheck = ko.computed(function () { + const state = this.validationState(); + const valid = ["issuer"] + .map((field) => { + if (state[field] !== undefined) { + return state[field]; + } + return false; + }) + .reduce(function (prev, cur) { + return prev && cur; + }, true); + return valid; + }, this); + + return this; + }, + + initialSelected() { + let found = window.checkoutConfig.payment.buckaroo.paybybank.banks.find(function (bank) { + return bank.selected === true; + }); + + if (found !== undefined) { + this.selectedBank(found.code); + } + }, + + validateField(data, event) { + const isValid = $(event.target).valid(); + let state = this.validationState(); + state["issuer"] = isValid; + this.validationState(state); + }, + + toggleShow: function () { + this.showAll(!this.showAll()); + }, + /** + * Place order. + * + * placeOrderAction has been changed from Magento_Checkout/js/action/place-order to our own version + * (Buckaroo_Magento2/js/action/place-order) to prevent redirect and handle the response. + */ + placeOrder: function (data, event) { + var self = this, + placeOrder; + + if (event) { + event.preventDefault(); + } + + if (this.validate() && additionalValidators.validate()) { + this.isPlaceOrderActionAllowed(false); + placeOrder = placeOrderAction( + this.getData(), + this.redirectAfterPlaceOrder, + this.messageContainer + ); + + $.when(placeOrder) + .fail(function () { + self.isPlaceOrderActionAllowed(true); + }) + .done(this.afterPlaceOrder.bind(this)); + return true; + } + return false; + }, + + afterPlaceOrder: function () { + var response = window.checkoutConfig.payment.buckaroo.response; + response = $.parseJSON(response); + checkoutCommon.redirectHandle(response); + }, + + selectPaymentMethod: function () { + selectPaymentMethodAction(this.getData()); + checkoutData.setSelectedPaymentMethod(this.item.method); + return true; + }, + + getData: function () { + return { + method: this.item.method, + po_number: null, + additional_data: { + issuer: this.selectedBank(), + }, + }; + }, + + payWithBaseCurrency: function () { + var allowedCurrencies = + window.checkoutConfig.payment.buckaroo.paybybank.allowedCurrencies; + + return allowedCurrencies.indexOf(this.currencyCode) < 0; + }, + + getPayWithBaseCurrencyText: function () { + var text = $.mage.__("The transaction will be processed using %s."); + + return text.replace("%s", this.baseCurrencyCode); + }, + }); +}); diff --git a/view/frontend/web/template/payment/buckaroo_magento2_paybybank.html b/view/frontend/web/template/payment/buckaroo_magento2_paybybank.html new file mode 100644 index 000000000..e561e75ac --- /dev/null +++ b/view/frontend/web/template/payment/buckaroo_magento2_paybybank.html @@ -0,0 +1,125 @@ +
+
+
+
+ + +
+
+ +
+
+
+ +
+ + + + +
+ + + +
+ +
+
+
+
+ + +
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+
+ + + + + +
+ +
+ +
+
+
+
+ +
+ + + +
+ +
+
+ +
+
+ + +
+ +
+ +
+