Repository navigation
Expand file tree
/
Copy pathMethod.php
More file actions
173 lines (167 loc) · 7.95 KB
/
Copy pathMethod.php
File metadata and controls
173 lines (167 loc) · 7.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
namespace CanadaSatellite\Bambora;
use CanadaSatellite\Bambora\Action\Authorize;
use CanadaSatellite\Bambora\Action\Capture;
use CanadaSatellite\Bambora\Action\Refund;
use CanadaSatellite\Bambora\Action\_Void;
use Magento\Framework\DataObject as _DO;
use Magento\Framework\Exception\LocalizedException as LE;
use Magento\Framework\ObjectManager\NoninterceptableInterface as INonInterceptable;
use Magento\Payment\Model\Info as I;
use Magento\Payment\Model\InfoInterface as II;
use Magento\Quote\Api\Data\CartInterface as ICart;
use Magento\Quote\Model\Quote as Q;
use Magento\Quote\Model\Quote\Payment as QP;
use Magento\Sales\Model\Order\Payment as OP;
# 2021-06-27 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
# "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
final class Method extends \Magento\Payment\Model\Method\Cc implements INonInterceptable {
const CODE = 'beanstream';
protected $_code = self::CODE;
protected $_isGateway = true;
protected $_canAuthorize = true;
protected $_canCapture = true;
protected $_canCapturePartial = false;
protected $_canRefund = true;
protected $_canRefundInvoicePartial = true;
protected $_canVoid = true;
protected $_canUseInternal = true;
protected $_canUseCheckout = true;
protected $_canUseForMultishipping = true;
protected $_canSaveCc = false;
protected $_canOrder = false;
/**
* 2021-06-27 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* @override
* @see \Magento\Payment\Model\MethodInterface::authorize()
* @used-by \Magento\Sales\Model\Order\Payment\Operations\AuthorizeOperation::authorize()
* https://github.com/magento/magento2/blob/2.1.5/app/code/Magento/Sales/Model/Order/Payment/Operations/AuthorizeOperation.php#L45
* 2021-07-01
* $a is a string because it is a result of the @see \Magento\Sales\Model\Order\Payment::formatAmount() call:
* $amount = $payment->formatAmount($amount, true);
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment/Operations/AuthorizeOperation.php#L36
* @param II|I|OP $i
* @param string|float $a
* @return $this
* @throws LE
*/
function authorize(II $i, $a) {
Authorize::s($this)->p($a);
return $this;
}
/**
* 2021-06-27 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* @override
* @see \Magento\Payment\Model\MethodInterface::capture()
* @used-by \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation::capture():
* $method->capture($payment, $amountToCapture);
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment/Operations/CaptureOperation.php#L82
* 2021-07-01
* $a is a string because it is a result of the @see \Magento\Sales\Model\Order\Payment::formatAmount() call:
* $amountToCapture = $payment->formatAmount($invoice->getBaseGrandTotal());
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment/Operations/CaptureOperation.php#L37
* @param II|I|OP $i
* @param string|float $a
* @return $this
* @throws LE
*/
function capture(II $i, $a) {
Capture::s($this)->p($a);
return $this;
}
/**
* 2021-06-27 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* @override
* @see \Magento\Payment\Model\MethodInterface::isAvailable()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/MethodInterface.php#L343-L350
* @see \Magento\Payment\Model\Method\AbstractMethod::isAvailable()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/Method/AbstractMethod.php#L805-L825
* @used-by \Magento\Payment\Block\Form\Container::getMethods()
* @used-by \Magento\Payment\Helper\Data::getStoreMethods()
* @used-by \Magento\Payment\Model\MethodList::getAvailableMethods()
* @used-by \Magento\Quote\Model\Quote\Payment::importData()
* @used-by \Magento\Sales\Model\AdminOrder\Create::_validate()
* @param ICart|Q|null $q
* @return array|bool|mixed|null
*/
function isAvailable(ICart $q = null) {/** @var bool $r */
if ($r = $this->isActive($q ? $q->getStoreId() : null)) {
df_dispatch('payment_method_is_active', ['method_instance' => $this, 'quote' => $q,
'result' => ($evR = new _DO(['is_available' => true])) /** @var _DO $evR */
]);
$r = $evR['is_available'];
}
return $r;
}
/**
* 2021-06-28 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* 2021-07-02
* $a is a string because it is a result of the @see \Magento\Sales\Model\Order\Payment::formatAmount() call:
* $baseAmountToRefund = $this->formatAmount($creditmemo->getBaseGrandTotal());
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment.php#L655
* @override
* @see \Magento\Payment\Model\MethodInterface::refund()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/MethodInterface.php#L269-L277
* @see \Magento\Payment\Model\Method\AbstractMethod::refund()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/Method/AbstractMethod.php#L640-L656
* @used-by \Magento\Sales\Model\Order\Payment::refund()
* $gateway->refund($this, $baseAmountToRefund);
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment.php#L684
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/Order/Payment.php#L701
* @param II|I|OP $payment
* @param string|float $a
* @return $this
*/
function refund(II $i, $a) {
Refund::s($this)->p($a);
return $this;
}
/**
* 2021-06-28 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* @override
* How is a payment method's validate() used? https://mage2.pro/t/698
* @see \Magento\Payment\Model\MethodInterface::validate()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/MethodInterface.php#L230-L237
* @see \Magento\Payment\Model\Method\AbstractMethod::validate()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/Method/AbstractMethod.php#L566-L583
* @used-by \Magento\Quote\Model\Quote\Payment::importData()
* $method->validate();
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Quote/Model/Quote/Payment.php#L202
* @used-by \Magento\Sales\Model\AdminOrder\Create::_validate()
* $method->validate();
* https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Sales/Model/AdminOrder/Create.php#L2012
* @used-by \Magento\Sales\Model\Order\Payment::place()
* $methodInstance->validate();
* @return $this
* @throws LE
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
function validate() {
$i = $this->getInfoInstance(); /** @var QP $i */
$i->setCcNumber($n = preg_replace('/[\-\s]+/', '', $i->getCcNumber()));
$i->setCcType(BankCardNetworkDetector::p($n));
return parent::validate();
}
/**
* 2021-06-28 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
* "Refactor the `Schogini_Beanstream` module": https://github.com/canadasatellite-ca/bambora/issues/1
* @override
* @see \Magento\Payment\Model\MethodInterface::void()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/MethodInterface.php#L288-L295
* @see \Magento\Payment\Model\Method\AbstractMethod::void()
* https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Payment/Model/Method/AbstractMethod.php#L671-L686
* @param II|I|OP $i
* @return $this
* @uses _void()
*/
function void(II $i) {
_Void::s($this)->p();
return $this;
}
}