![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-sales/Model/Order/Payment/Operations/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Sales\Model\Order\Payment\Operations; use Magento\Sales\Api\Data\OrderPaymentInterface; use Magento\Sales\Model\Order; use Magento\Sales\Model\Order\Payment; use Magento\Sales\Model\Order\Payment\Transaction; class AuthorizeOperation extends AbstractOperation { /** * Authorizes payment. * * @param OrderPaymentInterface $payment * @param bool $isOnline * @param string|float $amount * @return OrderPaymentInterface */ public function authorize(OrderPaymentInterface $payment, $isOnline, $amount) { // check for authorization amount to be equal to grand total /** * @var $payment Payment */ $payment->setShouldCloseParentTransaction(false); $isSameCurrency = $payment->isSameCurrency(); if (!$isSameCurrency || !$payment->isCaptureFinal($amount)) { $payment->setIsFraudDetected(true); } // update totals $amount = $payment->formatAmount($amount, true); $payment->setBaseAmountAuthorized($amount); // do authorization $order = $payment->getOrder(); if ($isOnline) { // invoke authorization on gateway $method = $payment->getMethodInstance(); $method->setStore($order->getStoreId()); $method->authorize($payment, $amount); } $message = $this->stateCommand->execute($payment, $amount, $order); // update transactions, order state and add comments $transaction = $payment->addTransaction(Transaction::TYPE_AUTH); $message = $payment->prependMessage($message); $payment->addTransactionCommentsToOrder($transaction, $message); return $payment; } }