Version Notes
Minor bug fixes.
This plugin is only compatible to Magento's checkout type OnePage.
Download this release
Release Info
Developer | PagBrasil |
Extension | PagBrasil |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.2 to 2.2.0
- app/code/community/Mzcart/Pagbrasil/Model/Abstract.php +2 -3
- app/code/community/Mzcart/Pagbrasil/Model/Acc.php +7 -6
- app/code/community/Mzcart/Pagbrasil/Model/Bb.php +17 -7
- app/code/community/Mzcart/Pagbrasil/Model/Event.php +17 -5
- app/code/community/Mzcart/Pagbrasil/Model/Obt.php +0 -1
- app/code/community/Mzcart/Pagbrasil/controllers/ProcessingController.php +203 -105
- app/code/community/Mzcart/Pagbrasil/etc/config.xml +2 -2
- app/code/community/Mzcart/Pagbrasil/etc/system.xml +11 -1
- app/design/frontend/base/default/template/pagbrasil/payment.phtml +84 -34
- app/locale/pt_BR/Mzcart_Pagbrasil.csv +1 -0
- package.xml +8 -6
app/code/community/Mzcart/Pagbrasil/Model/Abstract.php
CHANGED
@@ -16,7 +16,6 @@
|
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
19 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
abstract class Mzcart_Pagbrasil_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
@@ -28,7 +27,7 @@ abstract class Mzcart_Pagbrasil_Model_Abstract extends Mage_Payment_Model_Method
|
|
28 |
|
29 |
protected $_formBlockType = 'pagbrasil/form';
|
30 |
protected $_infoBlockType = 'pagbrasil/info';
|
31 |
-
|
32 |
/**
|
33 |
* Availability options
|
34 |
*/
|
@@ -183,7 +182,7 @@ abstract class Mzcart_Pagbrasil_Model_Abstract extends Mage_Payment_Model_Method
|
|
183 |
'address_zip' => preg_replace('/[^0-9]+/', '',$billing->getPostcode()),
|
184 |
'address_city' => $billing->getCity(),
|
185 |
'address_state' => $billing->getRegionCode(),
|
186 |
-
'amount_brl' => $amount
|
187 |
);
|
188 |
return $params;
|
189 |
}
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
|
|
19 |
* @more info available on mzcart.com
|
20 |
*/
|
21 |
abstract class Mzcart_Pagbrasil_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
27 |
|
28 |
protected $_formBlockType = 'pagbrasil/form';
|
29 |
protected $_infoBlockType = 'pagbrasil/info';
|
30 |
+
|
31 |
/**
|
32 |
* Availability options
|
33 |
*/
|
182 |
'address_zip' => preg_replace('/[^0-9]+/', '',$billing->getPostcode()),
|
183 |
'address_city' => $billing->getCity(),
|
184 |
'address_state' => $billing->getRegionCode(),
|
185 |
+
'amount_brl' => $amount
|
186 |
);
|
187 |
return $params;
|
188 |
}
|
app/code/community/Mzcart/Pagbrasil/Model/Acc.php
CHANGED
@@ -16,7 +16,6 @@
|
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
19 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
class Mzcart_Pagbrasil_Model_Acc extends Mzcart_Pagbrasil_Model_Abstract
|
@@ -32,17 +31,19 @@ class Mzcart_Pagbrasil_Model_Acc extends Mzcart_Pagbrasil_Model_Abstract
|
|
32 |
*
|
33 |
* @return array
|
34 |
*/
|
35 |
-
public function getFormFields()
|
|
|
36 |
$_order = $this->getOrder();
|
37 |
// $order_id = $_order->getRealOrderId();
|
38 |
-
$params = array
|
|
|
39 |
'pbtoken' => Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_PAGBRASIL_TOKEN, $_order->getStoreId()),
|
40 |
'cc_installments' => 0,
|
41 |
'url_return' => Mage::getUrl('pagbrasil/processing/return'),
|
42 |
-
|
43 |
-
|
44 |
$params = array_merge($params, $this->_getCommonFields());
|
45 |
-
|
46 |
}
|
47 |
|
48 |
/**
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
|
|
19 |
* @more info available on mzcart.com
|
20 |
*/
|
21 |
class Mzcart_Pagbrasil_Model_Acc extends Mzcart_Pagbrasil_Model_Abstract
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
34 |
+
public function getFormFields()
|
35 |
+
{
|
36 |
$_order = $this->getOrder();
|
37 |
// $order_id = $_order->getRealOrderId();
|
38 |
+
$params = array
|
39 |
+
(
|
40 |
'pbtoken' => Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_PAGBRASIL_TOKEN, $_order->getStoreId()),
|
41 |
'cc_installments' => 0,
|
42 |
'url_return' => Mage::getUrl('pagbrasil/processing/return'),
|
43 |
+
'cc_auth' => Mage::getStoreConfig("payment/pagbrasil_acc/preauth") == '1' ? '1' : ''
|
44 |
+
);
|
45 |
$params = array_merge($params, $this->_getCommonFields());
|
46 |
+
return $params;
|
47 |
}
|
48 |
|
49 |
/**
|
app/code/community/Mzcart/Pagbrasil/Model/Bb.php
CHANGED
@@ -16,7 +16,6 @@
|
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
19 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
class Mzcart_Pagbrasil_Model_Bb extends Mzcart_Pagbrasil_Model_Abstract {
|
@@ -49,11 +48,16 @@ class Mzcart_Pagbrasil_Model_Bb extends Mzcart_Pagbrasil_Model_Abstract {
|
|
49 |
*
|
50 |
* @return array
|
51 |
*/
|
52 |
-
public function getBolUrl()
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
$curl = curl_init($this->getUrl());
|
55 |
$request = '';
|
56 |
-
foreach($params as $k => $v)
|
|
|
57 |
$request .= $k . '=' . trim($v) . '&';
|
58 |
}
|
59 |
|
@@ -64,9 +68,15 @@ class Mzcart_Pagbrasil_Model_Bb extends Mzcart_Pagbrasil_Model_Abstract {
|
|
64 |
curl_setopt($curl, CURLOPT_TIMEOUT, 50);
|
65 |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
66 |
$response = curl_exec($curl);
|
67 |
-
if (substr($response, 0, 7) == 'http://' )
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
return false;
|
71 |
}
|
72 |
}
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
|
|
19 |
* @more info available on mzcart.com
|
20 |
*/
|
21 |
class Mzcart_Pagbrasil_Model_Bb extends Mzcart_Pagbrasil_Model_Abstract {
|
48 |
*
|
49 |
* @return array
|
50 |
*/
|
51 |
+
public function getBolUrl()
|
52 |
+
{
|
53 |
+
$_order = $this->getOrder();
|
54 |
+
//$order_id = $_order->getRealOrderId();
|
55 |
+
|
56 |
+
$params = $this->getFormFields();
|
57 |
$curl = curl_init($this->getUrl());
|
58 |
$request = '';
|
59 |
+
foreach($params as $k => $v)
|
60 |
+
{
|
61 |
$request .= $k . '=' . trim($v) . '&';
|
62 |
}
|
63 |
|
68 |
curl_setopt($curl, CURLOPT_TIMEOUT, 50);
|
69 |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
70 |
$response = curl_exec($curl);
|
71 |
+
if (substr($response, 0, 7) == 'http://' )
|
72 |
+
{
|
73 |
+
$msg = Mage::helper('pagbrasil')->__('Boleto issued and waiting for payment.');
|
74 |
+
$_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
75 |
+
$_order->save();
|
76 |
+
return $response;
|
77 |
+
}
|
78 |
+
else
|
79 |
+
{
|
80 |
return false;
|
81 |
}
|
82 |
}
|
app/code/community/Mzcart/Pagbrasil/Model/Event.php
CHANGED
@@ -26,7 +26,8 @@ class Mzcart_Pagbrasil_Model_Event
|
|
26 |
const PAGBRASIL_STATUS_FAIL = -2;
|
27 |
const PAGBRASIL_STATUS_CANCEL = -1;
|
28 |
const PAGBRASIL_STATUS_PENDING = 0;
|
29 |
-
const
|
|
|
30 |
|
31 |
/*
|
32 |
* @param Mage_Sales_Model_Order
|
@@ -80,10 +81,12 @@ class Mzcart_Pagbrasil_Model_Event
|
|
80 |
*/
|
81 |
public function processStatusEvent($check=true)
|
82 |
{
|
83 |
-
try
|
|
|
84 |
$params = $this->_validateEventData($check);
|
85 |
$msg = '';
|
86 |
-
switch($params['status'])
|
|
|
87 |
case self::PAGBRASIL_STATUS_FAIL: //fail
|
88 |
$msg = Mage::helper('pagbrasil')->__('Payment failed.');
|
89 |
$this->_processCancel($msg);
|
@@ -95,6 +98,10 @@ class Mzcart_Pagbrasil_Model_Event
|
|
95 |
case self::PAGBRASIL_STATUS_PENDING: //pending
|
96 |
$msg = Mage::helper('pagbrasil')->__('Pending order #%s created.', $params['order']);
|
97 |
$this->_processSale($params['status'], $msg);
|
|
|
|
|
|
|
|
|
98 |
break;
|
99 |
case self::PAGBRASIL_STATUS_SUCCESS: //ok
|
100 |
$msg = Mage::helper('pagbrasil')->__('Payment authorized.');
|
@@ -102,9 +109,13 @@ class Mzcart_Pagbrasil_Model_Event
|
|
102 |
break;
|
103 |
}
|
104 |
return $msg;
|
105 |
-
}
|
|
|
|
|
106 |
return $e->getMessage();
|
107 |
-
}
|
|
|
|
|
108 |
Mage::logException($e);
|
109 |
}
|
110 |
return;
|
@@ -167,6 +178,7 @@ class Mzcart_Pagbrasil_Model_Event
|
|
167 |
$this->_order->sendNewOrderEmail();
|
168 |
$this->_order->setEmailSent(true);
|
169 |
break;
|
|
|
170 |
case self::PAGBRASIL_STATUS_PENDING:
|
171 |
$this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
172 |
// save transaction ID
|
26 |
const PAGBRASIL_STATUS_FAIL = -2;
|
27 |
const PAGBRASIL_STATUS_CANCEL = -1;
|
28 |
const PAGBRASIL_STATUS_PENDING = 0;
|
29 |
+
const PAGBRASIL_STATUS_PRE_AUTHORIZE = 1;
|
30 |
+
const PAGBRASIL_STATUS_SUCCESS = 2;
|
31 |
|
32 |
/*
|
33 |
* @param Mage_Sales_Model_Order
|
81 |
*/
|
82 |
public function processStatusEvent($check=true)
|
83 |
{
|
84 |
+
try
|
85 |
+
{
|
86 |
$params = $this->_validateEventData($check);
|
87 |
$msg = '';
|
88 |
+
switch($params['status'])
|
89 |
+
{
|
90 |
case self::PAGBRASIL_STATUS_FAIL: //fail
|
91 |
$msg = Mage::helper('pagbrasil')->__('Payment failed.');
|
92 |
$this->_processCancel($msg);
|
98 |
case self::PAGBRASIL_STATUS_PENDING: //pending
|
99 |
$msg = Mage::helper('pagbrasil')->__('Pending order #%s created.', $params['order']);
|
100 |
$this->_processSale($params['status'], $msg);
|
101 |
+
break;
|
102 |
+
case self::PAGBRASIL_STATUS_PRE_AUTHORIZE: //Pre-authorize
|
103 |
+
$msg = Mage::helper('pagbrasil')->__('Payment pre-authorized but not captured yet.', $params['order']);
|
104 |
+
$this->_processSale($params['status'], $msg);
|
105 |
break;
|
106 |
case self::PAGBRASIL_STATUS_SUCCESS: //ok
|
107 |
$msg = Mage::helper('pagbrasil')->__('Payment authorized.');
|
109 |
break;
|
110 |
}
|
111 |
return $msg;
|
112 |
+
}
|
113 |
+
catch (Mage_Core_Exception $e)
|
114 |
+
{
|
115 |
return $e->getMessage();
|
116 |
+
}
|
117 |
+
catch(Exception $e)
|
118 |
+
{
|
119 |
Mage::logException($e);
|
120 |
}
|
121 |
return;
|
178 |
$this->_order->sendNewOrderEmail();
|
179 |
$this->_order->setEmailSent(true);
|
180 |
break;
|
181 |
+
case self::PAGBRASIL_STATUS_PRE_AUTHORIZE:
|
182 |
case self::PAGBRASIL_STATUS_PENDING:
|
183 |
$this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
184 |
// save transaction ID
|
app/code/community/Mzcart/Pagbrasil/Model/Obt.php
CHANGED
@@ -16,7 +16,6 @@
|
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
19 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
class Mzcart_Pagbrasil_Model_Obt extends Mzcart_Pagbrasil_Model_Abstract
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
|
|
19 |
* @more info available on mzcart.com
|
20 |
*/
|
21 |
class Mzcart_Pagbrasil_Model_Obt extends Mzcart_Pagbrasil_Model_Abstract
|
app/code/community/Mzcart/Pagbrasil/controllers/ProcessingController.php
CHANGED
@@ -16,7 +16,6 @@
|
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
19 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_Action
|
@@ -58,10 +57,13 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
58 |
$billing = $order ->getBillingAddress();
|
59 |
$vatid = $billing->getVatId();
|
60 |
|
61 |
-
if
|
|
|
62 |
// $session->addError(Mage::helper('pagbrasil')->__('The CPF OR CNPJ is valid!'));
|
63 |
// Mage::throwException(Mage::helper('pagbrasil')->__('The CPF OR CNPJ is valid!'));
|
64 |
-
}
|
|
|
|
|
65 |
Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
|
66 |
$session->addError(Mage::helper('pagbrasil')->__('The CPF or CNPJ is not valid!'));
|
67 |
//parent::_redirect('checkout/cart');
|
@@ -69,19 +71,30 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
69 |
// exit();
|
70 |
Mage::throwException(Mage::helper('pagbrasil')->__('The CPF or CNPJ is not valid!'));
|
71 |
}
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
$order->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
|
83 |
-
|
84 |
-
|
|
|
85 |
} catch (Exception $e){
|
86 |
Mage::logException($e);
|
87 |
parent::_redirect('checkout/cart');
|
@@ -91,14 +104,25 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
91 |
/**
|
92 |
* Obt:Action to which the customer will be returned when the payment is made.
|
93 |
*/
|
94 |
-
public function bankAction()
|
|
|
95 |
$session = $this->_getCheckout();
|
96 |
$session->getQuote()->setIsActive(true)->save();
|
97 |
$curl = curl_init('https://www.pagbrasil.com/pagbrasil/addorder.mv');
|
98 |
$request = '';
|
99 |
// $pm = '';$url = '';
|
100 |
$params = $this->getRequest()->getParams();
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
// if ($k == 'payment_method') {
|
103 |
// $pm = trim($v);
|
104 |
// }
|
@@ -128,37 +152,46 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
128 |
error_log("\n" . $response . "\n",3,'logfile');
|
129 |
$msg = '';
|
130 |
$ok = 0;
|
131 |
-
if ($response!= false && substr($response, 0, 7) == 'http://' )
|
|
|
132 |
$ok = 1;
|
133 |
-
} else {
|
134 |
-
|
135 |
}
|
136 |
|
137 |
-
if ($ok ==1)
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
142 |
}
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
145 |
|
146 |
|
147 |
/**
|
148 |
* Cc(if mode)/Obt:Action to which the customer will be returned when the payment is made.
|
149 |
*/
|
150 |
-
public function returnAction()
|
|
|
151 |
// error_log(print_r($params,1),3,'abc');
|
152 |
$params = $this->getRequest()->getParams();
|
153 |
-
if (isset($params['order']))
|
|
|
154 |
$order_id = trim($params['order']);
|
155 |
-
}
|
|
|
|
|
156 |
die('Illegal Access');
|
157 |
}
|
158 |
|
159 |
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
160 |
|
161 |
-
if (!$_order->getId())
|
|
|
162 |
Mage::throwException('Order not found.');
|
163 |
}
|
164 |
|
@@ -179,15 +212,16 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
179 |
$xml = new DOMDocument();
|
180 |
$xml->loadXML($response);
|
181 |
|
182 |
-
if ( isset($xml->getElementsByTagName('order_status')->item(0)->nodeValue))
|
|
|
183 |
$payment_status = $xml->getElementsByTagName('order_status')->item(0)->nodeValue;
|
184 |
-
|
185 |
-
|
186 |
-
case 'PC':$params['status'] = 2;break;
|
187 |
-
case 'PA':$params['status'] =
|
188 |
-
case 'WP':$params['status'] = 0;break;
|
189 |
-
case 'PF':$params['status'] = -2;break;
|
190 |
-
case 'PR':$params['status'] = -2;break;
|
191 |
}
|
192 |
}
|
193 |
// var_dump($params);exit;
|
@@ -199,13 +233,23 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
199 |
$event = Mage::getModel('pagbrasil/event')->setEventData($params);
|
200 |
$message = $event->processStatusEvent(false);
|
201 |
//var_dump($params);exit;
|
202 |
-
if
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
205 |
$this->_redirect('checkout/cart');
|
206 |
//exit();
|
207 |
-
}
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
$this->_getCheckout()->setLastSuccessQuoteId($quoteId);
|
210 |
// var_dump($session->getQuoteId());exit;
|
211 |
// var_dump($quoteId);exit;
|
@@ -217,38 +261,44 @@ class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_A
|
|
217 |
}
|
218 |
//need a temp
|
219 |
//check the status action temp
|
220 |
-
|
221 |
-
|
222 |
-
}
|
223 |
|
224 |
/**
|
225 |
* Action to which the customer will be returned when the payment is made.
|
226 |
*/
|
227 |
-
public function postbackAction()
|
|
|
228 |
$params = $this->getRequest()->getParams();
|
229 |
|
230 |
error_log(print_r($params,1) . "\n\n",3,'logfile');
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
236 |
|
237 |
-
if (isset($params['secret']))
|
|
|
238 |
$secret = trim($params['secret']);
|
239 |
-
}
|
|
|
|
|
240 |
die('Illegal Access');
|
241 |
}
|
242 |
|
243 |
$payment_method = trim($params['payment_method']);
|
244 |
-
switch($payment_method)
|
|
|
245 |
case 'B':
|
246 |
$content = trim(preg_replace('/\s+/', '',$params['content']));
|
247 |
$xml = new DOMDocument();
|
248 |
-
$content = str_replace('<br />','',nl2br($content));
|
249 |
$xml->loadXML($content);
|
250 |
$boletolist = $xml->getElementsByTagName('boleto');
|
251 |
-
foreach ($boletolist as $boleto)
|
|
|
252 |
$order_id = trim($boleto->childNodes->item(0)->nodeValue);
|
253 |
|
254 |
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
@@ -257,7 +307,8 @@ $content = str_replace('<br />','',nl2br($content));
|
|
257 |
Mage::throwException('Order not found.');
|
258 |
}
|
259 |
$secret2 = Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY, $_order->getStoreId());
|
260 |
-
if ($secret != $secret2)
|
|
|
261 |
die('Illegal Access');
|
262 |
}
|
263 |
|
@@ -265,55 +316,63 @@ $content = str_replace('<br />','',nl2br($content));
|
|
265 |
$amount_due = trim($boleto->childNodes->item(3)->nodeValue);
|
266 |
$amount_brl = $amount_paid;
|
267 |
|
268 |
-
if ($amount_paid == $amount_due )
|
|
|
269 |
$msg = Mage::helper('pagbrasil')->__('The order was paid.');
|
270 |
$_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $msg);
|
271 |
$_order->save();
|
272 |
$_order->getPayment()->setLastTransId($order_id);
|
273 |
$_order->sendNewOrderEmail();
|
274 |
$_order->setEmailSent(true);
|
275 |
-
}
|
276 |
-
|
|
|
|
|
277 |
$msg = sprintf($msg, $amount_due, $amount_paid);
|
278 |
$_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
279 |
$_order->getPayment()->setLastTransId($order_id);
|
280 |
}
|
281 |
$_order->save();
|
282 |
}
|
283 |
-
|
284 |
-
|
285 |
break;
|
286 |
default:
|
287 |
$payment_status = $params['payment_status'];
|
288 |
-
switch ($payment_status)
|
289 |
-
|
290 |
-
case '
|
291 |
-
case '
|
292 |
-
case '
|
293 |
-
case '
|
|
|
294 |
}
|
295 |
$event = Mage::getModel('pagbrasil/event')->setEventData($params);
|
296 |
$message = $event->processStatusEvent();
|
297 |
}
|
298 |
|
299 |
-
echo 'Received successfully in
|
300 |
-
|
301 |
}
|
302 |
|
303 |
/**
|
304 |
* Obt:Action to which the customer will be returned when the payment is made.
|
305 |
*/
|
306 |
-
public function successAction()
|
|
|
307 |
$event = Mage::getModel('pagbrasil/event')
|
308 |
->setEventData($this->getRequest()->getParams());
|
309 |
-
try
|
|
|
310 |
$quoteId = $event->successEvent();
|
311 |
$this->_getCheckout()->setLastSuccessQuoteId($quoteId);
|
312 |
$this->_redirect('checkout/onepage/success');
|
313 |
return;
|
314 |
-
}
|
|
|
|
|
315 |
$this->_getCheckout()->addError($e->getMessage());
|
316 |
-
}
|
|
|
|
|
317 |
Mage::logException($e);
|
318 |
}
|
319 |
$this->_redirect('checkout/cart');
|
@@ -374,60 +433,94 @@ $content = str_replace('<br />','',nl2br($content));
|
|
374 |
return $this;
|
375 |
}
|
376 |
|
377 |
-
function _validaCPF($cpf)
|
|
|
378 |
$tam_cpf = strlen($cpf);
|
379 |
$cpf_limpo = "";
|
380 |
-
for ($i=0; $i<$tam_cpf; $i++)
|
381 |
-
|
382 |
-
|
383 |
-
$
|
|
|
|
|
|
|
384 |
}
|
385 |
-
if (strlen($cpf_limpo)!=11)
|
386 |
-
|
|
|
|
|
387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
// achar o primeiro digito verificador
|
389 |
$soma = 0;
|
390 |
-
for ($i=0; $i<9; $i++)
|
391 |
-
|
|
|
|
|
392 |
|
393 |
-
if ($soma == 0)
|
394 |
-
|
|
|
|
|
395 |
|
396 |
$primeiro_digito = 11 - $soma % 11;
|
397 |
|
398 |
-
if ($primeiro_digito > 9)
|
399 |
-
|
|
|
|
|
400 |
|
401 |
-
if (substr($cpf_limpo, 9, 1) != $primeiro_digito)
|
402 |
-
|
|
|
|
|
403 |
|
404 |
// acha o segundo digito verificador
|
405 |
$soma = 0;
|
406 |
-
for ($i=0; $i<10; $i++)
|
407 |
-
|
|
|
|
|
408 |
|
409 |
$segundo_digito = 11 - $soma % 11;
|
410 |
|
411 |
-
if ($segundo_digito > 9)
|
412 |
-
|
|
|
|
|
413 |
|
414 |
-
if (substr($cpf_limpo, 10, 1) != $segundo_digito)
|
415 |
-
|
|
|
|
|
416 |
|
417 |
return true;
|
418 |
}
|
419 |
|
420 |
|
421 |
-
function _validaCNPJ($cnpj)
|
|
|
422 |
$pontos = array(',','-','.','','/');
|
423 |
|
424 |
$cnpj = str_replace($pontos,'',$cnpj);
|
425 |
$cnpj = trim($cnpj);
|
426 |
-
if(empty($cnpj) || strlen($cnpj) != 14)
|
427 |
-
|
|
|
|
|
|
|
|
|
428 |
$rev_cnpj = strrev(substr($cnpj, 0, 12));
|
429 |
$sum = '';
|
430 |
-
for ($i = 0; $i <= 11; $i++)
|
|
|
431 |
$i == 0 ? $multiplier = 2 : $multiplier;
|
432 |
$i == 8 ? $multiplier = 2 : $multiplier;
|
433 |
$multiply = ($rev_cnpj[$i] * $multiplier);
|
@@ -443,21 +536,26 @@ $content = str_replace('<br />','',nl2br($content));
|
|
443 |
$rev_cnpj = strrev($sub_cnpj.$dv1);
|
444 |
unset($sum);
|
445 |
$sum = '';
|
446 |
-
for ($i = 0; $i <= 12; $i++)
|
|
|
447 |
$i == 0 ? $multiplier = 2 : $multiplier;
|
448 |
$i == 8 ? $multiplier = 2 : $multiplier;
|
449 |
$multiply = ($rev_cnpj[$i] * $multiplier);
|
450 |
$sum = $sum + $multiply;
|
451 |
$multiplier++;
|
452 |
-
|
453 |
}
|
454 |
$rest = $sum % 11;
|
455 |
if ($rest == 0 || $rest == 1) $dv2 = 0;
|
456 |
else $dv2 = 11 - $rest;
|
457 |
|
458 |
-
if ($dv1 == $cnpj[12] && $dv2 == $cnpj[13])
|
459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
}
|
461 |
}
|
462 |
-
|
463 |
}
|
16 |
*
|
17 |
* @version 1.0
|
18 |
* @date 02/13/2014
|
|
|
19 |
* @more info available on mzcart.com
|
20 |
*/
|
21 |
class Mzcart_Pagbrasil_ProcessingController extends Mage_Core_Controller_Front_Action
|
57 |
$billing = $order ->getBillingAddress();
|
58 |
$vatid = $billing->getVatId();
|
59 |
|
60 |
+
if($this -> _validaCPF($vatid) || $this -> _validaCNPJ($vatid))
|
61 |
+
{
|
62 |
// $session->addError(Mage::helper('pagbrasil')->__('The CPF OR CNPJ is valid!'));
|
63 |
// Mage::throwException(Mage::helper('pagbrasil')->__('The CPF OR CNPJ is valid!'));
|
64 |
+
}
|
65 |
+
else
|
66 |
+
{
|
67 |
Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
|
68 |
$session->addError(Mage::helper('pagbrasil')->__('The CPF or CNPJ is not valid!'));
|
69 |
//parent::_redirect('checkout/cart');
|
71 |
// exit();
|
72 |
Mage::throwException(Mage::helper('pagbrasil')->__('The CPF or CNPJ is not valid!'));
|
73 |
}
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
if($order->getState() != "pending_payment")
|
78 |
+
{
|
79 |
+
parent::_redirect('checkout/cart');
|
80 |
+
//die();
|
81 |
+
}
|
82 |
+
else
|
83 |
+
{
|
84 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
85 |
+
Mage::helper('pagbrasil')->__('The customer was redirected to PagBrasil.')
|
86 |
+
);
|
87 |
+
$order->save();
|
88 |
|
89 |
+
$session->setPagbrasilQuoteId($session->getQuoteId());
|
90 |
+
$session->setPagbrasilRealOrderId($session->getLastRealOrderId());
|
91 |
+
$session->getQuote()->setIsActive(true)->save();
|
92 |
+
//$session->getQuote()->setIsActive(false)->save();
|
93 |
+
//$session->clear();
|
94 |
|
95 |
+
$this->loadLayout();
|
96 |
+
$this->renderLayout();
|
97 |
+
}
|
98 |
} catch (Exception $e){
|
99 |
Mage::logException($e);
|
100 |
parent::_redirect('checkout/cart');
|
104 |
/**
|
105 |
* Obt:Action to which the customer will be returned when the payment is made.
|
106 |
*/
|
107 |
+
public function bankAction()
|
108 |
+
{
|
109 |
$session = $this->_getCheckout();
|
110 |
$session->getQuote()->setIsActive(true)->save();
|
111 |
$curl = curl_init('https://www.pagbrasil.com/pagbrasil/addorder.mv');
|
112 |
$request = '';
|
113 |
// $pm = '';$url = '';
|
114 |
$params = $this->getRequest()->getParams();
|
115 |
+
if (isset($params['order']))
|
116 |
+
{
|
117 |
+
$order_id = trim($params['order']);
|
118 |
+
}
|
119 |
+
else
|
120 |
+
{
|
121 |
+
die('Illegal Access');
|
122 |
+
}
|
123 |
+
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
124 |
+
foreach($params as $k => $v)
|
125 |
+
{
|
126 |
// if ($k == 'payment_method') {
|
127 |
// $pm = trim($v);
|
128 |
// }
|
152 |
error_log("\n" . $response . "\n",3,'logfile');
|
153 |
$msg = '';
|
154 |
$ok = 0;
|
155 |
+
if ($response!= false && substr($response, 0, 7) == 'http://' )
|
156 |
+
{
|
157 |
$ok = 1;
|
|
|
|
|
158 |
}
|
159 |
|
160 |
+
if ($ok == 1)
|
161 |
+
{
|
162 |
+
$msg = Mage::helper('pagbrasil')->__('The customer was redirected to bank.');
|
163 |
+
$_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
164 |
+
$_order->save();
|
165 |
+
$ok = header('Location: ' . $response);
|
166 |
+
die();
|
167 |
}
|
168 |
+
else
|
169 |
+
{
|
170 |
+
parent::_redirect('checkout/cart');
|
171 |
+
}
|
172 |
+
}
|
173 |
|
174 |
|
175 |
/**
|
176 |
* Cc(if mode)/Obt:Action to which the customer will be returned when the payment is made.
|
177 |
*/
|
178 |
+
public function returnAction()
|
179 |
+
{
|
180 |
// error_log(print_r($params,1),3,'abc');
|
181 |
$params = $this->getRequest()->getParams();
|
182 |
+
if (isset($params['order']))
|
183 |
+
{
|
184 |
$order_id = trim($params['order']);
|
185 |
+
}
|
186 |
+
else
|
187 |
+
{
|
188 |
die('Illegal Access');
|
189 |
}
|
190 |
|
191 |
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
192 |
|
193 |
+
if (!$_order->getId())
|
194 |
+
{
|
195 |
Mage::throwException('Order not found.');
|
196 |
}
|
197 |
|
212 |
$xml = new DOMDocument();
|
213 |
$xml->loadXML($response);
|
214 |
|
215 |
+
if ( isset($xml->getElementsByTagName('order_status')->item(0)->nodeValue))
|
216 |
+
{
|
217 |
$payment_status = $xml->getElementsByTagName('order_status')->item(0)->nodeValue;
|
218 |
+
switch ($payment_status)
|
219 |
+
{
|
220 |
+
case 'PC':$params['status'] = 2; break;
|
221 |
+
case 'PA':$params['status'] = 1; break;
|
222 |
+
case 'WP':$params['status'] = 0; break;
|
223 |
+
case 'PF':$params['status'] = -2; break;
|
224 |
+
case 'PR':$params['status'] = -2; break;
|
225 |
}
|
226 |
}
|
227 |
// var_dump($params);exit;
|
233 |
$event = Mage::getModel('pagbrasil/event')->setEventData($params);
|
234 |
$message = $event->processStatusEvent(false);
|
235 |
//var_dump($params);exit;
|
236 |
+
if($params['status'] < 1)
|
237 |
+
{
|
238 |
+
if($params["payment_method"] != "R" && $params["payment_method"] != "E" && $params["payment_method"] != "S")
|
239 |
+
{
|
240 |
+
$session->addError($message);
|
241 |
+
}
|
242 |
+
//Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
|
243 |
$this->_redirect('checkout/cart');
|
244 |
//exit();
|
245 |
+
}
|
246 |
+
elseif($params['status'] == 1)
|
247 |
+
{
|
248 |
+
$this->_redirect('checkout/onepage/success');
|
249 |
+
}
|
250 |
+
else
|
251 |
+
{
|
252 |
+
$quoteId = $event->successEvent();
|
253 |
$this->_getCheckout()->setLastSuccessQuoteId($quoteId);
|
254 |
// var_dump($session->getQuoteId());exit;
|
255 |
// var_dump($quoteId);exit;
|
261 |
}
|
262 |
//need a temp
|
263 |
//check the status action temp
|
264 |
+
}
|
|
|
|
|
265 |
|
266 |
/**
|
267 |
* Action to which the customer will be returned when the payment is made.
|
268 |
*/
|
269 |
+
public function postbackAction()
|
270 |
+
{
|
271 |
$params = $this->getRequest()->getParams();
|
272 |
|
273 |
error_log(print_r($params,1) . "\n\n",3,'logfile');
|
274 |
+
/*
|
275 |
+
$params =array(
|
276 |
+
'payment_method' => 'B',
|
277 |
+
'secret' => 'b1299d4c01b127f02851e3b726b75675615f8081',
|
278 |
+
'content' => '<boletos_list><boleto><order>100000033</order><payment_date>02/17/2014</payment_date><amount_paid>12.05</amount_paid><amount_due>12.05</amount_due><param_url>order=100000033</param_url></boleto></boletos_list>'
|
279 |
+
);
|
280 |
+
*/
|
281 |
|
282 |
+
if (isset($params['secret']))
|
283 |
+
{
|
284 |
$secret = trim($params['secret']);
|
285 |
+
}
|
286 |
+
else
|
287 |
+
{
|
288 |
die('Illegal Access');
|
289 |
}
|
290 |
|
291 |
$payment_method = trim($params['payment_method']);
|
292 |
+
switch($payment_method)
|
293 |
+
{
|
294 |
case 'B':
|
295 |
$content = trim(preg_replace('/\s+/', '',$params['content']));
|
296 |
$xml = new DOMDocument();
|
297 |
+
$content = str_replace('<br />','',nl2br($content));
|
298 |
$xml->loadXML($content);
|
299 |
$boletolist = $xml->getElementsByTagName('boleto');
|
300 |
+
foreach ($boletolist as $boleto)
|
301 |
+
{
|
302 |
$order_id = trim($boleto->childNodes->item(0)->nodeValue);
|
303 |
|
304 |
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
307 |
Mage::throwException('Order not found.');
|
308 |
}
|
309 |
$secret2 = Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY, $_order->getStoreId());
|
310 |
+
if ($secret != $secret2)
|
311 |
+
{
|
312 |
die('Illegal Access');
|
313 |
}
|
314 |
|
316 |
$amount_due = trim($boleto->childNodes->item(3)->nodeValue);
|
317 |
$amount_brl = $amount_paid;
|
318 |
|
319 |
+
if ($amount_paid == $amount_due )
|
320 |
+
{
|
321 |
$msg = Mage::helper('pagbrasil')->__('The order was paid.');
|
322 |
$_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $msg);
|
323 |
$_order->save();
|
324 |
$_order->getPayment()->setLastTransId($order_id);
|
325 |
$_order->sendNewOrderEmail();
|
326 |
$_order->setEmailSent(true);
|
327 |
+
}
|
328 |
+
else
|
329 |
+
{
|
330 |
+
$msg = Mage::helper('pagbrasil')->__('The order was partialy paid. Amount Due: %s, Amount Paid: %s.');
|
331 |
$msg = sprintf($msg, $amount_due, $amount_paid);
|
332 |
$_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
|
333 |
$_order->getPayment()->setLastTransId($order_id);
|
334 |
}
|
335 |
$_order->save();
|
336 |
}
|
|
|
|
|
337 |
break;
|
338 |
default:
|
339 |
$payment_status = $params['payment_status'];
|
340 |
+
switch ($payment_status)
|
341 |
+
{
|
342 |
+
case 'A':$params['status'] = $params['cc_auth'] == 1 ? 1 : 2; break;
|
343 |
+
case 'F':$params['status'] = -2; break;
|
344 |
+
case 'R':$params['status'] = 0; break;
|
345 |
+
case 'C':$params['status'] = -1; break;
|
346 |
+
case 'P':$params['status'] = -1; break;
|
347 |
}
|
348 |
$event = Mage::getModel('pagbrasil/event')->setEventData($params);
|
349 |
$message = $event->processStatusEvent();
|
350 |
}
|
351 |
|
352 |
+
echo 'Received successfully in '.time();
|
353 |
+
die();
|
354 |
}
|
355 |
|
356 |
/**
|
357 |
* Obt:Action to which the customer will be returned when the payment is made.
|
358 |
*/
|
359 |
+
public function successAction()
|
360 |
+
{
|
361 |
$event = Mage::getModel('pagbrasil/event')
|
362 |
->setEventData($this->getRequest()->getParams());
|
363 |
+
try
|
364 |
+
{
|
365 |
$quoteId = $event->successEvent();
|
366 |
$this->_getCheckout()->setLastSuccessQuoteId($quoteId);
|
367 |
$this->_redirect('checkout/onepage/success');
|
368 |
return;
|
369 |
+
}
|
370 |
+
catch (Mage_Core_Exception $e)
|
371 |
+
{
|
372 |
$this->_getCheckout()->addError($e->getMessage());
|
373 |
+
}
|
374 |
+
catch(Exception $e)
|
375 |
+
{
|
376 |
Mage::logException($e);
|
377 |
}
|
378 |
$this->_redirect('checkout/cart');
|
433 |
return $this;
|
434 |
}
|
435 |
|
436 |
+
function _validaCPF($cpf)
|
437 |
+
{
|
438 |
$tam_cpf = strlen($cpf);
|
439 |
$cpf_limpo = "";
|
440 |
+
for ($i=0; $i<$tam_cpf; $i++)
|
441 |
+
{
|
442 |
+
$carac = substr($cpf, $i, 1);
|
443 |
+
if (ord($carac)>=48 && ord($carac)<=57)
|
444 |
+
{
|
445 |
+
$cpf_limpo .= $carac;
|
446 |
+
}
|
447 |
}
|
448 |
+
if (strlen($cpf_limpo)!=11)
|
449 |
+
{
|
450 |
+
return false;
|
451 |
+
}
|
452 |
|
453 |
+
for($i = 0; $i <= 9; $i++)
|
454 |
+
{
|
455 |
+
if(str_repeat($i, 11) == $cpf_limpo)
|
456 |
+
{
|
457 |
+
return false;
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
// achar o primeiro digito verificador
|
462 |
$soma = 0;
|
463 |
+
for ($i=0; $i<9; $i++)
|
464 |
+
{
|
465 |
+
$soma += (int)substr($cpf_limpo, $i, 1) * (10-$i);
|
466 |
+
}
|
467 |
|
468 |
+
if ($soma == 0)
|
469 |
+
{
|
470 |
+
return false;
|
471 |
+
}
|
472 |
|
473 |
$primeiro_digito = 11 - $soma % 11;
|
474 |
|
475 |
+
if ($primeiro_digito > 9)
|
476 |
+
{
|
477 |
+
$primeiro_digito = 0;
|
478 |
+
}
|
479 |
|
480 |
+
if (substr($cpf_limpo, 9, 1) != $primeiro_digito)
|
481 |
+
{
|
482 |
+
return false;
|
483 |
+
}
|
484 |
|
485 |
// acha o segundo digito verificador
|
486 |
$soma = 0;
|
487 |
+
for ($i=0; $i<10; $i++)
|
488 |
+
{
|
489 |
+
$soma += (int)substr($cpf_limpo, $i, 1) * (11-$i);
|
490 |
+
}
|
491 |
|
492 |
$segundo_digito = 11 - $soma % 11;
|
493 |
|
494 |
+
if ($segundo_digito > 9)
|
495 |
+
{
|
496 |
+
$segundo_digito = 0;
|
497 |
+
}
|
498 |
|
499 |
+
if (substr($cpf_limpo, 10, 1) != $segundo_digito)
|
500 |
+
{
|
501 |
+
return false;
|
502 |
+
}
|
503 |
|
504 |
return true;
|
505 |
}
|
506 |
|
507 |
|
508 |
+
function _validaCNPJ($cnpj)
|
509 |
+
{
|
510 |
$pontos = array(',','-','.','','/');
|
511 |
|
512 |
$cnpj = str_replace($pontos,'',$cnpj);
|
513 |
$cnpj = trim($cnpj);
|
514 |
+
if(empty($cnpj) || strlen($cnpj) != 14)
|
515 |
+
{
|
516 |
+
return false;
|
517 |
+
}
|
518 |
+
else
|
519 |
+
{
|
520 |
$rev_cnpj = strrev(substr($cnpj, 0, 12));
|
521 |
$sum = '';
|
522 |
+
for ($i = 0; $i <= 11; $i++)
|
523 |
+
{
|
524 |
$i == 0 ? $multiplier = 2 : $multiplier;
|
525 |
$i == 8 ? $multiplier = 2 : $multiplier;
|
526 |
$multiply = ($rev_cnpj[$i] * $multiplier);
|
536 |
$rev_cnpj = strrev($sub_cnpj.$dv1);
|
537 |
unset($sum);
|
538 |
$sum = '';
|
539 |
+
for ($i = 0; $i <= 12; $i++)
|
540 |
+
{
|
541 |
$i == 0 ? $multiplier = 2 : $multiplier;
|
542 |
$i == 8 ? $multiplier = 2 : $multiplier;
|
543 |
$multiply = ($rev_cnpj[$i] * $multiplier);
|
544 |
$sum = $sum + $multiply;
|
545 |
$multiplier++;
|
|
|
546 |
}
|
547 |
$rest = $sum % 11;
|
548 |
if ($rest == 0 || $rest == 1) $dv2 = 0;
|
549 |
else $dv2 = 11 - $rest;
|
550 |
|
551 |
+
if ($dv1 == $cnpj[12] && $dv2 == $cnpj[13])
|
552 |
+
{
|
553 |
+
return true; //$cnpj;
|
554 |
+
}
|
555 |
+
else
|
556 |
+
{
|
557 |
+
return false;
|
558 |
+
}
|
559 |
}
|
560 |
}
|
|
|
561 |
}
|
app/code/community/Mzcart/Pagbrasil/etc/config.xml
CHANGED
@@ -17,14 +17,13 @@
|
|
17 |
*
|
18 |
* @version 1.0
|
19 |
* @date 02/13/2014
|
20 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
21 |
* @more info available on mzcart.com
|
22 |
*/
|
23 |
-->
|
24 |
<config>
|
25 |
<modules>
|
26 |
<Mzcart_Pagbrasil>
|
27 |
-
<version>
|
28 |
</Mzcart_Pagbrasil>
|
29 |
</modules>
|
30 |
<global>
|
@@ -138,6 +137,7 @@
|
|
138 |
<pagbrasil_acc>
|
139 |
<group>pbrasils</group>
|
140 |
<active>0</active>
|
|
|
141 |
<model>pagbrasil/acc</model>
|
142 |
<title>Visa, Mastercard, Diners, American Express, Hipercard, Elo, Aura</title>
|
143 |
<allowspecific>0</allowspecific>
|
17 |
*
|
18 |
* @version 1.0
|
19 |
* @date 02/13/2014
|
|
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
-->
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Mzcart_Pagbrasil>
|
26 |
+
<version>2.2.0</version>
|
27 |
</Mzcart_Pagbrasil>
|
28 |
</modules>
|
29 |
<global>
|
137 |
<pagbrasil_acc>
|
138 |
<group>pbrasils</group>
|
139 |
<active>0</active>
|
140 |
+
<preauth>0</preauth>
|
141 |
<model>pagbrasil/acc</model>
|
142 |
<title>Visa, Mastercard, Diners, American Express, Hipercard, Elo, Aura</title>
|
143 |
<allowspecific>0</allowspecific>
|
app/code/community/Mzcart/Pagbrasil/etc/system.xml
CHANGED
@@ -17,7 +17,6 @@
|
|
17 |
*
|
18 |
* @version 1.0
|
19 |
* @date 02/13/2014
|
20 |
-
* @author george zheng <xinhaozheng@gmail.com>
|
21 |
* @more info available on mzcart.com
|
22 |
*/
|
23 |
-->
|
@@ -78,6 +77,17 @@
|
|
78 |
<show_in_website>1</show_in_website>
|
79 |
<show_in_store>1</show_in_store>
|
80 |
</active>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
<sort_order translate="label">
|
82 |
<label>Sort Order</label>
|
83 |
<frontend_type>text</frontend_type>
|
17 |
*
|
18 |
* @version 1.0
|
19 |
* @date 02/13/2014
|
|
|
20 |
* @more info available on mzcart.com
|
21 |
*/
|
22 |
-->
|
77 |
<show_in_website>1</show_in_website>
|
78 |
<show_in_store>1</show_in_store>
|
79 |
</active>
|
80 |
+
<preauth translate="label">
|
81 |
+
<label>Pre-authorize only</label>
|
82 |
+
<comment>IMPORTANT: If you activate this option you will need to manually capture each transaction at the PagBrasil Merchant Interface. Pre-authorizations that are not captured will expire after 4 days.</comment>
|
83 |
+
<frontend_type>select</frontend_type>
|
84 |
+
<config_path>payment/pagbrasil_acc/preauth</config_path>
|
85 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
86 |
+
<sort_order>2</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
</preauth>
|
91 |
<sort_order translate="label">
|
92 |
<label>Sort Order</label>
|
93 |
<frontend_type>text</frontend_type>
|
app/design/frontend/base/default/template/pagbrasil/payment.phtml
CHANGED
@@ -26,46 +26,83 @@
|
|
26 |
?>
|
27 |
<?php
|
28 |
// var_dump($this->getPagbrasilMethod());
|
29 |
-
if($this->getPagbrasilMethod() == 'pagbrasil_bb')
|
|
|
30 |
$bburl = $this->getBbUrl();
|
31 |
$srcstr = ($bburl == false) ? '' : $bburl;
|
32 |
-
//
|
33 |
}
|
34 |
?>
|
35 |
<div class="page-head">
|
36 |
<h3>
|
37 |
-
<?php
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
</h3>
|
41 |
</div>
|
42 |
<table style="width:100%;">
|
43 |
<tr>
|
44 |
<td style="width:75%">
|
45 |
-
<?php
|
46 |
-
|
|
|
|
|
47 |
<iframe id="tpagbrasilframe" name="tpagbrasilframe" frameborder=0 style="width:100%; height:750px;border:none;background:url(''; " <?php echo isset($srcstr)?$srcstr:'';?> >
|
48 |
-
|
49 |
</iframe>
|
50 |
|
51 |
-
<?php
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
<p><?php echo Mage::helper('pagbrasil')->__("Please select the bank to checkout");?></p>
|
57 |
-
<form name="pagbrasil_obt" id="pagbrasil_obt" action="<?php echo Mage::getUrl('pagbrasil/processing/bank')
|
58 |
-
<?php
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
<select name="payment_method" id="payment_method" class="validate-select">
|
65 |
<option value=""><?php echo Mage::helper('pagbrasil')->__("Please select your bank");?></option>
|
66 |
-
<?php
|
|
|
|
|
|
|
67 |
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
|
68 |
-
<?php
|
|
|
|
|
69 |
</select>
|
70 |
<br />
|
71 |
<br />
|
@@ -77,22 +114,33 @@ if($this->getPagbrasilMethod() == 'pagbrasil_bb') {
|
|
77 |
var dataForm = new VarienForm('pagbrasil_obt', true);
|
78 |
//]]>
|
79 |
</script>
|
80 |
-
<?php
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
</tr>
|
85 |
</table>
|
86 |
|
87 |
-
<?php
|
88 |
-
|
89 |
-
|
|
|
90 |
<form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
|
91 |
-
<?php
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
<input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
|
94 |
-
<?php
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
</form>
|
97 |
|
98 |
<script type="text/javascript">
|
@@ -103,5 +151,7 @@ if($this->getPagbrasilMethod() == 'pagbrasil_bb') {
|
|
103 |
</script>
|
104 |
|
105 |
|
106 |
-
<?php
|
|
|
|
|
107 |
|
26 |
?>
|
27 |
<?php
|
28 |
// var_dump($this->getPagbrasilMethod());
|
29 |
+
if($this->getPagbrasilMethod() == 'pagbrasil_bb')
|
30 |
+
{
|
31 |
$bburl = $this->getBbUrl();
|
32 |
$srcstr = ($bburl == false) ? '' : $bburl;
|
33 |
+
//var_dump($srcstr);
|
34 |
}
|
35 |
?>
|
36 |
<div class="page-head">
|
37 |
<h3>
|
38 |
+
<?php
|
39 |
+
if($this->getPagbrasilMethod() == 'pagbrasil_bb')
|
40 |
+
{
|
41 |
+
if($srcstr != '')
|
42 |
+
{
|
43 |
+
?>
|
44 |
+
<a href="<?php echo $srcstr ?>" target="_blank"><?php echo Mage::helper('pagbrasil')->__('Please click here to view or print your boleto bancario'); ?></a>
|
45 |
+
<?php
|
46 |
+
}
|
47 |
+
else
|
48 |
+
{
|
49 |
+
?>
|
50 |
+
<p><?php echo Mage::helper('pagbrasil')->__('An error occurred while generating the boleto bancario.'); ?></p>
|
51 |
+
<?php
|
52 |
+
}
|
53 |
+
}
|
54 |
+
else
|
55 |
+
{
|
56 |
+
echo Mage::helper('pagbrasil')->__('Payment');
|
57 |
+
}
|
58 |
+
?>
|
59 |
</h3>
|
60 |
</div>
|
61 |
<table style="width:100%;">
|
62 |
<tr>
|
63 |
<td style="width:75%">
|
64 |
+
<?php
|
65 |
+
if($this->getPagbrasilMethod() == 'pagbrasil_acc')
|
66 |
+
{
|
67 |
+
?>
|
68 |
<iframe id="tpagbrasilframe" name="tpagbrasilframe" frameborder=0 style="width:100%; height:750px;border:none;background:url(''; " <?php echo isset($srcstr)?$srcstr:'';?> >
|
69 |
+
<img src="<?php echo $this->getSkinUrl("images/pagbrasil/loading.gif");?>" />
|
70 |
</iframe>
|
71 |
|
72 |
+
<?php
|
73 |
+
}
|
74 |
+
elseif($this->getPagbrasilMethod() == 'pagbrasil_obt')
|
75 |
+
{
|
76 |
+
?>
|
77 |
<p><?php echo Mage::helper('pagbrasil')->__("Please select the bank to checkout");?></p>
|
78 |
+
<form name="pagbrasil_obt" id="pagbrasil_obt" action="<?php echo Mage::getUrl('pagbrasil/processing/bank');?>" method="POST">
|
79 |
+
<?php
|
80 |
+
if(is_array($this->getFormData()))
|
81 |
+
{
|
82 |
+
foreach ($this->getFormData() as $name => $value)
|
83 |
+
{
|
84 |
+
if ($name == 'payment_method')
|
85 |
+
{
|
86 |
+
continue;
|
87 |
+
}
|
88 |
+
?>
|
89 |
+
<input type="hidden" name="<?php echo $name;?>" value="<?php echo $value;?>"/>
|
90 |
+
<?php
|
91 |
+
}
|
92 |
+
?>
|
93 |
+
<?php
|
94 |
+
}
|
95 |
+
?>
|
96 |
<select name="payment_method" id="payment_method" class="validate-select">
|
97 |
<option value=""><?php echo Mage::helper('pagbrasil')->__("Please select your bank");?></option>
|
98 |
+
<?php
|
99 |
+
foreach ($this->getObtBanks() as $k => $v)
|
100 |
+
{
|
101 |
+
?>
|
102 |
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
|
103 |
+
<?php
|
104 |
+
}
|
105 |
+
?>
|
106 |
</select>
|
107 |
<br />
|
108 |
<br />
|
114 |
var dataForm = new VarienForm('pagbrasil_obt', true);
|
115 |
//]]>
|
116 |
</script>
|
117 |
+
<?php
|
118 |
+
}
|
119 |
+
?>
|
120 |
+
</td>
|
121 |
</tr>
|
122 |
</table>
|
123 |
|
124 |
+
<?php
|
125 |
+
if ($this->getPagbrasilMethod() == 'pagbrasil_acc') //credit card payment
|
126 |
+
{
|
127 |
+
?>
|
128 |
<form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
|
129 |
+
<?php
|
130 |
+
if(is_array($this->getFormData()))
|
131 |
+
{
|
132 |
+
?>
|
133 |
+
<?php
|
134 |
+
foreach ($this->getFormData() as $name => $value)
|
135 |
+
{
|
136 |
+
?>
|
137 |
<input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
|
138 |
+
<?php
|
139 |
+
}
|
140 |
+
?>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
?>
|
144 |
</form>
|
145 |
|
146 |
<script type="text/javascript">
|
151 |
</script>
|
152 |
|
153 |
|
154 |
+
<?php
|
155 |
+
}
|
156 |
+
?>
|
157 |
|
app/locale/pt_BR/Mzcart_Pagbrasil.csv
CHANGED
@@ -14,3 +14,4 @@
|
|
14 |
"Please select your bank","Por favor selecione o seu banco"
|
15 |
"Payment","Pagamento"
|
16 |
"Please click here to view or print your boleto bancario","Por favor, clique aqui para visualizar e imprimir seu boleto bancário"
|
|
14 |
"Please select your bank","Por favor selecione o seu banco"
|
15 |
"Payment","Pagamento"
|
16 |
"Please click here to view or print your boleto bancario","Por favor, clique aqui para visualizar e imprimir seu boleto bancário"
|
17 |
+
"An error occurred while generating the boleto bancario.","Ocorreu um erro ao emitir o boleto bancário."
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PagBrasil</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
@@ -48,11 +48,13 @@ Contact us
|
|
48 |
We will be glad to assist you on opening a merchant account with us. Please contact us at https://www.pagbrasil.com/pb/contact-us.html for more information on how PagBrasil can multiply your sales. 
|
49 |

|
50 |
Or visit our website www.pagbrasil.com</description>
|
51 |
-
<notes>
|
|
|
|
|
52 |
<authors><author><name>PagBrasil</name><user>PagBrasil</user><email>support@pagbrasil.com</email></author></authors>
|
53 |
-
<date>
|
54 |
-
<time>
|
55 |
-
<contents><target name="magecommunity"><dir name="Mzcart"><dir name="Pagbrasil"><dir name="Block"><file name="Form.php" hash="ba94fcaafb4e285e04e05cb910ffa417"/><file name="Info.php" hash="3124b6b54fe204541371f73fe244fd9c"/><file name="Payment.php" hash="c37ce4f038ddf9d07b194ae8bd358cfa"/><file name="Redirect.php" hash="dcb5b438b357ef72247b9949e3894939"/></dir><dir name="Helper"><file name="Data.php" hash="91dc606b4f412f5fa4c21fe6bbd6258a"/></dir><dir name="Model"><file name="Abstract.php" hash="
|
56 |
<compatible/>
|
57 |
-
<dependencies><required><php><min>5.2.0</min><max>
|
58 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PagBrasil</name>
|
4 |
+
<version>2.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
48 |
We will be glad to assist you on opening a merchant account with us. Please contact us at https://www.pagbrasil.com/pb/contact-us.html for more information on how PagBrasil can multiply your sales. 
|
49 |

|
50 |
Or visit our website www.pagbrasil.com</description>
|
51 |
+
<notes>Minor bug fixes.
|
52 |
+

|
53 |
+
This plugin is only compatible to Magento's checkout type OnePage.</notes>
|
54 |
<authors><author><name>PagBrasil</name><user>PagBrasil</user><email>support@pagbrasil.com</email></author></authors>
|
55 |
+
<date>2015-03-11</date>
|
56 |
+
<time>14:52:10</time>
|
57 |
+
<contents><target name="magecommunity"><dir name="Mzcart"><dir name="Pagbrasil"><dir name="Block"><file name="Form.php" hash="ba94fcaafb4e285e04e05cb910ffa417"/><file name="Info.php" hash="3124b6b54fe204541371f73fe244fd9c"/><file name="Payment.php" hash="c37ce4f038ddf9d07b194ae8bd358cfa"/><file name="Redirect.php" hash="dcb5b438b357ef72247b9949e3894939"/></dir><dir name="Helper"><file name="Data.php" hash="91dc606b4f412f5fa4c21fe6bbd6258a"/></dir><dir name="Model"><file name="Abstract.php" hash="f5146720c1ed8d914748476d83d31183"/><file name="Acc.php" hash="5ac5b99d5348bd364a78888ac81aaac8"/><file name="Bb.php" hash="e92c6b31e3b1ef1d3ae8b6b013ada7e6"/><file name="Event.php" hash="548fb8c163d24c9628ce78c12652c187"/><file name="Obt.php" hash="98a85c14af2b0135d26978a009c846e7"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="e9002a1eba32f51d044af0f8c9608e85"/></dir><dir name="etc"><file name="config.xml" hash="67632770c0cd477550ebb1c10bc9db41"/><file name="system.xml" hash="d8663ac53ddbea9fdeec6c86f90dda4a"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pagbrasil.xml" hash="0dfc4e1e75fa4d8385e130d3fa746920"/></dir><dir name="template"><dir name="pagbrasil"><file name="form.phtml" hash="e167e921f46ba54c8ef60af6eb99faef"/><file name="info.phtml" hash="b1ae519e4d9d4984494ba89d10a46243"/><file name="payment-ajax.phtml" hash="6e4d66f6bd5355971c8732c734495a24"/><file name="payment-single-col.phtml" hash="085788edf01d03b830dede92fea785c8"/><file name="payment.phtml" hash="13247d47c87a70f332c9f51145939e2b"/><file name="redirect.phtml" hash="99811d651f215827bbd85db9ade1824b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Mzcart_Pagbrasil.csv" hash="a0eddefab5bd2dd016a3a0621c965a3a"/></dir><dir name="pt_BR"><file name="Mzcart_Pagbrasil.csv" hash="180c6f081be434452c437cdc16465c58"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="pagbrasil"><file name="Thumbs.db" hash="01a92737de4b94181521fb8e47f61c24"/><file name="loading.gif" hash="e27e38e1eac6c9e8736bf8d63044289c"/><file name="pagbrasil_acc.gif" hash="d0c923e9530e02ef737de436b8cdb347"/><file name="pagbrasil_bb.gif" hash="c918b6473bd26fc8b7f98bfe94551430"/><file name="pagbrasil_obt.gif" hash="dfe033cd9116b6bd3bf015eeff63d35b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mzcart_Pagbrasil.xml" hash="755c1aa1443bef3423a3c68272e5a72e"/></dir></target></contents>
|
58 |
<compatible/>
|
59 |
+
<dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
|
60 |
</package>
|