10
10
use Magento \Sales \Model \Order \Payment ;
11
11
/**
12
12
* 2016-05-10
13
- * @see \Dfe\CheckoutCom\Handler\Charge\Captured::invoice()
14
- * @see \Dfe\CheckoutCom\Handler\Charge\Captured::process()
15
- * @see \Dfe\CheckoutCom\Handler\Charge\Refunded::process()
13
+ * @see \Dfe\CheckoutCom\Handler\Charge\Captured
14
+ * @see \Dfe\CheckoutCom\Handler\Charge\Refunded
15
+ * @see \Dfe\CheckoutCom\Handler\Charge\Voided
16
16
*/
17
17
abstract class Charge extends Handler {
18
18
/**
@@ -59,18 +59,15 @@ final protected function o() {return df_order($this->op());}
59
59
* @used-by \Dfe\CheckoutCom\Handler\Charge\Voided::process()
60
60
* @return Payment|DfPayment|null
61
61
*/
62
- final protected function op () {return dfc ($ this , function () {return
63
- $ this ->paymentByTxnId ($ this ->parentId ())
64
- ;});}
62
+ final protected function op () {return dfc ($ this , function () {return $ this ->paymentByTxnId ($ this ->parentId ());});}
65
63
66
64
/**
67
65
* 2016-03-26
68
66
* @param string|null $id
69
67
* @return Payment|DfPayment|null
70
68
*/
71
69
final protected function paymentByTxnId ($ id ) {return dfc ($ this , function ($ id ) {
72
- /** @var Payment|null $result */
73
- $ result = null ;
70
+ $ result = null ; /** @var Payment|null $result */
74
71
if ($ id ) {
75
72
/** @var int|null $paymentId */
76
73
$ paymentId = df_fetch_one ('sales_payment_transaction ' , 'payment_id ' , ['txn_id ' => $ id ]);
@@ -95,31 +92,31 @@ final protected function paymentByTxnId($id) {return dfc($this, function($id) {
95
92
* идентификатор транзакции, потому что метод
96
93
* @see \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation::capture()
97
94
* перетрёт наш идентификатор кодом:
98
- $payment->setTransactionId(
99
- $this->transactionManager->generateTransactionId(
100
- $payment,
101
- Transaction::TYPE_CAPTURE,
102
- $payment->getAuthorizationTransaction()
103
- )
104
- );
95
+ * $payment->setTransactionId(
96
+ * $this->transactionManager->generateTransactionId(
97
+ * $payment,
98
+ * Transaction::TYPE_CAPTURE,
99
+ * $payment->getAuthorizationTransaction()
100
+ * )
101
+ * );
105
102
* https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Operations/CaptureOperation.php#L40-L46
106
103
* Однако мне следовало посмотреть глубже, в реализацию метода
107
104
* @see \Magento\Sales\Model\Order\Payment\Transaction\Manager::generateTransactionId()
108
105
* чтобы понять, что когда нестандартный идентификатор транзакции уже установлен,
109
106
* то метод его не перетирает:
110
- if (!$payment->getParentTransactionId()
111
- && !$payment->getTransactionId() && $transactionBasedOn
112
- ) {
113
- $payment->setParentTransactionId($transactionBasedOn->getTxnId());
114
- }
115
- // generate transaction id for an offline action or payment method that didn't set it
116
- if (
117
- ($parentTxnId = $payment->getParentTransactionId())
118
- && !$payment->getTransactionId()
119
- ) {
120
- return "{$parentTxnId}-{$type}";
121
- }
122
- return $payment->getTransactionId();
107
+ * if (!$payment->getParentTransactionId()
108
+ * && !$payment->getTransactionId() && $transactionBasedOn
109
+ * ) {
110
+ * $payment->setParentTransactionId($transactionBasedOn->getTxnId());
111
+ * }
112
+ * // generate transaction id for an offline action or payment method that didn't set it
113
+ * if (
114
+ * ($parentTxnId = $payment->getParentTransactionId())
115
+ * && !$payment->getTransactionId()
116
+ * ) {
117
+ * return "{$parentTxnId}-{$type}";
118
+ * }
119
+ * return $payment->getTransactionId();
123
120
* https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L73-L80
124
121
* Поэтому никакие обходные манёвры нам не нужны,
125
122
* и смело устанвливаем транзакции наш нестандартный идентификатор прямо здесь.
0 commit comments