RicardoMartins_PagSeguro - Version 2.1.0

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.1.0
Comparing to
See all releases


Code changes from version 2.0.4 to 2.1.0

app/code/community/RicardoMartins/PagSeguro/Block/Form/Cc.php CHANGED
@@ -35,27 +35,18 @@ class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
35
$this->setTemplate('ricardomartins_pagseguro/form/cc.phtml');
36
}
37
38
- protected function _prepareLayout(){
39
- // Mage::app()->getLayout()->getUpdate()->addHandle('pagseguro');
40
//adicionaremos o JS do pagseguro na tela que usará o bloco de cartao logo após o <body>
41
- $scriptblock = Mage::app()->getLayout()->createBlock('core/text', 'js_pagseguro');
42
- $scriptblock->setText(sprintf(
43
- '
44
- <script type="text/javascript">var RMPagSeguroSiteBaseURL = "%s";</script>
45
- <script type="text/javascript" src="%s"></script>
46
- <script type="text/javascript" src="%s"></script>
47
- ',
48
- Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true),
49
- Mage::helper('ricardomartins_pagseguro')->getJsUrl(),
50
- Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'pagseguro/pagseguro.js'
51
- ));
52
$head = Mage::app()->getLayout()->getBlock('after_body_start');
53
54
- // Mage::app()->getLayout()->getBlock('head')->addJs('pagseguro/pagseguro.js');
55
-
56
- if($head)
57
- {
58
- $head->append($scriptblock);
59
}
60
61
return parent::_prepareLayout();
@@ -63,8 +54,8 @@ class RicardoMartins_PagSeguro_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
63
64
public function isDobVisible()
65
{
66
- $owner_dob_attribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
67
- return empty($owner_dob_attribute);
68
}
69
70
}
35
$this->setTemplate('ricardomartins_pagseguro/form/cc.phtml');
36
}
37
38
+ /**
39
+ * Insere o javascript do modulo somente na hora da renderização, caso ainda não tenha sido inserido.
40
+ * @return Mage_Core_Block_Abstract
41
+ */
42
+ protected function _prepareLayout()
43
+ {
44
//adicionaremos o JS do pagseguro na tela que usará o bloco de cartao logo após o <body>
45
$head = Mage::app()->getLayout()->getBlock('after_body_start');
46
47
+ if ($head && false == $head->getChild('js_pagseguro')) {
48
+ $scriptBlock = Mage::helper('ricardomartins_pagseguro')->getPagSeguroScriptBlock();
49
+ $head->append($scriptBlock);
50
}
51
52
return parent::_prepareLayout();
54
55
public function isDobVisible()
56
{
57
+ $ownerDobAttribute = Mage::getStoreConfig('payment/pagseguro_cc/owner_dob_attribute');
58
+ return empty($ownerDobAttribute);
59
}
60
61
}
app/code/community/RicardoMartins/PagSeguro/Helper/Data.php CHANGED
@@ -43,7 +43,6 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
43
CURLOPT_TIMEOUT => 45,
44
CURLOPT_SSL_VERIFYPEER => false,
45
CURLOPT_SSL_VERIFYHOST => false,
46
-
47
));
48
49
$response = null;
@@ -58,8 +57,12 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
58
59
libxml_use_internal_errors(true);
60
$xml = simplexml_load_string($response);
61
- if(false === $xml){
62
- $this->writeLog('Falha na autenticação com API do PagSeguro. Verifique email e token cadastrados. Retorno pagseguro: ' . $response);
63
return false;
64
}
65
return (string)$xml->id;
@@ -155,6 +158,7 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
155
*/
156
public function getToken()
157
{
158
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_TOKEN);
159
if($this->isSandbox())
160
{
@@ -215,4 +219,44 @@ class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract
215
}
216
return Mage::app()->getTranslator()->translate($args);
217
}
218
}
43
CURLOPT_TIMEOUT => 45,
44
CURLOPT_SSL_VERIFYPEER => false,
45
CURLOPT_SSL_VERIFYHOST => false,
46
));
47
48
$response = null;
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('Falha na autenticação com API do PagSeguro. Verifique email e token cadastrados. Retorno pagseguro: ' . $response);
65
+ }
66
return false;
67
}
68
return (string)$xml->id;
158
*/
159
public function getToken()
160
{
161
+ $this->checkTokenIntegrity();
162
$token = Mage::getStoreConfig(self::XML_PATH_PAYMENT_PAGSEGURO_TOKEN);
163
if($this->isSandbox())
164
{
219
}
220
return Mage::app()->getTranslator()->translate($args);
221
}
222
+
223
+ /**
224
+ * Verifica se o campo de token é do tipo password e gera um warning no log caso não seja.
225
+ * @author Ricardo Martins
226
+ * @return void
227
+ */
228
+ public function checkTokenIntegrity()
229
+ {
230
+ $section = Mage::getSingleton('adminhtml/config')->getSection('payment');
231
+ $frontendType = (string)$section->groups->pagseguro->fields->token->frontend_type;
232
+
233
+ if ('obscure' != $frontendType) {
234
+ $this->writeLog(
235
+ 'O Token não está seguro. Outro módulo PagSeguro pode estar em conflito. Desabilite-os via XML.'
236
+ );
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Gera o HTML dos JS do Modulo
242
+ * @author Ricardo Martins
243
+ * @return Mage_Core_Block_Text
244
+ */
245
+ public function getPagSeguroScriptBlock()
246
+ {
247
+ $scriptblock = Mage::app()->getLayout()->createBlock('core/text', 'js_pagseguro');
248
+ $scriptblock->setText(
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, true),
256
+ Mage::helper('ricardomartins_pagseguro')->getJsUrl(),
257
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'pagseguro/pagseguro.js'
258
+ )
259
+ );
260
+ return $scriptblock;
261
+ }
262
}
app/code/community/RicardoMartins/PagSeguro/Model/Observer.php CHANGED
@@ -9,13 +9,18 @@ class RicardoMartins_PagSeguro_Model_Observer
9
*/
10
public function addDirectPaymentBlock($observer)
11
{
12
- $pagseguroBlocks = array('ricardomartins_pagseguropro/form_boleto','ricardomartins_pagseguro/form_cc');
13
$blockType = $observer->getBlock()->getType();
14
- if(in_array($blockType,$pagseguroBlocks)){
15
$output = $observer->getTransport()->getHtml();
16
- $directpayment = Mage::app()->getLayout()->createBlock('ricardomartins_pagseguro/form_directpayment')->toHtml();
17
$observer->getTransport()->setHtml($output . $directpayment);
18
-
19
}
20
return $this;
21
}
9
*/
10
public function addDirectPaymentBlock($observer)
11
{
12
+ $pagseguroBlocks = array(
13
+ 'ricardomartins_pagseguropro/form_tef',
14
+ 'ricardomartins_pagseguropro/form_boleto',
15
+ 'ricardomartins_pagseguro/form_cc',
16
+ );
17
$blockType = $observer->getBlock()->getType();
18
+ if (in_array($blockType, $pagseguroBlocks)) {
19
$output = $observer->getTransport()->getHtml();
20
+ $directpayment = Mage::app()->getLayout()
21
+ ->createBlock('ricardomartins_pagseguro/form_directpayment')
22
+ ->toHtml();
23
$observer->getTransport()->setHtml($output . $directpayment);
24
}
25
return $this;
26
}
app/code/community/RicardoMartins/PagSeguro/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<RicardoMartins_PagSeguro>
5
- <version>2.0.4</version>
6
</RicardoMartins_PagSeguro>
7
</modules>
8
<global>
@@ -44,11 +44,10 @@
44
<events>
45
<core_block_abstract_to_html_after>
46
<observers>
47
- <ricardomartins_pagseguro>
48
- <type>model</type>
49
- <class>RicardoMartins_PagSeguro_Model_Observer</class>
50
<method>addDirectPaymentBlock</method>
51
- </ricardomartins_pagseguro>
52
</observers>
53
</core_block_abstract_to_html_after>
54
</events>
2
<config>
3
<modules>
4
<RicardoMartins_PagSeguro>
5
+ <version>2.1.0</version>
6
</RicardoMartins_PagSeguro>
7
</modules>
8
<global>
44
<events>
45
<core_block_abstract_to_html_after>
46
<observers>
47
+ <pagseguro>
48
+ <class>ricardomartins_pagseguro/observer</class>
49
<method>addDirectPaymentBlock</method>
50
+ </pagseguro>
51
</observers>
52
</core_block_abstract_to_html_after>
53
</events>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>RicardoMartins_PagSeguro</name>
4
- <version>2.0.4</version>
5
<stability>stable</stability>
6
<license>MIT</license>
7
<channel>community</channel>
@@ -13,9 +13,9 @@ Os dados do cart&#xE3;o s&#xE3;o enviados para o site do pagseguro de forma segu
13
&#xD;
14
Os bugs devem ser reportados na &#xE1;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-04-03</date>
17
- <time>20:05:02</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="3ec300291bfb59a545bfb99a23f2d670"/><file name="Directpayment.php" hash="937273e541d362f353b2bde87c041631"/><dir name="Info"><file name="Cc.php" hash="ef4952bfb9d12dae0b6ce13afeb0d1bb"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="04042cc71f1f098b0513627f02c2cf0e"/><file name="Internal.php" hash="fbf64a95060a3d2f47ef44bde57a5c70"/><file name="Params.php" hash="ac7a5a794806a1881b81548977ea96c9"/></dir><dir name="Model"><file name="Abstract.php" hash="8489ad3cb2c7371e82b482be3e01a259"/><file name="Observer.php" hash="e709c92bc86416ffdcfe2fda5b8a4d37"/><dir name="Payment"><file name="Cc.php" hash="45cc744efc1d808f7661bcf611ba33e1"/></dir><dir name="Source"><dir name="Customer"><dir name="Address"><dir name="Attributes"><file name="Optional.php" hash="f25cdc6fe64c4e815cc9550e1d8f0977"/></dir><file name="Attributes.php" hash="01b0c102f051ec79fcf09feef3c79a63"/></dir><file name="Attributes.php" hash="4632cc4e9a67ef1d2633058def2c2e03"/><file name="Cpf.php" hash="fae15336acbf15a9bf43f7ae5e3fc9f2"/><file name="Dob.php" hash="ec1b44beafb11cd5dc30b8fe1aea2a74"/></dir><file name="Paymentmethods.php" hash="5ea1877c9f73a6dec6bc91900309a5a5"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><file name="Groups.php" hash="9649812c9f20e055ed1cb9fd92fbe656"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="f4678d73ebdfa7419870d74ca7f651f7"/><file name="NotificationController.php" hash="ec75706a308d334fad9232d0a193833f"/><file name="TestController.php" hash="dc8831ab4de2bd10d62a3ff9b6397add"/></dir><dir name="etc"><file name="config.xml" hash="5d3aba1133889c0eaa004c93bb2e63cc"/><file name="system.xml" hash="c2325165f309d3cad495c9afb71e7c8d"/></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="fef544ca8afd619526b9ea2a9d19e7e5"/><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>
1
<?xml version="1.0"?>
2
<package>
3
<name>RicardoMartins_PagSeguro</name>
4
+ <version>2.1.0</version>
5
<stability>stable</stability>
6
<license>MIT</license>
7
<channel>community</channel>
13
&#xD;
14
Os bugs devem ser reportados na &#xE1;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-05-29</date>
17
+ <time>00:13:03</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="6a7509b076172f421adbbdb1c96fe116"/><file name="Directpayment.php" hash="937273e541d362f353b2bde87c041631"/><dir name="Info"><file name="Cc.php" hash="ef4952bfb9d12dae0b6ce13afeb0d1bb"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f8751d7db405c50a7eeb72c1f3fb84c5"/><file name="Internal.php" hash="fbf64a95060a3d2f47ef44bde57a5c70"/><file name="Params.php" hash="ac7a5a794806a1881b81548977ea96c9"/></dir><dir name="Model"><file name="Abstract.php" hash="8489ad3cb2c7371e82b482be3e01a259"/><file name="Observer.php" hash="29a784cdb6203baf6b5f0abeeeda99ed"/><dir name="Payment"><file name="Cc.php" hash="45cc744efc1d808f7661bcf611ba33e1"/></dir><dir name="Source"><dir name="Customer"><dir name="Address"><dir name="Attributes"><file name="Optional.php" hash="f25cdc6fe64c4e815cc9550e1d8f0977"/></dir><file name="Attributes.php" hash="01b0c102f051ec79fcf09feef3c79a63"/></dir><file name="Attributes.php" hash="4632cc4e9a67ef1d2633058def2c2e03"/><file name="Cpf.php" hash="fae15336acbf15a9bf43f7ae5e3fc9f2"/><file name="Dob.php" hash="ec1b44beafb11cd5dc30b8fe1aea2a74"/></dir><file name="Paymentmethods.php" hash="5ea1877c9f73a6dec6bc91900309a5a5"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><file name="Groups.php" hash="9649812c9f20e055ed1cb9fd92fbe656"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="f4678d73ebdfa7419870d74ca7f651f7"/><file name="NotificationController.php" hash="ec75706a308d334fad9232d0a193833f"/><file name="TestController.php" hash="dc8831ab4de2bd10d62a3ff9b6397add"/></dir><dir name="etc"><file name="config.xml" hash="9d8c9618fb285f122fa857d08668ee9e"/><file name="system.xml" hash="c2325165f309d3cad495c9afb71e7c8d"/></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="fef544ca8afd619526b9ea2a9d19e7e5"/><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>