Skip to content

Commit a453841

Browse files
committed
BP-3684-Add-payment-method-Blik-Magento-2
1 parent dce5956 commit a453841

File tree

18 files changed

+604
-5
lines changed

18 files changed

+604
-5
lines changed

Block/Widget/Button/Toolbar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class Toolbar
6262
'buckaroo_magento2_wechatpay',
6363
'buckaroo_magento2_p24',
6464
'buckaroo_magento2_trustly',
65-
'buckaroo_magento2_pospayment'
65+
'buckaroo_magento2_pospayment',
66+
'buckaroo_magento2_blik',
6667
];
6768

6869
/**

Helper/Data.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ public function getPaymentMethodsList()
453453
['value' => 'transfer', 'label' => __('Bank Transfer')],
454454
['value' => 'trustly', 'label' => __('Trustly')],
455455
['value' => 'wechatpay', 'label' => __('WeChatPay')],
456+
['value' => 'blik', 'label' => __('Blik')],
456457
];
457458
}
458459

Model/Config/Source/PaymentMethods/AfterExpiry.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function toOptionArray()
5454
['value' => 'wechatpay', 'label' => __('WeChatPay')],
5555
['value' => 'p24', 'label' => __('P24')],
5656
['value' => 'trustly', 'label' => __('Trustly')],
57+
['value' => 'blik', 'label' => __('Blik')],
5758
];
5859

5960
return $options;

Model/Config/Source/PaymentMethods/PayLink.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function toOptionArray()
5454
['value' => 'wechatpay', 'label' => __('WeChatPay')],
5555
['value' => 'p24', 'label' => __('P24')],
5656
['value' => 'trustly', 'label' => __('Trustly')],
57+
['value' => 'blik', 'label' => __('Blik')],
5758
];
5859

5960
return $options;

Model/Config/Source/PaymentMethods/PayPerEmail.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ public function toOptionArray()
149149
'value' => 'trustly',
150150
'label' => __('Trustly'),
151151
'code' => 'buckaroo_magento2_trustly'
152+
],
153+
[
154+
'value' => 'blik',
155+
'label' => __('Blik'),
156+
'code' => 'buckaroo_magento2_blik'
152157
]
153158
];
154159

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* NOTICE OF LICENSE
4+
*
5+
* This source file is subject to the MIT License
6+
* It is available through the world-wide-web at this URL:
7+
* https://tldrlegal.com/license/mit-license
8+
* If you are unable to obtain it through the world-wide-web, please send an email
9+
* to support@buckaroo.nl so we can send you a copy immediately.
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this module to newer
14+
* versions in the future. If you wish to customize this module for your
15+
* needs please contact support@buckaroo.nl for more information.
16+
*
17+
* @copyright Copyright (c) Buckaroo B.V.
18+
* @license https://tldrlegal.com/license/mit-license
19+
*/
20+
21+
namespace Buckaroo\Magento2\Model\ConfigProvider\Method;
22+
23+
class Blik extends AbstractConfigProvider
24+
{
25+
const XPATH_BLIK_PAYMENT_FEE = 'payment/buckaroo_magento2_blik/payment_fee';
26+
const XPATH_BLIK_PAYMENT_FEE_LABEL = 'payment/buckaroo_magento2_blik/payment_fee_label';
27+
const XPATH_BLIK_ACTIVE = 'payment/buckaroo_magento2_blik/active';
28+
const XPATH_BLIK_SUBTEXT = 'payment/buckaroo_magento2_blik/subtext';
29+
const XPATH_BLIK_SUBTEXT_STYLE = 'payment/buckaroo_magento2_blik/subtext_style';
30+
const XPATH_BLIK_SUBTEXT_COLOR = 'payment/buckaroo_magento2_blik/subtext_color';
31+
const XPATH_BLIK_ACTIVE_STATUS = 'payment/buckaroo_magento2_blik/active_status';
32+
const XPATH_BLIK_ORDER_STATUS_SUCCESS = 'payment/buckaroo_magento2_blik/order_status_success';
33+
const XPATH_BLIK_ORDER_STATUS_FAILED = 'payment/buckaroo_magento2_blik/order_status_failed';
34+
const XPATH_BLIK_AVAILABLE_IN_BACKEND = 'payment/buckaroo_magento2_blik/available_in_backend';
35+
36+
const XPATH_ALLOWED_CURRENCIES = 'payment/buckaroo_magento2_blik/allowed_currencies';
37+
38+
const XPATH_ALLOW_SPECIFIC = 'payment/buckaroo_magento2_blik/allowspecific';
39+
const XPATH_SPECIFIC_COUNTRY = 'payment/buckaroo_magento2_blik/specificcountry';
40+
const XPATH_SPECIFIC_CUSTOMER_GROUP = 'payment/buckaroo_magento2_blik/specificcustomergroup';
41+
42+
/**
43+
* @var array
44+
*/
45+
protected $allowedCurrencies = [
46+
'PLN'
47+
];
48+
/**
49+
* @return array|void
50+
*/
51+
public function getConfig()
52+
{
53+
$paymentFeeLabel = $this->getBuckarooPaymentFeeLabel(
54+
\Buckaroo\Magento2\Model\Method\Blik::PAYMENT_METHOD_CODE
55+
);
56+
57+
return [
58+
'payment' => [
59+
'buckaroo' => [
60+
'blik' => [
61+
'paymentFeeLabel' => $paymentFeeLabel,
62+
'subtext' => $this->getSubtext(),
63+
'subtext_style' => $this->getSubtextStyle(),
64+
'subtext_color' => $this->getSubtextColor(),
65+
'allowedCurrencies' => $this->getAllowedCurrencies(),
66+
],
67+
],
68+
],
69+
];
70+
}
71+
72+
/**
73+
* @param null|int $storeId
74+
*
75+
* @return float
76+
*/
77+
public function getPaymentFee($storeId = null)
78+
{
79+
$paymentFee = $this->scopeConfig->getValue(
80+
self::XPATH_BLIK_PAYMENT_FEE,
81+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
82+
$storeId
83+
);
84+
85+
return $paymentFee ? $paymentFee : false;
86+
}
87+
}

