Open LuizSantos22 opened 3 months ago
CORREÇÃO MOMENTÂNEA DO ERRO (ainda estou testando para verificar se essa correção não afetará o funcionamento do módulo da Yapay):
Faça uma cópia e guarde como backup do arquivo em: app/code/community/Tray/CheckoutApi/Block/Onepage/Success.php
Edite "Success.php" e use a função control + "F" para procurar este linha:
protected function getPayment()
Dessa linha pra baixo, substitua por este código:
`protected function getPayment() { $standard = null; // Initialize the $standard variable
$quote_id = Mage::getSingleton('checkout/session')->getData('last_quote_id');
$quote = Mage::getModel('sales/quote')->load($quote_id);
switch ($quote->getPayment()->getData('method')) {
case 'traycheckoutapi_bankslip':
$standard = Mage::getModel('checkoutapi/bankslip');
break;
case 'traycheckoutapi':
$standard = Mage::getModel('checkoutapi/standard');
break;
case 'traycheckoutapi_onlinetransfer':
$standard = Mage::getModel('checkoutapi/onlinetransfer');
break;
case 'traycheckoutapi_pix':
$standard = Mage::getModel('checkoutapi/pix');
break;
}
if($standard == null)
{
$this->wasPaidWithYapay = false;
return false;
} else {
$this->wasPaidWithYapay = true;
}
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
if ($order->getStatus() == "pending" || $order->getStatus() == "pending_payment") {
$response = $standard->getTrayCheckoutRequest("/v2/transactions/pay_complete", $standard->getCheckoutFormFields());
$xml = simplexml_load_string($response);
$this->order_number = str_replace($standard->getConfigData('prefixo'), '', $xml->data_response->transaction->order_number);
$this->order_number_tc = $xml->data_response->transaction->order_number;
$this->transaction_id = $xml->data_response->transaction->transaction_id;
$this->url_payment = $xml->data_response->transaction->payment->url_payment;
$this->typeful_line = $xml->data_response->transaction->payment->linha_digitavel;
$this->qrcode_path = $xml->data_response->transaction->payment->qrcode_path;
$this->qrcode_original_path = $xml->data_response->transaction->payment->qrcode_original_path;
$this->payment_response = $xml->data_response->transaction->payment->payment_response;
$this->status_id = $xml->data_response->transaction->status_id;
$this->status_name = $xml->data_response->transaction->status_name;
$this->payment_method_name = $xml->data_response->transaction->payment->payment_method_name;
$this->payment_method_id = $xml->data_response->transaction->payment->payment_method_id;
$this->token_account = $standard->getConfigData('token');
$this->environment = $standard->getConfigData('sandbox');
$standard->updateTransactionTrayCheckout($xml->data_response->transaction);
echo '';
}
}
`
Explicação: Ao definir $standard como "null" por padrão, ele evita o erro mencionado acima, pois caso nenhuma das opções do módulo da Yapay seja selecionada (por exemplo, o cliente escolhe outro meio de pagamento), o $standard não aparece como "undefined" (indefinido), evitando o erro.
Ambiente: Testes Versão PHP 7.4 (ocorre em outras versões também) Plataforma Instalada: OpenMage 19.5.0 (ocorre com outras versões também) Checkout OneStepCheckout Moip 2.0.3 (versão anterior à atual aqui no Github)
Erro: `Notice: Undefined variable: standard in app/code/community/Tray/CheckoutApi/Block/Onepage/Success.php on line 117
0 app/code/community/Tray/CheckoutApi/Block/Onepage/Success.php(117): mageCoreErrorHandler(8, 'Undefined varia...', '/home/ultraele/...', 117, Array)
1 app/design/frontend/base/default/template/tray/checkoutapi/success.phtml(21): Tray_CheckoutApi_Block_Onepage_Success->getPayment()
2 app/code/core/Mage/Core/Block/Template.php(257): include('/home/ultraele/...')
3 app/code/core/Mage/Core/Block/Template.php(294): Mage_Core_Block_Template->fetchView('frontend/base/d...')
4 app/code/core/Mage/Core/Block/Template.php(307): Mage_Core_Block_Template->renderView()
5 app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Core_Block_Template->_toHtml()
6 app/code/core/Mage/Core/Block/Text/List.php(42): Mage_Core_Block_Abstract->toHtml()
7 app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Core_Block_Text_List->_toHtml()
8 app/code/core/Mage/Core/Block/Abstract.php(650): Mage_Core_Block_Abstract->toHtml()
9 app/code/core/Mage/Core/Block/Abstract.php(594): Mage_Core_Block_Abstract->_getChildHtml('content', true)
10 app/design/frontend/ultimo/default/template/page/2columns-right.phtml(34): Mage_Core_Block_Abstract->getChildHtml('content')
11 app/code/core/Mage/Core/Block/Template.php(257): include('/home/...')
12 app/code/core/Mage/Core/Block/Template.php(294): Mage_Core_Block_Template->fetchView('frontend/ultimo...')
13 app/code/core/Mage/Core/Block/Template.php(307): Mage_Core_Block_Template->renderView()
14 app/code/core/Mage/Core/Block/Abstract.php(933): Mage_Core_Block_Template->_toHtml()
15 app/code/core/Mage/Core/Model/Layout.php(580): Mage_Core_Block_Abstract->toHtml()
16 app/code/core/Mage/Core/Controller/Varien/Action.php(397): Mage_Core_Model_Layout->getOutput()
17 app/code/core/Mage/Checkout/controllers/OnepageController.php(291): Mage_Core_Controller_Varien_Action->renderLayout()
18 app/code/core/Mage/Core/Controller/Varien/Action.php(428): Mage_Checkout_OnepageController->successAction()
19 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(262): Mage_Core_Controller_Varien_Action->dispatch('success')
20 app/code/core/Mage/Core/Controller/Varien/Front.php(188): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
21 app/code/core/Mage/Core/Model/App.php(371): Mage_Core_Controller_Varien_Front->dispatch()
22 app/Mage.php(748): Mage_Core_Model_App->run(Array)
23 index.php(64): Mage::run('', 'store')
24 {main}`