Bcash_Pagamento - Version 1.1.3

Version Notes

Update transaction data at Order table

Download this release

Release Info

Developer Bcash
Extension Bcash_Pagamento
Version 1.1.3
Comparing to
See all releases


Code changes from version 1.0.0 to 1.1.3

app/code/community/Bcash/Pagamento/Helper/Data.php CHANGED
@@ -5,6 +5,7 @@ require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
5
  use Bcash\Service\Consultation;
6
  use Bcash\Exception\ValidationException;
7
  use Bcash\Exception\ConnectionException;
 
8
 
9
  class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
10
  {
@@ -13,6 +14,8 @@ class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
13
  private $token;
14
  private $obj;
15
  private $sandbox;
 
 
16
 
17
  public function __construct()
18
  {
@@ -20,6 +23,8 @@ class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
20
  $this->email = $this->obj->getConfigData('email');
21
  $this->token = $this->obj->getConfigData('token');
22
  $this->sandbox = $this->obj->getConfigData('sandbox');
 
 
23
  }
24
 
25
  public function getTransaction($transactionId = null, $orderId = null)
@@ -49,6 +54,35 @@ class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
49
  return $response;
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  public function setTransaction()
53
  {
54
  //Create Transaction with Bcash
@@ -56,4 +90,51 @@ class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
56
  die('setTransaction');
57
 
58
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
5
  use Bcash\Service\Consultation;
6
  use Bcash\Exception\ValidationException;
7
  use Bcash\Exception\ConnectionException;
8
+ use Bcash\Service\Installments;
9
 
10
  class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
11
  {
14
  private $token;
15
  private $obj;
16
  private $sandbox;
17
+ private $quote;
18
+ private $max_installments;
19
 
20
  public function __construct()
21
  {
23
  $this->email = $this->obj->getConfigData('email');
24
  $this->token = $this->obj->getConfigData('token');
25
  $this->sandbox = $this->obj->getConfigData('sandbox');
26
+ $this->max_installments = $this->obj->getConfigData('max_installments');
27
+ $this->desconto_credito_1x = $this->obj->getConfigData('desconto_credito_1x');
28
  }
29
 
30
  public function getTransaction($transactionId = null, $orderId = null)
54
  return $response;
55
  }
56
 
57
+ /**
58
+ * Retorna os parcelamentos possíveis via cartão de crédito.
59
+ * @return array
60
+ */
61
+ public function getInstallments()
62
+ {
63
+ $installments = new Installments($this->email, $this->token);
64
+ try {
65
+ $sessionCheckout = Mage::getSingleton('checkout/session');
66
+ $quoteId = $sessionCheckout->getQuoteId();
67
+ $this->quote = Mage::getModel("sales/quote")->load($quoteId);
68
+ $grandTotal = floatval(number_format($this->quote->getData('grand_total'), 2, '.', ''));
69
+ $ignoreScheduledDiscount = false;
70
+ if($this->sandbox){
71
+ $installments->enableSandBox(true);
72
+ }
73
+ $response = $installments->calculate($grandTotal, $this->max_installments, $ignoreScheduledDiscount);
74
+ return array("ok" => true, "installments" => array(0 => $this->prepareInstallmentsCards($response)));
75
+ } catch (ValidationException $e) {
76
+ Mage::log("Erro Bcash ValidationException:" . $e->getMessage());
77
+ Mage::log($e->getErrors());
78
+ return array("ok" => false, "installments" => array("1" => $grandTotal));
79
+ } catch (ConnectionException $e) {
80
+ Mage::log("Erro Bcash ConnectionException:" . $e->getMessage());
81
+ Mage::log($e->getErrors());
82
+ return array("ok" => false, "installments" => array("1" => $grandTotal));
83
+ }
84
+ }
85
+
86
  public function setTransaction()
87
  {
88
  //Create Transaction with Bcash
90
  die('setTransaction');
91
 
92
  }
93
+
94
+ /**
95
+ * Sincronização de informações da transação Bcash entre Quote e Order
96
+ *
97
+ * @param $orderId
98
+ * @param $quoteId
99
+ * @throws Exception
100
+ */
101
+ public function updateOrderSyncBcashDataWithQuote($orderId, $quoteId)
102
+ {
103
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
104
+ $order = Mage::getModel('sales/order')->load($orderId);
105
+
106
+ $order->setTransactionIdBcash($quote->getTransactionIdBcash())
107
+ ->setStatusBcash($quote->getStatusBcash())
108
+ ->setDescriptionStatusBcash($quote->getDescriptionStatusBcash())
109
+ ->setPaymentLinkBcash($quote->getPaymentLinkBcash())
110
+ ->setPaymentMethodBcash($quote->getPaymentMethodBcash())
111
+ ->setInstallmentsBcash($quote->getInstallmentsBcash());
112
+ $order->save();
113
+ }
114
+
115
+ private function prepareInstallmentsCards($installments)
116
+ {
117
+ foreach ($installments->paymentTypes as $obj) {
118
+ if ('card' != $obj->name) {
119
+ unset($obj);
120
+ } else {
121
+ if ($this->desconto_credito_1x) {
122
+ $subTotal = floatval($this->quote->getSubtotal());
123
+ $desconto = ($this->desconto_credito_1x / 100) * $subTotal;
124
+ if ($desconto) {
125
+ foreach ($obj->paymentMethods as $type) {
126
+ foreach ($type->installments as &$installment) {
127
+ if ($installment->number == 1) {
128
+ $installment->installmentAmount -= $desconto;
129
+ $installment->installmentAmountDesc = " ({$this->desconto_credito_1x} % de desconto)";
130
+ break;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ return $installments;
139
+ }
140
  }
app/code/community/Bcash/Pagamento/Helper/Transaction.php CHANGED
@@ -212,7 +212,7 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
212
  public function createTransactionRequestBcash()
213
  {
214
  //Id:Plataforma => 565
215
- $url = Mage::getUrl('pagamento/notification/request');
216
  $transactionRequest = new TransactionRequest();
217
  $transactionRequest->setSellerMail($this->email);
218
  $transactionRequest->setOrderId($this->quoteBcash->getReservedOrderId());
@@ -223,7 +223,6 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
223
  $transactionRequest->setViewedContract("S");
224
  $transactionRequest->setDependentTransactions($this->createDependentTransactionsBcash());
225
  $transactionRequest->setPlatformId(565);
226
- //var_dump($transactionRequest);
227
  return $transactionRequest;
228
  }
229
 
@@ -238,10 +237,12 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
238
  $this->transactionRequest->setInstallments($this->installments);
239
  }
240
 
241
- if ($this->installments == 1) {
242
  $discount = $this->calculateDiscount($this->payment_method);
243
  $this->setDiscountBcash($discount);
244
- }
 
 
245
  }
246
 
247
  /**
@@ -259,7 +260,6 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
259
  $percent = $this->obj->getConfigData('desconto_boleto');
260
  }
261
  if ($percent) {
262
- //$discount = floatval(($this->subTotalBcash / 100) * $percent);
263
  $discount = floatval(number_format(($this->subTotalBcash / 100) * $percent, 2, '.', ''));
264
  $this->discountPercentBcash = $percent;
265
  $this->discountBcash = $discount;
@@ -410,6 +410,9 @@ class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
410
  */
411
  public function setDiscountBcash($discount)
412
  {
 
 
 
413
  $this->discountBcash = $discount;
414
  $this->transactionRequest->setDiscount($discount);
415
  }
212
  public function createTransactionRequestBcash()
213
  {
214
  //Id:Plataforma => 565
215
+ $url = Mage::getUrl('pagamento/notification/request',array('_secure'=>true));
216
  $transactionRequest = new TransactionRequest();
217
  $transactionRequest->setSellerMail($this->email);
218
  $transactionRequest->setOrderId($this->quoteBcash->getReservedOrderId());
223
  $transactionRequest->setViewedContract("S");
224
  $transactionRequest->setDependentTransactions($this->createDependentTransactionsBcash());
225
  $transactionRequest->setPlatformId(565);
 
226
  return $transactionRequest;
227
  }
228
 
237
  $this->transactionRequest->setInstallments($this->installments);
238
  }
239
 
240
+ /*if ($this->installments == 1) {
241
  $discount = $this->calculateDiscount($this->payment_method);
242
  $this->setDiscountBcash($discount);
243
+ }*/
244
+
245
+ $this->setDiscountBcash();
246
  }
247
 
248
  /**
260
  $percent = $this->obj->getConfigData('desconto_boleto');
261
  }
262
  if ($percent) {
 
263
  $discount = floatval(number_format(($this->subTotalBcash / 100) * $percent, 2, '.', ''));
264
  $this->discountPercentBcash = $percent;
265
  $this->discountBcash = $discount;
410
  */
411
  public function setDiscountBcash($discount)
412
  {
413
+ $discount = $this->quoteBcash->getShippingAddress()->getDiscountAmount();
414
+ if($discount < 0) { $discount = ((-1) * $discount); }
415
+ $discount = floatval(number_format($discount, 2, '.', ''));
416
  $this->discountBcash = $discount;
417
  $this->transactionRequest->setDiscount($discount);
418
  }
app/code/community/Bcash/Pagamento/Model/Observer.php CHANGED
@@ -34,16 +34,23 @@ class Bcash_Pagamento_Model_Observer
34
  */
35
  public function saveOrderQuoteToSession($observer)
36
  {
37
- /* @var $event Varien_Event */
38
  $event = $observer->getEvent();
39
- /* @var $order Mage_Sales_Model_Order */
40
  $order = $event->getOrder();
41
- /* @var $quote Mage_Sales_Model_Quote */
42
  $quote = $event->getQuote();
43
- $session = Mage::getSingleton('checkout/session');
 
44
  $quoteId = $quote->getId();
45
  $orderId = $order->getId();
46
  $incrId = $order->getIncrementId();
 
 
 
 
 
 
47
  Mage::log("Saving quote [$quoteId] and order [$incrId] to checkout/session");
48
  $session->setData('OrderIdBcash', $orderId);
49
  $session->setData('OrderIncrementIdBcash', $incrId);
@@ -55,26 +62,6 @@ class Bcash_Pagamento_Model_Observer
55
  return $this;
56
  }
57
 
58
- /*
59
- <global>
60
- - If you want your observer to listen no matter where the event is dispatched from, put it here. You can also put it in "frontend" or "adminhtml".
61
- <events>
62
- - This is the element that stores all of the events that are registered.
63
- <checkout_submit_all_after>
64
- - This is the "event" that you are listening to.
65
- <observers>
66
- - This is the type of event. I don't think there are others.
67
- <awesome_example>
68
- - This is a unique string that defines this configuration. It can be anything, and just needs to be unique.
69
- <type>
70
- - I have always used singleton, but other options can be "model" or "object". The "singleton" will create the object as Mage::getSingleton()
71
- while both "object" and "model" will use Mage::getModel() when creating the observer object.
72
- <class>
73
- - This is the observer class.
74
- <method>
75
- - This is the function to be called in the observer class.
76
- */
77
-
78
  /**
79
  * Adiciona o Link do meio de pagamento a página de sucesso.
80
  * @param $observer
@@ -109,4 +96,55 @@ class Bcash_Pagamento_Model_Observer
109
  }
110
  }
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
34
  */
35
  public function saveOrderQuoteToSession($observer)
36
  {
37
+ // @var $event Varien_Event
38
  $event = $observer->getEvent();
39
+ // @var $order Mage_Sales_Model_Order
40
  $order = $event->getOrder();
41
+ // @var $quote Mage_Sales_Model_Quote
42
  $quote = $event->getQuote();
43
+
44
+
45
  $quoteId = $quote->getId();
46
  $orderId = $order->getId();
47
  $incrId = $order->getIncrementId();
48
+
49
+ // Sync datas
50
+ Mage::helper('pagamento')->updateOrderSyncBcashDataWithQuote($orderId, $quoteId);
51
+
52
+ // Session values
53
+ $session = Mage::getSingleton('checkout/session');
54
  Mage::log("Saving quote [$quoteId] and order [$incrId] to checkout/session");
55
  $session->setData('OrderIdBcash', $orderId);
56
  $session->setData('OrderIncrementIdBcash', $incrId);
62
  return $this;
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  /**
66
  * Adiciona o Link do meio de pagamento a página de sucesso.
67
  * @param $observer
96
  }
97
  }
98
 
99
+ public function updateSalesQuotePayment(Varien_Event_Observer $observer)
100
+ {
101
+ try {
102
+ if (!is_null($observer->getQuote())) {
103
+ $params = Mage::app()->getFrontController()->getRequest()->getParams();
104
+ $params['installments_bcash'] = isset($params['installments_bcash']) ? $params['installments_bcash'] : 1;
105
+
106
+ //Adiciona Desconto ao Pedido caso 1x Credito, Boleto ou TEF (configurados no Backend)
107
+ $discountAmount = 0;
108
+ if ($params['installments_bcash'] == 1) {
109
+ $transaction = new Bcash_Pagamento_Helper_Transaction();
110
+ $discountAmount = $transaction->calculateDiscount($params['payment-method']);
111
+ }
112
+
113
+ $quote = $observer->getQuote();
114
+ $quote->collectTotals();
115
+
116
+ if($discountAmount > 0) {
117
+ $grandTotal = $quote->getGrandTotal();
118
+ $subTotalWithDiscount = $quote->getSubtotalWithDiscount();
119
+ $baseGrandTotal = $quote->getBaseGrandTotal();
120
+ $baseSubTotalWithDiscount = $quote->getBaseSubtotalWithDiscount();
121
+
122
+ // Outros descontos aplicados
123
+ $objDiscountAmount = $quote->getDiscountAmount();
124
+ if ($objDiscountAmount <> 0) {
125
+ $discountAmount = (-1 * ((-$discountAmount) + $objDiscountAmount));
126
+ $grandTotal = $grandTotal + (-1 * $objDiscountAmount);
127
+ $subTotalWithDiscount = $subTotalWithDiscount + (-1 * $objDiscountAmount);
128
+ $baseGrandTotal = $baseGrandTotal + (-1 * $objDiscountAmount);
129
+ $baseSubTotalWithDiscount = $baseSubTotalWithDiscount + (-1 * $objDiscountAmount);
130
+ }
131
+
132
+ $totalDiscountAmount = $discountAmount;
133
+ $subtotalWithDiscount = $subTotalWithDiscount - $discountAmount;
134
+ $baseTotalDiscountAmount = $discountAmount;
135
+ $baseSubtotalWithDiscount = $baseSubTotalWithDiscount - $discountAmount;
136
+
137
+ $quote->setDiscountAmount(-$totalDiscountAmount);
138
+ $quote->setSubtotalWithDiscount($subtotalWithDiscount);
139
+ $quote->setBaseDiscountAmount($baseTotalDiscountAmount);
140
+ $quote->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
141
+ $quote->setGrandTotal($grandTotal - $totalDiscountAmount);
142
+ $quote->setBaseGrandTotal($baseGrandTotal - $baseTotalDiscountAmount);
143
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
144
+ $quote->save();
145
+ }
146
+ }
147
+ } catch (Exception $e) { Mage::log($e->getMessage()); }
148
+ }
149
+
150
  }
app/code/community/Bcash/Pagamento/Model/PaymentMethod.php CHANGED
@@ -56,7 +56,7 @@ class Bcash_Pagamento_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
56
 
57
  try {
58
  $result = $this->_customBeginPayment();
59
- Mage::log(print_r($result, true));
60
  $response = $result['response'];
61
  $payment_method = $result['payment_method'];
62
  $installments = $result['installments'];
@@ -151,11 +151,16 @@ class Bcash_Pagamento_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
151
  $params['installments_bcash'] = isset($params['installments_bcash']) ?$params['installments_bcash']:1;
152
 
153
  //Adiciona Desconto ao Pedido caso 1x Credito, Boleto ou TEF (configurados no Backend)
154
- $discount = 0;
155
- if ($params['installments_bcash'] == 1) {
156
- $discount = $this->calculateDiscount($params['payment-method']);
 
 
 
 
 
157
  }
158
- $this->addDiscountToQuote($discount);
159
  return $result;
160
  }
161
 
@@ -169,21 +174,57 @@ class Bcash_Pagamento_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
169
  {
170
  $cart = Mage::getSingleton('checkout/cart');
171
  $objShippingAddress = $cart->getQuote()->getShippingAddress();
172
- $objShippingAddress->setDiscountDescription('Meio de pagamento selecionado');
173
- $objShippingAddress->addTotal(array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  'code' => 'discount',
175
  'title' => "Desconto",
176
  'value' => -$discountAmount,
177
  ));
178
- $totalDiscountAmount = $discountAmount;
179
- $subtotalWithDiscount = $discountAmount;
180
- $baseTotalDiscountAmount = $discountAmount;
181
- $baseSubtotalWithDiscount = $discountAmount;
182
- $objShippingAddress->setDiscountAmount($totalDiscountAmount);
183
- $objShippingAddress->setSubtotalWithDiscount($subtotalWithDiscount);
184
- $objShippingAddress->setBaseDiscountAmount($baseTotalDiscountAmount);
185
- $objShippingAddress->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
186
- $objShippingAddress->setGrandTotal($objShippingAddress->getGrandTotal() - $objShippingAddress->getDiscountAmount());
187
- $objShippingAddress->setBaseGrandTotal($objShippingAddress->getBaseGrandTotal() - $objShippingAddress->getBaseDiscountAmount());
 
 
 
 
188
  }
189
  }
56
 
57
  try {
58
  $result = $this->_customBeginPayment();
59
+ //Mage::log(print_r($result, true));
60
  $response = $result['response'];
61
  $payment_method = $result['payment_method'];
62
  $installments = $result['installments'];
151
  $params['installments_bcash'] = isset($params['installments_bcash']) ?$params['installments_bcash']:1;
152
 
153
  //Adiciona Desconto ao Pedido caso 1x Credito, Boleto ou TEF (configurados no Backend)
154
+ if(isset($params['payment-method'])) {
155
+ $discount = 0;
156
+ if ($params['installments_bcash'] == 1) {
157
+ $discount = $this->calculateDiscount($params['payment-method']);
158
+ }
159
+ if(!empty($params['payment-method'])) {
160
+ $this->addDiscountToQuote($discount);
161
+ }
162
  }
163
+
164
  return $result;
165
  }
166
 
174
  {
175
  $cart = Mage::getSingleton('checkout/cart');
176
  $objShippingAddress = $cart->getQuote()->getShippingAddress();
177
+
178
+
179
+ //Mage::log($objShippingAddress);
180
+
181
+ if($discountAmount > 0) {
182
+ // Update quote
183
+ Mage::dispatchEvent(
184
+ 'sales_quote_payment_import_data_before',
185
+ array(
186
+ 'quote' => $cart->getQuote()
187
+ )
188
+ );
189
+ $discountDescription = $objShippingAddress->getDiscountDescription();
190
+ if(!empty($discountDescription)) { $discountDescription .= " + "; }
191
+
192
+ $objShippingAddress->setDiscountDescription($discountDescription . 'Meio de pagamento');
193
+
194
+
195
+ $grandTotal = $objShippingAddress->getGrandTotal();
196
+ $subTotalWithDiscount = $objShippingAddress->getSubtotalWithDiscount();
197
+ $baseGrandTotal = $objShippingAddress->getBaseGrandTotal();
198
+ $baseSubTotalWithDiscount = $objShippingAddress->getBaseSubtotalWithDiscount();
199
+
200
+ // Outros descontos aplicados
201
+ $objDiscountAmount = $objShippingAddress->getDiscountAmount();
202
+ if ($objDiscountAmount <> 0) {
203
+ $discountAmount = (-1 * ((-$discountAmount) + $objDiscountAmount));
204
+ $grandTotal = $grandTotal + (-1 * $objDiscountAmount);
205
+ $subTotalWithDiscount = $subTotalWithDiscount + (-1 * $objDiscountAmount);
206
+ $baseGrandTotal = $baseGrandTotal + (-1 * $objDiscountAmount);
207
+ $baseSubTotalWithDiscount = $baseSubTotalWithDiscount + (-1 * $objDiscountAmount);
208
+ }
209
+
210
+ $objShippingAddress->addTotal(array(
211
  'code' => 'discount',
212
  'title' => "Desconto",
213
  'value' => -$discountAmount,
214
  ));
215
+
216
+ $totalDiscountAmount = $discountAmount;
217
+ $subtotalWithDiscount = $subTotalWithDiscount - $discountAmount;
218
+ $baseTotalDiscountAmount = $discountAmount;
219
+ $baseSubtotalWithDiscount = $baseSubTotalWithDiscount - $discountAmount;
220
+
221
+ $objShippingAddress->setDiscountAmount(-$totalDiscountAmount);
222
+ $objShippingAddress->setSubtotalWithDiscount($subtotalWithDiscount);
223
+ $objShippingAddress->setBaseDiscountAmount($baseTotalDiscountAmount);
224
+ $objShippingAddress->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
225
+ $objShippingAddress->setGrandTotal($grandTotal - $totalDiscountAmount);
226
+ $objShippingAddress->setBaseGrandTotal($baseGrandTotal - $baseTotalDiscountAmount);
227
+ $objShippingAddress->save();
228
+ }
229
  }
230
  }
app/code/community/Bcash/Pagamento/controllers/NotificationController.php CHANGED
@@ -44,7 +44,7 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
44
  $statusId = (int)Mage::app()->getRequest()->getParam('statusId');
45
 
46
  // Notification Simulator
47
- $urlSubmit = Mage::getUrl('pagamento/notification/index');
48
  echo "<h1>Bcash Notification Simulator</h1>
49
  <form method='GET' action='" . $urlSubmit . "'>
50
  <label>Nro. Pedido:</label>
@@ -65,7 +65,7 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
65
  </form>";
66
 
67
  if(!empty($transactionId) && !empty($statusId) && !empty($orderId)) {
68
- $urlSimulator = Mage::getUrl('pagamento/notification/request');
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);
@@ -137,6 +137,9 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
137
  {
138
  // Carrega pedido a partir de código incremental
139
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
 
 
 
140
  switch ($statusId) {
141
  case NotificationStatusEnum::APPROVED:
142
  case NotificationStatusEnum::COMPLETED:
@@ -150,7 +153,6 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
150
  $order->save();
151
 
152
  // Atualiza status na transação
153
- $quoteId = $order->getQuoteId();
154
  $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
155
  $quote->setStatusBcash($statusId)
156
  ->setDescriptionStatusBcash("Aprovada");
@@ -162,6 +164,12 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
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
  break;
166
  case NotificationStatusEnum::CANCELLED:
167
  $order->registerCancellation('Pagamento cancelado.', TRUE)->save();
@@ -169,7 +177,6 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
169
  $order->save();
170
 
171
  // Atualiza status na transação
172
- $quoteId = $order->getQuoteId();
173
  $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
174
  $quote->setStatusBcash($statusId)
175
  ->setDescriptionStatusBcash("Cancelada");
@@ -183,6 +190,12 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
183
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
184
  }
185
  $order->save();
 
 
 
 
 
 
186
  break;
187
  case NotificationStatusEnum::CHARGEBACK:
188
  $order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status CHARGEBACK EM ANÁLISE. Entre em contato com o Bcash.');
@@ -192,15 +205,30 @@ class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_
192
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
193
  }
194
  $order->save();
 
 
 
 
 
 
195
  break;
196
  case NotificationStatusEnum::REFUNDED:
197
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
 
 
 
 
 
 
198
  break;
199
  default:
200
  $order->addStatusHistoryComment('Notificação da transação ' . $transactionId . ' sem ação identificada para o status ' . $statusId);
201
  $order->save();
202
  break;
203
  }
 
 
 
204
  }
205
 
206
  /**
44
  $statusId = (int)Mage::app()->getRequest()->getParam('statusId');
45
 
46
  // Notification Simulator
47
+ $urlSubmit = Mage::getUrl('pagamento/notification/index',array('_secure'=>true));
48
  echo "<h1>Bcash Notification Simulator</h1>
49
  <form method='GET' action='" . $urlSubmit . "'>
50
  <label>Nro. Pedido:</label>
65
  </form>";
66
 
67
  if(!empty($transactionId) && !empty($statusId) && !empty($orderId)) {
68
+ $urlSimulator = Mage::getUrl('pagamento/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);
137
  {
138
  // Carrega pedido a partir de código incremental
139
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
140
+ $orderId = $order->getId();
141
+ $quoteId = $order->getQuoteId();
142
+
143
  switch ($statusId) {
144
  case NotificationStatusEnum::APPROVED:
145
  case NotificationStatusEnum::COMPLETED:
153
  $order->save();
154
 
155
  // Atualiza status na transação
 
156
  $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
157
  $quote->setStatusBcash($statusId)
158
  ->setDescriptionStatusBcash("Aprovada");
164
  $payment->setIsTransactionClosed(0);
165
  $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('Status'=>'Em andamento'));
166
  $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
167
+
168
+ // Atualiza status na transação
169
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
170
+ $quote->setStatusBcash($statusId)
171
+ ->setDescriptionStatusBcash("Em andamento");
172
+ $quote->save();
173
  break;
174
  case NotificationStatusEnum::CANCELLED:
175
  $order->registerCancellation('Pagamento cancelado.', TRUE)->save();
177
  $order->save();
178
 
179
  // Atualiza status na transação
 
180
  $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
181
  $quote->setStatusBcash($statusId)
182
  ->setDescriptionStatusBcash("Cancelada");
190
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
191
  }
192
  $order->save();
193
+
194
+ // Atualiza status na transação
195
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
196
+ $quote->setStatusBcash($statusId)
197
+ ->setDescriptionStatusBcash("Em disputa");
198
+ $quote->save();
199
  break;
200
  case NotificationStatusEnum::CHARGEBACK:
201
  $order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status CHARGEBACK EM ANÁLISE. Entre em contato com o Bcash.');
205
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
206
  }
207
  $order->save();
208
+
209
+ // Atualiza status na transação
210
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
211
+ $quote->setStatusBcash($statusId)
212
+ ->setDescriptionStatusBcash("Chargeback");
213
+ $quote->save();
214
  break;
215
  case NotificationStatusEnum::REFUNDED:
216
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
217
+
218
+ // Atualiza status na transação
219
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
220
+ $quote->setStatusBcash($statusId)
221
+ ->setDescriptionStatusBcash("Devolvida");
222
+ $quote->save();
223
  break;
224
  default:
225
  $order->addStatusHistoryComment('Notificação da transação ' . $transactionId . ' sem ação identificada para o status ' . $statusId);
226
  $order->save();
227
  break;
228
  }
229
+
230
+ // Sinc datas
231
+ Mage::helper('pagamento')->updateOrderSyncBcashDataWithQuote($orderId, $quoteId);
232
  }
233
 
234
  /**
app/code/community/Bcash/Pagamento/controllers/PaymentController.php CHANGED
@@ -124,4 +124,40 @@ class Bcash_Pagamento_PaymentController extends Mage_Core_Controller_Front_Actio
124
 
125
  $this->renderLayout();
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
124
 
125
  $this->renderLayout();
126
  }
127
+
128
+ /**
129
+ * Retorna parcelamentos por Json
130
+ */
131
+ public function installmentsAction()
132
+ {
133
+ $method = Mage::app()->getRequest()->getPost('method');
134
+
135
+ $paymentInstallments = Mage::helper('pagamento')->getInstallments();
136
+ $response = "[{ccId : 0, ccName : '', ccNumber : '', ccDescript : '(Selecione o número de parcelas)'}";
137
+ $okInstallments = $paymentInstallments['ok'];
138
+ if($okInstallments):
139
+ $installments = $paymentInstallments["installments"][0]->paymentTypes;
140
+ foreach ($installments as $type) :
141
+ if ($type->name == 'card') :
142
+ foreach ($type->paymentMethods as $typePayment) :
143
+ foreach ($typePayment->installments as $paymentInstallment) :
144
+ $response .= ",{ccId : " . $typePayment->id . ", ccName : '" . $typePayment->name . "', ccNumber : " . $paymentInstallment->number . ",
145
+ ccDescript : '" . $paymentInstallment->number . "x - R$ " . number_format($paymentInstallment->installmentAmount,2,',','.') .
146
+ ($paymentInstallment->rate ? ' ('. number_format($paymentInstallment->rate,2,',','.') . '%)' : '') . (isset($paymentInstallment->installmentAmountDesc) ? $paymentInstallment->installmentAmountDesc : '') . "'}";
147
+ endforeach;
148
+ endforeach;
149
+ endif;
150
+ endforeach;
151
+ endif;
152
+ $response .= "]";
153
+
154
+ $returnResponse = array(
155
+ "installments" => $response,
156
+ "method" => $method
157
+ );
158
+
159
+ header('Content-Type: application/json');
160
+ echo json_encode($returnResponse);
161
+ exit;
162
+ }
163
  }
app/code/community/Bcash/Pagamento/etc/config.xml CHANGED
@@ -169,6 +169,14 @@
169
  </bcash_pagamento_observer>
170
  </observers>
171
  </checkout_type_onepage_save_order_after>
 
 
 
 
 
 
 
 
172
  </events>
173
  </frontend>
174
  <default>
169
  </bcash_pagamento_observer>
170
  </observers>
171
  </checkout_type_onepage_save_order_after>
172
+ <sales_quote_payment_import_data_before>
173
+ <observers>
174
+ <bcash_pagamento_observer>
175
+ <class>Bcash_Pagamento_Model_Observer</class>
176
+ <method>updateSalesQuotePayment</method>
177
+ </bcash_pagamento_observer>
178
+ </observers>
179
+ </sales_quote_payment_import_data_before>
180
  </events>
181
  </frontend>
182
  <default>
app/design/frontend/base/default/template/pagamento/checkout/success.phtml CHANGED
@@ -3,7 +3,7 @@
3
  <div id="bcash_pagamento" style="float:left; width: 100%; padding: 10px;">
4
  <?php
5
  //$this->escapeHtml($this->getOrder()->getViewOrderUrl())
6
- $url = Mage::getUrl() . 'sales/order/view/order_id/' . $this->getOrder()->getId();
7
  $idPedido = $this->getQuote()->getReservedOrderId();
8
  $type = $this->getType();
9
  if ($type && $type->type == Bcash_Pagamento_Helper_PaymentMethod::CARD_TYPE): ?>
3
  <div id="bcash_pagamento" style="float:left; width: 100%; padding: 10px;">
4
  <?php
5
  //$this->escapeHtml($this->getOrder()->getViewOrderUrl())
6
+ $url = Mage::getUrl('', array('_secure'=>true)) . 'sales/order/view/order_id/' . $this->getOrder()->getId();
7
  $idPedido = $this->getQuote()->getReservedOrderId();
8
  $type = $this->getType();
9
  if ($type && $type->type == Bcash_Pagamento_Helper_PaymentMethod::CARD_TYPE): ?>
app/design/frontend/base/default/template/pagamento/form/payment.phtml CHANGED
@@ -49,6 +49,7 @@ $paymentGroupName = array(
49
  </div>
50
  </div>
51
 
 
52
  <?php foreach ($paymentMethods as $paymentType => $payments): ?>
53
  <?php
54
  $totalPayments = count($payments);
@@ -173,11 +174,12 @@ $paymentGroupName = array(
173
  <?php
174
  $size--;
175
  endforeach; ?>
 
176
  </div>
177
  <!-- div b-col-xs-4 -->
178
  <script type="text/javascript">
179
  //<![CDATA[
180
- var requestUrl = '<?php echo Mage::getUrl('pagamento/payment/dados') ?>';
181
 
182
  function in_array(needle, haystack, argStrict) {
183
  var key = '',
@@ -240,32 +242,46 @@ $paymentGroupName = array(
240
 
241
  var initBcashPagamento = function () {
242
  checkPaymentOnLoad();
 
 
 
 
 
243
 
244
  function showInstallmentsOnlyForMethod(method)
245
  {
 
 
 
 
 
 
 
 
 
246
  if (in_array(method, cards)) {
247
  var select_id = 'installments_bcash';
248
  var select = document.getElementById(select_id);
249
 
250
- if(installments_cc.length > 1) {
251
  // Remove options
252
  var i; for(i=select.options.length-1; i>=0; i--) { select.remove(i); }
253
 
254
  // Add options
255
  var option = '';
256
- for (i=0; i < installments_cc.length; i++) {
257
- if(installments_cc[i].ccId == 0) {
258
  option = document.createElement("option");
259
- option.text = installments_cc[i].ccDescript;
260
  option.value = '';
261
  option.disabled = 'disabled';
262
  select.add(option);
263
  option = '';
264
  }
265
- if(installments_cc[i].ccId == method) {
266
  option = document.createElement("option");
267
- option.text = installments_cc[i].ccDescript;
268
- option.value = installments_cc[i].ccNumber;
269
  select.add(option);
270
  option = '';
271
  }
@@ -275,6 +291,19 @@ $paymentGroupName = array(
275
  }
276
  }
277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  function ableCvv(card) {
279
  cvvInput = document.getElementById("cvv_bcash");
280
  cvvInput.value = '';
@@ -305,16 +334,38 @@ $paymentGroupName = array(
305
  if (typeof(OSCPayment) !== 'undefined') {
306
  OSCPayment.forcesavePayment();
307
  }
 
 
 
 
 
308
  }
309
 
310
  function checkPaymentOnLoad() {
 
 
311
  document.body.select('input[type=radio][name="payment[method]"]').each(function (e) {
312
- if(e.value == 'pagamento') {
313
- e.checked = true;
314
- //force order review reload
315
- forceReloadOrderReviewOsc();
 
 
316
  }
317
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  }
319
 
320
  function checkIsCardSelected() {
@@ -440,7 +491,14 @@ $paymentGroupName = array(
440
  disableUnunsed(paymentRadio);
441
  showInstallmentsOnlyForMethod(paymentRadio.value);
442
  ableCvv(paymentRadio.value);
443
- checkPaymentOnLoad();
 
 
 
 
 
 
 
444
  }
445
 
446
  function enableCardForm() {
@@ -809,6 +867,124 @@ $paymentGroupName = array(
809
  return true;
810
  }
811
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
812
  };
813
  initBcashPagamento();
814
  //]]>
49
  </div>
50
  </div>
51
 
52
+ <div id="payment-bcash-group">
53
  <?php foreach ($paymentMethods as $paymentType => $payments): ?>
54
  <?php
55
  $totalPayments = count($payments);
174
  <?php
175
  $size--;
176
  endforeach; ?>
177
+ </div>
178
  </div>
179
  <!-- div b-col-xs-4 -->
180
  <script type="text/javascript">
181
  //<![CDATA[
182
+ var requestUrl = '<?php echo Mage::getUrl('pagamento/payment/dados',array('_secure'=>true)) ?>';
183
 
184
  function in_array(needle, haystack, argStrict) {
185
  var key = '',
242
 
243
  var initBcashPagamento = function () {
244
  checkPaymentOnLoad();
245
+ uncheckBcashPaymentMethods();
246
+
247
+ function parseJSON(data) {
248
+ return (window.JSON && window.JSON.parse ? window.JSON.parse( data ) : (new Function("return " + data))());
249
+ }
250
 
251
  function showInstallmentsOnlyForMethod(method)
252
  {
253
+ changeInstallmentsSelect("Carregando...");
254
+ // Update installments before show
255
+ updateInstallments(method);
256
+ }
257
+
258
+ function showInstallmentsSelectBox(method, installmentsStr)
259
+ {
260
+ var newInstallments = eval('(' + installmentsStr + ')');
261
+
262
  if (in_array(method, cards)) {
263
  var select_id = 'installments_bcash';
264
  var select = document.getElementById(select_id);
265
 
266
+ if(newInstallments.length > 1) {
267
  // Remove options
268
  var i; for(i=select.options.length-1; i>=0; i--) { select.remove(i); }
269
 
270
  // Add options
271
  var option = '';
272
+ for (i=0; i < newInstallments.length; i++) {
273
+ if(newInstallments[i].ccId == 0) {
274
  option = document.createElement("option");
275
+ option.text = newInstallments[i].ccDescript;
276
  option.value = '';
277
  option.disabled = 'disabled';
278
  select.add(option);
279
  option = '';
280
  }
281
+ if(newInstallments[i].ccId == method) {
282
  option = document.createElement("option");
283
+ option.text = newInstallments[i].ccDescript;
284
+ option.value = newInstallments[i].ccNumber;
285
  select.add(option);
286
  option = '';
287
  }
291
  }
292
  }
293
 
294
+ function changeInstallmentsSelect(text) {
295
+ var changeSelect_id = 'installments_bcash';
296
+ var changeSelect = document.getElementById(changeSelect_id);
297
+ // Remove installments options
298
+ var i; for(i=changeSelect.options.length-1; i>=0; i--) { changeSelect.remove(i); }
299
+ var changeOption = document.createElement("option");
300
+ changeOption.text = text;
301
+ changeOption.value = '';
302
+ //changeOption.disabled = 'disabled';
303
+ changeSelect.add(changeOption);
304
+ document.getElementById(changeSelect_id).value = "";
305
+ }
306
+
307
  function ableCvv(card) {
308
  cvvInput = document.getElementById("cvv_bcash");
309
  cvvInput.value = '';
334
  if (typeof(OSCPayment) !== 'undefined') {
335
  OSCPayment.forcesavePayment();
336
  }
337
+ if(typeof(checkout) !== 'undefined') {
338
+ if ((typeof(checkout.update) !== 'undefined') && (typeof(checkout.urls) !== 'undefined')) {
339
+ checkout.update(checkout.urls.payment_method);
340
+ }
341
+ }
342
  }
343
 
344
  function checkPaymentOnLoad() {
345
+ var hasChecked = 0;
346
+ var isBcash = 0;
347
  document.body.select('input[type=radio][name="payment[method]"]').each(function (e) {
348
+ if(e.checked == true) {
349
+ hasChecked = 1;
350
+ if(e.value == 'pagamento') {
351
+ isBcash = 1;
352
+ showBcashPaymentMethod();
353
+ }
354
  }
355
  });
356
+
357
+ if(hasChecked == 0 && isBcash == 0) {
358
+ document.body.select('input[type=radio][name="payment[method]"]').each(function (e) {
359
+ if(e.value == 'pagamento') {
360
+ e.checked = true;
361
+ showBcashPaymentMethod();
362
+ }
363
+ });
364
+ }
365
+
366
+ if(hasChecked == 1 && isBcash == 0) {
367
+ hideBcashPaymentMethod();
368
+ }
369
  }
370
 
371
  function checkIsCardSelected() {
491
  disableUnunsed(paymentRadio);
492
  showInstallmentsOnlyForMethod(paymentRadio.value);
493
  ableCvv(paymentRadio.value);
494
+ document.body.select('input[type=radio][name="payment[method]"]').each(function (e) {
495
+ if(e.value == 'pagamento') {
496
+ e.checked = true;
497
+ }
498
+ });
499
+ //force order review reload
500
+ forceReloadOrderReviewOsc();
501
+
502
  }
503
 
504
  function enableCardForm() {
867
  return true;
868
  }
869
  }
870
+
871
+ function updateInstallments(method) {
872
+ new Ajax.Request('<?php echo Mage::getUrl('pagamento/payment/installments',array('_secure'=>true)) ?>', {
873
+ method: 'post',
874
+ parameters: 'method=' + method,
875
+ onSuccess: successGetInstallments,
876
+ onFailure: failureGetInstallments
877
+ });
878
+ }
879
+
880
+ function successGetInstallments(response) {
881
+ var strInstallmentsResponse = response.responseJSON.installments;
882
+ var strMethodResponse = response.responseJSON.method;
883
+
884
+ // Update json
885
+ installments_cc = eval('(' + strInstallmentsResponse + ')');
886
+
887
+ showInstallmentsSelectBox(strMethodResponse, strInstallmentsResponse);
888
+ }
889
+
890
+ function failureGetInstallments(response){
891
+ alert("Falha inesperada ao atualizar parcelamentos. Por favor, selecione o meio de pagamento novamente." );
892
+ }
893
+
894
+ function hideBcashPaymentMethod() {
895
+ var paymentConteiner = document.getElementById('payment-<?php echo $code; ?>');
896
+ var paymentBcashConteiner = document.getElementById('payment-bcash-group');
897
+
898
+ // cards
899
+ var cardConteiner = document.getElementById('card-conteiner');
900
+ if(!hasClass(cardConteiner, 'b-hide')){
901
+ cardConteiner.className = cardConteiner.className + " b-hide";
902
+ }
903
+ disableCardForm();
904
+
905
+ // radios
906
+ document.body.select('input[type=radio][name="payment-method"]:checked').each(function (element) {
907
+ if (element.checked) {
908
+ element.checked = false;
909
+ }
910
+ });
911
+ var paymentRadios = document.getElementsByClassName("payment-method-bcash");
912
+ for (var i = paymentRadios.length - 1; i >= 0; i--) {
913
+ if(hasClass(paymentRadios[i], 'validate-one-required-by-name')) {
914
+ paymentRadios[i].className = paymentRadios[i].className.replace(/\bvalidate-one-required-by-name\b/, '');
915
+ }
916
+ paymentRadios[i].disabled = true;
917
+ }
918
+
919
+ // all
920
+ if(!hasClass(paymentBcashConteiner, 'b-hide')){
921
+ paymentBcashConteiner.className = paymentBcashConteiner.className + " b-hide";
922
+ }
923
+ if (!hasClass(paymentConteiner, 'b-hide')) {
924
+ paymentConteiner.className = paymentConteiner.className + " b-hide";
925
+ }
926
+ }
927
+
928
+ function uncheckBcashPaymentMethods() {
929
+ document.body.select('input[type=radio][name="payment-method"]:checked').each(function (element) {
930
+ if (element.checked) {
931
+ element.checked = false;
932
+ }
933
+ });
934
+ }
935
+
936
+ function showBcashPaymentMethod() {
937
+ var paymentConteiner = document.getElementById('payment-<?php echo $code; ?>');
938
+ var paymentBcashConteiner = document.getElementById('payment-bcash-group');
939
+
940
+ var paymentRadios = document.getElementsByClassName("payment-method-bcash");
941
+ for (var i = paymentRadios.length - 1; i >= 0; i--) {
942
+ if(!hasClass(paymentRadios[i], 'validate-one-required-by-name')) {
943
+ paymentRadios[i].className = paymentRadios[i].className + " validate-one-required-by-name";
944
+ }
945
+ paymentRadios[i].disabled = false;
946
+ }
947
+ if(hasClass(paymentBcashConteiner, 'b-hide')) {
948
+ paymentBcashConteiner.className = paymentBcashConteiner.className.replace(/\bb-hide\b/, '');
949
+ }
950
+ if (hasClass(paymentConteiner, 'b-hide')) {
951
+ paymentConteiner.className = paymentConteiner.className.replace(/\bb-hide\b/, '');
952
+ }
953
+ }
954
+
955
+ $(document).on('change', 'input[type=radio][name=payment[method]]', function (event) {
956
+ var target = event.target;
957
+ var paymentConteiner = document.getElementById('payment-<?php echo $code; ?>');
958
+ var paymentBcashConteiner = document.getElementById('payment-bcash-group');
959
+ if(target.id == 'p_method_pagamento') {
960
+ showBcashPaymentMethod();
961
+ } else {
962
+
963
+ hideBcashPaymentMethod();
964
+ }
965
+ event.preventDefault();
966
+ });
967
+
968
+ $(document).on('change', 'input[type=radio][name=shipping_method]', function (event) {
969
+ var target = event.target;
970
+ changeInstallmentsSelect("Selecione novamente o meio de pagamento.");
971
+ uncheckBcashPaymentMethods();
972
+ event.preventDefault();
973
+ });
974
+
975
+ $(document).on('click', '#coupon-cancel', function (event) {
976
+ var target = event.target;
977
+ changeInstallmentsSelect("Selecione novamente o meio de pagamento.");
978
+ uncheckBcashPaymentMethods();
979
+ event.preventDefault();
980
+ });
981
+
982
+ $(document).on('click', '#coupon-apply', function (event) {
983
+ var target = event.target;
984
+ changeInstallmentsSelect("Selecione novamente o meio de pagamento.");
985
+ uncheckBcashPaymentMethods();
986
+ event.preventDefault();
987
+ });
988
  };
989
  initBcashPagamento();
990
  //]]>
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bcash_Pagamento</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>M&#xF3;dulo para Magento Bcash Transparente (API)</summary>
10
  <description>M&#xF3;dulo para Magento Bcash Transparente (API)</description>
11
- <notes>- Checkout transparente com API Bcash;&#xD;
12
- - Estorno/Cancelamento de pagamento diretamente no Bcash;&#xD;
13
- - Atualiza&#xE7;&#xE3;o autom&#xE1;tica de status do pagamento.</notes>
14
  <authors><author><name>Bcash</name><user>Bcash</user><email>danilo.benedetti@bcash.com.br</email></author></authors>
15
- <date>2015-10-08</date>
16
- <time>20:40:14</time>
17
- <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="ce5a4c048d7579d00640a06635c68790"/><file name="View.php" hash="ec2e6d2af5eb75cd727cb8923ee7d06a"/></dir></dir></dir><dir name="Form"><file name="Payment.php" hash="6e4147ecf10be00f598601160a27ce2c"/></dir><dir name="Info"><file name="Payment.php" hash="7df027e4d1c5819454778ebe535828cf"/></dir></dir><dir name="Helper"><file name="Data.php" hash="720a98734461aebde16b0753b48e699b"/><file name="PaymentMethod.php" hash="1fe0aa7851a9ba7f4f195869841defc3"/><file name="Transaction.php" hash="9bbfdd2dc9d982a22aeb917702dc0c69"/></dir><dir name="Model"><file name="Observer.php" hash="51a6c9bf70be31f406213d5f58e0812e"/><file name="Order.php" hash="e82596b3ad50673719e88d65597995d9"/><file name="PaymentMethod.php" hash="2365de778dc2187456a19ca71a45badb"/><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="f5e28688b10de3a386632ffe9db53dec"/></dir></dir><file name="NotificationController.php" hash="ade9f612e7b4fb55575a4eb7c3f26274"/><file name="PaymentController.php" hash="f1a7cb9ad8a36c035843fca0932a2959"/></dir><dir name="etc"><file name="config.xml" hash="a47ffcb9c303eb0fcb72b6d38cff23ea"/><file name="system.xml" hash="445170483c052ee95127df17723ca561"/></dir><dir name="sql"><dir name="pagamento_setup"><file name="mysql4-install-0.1.0.php" hash="51ff3e257bb67b19c92f05793617b225"/></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="5e15451eac5922ec1fc48f0b703bf09c"/></dir></dir></dir><dir name="template"><dir name="pagamento"><dir name="checkout"><file name="success.phtml" hash="b05ea8293726da56f3e5007740d2872f"/></dir><dir name="form"><file name="payment.phtml" hash="0cd4c6a5cda187622931867e083f6405"/></dir><dir name="sales"><dir name="order"><dir name="info"><dir name="buttons"><file name="payment.phtml" hash="218fcb385c5c7c643967a69b23b62896"/></dir></dir></dir></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="34b84ab770c9d29b95ab2244256a63e7"/></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="BcashApi"><dir name="src"><file name="AutoLoader.php" hash="d661e36286a54d06a36cc13ed62379d1"/><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><file name="autoloader.php" hash="9d6567ac5239179a52d4fa8c1d3542f0"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bcash_Pagamento</name>
4
+ <version>1.1.3</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>M&#xF3;dulo para Magento Bcash Transparente (API)</summary>
10
  <description>M&#xF3;dulo para Magento Bcash Transparente (API)</description>
11
+ <notes>Update transaction data at Order table</notes>
 
 
12
  <authors><author><name>Bcash</name><user>Bcash</user><email>danilo.benedetti@bcash.com.br</email></author></authors>
13
+ <date>2015-11-19</date>
14
+ <time>16:37:09</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="ce5a4c048d7579d00640a06635c68790"/><file name="View.php" hash="ec2e6d2af5eb75cd727cb8923ee7d06a"/></dir></dir></dir><dir name="Form"><file name="Payment.php" hash="6e4147ecf10be00f598601160a27ce2c"/></dir><dir name="Info"><file name="Payment.php" hash="7df027e4d1c5819454778ebe535828cf"/></dir></dir><dir name="Helper"><file name="Data.php" hash="40d1bbfca9603c987c02ead374829bda"/><file name="PaymentMethod.php" hash="1fe0aa7851a9ba7f4f195869841defc3"/><file name="Transaction.php" hash="877f97026561b3242a67dc3044ded083"/></dir><dir name="Model"><file name="Observer.php" hash="0c14d85855be15a2b6c79b4a9e084f69"/><file name="Order.php" hash="e82596b3ad50673719e88d65597995d9"/><file name="PaymentMethod.php" hash="8ba2cd750107ab1a2afb39c377688e37"/><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="f5e28688b10de3a386632ffe9db53dec"/></dir></dir><file name="NotificationController.php" hash="67dd78990534ff0b054d48392a6491b5"/><file name="PaymentController.php" hash="22429bd95d83c4d2bbc0c2c3d32f94d5"/></dir><dir name="etc"><file name="config.xml" hash="6cab1a4596bdce8261e61dc8ef5c4533"/><file name="system.xml" hash="445170483c052ee95127df17723ca561"/></dir><dir name="sql"><dir name="pagamento_setup"><file name="mysql4-install-0.1.0.php" hash="51ff3e257bb67b19c92f05793617b225"/></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="5e15451eac5922ec1fc48f0b703bf09c"/></dir></dir></dir><dir name="template"><dir name="pagamento"><dir name="checkout"><file name="success.phtml" hash="bdee0194f3174b6eb2bc26965c8c4bb9"/></dir><dir name="form"><file name="payment.phtml" hash="7a43e30885bdb3dbc70612cee661a0ee"/></dir><dir name="sales"><dir name="order"><dir name="info"><dir name="buttons"><file name="payment.phtml" hash="218fcb385c5c7c643967a69b23b62896"/></dir></dir></dir></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="34b84ab770c9d29b95ab2244256a63e7"/></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="BcashApi"><dir name="src"><file name="AutoLoader.php" hash="d661e36286a54d06a36cc13ed62379d1"/><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><file name="autoloader.php" hash="9d6567ac5239179a52d4fa8c1d3542f0"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
18
  </package>