Version Notes
- Consulta de Id da transação Bcash na tabela Quote
Download this release
Release Info
Developer | Bcash |
Extension | Bcash_Pagamento |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.5
- app/code/community/Bcash/Pagamento/Helper/Transaction.php +35 -10
- app/code/community/Bcash/Pagamento/Model/Observer.php +2 -1
- app/code/community/Bcash/Pagamento/controllers/NotificationController.php +130 -70
- app/code/community/Bcash/Pagamento/etc/config.xml +4 -4
- app/code/community/Bcash/Pagamento/sql/pagamento_setup/{mysql4-upgrade-0.1.0-1.2.2.php → mysql4-upgrade-0.1.0-1.2.5.php} +1 -1
- package.xml +5 -5
app/code/community/Bcash/Pagamento/Helper/Transaction.php
CHANGED
@@ -50,6 +50,10 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
50 |
* @var
|
51 |
*/
|
52 |
private $itemsBcash;
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* @var
|
55 |
*/
|
@@ -139,7 +143,8 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
139 |
//$shippingHandling = floatval($this->grandTotalBcash -$this->subTotalBcash);
|
140 |
$this->billingDataBcash = $this->quoteBcash->getBillingAddress()->getData();
|
141 |
$this->quoteIdTransaction = (str_pad($quoteId, 9, 0, STR_PAD_LEFT));
|
142 |
-
|
|
|
143 |
$this->cards = array(PaymentMethodEnum::VISA, PaymentMethodEnum::MASTERCARD, PaymentMethodEnum::AMERICAN_EXPRESS, PaymentMethodEnum::AURA, PaymentMethodEnum::DINERS, PaymentMethodEnum::HIPERCARD, PaymentMethodEnum::ELO);
|
144 |
$this->boleto = PaymentMethodEnum::BANK_SLIP;
|
145 |
$this->tefs = array(PaymentMethodEnum::BB_ONLINE_TRANSFER, PaymentMethodEnum::BRADESCO_ONLINE_TRANSFER, PaymentMethodEnum::ITAU_ONLINE_TRANSFER, PaymentMethodEnum::BANRISUL_ONLINE_TRANSFER, PaymentMethodEnum::HSBC_ONLINE_TRANSFER);
|
@@ -154,14 +159,15 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
154 |
*/
|
155 |
public function startTransaction()
|
156 |
{
|
157 |
-
$this->transactionRequest = $this->createTransactionRequestBcash();
|
158 |
-
$this->setShippingBcash();
|
159 |
-
$this->setPaymentMethodBcash();
|
160 |
-
$payment = new Payment($this->consumer_key);
|
161 |
-
if ($this->sandbox) {
|
162 |
-
$payment->enableSandBox(true);
|
163 |
-
}
|
164 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
$response = $payment->create($this->transactionRequest);
|
166 |
|
167 |
$arRet = array(
|
@@ -199,6 +205,9 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
199 |
$messages .= "\n- " . urldecode($err->description) . " (" . $err->code . ")";
|
200 |
}
|
201 |
Mage::throwException($messages);
|
|
|
|
|
|
|
202 |
}
|
203 |
}
|
204 |
|
@@ -347,7 +356,7 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
347 |
public function createProductBcash()
|
348 |
{
|
349 |
$products = array();
|
350 |
-
foreach ($this->
|
351 |
$price = $item->getPrice();
|
352 |
if ($price > 0) {
|
353 |
$product = new Product();
|
@@ -357,9 +366,10 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
357 |
$product->setDescription($name);
|
358 |
$qty = $item->getQty();
|
359 |
$product->setAmount(intval($qty));
|
360 |
-
$product->setValue(floatval($price));
|
361 |
array_push($products, $product);
|
362 |
}
|
|
|
363 |
}
|
364 |
return $products;
|
365 |
}
|
@@ -491,4 +501,19 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
|
491 |
}
|
492 |
return $state;
|
493 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
50 |
* @var
|
51 |
*/
|
52 |
private $itemsBcash;
|
53 |
+
/**
|
54 |
+
* @var
|
55 |
+
*/
|
56 |
+
private $quoteAllVisibleItems;
|
57 |
/**
|
58 |
* @var
|
59 |
*/
|
143 |
//$shippingHandling = floatval($this->grandTotalBcash -$this->subTotalBcash);
|
144 |
$this->billingDataBcash = $this->quoteBcash->getBillingAddress()->getData();
|
145 |
$this->quoteIdTransaction = (str_pad($quoteId, 9, 0, STR_PAD_LEFT));
|
146 |
+
//$this->itemsBcash = $this->quoteBcash->getItemsCollection()->getItems();
|
147 |
+
$this->quoteAllVisibleItems = $this->loadAllVisibleItemsOnCart($this->quoteBcash);
|
148 |
$this->cards = array(PaymentMethodEnum::VISA, PaymentMethodEnum::MASTERCARD, PaymentMethodEnum::AMERICAN_EXPRESS, PaymentMethodEnum::AURA, PaymentMethodEnum::DINERS, PaymentMethodEnum::HIPERCARD, PaymentMethodEnum::ELO);
|
149 |
$this->boleto = PaymentMethodEnum::BANK_SLIP;
|
150 |
$this->tefs = array(PaymentMethodEnum::BB_ONLINE_TRANSFER, PaymentMethodEnum::BRADESCO_ONLINE_TRANSFER, PaymentMethodEnum::ITAU_ONLINE_TRANSFER, PaymentMethodEnum::BANRISUL_ONLINE_TRANSFER, PaymentMethodEnum::HSBC_ONLINE_TRANSFER);
|
159 |
*/
|
160 |
public function startTransaction()
|
161 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
try {
|
163 |
+
$this->transactionRequest = $this->createTransactionRequestBcash();
|
164 |
+
$this->setShippingBcash();
|
165 |
+
$this->setPaymentMethodBcash();
|
166 |
+
$payment = new Payment($this->consumer_key);
|
167 |
+
if ($this->sandbox) {
|
168 |
+
$payment->enableSandBox(true);
|
169 |
+
}
|
170 |
+
|
171 |
$response = $payment->create($this->transactionRequest);
|
172 |
|
173 |
$arRet = array(
|
205 |
$messages .= "\n- " . urldecode($err->description) . " (" . $err->code . ")";
|
206 |
}
|
207 |
Mage::throwException($messages);
|
208 |
+
} catch (Exception $e) {
|
209 |
+
Mage::helper("bcash")->saveLog($e->getMessage());
|
210 |
+
Mage::throwException($e->getMessage());
|
211 |
}
|
212 |
}
|
213 |
|
356 |
public function createProductBcash()
|
357 |
{
|
358 |
$products = array();
|
359 |
+
foreach ($this->quoteAllVisibleItems as $item) {
|
360 |
$price = $item->getPrice();
|
361 |
if ($price > 0) {
|
362 |
$product = new Product();
|
366 |
$product->setDescription($name);
|
367 |
$qty = $item->getQty();
|
368 |
$product->setAmount(intval($qty));
|
369 |
+
$product->setValue(floatval(number_format($price, 2, '.', '')));
|
370 |
array_push($products, $product);
|
371 |
}
|
372 |
+
|
373 |
}
|
374 |
return $products;
|
375 |
}
|
501 |
}
|
502 |
return $state;
|
503 |
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Retorna todos os itens que não estão marcados como apagado e não tem pai
|
507 |
+
* (ou seja, retornará itens de produtos do tipo bundled e configurable, mas não os produtos associados a eles).
|
508 |
+
* Cada item do array corresponde a uma linha exibida na página do carrinho.
|
509 |
+
*
|
510 |
+
* @param $quote
|
511 |
+
* @return mixed
|
512 |
+
*/
|
513 |
+
private function loadAllVisibleItemsOnCart($quote)
|
514 |
+
{
|
515 |
+
$items = $quote->getAllVisibleItems();
|
516 |
+
|
517 |
+
return $items;
|
518 |
+
}
|
519 |
}
|
app/code/community/Bcash/Pagamento/Model/Observer.php
CHANGED
@@ -90,7 +90,8 @@ class Bcash_Pagamento_Model_Observer
|
|
90 |
$block->setType($type);
|
91 |
$layout->getBlock('content')->append($block);
|
92 |
|
93 |
-
|
|
|
94 |
} catch (Exception $e) {
|
95 |
Mage::helper("bcash")->saveLog($e->getMessage());
|
96 |
}
|
90 |
$block->setType($type);
|
91 |
$layout->getBlock('content')->append($block);
|
92 |
|
93 |
+
$bcashTransacation = $order->getTransactionIdBcash();
|
94 |
+
Mage::helper("bcash")->saveLog("Pedido '" . $lastOrderId . "' realizado com sucesso. Transacao: " . $bcashTransacation);
|
95 |
} catch (Exception $e) {
|
96 |
Mage::helper("bcash")->saveLog($e->getMessage());
|
97 |
}
|
app/code/community/Bcash/Pagamento/controllers/NotificationController.php
CHANGED
@@ -25,7 +25,7 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
25 |
protected function _construct()
|
26 |
{
|
27 |
// access log (debug)
|
28 |
-
Mage::helper("bcash")->saveLog('Notification visitor: ' . Mage::helper('core/http')->getRemoteAddr());
|
29 |
|
30 |
$this->email = Mage::getStoreConfig('payment/bcash/email');
|
31 |
$this->token = Mage::getStoreConfig('payment/bcash/token');
|
@@ -37,14 +37,14 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
37 |
*/
|
38 |
public function indexAction()
|
39 |
{
|
40 |
-
if($this->sandbox) {
|
41 |
// Get request
|
42 |
$transactionId = Mage::app()->getRequest()->getParam('transactionId');
|
43 |
$orderId = trim(stripslashes(Mage::app()->getRequest()->getParam('orderId')));
|
44 |
$statusId = (int)Mage::app()->getRequest()->getParam('statusId');
|
45 |
|
46 |
// Notification Simulator
|
47 |
-
$urlSubmit = Mage::getUrl('bcash/notification/index',array('_secure'=>true));
|
48 |
echo "<h1>Bcash Notification Simulator</h1>
|
49 |
<form method='GET' action='" . $urlSubmit . "'>
|
50 |
<label>Nro. Pedido:</label>
|
@@ -64,15 +64,15 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
64 |
<input type='submit' value='Enviar'/>
|
65 |
</form>";
|
66 |
|
67 |
-
if(!empty($transactionId) && !empty($statusId) && !empty($orderId)) {
|
68 |
-
$urlSimulator = Mage::getUrl('bcash/notification/request',array('_secure'=>true));
|
69 |
$returnSimulator = $this->notificationSimulator($urlSimulator, $transactionId, $orderId, $statusId);
|
70 |
echo "<h2>Retorno:</h2> <div style='clear:both;'></div><pre style='background-color: #EAEAEA; padding:20px;'>";
|
71 |
var_dump($returnSimulator);
|
72 |
echo "</pre>";
|
73 |
}
|
74 |
echo "<div style='clear:both;'><div style='float: right;margin-top: 20px; font-size: 12px;'>hostSandBox: " . Config::hostSandBox . "</div>";
|
75 |
-
}else {
|
76 |
echo "Habilite o Sandbox para simular notificações pelo Bcash.";
|
77 |
}
|
78 |
}
|
@@ -96,6 +96,9 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
96 |
$notification->enableSandBox($this->sandbox);
|
97 |
|
98 |
try {
|
|
|
|
|
|
|
99 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
100 |
if ($order->getData() != null) {
|
101 |
// Checa requisição válida através de valor total do pedido (valor dos produtos + frete + acréscimo - desconto)
|
@@ -103,17 +106,24 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
103 |
$validNotification = $notification->verify($transactionValue);
|
104 |
|
105 |
if ($validNotification == true) {
|
106 |
-
//
|
107 |
-
$
|
108 |
-
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
114 |
}
|
115 |
} else {
|
116 |
-
Mage::helper("bcash")->saveLog("Atencao!!! Pedido " . $orderId . " nao
|
117 |
}
|
118 |
} catch (ValidationException $e) {
|
119 |
Mage::helper("bcash")->saveLog("Validation error - NotificationController->requestAction: " . $e->getMessage(), $e->getErrors());
|
@@ -140,84 +150,92 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
140 |
|
141 |
switch ($statusId) {
|
142 |
case NotificationStatusEnum::APPROVED:
|
143 |
-
|
144 |
$BaseGrandtotal = $order->getBaseGrandTotal();
|
145 |
$payment = $order->getPayment();
|
146 |
$payment->setTransactionId($transactionId)
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
$order->save();
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
break;
|
159 |
case NotificationStatusEnum::IN_PROGRESS:
|
|
|
160 |
$payment = $order->getPayment();
|
161 |
$payment->setTransactionId($transactionId);
|
162 |
$payment->setIsTransactionClosed(0);
|
163 |
-
$payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('Status'=>'Em andamento'));
|
164 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
break;
|
172 |
case NotificationStatusEnum::CANCELLED:
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
break;
|
183 |
case NotificationStatusEnum::IN_DISPUTE:
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
break;
|
198 |
case NotificationStatusEnum::CHARGEBACK:
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
break;
|
213 |
case NotificationStatusEnum::REFUNDED:
|
214 |
-
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
break;
|
222 |
default:
|
223 |
$order->addStatusHistoryComment('Notificação da transação ' . $transactionId . ' sem ação identificada para o status ' . $statusId);
|
@@ -229,6 +247,48 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
|
|
229 |
Mage::helper('bcash')->updateOrderSyncBcashDataWithQuote($orderId, $quoteId);
|
230 |
}
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
/**
|
233 |
* Simulação de notificação enviada pelo Bcash na URL de retorno
|
234 |
*
|
25 |
protected function _construct()
|
26 |
{
|
27 |
// access log (debug)
|
28 |
+
Mage::helper("bcash")->saveLog('Step 1 - Notification visitor: ' . Mage::helper('core/http')->getRemoteAddr());
|
29 |
|
30 |
$this->email = Mage::getStoreConfig('payment/bcash/email');
|
31 |
$this->token = Mage::getStoreConfig('payment/bcash/token');
|
37 |
*/
|
38 |
public function indexAction()
|
39 |
{
|
40 |
+
if ($this->sandbox) {
|
41 |
// Get request
|
42 |
$transactionId = Mage::app()->getRequest()->getParam('transactionId');
|
43 |
$orderId = trim(stripslashes(Mage::app()->getRequest()->getParam('orderId')));
|
44 |
$statusId = (int)Mage::app()->getRequest()->getParam('statusId');
|
45 |
|
46 |
// Notification Simulator
|
47 |
+
$urlSubmit = Mage::getUrl('bcash/notification/index', array('_secure' => true));
|
48 |
echo "<h1>Bcash Notification Simulator</h1>
|
49 |
<form method='GET' action='" . $urlSubmit . "'>
|
50 |
<label>Nro. Pedido:</label>
|
64 |
<input type='submit' value='Enviar'/>
|
65 |
</form>";
|
66 |
|
67 |
+
if (!empty($transactionId) && !empty($statusId) && !empty($orderId)) {
|
68 |
+
$urlSimulator = Mage::getUrl('bcash/notification/request', array('_secure' => true));
|
69 |
$returnSimulator = $this->notificationSimulator($urlSimulator, $transactionId, $orderId, $statusId);
|
70 |
echo "<h2>Retorno:</h2> <div style='clear:both;'></div><pre style='background-color: #EAEAEA; padding:20px;'>";
|
71 |
var_dump($returnSimulator);
|
72 |
echo "</pre>";
|
73 |
}
|
74 |
echo "<div style='clear:both;'><div style='float: right;margin-top: 20px; font-size: 12px;'>hostSandBox: " . Config::hostSandBox . "</div>";
|
75 |
+
} else {
|
76 |
echo "Habilite o Sandbox para simular notificações pelo Bcash.";
|
77 |
}
|
78 |
}
|
96 |
$notification->enableSandBox($this->sandbox);
|
97 |
|
98 |
try {
|
99 |
+
// Request log
|
100 |
+
Mage::helper("bcash")->saveLog('Step 2 - Informacoes da requisicao recebida: {transacao_id: ' . $transactionId . ', pedido: ' . $orderId . ', status_id: ' . $statusId . ', status: ' . $status . '}');
|
101 |
+
|
102 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
103 |
if ($order->getData() != null) {
|
104 |
// Checa requisição válida através de valor total do pedido (valor dos produtos + frete + acréscimo - desconto)
|
106 |
$validNotification = $notification->verify($transactionValue);
|
107 |
|
108 |
if ($validNotification == true) {
|
109 |
+
// Checa se o código da transação está relacionado com o pedido
|
110 |
+
if ($this->isValidTransactionForOrder($order, $transactionId)) {
|
111 |
+
Mage::helper("bcash")->saveLog("Step 3 - Notificacao pode ser processada no pedido.");
|
112 |
+
|
113 |
+
// Registro de notificação recebida
|
114 |
+
$order->addStatusHistoryComment('Notificação da transação de pagamento recebida. Status: ' . $status);
|
115 |
+
$order->save();
|
116 |
|
117 |
+
// Processamento da notificação no pedido
|
118 |
+
$this->processNotification($transactionId, $orderId, $statusId);
|
119 |
+
} else {
|
120 |
+
Mage::helper("bcash")->saveLog("Step 3 - A transacao recebida nao esta relacionada com o pedido e nao sera processada.");
|
121 |
+
}
|
122 |
+
} else {
|
123 |
+
Mage::helper("bcash")->saveLog("Step 3 - Notificacao invalida recebida.");
|
124 |
}
|
125 |
} else {
|
126 |
+
Mage::helper("bcash")->saveLog("Step 3 - Atencao!!! Pedido " . $orderId . " nao encontrado. ");
|
127 |
}
|
128 |
} catch (ValidationException $e) {
|
129 |
Mage::helper("bcash")->saveLog("Validation error - NotificationController->requestAction: " . $e->getMessage(), $e->getErrors());
|
150 |
|
151 |
switch ($statusId) {
|
152 |
case NotificationStatusEnum::APPROVED:
|
153 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
154 |
$BaseGrandtotal = $order->getBaseGrandTotal();
|
155 |
$payment = $order->getPayment();
|
156 |
$payment->setTransactionId($transactionId)
|
157 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
158 |
+
->setPreparedMessage("Pagamento aprovado.")
|
159 |
+
->setIsTransactionClosed(1)
|
160 |
+
->registerCaptureNotification($BaseGrandtotal);
|
161 |
$order->save();
|
162 |
+
}
|
163 |
+
// Atualiza status na transação
|
164 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
165 |
+
$quote->setStatusBcash($statusId)
|
166 |
+
->setDescriptionStatusBcash("Aprovada");
|
167 |
+
$quote->save();
|
168 |
+
break;
|
169 |
+
case NotificationStatusEnum::COMPLETED:
|
170 |
+
// Atualiza status na transação
|
171 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
172 |
+
$quote->setStatusBcash($statusId)
|
173 |
+
->setDescriptionStatusBcash("Concluída");
|
174 |
+
$quote->save();
|
175 |
break;
|
176 |
case NotificationStatusEnum::IN_PROGRESS:
|
177 |
+
if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
178 |
$payment = $order->getPayment();
|
179 |
$payment->setTransactionId($transactionId);
|
180 |
$payment->setIsTransactionClosed(0);
|
181 |
+
$payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('Status' => 'Em andamento'));
|
182 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
183 |
+
}
|
184 |
+
// Atualiza status na transação
|
185 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
186 |
+
$quote->setStatusBcash($statusId)
|
187 |
+
->setDescriptionStatusBcash("Em andamento");
|
188 |
+
$quote->save();
|
189 |
break;
|
190 |
case NotificationStatusEnum::CANCELLED:
|
191 |
+
$order->registerCancellation('Pagamento cancelado.', TRUE)->save();
|
192 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
|
193 |
+
$order->save();
|
194 |
|
195 |
+
// Atualiza status na transação
|
196 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
197 |
+
$quote->setStatusBcash($statusId)
|
198 |
+
->setDescriptionStatusBcash("Cancelada");
|
199 |
+
$quote->save();
|
200 |
break;
|
201 |
case NotificationStatusEnum::IN_DISPUTE:
|
202 |
+
$order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status EM DISPUTA. Entre em contato com o Bcash.');
|
203 |
+
if ($order->canHold()) {
|
204 |
+
$order->hold();
|
205 |
+
} else {
|
206 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
|
207 |
+
}
|
208 |
+
$order->save();
|
209 |
|
210 |
+
// Atualiza status na transação
|
211 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
212 |
+
$quote->setStatusBcash($statusId)
|
213 |
+
->setDescriptionStatusBcash("Em disputa");
|
214 |
+
$quote->save();
|
215 |
break;
|
216 |
case NotificationStatusEnum::CHARGEBACK:
|
217 |
+
$order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status CHARGEBACK EM ANÁLISE. Entre em contato com o Bcash.');
|
218 |
+
if ($order->canHold()) {
|
219 |
+
$order->hold();
|
220 |
+
} else {
|
221 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
|
222 |
+
}
|
223 |
+
$order->save();
|
224 |
|
225 |
+
// Atualiza status na transação
|
226 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
227 |
+
$quote->setStatusBcash($statusId)
|
228 |
+
->setDescriptionStatusBcash("Chargeback");
|
229 |
+
$quote->save();
|
230 |
break;
|
231 |
case NotificationStatusEnum::REFUNDED:
|
232 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
233 |
|
234 |
+
// Atualiza status na transação
|
235 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
236 |
+
$quote->setStatusBcash($statusId)
|
237 |
+
->setDescriptionStatusBcash("Devolvida");
|
238 |
+
$quote->save();
|
239 |
break;
|
240 |
default:
|
241 |
$order->addStatusHistoryComment('Notificação da transação ' . $transactionId . ' sem ação identificada para o status ' . $statusId);
|
247 |
Mage::helper('bcash')->updateOrderSyncBcashDataWithQuote($orderId, $quoteId);
|
248 |
}
|
249 |
|
250 |
+
/**
|
251 |
+
* Verifica se a transação está relacionada com o pedido
|
252 |
+
*
|
253 |
+
* @param $order
|
254 |
+
* @param $transactionId
|
255 |
+
* @return bool
|
256 |
+
*/
|
257 |
+
private function isValidTransactionForOrder($order, $transactionId)
|
258 |
+
{
|
259 |
+
try {
|
260 |
+
/*
|
261 |
+
* Order data
|
262 |
+
*/
|
263 |
+
$orderTransactionId = $order->getTransactionIdBcash();
|
264 |
+
if ($orderTransactionId == $transactionId) {
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
// Comparação de string segura para binário
|
268 |
+
if (strcmp($orderTransactionId, $transactionId) == 0) {
|
269 |
+
return true;
|
270 |
+
}
|
271 |
+
|
272 |
+
/*
|
273 |
+
* Quote data
|
274 |
+
*/
|
275 |
+
$quoteId = $order->getQuoteId();
|
276 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
277 |
+
$quoteTransactionId = $quote->getTransactionIdBcash();
|
278 |
+
if ($quoteTransactionId == $transactionId) {
|
279 |
+
return true;
|
280 |
+
}
|
281 |
+
// Comparação de string segura para binário
|
282 |
+
if (strcmp($quoteTransactionId, $transactionId) == 0) {
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
} catch (Exception $e) {
|
286 |
+
Mage::helper("bcash")->saveLog("Erro inesperado: " . $e->getMessage());
|
287 |
+
}
|
288 |
+
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
|
292 |
/**
|
293 |
* Simulação de notificação enviada pelo Bcash na URL de retorno
|
294 |
*
|
app/code/community/Bcash/Pagamento/etc/config.xml
CHANGED
@@ -3,19 +3,19 @@
|
|
3 |
<modules>
|
4 |
|
5 |
<Bcash_Pagamento>
|
6 |
-
<version>1.2.
|
7 |
</Bcash_Pagamento>
|
8 |
|
9 |
<Bcash_Creditcard>
|
10 |
-
<version>1.2.
|
11 |
</Bcash_Creditcard>
|
12 |
|
13 |
<Bcash_Bankslip>
|
14 |
-
<version>1.2.
|
15 |
</Bcash_Bankslip>
|
16 |
|
17 |
<Bcash_Onlinetransfer>
|
18 |
-
<version>1.2.
|
19 |
</Bcash_Onlinetransfer>
|
20 |
|
21 |
</modules>
|
3 |
<modules>
|
4 |
|
5 |
<Bcash_Pagamento>
|
6 |
+
<version>1.2.5</version>
|
7 |
</Bcash_Pagamento>
|
8 |
|
9 |
<Bcash_Creditcard>
|
10 |
+
<version>1.2.5</version>
|
11 |
</Bcash_Creditcard>
|
12 |
|
13 |
<Bcash_Bankslip>
|
14 |
+
<version>1.2.5</version>
|
15 |
</Bcash_Bankslip>
|
16 |
|
17 |
<Bcash_Onlinetransfer>
|
18 |
+
<version>1.2.5</version>
|
19 |
</Bcash_Onlinetransfer>
|
20 |
|
21 |
</modules>
|
app/code/community/Bcash/Pagamento/sql/pagamento_setup/{mysql4-upgrade-0.1.0-1.2.2.php → mysql4-upgrade-0.1.0-1.2.5.php}
RENAMED
@@ -63,5 +63,5 @@ try {
|
|
63 |
$installer->endSetup();
|
64 |
|
65 |
} catch (Exception $e) {
|
66 |
-
Mage::log("Exception - app/code/community/Bcash/Pagamento/sql/pagamento_setup/mysql4-upgrade
|
67 |
}
|
63 |
$installer->endSetup();
|
64 |
|
65 |
} catch (Exception $e) {
|
66 |
+
Mage::log("Exception - app/code/community/Bcash/Pagamento/sql/pagamento_setup/mysql4-upgrade-*.php: " . $e->getMessage());
|
67 |
}
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Bcash_Pagamento</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Bcash Magento Transparente (API)</summary>
|
10 |
<description>Bcash Magento Transparente (API)</description>
|
11 |
-
<notes>-
|
12 |
<authors><author><name>Bcash</name><user>Bcash</user><email>danilo.benedetti@bcash.com.br</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Bcash"><dir name="Pagamento"><dir name="Block"><dir name="Adminhtml"><file name="Dependentes.php" hash="817d7116d5ab890b5525a7185100ab37"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="c5edf74ec8dedbf4578d8d8126157987"/><file name="View.php" hash="04e915acc1ca7b2148dd657ad7b39782"/></dir></dir></dir><dir name="Form"><file name="Bankslip.php" hash="2ca4f97c502fae164ea4079feb75e487"/><file name="Creditcard.php" hash="f009da6d0b0b592f4e57fd1d21c65c38"/><file name="Onlinetransfer.php" hash="3d2c667251c52f85ab1f2a5b3779b1f0"/></dir><dir name="Info"><file name="Bankslip.php" hash="5d627fa1b4e184ca314ae0c553f183a8"/><file name="Creditcard.php" hash="a5fa9c4d22c78b884b2f126098462a08"/><file name="Onlinetransfer.php" hash="e904739e0c43300b6aeeb62af9de5411"/></dir></dir><dir name="Helper"><file name="Data.php" hash="11de13ac908a8167f4011b75f55ff059"/><file name="PaymentMethod.php" hash="516dc381c251edce75d51a362f0e0bd0"/><file name="Transaction.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Bcash_Pagamento</name>
|
4 |
+
<version>1.2.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Bcash Magento Transparente (API)</summary>
|
10 |
<description>Bcash Magento Transparente (API)</description>
|
11 |
+
<notes>- Consulta de Id da transação Bcash na tabela Quote</notes>
|
12 |
<authors><author><name>Bcash</name><user>Bcash</user><email>danilo.benedetti@bcash.com.br</email></author></authors>
|
13 |
+
<date>2016-03-16</date>
|
14 |
+
<time>14:36:42</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Bcash"><dir name="Pagamento"><dir name="Block"><dir name="Adminhtml"><file name="Dependentes.php" hash="817d7116d5ab890b5525a7185100ab37"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="c5edf74ec8dedbf4578d8d8126157987"/><file name="View.php" hash="04e915acc1ca7b2148dd657ad7b39782"/></dir></dir></dir><dir name="Form"><file name="Bankslip.php" hash="2ca4f97c502fae164ea4079feb75e487"/><file name="Creditcard.php" hash="f009da6d0b0b592f4e57fd1d21c65c38"/><file name="Onlinetransfer.php" hash="3d2c667251c52f85ab1f2a5b3779b1f0"/></dir><dir name="Info"><file name="Bankslip.php" hash="5d627fa1b4e184ca314ae0c553f183a8"/><file name="Creditcard.php" hash="a5fa9c4d22c78b884b2f126098462a08"/><file name="Onlinetransfer.php" hash="e904739e0c43300b6aeeb62af9de5411"/></dir></dir><dir name="Helper"><file name="Data.php" hash="11de13ac908a8167f4011b75f55ff059"/><file name="PaymentMethod.php" hash="516dc381c251edce75d51a362f0e0bd0"/><file name="Transaction.php" hash="d4f0235e9bd2d8177dbc0fc95fcd8abc"/></dir><dir name="Model"><file name="Bankslip.php" hash="087f1f0ca27d28660f8a950f139fc2c5"/><file name="Creditcard.php" hash="be90e4bbfdefb6fdf2544289b3e0db32"/><file name="Observer.php" hash="ac0a7cb43dfe31d298c5dd87f19124dc"/><file name="Onlinetransfer.php" hash="25dfefce7da371bfaab2d07801cd72da"/><file name="Order.php" hash="4d646d09ccf6e24907e6e23412649b5a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Installments.php" hash="5fae970a6cb83b5be079c5762b8e214d"/></dir></dir></dir></dir><dir name="controllers"><dir name="Admin"><dir name="Sales"><file name="OrderController.php" hash="5b7a924f03dc209a4dcd3a6f43d29c7c"/></dir></dir><file name="NotificationController.php" hash="773ee08d6a5c4f45f8714ebeabcffdea"/><file name="PaymentController.php" hash="c1a1086e309813ab7c06e240be697f42"/></dir><dir name="etc"><file name="config.xml" hash="9f689b7c83c70bfda97c7932f2877f7b"/><file name="system.xml" hash="a6f3757a03e94ba1a0ad105fe53152c9"/></dir><dir name="sql"><dir name="pagamento_setup"><file name="mysql4-install-0.1.0.php" hash="2e7c6977f85f3d3bd86f975c07490d5f"/><file name="mysql4-upgrade-0.1.0-1.2.5.php" hash="51b3e59929a80b857bf0d42a39069ef4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="bcash"><dir name="pagamento"><file name="layout.xml" hash="2cc82944f642513a946299a26c1d0063"/></dir></dir></dir><dir name="template"><dir name="bcash"><dir name="pagamento"><dir name="checkout"><file name="success.phtml" hash="939702b20d07f17506edf119ca6d5121"/></dir><dir name="form"><file name="bankslip.phtml" hash="622324f3e4d9f039b57d4aa4430109ea"/><file name="creditcard.phtml" hash="82bd85f88542a7a718fe3bfc72df2d8f"/><file name="onlinetransfer.phtml" hash="90f61cd593a4cb75dc763a9c9adaecee"/></dir><file name="info.phtml" hash="c41cb9edc7653cd05bdc4a7ccd17c163"/><dir name="sales"><dir name="order"><dir name="info"><dir name="buttons"><file name="payment.phtml" hash="454b2bac39dac3e8729773ff50eabc26"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="bcash"><dir name="pagamento"><file name="info.phtml" hash="2d63fca436efc0431e365b35a83f0ce2"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bcash_Pagamento.xml" hash="3dd07f527dbcd104762897d392acb31b"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="bcash"><dir name="pagamento"><dir name="css"><file name="application.css" hash="cd3d8d4eff2299cd620c2abf3c5c2bc6"/></dir><dir name="images"><file name="application-sprite.png" hash="2c6c670b3ca8f7eb783f874bd387527e"/></dir><dir name="js"><file name="payment.js" hash="c0124aabf6a91849c0aa7db6cea6a471"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Bcash"><file name="AutoLoader.php" hash="498e3f6f8a4daed6823bfceb5cd88ea4"/><dir name="Config"><file name="Config.php" hash="027627d0781a1a6842ab2b6f7cb13512"/></dir><dir name="Domain"><file name="Address.php" hash="ebc176d33ba79ac46cf59561f479919f"/><file name="CreditCard.php" hash="bcf12a466ab99f25da348a93c2e7f995"/><file name="CurrencyEnum.php" hash="c2097c3796e8ab354a9b61ce1bb9c70e"/><file name="Customer.php" hash="68f056140a92bfb9a7534ced54939d44"/><file name="DependentTransaction.php" hash="2553d6ed93f39cb96ef185cbc886311c"/><file name="GenderEnum.php" hash="11377e531d5914b232b99f8cee61e61c"/><file name="Model.php" hash="f1b7fe3fb7384852f16f4b6931fc8545"/><file name="NotificationContent.php" hash="52b6ad7894c455dd4f4c199fdaf1fad3"/><file name="NotificationStatusEnum.php" hash="1635e03b18f7de30fd6bd80a7ff4f4d4"/><file name="PaymentMethod.php" hash="86fbfc29bc8671a4617f51a36031eba4"/><file name="PaymentMethodEnum.php" hash="d0deaeac659f54826bb38aa94d7f5c34"/><file name="Product.php" hash="674e7475e0555e9f2f592c7931098144"/><file name="ShippingTypeEnum.php" hash="4849b2ff3bf4294285e1d2e51d5226ea"/><file name="StateEnum.php" hash="75080122c0eb3807dcca92e064ff5d1d"/><file name="TransactionRequest.php" hash="f1e29973341750cca57dfac7f1496355"/></dir><dir name="Exception"><file name="BaseException.php" hash="e4d5637be15c9939cedb80b6aa54418e"/><file name="ConnectionException.php" hash="421fb7fbab02fe882a00765cc9cff569"/><file name="ValidationException.php" hash="03379f9626fcb19694a3662395da755f"/></dir><dir name="Helper"><file name="HttpHelper.php" hash="3ee5690f7eb45974cf888128643b2700"/></dir><dir name="Http"><dir name="Authentication"><file name="Basic.php" hash="b9ca27226db5535b70edea699d6d2e55"/><file name="OAuth.php" hash="92e6d135821380337561ace5572b8f9a"/></dir><file name="Connection.php" hash="381b6f242da04ef4c68691e70a3118b5"/><file name="GetRequest.php" hash="bbb366a1fb1396cd53e7976740880351"/><file name="PostRequest.php" hash="9e425ddf0278e72ffbb3b7369e18359d"/><file name="PutRequest.php" hash="7da14392d43109682f7373e8d4b12660"/><file name="Response.php" hash="f941571206e14c8251373168b08e297f"/></dir><dir name="Service"><file name="Account.php" hash="1e62bbf14e84348bb4b08a37ca843dfb"/><file name="Cancellation.php" hash="e1931a4e0bc1e66006670645336d93f4"/><file name="Consultation.php" hash="8c4fb3a25d9ffa418aad36cce99cab12"/><file name="IEnvironmentManager.php" hash="05668b184b91a5895f8308e5dc02d422"/><file name="Installments.php" hash="101e7aa5aace7e618156c3152aa894c8"/><file name="Notification.php" hash="550b7ee0fea57d7ac30c4648c9896c39"/><file name="Payment.php" hash="87a8184a928e04f56b6b9d796a6e9806"/></dir><dir name="Test"><file name="NotificationSimulator.php" hash="de77ea4d3c4c656a1dafd77f944aafbe"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
18 |
</package>
|