Version Notes
Versão estável.
Os bugs devem ser reportados na área de Issues no github do projeto em https://github.com/r-martins/PagSeguro-Magento-Transparente
Download this release
Release Info
Developer | Ricardo Martins |
Extension | RicardoMartins_PagSeguro |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.0 to 2.2.0
- app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php +13 -23
- app/code/community/RicardoMartins/PagSeguro/Block/Form/Directpayment.php +12 -2
- app/code/community/RicardoMartins/PagSeguro/Helper/Data.php +84 -72
- app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php +31 -27
- app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +196 -131
- app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php +113 -64
- app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php +96 -42
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Address/Attributes.php +20 -12
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Address/Attributes/Optional.php +19 -11
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Attributes.php +18 -7
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Cpf.php +22 -11
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Dob.php +16 -8
- app/code/community/RicardoMartins/PagSeguro/Model/Source/Paymentmethods.php +9 -2
- app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Backend/Token.php +69 -0
- app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Source/Customer/Groups.php +13 -1
- app/code/community/RicardoMartins/PagSeguro/controllers/AjaxController.php +20 -5
- app/code/community/RicardoMartins/PagSeguro/controllers/NotificationController.php +20 -5
- app/code/community/RicardoMartins/PagSeguro/controllers/TestController.php +35 -13
- app/code/community/RicardoMartins/PagSeguro/etc/config.xml +1 -1
- app/code/community/RicardoMartins/PagSeguro/etc/system.xml +2 -1
- app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml +8 -0
- package.xml +4 -4
app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php
CHANGED
@@ -1,29 +1,14 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Magento
|
|
|
4 |
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
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 |
-
* 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 Mage
|
22 |
-
* @package Mage_Paygate
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
-
|
27 |
class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
|
28 |
{
|
29 |
/**
|
@@ -36,7 +21,7 @@ class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
|
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
* @return Mage_Core_Block_Abstract
|
41 |
*/
|
42 |
protected function _prepareLayout()
|
@@ -52,6 +37,11 @@ class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
|
|
52 |
return parent::_prepareLayout();
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
public function isDobVisible()
|
56 |
{
|
57 |
$ownerDobAttribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
|
1 |
<?php
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Form CC Block Class
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
*/
|
|
|
12 |
class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
|
13 |
{
|
14 |
/**
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Insert module's javascript on rendering, only if it wasn't inserted before
|
25 |
* @return Mage_Core_Block_Abstract
|
26 |
*/
|
27 |
protected function _prepareLayout()
|
37 |
return parent::_prepareLayout();
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Check if Date of Birthday should be visible
|
42 |
+
* You can set up it on Payment Methods->PagSeguro Cartão de Crédito
|
43 |
+
* @return bool
|
44 |
+
*/
|
45 |
public function isDobVisible()
|
46 |
{
|
47 |
$ownerDobAttribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
|
app/code/community/RicardoMartins/PagSeguro/Block/Form/Directpayment.php
CHANGED
@@ -1,4 +1,14 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_Block_Form_Directpayment extends Mage_Core_Block_Template
|
3 |
{
|
4 |
protected function _construct()
|
@@ -9,8 +19,8 @@ class RicardoMartins_PagSeguro_Block_Form_Directpayment extends Mage_Core_Block_
|
|
9 |
|
10 |
protected function _toHtml()
|
11 |
{
|
12 |
-
// avoids block
|
13 |
-
if(false == Mage::registry('directpayment_loaded')) {
|
14 |
Mage::register('directpayment_loaded', true);
|
15 |
return parent::_toHtml();
|
16 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Form DirectPayment Block Class
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_Block_Form_Directpayment extends Mage_Core_Block_Template
|
13 |
{
|
14 |
protected function _construct()
|
19 |
|
20 |
protected function _toHtml()
|
21 |
{
|
22 |
+
// avoids block being inserted twice
|
23 |
+
if (false == Mage::registry('directpayment_loaded')) {
|
24 |
Mage::register('directpayment_loaded', true);
|
25 |
return parent::_toHtml();
|
26 |
}
|
app/code/community/RicardoMartins/PagSeguro/Helper/Data.php
CHANGED
@@ -1,49 +1,60 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
-
const XML_PATH_PAYMENT_PAGSEGURO_EMAIL
|
6 |
-
const XML_PATH_PAYMENT_PAGSEGURO_TOKEN
|
7 |
-
const XML_PATH_PAYMENT_PAGSEGURO_DEBUG
|
8 |
-
const XML_PATH_PAUMENT_PAGSEGURO_SANDBOX
|
9 |
-
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_EMAIL
|
10 |
-
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_TOKEN
|
11 |
-
const XML_PATH_PAYMENT_PAGSEGURO_WS_URL
|
12 |
-
const XML_PATH_PAYMENT_PAGSEGURO_WS_URL_APP
|
13 |
-
const XML_PATH_PAYMENT_PAGSEGURO_JS_URL
|
14 |
-
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL
|
15 |
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL_APP = 'payment/pagseguro/sandbox_ws_url_app';
|
16 |
-
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_JS_URL
|
17 |
-
const XML_PATH_PAYMENT_PAGSEGURO_KEY_TYPE
|
18 |
-
const XML_PATH_PAYMENT_PAGSEGURO_KEY
|
19 |
-
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
* @return bool|string
|
25 |
*/
|
26 |
public function getSessionId()
|
27 |
{
|
28 |
-
$
|
29 |
|
30 |
-
$url = $this->getWsUrl('sessions'
|
31 |
|
32 |
$ch = curl_init($url);
|
33 |
$params['email'] = $this->getMerchantEmail();
|
34 |
$params['token'] = $this->getToken();
|
35 |
-
if($
|
36 |
$params['public_key'] = $this->getPagSeguroProKey();
|
37 |
}
|
38 |
|
39 |
-
curl_setopt_array(
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
|
48 |
$response = null;
|
49 |
|
@@ -54,52 +65,54 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
54 |
return false;
|
55 |
}
|
56 |
|
57 |
-
|
58 |
libxml_use_internal_errors(true);
|
59 |
$xml = simplexml_load_string($response);
|
60 |
if (false === $xml) {
|
61 |
if (curl_errno($ch) > 0) {
|
62 |
$this->writeLog('Falha de comunicação com API do PagSeguro: ' . curl_error($ch));
|
63 |
} else {
|
64 |
-
$this->writeLog(
|
|
|
|
|
|
|
65 |
}
|
66 |
return false;
|
67 |
}
|
|
|
68 |
return (string)$xml->id;
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
* @return string
|
74 |
*/
|
75 |
public function getMerchantEmail()
|
76 |
{
|
77 |
-
if($this->isSandbox())
|
78 |
-
{
|
79 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_EMAIL);
|
80 |
}
|
81 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_EMAIL);
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
*
|
86 |
-
*
|
87 |
-
* @param
|
|
|
88 |
*
|
89 |
* @return string
|
90 |
*/
|
91 |
-
public function getWsUrl($amend='', $
|
92 |
{
|
93 |
-
if($this->isSandbox())
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
}else{
|
98 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL) . $amend;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
-
if($this->getLicenseType()=='app' && $
|
103 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_WS_URL_APP) . $amend;
|
104 |
}
|
105 |
|
@@ -107,20 +120,19 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
-
*
|
111 |
* @return string
|
112 |
*/
|
113 |
public function getJsUrl()
|
114 |
{
|
115 |
-
if($this->isSandbox())
|
116 |
-
{
|
117 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_JS_URL);
|
118 |
}
|
119 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_JS_URL);
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
-
*
|
124 |
* @return bool
|
125 |
*/
|
126 |
public function isDebugActive()
|
@@ -129,7 +141,7 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
*
|
133 |
* @return bool
|
134 |
*/
|
135 |
public function isSandbox()
|
@@ -138,34 +150,32 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
-
*
|
142 |
* @param $obj mixed|string
|
143 |
*/
|
144 |
public function writeLog($obj)
|
145 |
{
|
146 |
if ($this->isDebugActive()) {
|
147 |
-
if(is_string($obj)){
|
148 |
Mage::log($obj, Zend_Log::DEBUG, 'pagseguro.log', true);
|
149 |
-
}else{
|
150 |
Mage::log(var_export($obj, true), Zend_Log::DEBUG, 'pagseguro.log', true);
|
151 |
}
|
152 |
}
|
153 |
}
|
154 |
|
155 |
/**
|
156 |
-
*
|
157 |
* @return string | false
|
158 |
*/
|
159 |
public function getToken()
|
160 |
{
|
161 |
$this->checkTokenIntegrity();
|
162 |
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_TOKEN);
|
163 |
-
if($this->isSandbox())
|
164 |
-
{
|
165 |
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_TOKEN);
|
166 |
}
|
167 |
-
if(empty($token))
|
168 |
-
{
|
169 |
return false;
|
170 |
}
|
171 |
|
@@ -173,17 +183,17 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
* @return bool
|
178 |
*/
|
179 |
public function isCpfVisible()
|
180 |
{
|
181 |
-
$
|
182 |
-
return empty($
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
-
*
|
187 |
* @return string
|
188 |
*/
|
189 |
public function getLicenseType()
|
@@ -192,7 +202,7 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
192 |
}
|
193 |
|
194 |
/**
|
195 |
-
*
|
196 |
* @return string
|
197 |
*/
|
198 |
public function getPagSeguroProKey()
|
@@ -201,18 +211,19 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
201 |
}
|
202 |
|
203 |
/**
|
204 |
-
*
|
205 |
* @author Ricardo Martins
|
206 |
* @return string
|
207 |
*/
|
208 |
-
public function __()
|
|
|
209 |
$args = func_get_args();
|
210 |
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName());
|
211 |
array_unshift($args, $expr);
|
212 |
|
213 |
$text = $args[0]->getText();
|
214 |
-
preg_match('/(.*)\:(.*)/'
|
215 |
-
if($matches!==false && isset($matches[1])){
|
216 |
array_shift($matches);
|
217 |
$matches[0] .= ': %s';
|
218 |
$args = $matches;
|
@@ -221,7 +232,7 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
-
*
|
225 |
* @author Ricardo Martins
|
226 |
* @return void
|
227 |
*/
|
@@ -238,25 +249,26 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
-
*
|
242 |
* @author Ricardo Martins
|
243 |
* @return Mage_Core_Block_Text
|
244 |
*/
|
245 |
public function getPagSeguroScriptBlock()
|
246 |
{
|
247 |
-
$
|
248 |
-
$
|
|
|
249 |
sprintf(
|
250 |
'
|
251 |
<script type="text/javascript">var RMPagSeguroSiteBaseURL = "%s";</script>
|
252 |
<script type="text/javascript" src="%s"></script>
|
253 |
<script type="text/javascript" src="%s"></script>
|
254 |
',
|
255 |
-
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,
|
256 |
Mage::helper('ricardomartins_pagseguro')->getJsUrl(),
|
257 |
-
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS,
|
258 |
)
|
259 |
);
|
260 |
-
return $
|
261 |
}
|
262 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Helper Class - responsible for helping on gathering config information
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
|
13 |
{
|
14 |
+
const XML_PATH_PAYMENT_PAGSEGURO_EMAIL = 'payment/pagseguro/merchant_email';
|
15 |
+
const XML_PATH_PAYMENT_PAGSEGURO_TOKEN = 'payment/pagseguro/token';
|
16 |
+
const XML_PATH_PAYMENT_PAGSEGURO_DEBUG = 'payment/pagseguro/debug';
|
17 |
+
const XML_PATH_PAUMENT_PAGSEGURO_SANDBOX = 'payment/pagseguro/sandbox';
|
18 |
+
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_EMAIL = 'payment/pagseguro/sandbox_merchant_email';
|
19 |
+
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_TOKEN = 'payment/pagseguro/sandbox_token';
|
20 |
+
const XML_PATH_PAYMENT_PAGSEGURO_WS_URL = 'payment/pagseguro/ws_url';
|
21 |
+
const XML_PATH_PAYMENT_PAGSEGURO_WS_URL_APP = 'payment/pagseguro/ws_url_app';
|
22 |
+
const XML_PATH_PAYMENT_PAGSEGURO_JS_URL = 'payment/pagseguro/js_url';
|
23 |
+
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL = 'payment/pagseguro/sandbox_ws_url';
|
24 |
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL_APP = 'payment/pagseguro/sandbox_ws_url_app';
|
25 |
+
const XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_JS_URL = 'payment/pagseguro/sandbox_js_url';
|
26 |
+
const XML_PATH_PAYMENT_PAGSEGURO_KEY_TYPE = 'payment/pagseguropro/key_type';
|
27 |
+
const XML_PATH_PAYMENT_PAGSEGURO_KEY = 'payment/pagseguropro/key';
|
|
|
28 |
|
29 |
/**
|
30 |
+
* Returns session ID from PagSeguro that will be used on JavaScript methods.
|
31 |
+
* or FALSE on failure
|
32 |
* @return bool|string
|
33 |
*/
|
34 |
public function getSessionId()
|
35 |
{
|
36 |
+
$useApp = $this->getLicenseType() == 'app';
|
37 |
|
38 |
+
$url = $this->getWsUrl('sessions', $useApp);
|
39 |
|
40 |
$ch = curl_init($url);
|
41 |
$params['email'] = $this->getMerchantEmail();
|
42 |
$params['token'] = $this->getToken();
|
43 |
+
if ($useApp) {
|
44 |
$params['public_key'] = $this->getPagSeguroProKey();
|
45 |
}
|
46 |
|
47 |
+
curl_setopt_array(
|
48 |
+
$ch,
|
49 |
+
array(
|
50 |
+
CURLOPT_POSTFIELDS => http_build_query($params),
|
51 |
+
CURLOPT_POST => count($params),
|
52 |
+
CURLOPT_RETURNTRANSFER => 1,
|
53 |
+
CURLOPT_TIMEOUT => 45,
|
54 |
+
CURLOPT_SSL_VERIFYPEER => false,
|
55 |
+
CURLOPT_SSL_VERIFYHOST => false,
|
56 |
+
)
|
57 |
+
);
|
58 |
|
59 |
$response = null;
|
60 |
|
65 |
return false;
|
66 |
}
|
67 |
|
|
|
68 |
libxml_use_internal_errors(true);
|
69 |
$xml = simplexml_load_string($response);
|
70 |
if (false === $xml) {
|
71 |
if (curl_errno($ch) > 0) {
|
72 |
$this->writeLog('Falha de comunicação com API do PagSeguro: ' . curl_error($ch));
|
73 |
} else {
|
74 |
+
$this->writeLog(
|
75 |
+
'Falha na autenticação com API do PagSeguro. Verifique email e token cadastrados.
|
76 |
+
Retorno pagseguro: ' . $response
|
77 |
+
);
|
78 |
}
|
79 |
return false;
|
80 |
}
|
81 |
+
|
82 |
return (string)$xml->id;
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
+
* Return merchant e-mail setup on admin
|
87 |
* @return string
|
88 |
*/
|
89 |
public function getMerchantEmail()
|
90 |
{
|
91 |
+
if ($this->isSandbox()) {
|
|
|
92 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_EMAIL);
|
93 |
}
|
94 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_EMAIL);
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Returns Webservice URL based on selected environment (prod or sandbox)
|
99 |
+
*
|
100 |
+
* @param string $amend suffix
|
101 |
+
* @param bool $useApp uses app?
|
102 |
*
|
103 |
* @return string
|
104 |
*/
|
105 |
+
public function getWsUrl($amend='', $useApp = false)
|
106 |
{
|
107 |
+
if ($this->isSandbox()) {
|
108 |
+
if ($this->getLicenseType()=='app' && $useApp) {
|
109 |
+
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL_APP) . $amend;
|
110 |
+
} else {
|
|
|
111 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_WS_URL) . $amend;
|
112 |
}
|
113 |
}
|
114 |
|
115 |
+
if ($this->getLicenseType()=='app' && $useApp) {
|
116 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_WS_URL_APP) . $amend;
|
117 |
}
|
118 |
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
+
* Return PagSeguro's lib url based on selected environment (prod or sandbox)
|
124 |
* @return string
|
125 |
*/
|
126 |
public function getJsUrl()
|
127 |
{
|
128 |
+
if ($this->isSandbox()) {
|
|
|
129 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_JS_URL);
|
130 |
}
|
131 |
return Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_JS_URL);
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
+
* Check if debug mode is active
|
136 |
* @return bool
|
137 |
*/
|
138 |
public function isDebugActive()
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
+
* Is in sandbox mode?
|
145 |
* @return bool
|
146 |
*/
|
147 |
public function isSandbox()
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
+
* Write something to pagseguro.log
|
154 |
* @param $obj mixed|string
|
155 |
*/
|
156 |
public function writeLog($obj)
|
157 |
{
|
158 |
if ($this->isDebugActive()) {
|
159 |
+
if (is_string($obj)) {
|
160 |
Mage::log($obj, Zend_Log::DEBUG, 'pagseguro.log', true);
|
161 |
+
} else {
|
162 |
Mage::log(var_export($obj, true), Zend_Log::DEBUG, 'pagseguro.log', true);
|
163 |
}
|
164 |
}
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
+
* Get current decrypted token based on selected environment. Return FALSE if empty.
|
169 |
* @return string | false
|
170 |
*/
|
171 |
public function getToken()
|
172 |
{
|
173 |
$this->checkTokenIntegrity();
|
174 |
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_TOKEN);
|
175 |
+
if ($this->isSandbox()) {
|
|
|
176 |
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_SANDBOX_TOKEN);
|
177 |
}
|
178 |
+
if (empty($token)) {
|
|
|
179 |
return false;
|
180 |
}
|
181 |
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* Check if CPF should be visible with other payment fields
|
187 |
* @return bool
|
188 |
*/
|
189 |
public function isCpfVisible()
|
190 |
{
|
191 |
+
$customerCpfAttribute = Mage::getStoreConfig('payment/pagseguro/customer_cpf_attribute');
|
192 |
+
return empty($customerCpfAttribute);
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
+
* Get license type (if any)
|
197 |
* @return string
|
198 |
*/
|
199 |
public function getLicenseType()
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* Get PagSeguro PRO key (if exists)
|
206 |
* @return string
|
207 |
*/
|
208 |
public function getPagSeguroProKey()
|
211 |
}
|
212 |
|
213 |
/**
|
214 |
+
* Translate dynamic words from PagSeguro errors and messages
|
215 |
* @author Ricardo Martins
|
216 |
* @return string
|
217 |
*/
|
218 |
+
public function __()
|
219 |
+
{
|
220 |
$args = func_get_args();
|
221 |
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName());
|
222 |
array_unshift($args, $expr);
|
223 |
|
224 |
$text = $args[0]->getText();
|
225 |
+
preg_match('/(.*)\:(.*)/', $text, $matches);
|
226 |
+
if ($matches!==false && isset($matches[1])) {
|
227 |
array_shift($matches);
|
228 |
$matches[0] .= ': %s';
|
229 |
$args = $matches;
|
232 |
}
|
233 |
|
234 |
/**
|
235 |
+
* Check token integrity by verifying it type. If not encrypted, creates a warning on log.
|
236 |
* @author Ricardo Martins
|
237 |
* @return void
|
238 |
*/
|
249 |
}
|
250 |
|
251 |
/**
|
252 |
+
* Creates the dynamic parts on module's JS
|
253 |
* @author Ricardo Martins
|
254 |
* @return Mage_Core_Block_Text
|
255 |
*/
|
256 |
public function getPagSeguroScriptBlock()
|
257 |
{
|
258 |
+
$scriptBlock = Mage::app()->getLayout()->createBlock('core/text', 'js_pagseguro');
|
259 |
+
$secure = Mage::getStoreConfigFlag('web/secure/use_in_frontend');
|
260 |
+
$scriptBlock->setText(
|
261 |
sprintf(
|
262 |
'
|
263 |
<script type="text/javascript">var RMPagSeguroSiteBaseURL = "%s";</script>
|
264 |
<script type="text/javascript" src="%s"></script>
|
265 |
<script type="text/javascript" src="%s"></script>
|
266 |
',
|
267 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure),
|
268 |
Mage::helper('ricardomartins_pagseguro')->getJsUrl(),
|
269 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, $secure) . 'pagseguro/pagseguro.js'
|
270 |
)
|
271 |
);
|
272 |
+
return $scriptBlock;
|
273 |
}
|
274 |
}
|
app/code/community/RicardoMartins/PagSeguro/Helper/Internal.php
CHANGED
@@ -1,17 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Helper_Internal extends Mage_Core_Helper_Abstract
|
9 |
{
|
10 |
-
|
11 |
-
*
|
12 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
|
|
|
|
13 |
*/
|
14 |
-
public static function getFields($type = 'customer_address')
|
|
|
15 |
$entityType = Mage::getModel('eav/config')->getEntityType($type);
|
16 |
$entityTypeId = $entityType->getEntityTypeId();
|
17 |
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
|
@@ -19,35 +26,32 @@ class RicardoMartins_PagSeguro_Helper_Internal extends Mage_Core_Helper_Abstract
|
|
19 |
return $attributes->getData();
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
*
|
24 |
* @return array
|
25 |
*/
|
26 |
public function getCreditCardApiCallParams(Mage_Sales_Model_Order $order, $payment)
|
27 |
{
|
28 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
29 |
-
$
|
30 |
$params = array(
|
31 |
-
|
32 |
-
'token'
|
33 |
-
'paymentMode'
|
34 |
-
'paymentMethod'
|
35 |
-
'receiverEmail'
|
36 |
-
'currency'
|
37 |
'creditCardToken' => $payment['additional_information']['credit_card_token'],
|
38 |
-
'reference'
|
39 |
-
'extraAmount'=> $
|
40 |
-
'notificationURL'
|
41 |
);
|
42 |
-
$
|
43 |
-
$params = array_merge($params, $
|
44 |
-
$params = array_merge($params, $
|
45 |
-
$params = array_merge($params, $
|
46 |
-
$params = array_merge($params, $
|
47 |
-
$params = array_merge($params, $
|
48 |
-
$params = array_merge($params, $phelper->getCreditCardInstallmentsParams($order,$payment));
|
49 |
-
|
50 |
-
// Mage::log(var_export($params, true), null, 'pagseguro.log', true);
|
51 |
|
52 |
return $params;
|
53 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Internal Helper Class - responsible for some internal requests
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Helper_Internal extends Mage_Core_Helper_Abstract
|
13 |
{
|
14 |
+
/**
|
15 |
+
* Get fields from a given entity
|
16 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
17 |
+
* @param $type
|
18 |
+
* @return mixed
|
19 |
*/
|
20 |
+
public static function getFields($type = 'customer_address')
|
21 |
+
{
|
22 |
$entityType = Mage::getModel('eav/config')->getEntityType($type);
|
23 |
$entityTypeId = $entityType->getEntityTypeId();
|
24 |
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
|
26 |
return $attributes->getData();
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Returns associative array with required parameters to API, used on CC method calls
|
31 |
* @return array
|
32 |
*/
|
33 |
public function getCreditCardApiCallParams(Mage_Sales_Model_Order $order, $payment)
|
34 |
{
|
35 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
36 |
+
$pHelper = Mage::helper('ricardomartins_pagseguro/params'); //params helper - helper auxiliar de parametrização
|
37 |
$params = array(
|
38 |
+
'email' => $helper->getMerchantEmail(),
|
39 |
+
'token' => $helper->getToken(),
|
40 |
+
'paymentMode' => 'default',
|
41 |
+
'paymentMethod' => 'creditCard',
|
42 |
+
'receiverEmail' => $helper->getMerchantEmail(),
|
43 |
+
'currency' => 'BRL',
|
44 |
'creditCardToken' => $payment['additional_information']['credit_card_token'],
|
45 |
+
'reference' => $order->getIncrementId(),
|
46 |
+
'extraAmount' => $pHelper->getExtraAmount($order),
|
47 |
+
'notificationURL' => Mage::getUrl('ricardomartins_pagseguro/notification'),
|
48 |
);
|
49 |
+
$params = array_merge($params, $pHelper->getItemsParams($order));
|
50 |
+
$params = array_merge($params, $pHelper->getSenderParams($order, $payment));
|
51 |
+
$params = array_merge($params, $pHelper->getAddressParams($order, 'shipping'));
|
52 |
+
$params = array_merge($params, $pHelper->getAddressParams($order, 'billing'));
|
53 |
+
$params = array_merge($params, $pHelper->getCreditCardHolderParams($order, $payment));
|
54 |
+
$params = array_merge($params, $pHelper->getCreditCardInstallmentsParams($order, $payment));
|
|
|
|
|
|
|
55 |
|
56 |
return $params;
|
57 |
}
|
app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
CHANGED
@@ -1,36 +1,39 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
9 |
{
|
10 |
|
11 |
/**
|
12 |
-
*
|
13 |
* @param Mage_Sales_Model_Order $order
|
14 |
* @return array
|
15 |
*/
|
16 |
public function getItemsParams(Mage_Sales_Model_Order $order)
|
17 |
{
|
18 |
-
$
|
19 |
-
if($items = $order->getAllVisibleItems())
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
$
|
25 |
-
$retorno['itemAmount'.$x] = number_format($items[$y]->getPrice(),2,'.','');
|
26 |
-
$retorno['itemQuantity'.$x] = $items[$y]->getQtyOrdered();
|
27 |
}
|
28 |
}
|
29 |
-
return $
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
*
|
|
|
34 |
* @param Mage_Sales_Model_Order $order
|
35 |
* @param $payment
|
36 |
* @return array
|
@@ -38,30 +41,36 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
38 |
public function getSenderParams(Mage_Sales_Model_Order $order, $payment)
|
39 |
{
|
40 |
$digits = new Zend_Filter_Digits();
|
41 |
-
$cpf = $this->_getCustomerCpfValue($order
|
42 |
|
43 |
-
//telefone
|
44 |
$phone = $this->_extractPhone($order->getBillingAddress()->getTelephone());
|
45 |
|
46 |
|
47 |
-
$
|
48 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
'senderEmail' => trim($order->getCustomerEmail()),
|
50 |
'senderHash' => $payment['additional_information']['sender_hash'],
|
51 |
'senderCPF' => $digits->filter($cpf),
|
52 |
'senderAreaCode'=> $phone['area'],
|
53 |
'senderPhone' => $phone['number'],
|
54 |
);
|
55 |
-
if(strlen($
|
56 |
-
$
|
57 |
-
unset($
|
58 |
}
|
59 |
|
60 |
-
return $
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
-
*
|
65 |
* @param Mage_Sales_Model_Order $order
|
66 |
* @param $payment
|
67 |
* @return array
|
@@ -70,52 +79,54 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
70 |
{
|
71 |
$digits = new Zend_Filter_Digits();
|
72 |
|
73 |
-
$cpf = $this->_getCustomerCpfValue($order
|
74 |
-
|
75 |
|
76 |
-
//
|
77 |
-
$creditCardHolderBirthDate = $this->_getCustomerCcDobValue($order->getCustomer()
|
78 |
$phone = $this->_extractPhone($order->getBillingAddress()->getTelephone());
|
79 |
|
80 |
|
81 |
-
$
|
82 |
-
|
|
|
83 |
'creditCardHolderBirthDate' => $creditCardHolderBirthDate,
|
84 |
'creditCardHolderCPF' => $digits->filter($cpf),
|
85 |
'creditCardHolderAreaCode' => $phone['area'],
|
86 |
'creditCardHolderPhone' => $phone['number'],
|
87 |
);
|
88 |
|
89 |
-
return $
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
*
|
94 |
* @param Mage_Sales_Model_Order $order
|
95 |
* @param $payment Mage_Sales_Model_Order_Payment
|
96 |
* @return array
|
97 |
*/
|
98 |
public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $payment)
|
99 |
{
|
100 |
-
$
|
101 |
-
if($payment->getAdditionalInformation('installment_quantity')
|
102 |
-
|
103 |
-
$
|
104 |
'installmentQuantity' => $payment->getAdditionalInformation('installment_quantity'),
|
105 |
-
'installmentValue' => number_format(
|
|
|
|
|
106 |
);
|
107 |
-
}else{
|
108 |
-
$
|
109 |
'installmentQuantity' => '1',
|
110 |
-
'installmentValue' => number_format($order->getGrandTotal(),2,'.',''),
|
111 |
);
|
112 |
}
|
113 |
-
return $
|
114 |
}
|
115 |
|
116 |
|
117 |
/**
|
118 |
-
*
|
119 |
* @param Mage_Sales_Model_Order $order
|
120 |
* @param string (billing|shipping) $type
|
121 |
* @return array
|
@@ -124,52 +135,57 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
124 |
{
|
125 |
$digits = new Zend_Filter_Digits();
|
126 |
|
127 |
-
//
|
128 |
/** @var Mage_Sales_Model_Order_Address $address */
|
129 |
-
$address = ($type=='shipping' && !$order->getIsVirtual()) ?
|
130 |
-
|
131 |
-
$
|
132 |
-
$
|
133 |
-
$
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
$
|
138 |
-
$
|
139 |
-
$
|
|
|
140 |
$addressPostalCode = $digits->filter($address->getPostcode());
|
141 |
$addressCity = $address->getCity();
|
142 |
-
$addressState = $this->getStateCode(
|
143 |
|
144 |
|
145 |
-
$
|
146 |
-
$type.'AddressStreet' => substr($addressStreet,0,80),
|
147 |
-
$type.'AddressNumber' => substr($addressNumber,0,20),
|
148 |
-
$type.'AddressComplement' => substr($addressComplement,0,40),
|
149 |
-
$type.'AddressDistrict' => substr($addressDistrict,0,60),
|
150 |
$type.'AddressPostalCode' => $addressPostalCode,
|
151 |
-
$type.'AddressCity' => substr($addressCity,0,60),
|
152 |
$type.'AddressState' => $addressState,
|
153 |
$type.'AddressCountry' => 'BRA',
|
154 |
);
|
155 |
|
156 |
-
//
|
157 |
-
if($type == 'shipping')
|
158 |
-
{
|
159 |
$shippingType = $this->_getShippingType($order);
|
160 |
$shippingCost = $order->getShippingAmount();
|
161 |
-
$
|
162 |
-
if($shippingCost > 0)
|
163 |
-
|
164 |
-
if($this->_shouldSplit($order)){
|
165 |
$shippingCost -= 0.01;
|
166 |
}
|
167 |
-
$
|
168 |
}
|
169 |
}
|
170 |
-
return $
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
public function getStateCode($state)
|
174 |
{
|
175 |
if(strlen($state) == 2 && is_string($state))
|
@@ -181,9 +197,36 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
181 |
$state = $this->normalizeChars($state);
|
182 |
$state = trim($state);
|
183 |
$state = mb_convert_case($state, MB_CASE_UPPER);
|
184 |
-
$codes = array(
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
return $code;
|
188 |
}
|
189 |
}
|
@@ -196,7 +239,8 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
196 |
* @param string $s
|
197 |
* @return string
|
198 |
*/
|
199 |
-
public static function normalizeChars($s)
|
|
|
200 |
$replace = array(
|
201 |
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'Ae', 'Å'=>'A', 'Æ'=>'A', 'Ă'=>'A',
|
202 |
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'ae', 'å'=>'a', 'ă'=>'a', 'æ'=>'ae',
|
@@ -221,24 +265,36 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
-
*
|
|
|
225 |
* @param Mage_Sales_Model_Order $order
|
226 |
*
|
227 |
-
* @return
|
228 |
*/
|
229 |
public function getExtraAmount($order)
|
230 |
{
|
231 |
$discount = $order->getDiscountAmount();
|
232 |
-
$
|
233 |
-
$extra = $discount
|
234 |
-
|
|
|
235 |
$extra = $extra+0.01;
|
236 |
}
|
237 |
-
return number_format($extra,2, '.','');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
-
*
|
242 |
* @author Ricardo Martins <ricardo@ricardomartins.net.br>
|
243 |
* @param string $phone
|
244 |
* @return array
|
@@ -248,16 +304,15 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
248 |
$digits = new Zend_Filter_Digits();
|
249 |
$phone = $digits->filter($phone);
|
250 |
//se começar com zero, pula o primeiro digito
|
251 |
-
if(substr($phone,0,1) == '0')
|
252 |
-
|
253 |
-
$phone = substr($phone,1,strlen($phone));
|
254 |
}
|
255 |
-
$
|
256 |
|
257 |
-
$phone = preg_replace('/^(\d{2})(\d{7,9})$/','$1-$2'
|
258 |
-
|
259 |
-
{
|
260 |
-
list($area
|
261 |
return array(
|
262 |
'area' => $area,
|
263 |
'number'=>$number
|
@@ -265,13 +320,13 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
265 |
}
|
266 |
|
267 |
return array(
|
268 |
-
'area' => (string)substr($
|
269 |
-
'number'=> (string)substr($
|
270 |
);
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
-
*
|
275 |
* 1 – PAC, 2 – SEDEX, 3 - Desconhecido
|
276 |
* @param Mage_Sales_Model_Order $order
|
277 |
*
|
@@ -280,37 +335,37 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
280 |
private function _getShippingType(Mage_Sales_Model_Order $order)
|
281 |
{
|
282 |
$method = strtolower($order->getShippingMethod());
|
283 |
-
if(strstr($method,'pac') !== false){
|
284 |
return '1';
|
285 |
-
}else if(strstr($method,'sedex') !== false)
|
286 |
-
{
|
287 |
return '2';
|
288 |
}
|
289 |
return '3';
|
290 |
}
|
291 |
|
292 |
/**
|
293 |
-
*
|
|
|
|
|
294 |
* @param Mage_Sales_Model_Order_Address $address
|
295 |
-
* @param string $
|
|
|
|
|
296 |
*/
|
297 |
-
private function _getAddressAttributeValue($address, $
|
298 |
{
|
299 |
-
$
|
300 |
|
301 |
-
if($
|
302 |
-
{
|
303 |
return $address->getStreet(intval($matches[1]));
|
304 |
-
}
|
305 |
-
else if($attribute_id == '') //Nao informar ao pagseguro
|
306 |
-
{
|
307 |
return '';
|
308 |
}
|
309 |
-
return (string)$address->getData($
|
310 |
}
|
311 |
|
312 |
/**
|
313 |
-
*
|
314 |
* @param Mage_Customer_Model_Customer $customer
|
315 |
* @param $payment
|
316 |
*
|
@@ -318,23 +373,22 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
318 |
*/
|
319 |
private function _getCustomerCcDobValue(Mage_Customer_Model_Customer $customer, $payment)
|
320 |
{
|
321 |
-
$
|
322 |
|
323 |
-
if(empty($
|
324 |
-
|
325 |
-
if(isset($payment['additional_information']['credit_card_owner_birthdate'])){
|
326 |
return $payment['additional_information']['credit_card_owner_birthdate'];
|
327 |
}
|
328 |
}
|
329 |
|
330 |
-
$dob = $customer->getResource()->getAttribute($
|
331 |
|
332 |
|
333 |
return date('d/m/Y', strtotime($dob));
|
334 |
}
|
335 |
|
336 |
/**
|
337 |
-
*
|
338 |
* @param Mage_Sales_Model_Order $order
|
339 |
* @param Mage_Payment_Model_Method_Abstract $payment
|
340 |
*
|
@@ -342,36 +396,47 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
342 |
*/
|
343 |
private function _getCustomerCpfValue(Mage_Sales_Model_Order $order, $payment)
|
344 |
{
|
345 |
-
$
|
346 |
|
347 |
-
if(empty($
|
348 |
-
|
349 |
-
|
350 |
-
return $payment['additional_information'][$payment->getMethod().'_cpf'];
|
351 |
}
|
352 |
}
|
353 |
-
$entity = explode('|'
|
354 |
$cpf = '';
|
355 |
-
if(count($entity) == 1 || $entity[0] == 'customer'){
|
356 |
-
if(count($entity) == 2){
|
357 |
-
$
|
358 |
}
|
359 |
$customer = $order->getCustomer();
|
360 |
|
361 |
-
$cpf = $customer->getData($
|
362 |
-
}else if(count($entity) == 2 && $entity[0] == 'billing' ){ //billing
|
363 |
$cpf = $order->getShippingAddress()->getData($entity[1]);
|
364 |
}
|
365 |
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
}
|
368 |
|
369 |
|
370 |
/**
|
371 |
-
*
|
372 |
-
*
|
373 |
-
*
|
374 |
-
*
|
375 |
*
|
376 |
* @param $order
|
377 |
*
|
@@ -380,11 +445,11 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
380 |
private function _shouldSplit($order)
|
381 |
{
|
382 |
$discount = $order->getDiscountAmount();
|
383 |
-
$
|
384 |
-
$extraAmount = $discount
|
385 |
|
386 |
$totalAmount = 0;
|
387 |
-
foreach($order->getAllVisibleItems() as $item){
|
388 |
$totalAmount += $item->getRowTotal();
|
389 |
}
|
390 |
return (abs($extraAmount) == $totalAmount);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Params Helper Class - responsible for formatting and grabbing parameters used on PagSeguro API calls
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
13 |
{
|
14 |
|
15 |
/**
|
16 |
+
* Return items information, to be send to API
|
17 |
* @param Mage_Sales_Model_Order $order
|
18 |
* @return array
|
19 |
*/
|
20 |
public function getItemsParams(Mage_Sales_Model_Order $order)
|
21 |
{
|
22 |
+
$return = array();
|
23 |
+
if ($items = $order->getAllVisibleItems()) {
|
24 |
+
for ($x=1, $y=0, $c=count($items); $x <= $c; $x++, $y++) {
|
25 |
+
$return['itemId'.$x] = $items[$y]->getId();
|
26 |
+
$return['itemDescription'.$x] = substr($items[$y]->getName(), 0, 100);
|
27 |
+
$return['itemAmount'.$x] = number_format($items[$y]->getPrice(), 2, '.', '');
|
28 |
+
$return['itemQuantity'.$x] = $items[$y]->getQtyOrdered();
|
|
|
|
|
29 |
}
|
30 |
}
|
31 |
+
return $return;
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Return an array with Sender(Customer) information to be used on API call
|
36 |
+
*
|
37 |
* @param Mage_Sales_Model_Order $order
|
38 |
* @param $payment
|
39 |
* @return array
|
41 |
public function getSenderParams(Mage_Sales_Model_Order $order, $payment)
|
42 |
{
|
43 |
$digits = new Zend_Filter_Digits();
|
44 |
+
$cpf = $this->_getCustomerCpfValue($order, $payment);
|
45 |
|
|
|
46 |
$phone = $this->_extractPhone($order->getBillingAddress()->getTelephone());
|
47 |
|
48 |
|
49 |
+
$senderName = sprintf(
|
50 |
+
'%s %s',
|
51 |
+
$this->removeDuplicatedSpaces($order->getCustomerFirstname()),
|
52 |
+
$this->removeDuplicatedSpaces($order->getCustomerLastname())
|
53 |
+
);
|
54 |
+
$senderName = substr($senderName, 0, 50);
|
55 |
+
|
56 |
+
$return = array(
|
57 |
+
'senderName' => $senderName,
|
58 |
'senderEmail' => trim($order->getCustomerEmail()),
|
59 |
'senderHash' => $payment['additional_information']['sender_hash'],
|
60 |
'senderCPF' => $digits->filter($cpf),
|
61 |
'senderAreaCode'=> $phone['area'],
|
62 |
'senderPhone' => $phone['number'],
|
63 |
);
|
64 |
+
if (strlen($return['senderCPF']) > 11) {
|
65 |
+
$return['senderCNPJ'] = $return['senderCPF'];
|
66 |
+
unset($return['senderCPF']);
|
67 |
}
|
68 |
|
69 |
+
return $return;
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
+
* Returns an array with credit card's owner (Customer) to be used on API
|
74 |
* @param Mage_Sales_Model_Order $order
|
75 |
* @param $payment
|
76 |
* @return array
|
79 |
{
|
80 |
$digits = new Zend_Filter_Digits();
|
81 |
|
82 |
+
$cpf = $this->_getCustomerCpfValue($order, $payment);
|
|
|
83 |
|
84 |
+
//data
|
85 |
+
$creditCardHolderBirthDate = $this->_getCustomerCcDobValue($order->getCustomer(), $payment);
|
86 |
$phone = $this->_extractPhone($order->getBillingAddress()->getTelephone());
|
87 |
|
88 |
|
89 |
+
$holderName = $this->removeDuplicatedSpaces($payment['additional_information']['credit_card_owner']);
|
90 |
+
$return = array(
|
91 |
+
'creditCardHolderName' => $holderName,
|
92 |
'creditCardHolderBirthDate' => $creditCardHolderBirthDate,
|
93 |
'creditCardHolderCPF' => $digits->filter($cpf),
|
94 |
'creditCardHolderAreaCode' => $phone['area'],
|
95 |
'creditCardHolderPhone' => $phone['number'],
|
96 |
);
|
97 |
|
98 |
+
return $return;
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
+
* Return an array with installment information to be used with API
|
103 |
* @param Mage_Sales_Model_Order $order
|
104 |
* @param $payment Mage_Sales_Model_Order_Payment
|
105 |
* @return array
|
106 |
*/
|
107 |
public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $payment)
|
108 |
{
|
109 |
+
$return = array();
|
110 |
+
if ($payment->getAdditionalInformation('installment_quantity')
|
111 |
+
&& $payment->getAdditionalInformation('installment_value')) {
|
112 |
+
$return = array(
|
113 |
'installmentQuantity' => $payment->getAdditionalInformation('installment_quantity'),
|
114 |
+
'installmentValue' => number_format(
|
115 |
+
$payment->getAdditionalInformation('installment_value'), 2, '.', ''
|
116 |
+
),
|
117 |
);
|
118 |
+
} else {
|
119 |
+
$return = array(
|
120 |
'installmentQuantity' => '1',
|
121 |
+
'installmentValue' => number_format($order->getGrandTotal(), 2, '.', ''),
|
122 |
);
|
123 |
}
|
124 |
+
return $return;
|
125 |
}
|
126 |
|
127 |
|
128 |
/**
|
129 |
+
* Return an array with address (shipping/billing) information to be used on API
|
130 |
* @param Mage_Sales_Model_Order $order
|
131 |
* @param string (billing|shipping) $type
|
132 |
* @return array
|
135 |
{
|
136 |
$digits = new Zend_Filter_Digits();
|
137 |
|
138 |
+
//address attributes
|
139 |
/** @var Mage_Sales_Model_Order_Address $address */
|
140 |
+
$address = ($type=='shipping' && !$order->getIsVirtual()) ?
|
141 |
+
$order->getShippingAddress() : $order->getBillingAddress();
|
142 |
+
$addressStreetAttribute = Mage::getStoreConfig('payment/pagseguro/address_street_attribute');
|
143 |
+
$addressNumberAttribute = Mage::getStoreConfig('payment/pagseguro/address_number_attribute');
|
144 |
+
$addressComplementAttribute = Mage::getStoreConfig('payment/pagseguro/address_complement_attribute');
|
145 |
+
$addressNeighborhoodAttribute = Mage::getStoreConfig('payment/pagseguro/address_neighborhood_attribute');
|
146 |
+
|
147 |
+
//gathering address data
|
148 |
+
$addressStreet = $this->_getAddressAttributeValue($address, $addressStreetAttribute);
|
149 |
+
$addressNumber = $this->_getAddressAttributeValue($address, $addressNumberAttribute);
|
150 |
+
$addressComplement = $this->_getAddressAttributeValue($address, $addressComplementAttribute);
|
151 |
+
$addressDistrict = $this->_getAddressAttributeValue($address, $addressNeighborhoodAttribute);
|
152 |
$addressPostalCode = $digits->filter($address->getPostcode());
|
153 |
$addressCity = $address->getCity();
|
154 |
+
$addressState = $this->getStateCode($address->getRegion());
|
155 |
|
156 |
|
157 |
+
$return = array(
|
158 |
+
$type.'AddressStreet' => substr($addressStreet, 0, 80),
|
159 |
+
$type.'AddressNumber' => substr($addressNumber, 0, 20),
|
160 |
+
$type.'AddressComplement' => substr($addressComplement, 0, 40),
|
161 |
+
$type.'AddressDistrict' => substr($addressDistrict, 0, 60),
|
162 |
$type.'AddressPostalCode' => $addressPostalCode,
|
163 |
+
$type.'AddressCity' => substr($addressCity, 0, 60),
|
164 |
$type.'AddressState' => $addressState,
|
165 |
$type.'AddressCountry' => 'BRA',
|
166 |
);
|
167 |
|
168 |
+
//shipping specific
|
169 |
+
if ($type == 'shipping') {
|
|
|
170 |
$shippingType = $this->_getShippingType($order);
|
171 |
$shippingCost = $order->getShippingAmount();
|
172 |
+
$return['shippingType'] = $shippingType;
|
173 |
+
if ($shippingCost > 0) {
|
174 |
+
if ($this->_shouldSplit($order)) {
|
|
|
175 |
$shippingCost -= 0.01;
|
176 |
}
|
177 |
+
$return['shippingCost'] = number_format($shippingCost, 2, '.', '');
|
178 |
}
|
179 |
}
|
180 |
+
return $return;
|
181 |
}
|
182 |
|
183 |
+
/**
|
184 |
+
* Get BR State code even if it was typed manually
|
185 |
+
* @param $state
|
186 |
+
*
|
187 |
+
* @return string
|
188 |
+
*/
|
189 |
public function getStateCode($state)
|
190 |
{
|
191 |
if(strlen($state) == 2 && is_string($state))
|
197 |
$state = $this->normalizeChars($state);
|
198 |
$state = trim($state);
|
199 |
$state = mb_convert_case($state, MB_CASE_UPPER);
|
200 |
+
$codes = array(
|
201 |
+
'AC'=>'ACRE',
|
202 |
+
'AL'=>'ALAGOAS',
|
203 |
+
'AM'=>'AMAZONAS',
|
204 |
+
'AP'=>'AMAPA',
|
205 |
+
'BA'=>'BAHIA',
|
206 |
+
'CE'=>'CEARA',
|
207 |
+
'DF'=>'DISTRITO FEDERAL',
|
208 |
+
'ES'=>'ESPIRITO SANTO',
|
209 |
+
'GO'=>'GOIAS',
|
210 |
+
'MA'=>'MARANHAO',
|
211 |
+
'MT'=>'MATO GROSSO',
|
212 |
+
'MS'=>'MATO GROSSO DO SUL',
|
213 |
+
'MG'=>'MINAS GERAIS',
|
214 |
+
'PA'=>'PARA',
|
215 |
+
'PB'=>'PARAIBA',
|
216 |
+
'PR'=>'PARANA',
|
217 |
+
'PE'=>'PERNAMBUCO',
|
218 |
+
'PI'=>'PIAUI',
|
219 |
+
'RJ'=>'RIO DE JANEIRO',
|
220 |
+
'RN'=>'RIO GRANDE DO NORTE',
|
221 |
+
'RO'=>'RONDONIA',
|
222 |
+
'RS'=>'RIO GRANDE DO SUL',
|
223 |
+
'RR'=>'RORAIMA',
|
224 |
+
'SC'=>'SANTA CATARINA',
|
225 |
+
'SE'=>'SERGIPE',
|
226 |
+
'SP'=>'SAO PAULO',
|
227 |
+
'TO'=>'TOCANTINS'
|
228 |
+
);
|
229 |
+
if ($code = array_search($state, $codes)) {
|
230 |
return $code;
|
231 |
}
|
232 |
}
|
239 |
* @param string $s
|
240 |
* @return string
|
241 |
*/
|
242 |
+
public static function normalizeChars($s)
|
243 |
+
{
|
244 |
$replace = array(
|
245 |
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'Ae', 'Å'=>'A', 'Æ'=>'A', 'Ă'=>'A',
|
246 |
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'ae', 'å'=>'a', 'ă'=>'a', 'æ'=>'ae',
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
+
* Calculates the "Exta" value that corresponds to Tax values minus Discount given
|
269 |
+
* It makes the correct discount to be shown correctly on PagSeguro
|
270 |
* @param Mage_Sales_Model_Order $order
|
271 |
*
|
272 |
+
* @return float
|
273 |
*/
|
274 |
public function getExtraAmount($order)
|
275 |
{
|
276 |
$discount = $order->getDiscountAmount();
|
277 |
+
$taxAmount = $order->getTaxAmount();
|
278 |
+
$extra = $discount + $taxAmount;
|
279 |
+
|
280 |
+
if ($this->_shouldSplit($order)) {
|
281 |
$extra = $extra+0.01;
|
282 |
}
|
283 |
+
return number_format($extra, 2, '.', '');
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Remove duplicated spaces from string
|
288 |
+
* @param $string
|
289 |
+
* @return string
|
290 |
+
*/
|
291 |
+
public function removeDuplicatedSpaces($string)
|
292 |
+
{
|
293 |
+
return preg_replace('/\s+/', ' ', $string);
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
+
* Extracts phone area code and returns phone number, with area code as key of the returned array
|
298 |
* @author Ricardo Martins <ricardo@ricardomartins.net.br>
|
299 |
* @param string $phone
|
300 |
* @return array
|
304 |
$digits = new Zend_Filter_Digits();
|
305 |
$phone = $digits->filter($phone);
|
306 |
//se começar com zero, pula o primeiro digito
|
307 |
+
if (substr($phone, 0, 1) == '0') {
|
308 |
+
$phone = substr($phone, 1, strlen($phone));
|
|
|
309 |
}
|
310 |
+
$originalPhone = $phone;
|
311 |
|
312 |
+
$phone = preg_replace('/^(\d{2})(\d{7,9})$/', '$1-$2', $phone);
|
313 |
+
|
314 |
+
if (is_array($phone) && count($phone) == 2) {
|
315 |
+
list($area, $number) = explode('-', $phone);
|
316 |
return array(
|
317 |
'area' => $area,
|
318 |
'number'=>$number
|
320 |
}
|
321 |
|
322 |
return array(
|
323 |
+
'area' => (string)substr($originalPhone, 0, 2),
|
324 |
+
'number'=> (string)substr($originalPhone, 2, 9),
|
325 |
);
|
326 |
}
|
327 |
|
328 |
/**
|
329 |
+
* Return shipping code based on PagSeguro Documentation
|
330 |
* 1 – PAC, 2 – SEDEX, 3 - Desconhecido
|
331 |
* @param Mage_Sales_Model_Order $order
|
332 |
*
|
335 |
private function _getShippingType(Mage_Sales_Model_Order $order)
|
336 |
{
|
337 |
$method = strtolower($order->getShippingMethod());
|
338 |
+
if (strstr($method, 'pac') !== false) {
|
339 |
return '1';
|
340 |
+
} else if (strstr($method, 'sedex') !== false) {
|
|
|
341 |
return '2';
|
342 |
}
|
343 |
return '3';
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
+
* Gets the shipping attribute based on one of the id's from
|
348 |
+
* RicardoMartins_PagSeguro_Model_Source_Customer_Address_*
|
349 |
+
*
|
350 |
* @param Mage_Sales_Model_Order_Address $address
|
351 |
+
* @param string $attributeId
|
352 |
+
*
|
353 |
+
* @return string
|
354 |
*/
|
355 |
+
private function _getAddressAttributeValue($address, $attributeId)
|
356 |
{
|
357 |
+
$isStreetline = preg_match('/^street_(\d{1})$/', $attributeId, $matches);
|
358 |
|
359 |
+
if ($isStreetline !== false && isset($matches[1])) { //uses streetlines
|
|
|
360 |
return $address->getStreet(intval($matches[1]));
|
361 |
+
} else if ($attributeId == '') { //do not tell pagseguro
|
|
|
|
|
362 |
return '';
|
363 |
}
|
364 |
+
return (string)$address->getData($attributeId);
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
+
* Returns customer's date of birthday, based on your module configuration
|
369 |
* @param Mage_Customer_Model_Customer $customer
|
370 |
* @param $payment
|
371 |
*
|
373 |
*/
|
374 |
private function _getCustomerCcDobValue(Mage_Customer_Model_Customer $customer, $payment)
|
375 |
{
|
376 |
+
$ccDobAttribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
|
377 |
|
378 |
+
if (empty($ccDobAttribute)) { //when asked with payment data
|
379 |
+
if (isset($payment['additional_information']['credit_card_owner_birthdate'])) {
|
|
|
380 |
return $payment['additional_information']['credit_card_owner_birthdate'];
|
381 |
}
|
382 |
}
|
383 |
|
384 |
+
$dob = $customer->getResource()->getAttribute($ccDobAttribute)->getFrontend()->getValue($customer);
|
385 |
|
386 |
|
387 |
return date('d/m/Y', strtotime($dob));
|
388 |
}
|
389 |
|
390 |
/**
|
391 |
+
* Returns customer's CPF based on your module configuration
|
392 |
* @param Mage_Sales_Model_Order $order
|
393 |
* @param Mage_Payment_Model_Method_Abstract $payment
|
394 |
*
|
396 |
*/
|
397 |
private function _getCustomerCpfValue(Mage_Sales_Model_Order $order, $payment)
|
398 |
{
|
399 |
+
$customerCpfAttribute = Mage::getStoreConfig('payment/pagseguro/customer_cpf_attribute');
|
400 |
|
401 |
+
if (empty($customerCpfAttribute)) { //Asked with payment data
|
402 |
+
if (isset($payment['additional_information'][$payment->getMethod() . '_cpf'])) {
|
403 |
+
return $payment['additional_information'][$payment->getMethod() . '_cpf'];
|
|
|
404 |
}
|
405 |
}
|
406 |
+
$entity = explode('|', $customerCpfAttribute);
|
407 |
$cpf = '';
|
408 |
+
if (count($entity) == 1 || $entity[0] == 'customer') {
|
409 |
+
if (count($entity) == 2) {
|
410 |
+
$customerCpfAttribute = $entity[1];
|
411 |
}
|
412 |
$customer = $order->getCustomer();
|
413 |
|
414 |
+
$cpf = $customer->getData($customerCpfAttribute);
|
415 |
+
} else if (count($entity) == 2 && $entity[0] == 'billing' ) { //billing
|
416 |
$cpf = $order->getShippingAddress()->getData($entity[1]);
|
417 |
}
|
418 |
|
419 |
+
$cpfObj = new Varien_Object(array('cpf'=>$cpf));
|
420 |
+
|
421 |
+
//you can create a module to get customer's CPF from somewhere else
|
422 |
+
Mage::dispatchEvent(
|
423 |
+
'ricardomartins_pagseguro_return_cpf_before',
|
424 |
+
array(
|
425 |
+
'order' => $order,
|
426 |
+
'payment' => $payment,
|
427 |
+
'cpf_obj' => $cpfObj,
|
428 |
+
)
|
429 |
+
);
|
430 |
+
|
431 |
+
return $cpfObj->getCpf();
|
432 |
}
|
433 |
|
434 |
|
435 |
/**
|
436 |
+
* Should split shipping? If grand total is equal to discount total.
|
437 |
+
* PagSeguro needs to receive product values > R$0,00, even if you need to invoice only shipping
|
438 |
+
* and would like to give producs for free.
|
439 |
+
* In these cases, splitting will add R$0,01 for each product, reducing R$0,01 from shipping total.
|
440 |
*
|
441 |
* @param $order
|
442 |
*
|
445 |
private function _shouldSplit($order)
|
446 |
{
|
447 |
$discount = $order->getDiscountAmount();
|
448 |
+
$taxAmount = $order->getTaxAmount();
|
449 |
+
$extraAmount = $discount + $taxAmount;
|
450 |
|
451 |
$totalAmount = 0;
|
452 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
453 |
$totalAmount += $item->getRowTotal();
|
454 |
}
|
455 |
return (abs($extraAmount) == $totalAmount);
|
app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php
CHANGED
@@ -1,19 +1,34 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
3 |
{
|
4 |
/**
|
5 |
-
*
|
6 |
* @see https://pagseguro.uol.com.br/v2/guia-de-integracao/api-de-notificacoes.html#v2-item-servico-de-notificacoes
|
7 |
* @param SimpleXMLElement $resultXML
|
8 |
*/
|
9 |
public function proccessNotificatonResult(SimpleXMLElement $resultXML)
|
10 |
{
|
11 |
-
if(isset($resultXML->error)){
|
12 |
$errMsg = Mage::helper('ricardomartins_pagseguro')->__((string)$resultXML->error->message);
|
13 |
-
Mage::throwException(
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
-
if(isset($resultXML->reference))
|
16 |
-
{
|
17 |
/** @var Mage_Sales_Model_Order $order */
|
18 |
$order = Mage::getModel('sales/order')->loadByIncrementId((string)$resultXML->reference);
|
19 |
$payment = $order->getPayment();
|
@@ -21,24 +36,24 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
21 |
$processedState = $this->processStatus((int)$resultXML->status);
|
22 |
$message = $processedState->getMessage();
|
23 |
|
24 |
-
if((int)$resultXML->status == 6) //valor devolvido (gera credit memo e tenta cancelar o pedido)
|
25 |
-
{
|
26 |
if ($order->canUnhold()) {
|
27 |
$order->unhold();
|
28 |
}
|
29 |
-
if($order->canCancel())
|
30 |
-
{
|
31 |
$order->cancel();
|
32 |
$order->save();
|
33 |
-
}else{
|
34 |
$payment->registerRefundNotification(floatval($resultXML->grossAmount));
|
35 |
-
$order->addStatusHistoryComment(
|
36 |
-
|
|
|
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
if((int)$resultXML->status == 7 && isset($resultXML->cancellationSource))
|
41 |
-
|
42 |
switch((string)$resultXML->cancellationSource)
|
43 |
{
|
44 |
case 'INTERNAL':
|
@@ -51,22 +66,28 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
51 |
$order->cancel();
|
52 |
}
|
53 |
|
54 |
-
if($processedState->getStateChanged())
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
$order->addStatusHistoryComment($message);
|
59 |
}
|
60 |
|
61 |
-
if((int)$resultXML->status == 3) //Quando o pedido foi dado como Pago
|
62 |
-
{
|
63 |
//cria fatura e envia email (se configurado)
|
64 |
// $payment->registerCaptureNotification(floatval($resultXML->grossAmount));
|
65 |
$invoice = $order->prepareInvoice();
|
66 |
$invoice->register()->pay();
|
67 |
$msg = sprintf('Pagamento capturado. Identificador da Transação: %s', (string)$resultXML->code);
|
68 |
$invoice->addComment($msg);
|
69 |
-
$invoice->sendEmail(
|
|
|
|
|
|
|
70 |
Mage::getModel('core/resource_transaction')
|
71 |
->addObject($invoice)
|
72 |
->addObject($invoice->getOrder())
|
@@ -76,18 +97,21 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
76 |
|
77 |
$payment->save();
|
78 |
$order->save();
|
79 |
-
Mage::dispatchEvent(
|
|
|
|
|
80 |
'order' => $order,
|
81 |
'payment'=> $payment,
|
82 |
'result_xml' => $resultXML,
|
83 |
-
)
|
84 |
-
|
|
|
85 |
Mage::throwException('Retorno inválido. Referência do pedido não encontrada.');
|
86 |
}
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
-
*
|
91 |
* @param $notificationCode
|
92 |
*
|
93 |
* @return SimpleXMLElement
|
@@ -97,10 +121,12 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
97 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
98 |
$url = $helper->getWsUrl('transactions/notifications/' . $notificationCode, false);
|
99 |
$client = new Zend_Http_Client($url);
|
100 |
-
$client->setParameterGet(
|
|
|
101 |
'token'=>$helper->getToken(),
|
102 |
'email'=> $helper->getMerchantEmail(),
|
103 |
-
)
|
|
|
104 |
|
105 |
$client->request();
|
106 |
$resposta = $client->getLastResponse()->getBody();
|
@@ -111,7 +137,8 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
111 |
}
|
112 |
|
113 |
/**
|
114 |
-
*
|
|
|
115 |
* @param $statusCode
|
116 |
* @return Varien_Object
|
117 |
*/
|
@@ -125,24 +152,36 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
125 |
case '1':
|
126 |
$return->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
127 |
$return->setIsCustomerNotified($this->getCode()!='pagseguro_cc');
|
128 |
-
if($this->getCode()=='pagseguro_cc'){
|
129 |
$return->setStateChanged(false);
|
130 |
}
|
131 |
-
$return->setMessage(
|
|
|
|
|
|
|
132 |
break;
|
133 |
case '2':
|
134 |
$return->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW);
|
135 |
$return->setIsCustomerNotified(true);
|
136 |
-
$return->setMessage(
|
|
|
|
|
|
|
137 |
break;
|
138 |
case '3':
|
139 |
$return->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
140 |
$return->setIsCustomerNotified(true);
|
141 |
-
$return->setMessage(
|
|
|
|
|
|
|
142 |
$return->setIsTransactionPending(false);
|
143 |
break;
|
144 |
case '4':
|
145 |
-
$return->setMessage(
|
|
|
|
|
|
|
146 |
$return->setIsCustomerNotified(false);
|
147 |
$return->setStateChanged(false);
|
148 |
$return->setIsTransactionPending(false);
|
@@ -151,7 +190,10 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
151 |
$return->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
152 |
$return->setIsCustomerNotified(false);
|
153 |
$return->setIsTransactionPending(false);
|
154 |
-
$return->setMessage(
|
|
|
|
|
|
|
155 |
break;
|
156 |
case '6':
|
157 |
$return->setState(Mage_Sales_Model_Order::STATE_CLOSED);
|
@@ -173,7 +215,7 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
* @param $params
|
178 |
* @param $payment
|
179 |
*
|
@@ -182,23 +224,23 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
182 |
public function callApi($params, $payment)
|
183 |
{
|
184 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
185 |
-
$
|
186 |
-
if($
|
187 |
$params['public_key'] = Mage::getStoreConfig('payment/pagseguropro/key');
|
188 |
}
|
189 |
-
$params = $this->
|
190 |
-
$
|
191 |
|
192 |
-
$helper->writeLog('Parametros sendo enviados para API (/transactions): '. var_export($params,true));
|
193 |
|
194 |
$ch = curl_init();
|
195 |
-
curl_setopt($ch,CURLOPT_URL, $helper->getWsUrl('transactions', $
|
196 |
-
curl_setopt($ch,CURLOPT_POST, count($params));
|
197 |
-
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
|
198 |
-
curl_setopt($ch,CURLOPT_POSTFIELDS, $
|
199 |
-
curl_setopt($ch,CURLOPT_TIMEOUT, 45);
|
200 |
-
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, 0);
|
201 |
-
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, 0);
|
202 |
|
203 |
try{
|
204 |
$response = curl_exec($ch);
|
@@ -206,61 +248,68 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
206 |
Mage::throwException('Falha na comunicação com Pagseguro (' . $e->getMessage() . ')');
|
207 |
}
|
208 |
|
209 |
-
if(curl_error($ch)){
|
210 |
-
Mage::throwException(
|
|
|
|
|
211 |
}
|
212 |
curl_close($ch);
|
213 |
|
214 |
-
$helper->writeLog('Retorno PagSeguro (/transactions): ' . var_export($response,true));
|
215 |
|
216 |
libxml_use_internal_errors(true);
|
217 |
$xml = simplexml_load_string(trim($response));
|
218 |
-
if(false === $xml){
|
219 |
switch($response){
|
220 |
case 'Unauthorized':
|
221 |
-
$helper->writeLog(
|
|
|
|
|
222 |
break;
|
223 |
case 'Forbidden':
|
224 |
-
$helper->writeLog(
|
|
|
|
|
|
|
225 |
break;
|
226 |
default:
|
227 |
$helper->writeLog('Retorno inesperado do PagSeguro. Retorno: ' . $response);
|
228 |
}
|
229 |
-
Mage::throwException(
|
|
|
|
|
230 |
}
|
231 |
|
232 |
return $xml;
|
233 |
}
|
234 |
|
235 |
/**
|
236 |
-
*
|
237 |
* @param array $params
|
238 |
*
|
239 |
* @return array
|
240 |
*/
|
241 |
-
protected function
|
242 |
{
|
243 |
-
foreach($params as $k => $v)
|
244 |
-
{
|
245 |
$params[$k] = utf8_decode($v);
|
246 |
}
|
247 |
return $params;
|
248 |
}
|
249 |
|
250 |
/**
|
251 |
-
*
|
252 |
* @param array $params
|
253 |
*
|
254 |
* @return string
|
255 |
*/
|
256 |
protected function _convertToCURLString(array $params)
|
257 |
{
|
258 |
-
$
|
259 |
-
foreach($params as $k => $v)
|
260 |
-
|
261 |
-
$fields_string .= $k.'='.urlencode($v).'&';
|
262 |
}
|
263 |
|
264 |
-
return rtrim($
|
265 |
}
|
266 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* PagSeguro Abstract Model Class - Used on processing and sending information to/from PagSeguro
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
13 |
{
|
14 |
/**
|
15 |
+
* Processes notification XML data. XML is sent right after order is sent to PagSeguro, and on order updates.
|
16 |
* @see https://pagseguro.uol.com.br/v2/guia-de-integracao/api-de-notificacoes.html#v2-item-servico-de-notificacoes
|
17 |
* @param SimpleXMLElement $resultXML
|
18 |
*/
|
19 |
public function proccessNotificatonResult(SimpleXMLElement $resultXML)
|
20 |
{
|
21 |
+
if (isset($resultXML->error)) {
|
22 |
$errMsg = Mage::helper('ricardomartins_pagseguro')->__((string)$resultXML->error->message);
|
23 |
+
Mage::throwException(
|
24 |
+
$this->_getHelper()->__(
|
25 |
+
'Problemas ao processar seu pagamento. %s(%s)',
|
26 |
+
$errMsg,
|
27 |
+
(string)$resultXML->error->code
|
28 |
+
)
|
29 |
+
);
|
30 |
}
|
31 |
+
if (isset($resultXML->reference)) {
|
|
|
32 |
/** @var Mage_Sales_Model_Order $order */
|
33 |
$order = Mage::getModel('sales/order')->loadByIncrementId((string)$resultXML->reference);
|
34 |
$payment = $order->getPayment();
|
36 |
$processedState = $this->processStatus((int)$resultXML->status);
|
37 |
$message = $processedState->getMessage();
|
38 |
|
39 |
+
if ((int)$resultXML->status == 6) { //valor devolvido (gera credit memo e tenta cancelar o pedido)
|
|
|
40 |
if ($order->canUnhold()) {
|
41 |
$order->unhold();
|
42 |
}
|
43 |
+
if ($order->canCancel()) {
|
|
|
44 |
$order->cancel();
|
45 |
$order->save();
|
46 |
+
} else {
|
47 |
$payment->registerRefundNotification(floatval($resultXML->grossAmount));
|
48 |
+
$order->addStatusHistoryComment(
|
49 |
+
'Devolvido: o valor foi devolvido ao comprador, mas o
|
50 |
+
pedido encontra-se em um estado que não pode ser cancelado.'
|
51 |
+
)->save();
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
if ((int)$resultXML->status == 7 && isset($resultXML->cancellationSource)) {
|
56 |
+
//Especificamos a fonte do cancelamento do pedido
|
57 |
switch((string)$resultXML->cancellationSource)
|
58 |
{
|
59 |
case 'INTERNAL':
|
66 |
$order->cancel();
|
67 |
}
|
68 |
|
69 |
+
if ($processedState->getStateChanged()) {
|
70 |
+
$order->setState(
|
71 |
+
$processedState->getState(),
|
72 |
+
true,
|
73 |
+
$message,
|
74 |
+
$processedState->getIsCustomerNotified()
|
75 |
+
)->save();
|
76 |
+
} else {
|
77 |
$order->addStatusHistoryComment($message);
|
78 |
}
|
79 |
|
80 |
+
if ((int)$resultXML->status == 3) { //Quando o pedido foi dado como Pago
|
|
|
81 |
//cria fatura e envia email (se configurado)
|
82 |
// $payment->registerCaptureNotification(floatval($resultXML->grossAmount));
|
83 |
$invoice = $order->prepareInvoice();
|
84 |
$invoice->register()->pay();
|
85 |
$msg = sprintf('Pagamento capturado. Identificador da Transação: %s', (string)$resultXML->code);
|
86 |
$invoice->addComment($msg);
|
87 |
+
$invoice->sendEmail(
|
88 |
+
Mage::getStoreConfigFlag('payment/pagseguro/send_invoice_email'),
|
89 |
+
'Pagamento recebido com sucesso.'
|
90 |
+
);
|
91 |
Mage::getModel('core/resource_transaction')
|
92 |
->addObject($invoice)
|
93 |
->addObject($invoice->getOrder())
|
97 |
|
98 |
$payment->save();
|
99 |
$order->save();
|
100 |
+
Mage::dispatchEvent(
|
101 |
+
'pagseguro_proccess_notification_after',
|
102 |
+
array(
|
103 |
'order' => $order,
|
104 |
'payment'=> $payment,
|
105 |
'result_xml' => $resultXML,
|
106 |
+
)
|
107 |
+
);
|
108 |
+
} else {
|
109 |
Mage::throwException('Retorno inválido. Referência do pedido não encontrada.');
|
110 |
}
|
111 |
}
|
112 |
|
113 |
/**
|
114 |
+
* Grab statuses changes when receiving a new notification code
|
115 |
* @param $notificationCode
|
116 |
*
|
117 |
* @return SimpleXMLElement
|
121 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
122 |
$url = $helper->getWsUrl('transactions/notifications/' . $notificationCode, false);
|
123 |
$client = new Zend_Http_Client($url);
|
124 |
+
$client->setParameterGet(
|
125 |
+
array(
|
126 |
'token'=>$helper->getToken(),
|
127 |
'email'=> $helper->getMerchantEmail(),
|
128 |
+
)
|
129 |
+
);
|
130 |
|
131 |
$client->request();
|
132 |
$resposta = $client->getLastResponse()->getBody();
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
+
* Processes order status and return information about order status and state
|
141 |
+
* Doesn' change anything to the order. Just returns an object showing what to do.
|
142 |
* @param $statusCode
|
143 |
* @return Varien_Object
|
144 |
*/
|
152 |
case '1':
|
153 |
$return->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
154 |
$return->setIsCustomerNotified($this->getCode()!='pagseguro_cc');
|
155 |
+
if ($this->getCode()=='pagseguro_cc') {
|
156 |
$return->setStateChanged(false);
|
157 |
}
|
158 |
+
$return->setMessage(
|
159 |
+
'Aguardando pagamento: o comprador iniciou a transação,
|
160 |
+
mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.'
|
161 |
+
);
|
162 |
break;
|
163 |
case '2':
|
164 |
$return->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW);
|
165 |
$return->setIsCustomerNotified(true);
|
166 |
+
$return->setMessage(
|
167 |
+
'Em análise: o comprador optou por pagar com um cartão de crédito e
|
168 |
+
o PagSeguro está analisando o risco da transação.'
|
169 |
+
);
|
170 |
break;
|
171 |
case '3':
|
172 |
$return->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
173 |
$return->setIsCustomerNotified(true);
|
174 |
+
$return->setMessage(
|
175 |
+
'Paga: a transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação
|
176 |
+
da instituição financeira responsável pelo processamento.'
|
177 |
+
);
|
178 |
$return->setIsTransactionPending(false);
|
179 |
break;
|
180 |
case '4':
|
181 |
+
$return->setMessage(
|
182 |
+
'Disponível: a transação foi paga e chegou ao final de seu prazo de liberação sem
|
183 |
+
ter sido retornada e sem que haja nenhuma disputa aberta.'
|
184 |
+
);
|
185 |
$return->setIsCustomerNotified(false);
|
186 |
$return->setStateChanged(false);
|
187 |
$return->setIsTransactionPending(false);
|
190 |
$return->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
191 |
$return->setIsCustomerNotified(false);
|
192 |
$return->setIsTransactionPending(false);
|
193 |
+
$return->setMessage(
|
194 |
+
'Em disputa: o comprador, dentro do prazo de liberação da transação,
|
195 |
+
abriu uma disputa.'
|
196 |
+
);
|
197 |
break;
|
198 |
case '6':
|
199 |
$return->setState(Mage_Sales_Model_Order::STATE_CLOSED);
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
+
* Call PagSeguro API to place an order (/transactions)
|
219 |
* @param $params
|
220 |
* @param $payment
|
221 |
*
|
224 |
public function callApi($params, $payment)
|
225 |
{
|
226 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
227 |
+
$useApp = $helper->getLicenseType() == 'app';
|
228 |
+
if ($useApp) {
|
229 |
$params['public_key'] = Mage::getStoreConfig('payment/pagseguropro/key');
|
230 |
}
|
231 |
+
$params = $this->_convertEncoding($params);
|
232 |
+
$paramsString = $this->_convertToCURLString($params);
|
233 |
|
234 |
+
$helper->writeLog('Parametros sendo enviados para API (/transactions): '. var_export($params, true));
|
235 |
|
236 |
$ch = curl_init();
|
237 |
+
curl_setopt($ch, CURLOPT_URL, $helper->getWsUrl('transactions', $useApp));
|
238 |
+
curl_setopt($ch, CURLOPT_POST, count($params));
|
239 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
240 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $paramsString);
|
241 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 45);
|
242 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
243 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
244 |
|
245 |
try{
|
246 |
$response = curl_exec($ch);
|
248 |
Mage::throwException('Falha na comunicação com Pagseguro (' . $e->getMessage() . ')');
|
249 |
}
|
250 |
|
251 |
+
if (curl_error($ch)) {
|
252 |
+
Mage::throwException(
|
253 |
+
sprintf('Falha ao tentar enviar parametros ao PagSeguro: %s (%s)', curl_error($ch), curl_errno($ch))
|
254 |
+
);
|
255 |
}
|
256 |
curl_close($ch);
|
257 |
|
258 |
+
$helper->writeLog('Retorno PagSeguro (/transactions): ' . var_export($response, true));
|
259 |
|
260 |
libxml_use_internal_errors(true);
|
261 |
$xml = simplexml_load_string(trim($response));
|
262 |
+
if (false === $xml) {
|
263 |
switch($response){
|
264 |
case 'Unauthorized':
|
265 |
+
$helper->writeLog(
|
266 |
+
'Token/email não autorizado pelo PagSeguro. Verifique suas configurações no painel.'
|
267 |
+
);
|
268 |
break;
|
269 |
case 'Forbidden':
|
270 |
+
$helper->writeLog(
|
271 |
+
'Acesso não autorizado à Api Pagseguro. Verifique se você tem permissão para
|
272 |
+
usar este serviço. Retorno: ' . var_export($response, true)
|
273 |
+
);
|
274 |
break;
|
275 |
default:
|
276 |
$helper->writeLog('Retorno inesperado do PagSeguro. Retorno: ' . $response);
|
277 |
}
|
278 |
+
Mage::throwException(
|
279 |
+
'Houve uma falha ao processar seu pedido/pagamento. Por favor entre em contato conosco.'
|
280 |
+
);
|
281 |
}
|
282 |
|
283 |
return $xml;
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
+
* Convert array values to utf-8
|
288 |
* @param array $params
|
289 |
*
|
290 |
* @return array
|
291 |
*/
|
292 |
+
protected function _convertEncoding(array $params)
|
293 |
{
|
294 |
+
foreach ($params as $k => $v) {
|
|
|
295 |
$params[$k] = utf8_decode($v);
|
296 |
}
|
297 |
return $params;
|
298 |
}
|
299 |
|
300 |
/**
|
301 |
+
* Convert API params (already ISO-8859-1) to url format (curl string)
|
302 |
* @param array $params
|
303 |
*
|
304 |
* @return string
|
305 |
*/
|
306 |
protected function _convertToCURLString(array $params)
|
307 |
{
|
308 |
+
$fieldsString = '';
|
309 |
+
foreach ($params as $k => $v) {
|
310 |
+
$fieldsString .= $k.'='.urlencode($v).'&';
|
|
|
311 |
}
|
312 |
|
313 |
+
return rtrim($fieldsString, '&');
|
314 |
}
|
315 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php
CHANGED
@@ -1,4 +1,14 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro_Model_Abstract
|
3 |
{
|
4 |
protected $_code = 'pagseguro_cc';
|
@@ -14,57 +24,77 @@ class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro
|
|
14 |
protected $_canUseForMultishipping = true;
|
15 |
protected $_canSaveCc = false;
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
public function isAvailable($quote = null)
|
18 |
{
|
19 |
-
$
|
20 |
-
if (empty($quote)){
|
21 |
-
return $
|
22 |
}
|
23 |
if (Mage::getStoreConfigFlag("payment/pagseguro_cc/group_restriction") == false) {
|
24 |
-
return $
|
25 |
}
|
26 |
|
27 |
-
$
|
28 |
-
$
|
29 |
|
30 |
-
if($
|
31 |
return true;
|
32 |
}
|
33 |
|
34 |
return false;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
public function assignData($data)
|
38 |
{
|
39 |
-
if(!($data instanceof Varien_Object)){
|
40 |
$data = new Varien_Object($data);
|
41 |
}
|
42 |
|
43 |
$info = $this->getInfoInstance();
|
44 |
-
$info->setAdditionalInformation('sender_hash'
|
45 |
-
->setAdditionalInformation('credit_card_token'
|
46 |
->setAdditionalInformation('credit_card_owner', $data->getPsCcOwner())
|
47 |
->setCcType($data->getPsCardType())
|
48 |
->setCcLast4(substr($data->getPsCcNumber(), -4));
|
49 |
|
50 |
//cpf
|
51 |
-
if(Mage::helper('ricardomartins_pagseguro')->isCpfVisible()) {
|
52 |
$info->setAdditionalInformation($this->getCode() . '_cpf', $data->getData($this->getCode() . '_cpf'));
|
53 |
}
|
54 |
|
55 |
-
//
|
56 |
-
$
|
57 |
-
if(empty($
|
58 |
-
$info->setAdditionalInformation(
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
-
//
|
64 |
-
if($data->getPsCcInstallments())
|
65 |
-
{
|
66 |
$installments = explode('|', $data->getPsCcInstallments());
|
67 |
-
if(false !== $installments && count($installments)==2){
|
68 |
$info->setAdditionalInformation('installment_quantity', (int)$installments[0]);
|
69 |
$info->setAdditionalInformation('installment_value', $installments[1]);
|
70 |
}
|
@@ -73,51 +103,69 @@ class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro
|
|
73 |
return $this;
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
76 |
public function validate()
|
77 |
{
|
78 |
parent::validate();
|
79 |
$info = $this->getInfoInstance();
|
80 |
|
81 |
-
$
|
82 |
-
$
|
83 |
-
|
84 |
-
if(empty($
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
return $this;
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
public function order(Varien_Object $payment, $amount)
|
93 |
{
|
94 |
$order = $payment->getOrder();
|
95 |
|
96 |
-
//
|
97 |
$params = Mage::helper('ricardomartins_pagseguro/internal')->getCreditCardApiCallParams($order, $payment);
|
98 |
|
99 |
-
//
|
100 |
-
$
|
101 |
-
$this->proccessNotificatonResult($
|
102 |
|
103 |
-
if(isset($
|
104 |
$errMsg = array();
|
105 |
-
foreach($
|
106 |
$errMsg[] = (string)$error->message . '(' . $error->code . ')';
|
107 |
}
|
108 |
-
Mage::throwException('Um ou mais erros ocorreram no seu pagamento.' . PHP_EOL . implode(PHP_EOL
|
109 |
}
|
110 |
|
111 |
$payment->setSkipOrderProcessing(true);
|
112 |
|
113 |
-
if(isset($
|
114 |
|
115 |
-
$additional = array('transaction_id'=>(string)$
|
116 |
-
if($existing = $payment->getAdditionalInformation())
|
117 |
-
|
118 |
-
|
119 |
-
{
|
120 |
-
$additional = array_merge($additional,$existing);
|
121 |
}
|
122 |
}
|
123 |
$payment->setAdditionalInformation($additional);
|
@@ -125,6 +173,12 @@ class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro
|
|
125 |
return $this;
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
public function _getStoreConfig($field)
|
129 |
{
|
130 |
return Mage::getStoreConfig("payment/pagseguro_cc/{$field}");
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Model CC Class - responsible for credit card payment processing
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro_Model_Abstract
|
13 |
{
|
14 |
protected $_code = 'pagseguro_cc';
|
24 |
protected $_canUseForMultishipping = true;
|
25 |
protected $_canSaveCc = false;
|
26 |
|
27 |
+
/**
|
28 |
+
* Check if module is available for current quote and customer group (if restriction is activated)
|
29 |
+
* @param Mage_Sales_Model_Quote $quote
|
30 |
+
*
|
31 |
+
* @return bool
|
32 |
+
*/
|
33 |
public function isAvailable($quote = null)
|
34 |
{
|
35 |
+
$isAvailable = parent::isAvailable($quote);
|
36 |
+
if (empty($quote)) {
|
37 |
+
return $isAvailable;
|
38 |
}
|
39 |
if (Mage::getStoreConfigFlag("payment/pagseguro_cc/group_restriction") == false) {
|
40 |
+
return $isAvailable;
|
41 |
}
|
42 |
|
43 |
+
$currentGroupId = $quote->getCustomerGroupId();
|
44 |
+
$customerGroups = explode(',', $this->_getStoreConfig('customer_groups'));
|
45 |
|
46 |
+
if ($isAvailable && in_array($currentGroupId, $customerGroups)) {
|
47 |
return true;
|
48 |
}
|
49 |
|
50 |
return false;
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* Assign data to info model instance
|
55 |
+
*
|
56 |
+
* @param mixed $data
|
57 |
+
* @return Mage_Payment_Model_Info
|
58 |
+
*/
|
59 |
public function assignData($data)
|
60 |
{
|
61 |
+
if (!($data instanceof Varien_Object)) {
|
62 |
$data = new Varien_Object($data);
|
63 |
}
|
64 |
|
65 |
$info = $this->getInfoInstance();
|
66 |
+
$info->setAdditionalInformation('sender_hash', $data->getSenderHash())
|
67 |
+
->setAdditionalInformation('credit_card_token', $data->getCreditCardToken())
|
68 |
->setAdditionalInformation('credit_card_owner', $data->getPsCcOwner())
|
69 |
->setCcType($data->getPsCardType())
|
70 |
->setCcLast4(substr($data->getPsCcNumber(), -4));
|
71 |
|
72 |
//cpf
|
73 |
+
if (Mage::helper('ricardomartins_pagseguro')->isCpfVisible()) {
|
74 |
$info->setAdditionalInformation($this->getCode() . '_cpf', $data->getData($this->getCode() . '_cpf'));
|
75 |
}
|
76 |
|
77 |
+
//DOB
|
78 |
+
$ownerDobAttribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
|
79 |
+
if (empty($ownerDobAttribute)) {
|
80 |
+
$info->setAdditionalInformation(
|
81 |
+
'credit_card_owner_birthdate',
|
82 |
+
date(
|
83 |
+
'd/m/Y',
|
84 |
+
strtotime(
|
85 |
+
$data->getPsCcOwnerBirthdayYear().
|
86 |
+
'/'.
|
87 |
+
$data->getPsCcOwnerBirthdayMonth().
|
88 |
+
'/'.$data->getPsCcOwnerBirthdayDay()
|
89 |
+
)
|
90 |
+
)
|
91 |
+
);
|
92 |
}
|
93 |
|
94 |
+
//Installments
|
95 |
+
if ($data->getPsCcInstallments()) {
|
|
|
96 |
$installments = explode('|', $data->getPsCcInstallments());
|
97 |
+
if (false !== $installments && count($installments)==2) {
|
98 |
$info->setAdditionalInformation('installment_quantity', (int)$installments[0]);
|
99 |
$info->setAdditionalInformation('installment_value', $installments[1]);
|
100 |
}
|
103 |
return $this;
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
+
* Validate payment method information object
|
108 |
+
*
|
109 |
+
* @return Mage_Payment_Model_Abstract
|
110 |
+
*/
|
111 |
public function validate()
|
112 |
{
|
113 |
parent::validate();
|
114 |
$info = $this->getInfoInstance();
|
115 |
|
116 |
+
$senderHash = $info->getAdditionalInformation('sender_hash');
|
117 |
+
$creditCardToken = $info->getAdditionalInformation('credit_card_token');
|
118 |
+
|
119 |
+
if (empty($creditCardToken) || empty($senderHash)) {
|
120 |
+
Mage::helper('ricardomartins_pagseguro')
|
121 |
+
->writeLog(
|
122 |
+
'Falha ao obter o token do cartao ou sender_hash.
|
123 |
+
Veja se os dados "sender_hash" e "credit_card_token" foram enviados no formulário.
|
124 |
+
Um problema de JavaScript pode ter ocorrido.
|
125 |
+
Se esta for apenas uma atualização de blocos via ajax nao se preocupe.'
|
126 |
+
);
|
127 |
+
Mage::throwException(
|
128 |
+
'Falha ao processar pagamento junto ao PagSeguro. Por favor, entre em contato com nossa equipe.'
|
129 |
+
);
|
130 |
}
|
131 |
return $this;
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
+
* Order payment
|
136 |
+
*
|
137 |
+
* @param Varien_Object $payment
|
138 |
+
* @param float $amount
|
139 |
+
*
|
140 |
+
* @return RicardoMartins_PagSeguro_Model_Payment_Cc
|
141 |
+
*/
|
142 |
public function order(Varien_Object $payment, $amount)
|
143 |
{
|
144 |
$order = $payment->getOrder();
|
145 |
|
146 |
+
//will grab data to be send via POST to API inside $params
|
147 |
$params = Mage::helper('ricardomartins_pagseguro/internal')->getCreditCardApiCallParams($order, $payment);
|
148 |
|
149 |
+
//call API
|
150 |
+
$returnXml = $this->callApi($params, $payment);
|
151 |
+
$this->proccessNotificatonResult($returnXml);
|
152 |
|
153 |
+
if (isset($returnXml->errors)) {
|
154 |
$errMsg = array();
|
155 |
+
foreach ($returnXml->errors as $error) {
|
156 |
$errMsg[] = (string)$error->message . '(' . $error->code . ')';
|
157 |
}
|
158 |
+
Mage::throwException('Um ou mais erros ocorreram no seu pagamento.' . PHP_EOL . implode(PHP_EOL, $errMsg));
|
159 |
}
|
160 |
|
161 |
$payment->setSkipOrderProcessing(true);
|
162 |
|
163 |
+
if (isset($returnXml->code)) {
|
164 |
|
165 |
+
$additional = array('transaction_id'=>(string)$returnXml->code);
|
166 |
+
if ($existing = $payment->getAdditionalInformation()) {
|
167 |
+
if (is_array($existing)) {
|
168 |
+
$additional = array_merge($additional, $existing);
|
|
|
|
|
169 |
}
|
170 |
}
|
171 |
$payment->setAdditionalInformation($additional);
|
173 |
return $this;
|
174 |
}
|
175 |
|
176 |
+
/**
|
177 |
+
* Generically get module's config field value
|
178 |
+
* @param $field
|
179 |
+
*
|
180 |
+
* @return mixed
|
181 |
+
*/
|
182 |
public function _getStoreConfig($field)
|
183 |
{
|
184 |
return Mage::getStoreConfig("payment/pagseguro_cc/{$field}");
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Address/Attributes.php
CHANGED
@@ -1,31 +1,39 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Address_Attributes
|
9 |
{
|
10 |
/**
|
11 |
-
*
|
12 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
13 |
* @return array
|
14 |
*/
|
15 |
-
public function toOptionArray()
|
|
|
16 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer_address');
|
17 |
$options = array();
|
18 |
|
19 |
-
foreach($fields as $key => $value) {
|
20 |
-
if(!is_null($value['frontend_label'])) {
|
21 |
-
//
|
22 |
-
if($value['attribute_code'] == 'street') {
|
23 |
-
$
|
24 |
-
for($i = 1; $i <= $
|
25 |
$options[] = array('value' => 'street_'.$i, 'label' => 'Street Line '.$i);
|
26 |
}
|
27 |
} else {
|
28 |
-
$options[] = array(
|
|
|
|
|
|
|
29 |
}
|
30 |
}
|
31 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Address Attribute model - for configuration purposes
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Address_Attributes
|
13 |
{
|
14 |
/**
|
15 |
+
* Return Address attribute
|
16 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
17 |
* @return array
|
18 |
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer_address');
|
22 |
$options = array();
|
23 |
|
24 |
+
foreach ($fields as $key => $value) {
|
25 |
+
if (!is_null($value['frontend_label'])) {
|
26 |
+
//in multiline cases, it allows to specify what each line means (i.e.: street, number)
|
27 |
+
if ($value['attribute_code'] == 'street') {
|
28 |
+
$streetLines = Mage::getStoreConfig('customer/address/street_lines');
|
29 |
+
for ($i = 1; $i <= $streetLines; $i++) {
|
30 |
$options[] = array('value' => 'street_'.$i, 'label' => 'Street Line '.$i);
|
31 |
}
|
32 |
} else {
|
33 |
+
$options[] = array(
|
34 |
+
'value' => $value['attribute_code'],
|
35 |
+
'label' => $value['frontend_label'] . ' (' . $value['attribute_code'] . ')'
|
36 |
+
);
|
37 |
}
|
38 |
}
|
39 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Address/Attributes/Optional.php
CHANGED
@@ -1,32 +1,40 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Address_Attributes_Optional
|
9 |
{
|
10 |
/**
|
11 |
-
*
|
12 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
13 |
* @return array
|
14 |
*/
|
15 |
-
public function toOptionArray()
|
|
|
16 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer_address');
|
17 |
$options = array();
|
18 |
$options[] = array('value'=>'','label'=>'Não Informar ao PagSeguro');
|
19 |
|
20 |
-
foreach($fields as $key => $value) {
|
21 |
-
if(!is_null($value['frontend_label'])) {
|
22 |
//caso esteja sendo usado a propriedade multilinha do endereco, ele aceita indicar o que cada linha faz
|
23 |
-
if($value['attribute_code'] == 'street') {
|
24 |
-
$
|
25 |
-
for($i = 1; $i <= $
|
26 |
$options[] = array('value' => 'street_'.$i, 'label' => 'Street Line '.$i);
|
27 |
}
|
28 |
} else {
|
29 |
-
$options[] = array(
|
|
|
|
|
|
|
30 |
}
|
31 |
}
|
32 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Optional Address Attribute model - for configuration purposes
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Address_Attributes_Optional
|
13 |
{
|
14 |
/**
|
15 |
+
* Return Address attribute
|
16 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
17 |
* @return array
|
18 |
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer_address');
|
22 |
$options = array();
|
23 |
$options[] = array('value'=>'','label'=>'Não Informar ao PagSeguro');
|
24 |
|
25 |
+
foreach ($fields as $key => $value) {
|
26 |
+
if (!is_null($value['frontend_label'])) {
|
27 |
//caso esteja sendo usado a propriedade multilinha do endereco, ele aceita indicar o que cada linha faz
|
28 |
+
if ($value['attribute_code'] == 'street') {
|
29 |
+
$streetLines = Mage::getStoreConfig('customer/address/street_lines');
|
30 |
+
for ($i = 1; $i <= $streetLines; $i++) {
|
31 |
$options[] = array('value' => 'street_'.$i, 'label' => 'Street Line '.$i);
|
32 |
}
|
33 |
} else {
|
34 |
+
$options[] = array(
|
35 |
+
'value' => $value['attribute_code'],
|
36 |
+
'label' => $value['frontend_label']. ' (' . $value['attribute_code'] . ')'
|
37 |
+
);
|
38 |
}
|
39 |
}
|
40 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Attributes.php
CHANGED
@@ -1,19 +1,30 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Attributes
|
9 |
{
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
12 |
$options = array();
|
13 |
|
14 |
-
foreach($fields as $key => $value) {
|
15 |
-
if(!is_null($value['frontend_label'])) {
|
16 |
-
$options[$value['frontend_label']] = array(
|
|
|
|
|
|
|
17 |
}
|
18 |
}
|
19 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Customer Attributes source, used for config
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Attributes
|
13 |
{
|
14 |
+
/**
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
public function toOptionArray()
|
18 |
+
{
|
19 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
20 |
$options = array();
|
21 |
|
22 |
+
foreach ($fields as $key => $value) {
|
23 |
+
if (!is_null($value['frontend_label'])) {
|
24 |
+
$options[$value['frontend_label']] = array(
|
25 |
+
'value' => $value['attribute_code'],
|
26 |
+
'label' => $value['frontend_label'] . ' (' . $value['attribute_code'] . ')'
|
27 |
+
);
|
28 |
}
|
29 |
}
|
30 |
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Cpf.php
CHANGED
@@ -1,27 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Cpf
|
9 |
{
|
10 |
-
public function toOptionArray()
|
|
|
11 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
12 |
$options = array();
|
13 |
$options[] = array('value'=>'','label'=>'Solicitar junto com os outros dados do pagamento');
|
14 |
|
15 |
-
foreach($fields as $key => $value) {
|
16 |
-
if(!is_null($value['frontend_label'])) {
|
17 |
-
$options['customer|'.$value['frontend_label']] = array(
|
|
|
|
|
|
|
18 |
}
|
19 |
}
|
20 |
|
21 |
-
$
|
22 |
-
foreach($
|
23 |
-
if(!is_null($value['frontend_label'])) {
|
24 |
-
$options['address|'.$value['frontend_label']] = array(
|
|
|
|
|
|
|
25 |
}
|
26 |
}
|
27 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Customer CPF possible fields mapping
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Cpf
|
13 |
{
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
17 |
$options = array();
|
18 |
$options[] = array('value'=>'','label'=>'Solicitar junto com os outros dados do pagamento');
|
19 |
|
20 |
+
foreach ($fields as $key => $value) {
|
21 |
+
if (!is_null($value['frontend_label'])) {
|
22 |
+
$options['customer|'.$value['frontend_label']] = array(
|
23 |
+
'value' => 'customer|'.$value['attribute_code'],
|
24 |
+
'label' => 'Customer: '.$value['frontend_label'] . ' (' . $value['attribute_code'] . ')'
|
25 |
+
);
|
26 |
}
|
27 |
}
|
28 |
|
29 |
+
$addressFields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer_address');
|
30 |
+
foreach ($addressFields as $key => $value) {
|
31 |
+
if (!is_null($value['frontend_label'])) {
|
32 |
+
$options['address|'.$value['frontend_label']] = array(
|
33 |
+
'value' => 'billing|'.$value['attribute_code'],
|
34 |
+
'label' => 'Billing: '.$value['frontend_label'] . ' (' . $value['attribute_code'] . ')'
|
35 |
+
);
|
36 |
}
|
37 |
}
|
38 |
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Customer/Dob.php
CHANGED
@@ -1,25 +1,33 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
-
* @
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Dob
|
9 |
{
|
10 |
/**
|
11 |
-
*
|
12 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
13 |
* @return array
|
14 |
*/
|
15 |
-
public function toOptionArray()
|
|
|
16 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
17 |
$options = array();
|
18 |
$options[] = array('value'=>'','label'=>'Solicitar ao cliente junto com dados do cartão');
|
19 |
|
20 |
-
foreach($fields as $key => $value) {
|
21 |
-
if(!is_null($value['frontend_label'])) {
|
22 |
-
$options[] = array(
|
|
|
|
|
|
|
23 |
}
|
24 |
}
|
25 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Customer DOB Class - for configuration purposes
|
5 |
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
*/
|
12 |
class RicardoMartins_PagSeguro_Model_Source_Customer_Dob
|
13 |
{
|
14 |
/**
|
15 |
+
* Returns address attributes
|
16 |
* @author Gabriela D'Ávila (http://davila.blog.br)
|
17 |
* @return array
|
18 |
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
$fields = Mage::helper('ricardomartins_pagseguro/internal')->getFields('customer');
|
22 |
$options = array();
|
23 |
$options[] = array('value'=>'','label'=>'Solicitar ao cliente junto com dados do cartão');
|
24 |
|
25 |
+
foreach ($fields as $key => $value) {
|
26 |
+
if (!is_null($value['frontend_label'])) {
|
27 |
+
$options[] = array(
|
28 |
+
'value' => $value['attribute_code'],
|
29 |
+
'label' => $value['frontend_label'] . ' (' . $value['attribute_code'] . ')'
|
30 |
+
);
|
31 |
}
|
32 |
}
|
33 |
|
app/code/community/RicardoMartins/PagSeguro/Model/Source/Paymentmethods.php
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
class RicardoMartins_PagSeguro_Model_Source_Paymentmethods
|
8 |
{
|
|
|
|
|
|
|
9 |
public function toOptionArray()
|
10 |
{
|
11 |
$options = array();
|
1 |
<?php
|
2 |
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
*
|
5 |
+
* @category RicardoMartins
|
6 |
+
* @package RicardoMartins_PagSeguro
|
7 |
+
* @author Ricardo Martins
|
8 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
9 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
10 |
*/
|
11 |
class RicardoMartins_PagSeguro_Model_Source_Paymentmethods
|
12 |
{
|
13 |
+
/**
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
public function toOptionArray()
|
17 |
{
|
18 |
$options = array();
|
app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Backend/Token.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Token Backend model - used for token validation on saving or changing
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
+
class RicardoMartins_PagSeguro_Model_System_Config_Backend_Token
|
13 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Decrypt and test current saved token
|
17 |
+
*/
|
18 |
+
public function _afterSave()
|
19 |
+
{
|
20 |
+
$token = Mage::helper('core')->decrypt($this->getValue());
|
21 |
+
if (!empty($token) && $token != $this->getOldValue()) {
|
22 |
+
$valid = $this->testToken($this->getFieldsetDataValue('merchant_email'), $token);
|
23 |
+
if ($valid !== true) {
|
24 |
+
Mage::getSingleton('core/session')->addWarning($valid);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
parent::_afterSave();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Test token by calling PagSeguro session API
|
33 |
+
* @param $email
|
34 |
+
* @param $token
|
35 |
+
*
|
36 |
+
* @return bool|string
|
37 |
+
*/
|
38 |
+
protected function testToken($email, $token)
|
39 |
+
{
|
40 |
+
$helper = Mage::helper('ricardomartins_pagseguro');
|
41 |
+
$url = $helper->getWsUrl('sessions/');
|
42 |
+
$ch = curl_init();
|
43 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
44 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
45 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
46 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
47 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf('email=%s&token=%s', $email, $token));
|
48 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
49 |
+
$ret = curl_exec($ch);
|
50 |
+
curl_close($ch);
|
51 |
+
libxml_use_internal_errors(true);
|
52 |
+
if ($ret == 'Forbidden' && $helper->getLicenseType() == '') {
|
53 |
+
return 'PagSeguro: Token de produção não habilitado para utilizar checkout transparente.
|
54 |
+
Você pode <a href="https://pagseguro.uol.com.br/receba-pagamentos.jhtml#checkout-transparent"
|
55 |
+
target="_blank">solicitar a liberação junto ao PagSeguro</a> ou instalar a
|
56 |
+
<a href="http://r-martins.github.io/PagSeguro-Magento-Transparente/pro/app.html"
|
57 |
+
target="_blank">versão PRO APP</a> que não requer autorização.';
|
58 |
+
}
|
59 |
+
|
60 |
+
$valid = simplexml_load_string($ret) !== false;
|
61 |
+
if (!$valid) {
|
62 |
+
return 'PagSeguro: Token de Produção inválido. Se necessário, utilize
|
63 |
+
<a href="http://r-martins.github.io/PagSeguro-Magento-Transparente/#faq" target="_blank">
|
64 |
+
esta ferramenta</a> para validar.';
|
65 |
+
}
|
66 |
+
|
67 |
+
return true;
|
68 |
+
}
|
69 |
+
}
|
app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Source/Customer/Groups.php
CHANGED
@@ -1,7 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class RicardoMartins_PagSeguro_Model_System_Config_Source_Customer_Groups
|
4 |
{
|
|
|
|
|
|
|
5 |
public function toOptionArray ()
|
6 |
{
|
7 |
return Mage::getModel('customer/group')->getCollection()
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Customer groups - for config purposes
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_Model_System_Config_Source_Customer_Groups
|
13 |
{
|
14 |
+
/**
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
public function toOptionArray ()
|
18 |
{
|
19 |
return Mage::getModel('customer/group')->getCollection()
|
app/code/community/RicardoMartins/PagSeguro/controllers/AjaxController.php
CHANGED
@@ -1,23 +1,38 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_AjaxController extends Mage_Core_Controller_Front_Action
|
3 |
{
|
|
|
4 |
/**
|
5 |
-
*
|
6 |
*/
|
7 |
public function getGrandTotalAction()
|
8 |
{
|
9 |
$total = Mage::helper('checkout/cart')->getQuote()->getGrandTotal();
|
10 |
|
11 |
-
$this->getResponse()->setHeader('Content-type','application/json', true);
|
12 |
$this->getResponse()->setBody(json_encode(array('total'=>$total)));
|
13 |
}
|
14 |
|
|
|
|
|
|
|
|
|
15 |
public function getSessionIdAction()
|
16 |
{
|
17 |
$_helper = Mage::helper('ricardomartins_pagseguro');
|
18 |
-
$
|
19 |
|
20 |
-
$this->getResponse()->setHeader('Content-type','application/json', true);
|
21 |
-
$this->getResponse()->setBody(json_encode(array('session_id'
|
22 |
}
|
23 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Ajax Controller responsible for module's ajax requests
|
5 |
+
*
|
6 |
+
* @category RicardoMartins
|
7 |
+
* @package RicardoMartins_PagSeguro
|
8 |
+
* @author Ricardo Martins
|
9 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
10 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
11 |
+
*/
|
12 |
class RicardoMartins_PagSeguro_AjaxController extends Mage_Core_Controller_Front_Action
|
13 |
{
|
14 |
+
|
15 |
/**
|
16 |
+
* Returns the order grand total, used to get installments of CC method
|
17 |
*/
|
18 |
public function getGrandTotalAction()
|
19 |
{
|
20 |
$total = Mage::helper('checkout/cart')->getQuote()->getGrandTotal();
|
21 |
|
22 |
+
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
23 |
$this->getResponse()->setBody(json_encode(array('total'=>$total)));
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
+
* Return session Id from PagSeguro, based on merchant e-mail and token
|
28 |
+
* Double check your e-mail and token at http://r-martins.github.io/PagSeguro-Magento-Transparente/#faq
|
29 |
+
*/
|
30 |
public function getSessionIdAction()
|
31 |
{
|
32 |
$_helper = Mage::helper('ricardomartins_pagseguro');
|
33 |
+
$sessionId = $_helper->getSessionId();
|
34 |
|
35 |
+
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
36 |
+
$this->getResponse()->setBody(json_encode(array('session_id' => $sessionId)));
|
37 |
}
|
38 |
}
|
app/code/community/RicardoMartins/PagSeguro/controllers/NotificationController.php
CHANGED
@@ -1,18 +1,33 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_NotificationController extends Mage_Core_Controller_Front_Action
|
3 |
{
|
4 |
/**
|
5 |
-
*
|
6 |
-
*
|
7 |
*/
|
8 |
public function indexAction()
|
9 |
{
|
10 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
11 |
-
if($helper->isSandbox()){
|
12 |
-
$this->getResponse()->setHeader('access-control-allow-origin','https://sandbox.pagseguro.uol.com.br');
|
13 |
}
|
14 |
/** @var RicardoMartins_PagSeguro_Model_Abstract $model */
|
15 |
-
Mage::helper('ricardomartins_pagseguro')
|
|
|
|
|
|
|
|
|
16 |
$model = Mage::getModel('ricardomartins_pagseguro/abstract');
|
17 |
$response = $model->getNotificationStatus($this->getRequest()->getPost('notificationCode'));
|
18 |
$model->proccessNotificatonResult($response);
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Notification Controller responsible for receive order update notifications from PagSeguro
|
5 |
+
* See how to setup notification url on module's official website
|
6 |
+
*
|
7 |
+
* @category RicardoMartins
|
8 |
+
* @package RicardoMartins_PagSeguro
|
9 |
+
* @author Ricardo Martins
|
10 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
11 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
12 |
+
*/
|
13 |
class RicardoMartins_PagSeguro_NotificationController extends Mage_Core_Controller_Front_Action
|
14 |
{
|
15 |
/**
|
16 |
+
* Receive and process pagseguro notifications.
|
17 |
+
* Don' forget to setup your notification url as http://yourstore.com/index.php/pagseguro/notification
|
18 |
*/
|
19 |
public function indexAction()
|
20 |
{
|
21 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
22 |
+
if ($helper->isSandbox()) {
|
23 |
+
$this->getResponse()->setHeader('access-control-allow-origin', 'https://sandbox.pagseguro.uol.com.br');
|
24 |
}
|
25 |
/** @var RicardoMartins_PagSeguro_Model_Abstract $model */
|
26 |
+
Mage::helper('ricardomartins_pagseguro')
|
27 |
+
->writeLog(
|
28 |
+
'Notificação recebida do pagseguro com os parâmetros:'
|
29 |
+
. var_export($this->getRequest()->getParams(), true)
|
30 |
+
);
|
31 |
$model = Mage::getModel('ricardomartins_pagseguro/abstract');
|
32 |
$response = $model->getNotificationStatus($this->getRequest()->getPost('notificationCode'));
|
33 |
$model->proccessNotificatonResult($response);
|
app/code/community/RicardoMartins/PagSeguro/controllers/TestController.php
CHANGED
@@ -1,26 +1,48 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class RicardoMartins_PagSeguro_TestController extends Mage_Core_Controller_Front_Action
|
3 |
{
|
4 |
-
public function indexAction(){
|
5 |
-
$this->getResponse()->setBody('works');
|
6 |
-
}
|
7 |
-
|
8 |
/**
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* Pode ser removido se assim preferir.
|
12 |
*/
|
13 |
-
public function getConfigAction()
|
|
|
14 |
$info = array();
|
15 |
-
$info['RicardoMartins_PagSeguro']['version'] = (string)Mage::getConfig()
|
|
|
16 |
$info['RicardoMartins_PagSeguro']['debug'] = Mage::getStoreConfigFlag('payment/pagseguro/debug');
|
17 |
$info['RicardoMartins_PagSeguro']['sandbox'] = Mage::getStoreConfigFlag('payment/pagseguro/sandbox');
|
18 |
|
19 |
-
if(Mage::getConfig()->getModuleConfig('RicardoMartins_PagSeguroPro')){
|
20 |
-
$info['RicardoMartins_PagSeguroPro']['version'] = (string)Mage::getConfig()
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
-
|
|
|
24 |
$this->getResponse()->setBody(json_encode($info));
|
25 |
}
|
26 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* PagSeguro Transparente Magento
|
4 |
+
* Test Controller responsible for diagnostics, usually when you ask for support
|
5 |
+
* It helps our team to detect misconfiguration and other problems when you ask for help
|
6 |
+
*
|
7 |
+
* @category RicardoMartins
|
8 |
+
* @package RicardoMartins_PagSeguro
|
9 |
+
* @author Ricardo Martins
|
10 |
+
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/)
|
11 |
+
* @license https://opensource.org/licenses/MIT MIT License
|
12 |
+
*/
|
13 |
class RicardoMartins_PagSeguro_TestController extends Mage_Core_Controller_Front_Action
|
14 |
{
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
+
* Bring us some information about the module configuration and version info.
|
17 |
+
* You can remove it, but can make our team to misjudge your configuration or problem.
|
|
|
18 |
*/
|
19 |
+
public function getConfigAction()
|
20 |
+
{
|
21 |
$info = array();
|
22 |
+
$info['RicardoMartins_PagSeguro']['version'] = (string)Mage::getConfig()
|
23 |
+
->getModuleConfig('RicardoMartins_PagSeguro')->version;
|
24 |
$info['RicardoMartins_PagSeguro']['debug'] = Mage::getStoreConfigFlag('payment/pagseguro/debug');
|
25 |
$info['RicardoMartins_PagSeguro']['sandbox'] = Mage::getStoreConfigFlag('payment/pagseguro/sandbox');
|
26 |
|
27 |
+
if (Mage::getConfig()->getModuleConfig('RicardoMartins_PagSeguroPro')) {
|
28 |
+
$info['RicardoMartins_PagSeguroPro']['version'] = (string)Mage::getConfig()
|
29 |
+
->getModuleConfig('RicardoMartins_PagSeguroPro')->version;
|
30 |
+
$info['RicardoMartins_PagSeguroPro']['key_type'] =
|
31 |
+
(string)Mage::getStoreConfig('payment/pagseguropro/key_type');
|
32 |
+
}
|
33 |
+
|
34 |
+
$helper = Mage::helper('ricardomartins_pagseguro');
|
35 |
+
$info['session_id'] = $helper->getSessionId();
|
36 |
+
|
37 |
+
$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
|
38 |
+
$coreHelper = Mage::helper('core');
|
39 |
+
foreach ($modules as $module) {
|
40 |
+
if (false !== strpos(strtolower($module), 'pagseguro') && $coreHelper->isModuleEnabled($module)) {
|
41 |
+
$info['pagseguro_modules'][] = $module;
|
42 |
+
}
|
43 |
}
|
44 |
+
|
45 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
46 |
$this->getResponse()->setBody(json_encode($info));
|
47 |
}
|
48 |
}
|
app/code/community/RicardoMartins/PagSeguro/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<RicardoMartins_PagSeguro>
|
5 |
-
<version>2.
|
6 |
</RicardoMartins_PagSeguro>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<RicardoMartins_PagSeguro>
|
5 |
+
<version>2.2.0</version>
|
6 |
</RicardoMartins_PagSeguro>
|
7 |
</modules>
|
8 |
<global>
|
app/code/community/RicardoMartins/PagSeguro/etc/system.xml
CHANGED
@@ -51,7 +51,8 @@
|
|
51 |
<token translate="label">
|
52 |
<label>Token</label>
|
53 |
<frontend_type>obscure</frontend_type>
|
54 |
-
|
|
|
55 |
<sort_order>20</sort_order>
|
56 |
<show_in_default>1</show_in_default>
|
57 |
<show_in_website>1</show_in_website>
|
51 |
<token translate="label">
|
52 |
<label>Token</label>
|
53 |
<frontend_type>obscure</frontend_type>
|
54 |
+
<!--<backend_model>adminhtml/system_config_backend_encrypted</backend_model>-->
|
55 |
+
<backend_model>ricardomartins_pagseguro/system_config_backend_token</backend_model>
|
56 |
<sort_order>20</sort_order>
|
57 |
<show_in_default>1</show_in_default>
|
58 |
<show_in_website>1</show_in_website>
|
app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
$_code=$this->getMethodCode();
|
3 |
?>
|
4 |
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
@@ -87,3 +88,10 @@ $_code=$this->getMethodCode();
|
|
87 |
<div class="selo-pagseguro"><img src="<?php echo $this->getSkinUrl('pagseguro/selo/selo04_200x60.gif');?>" alt="Pagamento processado pelo PagSeguro"/></div>
|
88 |
</li>
|
89 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
/** @var RicardoMartins_PagSeguro_Block_Form_Cc $this */
|
3 |
$_code=$this->getMethodCode();
|
4 |
?>
|
5 |
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
88 |
<div class="selo-pagseguro"><img src="<?php echo $this->getSkinUrl('pagseguro/selo/selo04_200x60.gif');?>" alt="Pagamento processado pelo PagSeguro"/></div>
|
89 |
</li>
|
90 |
</ul>
|
91 |
+
<script type="text/javascript">
|
92 |
+
//<![CDATA[
|
93 |
+
if ('undefined' !== typeof RMPagSeguro) {
|
94 |
+
RMPagSeguro.getInstallments();
|
95 |
+
}
|
96 |
+
//]]
|
97 |
+
</script>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RicardoMartins_PagSeguro</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT</license>
|
7 |
<channel>community</channel>
|
@@ -13,9 +13,9 @@ Os dados do cartão são enviados para o site do pagseguro de forma segu
|
|
13 |

|
14 |
Os bugs devem ser reportados na área de Issues no github do projeto em https://github.com/r-martins/PagSeguro-Magento-Transparente</notes>
|
15 |
<authors><author><name>Ricardo Martins</name><user>MAG001517858</user><email>ricardo@ricardomartins.info</email></author></authors>
|
16 |
-
<date>2015-
|
17 |
-
<time>
|
18 |
-
<contents><target name="magecommunity"><dir name="RicardoMartins"><dir name="PagSeguro"><dir name="Block"><dir name="Form"><dir name="Cc"><file name="Dob.php" hash="ed45c9f5576c289897eb5c86a46c6d85"/></dir><file name="Cc.php" hash="
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.2.1</min><max>5.6.16</max></php></required></dependencies>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RicardoMartins_PagSeguro</name>
|
4 |
+
<version>2.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT</license>
|
7 |
<channel>community</channel>
|
13 |

|
14 |
Os bugs devem ser reportados na área de Issues no github do projeto em https://github.com/r-martins/PagSeguro-Magento-Transparente</notes>
|
15 |
<authors><author><name>Ricardo Martins</name><user>MAG001517858</user><email>ricardo@ricardomartins.info</email></author></authors>
|
16 |
+
<date>2015-10-01</date>
|
17 |
+
<time>12:45:01</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="RicardoMartins"><dir name="PagSeguro"><dir name="Block"><dir name="Form"><dir name="Cc"><file name="Dob.php" hash="ed45c9f5576c289897eb5c86a46c6d85"/></dir><file name="Cc.php" hash="ca42cfcb32b98712a70da26ba168759d"/><file name="Directpayment.php" hash="98ba4fb562b4ad777dc20b15ca345381"/><dir name="Info"><file name="Cc.php" hash="ef4952bfb9d12dae0b6ce13afeb0d1bb"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f5e774e3c75acceff48e36d23762749a"/><file name="Internal.php" hash="5911252bc71b056c888a61df5f3bf58d"/><file name="Params.php" hash="f9570bc41f36422ad27646107d245597"/></dir><dir name="Model"><file name="Abstract.php" hash="9871f99771c89b5e698f451b77203176"/><file name="Observer.php" hash="29a784cdb6203baf6b5f0abeeeda99ed"/><dir name="Payment"><file name="Cc.php" hash="f74fbd32e01ffb57f9ece18f1a66faf1"/></dir><dir name="Source"><dir name="Customer"><dir name="Address"><dir name="Attributes"><file name="Optional.php" hash="cb7cc6beb016941997051a9d5eb1014c"/></dir><file name="Attributes.php" hash="0ffab3cf1d51871f7d57d95dd95822ec"/></dir><file name="Attributes.php" hash="96c7da94017a8b38bd3804e9b0401a58"/><file name="Cpf.php" hash="da6e6525163d2ba954d69c687d101d7d"/><file name="Dob.php" hash="f82a41da22e5a84e77c35ff91d7dfab9"/></dir><file name="Paymentmethods.php" hash="88897d21a7b5217f834eda0daead22c3"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Token.php" hash="05b6ea4b355cefcbb1a50d66aba637f6"/></dir><dir name="Source"><dir name="Customer"><file name="Groups.php" hash="f08bac32afcde8078a098446db79bc65"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="89b915bbfc061beb7550a56248177c9f"/><file name="NotificationController.php" hash="c4e32484a82f960db314969a2bfccbff"/><file name="TestController.php" hash="0e2c2bd2fc77ced55f880d1860e4318d"/></dir><dir name="etc"><file name="config.xml" hash="9a1615f08fc8769ffe611b5233bb70b4"/><file name="system.xml" hash="c652e549376568bda40e540486fe110b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RicardoMartins_PagSeguro.xml" hash="82d8294eccac1fb4047f27566b0c9f2a"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="RicardoMartins_PagSeguro.csv" hash="84a6cc4fb73769ac822c9e8e22b8cec8"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="pagseguro"><dir><dir name="selo"><file name="selo01_160x90.gif" hash="e6729bb969abb20588f134f7d29ea0ec"/><file name="selo01_200x60.gif" hash="e91ed131018bae7d9abc2cc1a72f539b"/><file name="selo01_300x60.gif" hash="13b07e35250b30a61c86c98815e3310c"/><file name="selo02_160x90.gif" hash="4e65530d2c42bae4e5fab617a4d0afdf"/><file name="selo02_200x60.gif" hash="ba629a85cef8982423c7679a4875283c"/><file name="selo02_300x60.gif" hash="5827aca40455f22caffee1392917f16c"/><file name="selo03_160x90.gif" hash="e3c69ace0991d7841728c6203fc305bf"/><file name="selo03_200x60.gif" hash="63135b65df64a70629748d66f5c0c453"/><file name="selo03_300x60.gif" hash="e88f1529f2d27d4732cd7c374752618e"/><file name="selo04_160x90.gif" hash="8e71cb1942c15427ba96ac21aacdb9d6"/><file name="selo04_200x60.gif" hash="f08b80b40541e35491a8d966cb420c78"/><file name="selo04_300x60.gif" hash="43f9fc4ad730111654777c26059e9fbf"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="ricardomartins_pagseguro"><dir><dir name="form"><dir name="cc"><file name="dob.phtml" hash="0ea9d4ff767a43d1393ddf1e2882a5da"/></dir><file name="cc.phtml" hash="1e5f98f09a867256ddfbd17b22320dcb"/><file name="directpayment.phtml" hash="05b00f5b33e53fd1091b5a84b31d7c85"/><dir name="info"><file name="cc.phtml" hash="0a3aa78e0775cd51bb7a168b813dd466"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="ricardomartins_pagseguro"><dir><dir name="form"><file name="directpayment.phtml" hash="d7f02da712e3bb310a6f785ebc36e3d3"/><dir name="info"><file name="cc.phtml" hash="0a3aa78e0775cd51bb7a168b813dd466"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="pagseguro"><file name="pagseguro.js" hash="db680c06c8b83319c33924739e6b0ad8"/></dir></dir></target></contents>
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.2.1</min><max>5.6.16</max></php></required></dependencies>
|
21 |
</package>
|