Version Notes
Versão estável.
Os bugs devem ser reportador 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 | 1.0.13 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.0.13
- app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +36 -7
- app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php +17 -1
- app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php +26 -0
- app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Source/Customer/Groups.php +11 -0
- app/code/community/RicardoMartins/PagSeguro/controllers/AjaxController.php +9 -0
- app/code/community/RicardoMartins/PagSeguro/etc/config.xml +2 -1
- app/code/community/RicardoMartins/PagSeguro/etc/system.xml +22 -0
- app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml +6 -5
- app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc/dob.phtml +3 -3
- js/pagseguro/pagseguro.js +32 -3
- package.xml +5 -5
app/code/community/RicardoMartins/PagSeguro/Helper/Params.php
CHANGED
@@ -21,7 +21,7 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
21 |
for($x=1, $y=0, $c=count($items); $x <= $c; $x++, $y++)
|
22 |
{
|
23 |
$retorno['itemId'.$x] = $items[$y]->getId();
|
24 |
-
$retorno['itemDescription'.$x] =
|
25 |
$retorno['itemAmount'.$x] = number_format($items[$y]->getPrice(),2,'.','');
|
26 |
$retorno['itemQuantity'.$x] = $items[$y]->getQtyOrdered();
|
27 |
}
|
@@ -47,7 +47,7 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
47 |
|
48 |
$retorno = array(
|
49 |
'senderName' => sprintf('%s %s',trim($order->getCustomerFirstname()), trim($order->getCustomerLastname())),
|
50 |
-
'senderEmail' => $order->getCustomerEmail(),
|
51 |
'senderHash' => $payment['additional_information']['sender_hash'],
|
52 |
'senderCPF' => $digits->filter($cpf),
|
53 |
'senderAreaCode'=> $phone['area'],
|
@@ -140,12 +140,12 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
140 |
|
141 |
|
142 |
$retorno = array(
|
143 |
-
$type.'AddressStreet' =>
|
144 |
-
$type.'AddressNumber' => $addressNumber,
|
145 |
-
$type.'AddressComplement' =>
|
146 |
-
$type.'AddressDistrict' =>
|
147 |
$type.'AddressPostalCode' => $addressPostalCode,
|
148 |
-
$type.'AddressCity' =>
|
149 |
$type.'AddressState' => $addressState,
|
150 |
$type.'AddressCountry' => 'BRA',
|
151 |
);
|
@@ -158,6 +158,9 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
158 |
$retorno['shippingType'] = $shippingType;
|
159 |
if($shippingCost > 0)
|
160 |
{
|
|
|
|
|
|
|
161 |
$retorno['shippingCost'] = number_format($shippingCost,2,'.','');
|
162 |
}
|
163 |
}
|
@@ -225,6 +228,9 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
225 |
$discount = $order->getDiscountAmount();
|
226 |
$tax_amount = $order->getTaxAmount();
|
227 |
$extra = $discount+$tax_amount;
|
|
|
|
|
|
|
228 |
return number_format($extra,2, '.','');
|
229 |
}
|
230 |
|
@@ -342,4 +348,27 @@ class RicardoMartins_PagSeguro_Helper_Params extends Mage_Core_Helper_Abstract
|
|
342 |
return $cpf;
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
}
|
21 |
for($x=1, $y=0, $c=count($items); $x <= $c; $x++, $y++)
|
22 |
{
|
23 |
$retorno['itemId'.$x] = $items[$y]->getId();
|
24 |
+
$retorno['itemDescription'.$x] = substr($items[$y]->getName(), 0, 100);
|
25 |
$retorno['itemAmount'.$x] = number_format($items[$y]->getPrice(),2,'.','');
|
26 |
$retorno['itemQuantity'.$x] = $items[$y]->getQtyOrdered();
|
27 |
}
|
47 |
|
48 |
$retorno = array(
|
49 |
'senderName' => sprintf('%s %s',trim($order->getCustomerFirstname()), trim($order->getCustomerLastname())),
|
50 |
+
'senderEmail' => trim($order->getCustomerEmail()),
|
51 |
'senderHash' => $payment['additional_information']['sender_hash'],
|
52 |
'senderCPF' => $digits->filter($cpf),
|
53 |
'senderAreaCode'=> $phone['area'],
|
140 |
|
141 |
|
142 |
$retorno = array(
|
143 |
+
$type.'AddressStreet' => substr($addressStreet,0,80),
|
144 |
+
$type.'AddressNumber' => substr($addressNumber,0,20),
|
145 |
+
$type.'AddressComplement' => substr($addressComplement,0,40),
|
146 |
+
$type.'AddressDistrict' => substr($addressDistrict,0,60),
|
147 |
$type.'AddressPostalCode' => $addressPostalCode,
|
148 |
+
$type.'AddressCity' => substr($addressCity,0,60),
|
149 |
$type.'AddressState' => $addressState,
|
150 |
$type.'AddressCountry' => 'BRA',
|
151 |
);
|
158 |
$retorno['shippingType'] = $shippingType;
|
159 |
if($shippingCost > 0)
|
160 |
{
|
161 |
+
if($this->_shouldSplit($order)){
|
162 |
+
$shippingCost -= 0.01;
|
163 |
+
}
|
164 |
$retorno['shippingCost'] = number_format($shippingCost,2,'.','');
|
165 |
}
|
166 |
}
|
228 |
$discount = $order->getDiscountAmount();
|
229 |
$tax_amount = $order->getTaxAmount();
|
230 |
$extra = $discount+$tax_amount;
|
231 |
+
if($this->_shouldSplit($order)){
|
232 |
+
$extra = $extra+0.01;
|
233 |
+
}
|
234 |
return number_format($extra,2, '.','');
|
235 |
}
|
236 |
|
348 |
return $cpf;
|
349 |
}
|
350 |
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Se deve ou não dividir o frete.. Se o total de produtos for igual o
|
354 |
+
* totalde desconto, o modulo diminuirá 1 centavo do frete e adicionará
|
355 |
+
* ao valor dos itens, pois o PagSeguro não aceita que os produtos custem
|
356 |
+
* zero.
|
357 |
+
*
|
358 |
+
* @param $order
|
359 |
+
*
|
360 |
+
* @return bool
|
361 |
+
*/
|
362 |
+
private function _shouldSplit($order)
|
363 |
+
{
|
364 |
+
$discount = $order->getDiscountAmount();
|
365 |
+
$tax_amount = $order->getTaxAmount();
|
366 |
+
$extraAmount = $discount+$tax_amount;
|
367 |
+
|
368 |
+
$totalAmount = 0;
|
369 |
+
foreach($order->getAllVisibleItems() as $item){
|
370 |
+
$totalAmount += $item->getRowTotal();
|
371 |
+
}
|
372 |
+
return (abs($extraAmount) == $totalAmount);
|
373 |
+
}
|
374 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php
CHANGED
@@ -173,9 +173,10 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
173 |
public function callApi($params, $payment)
|
174 |
{
|
175 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
|
|
176 |
$client = new Zend_Http_Client($helper->getWsUrl('transactions'));
|
177 |
$client->setMethod(Zend_Http_Client::POST);
|
178 |
-
$client->setConfig(array('timeout'=>
|
179 |
|
180 |
$client->setParameterPost($params); //parametros enviados via POST
|
181 |
|
@@ -208,4 +209,19 @@ class RicardoMartins_PagSeguro_Model_Abstract extends Mage_Payment_Model_Method_
|
|
208 |
|
209 |
return $xml;
|
210 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
173 |
public function callApi($params, $payment)
|
174 |
{
|
175 |
$helper = Mage::helper('ricardomartins_pagseguro');
|
176 |
+
$params = $this->_convertEnconding($params);
|
177 |
$client = new Zend_Http_Client($helper->getWsUrl('transactions'));
|
178 |
$client->setMethod(Zend_Http_Client::POST);
|
179 |
+
$client->setConfig(array('timeout'=>45));
|
180 |
|
181 |
$client->setParameterPost($params); //parametros enviados via POST
|
182 |
|
209 |
|
210 |
return $xml;
|
211 |
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Converte os valores enviados à api para ISO-8859-1
|
215 |
+
* @param array $params
|
216 |
+
*
|
217 |
+
* @return array
|
218 |
+
*/
|
219 |
+
protected function _convertEnconding(array $params)
|
220 |
+
{
|
221 |
+
foreach($params as $k => $v)
|
222 |
+
{
|
223 |
+
$params[$k] = utf8_decode($v);
|
224 |
+
}
|
225 |
+
return $params;
|
226 |
+
}
|
227 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/Payment/Cc.php
CHANGED
@@ -14,6 +14,27 @@ class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro
|
|
14 |
protected $_canUseForMultishipping = true;
|
15 |
protected $_canSaveCc = false;
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
public function assignData($data)
|
18 |
{
|
19 |
if(!($data instanceof Varien_Object)){
|
@@ -103,4 +124,9 @@ class RicardoMartins_PagSeguro_Model_Payment_Cc extends RicardoMartins_PagSeguro
|
|
103 |
return $this;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
14 |
protected $_canUseForMultishipping = true;
|
15 |
protected $_canSaveCc = false;
|
16 |
|
17 |
+
public function isAvailable($quote = null)
|
18 |
+
{
|
19 |
+
$is_available = parent::isAvailable ($quote);
|
20 |
+
if (empty($quote)){
|
21 |
+
return $is_available;
|
22 |
+
}
|
23 |
+
if (Mage::getStoreConfigFlag("payment/pagseguro_cc/group_restriction")
|
24 |
+
== false) {
|
25 |
+
return true;
|
26 |
+
}
|
27 |
+
|
28 |
+
$current_group_id = $quote->getCustomerGroupId ();
|
29 |
+
$customer_groups = explode (',', $this->_getStoreConfig('customer_groups'));
|
30 |
+
|
31 |
+
if($is_available && in_array($current_group_id, $customer_groups)){
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
public function assignData($data)
|
39 |
{
|
40 |
if(!($data instanceof Varien_Object)){
|
124 |
return $this;
|
125 |
}
|
126 |
|
127 |
+
public function _getStoreConfig($field)
|
128 |
+
{
|
129 |
+
return Mage::getStoreConfig("payment/pagseguro_cc/{$field}");
|
130 |
+
}
|
131 |
+
|
132 |
}
|
app/code/community/RicardoMartins/PagSeguro/Model/System/Config/Source/Customer/Groups.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
8 |
+
->toOptionArray();
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
app/code/community/RicardoMartins/PagSeguro/controllers/AjaxController.php
CHANGED
@@ -11,4 +11,13 @@ class RicardoMartins_PagSeguro_AjaxController extends Mage_Core_Controller_Front
|
|
11 |
$this->getResponse()->setHeader('Content-type','application/json');
|
12 |
$this->getResponse()->setBody(json_encode(array('total'=>$total)));
|
13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
11 |
$this->getResponse()->setHeader('Content-type','application/json');
|
12 |
$this->getResponse()->setBody(json_encode(array('total'=>$total)));
|
13 |
}
|
14 |
+
|
15 |
+
public function getSessionIdAction()
|
16 |
+
{
|
17 |
+
$_helper = Mage::helper('ricardomartins_pagseguro');
|
18 |
+
$session_id = $_helper->getSessionId();
|
19 |
+
|
20 |
+
$this->getResponse()->setHeader('Content-type','application/json');
|
21 |
+
$this->getResponse()->setBody(json_encode(array('session_id'=>$session_id)));
|
22 |
+
}
|
23 |
}
|
app/code/community/RicardoMartins/PagSeguro/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<RicardoMartins_PagSeguro>
|
5 |
-
<version>1.0.
|
6 |
</RicardoMartins_PagSeguro>
|
7 |
</modules>
|
8 |
<global>
|
@@ -64,6 +64,7 @@
|
|
64 |
<allowspecific>0</allowspecific>
|
65 |
<send_neworder_email>0</send_neworder_email>
|
66 |
<!--<specificcountry>BR</specificcountry>-->
|
|
|
67 |
</pagseguro_cc>
|
68 |
<pagseguro>
|
69 |
<customer_cpf_attribute>taxvat</customer_cpf_attribute>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<RicardoMartins_PagSeguro>
|
5 |
+
<version>1.0.13</version>
|
6 |
</RicardoMartins_PagSeguro>
|
7 |
</modules>
|
8 |
<global>
|
64 |
<allowspecific>0</allowspecific>
|
65 |
<send_neworder_email>0</send_neworder_email>
|
66 |
<!--<specificcountry>BR</specificcountry>-->
|
67 |
+
<group_restriction>0</group_restriction>
|
68 |
</pagseguro_cc>
|
69 |
<pagseguro>
|
70 |
<customer_cpf_attribute>taxvat</customer_cpf_attribute>
|
app/code/community/RicardoMartins/PagSeguro/etc/system.xml
CHANGED
@@ -221,6 +221,28 @@
|
|
221 |
<show_in_store>0</show_in_store>
|
222 |
<frontend_class>validate-number</frontend_class>
|
223 |
</sort_order>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
</fields>
|
225 |
</pagseguro_cc>
|
226 |
</groups>
|
221 |
<show_in_store>0</show_in_store>
|
222 |
<frontend_class>validate-number</frontend_class>
|
223 |
</sort_order>
|
224 |
+
<group_restriction>
|
225 |
+
<label>Habilitar restrição por grupos</label>
|
226 |
+
<frontend_type>select</frontend_type>
|
227 |
+
<sort_order>50</sort_order>
|
228 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
229 |
+
<show_in_default>1</show_in_default>
|
230 |
+
<show_in_website>1</show_in_website>
|
231 |
+
<show_in_store>0</show_in_store>
|
232 |
+
</group_restriction>
|
233 |
+
<customer_groups>
|
234 |
+
<label>Grupos de Cliente</label>
|
235 |
+
<frontend_type>multiselect</frontend_type>
|
236 |
+
<source_model>ricardomartins_pagseguro/system_config_source_customer_groups</source_model>
|
237 |
+
<sort_order>60</sort_order>
|
238 |
+
<show_in_default>1</show_in_default>
|
239 |
+
<show_in_website>1</show_in_website>
|
240 |
+
<show_in_store>1</show_in_store>
|
241 |
+
<comment><![CDATA[Grupos de clientes que podem usar este método.]]></comment>
|
242 |
+
<depends>
|
243 |
+
<group_restriction>1</group_restriction>
|
244 |
+
</depends>
|
245 |
+
</customer_groups>
|
246 |
</fields>
|
247 |
</pagseguro_cc>
|
248 |
</groups>
|
app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc.phtml
CHANGED
@@ -26,16 +26,17 @@ $_code=$this->getMethodCode();
|
|
26 |
<li id="<?php echo $_code ?>_cpf_div">
|
27 |
<label for="<?php echo $_code ?>_cpf" class="required"><em>*</em><?php echo $this->__('Credit Card Owner\'s CPF') ?></label>
|
28 |
<div class="input-box">
|
29 |
-
<input type="text" id="<?php echo $_code ?>_cpf" name="payment[<?php echo $_code?>_cpf]" title="<?php echo $this->__('Credit Card Owner\'s CPF') ?>" class="input-text required-entry validate-digits" value=""/>
|
30 |
</div>
|
31 |
</li>
|
32 |
<?php endif ?>
|
33 |
<li>
|
34 |
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
35 |
<div class="input-box">
|
36 |
-
<input type="text" id="<?php echo $_code ?>_cc_number" name="payment[ps_cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value=""/>
|
37 |
-
<?php #nao remover os
|
38 |
-
<span id="card-brand" style="text-transform: capitalize;"></span>
|
|
|
39 |
<input type="hidden" name="payment[ps_card_type]"/>
|
40 |
<input type="hidden" name="payment[credit_card_token]"/>
|
41 |
</div>
|
@@ -65,7 +66,7 @@ $_code=$this->getMethodCode();
|
|
65 |
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
66 |
<div class="input-box">
|
67 |
<div class="v-fix">
|
68 |
-
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[ps_cc_cid]" value="" />
|
69 |
</div>
|
70 |
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
71 |
</div>
|
26 |
<li id="<?php echo $_code ?>_cpf_div">
|
27 |
<label for="<?php echo $_code ?>_cpf" class="required"><em>*</em><?php echo $this->__('Credit Card Owner\'s CPF') ?></label>
|
28 |
<div class="input-box">
|
29 |
+
<input type="text" id="<?php echo $_code ?>_cpf" name="payment[<?php echo $_code?>_cpf]" title="<?php echo $this->__('Credit Card Owner\'s CPF') ?>" class="input-text required-entry validate-digits" value="" maxlength="11"/>
|
30 |
</div>
|
31 |
</li>
|
32 |
<?php endif ?>
|
33 |
<li>
|
34 |
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
35 |
<div class="input-box">
|
36 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" name="payment[ps_cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type required-entry" value="" maxlength="16"/>
|
37 |
+
<?php #nao remover os campos abaixo ?>
|
38 |
+
<span id="card-brand" style="text-transform: capitalize; display: block;"></span>
|
39 |
+
<span id="card-msg" style="color: red;clear:left; display: block;"></span>
|
40 |
<input type="hidden" name="payment[ps_card_type]"/>
|
41 |
<input type="hidden" name="payment[credit_card_token]"/>
|
42 |
</div>
|
66 |
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
67 |
<div class="input-box">
|
68 |
<div class="v-fix">
|
69 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[ps_cc_cid]" value="" maxlength="4"/>
|
70 |
</div>
|
71 |
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
72 |
</div>
|
app/design/frontend/base/default/template/ricardomartins_pagseguro/form/cc/dob.phtml
CHANGED
@@ -54,21 +54,21 @@ NOTE: Regarding styles - if we leave it this way, we'll move it to boxes.css
|
|
54 |
<?php
|
55 |
$this->setDateInput('d',
|
56 |
'<div class="dob-day">
|
57 |
-
<input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
58 |
<label for="' . $this->getFieldId('day') . '">' . $this->__('DD') . '</label>
|
59 |
</div>'
|
60 |
);
|
61 |
|
62 |
$this->setDateInput('m',
|
63 |
'<div class="dob-month">
|
64 |
-
<input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
65 |
<label for="' . $this->getFieldId('month') . '">' . $this->__('MM') . '</label>
|
66 |
</div>'
|
67 |
);
|
68 |
|
69 |
$this->setDateInput('y',
|
70 |
'<div class="dob-year">
|
71 |
-
<input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
72 |
<label for="' . $this->getFieldId('year') . '">' . $this->__('YYYY') . '</label>
|
73 |
</div>'
|
74 |
);
|
54 |
<?php
|
55 |
$this->setDateInput('d',
|
56 |
'<div class="dob-day">
|
57 |
+
<input type="text" maxlength="2" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
58 |
<label for="' . $this->getFieldId('day') . '">' . $this->__('DD') . '</label>
|
59 |
</div>'
|
60 |
);
|
61 |
|
62 |
$this->setDateInput('m',
|
63 |
'<div class="dob-month">
|
64 |
+
<input type="text" maxlength="2" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
65 |
<label for="' . $this->getFieldId('month') . '">' . $this->__('MM') . '</label>
|
66 |
</div>'
|
67 |
);
|
68 |
|
69 |
$this->setDateInput('y',
|
70 |
'<div class="dob-year">
|
71 |
+
<input type="text" maxlength="4" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
|
72 |
<label for="' . $this->getFieldId('year') . '">' . $this->__('YYYY') . '</label>
|
73 |
</div>'
|
74 |
);
|
js/pagseguro/pagseguro.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* PagSeguro Transparente para Magento
|
3 |
* @author Ricardo Martins <ricardo@ricardomartins.net.br>
|
4 |
* @link https://github.com/r-martins/PagSeguro-Magento-Transparente
|
5 |
-
* @version 0.2.
|
6 |
*/
|
7 |
document.observe("dom:loaded", function() {
|
8 |
RMPagSeguro = function RMPagSeguro(){};
|
@@ -41,27 +41,47 @@ document.observe("dom:loaded", function() {
|
|
41 |
|
42 |
RMPagSeguro.updateCreditCardToken = function(){
|
43 |
var ccNum = $$('input[name="payment[ps_cc_number]"]').first().value.replace(/^\s+|\s+$/g,'');
|
|
|
44 |
var ccExpMo = $$('select[name="payment[ps_cc_exp_month]"]').first().value;
|
45 |
var ccExpYr = $$('select[name="payment[ps_cc_exp_year]"]').first().value;
|
46 |
var ccCvv = $$('input[name="payment[ps_cc_cid]"]').first().value;
|
47 |
var ccTokenElm = $$('input[name="payment[credit_card_token]"]').first();
|
|
|
|
|
|
|
|
|
48 |
|
49 |
if(ccNum.length > 6 && ccExpMo != "" && ccExpYr != "" && ccCvv.length >= 3)
|
50 |
{
|
51 |
PagSeguroDirectPayment.createCardToken({
|
52 |
cardNumber: ccNum,
|
53 |
-
brand:
|
54 |
cvv: ccCvv,
|
55 |
expirationMonth: ccExpMo,
|
56 |
expirationYear: ccExpYr,
|
57 |
success: function(psresponse){
|
58 |
ccTokenElm.value = psresponse.card.token;
|
|
|
59 |
},
|
60 |
error: function(psresponse){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
console.log('Falha ao obter o token do cartao.');
|
|
|
62 |
},
|
63 |
complete: function(psresponse){
|
64 |
-
//
|
65 |
RMPagSeguro.reCheckSenderHash();
|
66 |
}
|
67 |
});
|
@@ -130,5 +150,14 @@ document.observe("dom:loaded", function() {
|
|
130 |
}
|
131 |
}
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
});
|
2 |
* PagSeguro Transparente para Magento
|
3 |
* @author Ricardo Martins <ricardo@ricardomartins.net.br>
|
4 |
* @link https://github.com/r-martins/PagSeguro-Magento-Transparente
|
5 |
+
* @version 0.2.2
|
6 |
*/
|
7 |
document.observe("dom:loaded", function() {
|
8 |
RMPagSeguro = function RMPagSeguro(){};
|
41 |
|
42 |
RMPagSeguro.updateCreditCardToken = function(){
|
43 |
var ccNum = $$('input[name="payment[ps_cc_number]"]').first().value.replace(/^\s+|\s+$/g,'');
|
44 |
+
var ccNumElm = $$('input[name="payment[ps_cc_number]"]').first();
|
45 |
var ccExpMo = $$('select[name="payment[ps_cc_exp_month]"]').first().value;
|
46 |
var ccExpYr = $$('select[name="payment[ps_cc_exp_year]"]').first().value;
|
47 |
var ccCvv = $$('input[name="payment[ps_cc_cid]"]').first().value;
|
48 |
var ccTokenElm = $$('input[name="payment[credit_card_token]"]').first();
|
49 |
+
var brandName = '';
|
50 |
+
if(undefined != RMPagSeguro.brand){
|
51 |
+
brandName = RMPagSeguro.brand.name;
|
52 |
+
}
|
53 |
|
54 |
if(ccNum.length > 6 && ccExpMo != "" && ccExpYr != "" && ccCvv.length >= 3)
|
55 |
{
|
56 |
PagSeguroDirectPayment.createCardToken({
|
57 |
cardNumber: ccNum,
|
58 |
+
brand: brandName,
|
59 |
cvv: ccCvv,
|
60 |
expirationMonth: ccExpMo,
|
61 |
expirationYear: ccExpYr,
|
62 |
success: function(psresponse){
|
63 |
ccTokenElm.value = psresponse.card.token;
|
64 |
+
$('card-msg').innerHTML = '';
|
65 |
},
|
66 |
error: function(psresponse){
|
67 |
+
if(undefined!=psresponse.errors["30400"]) {
|
68 |
+
$('card-msg').innerHTML = 'Dados do cartão inválidos.';
|
69 |
+
}else if(undefined!=psresponse.errors["10001"]){
|
70 |
+
$('card-msg').innerHTML = 'Tamanho do cartão inválido.';
|
71 |
+
}else if(undefined!=psresponse.errors["10006"]){
|
72 |
+
$('card-msg').innerHTML = 'Tamanho do CVV inválido.';
|
73 |
+
}else if(undefined!=psresponse.errors["30405"]){
|
74 |
+
$('card-msg').innerHTML = 'Data de validade incorreta.';
|
75 |
+
}else if(undefined!=psresponse.errors["30403"]){
|
76 |
+
RMPagSeguro.updateSessionId(); //Se sessao expirar, atualizamos a session
|
77 |
+
}else{
|
78 |
+
$('card-msg').innerHTML = 'Verifique os dados do cartão digitado.';
|
79 |
+
}
|
80 |
console.log('Falha ao obter o token do cartao.');
|
81 |
+
console.log(psresponse.errors);
|
82 |
},
|
83 |
complete: function(psresponse){
|
84 |
+
//console.log(psresponse);
|
85 |
RMPagSeguro.reCheckSenderHash();
|
86 |
}
|
87 |
});
|
150 |
}
|
151 |
}
|
152 |
|
153 |
+
RMPagSeguro.updateSessionId = function() {
|
154 |
+
var _url = RMPagSeguroSiteBaseURL + 'pseguro/ajax/getSessionId';
|
155 |
+
new Ajax.Request(_url, {
|
156 |
+
onSuccess: function (response) {
|
157 |
+
var session_id = response.responseJSON.session_id;
|
158 |
+
PagSeguroDirectPayment.setSessionId(session_id);
|
159 |
+
}
|
160 |
+
});
|
161 |
+
}
|
162 |
|
163 |
});
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RicardoMartins_PagSeguro</name>
|
4 |
-
<version>1.0.
|
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 reportador 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>2014-
|
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="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="57cbe8b75ae926b3f2e7561e0f191184"/><file name="Internal.php" hash="fbf64a95060a3d2f47ef44bde57a5c70"/><file name="Params.php" hash="
|
19 |
<compatible/>
|
20 |
-
<dependencies><required><php><min>5.2.1</min><max>5.
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RicardoMartins_PagSeguro</name>
|
4 |
+
<version>1.0.13</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT</license>
|
7 |
<channel>community</channel>
|
13 |

|
14 |
Os bugs devem ser reportador 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>2014-10-23</date>
|
17 |
+
<time>00:08:27</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="57cbe8b75ae926b3f2e7561e0f191184"/><file name="Internal.php" hash="fbf64a95060a3d2f47ef44bde57a5c70"/><file name="Params.php" hash="40f9780ced1f4545441a66226432daee"/></dir><dir name="Model"><file name="Abstract.php" hash="5d82cd2de41bff2c5e78dd3dc31f593b"/><file name="Observer.php" hash="e709c92bc86416ffdcfe2fda5b8a4d37"/><dir name="Payment"><file name="Cc.php" hash="ecfec49878d375d701068be6d4526740"/></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="037bd96ec4975c3587295e6bc1c2f43c"/><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="e95043b5da35be441bf8b1e8f64007d1"/><file name="NotificationController.php" hash="47641a62f0d1850ea7711d997bfa1fa5"/><file name="TestController.php" hash="b0d6a8e347b45f3013435a4c2ac4a16b"/></dir><dir name="etc"><file name="config.xml" hash="c6bf384c6acddfda85a1e951e360b278"/><file name="system.xml" hash="bfb232212cbae79463cf74202f20b8f0"/></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="bc2444ea954caf1b63603c37cfabedff"/></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="ed953a0e3ae788025653c7318e7c5777"/></dir><file name="cc.phtml" hash="fef544ca8afd619526b9ea2a9d19e7e5"/><file name="directpayment.phtml" hash="e4c2ed8d53d1334f6715f3c6fb638369"/><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="06ad1084da010774c1cf045944b3797a"/></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>
|