PagBrasil - Version 2.1.2

Version Notes

Initial release.

Download this release

Release Info

Developer PagBrasil
Extension PagBrasil
Version 2.1.2
Comparing to
See all releases


Version 2.1.2

Files changed (29) hide show
  1. app/code/community/Mzcart/Pagbrasil/Block/Form.php +95 -0
  2. app/code/community/Mzcart/Pagbrasil/Block/Info.php +53 -0
  3. app/code/community/Mzcart/Pagbrasil/Block/Payment.php +94 -0
  4. app/code/community/Mzcart/Pagbrasil/Block/Redirect.php +32 -0
  5. app/code/community/Mzcart/Pagbrasil/Helper/Data.php +27 -0
  6. app/code/community/Mzcart/Pagbrasil/Model/Abstract.php +222 -0
  7. app/code/community/Mzcart/Pagbrasil/Model/Acc.php +59 -0
  8. app/code/community/Mzcart/Pagbrasil/Model/Bb.php +73 -0
  9. app/code/community/Mzcart/Pagbrasil/Model/Event.php +250 -0
  10. app/code/community/Mzcart/Pagbrasil/Model/Obt.php +61 -0
  11. app/code/community/Mzcart/Pagbrasil/controllers/ProcessingController.php +463 -0
  12. app/code/community/Mzcart/Pagbrasil/etc/config.xml +164 -0
  13. app/code/community/Mzcart/Pagbrasil/etc/system.xml +243 -0
  14. app/design/frontend/base/default/layout/pagbrasil.xml +34 -0
  15. app/design/frontend/base/default/template/pagbrasil/form.phtml +39 -0
  16. app/design/frontend/base/default/template/pagbrasil/info.phtml +32 -0
  17. app/design/frontend/base/default/template/pagbrasil/payment-ajax.phtml +94 -0
  18. app/design/frontend/base/default/template/pagbrasil/payment-single-col.phtml +96 -0
  19. app/design/frontend/base/default/template/pagbrasil/payment.phtml +107 -0
  20. app/design/frontend/base/default/template/pagbrasil/redirect.phtml +29 -0
  21. app/etc/modules/Mzcart_Pagbrasil.xml +32 -0
  22. app/locale/en_US/Mzcart_Pagbrasil.csv +16 -0
  23. app/locale/pt_BR/Mzcart_Pagbrasil.csv +16 -0
  24. package.xml +58 -0
  25. skin/frontend/base/default/images/pagbrasil/Thumbs.db +0 -0
  26. skin/frontend/base/default/images/pagbrasil/loading.gif +0 -0
  27. skin/frontend/base/default/images/pagbrasil/pagbrasil_acc.gif +0 -0
  28. skin/frontend/base/default/images/pagbrasil/pagbrasil_bb.gif +0 -0
  29. skin/frontend/base/default/images/pagbrasil/pagbrasil_obt.gif +0 -0
