Skip to content

Commit

Permalink
Merge pull request #1038 from buckaroo-it/BP-3685-Add-payment-method-…
Browse files Browse the repository at this point in the history
…Blik-Magento-2-refactor

Bp 3685 add payment method blik magento 2 refactor
  • Loading branch information
AlbinaBaraliu authored Sep 5, 2024
2 parents b21be5b + 8d861cf commit 85f299b
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Block/Widget/Button/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Toolbar
'buckaroo_magento2_wechatpay',
'buckaroo_magento2_p24',
'buckaroo_magento2_trustly',
'buckaroo_magento2_pospayment'
'buckaroo_magento2_pospayment',
'buckaroo_magento2_blik'
];

/**
Expand Down
1 change: 1 addition & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public function getPaymentMethodsList()
['value' => 'transfer', 'label' => __('Bank Transfer')],
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'blik', 'label' => __('Blik')]
];
}

Expand Down
3 changes: 2 additions & 1 deletion Model/Config/Source/PaymentMethods/AfterExpiry.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function toOptionArray(): array
['value' => 'alipay', 'label' => __('Alipay')],
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'p24', 'label' => __('P24')],
['value' => 'trustly', 'label' => __('Trustly')]
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'blik', 'label' => __('Blik')]
];
}
}
3 changes: 2 additions & 1 deletion Model/Config/Source/PaymentMethods/PayLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function toOptionArray(): array
['value' => 'alipay', 'label' => __('Alipay')],
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'p24', 'label' => __('P24')],
['value' => 'trustly', 'label' => __('Trustly')]
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'blik', 'label' => __('Blik')]
];
}
}
5 changes: 5 additions & 0 deletions Model/Config/Source/PaymentMethods/PayPerEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public function toOptionArray(): array
'value' => 'trustly',
'label' => __('Trustly'),
'code' => 'buckaroo_magento2_trustly'
],
[
'value' => 'blik',
'label' => __('Blik'),
'code' => 'buckaroo_magento2_blik'
]
];
}
Expand Down
34 changes: 34 additions & 0 deletions Model/ConfigProvider/Method/Blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please email
* to [email protected], so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
declare(strict_types=1);

namespace Buckaroo\Magento2\Model\ConfigProvider\Method;

class Blik extends AbstractConfigProvider
{
public const CODE = 'buckaroo_magento2_blik';

/**
* @var array
*/
protected $allowedCurrencies = [
'PLN'
];
}
172 changes: 172 additions & 0 deletions etc/adminhtml/system/payment_methods/blik.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<!-- Blik Payment method group -->
<group id="buckaroo_magento2_blik" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Blik</label>
<frontend_model>Buckaroo\Magento2\Block\Config\Form\Field\Fieldset</frontend_model>

<field id="active" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Blik</label>
<comment><![CDATA[Enable or disable this payment method.]]></comment>
<source_model>Buckaroo\Magento2\Model\Config\Source\Enablemode</source_model>
<config_path>payment/buckaroo_magento2_blik/active</config_path>
</field>

<field id="title" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_blik/title</config_path>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext</label>
<comment><![CDATA[This controls the description which the user sees during checkout.]]></comment>
<config_path>payment/buckaroo_magento2_blik/subtext</config_path>
</field>

<field id="subtext_style" translate="label comment" type="select" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext style</label>
<comment><![CDATA[Choose a font style for the subtext.]]></comment>
<source_model>Buckaroo\Magento2\Model\Config\Source\SubtextStyle</source_model>
<config_path>payment/buckaroo_magento2_blik/subtext_style</config_path>
</field>

<field id="subtext_color" translate="label comment" sortOrder="27" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext color</label>
<comment><![CDATA[Choose a font color for the subtext.]]></comment>
<config_path>payment/buckaroo_magento2_blik/subtext_color</config_path>
<frontend_model>Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker</frontend_model>
</field>


<field id="sort_order" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend sort order</label>
<comment><![CDATA[Determines the sorting of payment methods.]]></comment>
<config_path>payment/buckaroo_magento2_blik/sort_order</config_path>
</field>

<group id="buckaroo_magento2_advanced" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Advanced Configuration</label>