Model/Method/Blik.php

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* NOTICE OF LICENSE
4+
*
5+
* This source file is subject to the MIT License
6+
* It is available through the world-wide-web at this URL:
7+
* https://tldrlegal.com/license/mit-license
8+
* If you are unable to obtain it through the world-wide-web, please send an email
9+
* to support@buckaroo.nl so we can send you a copy immediately.
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this module to newer
14+
* versions in the future. If you wish to customize this module for your
15+
* needs please contact support@buckaroo.nl for more information.
16+
*
17+
* @copyright Copyright (c) Buckaroo B.V.
18+
* @license https://tldrlegal.com/license/mit-license
19+
*/
20+
21+
namespace Buckaroo\Magento2\Model\Method;
22+
23+
class Blik extends AbstractMethod
24+
{
25+
/**
26+
* Payment Code
27+
*/
28+
const PAYMENT_METHOD_CODE = 'buckaroo_magento2_blik';
29+
30+
/**
31+
* @var string
32+
*/
33+
public $buckarooPaymentMethodCode = 'blik';
34+
35+
/**
36+
* Payment method code
37+
*
38+
* @var string
39+
*/
40+
protected $_code = self::PAYMENT_METHOD_CODE;
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function getOrderTransactionBuilder($payment)
46+
{
47+
$transactionBuilder = $this->transactionBuilderFactory->get('order');
48+
49+
$services = [
50+
'Name' => 'blik',
51+
'Action' => 'Pay',
52+
'Version' => 0,
53+
];
54+
55+
/**
56+
* @noinspection PhpUndefinedMethodInspection
57+
*/
58+
$transactionBuilder->setOrder($payment->getOrder())
59+
->setServices($services)
60+
->setMethod('TransactionRequest');
61+
62+
return $transactionBuilder;
63+
}
64+
65+
/**
66+
* {@inheritdoc}
67+
*/
68+
public function getCaptureTransactionBuilder($payment)
69+
{
70+
return false;
71+
}
72+
73+
/**
74+
* {@inheritdoc}
75+
*/
76+
public function getAuthorizeTransactionBuilder($payment)
77+
{
78+
return false;
79+
}
80+
81+
/**
82+
* {@inheritdoc}
83+
*/
84+
public function getVoidTransactionBuilder($payment)
85+
{
86+
return true;
87+
}
88+
89+
/**
90+
* @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment
91+
*
92+
* @return bool|string
93+
*/
94+
public function getPaymentMethodName($payment)
95+
{
96+
return 'blik';
97+
}
98+
}

etc/adminhtml/system/payment_methods.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,8 @@
118118

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

121+
<include path="Buckaroo_Magento2::system/payment_methods/blik.xml"/>
122+
123+
121124
</group>
122125
</include>

0 commit comments

Comments
 (0)