app/code/community/Mzcart/Pagbrasil/Block/Form.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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_Block_Form extends Mage_Payment_Block_Form
23
+ {
24
+ /**
25
+ * Available locales for content URL generation
26
+ *
27
+ * @var array
28
+ */
29
+ protected $_supportedInfoLocales = array('de');
30
+
31
+ /**
32
+ * Default locale for content URL generation
33
+ *
34
+ * @var string
35
+ */
36
+ protected $_defaultInfoLocale = 'en';
37
+
38
+ /**
39
+ * Constructor. Set template.
40
+ */
41
+ protected function _construct()
42
+ {
43
+ parent::_construct();
44
+ $this->setTemplate('pagbrasil/form.phtml');
45
+ }
46
+
47
+ /**
48
+ * Return payment logo image src
49
+ *
50
+ * @param string $payment Payment Code
51
+ * @return string|bool
52
+ */
53
+ public function getPaymentImageSrc($payment)
54
+ {
55
+ // if ($payment == 'pagbrasil_obt') {
56
+ // $payment .= '_'.$this->getInfoLocale();
57
+ // }
58
+
59
+ $imageFilename = Mage::getDesign()
60
+ ->getFilename('images' . DS . 'pagbrasil' . DS . $payment, array('_type' => 'skin'));
61
+
62
+ if (file_exists($imageFilename . '.png')) {
63
+ return $this->getSkinUrl('images/pagbrasil/' . $payment . '.png');
64
+ } else if (file_exists($imageFilename . '.gif')) {
65
+ return $this->getSkinUrl('images/pagbrasil/' . $payment . '.gif');
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Return supported locale for information text
73
+ *
74
+ * @return string
75
+ */
76
+ public function getInfoLocale()
77
+ {
78
+ $locale = substr(Mage::app()->getLocale()->getLocaleCode(), 0 ,2);
79
+ if (!in_array($locale, $this->_supportedInfoLocales)) {
80
+ $locale = $this->_defaultInfoLocale;
81
+ }
82
+ return $locale;
83
+ }
84
+
85
+ /**
86
+ * Return info URL for eWallet payment
87
+ *
88
+ * @return string
89
+ */
90
+ public function getBbInfoUrl()
91
+ {
92
+ $locale = substr(Mage::app()->getLocale()->getLocaleCode(), 0 ,2);
93
+ return 'http://www.pagbrasil.com/pb/services/payment-method/boleto-bancario.html?l=' . strtoupper($locale);
94
+ }
95
+ }
app/code/community/Mzcart/Pagbrasil/Block/Info.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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_Block_Info extends Mage_Payment_Block_Info
23
+ {
24
+ /**
25
+ * Constructor. Set template.
26
+ */
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('pagbrasil/info.phtml');
31
+ }
32
+
33
+ /**
34
+ * Returns code of payment method
35
+ *
36
+ * @return string
37
+ */
38
+ public function getMethodCode()
39
+ {
40
+ return $this->getInfo()->getMethodInstance()->getCode();
41
+ }
42
+
43
+ /**
44
+ * Build PDF content of info block
45
+ *
46
+ * @return string
47
+ */
48
+ public function toPdf()
49
+ {
50
+ $this->setTemplate('pagbrasil/pdf/info.phtml');
51
+ return $this->toHtml();
52
+ }
53
+ }
app/code/community/Mzcart/Pagbrasil/Block/Payment.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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_Block_Payment extends Mage_Core_Block_Template
23
+ {
24
+
25
+ /**
26
+ * Return checkout session instance
27
+ *
28
+ * @return Mage_Checkout_Model_Session
29
+ */
30
+ protected function _getCheckout()
31
+ {
32
+ return Mage::getSingleton('checkout/session');
33
+ }
34
+
35
+ /**
36
+ * Return order instance
37
+ *
38
+ * @return Mage_Sales_Model_Order|null
39
+ */
40
+ protected function _getOrder()
41
+ {
42
+ if ($this->getOrder()) {
43
+ return $this->getOrder();
44
+ } elseif ($orderIncrementId = $this->_getCheckout()->getLastRealOrderId()) {
45
+ return Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
46
+ } else {
47
+ return null;
48
+ }
49
+ }
50
+ public function getPagbrasilMethod() {
51
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getCode();
52
+ }
53
+
54
+ /**
55
+ * Get Form data by using ogone payment api
56
+ *
57
+ * @return array
58
+ */
59
+ public function getFormData()
60
+ {
61
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getFormFields();
62
+ }
63
+
64
+ /**
65
+ * Getting gateway url
66
+ *
67
+ * @return string
68
+ */
69
+ public function getFormAction()
70
+ {
71
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getUrl();
72
+ }
73
+
74
+ /**
75
+ * Getting Boleto Banc��rio url
76
+ *
77
+ * @return string
78
+ */
79
+ public function getBbUrl()
80
+ {
81
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getBolUrl();
82
+ }
83
+
84
+ /**
85
+ * Getting Boleto Banc��rio url
86
+ *
87
+ * @return string
88
+ */
89
+ public function getObtBanks()
90
+ {
91
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getObtBanks();
92
+ }
93
+
94
+ }
app/code/community/Mzcart/Pagbrasil/Block/Redirect.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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_Block_Redirect extends Mage_Core_Block_Template
23
+ {
24
+ /**
25
+ * Constructor. Set template.
26
+ */
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('pagbrasil/redirect.phtml');
31
+ }
32
+ }
app/code/community/Mzcart/Pagbrasil/Helper/Data.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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_Helper_Data extends Mage_Payment_Helper_Data
23
+ {
24
+ const XML_PATH_EMAIL = 'pagbrasil/settings/pagbrasil_email';
25
+ const XML_PATH_SECRET_KEY = 'pagbrasil/settings/secret_key';
26
+ const XML_PATH_PAGBRASIL_TOKEN = 'pagbrasil/settings/pagbrasil_token';
27
+ }
app/code/community/Mzcart/Pagbrasil/Model/Abstract.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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
23
+ {
24
+ /**
25
+ * unique internal payment method identifier
26
+ */
27
+ protected $_code = 'pagbrasil_abstract';
28
+
29
+ protected $_formBlockType = 'pagbrasil/form';
30
+ protected $_infoBlockType = 'pagbrasil/info';
31
+
32
+ /**
33
+ * Availability options
34
+ */
35
+ protected $_isGateway = true;
36
+ protected $_canAuthorize = true;
37
+ protected $_canCapture = true;
38
+ protected $_canCapturePartial = false;
39
+ protected $_canRefund = false;
40
+ protected $_canVoid = false;
41
+ protected $_canUseInternal = false;
42
+ protected $_canUseCheckout = true;
43
+ protected $_canUseForMultishipping = false;
44
+
45
+ protected $_paymentMethod = 'abstract';
46
+ protected $_defaultLocale = 'en';
47
+ protected $_supportedLocales = array('cn', 'cz', 'da', 'en', 'es', 'fi', 'de', 'fr', 'gr', 'it', 'nl', 'ro', 'ru', 'pl', 'sv', 'tr');
48
+ protected $_hidelogin = '1';
49
+
50
+ protected $_order;
51
+
52
+ /**
53
+ * Get order model
54
+ *
55
+ * @return Mage_Sales_Model_Order
56
+ */
57
+ public function getOrder()
58
+ {
59
+ if (!$this->_order) {
60
+ $this->_order = $this->getInfoInstance()->getOrder();
61
+ }
62
+ return $this->_order;
63
+ }
64
+
65
+ /**
66
+ * Return url for redirection after order placed
67
+ * @return string
68
+ */
69
+ public function getOrderPlaceRedirectUrl()
70
+ {
71
+ return Mage::getUrl('pagbrasil/processing/payment');
72
+ }
73
+
74
+ /**
75
+ * Capture payment through PagBrasil api
76
+ *
77
+ * @param Varien_Object $payment
78
+ * @param decimal $amount
79
+ * @return Mzcart_Pagbrasil_Model_Abstract
80
+ */
81
+ public function capture(Varien_Object $payment, $amount)
82
+ {
83
+ $payment->setStatus(self::STATUS_APPROVED)
84
+ ->setTransactionId($this->getTransactionId())
85
+ ->setIsTransactionClosed(0);
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Camcel payment
92
+ *
93
+ * @param Varien_Object $payment
94
+ * @return Mzcart_Pagbrasil_Model_Abstract
95
+ */
96
+ public function cancel(Varien_Object $payment)
97
+ {
98
+ $payment->setStatus(self::STATUS_DECLINED)
99
+ ->setTransactionId($this->getTransactionId())
100
+ ->setIsTransactionClosed(1);
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Return url of payment method
107
+ *
108
+ * @return string
109
+ */
110
+ public function getUrl()
111
+ {
112
+ return 'https://www.pagbrasil.com/pagbrasil/addorder.mv';
113
+ }
114
+
115
+ /**
116
+ * Return url of payment method
117
+ *
118
+ * @return string
119
+ */
120
+ public function getLocale()
121
+ {
122
+ $locale = explode('_', Mage::app()->getLocale()->getLocaleCode());
123
+ if (is_array($locale) && !empty($locale) && in_array($locale[0], $this->_supportedLocales)) {
124
+ return $locale[0];
125
+ }
126
+ return $this->getDefaultLocale();
127
+ }
128
+
129
+ /**
130
+ * prepare params array to send it to gateway page via POST
131
+ *
132
+ * @return array
133
+ */
134
+ //@todo _form
135
+ public function _getCommonFields() {
136
+ $order_id = $this->getOrder()->getRealOrderId();
137
+ $billing = $this->getOrder()->getBillingAddress();
138
+
139
+ if ($billing->getEmail()) {
140
+ $email = $billing->getEmail();
141
+ } else {
142
+ $email = $this->getOrder()->getCustomerEmail();
143
+ }
144
+
145
+ $_order = $this->getOrder();
146
+ //prepare amount in BRL
147
+ $storeCurrency = Mage::getSingleton('directory/currency')->load($_order->getBaseCurrencyCode());
148
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
149
+ $allowed_cur = array('BRL');
150
+ if ( !in_array($currency, $allowed_cur)) {
151
+ $amount = sprintf('%.2f', $storeCurrency->convert($_order->getBaseGrandTotal(), 'BRL'));
152
+ } else {
153
+ $amount = round($this->getOrder()->getGrandTotal(), 2);
154
+ }
155
+
156
+ //prepare product
157
+ $strProducts = '';
158
+ foreach($_order->getAllItems() as $item) {
159
+ $pname = trim(str_replace('"', '', $item->getName()));
160
+
161
+ if ( $pname == '' && $strProducts == '') {
162
+ $pname = 'Order ' . $order_id;
163
+ $qty = $item->getQtyOrdered()*1;
164
+ break;
165
+ }
166
+
167
+ $qty = $item->getQtyOrdered()*1;
168
+ $strProducts .= $pname . "(Qty: " . $qty . ")\n";
169
+
170
+ }
171
+
172
+ // error_log(print_r($billing,1),3,'aaa');
173
+ $params = array(
174
+ // 'secret' => Mage::getStoreConfig('secret_key'),
175
+ 'order' => $order_id, //date('His') . '-' .
176
+ 'payment_method' => $this->_paymentMethod,
177
+ 'product_name' => $strProducts,
178
+ 'customer_name' => $billing->getFirstname() . ' ' . $billing->getLastname(),
179
+ 'customer_taxid' => preg_replace('/[^0-9]+/', '',$billing->getVatId()),
180
+ 'customer_email' => $email,
181
+ 'customer_phone' => $billing->getTelephone(),
182
+ 'address_street' => $billing->getStreet(-1),
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
+ }
190
+ /**
191
+ * Get initialized flag status
192
+ * @return true
193
+ */
194
+ public function isInitializeNeeded()
195
+ {
196
+ return true;
197
+ }
198
+
199
+ /**
200
+ * Instantiate state and set it to state onject
201
+ * //@param
202
+ * //@param
203
+ */
204
+ public function initialize($paymentAction, $stateObject)
205
+ {
206
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
207
+ $stateObject->setState($state);
208
+ $stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
209
+ $stateObject->setIsNotified(false);
210
+ }
211
+
212
+ /**
213
+ * Get config action to process initialization
214
+ *
215
+ * @return string
216
+ */
217
+ public function getConfigPaymentAction()
218
+ {
219
+ $paymentAction = $this->getConfigData('payment_action');
220
+ return empty($paymentAction) ? true : $paymentAction;
221
+ }
222
+ }
app/code/community/Mzcart/Pagbrasil/Model/Acc.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module -- Credit Card Payment
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
23
+ {
24
+ /**
25
+ * unique internal payment method identifier
26
+ */
27
+ protected $_code = 'pagbrasil_acc';
28
+ protected $_paymentMethod = 'C';
29
+
30
+ /**
31
+ * prepare params array to send it to gateway page via POST
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
+ // 'url_return' => Mage::getUrl('pagbrasil/processing/return', array('order' => $order_id)),
43
+ );
44
+ $params = array_merge($params, $this->_getCommonFields());
45
+ return $params;
46
+ }
47
+
48
+ /**
49
+ * Return url of payment method
50
+ *
51
+ * @return string
52
+ */
53
+ public function getUrl()
54
+ {
55
+ // return 'https://www.pagbrasil.com/pagbrasil/addorder.mv';
56
+ return 'https://www.pagbrasil.com/pagbrasil/iframe/checkoutframe.mv';
57
+ }
58
+
59
+ }
app/code/community/Mzcart/Pagbrasil/Model/Bb.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module -- Bolleto Bancario Payment
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 {
23
+ /**
24
+ * unique internal payment method identifier
25
+ */
26
+ protected $_code = 'pagbrasil_bb';
27
+ protected $_paymentMethod = 'B';
28
+
29
+ /**
30
+ * prepare params array to send it to gateway page via POST
31
+ *
32
+ * @return array
33
+ */
34
+ public function getFormFields() {
35
+ $_order = $this->getOrder();
36
+ $order_id = $_order->getRealOrderId();
37
+ $params = array(
38
+ 'secret' => Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY, $_order->getStoreId()),
39
+ /* 'bol_expiration' => Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_BOL_EXPIRATION, $_order->getStoreId()),*/
40
+ 'param_url' => '?order=' . $order_id,
41
+ );
42
+ $params = array_merge($params, $this->_getCommonFields());
43
+ return $params;
44
+ }
45
+
46
+
47
+ /**
48
+ *
49
+ *
50
+ * @return array
51
+ */
52
+ public function getBolUrl() {
53
+ $params = $this->getFormFields();
54
+ $curl = curl_init($this->getUrl());
55
+ $request = '';
56
+ foreach($params as $k => $v) {
57
+ $request .= $k . '=' . trim($v) . '&';
58
+ }
59
+
60
+ curl_setopt($curl, CURLOPT_POST, true);
61
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
62
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
63
+ curl_setopt($curl, CURLOPT_HEADER, false);
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
+ return $response;
69
+ } else {
70
+ return false;
71
+ }
72
+ }
73
+ }
app/code/community/Mzcart/Pagbrasil/Model/Event.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Mzcart
16
+ * @package Mzcart_Pagbrasil
17
+ * @copyright Copyright (c) 2013 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * PagBrasil notification processor model
23
+ */
24
+ class Mzcart_Pagbrasil_Model_Event
25
+ {
26
+ const PAGBRASIL_STATUS_FAIL = -2;
27
+ const PAGBRASIL_STATUS_CANCEL = -1;
28
+ const PAGBRASIL_STATUS_PENDING = 0;
29
+ const PAGBRASIL_STATUS_SUCCESS = 2;
30
+
31
+ /*
32
+ * @param Mage_Sales_Model_Order
33
+ */
34
+ protected $_order = null;
35
+
36
+ /**
37
+ * Event request data
38
+ * @var array
39
+ */
40
+ protected $_eventData = array();
41
+
42
+ /**
43
+ * Enent request data setter
44
+ * @param array $data
45
+ * @return Mzcart_Pagbrasil_Model_Event
46
+ */
47
+ public function setEventData(array $data)
48
+ {
49
+ $this->_eventData = $data;
50
+ return $this;
51
+ }
52
+
53
+ /**
54
+ * Event request data getter
55
+ * @param string $key
56
+ * @return array|string
57
+ */
58
+ public function getEventData($key = null)
59
+ {
60
+ if (null === $key) {
61
+ return $this->_eventData;
62
+ }
63
+ return isset($this->_eventData[$key]) ? $this->_eventData[$key] : null;
64
+ }
65
+
66
+ /**
67
+ * Get singleton of Checkout Session Model
68
+ *
69
+ * @return Mage_Checkout_Model_Session
70
+ */
71
+ protected function _getCheckout()
72
+ {
73
+ return Mage::getSingleton('checkout/session');
74
+ }
75
+
76
+ /**
77
+ * Process status notification from Monebookers server
78
+ *
79
+ * @return String
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);
90
+ break;
91
+ case self::PAGBRASIL_STATUS_CANCEL: //cancel
92
+ $msg = Mage::helper('pagbrasil')->__('Payment was canceled.');
93
+ $this->_processCancel($msg);
94
+ break;
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.');
101
+ $this->_processSale($params['status'], $msg);
102
+ break;
103
+ }
104
+ return $msg;
105
+ } catch (Mage_Core_Exception $e) {
106
+ return $e->getMessage();
107
+ } catch(Exception $e) {
108
+ Mage::logException($e);
109
+ }
110
+ return;
111
+ }
112
+
113
+ /**
114
+ * Process cancelation
115
+ */
116
+ public function cancelEvent() {
117
+ try {
118
+ $this->_validateEventData(false);
119
+ $this->_processCancel('Payment was canceled.');
120
+ return Mage::helper('pagbrasil')->__('The order has been canceled.');
121
+ } catch (Mage_Core_Exception $e) {
122
+ return $e->getMessage();
123
+ } catch(Exception $e) {
124
+ Mage::logException($e);
125
+ }
126
+ return '';
127
+ }
128
+
129
+ /**
130
+ * Validate request and return QuoteId
131
+ * Can throw Mage_Core_Exception and Exception
132
+ *
133
+ * @return int
134
+ */
135
+ public function successEvent(){
136
+ $this->_validateEventData(false);
137
+ // var_dump($this->_order->getQuoteId());exit;
138
+ return $this->_order->getQuoteId();
139
+ }
140
+
141
+ /**
142
+ * Processed order cancelation
143
+ * @param string $msg Order history message
144
+ */
145
+ protected function _processCancel($msg)
146
+ {
147
+ $this->_order->cancel();
148
+ $this->_order->addStatusToHistory(Mage_Sales_Model_Order::STATE_CANCELED, $msg);
149
+ $this->_order->save();
150
+ }
151
+
152
+ /**
153
+ * Processes payment confirmation, creates invoice if necessary, updates order status,
154
+ * sends order confirmation to customer
155
+ * @param string $msg Order history message
156
+ */
157
+ protected function _processSale($status, $msg)
158
+ {
159
+ switch ($status) {
160
+ case self::PAGBRASIL_STATUS_SUCCESS:
161
+ $this->_createInvoice();
162
+ $this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $msg);
163
+ // save transaction ID
164
+ $this->_order->getPayment()->setLastTransId($this->getEventData('order'));
165
+ // send new order email
166
+ $this->_order->save();
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
173
+ $this->_order->getPayment()->setLastTransId($this->getEventData('order'));
174
+ break;
175
+ }
176
+ $this->_order->save();
177
+ }
178
+
179
+ /**
180
+ * Builds invoice for order
181
+ */
182
+ protected function _createInvoice()
183
+ {
184
+ if (!$this->_order->canInvoice()) {
185
+ return;
186
+ }
187
+ $invoice = $this->_order->prepareInvoice();
188
+ $invoice->register()->capture();
189
+ $this->_order->addRelatedObject($invoice);
190
+ }
191
+
192
+ /**
193
+ * Checking returned parameters
194
+ * Thorws Mage_Core_Exception if error
195
+ * @param bool $fullCheck Whether to make additional validations such as payment status, transaction signature etc.
196
+ *
197
+ * @return array $params request params
198
+ */
199
+ protected function _validateEventData($fullCheck = true)
200
+ {
201
+ // get request variables
202
+ $params = $this->_eventData;
203
+ if (empty($params)) {
204
+ Mage::throwException('Request does not contain any elements.');
205
+ }
206
+
207
+ if (empty($params['order'])) {
208
+ Mage::throwException('Missing or invalid order ID.');
209
+ }
210
+ // error_log("params:" . print_r($params,1) . "\n" , 3, 'logfile');
211
+
212
+ // load order for further validation
213
+ $this->_order = Mage::getModel('sales/order')->loadByIncrementId($params['order']);
214
+ if (!$this->_order->getId()) {
215
+ Mage::throwException('Order not found.');
216
+ }
217
+
218
+ if (0 !== strpos($this->_order->getPayment()->getMethodInstance()->getCode(), 'pagbrasil_')) {
219
+ Mage::throwException('Unknown payment method.');
220
+ }
221
+
222
+ // make additional validation
223
+ if ($fullCheck) {
224
+ // check payment status
225
+ if (empty($params['status'])) {
226
+ Mage::throwException('Unknown payment status.');
227
+ }
228
+
229
+ $checkParams = array('secret');
230
+ foreach ($checkParams as $key) {
231
+ if ($key == 'secret') {
232
+ $secretKey = Mage::getStoreConfig(
233
+ Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY,
234
+ $this->_order->getStoreId()
235
+ );
236
+
237
+ if (empty($secretKey)) {
238
+ Mage::throwException('Secret key is empty.');
239
+ }
240
+ break;
241
+ }
242
+ }
243
+
244
+ if ($secretKey != $params[$key]) {
245
+ Mage::throwException('Hash is not valid.');
246
+ }
247
+ }
248
+ return $params;
249
+ }
250
+ }
app/code/community/Mzcart/Pagbrasil/Model/Obt.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module -- Online Bank Transfer Payment
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
23
+ {
24
+ /**
25
+ * unique internal payment method identifier
26
+ */
27
+ protected $_code = 'pagbrasil_obt';
28
+ protected $_paymentMethod = 'R';//RES
29
+
30
+ /**
31
+ * prepare params array to send it to gateway page via POST
32
+ *
33
+ * @return array
34
+ */
35
+ public function getFormFields() {
36
+ $_order = $this->getOrder();
37
+ $order_id = $_order->getRealOrderId();
38
+ $params = array(
39
+ 'secret' => Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY, $_order->getStoreId()),
40
+ // 'url_return' => Mage::getUrl('pagbrasil/processing/return'),
41
+ 'url_return' => Mage::getUrl('pagbrasil/processing/return', array('order' => $order_id)),
42
+ 'param_url' => '',
43
+ // 'param_url' => '?order=' . $order_id,
44
+ );
45
+ $params = array_merge($params, $this->_getCommonFields());
46
+ return $params;
47
+ }
48
+
49
+ /**
50
+ *
51
+ *
52
+ * @return array
53
+ */
54
+ public function getObtBanks() {
55
+ return array(
56
+ 'R' => Mage::helper('pagbrasil')->__('pagbrasil_bank_r'),
57
+ 'E' => Mage::helper('pagbrasil')->__('pagbrasil_bank_e'),
58
+ 'S' => Mage::helper('pagbrasil')->__('pagbrasil_bank_s'),
59
+ );
60
+ }
61
+ }
app/code/community/Mzcart/Pagbrasil/controllers/ProcessingController.php ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * PagBrasil payment module
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
23
+ {
24
+ /**
25
+ * Get singleton of Checkout Session Model
26
+ *
27
+ * @return Mage_Checkout_Model_Session
28
+ */
29
+ protected function _getCheckout()
30
+ {
31
+ return Mage::getSingleton('checkout/session');
32
+ }
33
+
34
+ /**
35
+ * Iframe page which submits the payment data to PagBrasil.
36
+ */
37
+ public function placeformAction()
38
+ {
39
+ $this->loadLayout();
40
+ $this->renderLayout();
41
+ }
42
+
43
+ /**
44
+ * Show orderPlaceRedirect page which contains the PagBrasil iframe.
45
+ */
46
+ public function paymentAction()
47
+ {
48
+ try {
49
+ /* $this->getResponse()->setHeader("Content-Type", "text/html; charset=ISO-8859-1",true); */
50
+ $session = $this->_getCheckout();
51
+
52
+ $order = Mage::getModel('sales/order');
53
+ $order->loadByIncrementId($session->getLastRealOrderId());
54
+ if (!$order->getId()) {
55
+ Mage::throwException('No order for processing found');
56
+ }
57
+
58
+ $billing = $order ->getBillingAddress();
59
+ $vatid = $billing->getVatId();
60
+
61
+ if ($this -> _validaCPF($vatid) || $this -> _validaCNPJ($vatid) ) {
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
+ } else {
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');
68
+ parent::_redirect('customer/address/');
69
+ // exit();
70
+ Mage::throwException(Mage::helper('pagbrasil')->__('The CPF or CNPJ is not valid!'));
71
+ }
72
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
73
+ Mage::helper('pagbrasil')->__('The customer was redirected to PagBrasil.')
74
+ );
75
+ $order->save();
76
+
77
+ $session->setPagbrasilQuoteId($session->getQuoteId());
78
+ $session->setPagbrasilRealOrderId($session->getLastRealOrderId());
79
+ $session->getQuote()->setIsActive(true)->save();
80
+ //$session->getQuote()->setIsActive(false)->save();
81
+ //$session->clear();
82
+
83
+ $this->loadLayout();
84
+ $this->renderLayout();
85
+ } catch (Exception $e){
86
+ Mage::logException($e);
87
+ parent::_redirect('checkout/cart');
88
+ }
89
+ }
90
+
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
+ foreach($params as $k => $v) {
102
+ // if ($k == 'payment_method') {
103
+ // $pm = trim($v);
104
+ // }
105
+ // if ($k == 'url_return') {
106
+ // $url = trim($v);
107
+ // error_log("\nurl:" . $url . "\n",3,'logfile');
108
+ // continue;
109
+ // }
110
+ if ($k == 'url_return') {
111
+ continue;
112
+ }
113
+ $request .= $k . '=' . urlencode(trim($v)) . '&';
114
+ }
115
+ $params['url_return'] .= '?payment_method=' . $params['payment_method'];
116
+ $request .= 'url_return=' . urlencode($params['url_return']);
117
+ error_log("\n\n url_return " . $params['url_return'] . "\n", 3,'logfile');
118
+ //$request .= 'url_return=' . $url . 'payment_method/' . $pm;
119
+ error_log("\n\n request " . $request . "\n",3,'logfile');
120
+
121
+ curl_setopt($curl, CURLOPT_POST, true);
122
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
123
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
124
+ curl_setopt($curl, CURLOPT_HEADER, false);
125
+ curl_setopt($curl, CURLOPT_TIMEOUT, 50);
126
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
127
+ $response = curl_exec($curl);
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
+ $ok=header('Location: ' . $response);
139
+ exit;
140
+ } else {
141
+ $this->_redirect('checkout/onepage/success');
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
+ } else {
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
+
165
+ $curl = curl_init('https://www.pagbrasil.com/pagbrasil/getorder.mv');
166
+ $request = 'secret=' . Mage::getStoreConfig(Mzcart_Pagbrasil_Helper_Data::XML_PATH_SECRET_KEY, $_order->getStoreId());
167
+ $request .= '&order=' . $order_id;
168
+
169
+ curl_setopt($curl, CURLOPT_POST, true);
170
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
171
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
172
+ curl_setopt($curl, CURLOPT_HEADER, false);
173
+ curl_setopt($curl, CURLOPT_TIMEOUT, 50);
174
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
175
+
176
+ $response = curl_exec($curl);
177
+
178
+
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
+ switch ($payment_status) {
186
+ case 'PC':$params['status'] = 2;break;
187
+ case 'PA':$params['status'] = 0;break;
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;
194
+ // isset($params['payment_method'])? '': $params['payment_method']='Obt';
195
+
196
+ $session = $this->_getCheckout();
197
+ Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
198
+
199
+ $event = Mage::getModel('pagbrasil/event')->setEventData($params);
200
+ $message = $event->processStatusEvent(false);
201
+ //var_dump($params);exit;
202
+ if ( $params['status'] != 2) {
203
+ $session->addError($message);
204
+ Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
205
+ $this->_redirect('checkout/cart');
206
+ //exit();
207
+ } else {
208
+ $quoteId = $event->successEvent();
209
+ $this->_getCheckout()->setLastSuccessQuoteId($quoteId);
210
+ // var_dump($session->getQuoteId());exit;
211
+ // var_dump($quoteId);exit;
212
+ //$quote = Mage::getModel('sales/quote')->load($quoteId);
213
+ //$quote->setIsActive(true)->save();
214
+ $session->setQuoteId($quoteId);
215
+ //Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true)->save();
216
+ $this->_redirect('checkout/onepage/success');
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
+ // $params =array(
232
+ // 'payment_method' => 'B',
233
+ // 'secret' => 'b1299d4c01b127f02851e3b726b75675615f8081',
234
+ // '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>'
235
+ // );
236
+
237
+ if (isset($params['secret'])) {
238
+ $secret = trim($params['secret']);
239
+ } else {
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);
255
+
256
+ if (!$_order->getId()) {
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
+
264
+ $amount_paid = trim($boleto->childNodes->item(2)->nodeValue);
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
+ } else {
276
+ $msg = Mage::helper('pagbrasil')->__('The order was partialy paid.Amount Due: %s, ,Amount Paid: %s.');
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
+ case 'A':$params['status'] = 2;break;
290
+ case 'F':$params['status'] = -2;break;
291
+ case 'R':$params['status'] = 0;break;
292
+ case 'C':$params['status'] = -1;break;
293
+ case 'P':$params['status'] = -1;break;
294
+ }
295
+ $event = Mage::getModel('pagbrasil/event')->setEventData($params);
296
+ $message = $event->processStatusEvent();
297
+ }
298
+
299
+ echo 'Received successfully in [' . time() . ']';
300
+ exit;
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
+ } catch (Mage_Core_Exception $e) {
315
+ $this->_getCheckout()->addError($e->getMessage());
316
+ } catch(Exception $e) {
317
+ Mage::logException($e);
318
+ }
319
+ $this->_redirect('checkout/cart');
320
+ }
321
+
322
+ /**
323
+ * Action to which the customer will be returned if the payment process is
324
+ * cancelled.
325
+ * Cancel order and redirect user to the shopping cart.
326
+ */
327
+ public function cancelAction()
328
+ {
329
+ $event = Mage::getModel('pagbrasil/event')
330
+ ->setEventData($this->getRequest()->getParams());
331
+ $message = $event->cancelEvent();
332
+
333
+ // set quote to active
334
+ $session = $this->_getCheckout();
335
+ if ($quoteId = $session->getPagbrasilQuoteId()) {
336
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
337
+ if ($quote->getId()) {
338
+ $quote->setIsActive(true)->save();
339
+ $session->setQuoteId($quoteId);
340
+ }
341
+ }
342
+
343
+ $session->addError($message);
344
+ $this->_redirect('checkout/cart');
345
+ }
346
+
347
+ /**
348
+ * Action to which the transaction details will be posted after the payment
349
+ * process is complete.
350
+ */
351
+ public function statusAction()
352
+ {
353
+ $event = Mage::getModel('pagbrasil/event')
354
+ ->setEventData($this->getRequest()->getParams());
355
+ $message = $event->processStatusEvent();
356
+ $this->getResponse()->setBody($message);
357
+ }
358
+
359
+ /**
360
+ * Set redirect into responce. This has to be encapsulated in an JavaScript
361
+ * call to jump out of the iframe.
362
+ *
363
+ * @param string $path
364
+ * @param array $arguments
365
+ */
366
+ protected function _redirect($path, $arguments=array())
367
+ {
368
+ $this->getResponse()->setBody(
369
+ $this->getLayout()
370
+ ->createBlock('pagbrasil/redirect')
371
+ ->setRedirectUrl(Mage::getUrl($path, $arguments))
372
+ ->toHtml()
373
+ );
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
+ $carac = substr($cpf, $i, 1);
382
+ if (ord($carac)>=48 && ord($carac)<=57) // verifica se o codigo asc refere-se a 0-9
383
+ $cpf_limpo .= $carac;
384
+ }
385
+ if (strlen($cpf_limpo)!=11)
386
+ return false;
387
+
388
+ // achar o primeiro digito verificador
389
+ $soma = 0;
390
+ for ($i=0; $i<9; $i++)
391
+ $soma += (int)substr($cpf_limpo, $i, 1) * (10-$i);
392
+
393
+ if ($soma == 0)
394
+ return false;
395
+
396
+ $primeiro_digito = 11 - $soma % 11;
397
+
398
+ if ($primeiro_digito > 9)
399
+ $primeiro_digito = 0;
400
+
401
+ if (substr($cpf_limpo, 9, 1) != $primeiro_digito)
402
+ return false;
403
+
404
+ // acha o segundo digito verificador
405
+ $soma = 0;
406
+ for ($i=0; $i<10; $i++)
407
+ $soma += (int)substr($cpf_limpo, $i, 1) * (11-$i);
408
+
409
+ $segundo_digito = 11 - $soma % 11;
410
+
411
+ if ($segundo_digito > 9)
412
+ $segundo_digito = 0;
413
+
414
+ if (substr($cpf_limpo, 10, 1) != $segundo_digito)
415
+ return false;
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) return FALSE;
427
+ else {
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);
434
+ $sum = $sum + $multiply;
435
+ $multiplier++;
436
+
437
+ }
438
+ $rest = $sum % 11;
439
+ if ($rest == 0 || $rest == 1) $dv1 = 0;
440
+ else $dv1 = 11 - $rest;
441
+
442
+ $sub_cnpj = substr($cnpj, 0, 12);
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]) return true; //$cnpj;
459
+ else return false;
460
+ }
461
+ }
462
+
463
+ }
app/code/community/Mzcart/Pagbrasil/etc/config.xml ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * Pagbrasil payment module
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>1.0</version>
28
+ </Mzcart_Pagbrasil>
29
+ </modules>
30
+ <global>
31
+ <models>
32
+ <pagbrasil>
33
+ <class>Mzcart_Pagbrasil_Model</class>
34
+ </pagbrasil>
35
+ </models>
36
+ <helpers>
37
+ <pagbrasil>
38
+ <class>Mzcart_Pagbrasil_Helper</class>
39
+ </pagbrasil>
40
+ </helpers>
41
+ <resources>
42
+ <pagbrasil_setup>
43
+ <setup>
44
+ <module>Mzcart_Pagbrasil</module>
45
+ </setup>
46
+ </pagbrasil_setup>
47
+ </resources>
48
+ <blocks>
49
+ <pagbrasil><class>Mzcart_Pagbrasil_Block</class></pagbrasil>
50
+ </blocks>
51
+
52
+ <payment>
53
+ <groups>
54
+ <pbrasils>PagBrasil</pbrasils>
55
+ </groups>
56
+ </payment>
57
+ </global>
58
+ <frontend>
59
+ <secure_url>
60
+ <pagbrasil_processing>/pagbrasil/processing</pagbrasil_processing>
61
+ </secure_url>
62
+ <routers>
63
+ <pagbrasil>
64
+ <use>standard</use>
65
+ <args>
66
+ <module>Mzcart_Pagbrasil</module>
67
+ <frontName>pagbrasil</frontName>
68
+ </args>
69
+ </pagbrasil>
70
+ </routers>
71
+ <translate>
72
+ <modules>
73
+ <Mzcart_Pagbrasil>
74
+ <files>
75
+ <default>Mzcart_Pagbrasil.csv</default>
76
+ </files>
77
+ </Mzcart_Pagbrasil>
78
+ </modules>
79
+ </translate>
80
+ <layout>
81
+ <updates>
82
+ <pagbrasil>
83
+ <file>pagbrasil.xml</file>
84
+ </pagbrasil>
85
+ </updates>
86
+ </layout>
87
+ </frontend>
88
+ <admin>
89
+ <routers>
90
+ <adminhtml>
91
+ <args>
92
+ <modules>
93
+ <pagbrasil after="Mage_Adminhtml">Mzcart_Pagbrasil</pagbrasil>
94
+ </modules>
95
+ </args>
96
+ </adminhtml>
97
+ </routers>
98
+ </admin>
99
+ <adminhtml>
100
+ <translate>
101
+ <modules>
102
+ <Mzcart_Pagbrasil>
103
+ <files>
104
+ <default>Mzcart_Pagbrasil.csv</default>
105
+ </files>
106
+ </Mzcart_Pagbrasil>
107
+ </modules>
108
+ </translate>
109
+ <layout>
110
+ <updates>
111
+ <pagbrasil>
112
+ <file>pagbrasil.xml</file>
113
+ </pagbrasil>
114
+ </updates>
115
+ </layout>
116
+ <acl>
117
+ <resources>
118
+ <admin>
119
+ <children>
120
+ <system>
121
+ <children>
122
+ <config>
123
+ <children>
124
+ <pagbrasil translate="title" module="pagbrasil">
125
+ <title>Pagbrasil Settings</title>
126
+ </pagbrasil>
127
+ </children>
128
+ </config>
129
+ </children>
130
+ </system>
131
+ </children>
132
+ </admin>
133
+ </resources>
134
+ </acl>
135
+ </adminhtml>
136
+ <default>
137
+ <payment>
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>
144
+ </pagbrasil_acc>
145
+ <pagbrasil_bb>
146
+ <group>pbrasils</group>
147
+ <active>0</active>
148
+ <model>pagbrasil/bb</model>
149
+ <title>Boleto Banc&#225;rio</title>
150
+ <allowspecific>1</allowspecific>
151
+ <specificcountry>BR</specificcountry>
152
+ </pagbrasil_bb>
153
+ <pagbrasil_obt>
154
+ <group>pbrasils</group>
155
+ <active>0</active>
156
+ <model>pagbrasil/obt</model>
157
+ <title>Transfer&#234;ncia Banc&#225;ria (Bradesco, Banco do Brasil, Banrisul)</title>
158
+ <allowspecific>1</allowspecific>
159
+ <specificcountry>BR</specificcountry>
160
+ </pagbrasil_obt>
161
+ </payment>
162
+
163
+ </default>
164
+ </config>
app/code/community/Mzcart/Pagbrasil/etc/system.xml ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * PagBrasil payment module
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
+ <sections>
26
+ <pagbrasil translate="label" module="pagbrasil">
27
+ <label>PagBrasil</label>
28
+ <tab>sales</tab>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>1000</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <groups>
35
+ <settings translate="label">
36
+ <label>PagBrasil Settings</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <fields>
43
+ <pagbrasil_token translate="label,comment">
44
+ <label>Token</label>
45
+ <comment><![CDATA[Token assigned to your merchant account. If you have this feature enabled in your account, your token will be displayed at the PagBrasil Merchant Interface, tab "Update Information".]]></comment>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </pagbrasil_token>
52
+ <secret_key translate="label,comment">
53
+ <label>Secret Phrase</label>
54
+ <comment>Pre-shared secret phrase to secure the transaction. Secret phrase as defined in the PagBrasil's Merchant Interface, tab "Update Information".</comment>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>2</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </secret_key>
61
+ </fields>
62
+ </settings>
63
+ <pagbrasil_acc translate="label" module="pagbrasil">
64
+ <label>All credit cards accepted by PagBrasil</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>201</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <fields>
71
+ <active translate="label">
72
+ <label>Enabled</label>
73
+ <frontend_type>select</frontend_type>
74
+ <config_path>payment/pagbrasil_acc/active</config_path>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>1</sort_order>
77
+ <show_in_default>1</show_in_default>
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>
84
+ <config_path>payment/pagbrasil_acc/sort_order</config_path>
85
+ <sort_order>3</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </sort_order>
90
+ <title translate="label">
91
+ <label>Title</label>
92
+ <frontend_type>text</frontend_type>
93
+ <config_path>payment/pagbrasil_acc/title</config_path>
94
+ <sort_order>5</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </title>
99
+ <allowspecific translate="label">
100
+ <label>Payment from Applicable Countries</label>
101
+ <frontend_type>allowspecific</frontend_type>
102
+ <config_path>payment/pagbrasil_acc/allowspecific</config_path>
103
+ <sort_order>6</sort_order>
104
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </allowspecific>
109
+ <specificcountry translate="label">
110
+ <label>Payment from Specific Countries</label>
111
+ <frontend_type>multiselect</frontend_type>
112
+ <config_path>payment/pagbrasil_acc/specificcountry</config_path>
113
+ <sort_order>7</sort_order>
114
+ <source_model>adminhtml/system_config_source_country</source_model>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ <can_be_empty>1</can_be_empty>
119
+ </specificcountry>
120
+ </fields>
121
+ </pagbrasil_acc>
122
+ <pagbrasil_bb translate="label" module="pagbrasil">
123
+ <label>Boleto Bancario</label>
124
+ <frontend_type>text</frontend_type>
125
+ <sort_order>252</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ <fields>
130
+ <active translate="label">
131
+ <label>Enabled</label>
132
+ <frontend_type>select</frontend_type>
133
+ <config_path>payment/pagbrasil_bb/active</config_path>
134
+ <source_model>adminhtml/system_config_source_yesno</source_model>
135
+ <sort_order>1</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ </active>
140
+ <sort_order translate="label">
141
+ <label>Sort Order</label>
142
+ <frontend_type>text</frontend_type>
143
+ <config_path>payment/pagbrasil_bb/sort_order</config_path>
144
+ <sort_order>3</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </sort_order>
149
+ <title translate="label">
150
+ <label>Title</label>
151
+ <frontend_type>text</frontend_type>
152
+ <config_path>payment/pagbrasil_bb/title</config_path>
153
+ <sort_order>5</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ </title>
158
+ <allowspecific translate="label">
159
+ <label>Payment from Applicable Countries</label>
160
+ <frontend_type>allowspecific</frontend_type>
161
+ <config_path>payment/pagbrasil_bb/allowspecific</config_path>
162
+ <sort_order>6</sort_order>
163
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </allowspecific>
168
+ <specificcountry translate="label">
169
+ <label>Payment from Specific Countries</label>
170
+ <frontend_type>multiselect</frontend_type>
171
+ <config_path>payment/pagbrasil_bb/specificcountry</config_path>
172
+ <sort_order>7</sort_order>
173
+ <source_model>adminhtml/system_config_source_country</source_model>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ <can_be_empty>1</can_be_empty>
178
+ </specificcountry>
179
+ </fields>
180
+ </pagbrasil_bb>
181
+ <pagbrasil_obt translate="label" module="pagbrasil">
182
+ <label>Online Banking Transfer</label>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>211</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ <fields>
189
+ <active translate="label">
190
+ <label>Enabled</label>
191
+ <frontend_type>select</frontend_type>
192
+ <config_path>payment/pagbrasil_obt/active</config_path>
193
+ <source_model>adminhtml/system_config_source_yesno</source_model>
194
+ <sort_order>1</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ </active>
199
+ <sort_order translate="label">
200
+ <label>Sort Order</label>
201
+ <frontend_type>text</frontend_type>
202
+ <config_path>payment/pagbrasil_obt/sort_order</config_path>
203
+ <sort_order>3</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>1</show_in_website>
206
+ <show_in_store>1</show_in_store>
207
+ </sort_order>
208
+ <title translate="label">
209
+ <label>Title</label>
210
+ <frontend_type>text</frontend_type>
211
+ <config_path>payment/pagbrasil_obt/title</config_path>
212
+ <sort_order>5</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>1</show_in_store>
216
+ </title>
217
+ <allowspecific translate="label">
218
+ <label>Payment from Applicable Countries</label>
219
+ <frontend_type>allowspecific</frontend_type>
220
+ <config_path>payment/pagbrasil_obt/allowspecific</config_path>
221
+ <sort_order>6</sort_order>
222
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>1</show_in_store>
226
+ </allowspecific>
227
+ <specificcountry translate="label">
228
+ <label>Payment from Specific Countries</label>
229
+ <frontend_type>multiselect</frontend_type>
230
+ <config_path>payment/pagbrasil_obt/specificcountry</config_path>
231
+ <sort_order>7</sort_order>
232
+ <source_model>adminhtml/system_config_source_country</source_model>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ <can_be_empty>1</can_be_empty>
237
+ </specificcountry>
238
+ </fields>
239
+ </pagbrasil_obt>
240
+ </groups>
241
+ </pagbrasil>
242
+ </sections>
243
+ </config>
app/design/frontend/base/default/layout/pagbrasil.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * PagBrasil payment module
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
+ -->
25
+ <layout version="0.1.0">
26
+ <pagbrasil_processing_payment>
27
+ <reference name="root">
28
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
29
+ </reference>
30
+ <reference name="content">
31
+ <block type="pagbrasil/payment" name="pagbrasil_payment" template="pagbrasil/payment.phtml" />
32
+ </reference>
33
+ </pagbrasil_processing_payment>
34
+ </layout>
app/design/frontend/base/default/template/pagbrasil/form.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php $_code = $this->getMethodCode(); ?>
28
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none">
29
+ <li>
30
+ <?php echo Mage::helper('pagbrasil')->__('You will be redirected to our secure payment page when you place an order.') ?>
31
+ </li>
32
+ <?php if ($_img = $this->getPaymentImageSrc($_code)): ?>
33
+ <li>
34
+ <div style="padding:10px 15px 15px;">
35
+ <img src="<?php echo $_img ?>" alt="" /><br />
36
+ </div>
37
+ </li>
38
+ <?php endif; ?>
39
+ </ul>
app/design/frontend/base/default/template/pagbrasil/info.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?><br />
28
+ <?php if ($this->getInfo()->getLastTransId() == ''): ?>
29
+ <em><?php echo Mage::helper('pagbrasil')->__('You will be redirected to our secure payment page when you place an order.') ?></em>
30
+ <?php else: ?>
31
+ <?php echo Mage::helper('pagbrasil')->__('PagBrasil Transaction ID: %s', $this->escapeHtml($this->getInfo()->getLastTransId())) ?><br />
32
+ <?php endif; ?>
app/design/frontend/base/default/template/pagbrasil/payment-ajax.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <div class="page-head">
28
+ <h3><?php echo Mage::helper('pagbrasil')->__('Payment') ?></h3>
29
+ </div>
30
+ <?php
31
+ // var_dump($this->getPagbrasilMethod());
32
+ if($this->getPagbrasilMethod() == 'pagbrasil_bb') {
33
+ $bburl = $this->getBbUrl();
34
+ $srcstr = ($bburl == false) ? '' : ' src="' . $bburl .'" ';
35
+ // var_dump($srcstr);
36
+ }
37
+ ?>
38
+ <table style="width:100%;">
39
+ <tr>
40
+ <td style="width:75%">
41
+ <?php if($this->getPagbrasilMethod() != 'pagbrasil_obt') { ?>
42
+
43
+ <iframe id="tpagbrasilframe" name="tpagbrasilframe" frameborder=0 style="width:100%; height:600px;" <?php echo $srcstr;?> ></iframe>
44
+
45
+ <?php } else { ?>
46
+
47
+ <p/>
48
+ <p/>
49
+ <p/>
50
+ <p><?php echo Mage::helper('pagbrasil')->__("Please select the bank to checkout");?></p>
51
+ <form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
52
+ <?php if (is_array($this->getFormData())): ?>
53
+ <?php foreach ($this->getFormData() as $name => $value): ?>
54
+ <?php if ($name == 'payment_method') continue; ?>
55
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
56
+ <?php endforeach; ?>
57
+ <?php endif; ?>
58
+ <select name="payment_method" id="payment_method" >
59
+ <?php foreach ($this->getObtBanks() as $k => $v): ?>
60
+ <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
61
+ <?php endforeach; ?>
62
+ </select>
63
+ <br />
64
+ <br />
65
+ <input id="paymentbtn" type="submit" value="<?php echo Mage::helper('pagbrasil')->__("Proceed to bank checkout");?>" class="button" />
66
+
67
+ </form>
68
+
69
+
70
+ <?php } ?>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+
75
+ <?php if ($this->getPagbrasilMethod() == 'pagbrasil_acc') { //credit card payment?>
76
+
77
+
78
+ <form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
79
+ <?php if (is_array($this->getFormData())): ?>
80
+ <?php foreach ($this->getFormData() as $name => $value): ?>
81
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
82
+ <?php endforeach; ?>
83
+ <?php endif; ?>
84
+ </form>
85
+
86
+ <script type="text/javascript">
87
+ //<![CDATA[
88
+ var paymentform = document.getElementById('pagbrasil_place_form');
89
+ window.onload = paymentform.submit();
90
+ //]]>
91
+ </script>
92
+
93
+
94
+ <?php } ?>
app/design/frontend/base/default/template/pagbrasil/payment-single-col.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <div class="page-head">
28
+ <h3><?php echo Mage::helper('pagbrasil')->__('Payment') ?></h3>
29
+ </div>
30
+ <?php
31
+ // var_dump($this->getPagbrasilMethod());
32
+ if($this->getPagbrasilMethod() == 'pagbrasil_bb') {
33
+ $bburl = $this->getBbUrl();
34
+ $srcstr = ($bburl == false) ? '' : ' src="' . $bburl .'" ';
35
+ // var_dump($srcstr);
36
+ }
37
+ ?>
38
+
39
+ <table style="width:100%;">
40
+ <tr>
41
+ <td>
42
+
43
+ <iframe id="tpagbrasilframe" name="tpagbrasilframe" frameborder="0" style="width:100%; height:600px;border:none" <?php echo $srcstr;?> ></iframe>
44
+
45
+ <?php if($this->getPagbrasilMethod() == 'pagbrasil_obt') { ?>
46
+
47
+ <p/>
48
+ <p/>
49
+ <p/>
50
+ <p><?php echo Mage::helper('pagbrasil')->__("Please select the bank to checkout");?></p>
51
+ <form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo Mage::getUrl('pagbrasil/processing/bank') ?>" method="POST">
52
+ <?php if (is_array($this->getFormData())): ?>
53
+ <?php foreach ($this->getFormData() as $name => $value): ?>
54
+ <?php if ($name == 'payment_method') continue; ?>
55
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
56
+ <?php endforeach; ?>
57
+ <?php endif; ?>
58
+ <select name="payment_method" id="payment_method" >
59
+ <?php foreach ($this->getObtBanks() as $k => $v): ?>
60
+ <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
61
+ <?php endforeach; ?>
62
+ </select>
63
+ <br />
64
+ <br />
65
+ <input id="paymentbtn" type="submit" value="<?php echo Mage::helper('pagbrasil')->__("Proceed to bank checkout");?>" class="button" />
66
+
67
+ </form>
68
+
69
+ <?php } ?>
70
+
71
+
72
+ </td>
73
+ </tr>
74
+ </table>
75
+
76
+ <?php if ($this->getPagbrasilMethod() == 'pagbrasil_acc') { //credit card payment ?>
77
+
78
+
79
+ <form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
80
+ <?php if (is_array($this->getFormData())): ?>
81
+ <?php foreach ($this->getFormData() as $name => $value): ?>
82
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
83
+ <?php endforeach; ?>
84
+ <?php endif; ?>
85
+ </form>
86
+
87
+ <script type="text/javascript">
88
+ //<![CDATA[
89
+ var paymentform = document.getElementById('pagbrasil_place_form');
90
+ window.onload = paymentform.submit();
91
+ //]]>
92
+ </script>
93
+
94
+
95
+ <?php } ?>
96
+
app/design/frontend/base/default/template/pagbrasil/payment.phtml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Mzcart Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ // var_dump($this->getPagbrasilMethod());
29
+ if($this->getPagbrasilMethod() == 'pagbrasil_bb') {
30
+ $bburl = $this->getBbUrl();
31
+ $srcstr = ($bburl == false) ? '' : $bburl;
32
+ // var_dump($srcstr);
33
+ }
34
+ ?>
35
+ <div class="page-head">
36
+ <h3>
37
+ <?php if($this->getPagbrasilMethod() == 'pagbrasil_bb') { ?>
38
+ <a href="<?php echo $srcstr ?>" target="_blank"><?php echo Mage::helper('pagbrasil')->__('Please click here to view or print your boleto bancario'); ?></a>
39
+ <?php } else { echo Mage::helper('pagbrasil')->__('Payment'); } ?>
40
+ </h3>
41
+ </div>
42
+ <table style="width:100%;">
43
+ <tr>
44
+ <td style="width:75%">
45
+ <?php if($this->getPagbrasilMethod() == 'pagbrasil_acc') { ?>
46
+
47
+ <iframe id="tpagbrasilframe" name="tpagbrasilframe" frameborder=0 style="width:100%; height:750px;border:none;background:url(''; " <?php echo isset($srcstr)?$srcstr:'';?> >
48
+ <img src="<?php echo $this->getSkinUrl("images/pagbrasil/loading.gif");?>" />
49
+ </iframe>
50
+
51
+ <?php } elseif($this->getPagbrasilMethod() == 'pagbrasil_obt') { ?>
52
+
53
+ <p/>
54
+ <p/>
55
+ <p/>
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') ?>" method="POST">
58
+ <?php if (is_array($this->getFormData())): ?>
59
+ <?php foreach ($this->getFormData() as $name => $value): ?>
60
+ <?php if ($name == 'payment_method') continue; ?>
61
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
62
+ <?php endforeach; ?>
63
+ <?php endif; ?>
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 foreach ($this->getObtBanks() as $k => $v): ?>
67
+ <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
68
+ <?php endforeach; ?>
69
+ </select>
70
+ <br />
71
+ <br />
72
+ <input id="paymentbtn" type="submit" value="<?php echo Mage::helper('pagbrasil')->__("Proceed to bank checkout");?>" class="button" />
73
+
74
+ </form>
75
+ <script type="text/javascript">
76
+ //<![CDATA[
77
+ var dataForm = new VarienForm('pagbrasil_obt', true);
78
+ //]]>
79
+ </script>
80
+ <?php } ?>
81
+
82
+
83
+ </td>
84
+ </tr>
85
+ </table>
86
+
87
+ <?php if ($this->getPagbrasilMethod() == 'pagbrasil_acc') { //credit card payment ?>
88
+
89
+
90
+ <form name="pagbrasil" id="pagbrasil_place_form" target="tpagbrasilframe" action="<?php echo $this->getFormAction();?>" method="POST">
91
+ <?php if (is_array($this->getFormData())): ?>
92
+ <?php foreach ($this->getFormData() as $name => $value): ?>
93
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
94
+ <?php endforeach; ?>
95
+ <?php endif; ?>
96
+ </form>
97
+
98
+ <script type="text/javascript">
99
+ //<![CDATA[
100
+ var paymentform = document.getElementById('pagbrasil_place_form');
101
+ window.onload = paymentform.submit();
102
+ //]]>
103
+ </script>
104
+
105
+
106
+ <?php } ?>
107
+
app/design/frontend/base/default/template/pagbrasil/redirect.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <html><body>
28
+ <script type="text/javascript">parent.location.href="<?php echo $this->getRedirectUrl() ?>";</script>
29
+ </body></html>
app/etc/modules/Mzcart_Pagbrasil.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * PagBrasil payment module
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
+ -->
25
+ <config>
26
+ <modules>
27
+ <Mzcart_Pagbrasil>
28
+ <active>true</active>
29
+ <codePool>community</codePool>
30
+ </Mzcart_Pagbrasil>
31
+ </modules>
32
+ </config>
app/locale/en_US/Mzcart_Pagbrasil.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "pagbrasil_bank_r","Bradesco Com&#233;rcio Eletr&#244;nico"
2
+ "pagbrasil_bank_e","Banco do Brasil Com&#233;rcio Eletr&#244;nico"
3
+ "pagbrasil_bank_s","Banricompras"
4
+ "Proceed to bank checkout","Proceed to bank checkout"
5
+ "Please select the bank to checkout","Please select the bank to checkout"
6
+
7
+ "You will be redirected to our secure payment page when you place an order.","You will be redirected to our secure payment page when you place an order."
8
+
9
+ "Payment failed.","Payment failed."
10
+ "Payment was canceled.","Payment was canceled."
11
+ "Pending order #%s created.","Pending order #%s created."
12
+ "Payment authorized.","Payment authorized."
13
+ "The CPF or CNPJ is not valid!","The CPF or CNPJ is not valid!"
14
+ "Please select your bank","Please select your bank"
15
+ "Payment","Payment"
16
+ "Please click here to view or print your boleto bancario","Please click here to view or print your boleto bancario"
app/locale/pt_BR/Mzcart_Pagbrasil.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "pagbrasil_bank_r","Bradesco Com&#233;rcio Eletr&#244;nico"
2
+ "pagbrasil_bank_e","Banco do Brasil Com&#233;rcio Eletr&#244;nico"
3
+ "pagbrasil_bank_s","Banricompras"
4
+ "Proceed to bank checkout","Clique aqui para efetuar o pagamento"
5
+ "Please select the bank to checkout","Por favor selecione o seu banco"
6
+
7
+ "You will be redirected to our secure payment page when you place an order.","Voc&#234; ser&#225; redirecionado para nosso servidor seguro para efetuar o pagamento."
8
+
9
+ "Payment failed.","Falha no pagamento."
10
+ "Payment was canceled.","Pagamento cancelado."
11
+ "Pending order #%s created.","Pedido #%s em processamento."
12
+ "Payment authorized.","Pagamento autorizado."
13
+ "The CPF or CNPJ is not valid!","CPF/CNPJ inv&#225;lido!"
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&#225;rio"
package.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>PagBrasil</name>
4
+ <version>2.1.2</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Gain access to the broadest set of local payment methods, which may immediately multiply your sales in Brazil.</summary>
10
+ <description>Welcome to PagBrasil&#xD;
11
+ &#xD;
12
+ PagBrasil is the premier online payment processing service in Brazil designed for international merchants, e-commerce platforms and payment service providers. With PagBrasil you can sell cross border and receive the funds in US Dollars or Euros in your country without having a local company in Brazil or you can also sell locally and be paid in Brazilian Real. We are experts in the entire sales and buying process with more than 15 years of online payment processing experience in Brazil. &#xD;
13
+ &#xD;
14
+ Local Payment Methods&#xD;
15
+ &#xD;
16
+ Brazil online payment processing is becoming more and more important for international merchants as the Brazilian economy is being recognized as one of the biggest e-commerce opportunities in the world. Having Brazilian payment methods is crucial for success and PagBrasil offers the best payment processing service for Brazil. As a Brazil payment gateway we offer payment processing for e-commerce companies selling into Brazil. &#xD;
17
+ &#xD;
18
+ PagBrasil offers all major online payment methods for Brazil, such as:&#xD;
19
+ &#xD;
20
+ &#x2022; Boleto Banc&#xE1;rio&#xD;
21
+ &#x2022; Brazilian credit cards with installments&#xD;
22
+ &#x2022; Brazilian debit cards&#xD;
23
+ &#x2022; Online banking transfer (Bradesco Com&#xE9;rcio Eletr&#xF4;nico, Banco do Brasil Com&#xE9;rcio Eletr&#xF4;nico, Banrisul Banricompras)&#xD;
24
+ &#x2022; Support for recurring payments&#xD;
25
+ &#xD;
26
+ Why PagBrasil?&#xD;
27
+ &#xD;
28
+ &#x2022; Broadest set of local payment methods&#xD;
29
+ &#x2022; Instant payment confirmation &#xD;
30
+ &#x2022; National payment methods account for 90% of all online purchases&#xD;
31
+ &#x2022; Implementing PagBrasil may help to multiply your sales&#xD;
32
+ &#x2022; We are experts for the entire payment process&#xD;
33
+ &#x2022; Cutting-edge IT infrastructure&#xD;
34
+ &#x2022; Direct access to local payment methods&#xD;
35
+ &#x2022; Highly automated and cost-efficient business model&#xD;
36
+ &#x2022; Payouts in USD/EUR to anywhere in the world or BRL within Brazil&#xD;
37
+ &#x2022; 24/7 maintenance, 24/7 support&#xD;
38
+ &#x2022; Server uptime achieved in 2013: 99,98%&#xD;
39
+ &#x2022; Full PCI Compliance &#x2013; regularly audited by McAfee&#xD;
40
+ &#xD;
41
+ PagBrasil Magento Extension&#xD;
42
+ &#xD;
43
+ PagBrasil&#x2019;s Brazilian payment methods can be easily added to the merchant&#x2019;s Magento store by installing our Magento plugin. You can adapt the PagBrasil Magento module to your individual needs by adjusting a number of parameters, such as the number of credit card installments, the number of days until a boleto banc&#xE1;rio expires, the soft descriptor that identifies the payment on a credit card statement, an individual message shown on a boleto banc&#xE1;rio and many other options. &#xD;
44
+ &#xD;
45
+ &#xD;
46
+ Contact us&#xD;
47
+ &#xD;
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. &#xD;
49
+ &#xD;
50
+ Or visit our website www.pagbrasil.com</description>
51
+ <notes>Initial release.</notes>
52
+ <authors><author><name>PagBrasil</name><user>PagBrasil</user><email>support@pagbrasil.com</email></author></authors>
53
+ <date>2014-07-10</date>
54
+ <time>01:10:11</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="47dd424de9ca7f48c08570ae95b34a68"/><file name="Acc.php" hash="ac437ff31b1df14b9f363b2aeb340984"/><file name="Bb.php" hash="e5d3aa54423e32f3ce398d20b07ad662"/><file name="Event.php" hash="a660431fcffc8bbc23c3e286963af035"/><file name="Obt.php" hash="43e70efa6e5cee0fa2370a244affe95e"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="cb41db8fc306adda904fe44781a1422a"/></dir><dir name="etc"><file name="config.xml" hash="880ba28901a4ad1fea0c73704b95dfef"/><file name="system.xml" hash="a65ce59b031d0a11e011aae9f3b7031f"/></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="7a8a71efa3530efd46850c0bd11717ae"/><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="59f087d5fa100b1ced3e95a4f10830e2"/></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>
56
+ <compatible/>
57
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
58
+ </package>
skin/frontend/base/default/images/pagbrasil/Thumbs.db ADDED
Binary file
skin/frontend/base/default/images/pagbrasil/loading.gif ADDED
Binary file
skin/frontend/base/default/images/pagbrasil/pagbrasil_acc.gif ADDED
Binary file
skin/frontend/base/default/images/pagbrasil/pagbrasil_bb.gif ADDED
Binary file
skin/frontend/base/default/images/pagbrasil/pagbrasil_obt.gif ADDED
Binary file