<field id="order_email" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Send order confirmation email</label>
<comment><![CDATA[Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/buckaroo_magento2_blik/order_email</config_path>
</field>

<field id="payment_fee" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment fee</label>
<comment><![CDATA[The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.]]></comment>
<config_path>payment/buckaroo_magento2_blik/payment_fee</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\PaymentFee</backend_model>
</field>

<field id="payment_fee_label" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment fee frontend label</label>
<comment><![CDATA[This label will be displayed next to the fee on the checkout, order, invoice and creditmemo pages and pdfs.]]></comment>
<config_path>payment/buckaroo_magento2_blik/payment_fee_label</config_path>
</field>

<field id="active_status" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Method specific status enabled</label>
<comment><![CDATA[Enable or disable specific status.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/buckaroo_magento2_blik/active_status</config_path>
</field>

<field id="order_status_success" translate="label comment tooltip" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Method specific success status</label>
<comment><![CDATA[Leave empty to use default 'success' status.]]></comment>
<tooltip>To make a new status available it needs to be assigned to the correct state. See Magento documentation about state and status.</tooltip>
<source_model>Buckaroo\Magento2\Model\Config\Source\StatusesSuccess</source_model>
<config_path>payment/buckaroo_magento2_blik/order_status_success</config_path>
<depends>
<field id="active_status">1</field>
</depends>
</field>

<field id="order_status_failed" translate="label comment tooltip" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Method specific failed status</label>
<comment><![CDATA[Leave empty to use default 'failed' status.]]></comment>
<tooltip>To make a new status available it needs to be assigned to the correct state. See Magento documentation about state and status.</tooltip>
<source_model>Buckaroo\Magento2\Model\Config\Source\StatusesFailed</source_model>
<config_path>payment/buckaroo_magento2_blik/order_status_failed</config_path>
<depends>
<field id="active_status">1</field>
</depends>
</field>

<group id="buckaroo_magento2_visibility" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Method visibility</label>
<field id="min_amount" translate="label comment tooltip" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Min order amount (in Base Currency)</label>
<comment><![CDATA[Minimum order amount allowed.]]></comment>
<tooltip>The payment method shows only for orders with an order amount greater than the minimum amount.</tooltip>
<config_path>payment/buckaroo_magento2_blik/min_amount</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\Price</backend_model>
</field>

<field id="max_amount" translate="label comment tooltip" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Max order amount (in Base Currency)</label>
<comment><![CDATA[Maximum order amount allowed.]]></comment>
<tooltip>The payment method shows only for orders with an order amount smaller than the maximum amount.</tooltip>
<config_path>payment/buckaroo_magento2_blik/max_amount</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\Price</backend_model>
</field>

<field id="specificcustomergroup" translate="label" type="multiselect" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow customer groups</label>
<source_model>Buckaroo\Magento2\Model\Config\Source\SpecificCustomerGroups</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/buckaroo_magento2_blik/specificcustomergroup</config_path>
</field>

<field id="allowspecific" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment from applicable countries</label>
<source_model>Buckaroo\Magento2\Model\Config\Source\AllOrSpecificCountries</source_model>
<config_path>payment/buckaroo_magento2_blik/allowspecific</config_path>
</field>

<field id="specificcountry" translate="label comment" type="multiselect" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment from Specific Country</label>
<comment><![CDATA[Only available when set to 'specific countries'.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Locale\Country</source_model>
<config_path>payment/buckaroo_magento2_blik/specificcountry</config_path>
<depends>
<field id="allowspecific">1</field>
</depends>
</field>

<field id="allowed_currencies" translate="label comment tooltip" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allowed currencies</label>
<comment><![CDATA[Select payment method specific currencies.]]></comment>
<tooltip>Your contract with Buckaroo must allow for the selected currencies to be used with this payment method.</tooltip>
<config_path>payment/buckaroo_magento2_blik/allowed_currencies</config_path>
<source_model>Buckaroo\Magento2\Model\Config\Source\AllowedCurrencies::blik</source_model>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\AllowedCurrencies</backend_model>
</field>
</group>
</group>
</group>
</include>
2 changes: 2 additions & 0 deletions etc/adminhtml/system/payment_methods_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@
<include path="Buckaroo_Magento2::system/payment_methods/multibanco.xml"/>

<include path="Buckaroo_Magento2::system/payment_methods/knaken.xml"/>

<include path="Buckaroo_Magento2::system/payment_methods/blik.xml"/>
</include>
32 changes: 28 additions & 4 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<group>buckaroo_magento2</group>
<payment_action>order</payment_action>
<available_in_backend>0</available_in_backend>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius</payment_method_after_expiry>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius,blik</payment_method_after_expiry>
<can_authorize>0</can_authorize>
<can_capture>0</can_capture>
<can_capture_partial>0</can_capture_partial>
Expand Down Expand Up @@ -241,7 +241,7 @@
<group>buckaroo_magento2</group>
<payment_action>order</payment_action>
<available_in_backend>1</available_in_backend>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius</payment_method_after_expiry>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius,blik</payment_method_after_expiry>
<can_authorize>0</can_authorize>
<can_capture>0</can_capture>
<can_capture_partial>0</can_capture_partial>
Expand Down Expand Up @@ -353,6 +353,30 @@
<is_gateway>1</is_gateway>
</buckaroo_magento2_belfius>

<buckaroo_magento2_blik>
<active>0</active>
<model>BlikFacade</model>
<order_status>pending</order_status>
<title>Blik</title>
<allowspecific>0</allowspecific>
<sort_order>150</sort_order>
<order_email>1</order_email>
<payment_fee_label>Fee</payment_fee_label>
<group>buckaroo_magento2</group>
<payment_action>order</payment_action>
<available_in_backend>0</available_in_backend>
<can_authorize>0</can_authorize>
<can_capture>0</can_capture>
<can_capture_partial>0</can_capture_partial>
<can_order>1</can_order>
<can_void>1</can_void>
<can_refund>1</can_refund>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_use_internal>1</can_use_internal>
<can_use_checkout>1</can_use_checkout>
<is_gateway>1</is_gateway>
</buckaroo_magento2_blik>

<buckaroo_magento2_afterpay>
<active>0</active>
<model>AfterpayOldFacade</model>
Expand Down Expand Up @@ -420,8 +444,8 @@
<can_capture_partial>1</can_capture_partial>
<available_in_backend>1</available_in_backend>
<send_mail>1</send_mail>
<payment_method>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,sepadirectdebit,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius</payment_method>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius</payment_method_after_expiry>
<payment_method>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,sepadirectdebit,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius,blik</payment_method>
<payment_method_after_expiry>amex,bancontactmrcash,cartebancaire,cartebleuevisa,nexi,postepay,dankort,eps,giftcard,giropay,ideal,mastercard,paypal,sofortueberweisung,transfer,visa,maestro,visaelectron,vpay,alipay,wechatpay,p24,trustly,belfius,blik</payment_method_after_expiry>
<expire_days>7</expire_days>
<cron_cancel_ppe>1</cron_cancel_ppe>
<can_authorize>0</can_authorize>
Expand Down
Loading

0 comments on commit 85f299b

Please sign in to comment.