Version Notes
Principais características desta versão:
- Integração com Módulo de Pagamentos PagSeguro;
- Retorno Automático de Dados;
- Notificações API;
- Consulta de Pedidos;
- Rastreio por Logs;
- Mudança de Status de Pedido Automaticamente;
Novas funcionalidades serão implementadas em versões futuras.
Por favor, mandem sugestões de melhorias.
Tiago Sampaio
Download this release
Release Info
Developer | Tiago Sampaio |
Extension | OsStudios_PagSeguro |
Version | 1.0.0.0 |
Comparing to | |
See all releases |
Version 1.0.0.0
- app/code/community/OsStudios/PagSeguro/Block/Form.php +94 -0
- app/code/community/OsStudios/PagSeguro/Block/Info.php +69 -0
- app/code/community/OsStudios/PagSeguro/Block/Installments.php +118 -0
- app/code/community/OsStudios/PagSeguro/Block/Paylink.php +71 -0
- app/code/community/OsStudios/PagSeguro/Block/Success.php +89 -0
- app/code/community/OsStudios/PagSeguro/Controller/Front/Abstract.php +57 -0
- app/code/community/OsStudios/PagSeguro/Helper/Data.php +255 -0
- app/code/community/OsStudios/PagSeguro/Helper/Visie.php +235 -0
- app/code/community/OsStudios/PagSeguro/Model/Abstract.php +254 -0
- app/code/community/OsStudios/PagSeguro/Model/Credentials.php +47 -0
- app/code/community/OsStudios/PagSeguro/Model/Data.php +39 -0
- app/code/community/OsStudios/PagSeguro/Model/Hpp.php +321 -0
- app/code/community/OsStudios/PagSeguro/Model/Observer.php +28 -0
- app/code/community/OsStudios/PagSeguro/Model/Payment.php +112 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns.php +335 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Orders.php +214 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Abstract.php +115 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Api.php +126 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Consult.php +163 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Default.php +63 -0
- app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Transactions/Transaction.php +386 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Consult/Daysrange.php +37 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Installments.php +38 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Log/Types.php +38 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Order/Status/Canceled.php +51 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Order/Status/Paid.php +52 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Returnpage.php +38 -0
- app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Shipping/Price.php +36 -0
- app/code/community/OsStudios/PagSeguro/controllers/Adminhtml/ReturnsController.php +39 -0
- app/code/community/OsStudios/PagSeguro/controllers/PayController.php +140 -0
- app/code/community/OsStudios/PagSeguro/controllers/ReturnsController.php +103 -0
- app/code/community/OsStudios/PagSeguro/etc/adminhtml.xml +75 -0
- app/code/community/OsStudios/PagSeguro/etc/config.xml +164 -0
- app/code/community/OsStudios/PagSeguro/etc/system.xml +325 -0
- app/code/community/OsStudios/PagSeguro/sql/pagseguro_setup/mysql4-install-1.0.0.0.php +25 -0
- app/design/adminhtml/default/default/layout/osstudios_pagseguro.xml +24 -0
- app/design/frontend/base/default/layout/osstudios_pagseguro.xml +55 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/form.phtml +111 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/info.phtml +30 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/installments.phtml +128 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/installments_template.phtml +21 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/paylink.phtml +32 -0
- app/design/frontend/base/default/template/osstudios/pagseguro/success.phtml +77 -0
- app/etc/modules/OsStudios_PagSeguro.xml +31 -0
- app/locale/pt_BR/OsStudios_PagSeguro.csv +87 -0
- package.xml +43 -0
app/code/community/OsStudios/PagSeguro/Block/Form.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Form Block
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Block_Form extends Mage_Payment_Block_Form
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('osstudios/pagseguro/form.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _beforeToHtml()
|
32 |
+
{
|
33 |
+
$this->_prepareForm();
|
34 |
+
return parent::_beforeToHtml();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns PagSeguro Singleton Object
|
39 |
+
*
|
40 |
+
* @return OsStudios_Pagseguro_Model_Payment
|
41 |
+
*/
|
42 |
+
public function getPagSeguro()
|
43 |
+
{
|
44 |
+
return Mage::getSingleton('pagseguro/hpp');
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Returns the Order's Grand Total
|
49 |
+
*
|
50 |
+
* @return float
|
51 |
+
*/
|
52 |
+
public function getFinalValue()
|
53 |
+
{
|
54 |
+
$quote = Mage::getModel('checkout/session')->getQuote();
|
55 |
+
$totals = $quote->getTotals();
|
56 |
+
return $totals['grand_total']->_data['value'];
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _prepareForm()
|
60 |
+
{
|
61 |
+
$pagseguro = $this->getPagSeguro();
|
62 |
+
$helper = Mage::helper('pagseguro');
|
63 |
+
|
64 |
+
$msgAdd = $pagseguro->getConfigData('msg_add');
|
65 |
+
$installmentsAdd = $pagseguro->getConfigData('installments_add');
|
66 |
+
$installmentsUpfront = $pagseguro->getConfigData('installments_upfront');
|
67 |
+
|
68 |
+
$installments = $upfrontPrice = $upfrontDiscount = '';
|
69 |
+
$finalValue = $this->getFinalValue();
|
70 |
+
|
71 |
+
$installmentsShow = (boolean) ($pagseguro->getConfigData('installments_show') && $finalValue);
|
72 |
+
$installmentsUpfrontShow = (boolean) ($installmentsUpfront && $installmentsAdd != 0);
|
73 |
+
|
74 |
+
if ($installmentsShow) {
|
75 |
+
$installments = $helper->calculateInstallments($finalValue, $installmentsAdd);
|
76 |
+
|
77 |
+
if ($installmentsUpfrontShow) {
|
78 |
+
list($upfrontPrice, $upfrontDiscount) = $helper->calculateUpfrontPrice($finalValue, $installmentsAdd);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$this->addData(array(
|
83 |
+
'message' => $msgAdd,
|
84 |
+
'installments' => $installments,
|
85 |
+
'upfront_price' => $upfrontPrice,
|
86 |
+
'upfront_discount' => $upfrontDiscount,
|
87 |
+
'show_message' => (boolean) $msgAdd,
|
88 |
+
'show_installments' => $installmentsShow,
|
89 |
+
'show_upfront_price' => $installmentsUpfrontShow,
|
90 |
+
'show_form' => (boolean) ($msgAdd || $installmentsShow),
|
91 |
+
));
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
app/code/community/OsStudios/PagSeguro/Block/Info.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Info Block
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Block_Info extends Mage_Payment_Block_Info
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('osstudios/pagseguro/info.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _beforeToHtml()
|
32 |
+
{
|
33 |
+
$this->_prepareInfo();
|
34 |
+
return parent::_beforeToHtml();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns PagSeguro Singleton Object
|
39 |
+
*
|
40 |
+
* @return OsStudios_Pagseguro_Model_Payment
|
41 |
+
*/
|
42 |
+
public function getPagSeguro()
|
43 |
+
{
|
44 |
+
return Mage::getSingleton('pagseguro/hpp');
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _prepareInfo()
|
48 |
+
{
|
49 |
+
$pagseguro = $this->getPagSeguro();
|
50 |
+
if (!$order = $this->getInfo()->getOrder()) {
|
51 |
+
$order = $this->getInfo()->getQuote();
|
52 |
+
}
|
53 |
+
|
54 |
+
$transactionId = $this->getInfo()->getPagseguroTransactionId();
|
55 |
+
$paymentMethod = $this->getInfo()->getPagseguroPaymentMethod();
|
56 |
+
|
57 |
+
if ($paymentMethod == 'Boleto' AND $order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
|
58 |
+
$paymentMethod .= ' (<a href="' . Mage::getModel('pagseguro/data')->getPagSeguroBoletoUrl($transactionId) . '" onclick="this.target=\'_blank\'">reemitir</a>)';
|
59 |
+
}
|
60 |
+
|
61 |
+
$this->addData(array(
|
62 |
+
'show_paylink' => (boolean) !$transactionId && $order->getState() == Mage_Sales_Model_Order::STATE_NEW,
|
63 |
+
'pay_url' => $pagseguro->getOrderPlaceRedirectUrl($order->getId()),
|
64 |
+
'show_info' => (boolean) $transactionId,
|
65 |
+
'transaction_id' => $transactionId,
|
66 |
+
'payment_method' => $paymentMethod,
|
67 |
+
));
|
68 |
+
}
|
69 |
+
}
|
app/code/community/OsStudios/PagSeguro/Block/Installments.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Installments Block
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Block_Installments extends Mage_Core_Block_Template
|
24 |
+
{
|
25 |
+
|
26 |
+
protected $_showScripts = true;
|
27 |
+
|
28 |
+
protected function _construct()
|
29 |
+
{
|
30 |
+
parent::_construct();
|
31 |
+
$this->setTemplate('osstudios/pagseguro/installments.phtml');
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _beforeToHtml()
|
35 |
+
{
|
36 |
+
$this->_prepareForm();
|
37 |
+
return parent::_beforeToHtml();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns PagSeguro Singleton Object
|
42 |
+
*
|
43 |
+
* @return OsStudios_Pagseguro_Model_Payment
|
44 |
+
*/
|
45 |
+
public function getPagSeguro()
|
46 |
+
{
|
47 |
+
return Mage::getSingleton('pagseguro/hpp');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Returns Product's Final Price.
|
52 |
+
*
|
53 |
+
* @return float
|
54 |
+
*/
|
55 |
+
public function getProductFinalPrice()
|
56 |
+
{
|
57 |
+
$price = preg_replace("/^R\\$[ ]*/i", "", $this->getRequest()->getParam('price'));
|
58 |
+
$price = str_replace(".", "", $price);
|
59 |
+
$price = str_replace(",", ".", $price);
|
60 |
+
|
61 |
+
if ($price > 0) {
|
62 |
+
$this->_showScripts = false;
|
63 |
+
} else {
|
64 |
+
|
65 |
+
$productId = $this->getRequest()->getParam('id');
|
66 |
+
if (!Mage::registry('product') && $productId) {
|
67 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
68 |
+
Mage::register('product', $product);
|
69 |
+
} else {
|
70 |
+
$product = Mage::registry('product');
|
71 |
+
}
|
72 |
+
|
73 |
+
if ($product) {
|
74 |
+
$price = $product->getFinalPrice();
|
75 |
+
} else {
|
76 |
+
$price = 0;
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
return $price;
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _prepareForm()
|
86 |
+
{
|
87 |
+
$pagseguro = $this->getPagSeguro();
|
88 |
+
$helper = Mage::helper("pagseguro");
|
89 |
+
|
90 |
+
$pagseguroEnabled = $pagseguro->getConfigData('active');
|
91 |
+
$installmentsAdd = $pagseguro->getConfigData('installments_add');
|
92 |
+
$installmentsUpfront = $pagseguro->getConfigData('installments_upfront');
|
93 |
+
|
94 |
+
$installments = $upfrontPrice = $upfrontDiscount = '';
|
95 |
+
$finalValue = $this->getProductFinalPrice();
|
96 |
+
|
97 |
+
$installmentsShow = (boolean) ($pagseguro->getConfigData('installments_show') && $pagseguroEnabled && $finalValue);
|
98 |
+
$installmentsUpfrontShow = (boolean) ($installmentsUpfront && $installmentsAdd != 0);
|
99 |
+
|
100 |
+
if ($installmentsShow) {
|
101 |
+
$installments = $helper->calculateInstallments($finalValue, $installmentsAdd);
|
102 |
+
|
103 |
+
if ($installmentsUpfrontShow) {
|
104 |
+
list($upfrontPrice, $upfrontDiscount) = $helper->calculateUpfrontPrice($finalValue, $installmentsAdd);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
$this->addData(array(
|
109 |
+
'installments' => $installments,
|
110 |
+
'upfront_price' => $upfrontPrice,
|
111 |
+
'upfront_discount' => $upfrontDiscount,
|
112 |
+
'show_installments_scripts' => (boolean) ($pagseguroEnabled && $this->_showScripts),
|
113 |
+
'show_installments' => $installmentsShow,
|
114 |
+
'show_upfront_price' => $installmentsUpfrontShow,
|
115 |
+
));
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
app/code/community/OsStudios/PagSeguro/Block/Paylink.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Paylink Block
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Block_Paylink extends Mage_Core_Block_Template
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('osstudios/pagseguro/paylink.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns Current Order Object
|
33 |
+
*
|
34 |
+
* @return Mage_Sales_Model_Order
|
35 |
+
*/
|
36 |
+
public function getOrder()
|
37 |
+
{
|
38 |
+
return Mage::registry('current_order');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns PagSeguro Singleton Object
|
43 |
+
*
|
44 |
+
* @return OsStudios_Pagseguro_Model_Payment
|
45 |
+
*/
|
46 |
+
public function getPagSeguro()
|
47 |
+
{
|
48 |
+
return Mage::getSingleton('pagseguro/hpp');
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Check if the payment button can be shown
|
53 |
+
*
|
54 |
+
* @return boolean
|
55 |
+
*/
|
56 |
+
public function isShowPaylink()
|
57 |
+
{
|
58 |
+
$order = $this->getOrder();
|
59 |
+
return (bool) ($order->getPayment()->getMethod() == $this->getPagSeguro()->getCode() AND $order->getState() == Mage_Sales_Model_Order::STATE_NEW);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns Payment URL
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getPaymentUrl()
|
68 |
+
{
|
69 |
+
return $this->getPagSeguro()->getOrderPlaceRedirectUrl($this->getOrder()->getId());
|
70 |
+
}
|
71 |
+
}
|
app/code/community/OsStudios/PagSeguro/Block/Success.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Success Page Block
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Block_Success extends Mage_Core_Block_Template
|
24 |
+
{
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Init Infos and Prepare for Output
|
28 |
+
*/
|
29 |
+
protected function _beforeToHtml()
|
30 |
+
{
|
31 |
+
$this->_prepareOrder();
|
32 |
+
return parent::_beforeToHtml();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Escapes HTML Entities.
|
37 |
+
* Method created to older Magento versions compatibility.
|
38 |
+
*
|
39 |
+
* @param mixed $data
|
40 |
+
* @param array $allowedTags
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function escapeHtml($data, $allowedTags = null)
|
44 |
+
{
|
45 |
+
return Mage::helper('pagseguro')->escapeHtml($data, $allowedTags);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Returns PagSeguro Singleton Object
|
50 |
+
*
|
51 |
+
* @return OsStudios_Pagseguro_Model_Payment
|
52 |
+
*/
|
53 |
+
public function getPagSeguro()
|
54 |
+
{
|
55 |
+
return Mage::getSingleton('pagseguro/hpp');
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Get Session Order ID, load it and check if it can be viewed, printed, etc.
|
60 |
+
*/
|
61 |
+
protected function _prepareOrder()
|
62 |
+
{
|
63 |
+
$orderId = Mage::getSingleton('core/session')->getPagseguroOrderId();
|
64 |
+
if ($orderId) {
|
65 |
+
|
66 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
67 |
+
|
68 |
+
if ($order->getId()) {
|
69 |
+
|
70 |
+
$isVisible = !in_array($order->getState(), Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
|
71 |
+
$isHolded = (boolean) ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED);
|
72 |
+
|
73 |
+
$this->addData(array(
|
74 |
+
'order_id' => $order->getIncrementId(),
|
75 |
+
'is_order_visible' => $isVisible,
|
76 |
+
'is_order_holded' => $isHolded,
|
77 |
+
'can_print_order' => $isVisible,
|
78 |
+
'can_view_order' => (boolean) (Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible),
|
79 |
+
'view_order_url' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
|
80 |
+
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
|
81 |
+
'pagseguro_transaction_id' => $order->getPayment()->getPagseguroTransactionId(),
|
82 |
+
'pagseguro_payment_method' => $order->getPayment()->getPagseguroPaymentMethod(),
|
83 |
+
'pagseguro_boleto_url' => Mage::getModel('pagseguro/data')->getPagSeguroBoletoUrl($order->getPayment()->getPagseguroTransactionId()),
|
84 |
+
'pagseguro_payment_url' => $this->getPagSeguro()->getOrderPlaceRedirectUrl($order->getId()),
|
85 |
+
));
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
app/code/community/OsStudios/PagSeguro/Controller/Front/Abstract.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
* PagSeguro Controller Front Abstract
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
|
24 |
+
class OsStudios_PagSeguro_Controller_Front_Abstract extends Mage_Core_Controller_Front_Action
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return PagSeguro Singleton Object
|
29 |
+
*
|
30 |
+
* @return OsStudios_PagSeguro_Model_Hpp
|
31 |
+
*/
|
32 |
+
public function getPagSeguro()
|
33 |
+
{
|
34 |
+
return Mage::getSingleton('pagseguro/hpp');
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Return Checkout Object
|
40 |
+
*
|
41 |
+
* @return Mage_Checkout_Model_Session
|
42 |
+
*/
|
43 |
+
public function getCheckout()
|
44 |
+
{
|
45 |
+
return Mage::getSingleton('checkout/session');
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Return Order's Store ID
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
function getOrderStoreId($orderId) {
|
54 |
+
return Mage::getModel('sales/order')->load($orderId)->getStoreId();
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
app/code/community/OsStudios/PagSeguro/Helper/Data.php
ADDED
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Data Helper
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Helper_Data extends OsStudios_PagSeguro_Helper_Visie
|
24 |
+
{
|
25 |
+
|
26 |
+
const PARCEL_MAX_VALUE = 5;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Escapa entidades HTML.
|
30 |
+
* Função criada para compatibilidade com versões mais antigas do Magento.
|
31 |
+
*
|
32 |
+
* @param mixed $data
|
33 |
+
* @param array $allowedTags
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
public function escapeHtml($data, $allowedTags = null)
|
37 |
+
{
|
38 |
+
$core_helper = Mage::helper('core');
|
39 |
+
if (method_exists($core_helper, "escapeHtml")) {
|
40 |
+
return $core_helper->escapeHtml($data, $allowedTags);
|
41 |
+
} elseif (method_exists($core_helper, "htmlEscape")) {
|
42 |
+
return $core_helper->htmlEscape($data, $allowedTags);
|
43 |
+
} else {
|
44 |
+
return $data;
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Calcula preço da parcela desejada, de acordo com o valor informado e até
|
51 |
+
* quantas parcelas sem juros são disponibilizadas. Retorna um array com o
|
52 |
+
* valor total, o valor da parcela e uma mensagem extra.
|
53 |
+
*/
|
54 |
+
public function calculateRate($valor_original, $parcelas_sem_juros = 0, $intervalos = 1, $recalcula = false, $juros = 0.0199) {
|
55 |
+
|
56 |
+
$parcelas = $intervalos;
|
57 |
+
if ($parcelas_sem_juros > 1 and $parcelas <= $parcelas_sem_juros) {
|
58 |
+
$parcelas = $parcelas_sem_juros;
|
59 |
+
}
|
60 |
+
|
61 |
+
if ($juros > 1) {
|
62 |
+
$juros /= 100;
|
63 |
+
}
|
64 |
+
|
65 |
+
$msg_extra = "";
|
66 |
+
|
67 |
+
$valor_total = $valor_original;
|
68 |
+
if ($intervalos == 1 and $parcelas_sem_juros < 1) {
|
69 |
+
$valor_parcela = $valor_original;
|
70 |
+
$msg_extra = "Sem juros";
|
71 |
+
} else {
|
72 |
+
if ($parcelas <= $parcelas_sem_juros or $parcelas_sem_juros < 1) {
|
73 |
+
if ($parcelas_sem_juros > 1) {
|
74 |
+
$msg_extra = "Sem juros";
|
75 |
+
}
|
76 |
+
} else {
|
77 |
+
if ($juros == 0) {
|
78 |
+
$valor_parcela = $valor_original / $intervalos;
|
79 |
+
} else {
|
80 |
+
if ($recalcula) {
|
81 |
+
$valor_parcela = ($valor_original * $juros) / (1 - pow(1 / (1 + $juros), $parcelas_sem_juros));
|
82 |
+
$valor_total = $valor_parcela * $parcelas_sem_juros;
|
83 |
+
}
|
84 |
+
$parcelas -= $parcelas_sem_juros;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
if ($juros != 0 and ($recalcula or $intervalos > $parcelas_sem_juros)) {
|
88 |
+
$valor_parcela = ($valor_total * $juros) / (1 - pow(1 / (1 + $juros), $parcelas));
|
89 |
+
$valor_total = $valor_parcela * $parcelas;
|
90 |
+
}
|
91 |
+
$valor_parcela = $valor_total / $intervalos;
|
92 |
+
}
|
93 |
+
|
94 |
+
return array($valor_total, $valor_parcela, $msg_extra);
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Calcula preço à vista com desconto, de acordo com o valor informado e até
|
100 |
+
* quantas parcelas sem juros são disponibilizadas. Retorna um array com o
|
101 |
+
* valor e a porcentagem de desconto.
|
102 |
+
*/
|
103 |
+
public function calculateUpfrontPrice($valor_original, $parcelas_sem_juros, $juros = 0.0199) {
|
104 |
+
|
105 |
+
if (preg_match("/^[-+]?[0-9]{1,3}(\.[0-9]{3})*(,[0-9]*)?$/", $valor_original)) {
|
106 |
+
$valor_original = str_replace(".", "", $valor_original);
|
107 |
+
$valor_original = str_replace(",", ".", $valor_original);
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($juros > 1) {
|
111 |
+
$juros /= 100;
|
112 |
+
}
|
113 |
+
|
114 |
+
$valor_a_vista = $valor_original;
|
115 |
+
if ($parcelas_sem_juros >= 2 and $juros != 0) {
|
116 |
+
|
117 |
+
$valor_parcela = $valor_a_vista / $parcelas_sem_juros;
|
118 |
+
$valor_total = ($valor_parcela * (1 - pow(1 / (1 + $juros), $parcelas_sem_juros))) / $juros;
|
119 |
+
|
120 |
+
$valor_a_vista = $valor_total;
|
121 |
+
}
|
122 |
+
|
123 |
+
$desconto = ceil((1 - $valor_a_vista / $valor_original) * 100);
|
124 |
+
|
125 |
+
$valor_a_vista = number_format($valor_a_vista, 2, ",", "");
|
126 |
+
|
127 |
+
return array($valor_a_vista, $desconto);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Calcula planos de parcelamento de acordo com o valor e o número de parcelas
|
132 |
+
* sem juros a serem exibidas.
|
133 |
+
*/
|
134 |
+
public function calculateInstallments($valor_total_orig, $parcelas_sem_juros = 0, $recalcula = false, $juros = 0.0199, $parcelas_max = 18) {
|
135 |
+
|
136 |
+
$installments = array();
|
137 |
+
|
138 |
+
if (preg_match("/^[-+]?[0-9]{1,3}(\.[0-9]{3})*(,[0-9]*)?$/", $valor_total_orig)) {
|
139 |
+
$valor_total_orig = str_replace(".", "", $valor_total_orig);
|
140 |
+
$valor_total_orig = str_replace(",", ".", $valor_total_orig);
|
141 |
+
}
|
142 |
+
|
143 |
+
if ($parcelas_max < 1) {
|
144 |
+
$parcelas_max = 1;
|
145 |
+
}
|
146 |
+
|
147 |
+
for ($parcels = 1; $parcels <= $parcelas_max; $parcels++) {
|
148 |
+
|
149 |
+
list($valor_total, $valor_parcela, $msg_extra) = $this->calculateRate($valor_total_orig, $parcelas_sem_juros, $parcels, $recalcula, $juros);
|
150 |
+
|
151 |
+
if ($parcels > 1 and $valor_parcela < self::PARCEL_MAX_VALUE) {
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
|
155 |
+
$valor_parcela = number_format($valor_parcela, 2, ",", "");
|
156 |
+
$valor_total = number_format($valor_total, 2, ",", "");
|
157 |
+
|
158 |
+
$installments[] = array(
|
159 |
+
'valor_parcela' => $valor_parcela,
|
160 |
+
'valor_total' => $valor_total,
|
161 |
+
'msg_extra' => $msg_extra,
|
162 |
+
);
|
163 |
+
}
|
164 |
+
|
165 |
+
return $installments;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Retorna o menor valor de parcela sem juros possível,
|
170 |
+
* de acordo o número máximo de parcelas sem juros.
|
171 |
+
*/
|
172 |
+
public function getMinParcelWithoutRate($valor_total_orig, $parcelas_sem_juros = 0, $recalcula = false, $juros = 0.0199) {
|
173 |
+
|
174 |
+
$minParcelValue = 0;
|
175 |
+
$parcels = 1;
|
176 |
+
|
177 |
+
if ($valor_total_orig > self::PARCEL_MAX_VALUE) {
|
178 |
+
|
179 |
+
for (; $parcels <= $parcelas_sem_juros; $parcels++) {
|
180 |
+
list($valor_total, $valor_parcela) = $this->calculateRate($valor_total_orig, $parcelas_sem_juros, $parcels, $recalcula, $juros);
|
181 |
+
if ($parcels > 1 and $valor_parcela < self::PARCEL_MAX_VALUE) {
|
182 |
+
break;
|
183 |
+
} else {
|
184 |
+
$minParcelValue = $valor_parcela;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
$parcels--;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
$minParcelValue = number_format($minParcelValue, 2, ",", "");
|
192 |
+
|
193 |
+
return array($minParcelValue, $parcels);
|
194 |
+
}
|
195 |
+
|
196 |
+
public function ceiling($value, $precision = 0) {
|
197 |
+
return ceil($value * pow(10, $precision)) / pow(10, $precision);
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* trataTelefone
|
202 |
+
*
|
203 |
+
* @param string $tel Telefone a ser tratado
|
204 |
+
*
|
205 |
+
* @return array
|
206 |
+
*/
|
207 |
+
function trataTelefone($tel)
|
208 |
+
{
|
209 |
+
$numeros = preg_replace('/\D/','', $tel);
|
210 |
+
$tel = substr($numeros, sizeof($numeros)-9);
|
211 |
+
$ddd = substr($numeros, sizeof($numeros)-11,2);
|
212 |
+
return array($ddd, $tel);
|
213 |
+
}
|
214 |
+
|
215 |
+
public function formatDate($date)
|
216 |
+
{
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
*
|
222 |
+
* Registry any event/error log.
|
223 |
+
*
|
224 |
+
* @return OsStudios_PagSeguro_Helper_Data
|
225 |
+
*
|
226 |
+
* @param string $message
|
227 |
+
*/
|
228 |
+
public function log($message)
|
229 |
+
{
|
230 |
+
Mage::getModel('pagseguro/data')->log($message);
|
231 |
+
return $this;
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
/**
|
236 |
+
*
|
237 |
+
* Checks if the content is an XML file
|
238 |
+
* @param (mixed) $content
|
239 |
+
* @return (bool)
|
240 |
+
*/
|
241 |
+
public function isXml($content)
|
242 |
+
{
|
243 |
+
libxml_use_internal_errors(true);
|
244 |
+
$doc = new DOMDocument('1.0', 'utf-8');
|
245 |
+
$doc->loadXML($content);
|
246 |
+
|
247 |
+
$errors = libxml_get_errors();
|
248 |
+
if (empty($errors))
|
249 |
+
{
|
250 |
+
return true;
|
251 |
+
}
|
252 |
+
return false;
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
app/code/community/OsStudios/PagSeguro/Helper/Visie.php
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Payment Data Helper
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Helper_Visie extends Mage_Core_Helper_Abstract
|
24 |
+
{
|
25 |
+
|
26 |
+
/**
|
27 |
+
* convertNumber
|
28 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
29 |
+
*
|
30 |
+
* Converte número para padrão numérico
|
31 |
+
*
|
32 |
+
* @param string|int|double $number Numero que deseja converter
|
33 |
+
*
|
34 |
+
* @return double
|
35 |
+
*/
|
36 |
+
function convertNumber ($number)
|
37 |
+
{
|
38 |
+
$number = preg_replace('/\D/', '', $number) / 100;
|
39 |
+
return (double) str_replace(',', '.', $number);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* formatNumber
|
44 |
+
*
|
45 |
+
* Formata número para envio ao PagSeguro
|
46 |
+
*
|
47 |
+
* @param int|double $number Numero que deseja converter
|
48 |
+
*
|
49 |
+
* @return int
|
50 |
+
*/
|
51 |
+
function formatNumber ($number)
|
52 |
+
{
|
53 |
+
return sprintf('%.2f', (double) $number) * 100;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* trataEndereco
|
58 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
59 |
+
*
|
60 |
+
* @param string $end Endereço a ser tratado
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
function trataEndereco($end) {
|
65 |
+
$numeros = $this->dados('numeros');
|
66 |
+
$complementos = $this->dados('complementos');
|
67 |
+
if ($this->ehBrasilia($end)) {
|
68 |
+
$numero = 's/nº';
|
69 |
+
list($endereco, $complemento) = $this->brasiliaSeparaComplemento($end);
|
70 |
+
} else {
|
71 |
+
$endereco = $end;
|
72 |
+
$numero = 's/nº';
|
73 |
+
$complemento = '';
|
74 |
+
$quebrado = preg_split('/[-,]/', $end);
|
75 |
+
if (sizeof($quebrado) == 3){
|
76 |
+
list($endereco, $numero, $complemento) = $quebrado;
|
77 |
+
} elseif (sizeof($quebrado) == 2) {
|
78 |
+
list($endereco, $numero) = $quebrado;
|
79 |
+
} else {
|
80 |
+
list($endereco, $numero) = $this->buscaReversa($end);
|
81 |
+
}
|
82 |
+
$endereco = $this->tiraNumeroFinal($endereco);
|
83 |
+
if ($complemento == '')
|
84 |
+
list($numerob,$complemento) = $this->separaNumeroComplemento($numero);
|
85 |
+
}
|
86 |
+
return array($this->endtrim($endereco), $this->endtrim($numero), $this->endtrim($complemento));
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* separaNumeroComplemento
|
91 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
92 |
+
*
|
93 |
+
* @param string $n Número a ser tratado
|
94 |
+
*
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
function separaNumeroComplemento($n) {
|
98 |
+
$semnumeros = $this->dados('semnumeros');
|
99 |
+
$n = $this->endtrim($n);
|
100 |
+
foreach ($semnumeros as $sn) {
|
101 |
+
if ($n == $sn)return array($n, '');
|
102 |
+
if (substr($n, 0, strlen($sn)) == $sn)
|
103 |
+
return array(substr($n, 0, strlen($sn)), substr($n, strlen($sn)));
|
104 |
+
}
|
105 |
+
$q = preg_split('/\D/', $n);
|
106 |
+
$pos = strlen($q[0]);
|
107 |
+
return array(substr($n, 0, $pos), substr($n,$pos));
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* endtrim
|
112 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
113 |
+
*
|
114 |
+
* Remove caracteres e espaços desnecessários
|
115 |
+
*
|
116 |
+
* @param string|int|double $e Texto que deseja alterar
|
117 |
+
*
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
function endtrim($e){
|
121 |
+
return preg_replace('/^\W+|\W+$/', '', $e);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* brasiliaSeparaComplemento
|
126 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
127 |
+
*
|
128 |
+
* @param string $end Endereço a ser tratado
|
129 |
+
*
|
130 |
+
* @return array
|
131 |
+
*/
|
132 |
+
function brasiliaSeparaComplemento($end) {
|
133 |
+
$complementos = $this->dados('complementos');
|
134 |
+
foreach ($complementos as $c)
|
135 |
+
if ($pos = strpos(strtolower($end), $c))
|
136 |
+
return array(substr($end, 0 ,$pos), substr($end, $pos));
|
137 |
+
return array($end, '');
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* tiraNumeroFinal
|
142 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
143 |
+
*
|
144 |
+
* @param string $endereco Endereço a ser tratado
|
145 |
+
*
|
146 |
+
* @return string
|
147 |
+
*/
|
148 |
+
function tiraNumeroFinal($endereco) {
|
149 |
+
$numeros = $this->dados('numeros');
|
150 |
+
foreach ($numeros as $n)
|
151 |
+
foreach (array(" $n"," $n ") as $N)
|
152 |
+
if (substr($endereco, -strlen($N)) == $N)
|
153 |
+
return substr($endereco, 0, -strlen($N));
|
154 |
+
return $endereco;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* buscaReversa
|
159 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
160 |
+
*
|
161 |
+
* Encontra o primeiro caractere númerico dentre os últimos 10 da string informada
|
162 |
+
* e retorna a string separada na posição localizada
|
163 |
+
*
|
164 |
+
* @param string $texto Texto a ser procurado
|
165 |
+
*
|
166 |
+
* @return array
|
167 |
+
*/
|
168 |
+
function buscaReversa($texto) {
|
169 |
+
$encontrar = substr($texto, -10);
|
170 |
+
for ($i = 0; $i < 10; $i++) {
|
171 |
+
if (is_numeric(substr($encontrar, $i, 1))) {
|
172 |
+
return array(
|
173 |
+
substr($texto, 0, -10+$i),
|
174 |
+
substr($texto, -10+$i)
|
175 |
+
);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* ehBrasilia
|
182 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
183 |
+
*
|
184 |
+
* @param string $end Endereço a ser analisado
|
185 |
+
*
|
186 |
+
* @return bool
|
187 |
+
*/
|
188 |
+
function ehBrasilia($end) {
|
189 |
+
$brasilias = $this->dados('brasilias');
|
190 |
+
$naobrasilias = $this->dados('naobrasilias');
|
191 |
+
$brasilia = false;
|
192 |
+
foreach ($brasilias as $b)
|
193 |
+
if (strpos(strtolower($end),$b) != false)
|
194 |
+
$brasilia = true;
|
195 |
+
if ($brasilia)
|
196 |
+
foreach ($naobrasilias as $b)
|
197 |
+
if (strpos(strtolower($end),$b) != false)
|
198 |
+
$brasilia = false;
|
199 |
+
return $brasilia;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* dados
|
204 |
+
* (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
|
205 |
+
*
|
206 |
+
* Retorna dados auxiliares de acordo com o argumento passado,
|
207 |
+
* que podem ser:
|
208 |
+
* - 'complementos'
|
209 |
+
* - 'brasilias'
|
210 |
+
* - 'naobrasilias'
|
211 |
+
* - 'sems'
|
212 |
+
* - 'numeros'
|
213 |
+
* - 'semnumeros'
|
214 |
+
*
|
215 |
+
* @param string $v Código para escolha do retorno
|
216 |
+
*
|
217 |
+
* @return array
|
218 |
+
*/
|
219 |
+
function dados($v) {
|
220 |
+
|
221 |
+
$dados = array();
|
222 |
+
$dados['complementos'] = array("casa", "ap", "apto", "apart", "frente", "fundos", "sala", "cj");
|
223 |
+
$dados['brasilias'] = array("bloco", "setor", "quadra", "lote");
|
224 |
+
$dados['naobrasilias'] = array("av", "avenida", "rua", "alameda", "al.", "travessa", "trv", "praça", "praca");
|
225 |
+
$dados['sems'] = array("sem ", "s.", "s/", "s. ", "s/ ");
|
226 |
+
$dados['numeros'] = array('n.º', 'nº', "numero", "num", "número", "núm", "n");
|
227 |
+
$dados['semnumeros'] = array();
|
228 |
+
|
229 |
+
foreach ($dados['numeros'] as $n)
|
230 |
+
foreach ($dados['sems'] as $s)
|
231 |
+
$dados['semnumeros'][] = "$s$n";
|
232 |
+
return $dados[$v];
|
233 |
+
}
|
234 |
+
|
235 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Abstract.php
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
abstract class OsStudios_PagSeguro_Model_Abstract extends Mage_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
const PAGSEGURO_DATE_FORMAT = 'Y-m-d\TH:i';
|
22 |
+
const PAGSEGURO_LOG_FILENAME = 'osstudios_pagseguro.log';
|
23 |
+
const PAGSEGURO_LOG_FILENAME_POSTS = 'osstudios_pagseguro_return_posts.log';
|
24 |
+
|
25 |
+
protected $_configPrefix = 'payment/pagseguro_config/';
|
26 |
+
protected $_credentials = null;
|
27 |
+
protected $_store = null;
|
28 |
+
protected $_coreDate = null;
|
29 |
+
protected $_allowedLogTypes = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Retrieve information from PagSeguro configuration
|
33 |
+
*
|
34 |
+
* @param string $field
|
35 |
+
* @return mixed
|
36 |
+
*/
|
37 |
+
protected function getConfigData($field, $storeId = null)
|
38 |
+
{
|
39 |
+
if (null === $storeId) {
|
40 |
+
$storeId = $this->getStore();
|
41 |
+
}
|
42 |
+
$path = $this->_configPrefix.$field;
|
43 |
+
|
44 |
+
return Mage::getStoreConfig($path, $storeId);
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Registry any event/error log.
|
50 |
+
*
|
51 |
+
* @return OsStudios_PagSeguro_Model_Payment
|
52 |
+
*
|
53 |
+
* @param string $message
|
54 |
+
* @param integer $level
|
55 |
+
* @param string $file
|
56 |
+
* @param bool $forceLog
|
57 |
+
*/
|
58 |
+
public function log($content, $level = null, $file = self::PAGSEGURO_LOG_FILENAME, $forceLog = false)
|
59 |
+
{
|
60 |
+
if(Mage::getStoreConfig('payment/pagseguro_config/log_enable', $this->getStore())) {
|
61 |
+
if( !empty($content) ) {
|
62 |
+
if( is_array($content) || is_object($content)) {
|
63 |
+
Mage::log($content, $level, $file, $forceLog);
|
64 |
+
} else {
|
65 |
+
Mage::log("PagSeguro: " . $content, $level, $file, $forceLog);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns core date model from Magento
|
76 |
+
*
|
77 |
+
* @return Mage_Core_Model_Date
|
78 |
+
*/
|
79 |
+
protected function getCoreDate()
|
80 |
+
{
|
81 |
+
if(!$this->_coreDate) {
|
82 |
+
$this->_coreDate = Mage::getModel('core/date');
|
83 |
+
}
|
84 |
+
return $this->_coreDate;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns the Current Store
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getStore()
|
94 |
+
{
|
95 |
+
if(!$this->_store) {
|
96 |
+
$this->_store = Mage::app()->getStore();
|
97 |
+
}
|
98 |
+
return $this->_store;
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Returns the URL for payments on PagSeguro
|
104 |
+
*
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function getPagSeguroUrl()
|
108 |
+
{
|
109 |
+
$url = $this->getConfigData('pagseguro_url');
|
110 |
+
if(!$url) {
|
111 |
+
Mage::throwException( Mage::helper('pagseguro')->__('The PagSeguro URL could not be retrieved.') );
|
112 |
+
}
|
113 |
+
|
114 |
+
return $url;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Returns the Payment Notification URL of PagSeguro
|
120 |
+
*
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getPagSeguroNPIUrl()
|
124 |
+
{
|
125 |
+
$url = $this->getConfigData('pagseguro_npi_url');
|
126 |
+
if(!$url) {
|
127 |
+
Mage::throwException( Mage::helper('pagseguro')->__('The PagSeguro NPI URL could not be retrieved.') );
|
128 |
+
}
|
129 |
+
return $url;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Returns the URL to generate the billets of PagSeguro
|
135 |
+
*
|
136 |
+
* @param string $transactionId = PagSeguro Transaction ID
|
137 |
+
* @return (string)
|
138 |
+
*/
|
139 |
+
public function getPagSeguroBoletoUrl($transactionId, $escapeHtml = true)
|
140 |
+
{
|
141 |
+
$url = $this->getConfigData('pagseguro_billet_url');
|
142 |
+
if(!$url) {
|
143 |
+
Mage::throwException( Mage::helper('pagseguro')->__('The PagSeguro Billet URL could not be retrieved.') );
|
144 |
+
}
|
145 |
+
|
146 |
+
$url .= '?resizeBooklet=n&code=' . $transactionId;
|
147 |
+
if ($escapeHtml) {
|
148 |
+
$url = Mage::helper('pagseguro')->escapeHtml($url);
|
149 |
+
}
|
150 |
+
return $url;
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
*
|
156 |
+
* Returns transactions URL
|
157 |
+
* @return (string)
|
158 |
+
*/
|
159 |
+
public function getPagSeguroTransactionsUrl()
|
160 |
+
{
|
161 |
+
$url = $this->getConfigData('pagseguro_transactions_url');
|
162 |
+
if(!$url) {
|
163 |
+
Mage::throwException(Mage::helper('pagseguro')->__('Unable to retrieve transactions URL from module configuration.'));
|
164 |
+
}
|
165 |
+
return $url;
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Returns credentials
|
171 |
+
*
|
172 |
+
* @return OsStudios_PagSeguro_Model_Credentials
|
173 |
+
*/
|
174 |
+
protected function getCredentials()
|
175 |
+
{
|
176 |
+
if(!$this->_credentials) {
|
177 |
+
$this->_credentials = Mage::getModel('pagseguro/credentials');
|
178 |
+
}
|
179 |
+
return $this->_credentials;
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Get helper
|
185 |
+
*
|
186 |
+
* @return OsStudios_PagSeguro_Helper_Data
|
187 |
+
*/
|
188 |
+
protected function helper()
|
189 |
+
{
|
190 |
+
return Mage::helper('pagseguro');
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Extends translation functionality
|
196 |
+
*
|
197 |
+
* @return (string)
|
198 |
+
*/
|
199 |
+
protected function __($string)
|
200 |
+
{
|
201 |
+
$args = func_get_args();
|
202 |
+
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'pagseguro');
|
203 |
+
array_unshift($args, $expr);
|
204 |
+
return Mage::app()->getTranslator()->translate($args);
|
205 |
+
}
|
206 |
+
|
207 |
+
protected function _redirect($path = '', $params = array())
|
208 |
+
{
|
209 |
+
Mage::app()->getResponse()->setRedirect(Mage::getUrl($path, $params));
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Loads some order by order increment id as reference
|
215 |
+
*
|
216 |
+
* @param (string) $incrementId
|
217 |
+
* @return Mage_Sales_Model_Order
|
218 |
+
*/
|
219 |
+
protected function loadOrderByIncrementId($incrementId = null)
|
220 |
+
{
|
221 |
+
if($incrementId) {
|
222 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
223 |
+
|
224 |
+
if($order->hasData())
|
225 |
+
{
|
226 |
+
return $order;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
return null;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Check if some log is allowed
|
235 |
+
*
|
236 |
+
* @param unknown_type $type
|
237 |
+
*/
|
238 |
+
protected function isLogTypeAllowed($type = null)
|
239 |
+
{
|
240 |
+
if(!$this->_allowedLogTypes)
|
241 |
+
{
|
242 |
+
$data = $this->getConfigData('log_types');
|
243 |
+
$data = explode(',', $data);
|
244 |
+
$this->_allowedLogTypes = $data;
|
245 |
+
}
|
246 |
+
|
247 |
+
if($this->_allowedLogTypes) {
|
248 |
+
return in_array($type, $this->_allowedLogTypes);
|
249 |
+
} else {
|
250 |
+
return null;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Credentials.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Credentials extends OsStudios_PagSeguro_Model_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* PagSeguro Account E-mail
|
24 |
+
* @var (string)
|
25 |
+
*/
|
26 |
+
protected $_accountEmail = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* PagSeguro Account Token
|
31 |
+
* @var (string)
|
32 |
+
*/
|
33 |
+
protected $_token = null;
|
34 |
+
|
35 |
+
public function __construct()
|
36 |
+
{
|
37 |
+
parent::__construct();
|
38 |
+
|
39 |
+
$this->_accountEmail = $this->getConfigData('account_email');
|
40 |
+
$this->_token = $this->getConfigData('token');
|
41 |
+
|
42 |
+
$data = array('account_email' => $this->_accountEmail, 'token' => $this->_token);
|
43 |
+
|
44 |
+
$this->setData($data);
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Data.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Data extends OsStudios_PagSeguro_Model_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
public function isReturnApi($post)
|
22 |
+
{
|
23 |
+
if( isset($post['notificationCode']) && isset($post['notificationType']) ) {
|
24 |
+
return true;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
public function isReturnDefault($post)
|
29 |
+
{
|
30 |
+
if( isset($post['VendedorEmail']) && isset($post['TransacaoID']) && isset($post['Referencia']) && isset($post['DataTransacao']) &&
|
31 |
+
isset($post['TipoPagamento']) && isset($post['StatusTransacao']) && isset($post['CliNome']) && isset($post['CliEmail']) &&
|
32 |
+
isset($post['CliEndereco']) && isset($post['CliCidade']) && isset($post['CliEstado']) && isset($post['CliCEP']) &&
|
33 |
+
isset($post['CliTelefone']) && isset($post['NumItens']) && isset($post['Parcelas']) )
|
34 |
+
{
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Hpp.php
ADDED
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Hpp extends OsStudios_PagSeguro_Model_Payment
|
19 |
+
{
|
20 |
+
|
21 |
+
protected $_code = 'pagseguro_hpp';
|
22 |
+
protected $_formBlockType = 'pagseguro/form';
|
23 |
+
protected $_infoBlockType = 'pagseguro/info';
|
24 |
+
|
25 |
+
protected $_canUseInternal = true;
|
26 |
+
protected $_canUseForMultishipping = false;
|
27 |
+
protected $_canCapture = true;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* Set the $_POST information
|
33 |
+
*
|
34 |
+
* @param Mage_Core_Controller_Request_Http $post
|
35 |
+
*/
|
36 |
+
public function setPostData(Mage_Core_Controller_Request_Http $request)
|
37 |
+
{
|
38 |
+
$post = $request->getPost();
|
39 |
+
|
40 |
+
$this->setPost($post);
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
*
|
47 |
+
* Process before processReturn method.
|
48 |
+
*
|
49 |
+
* @return OsStudios_PagSeguro_Model_Payment
|
50 |
+
*
|
51 |
+
* @uses $this->log()
|
52 |
+
*/
|
53 |
+
public function _beforeProcessReturn()
|
54 |
+
{
|
55 |
+
$this->log('<!--[ '.Mage::helper('pagseguro')->__('Beginning of Return').' ]-->');
|
56 |
+
|
57 |
+
// Saves $_POST Data
|
58 |
+
$this->log('<!--[ '.Mage::helper('pagseguro')->__('Post Data').' ]-->');
|
59 |
+
$this->log($this->getPost());
|
60 |
+
$this->log('<!--[ '.Mage::helper('pagseguro')->__('End of Post Data').' ]-->');
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
*
|
68 |
+
* Process before processReturn method.
|
69 |
+
*
|
70 |
+
* @return OsStudios_PagSeguro_Model_Payment
|
71 |
+
*
|
72 |
+
* @uses $this->log()
|
73 |
+
*/
|
74 |
+
public function _afterProcessReturn()
|
75 |
+
{
|
76 |
+
$this->log('<!--[ '.Mage::helper('pagseguro')->__('Ending of Return').' ]-->');
|
77 |
+
$this->log(' ----------- >> ----------- ');
|
78 |
+
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* getOrderPlaceRedirectUrl
|
85 |
+
*
|
86 |
+
* Cria a URL de redirecionamento ao PagSeguro, utilizando
|
87 |
+
* o ID do pedido caso este seja informado
|
88 |
+
*
|
89 |
+
* @param int $orderId ID pedido
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getOrderPlaceRedirectUrl($orderId = 0)
|
94 |
+
{
|
95 |
+
$params = array();
|
96 |
+
$params['_secure'] = true;
|
97 |
+
|
98 |
+
if ($orderId != 0 && is_numeric($orderId)) {
|
99 |
+
$params['order_id'] = $orderId;
|
100 |
+
}
|
101 |
+
|
102 |
+
return Mage::getUrl('pagseguro/pay/redirect', $params);
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* createRedirectForm
|
108 |
+
*
|
109 |
+
* Cria o formulário de redirecionamento ao PagSeguro
|
110 |
+
*
|
111 |
+
* @return string
|
112 |
+
*
|
113 |
+
* @uses $this->getCheckoutFormFields()
|
114 |
+
*/
|
115 |
+
public function createRedirectForm()
|
116 |
+
{
|
117 |
+
$form = new Varien_Data_Form();
|
118 |
+
$form->setAction(Mage::getModel('pagseguro/data')->getPagSeguroUrl())
|
119 |
+
->setId('pagseguro_checkout')
|
120 |
+
->setName('pagseguro_checkout')
|
121 |
+
->setMethod('POST')
|
122 |
+
->setUseContainer(true);
|
123 |
+
|
124 |
+
$fields = $this->getCheckoutFormFields();
|
125 |
+
foreach ($fields as $field => $value) {
|
126 |
+
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
|
127 |
+
}
|
128 |
+
|
129 |
+
$submit_script = 'document.getElementById(\'pagseguro_checkout\').submit();';
|
130 |
+
|
131 |
+
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
132 |
+
$html .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="pt-BR">';
|
133 |
+
$html .= '<head>';
|
134 |
+
$html .= '<meta http-equiv="Content-Language" content="pt-br" />';
|
135 |
+
$html .= '<meta name="language" content="pt-br" />';
|
136 |
+
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
|
137 |
+
$html .= '<style type="text/css">';
|
138 |
+
$html .= '* { font-family: Arial; font-size: 16px; line-height: 34px; text-align: center; color: #222222; }';
|
139 |
+
$html .= 'small, a, a:link:visited:active, a:hover { font-size: 13px; line-height: normal; font-style: italic; }';
|
140 |
+
$html .= 'a, a:link:visited:active { font-weight: bold; text-decoration: none; }';
|
141 |
+
$html .= 'a:hover { font-weight: bold; text-decoration: underline; color: #555555; }';
|
142 |
+
$html .= '</style>';
|
143 |
+
$html .= '</head>';
|
144 |
+
$html .= '<body onload="' . $submit_script . '">';
|
145 |
+
$html .= 'Você será redirecionado ao <strong>PagSeguro</strong> em alguns instantes.<br />';
|
146 |
+
$html .= '<small>Se a página não carregar, <a href="#" onclick="' . $submit_script . ' return false;">clique aqui</a>.</small>';
|
147 |
+
$html .= $form->toHtml();
|
148 |
+
$html .= '</body></html>';
|
149 |
+
|
150 |
+
return utf8_decode($html);
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
/**
|
156 |
+
* getCheckoutFormFields
|
157 |
+
*
|
158 |
+
* Gera os campos para o formulário de redirecionamento ao Pagseguro
|
159 |
+
*
|
160 |
+
* @return array
|
161 |
+
*
|
162 |
+
* @uses $this->getOrder()
|
163 |
+
*/
|
164 |
+
public function getCheckoutFormFields()
|
165 |
+
{
|
166 |
+
$order = $this->getOrder();
|
167 |
+
|
168 |
+
// Utiliza endereço de cobrança caso produto seja virtual/para download
|
169 |
+
$address = $order->getIsVirtual() ? $order->getBillingAddress() : $order->getShippingAddress();
|
170 |
+
|
171 |
+
// Resgata CEP
|
172 |
+
$cep = preg_replace('@[^\d]@', '', $address->getPostcode());
|
173 |
+
|
174 |
+
// Dados de endereço
|
175 |
+
if ($this->getConfigData('custom_address_model', $order->getStoreId())) {
|
176 |
+
$endereco = $address->getStreet(1);
|
177 |
+
$numero = $address->getStreet(2);
|
178 |
+
$complemento = $address->getStreet(3);
|
179 |
+
$bairro = $address->getStreet(4);
|
180 |
+
} else {
|
181 |
+
list($endereco, $numero, $complemento) = Mage::helper('pagseguro')->trataEndereco($address->getStreet(1));
|
182 |
+
$bairro = $address->getStreet(2);
|
183 |
+
}
|
184 |
+
|
185 |
+
// Formata o telefone
|
186 |
+
list($ddd, $telefone) = Mage::helper('pagseguro')->trataTelefone($address->getTelephone());
|
187 |
+
|
188 |
+
// Monta os dados para o formulário
|
189 |
+
$sArr = array(
|
190 |
+
//'encoding' => 'utf-8',
|
191 |
+
//'email_cobranca' => $this->getConfigData('account_email', $order->getStoreId()),
|
192 |
+
'email_cobranca' => Mage::getStoreConfig('payment/pagseguro_config/account_email', $order->getStoreId()),
|
193 |
+
'Tipo' => "CP",
|
194 |
+
'Moeda' => "BRL",
|
195 |
+
'ref_transacao' => $order->getRealOrderId(),
|
196 |
+
'cliente_nome' => $address->getFirstname() . ' ' . $address->getLastname(),
|
197 |
+
'cliente_cep' => $cep,
|
198 |
+
'cliente_end' => $endereco,
|
199 |
+
'cliente_num' => $numero,
|
200 |
+
'cliente_compl' => $complemento,
|
201 |
+
'cliente_bairro' => $bairro,
|
202 |
+
'cliente_cidade' => $address->getCity(),
|
203 |
+
'cliente_uf' => $address->getRegionCode(),
|
204 |
+
'cliente_pais' => $address->getCountry(),
|
205 |
+
'cliente_ddd' => $ddd,
|
206 |
+
'cliente_tel' => $telefone,
|
207 |
+
'cliente_email' => $order->getCustomerEmail(),
|
208 |
+
);
|
209 |
+
|
210 |
+
|
211 |
+
$i = 1;
|
212 |
+
$items = $order->getAllVisibleItems();
|
213 |
+
|
214 |
+
$shipping_amount = $order->getBaseShippingAmount();
|
215 |
+
$tax_amount = $order->getBaseTaxAmount();
|
216 |
+
$discount_amount = $order->getBaseDiscountAmount();
|
217 |
+
|
218 |
+
$priceGrouping = $this->getConfigData('price_grouping', $order->getStoreId());
|
219 |
+
$shippingPrice = $this->getConfigData('shipping_price', $order->getStoreId());
|
220 |
+
|
221 |
+
if ($priceGrouping) {
|
222 |
+
|
223 |
+
$order_total = $order->getBaseSubtotal() + $tax_amount + $discount_amount;
|
224 |
+
if ($shippingPrice == 'grouped') {
|
225 |
+
$order_total += $shipping_amount;
|
226 |
+
}
|
227 |
+
$item_descr = $order->getStoreName(2) . " - Pedido " . $order->getRealOrderId();
|
228 |
+
$item_price = Mage::helper('pagseguro')->formatNumber($order_total);
|
229 |
+
$sArr = array_merge($sArr, array(
|
230 |
+
'item_descr_'.$i => substr($item_descr, 0, 100),
|
231 |
+
'item_id_'.$i => $order->getRealOrderId(),
|
232 |
+
'item_quant_'.$i => 1,
|
233 |
+
'item_valor_'.$i => $item_price,
|
234 |
+
));
|
235 |
+
$i++;
|
236 |
+
|
237 |
+
} else {
|
238 |
+
|
239 |
+
if ($items) {
|
240 |
+
foreach ($items as $item) {
|
241 |
+
$item_price = 0;
|
242 |
+
$item_qty = $item->getQtyOrdered() * 1;
|
243 |
+
if ($children = $item->getChildrenItems()) {
|
244 |
+
foreach ($children as $child) {
|
245 |
+
$item_price += $child->getBasePrice() * $child->getQtyOrdered() / $item_qty;
|
246 |
+
}
|
247 |
+
$item_price = Mage::helper('pagseguro')->formatNumber($item_price);
|
248 |
+
}
|
249 |
+
if (!$item_price) {
|
250 |
+
$item_price = Mage::helper('pagseguro')->formatNumber($item->getBasePrice());
|
251 |
+
}
|
252 |
+
$sArr = array_merge($sArr, array(
|
253 |
+
'item_descr_'.$i => substr($item->getName(), 0, 100),
|
254 |
+
'item_id_'.$i => substr($item->getSku(), 0, 100),
|
255 |
+
'item_quant_'.$i => $item_qty,
|
256 |
+
'item_valor_'.$i => $item_price,
|
257 |
+
));
|
258 |
+
$i++;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
if ($tax_amount > 0) {
|
263 |
+
$tax_amount = Mage::helper('pagseguro')->formatNumber($tax_amount);
|
264 |
+
$sArr = array_merge($sArr, array(
|
265 |
+
'item_descr_'.$i => "Taxa",
|
266 |
+
'item_id_'.$i => "taxa",
|
267 |
+
'item_quant_'.$i => 1,
|
268 |
+
'item_valor_'.$i => $tax_amount,
|
269 |
+
));
|
270 |
+
$i++;
|
271 |
+
}
|
272 |
+
|
273 |
+
if ($discount_amount != 0) {
|
274 |
+
$discount_amount = Mage::helper('pagseguro')->formatNumber($discount_amount);
|
275 |
+
if (preg_match("/^1\.[23]/i", Mage::getVersion())) {
|
276 |
+
$discount_amount = -$discount_amount;
|
277 |
+
}
|
278 |
+
$sArr = array_merge($sArr, array(
|
279 |
+
'extras' => $discount_amount,
|
280 |
+
));
|
281 |
+
}
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
if ($shipping_amount > 0) {
|
286 |
+
$shipping_amount = Mage::helper('pagseguro')->formatNumber($shipping_amount);
|
287 |
+
switch ($shippingPrice) {
|
288 |
+
case 'grouped':
|
289 |
+
if ($priceGrouping) {
|
290 |
+
break;
|
291 |
+
}
|
292 |
+
case 'product':
|
293 |
+
// passa o valor do frete como um produto
|
294 |
+
$sArr = array_merge($sArr, array(
|
295 |
+
'item_descr_'.$i => substr($order->getShippingDescription(), 0, 100),
|
296 |
+
'item_id_'.$i => "frete",
|
297 |
+
'item_quant_'.$i => 1,
|
298 |
+
'item_valor_'.$i => $shipping_amount,
|
299 |
+
));
|
300 |
+
$i++;
|
301 |
+
break;
|
302 |
+
|
303 |
+
case 'separated':
|
304 |
+
default:
|
305 |
+
// passa o valor do frete separadamente
|
306 |
+
$sArr = array_merge($sArr, array('item_frete_1' => $shipping_amount));
|
307 |
+
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
$rArr = array();
|
312 |
+
foreach ($sArr as $k => $v) {
|
313 |
+
// troca caractere '&' por 'e'
|
314 |
+
$value = str_replace("&", "e", $v);
|
315 |
+
$rArr[$k] = $value;
|
316 |
+
}
|
317 |
+
|
318 |
+
return $rArr;
|
319 |
+
}
|
320 |
+
|
321 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Observer.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Observer
|
19 |
+
{
|
20 |
+
|
21 |
+
public function cronConsultOrderStates()
|
22 |
+
{
|
23 |
+
$returns = Mage::getModel('pagseguro/returns');
|
24 |
+
$returns->setReturnType(OsStudios_PagSeguro_Model_Returns::PAGSEGURO_RETURN_TYPE_CONSULT)
|
25 |
+
->runReturns();
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Payment.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
abstract class OsStudios_PagSeguro_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* Current order
|
23 |
+
* @var Mage_Sales_Model_Order
|
24 |
+
*/
|
25 |
+
protected $_order = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* Status: Complete
|
30 |
+
* @var (string)
|
31 |
+
*/
|
32 |
+
const PAGSEGURO_STATUS_COMPLETE = 'Completo';
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* Status: Waiting for Payment
|
37 |
+
* @var (string)
|
38 |
+
*/
|
39 |
+
const PAGSEGURO_STATUS_WAITING_PAYMENT = 'Aguardando Pagto';
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* Status: Approved
|
44 |
+
* @var (string)
|
45 |
+
*/
|
46 |
+
const PAGSEGURO_STATUS_APPROVED = 'Aprovado';
|
47 |
+
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* Status: In Analysis
|
51 |
+
* @var (string)
|
52 |
+
*/
|
53 |
+
const PAGSEGURO_STATUS_ANALYSING = 'Em Análise';
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* Status: Canceled
|
58 |
+
* @var (string)
|
59 |
+
*/
|
60 |
+
const PAGSEGURO_STATUS_CANCELED = 'Cancelado';
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* Status: Returned
|
65 |
+
* @var (string)
|
66 |
+
*/
|
67 |
+
const PAGSEGURO_STATUS_RETURNED = 'Devolvido';
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Return Order
|
72 |
+
*
|
73 |
+
* @return Mage_Sales_Model_Order
|
74 |
+
*/
|
75 |
+
public function getOrder()
|
76 |
+
{
|
77 |
+
if ($this->_order == null) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
return $this->_order;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
*
|
86 |
+
* Set Current Order
|
87 |
+
*
|
88 |
+
* @param Mage_Sales_Model_Order $order
|
89 |
+
*/
|
90 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
91 |
+
{
|
92 |
+
if(!$this->_order)
|
93 |
+
{
|
94 |
+
$this->_order = $order;
|
95 |
+
}
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
*
|
101 |
+
* Registry any event/error log.
|
102 |
+
*
|
103 |
+
* @return OsStudios_PagSeguro_Model_Payment
|
104 |
+
*
|
105 |
+
* @param string $message
|
106 |
+
*/
|
107 |
+
public function log($message)
|
108 |
+
{
|
109 |
+
Mage::getModel('pagseguro/data')->log($message);
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns.php
ADDED
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns extends OsStudios_PagSeguro_Model_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
const PAGSEGURO_RETURN_RESPONSE_SUCCESS = true;
|
22 |
+
const PAGSEGURO_RETURN_RESPONSE_FAIL = false;
|
23 |
+
const PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED = 'Unauthorized';
|
24 |
+
const PAGSEGURO_RETURN_RESPONSE_AUTHORIZED = 'Authorized';
|
25 |
+
const PAGSEGURO_RETURN_RESPONSE_ERROR = 'Process Error';
|
26 |
+
|
27 |
+
const TABS = ' ';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Default return from PagSeguro
|
31 |
+
*
|
32 |
+
* @var (int)
|
33 |
+
*/
|
34 |
+
const PAGSEGURO_RETURN_TYPE_DEFAULT = 1;
|
35 |
+
const PAGSEGURO_RETURN_TYPE_DEFAULT_STRING = 'Default Return';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Api return from PagSeguro
|
39 |
+
*
|
40 |
+
* @var (int)
|
41 |
+
*/
|
42 |
+
const PAGSEGURO_RETURN_TYPE_API = 2;
|
43 |
+
const PAGSEGURO_RETURN_TYPE_API_STRING = 'Api Return';
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Request a consult in PagSeguro
|
47 |
+
*
|
48 |
+
* @var (int)
|
49 |
+
*/
|
50 |
+
const PAGSEGURO_RETURN_TYPE_CONSULT = 3;
|
51 |
+
const PAGSEGURO_RETURN_TYPE_CONSULT_STRING = 'Consulting Return';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Handle the return type
|
55 |
+
*
|
56 |
+
* @var (const)
|
57 |
+
*/
|
58 |
+
protected $_returnType = null;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Handle the post information
|
62 |
+
*
|
63 |
+
* @var (mixed)
|
64 |
+
*/
|
65 |
+
protected $_post = null;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Handle the process result
|
69 |
+
*
|
70 |
+
* @var (bool)
|
71 |
+
*/
|
72 |
+
protected $_success = false;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Handle the response result
|
76 |
+
*
|
77 |
+
* @var (mixed)
|
78 |
+
*/
|
79 |
+
protected $_response = null;
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Sets the post data
|
84 |
+
*
|
85 |
+
* @param (mixed) $post
|
86 |
+
* @return OsStudios_PagSeguro_Model_Returns
|
87 |
+
*/
|
88 |
+
public function setPostData($post)
|
89 |
+
{
|
90 |
+
$this->_post = $post;
|
91 |
+
$this->setPost($this->_post);
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Sets the return type
|
98 |
+
*
|
99 |
+
* @param (int) $type
|
100 |
+
* @return OsStudios_PagSeguro_Model_Returns
|
101 |
+
*/
|
102 |
+
public function setReturnType($type = self::PAGSEGURO_RETURN_TYPE_DEFAULT)
|
103 |
+
{
|
104 |
+
$this->_returnType = $type;
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Return true if the returned has processed
|
111 |
+
*
|
112 |
+
* @return (bool)
|
113 |
+
*/
|
114 |
+
public function isSuccess()
|
115 |
+
{
|
116 |
+
return $this->_success;
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Return response of the return
|
122 |
+
*
|
123 |
+
* @return (bool)
|
124 |
+
*/
|
125 |
+
public function getResponse()
|
126 |
+
{
|
127 |
+
return $this->_response;
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Runs before validation
|
133 |
+
*/
|
134 |
+
protected function _beforeValidate()
|
135 |
+
{
|
136 |
+
$this->log($this->__('%sInitializing validation.', self::TABS));
|
137 |
+
$this->log($this->__('%s-- ***** --.', self::TABS));
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Runs after validation
|
143 |
+
*/
|
144 |
+
protected function _afterValidate()
|
145 |
+
{
|
146 |
+
$this->log($this->__('%s-- ***** --.', self::TABS));
|
147 |
+
$this->log($this->__('%sFinishing validation.', self::TABS));
|
148 |
+
}
|
149 |
+
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Runs before validation
|
153 |
+
*/
|
154 |
+
protected function _beforeReturns()
|
155 |
+
{
|
156 |
+
$this->log($this->__('Initializing return.'));
|
157 |
+
$this->log($this->__('-- ***** --.'));
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Runs after validation
|
163 |
+
*/
|
164 |
+
protected function _afterReturns()
|
165 |
+
{
|
166 |
+
$this->log($this->__('-- ***** --.'));
|
167 |
+
$this->log($this->__('Finishing return.'));
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Validates the received post in PagSeguro
|
173 |
+
*
|
174 |
+
* @return (int)
|
175 |
+
*/
|
176 |
+
protected function _validate()
|
177 |
+
{
|
178 |
+
$this->_beforeValidate();
|
179 |
+
|
180 |
+
$post = $this->getPost();
|
181 |
+
|
182 |
+
$this->log($this->__('%sValidation Post Source:', self::TABS));
|
183 |
+
$this->log($post);
|
184 |
+
|
185 |
+
if( !empty($post)) {
|
186 |
+
|
187 |
+
$credentials = Mage::getModel('pagseguro/credentials');
|
188 |
+
|
189 |
+
$post['encoding'] = 'utf-8';
|
190 |
+
$post['Comando'] = 'validar';
|
191 |
+
$post['Token'] = $credentials->getToken();
|
192 |
+
|
193 |
+
$client = new Zend_Http_Client($this->getPagSeguroNPIUrl());
|
194 |
+
|
195 |
+
if( $this->getConfigData('use_curl') ) {
|
196 |
+
$adapter = new Zend_Http_Client_Adapter_Curl();
|
197 |
+
|
198 |
+
$config = array('timeout' => 30,
|
199 |
+
'curloptions' => array(
|
200 |
+
CURLOPT_SSL_VERIFYPEER => false
|
201 |
+
));
|
202 |
+
$adapter->setConfig($config);
|
203 |
+
$client->setAdapter($adapter);
|
204 |
+
}
|
205 |
+
|
206 |
+
try {
|
207 |
+
|
208 |
+
$client->setMethod(Zend_Http_Client::POST)
|
209 |
+
->setParameterPost($post);
|
210 |
+
|
211 |
+
$content = $client->request();
|
212 |
+
$return = $content->getBody();
|
213 |
+
|
214 |
+
$this->log($this->__('%sValidation Result: %s.', self::TABS, $return));
|
215 |
+
|
216 |
+
} catch (Mage_Core_Exception $e) {
|
217 |
+
$this->log($this->__('%sValidation Error: %s.', self::TABS, $e->getMessage()));
|
218 |
+
} catch (Exception $e) {
|
219 |
+
$this->log($this->__('%sValidation Error: %s.', self::TABS, $e->getMessage()));
|
220 |
+
}
|
221 |
+
|
222 |
+
$result = (strcmp($return, 'VERIFICADO') == 0);
|
223 |
+
}
|
224 |
+
|
225 |
+
$this->_afterValidate();
|
226 |
+
|
227 |
+
return $result;
|
228 |
+
//return true;
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Identifies and process the correct return
|
234 |
+
*
|
235 |
+
* @return OsStudios_PagSeguro_Model_Returns
|
236 |
+
*/
|
237 |
+
public function runReturns()
|
238 |
+
{
|
239 |
+
|
240 |
+
$this->_beforeReturns();
|
241 |
+
|
242 |
+
$type = $this->_returnType;
|
243 |
+
$post = $this->getPost();
|
244 |
+
|
245 |
+
$this->log($post, null, self::PAGSEGURO_LOG_FILENAME_POSTS);
|
246 |
+
|
247 |
+
switch ($type)
|
248 |
+
{
|
249 |
+
/**
|
250 |
+
* Returns from PagSeguro API
|
251 |
+
*/
|
252 |
+
case self::PAGSEGURO_RETURN_TYPE_API:
|
253 |
+
|
254 |
+
if($this->getConfigData('return_api_enable')) {
|
255 |
+
$this->log($this->__('%sReturn Type: %s.', self::TABS, self::PAGSEGURO_RETURN_TYPE_API_STRING));
|
256 |
+
|
257 |
+
$model = Mage::getModel('pagseguro/returns_types_api');
|
258 |
+
$this->_response = $model->setPostData($post)->processReturn()->getResponse();
|
259 |
+
|
260 |
+
$errArray = array(self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED, self::PAGSEGURO_RETURN_RESPONSE_ERROR);
|
261 |
+
|
262 |
+
if(in_array($this->_response, $errArray)) {
|
263 |
+
$this->_success = false;
|
264 |
+
} else {
|
265 |
+
$this->_success = true;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
break;
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Self consulting
|
272 |
+
*/
|
273 |
+
case self::PAGSEGURO_RETURN_TYPE_CONSULT:
|
274 |
+
|
275 |
+
$this->log($this->__('%sReturn Type: %s.', self::TABS, self::PAGSEGURO_RETURN_TYPE_CONSULT_STRING));
|
276 |
+
|
277 |
+
$stop = false;
|
278 |
+
|
279 |
+
$model = Mage::getModel('pagseguro/returns_types_consult');
|
280 |
+
|
281 |
+
$this->_response = $model->processReturn()->getResponse();
|
282 |
+
|
283 |
+
$this->log( $this->__('Response from Pagseguro: %s', $this->_response) );
|
284 |
+
|
285 |
+
if($this->_response == self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED) {
|
286 |
+
$errMsg = $this->__('%sThe consult was not authorized by PagSeguro.', self::TABS);
|
287 |
+
$stop = true;
|
288 |
+
} elseif ($this->_response == self::PAGSEGURO_RETURN_RESPONSE_ERROR) {
|
289 |
+
$errMsg = $this->__('%sPagSeguro has returned an error.', self::TABS);
|
290 |
+
$stop = true;
|
291 |
+
}
|
292 |
+
|
293 |
+
if(Mage::getSingleton('admin/session') && $stop) {
|
294 |
+
Mage::getSingleton('adminhtml/session')->addError($errMsg);
|
295 |
+
return $this;
|
296 |
+
}
|
297 |
+
|
298 |
+
$this->_success = true;
|
299 |
+
|
300 |
+
break;
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Automatic return from PagSeguro
|
304 |
+
*/
|
305 |
+
case self::PAGSEGURO_RETURN_TYPE_DEFAULT:
|
306 |
+
default:
|
307 |
+
|
308 |
+
if($this->getConfigData('return_default_enable')) {
|
309 |
+
$this->log($this->__('%sReturn Type: %s.', self::TABS, self::PAGSEGURO_RETURN_TYPE_DEFAULT_STRING));
|
310 |
+
|
311 |
+
if($this->_validate()) {
|
312 |
+
$this->log($this->__('%sValidation Successfully Done.', self::TABS));
|
313 |
+
$model = Mage::getModel('pagseguro/returns_types_default');
|
314 |
+
$this->_response = $model->setPostData($post)->processReturn()->getResponse();
|
315 |
+
} else {
|
316 |
+
$this->log($this->__('%sValidation Failed.', self::TABS));
|
317 |
+
}
|
318 |
+
|
319 |
+
$errArray = array(self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED, self::PAGSEGURO_RETURN_RESPONSE_ERROR);
|
320 |
+
|
321 |
+
if(in_array($this->_response, $errArray)) {
|
322 |
+
$this->_success = false;
|
323 |
+
} else {
|
324 |
+
$this->_success = true;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
break;
|
328 |
+
}
|
329 |
+
|
330 |
+
$this->_afterReturns();
|
331 |
+
|
332 |
+
return $this;
|
333 |
+
}
|
334 |
+
|
335 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Orders.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns_Orders extends OsStudios_PagSeguro_Model_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
const TABS = ' ';
|
22 |
+
|
23 |
+
const ORDER_NOTPROCESSED = 0;
|
24 |
+
const ORDER_PROCESSED = 1;
|
25 |
+
|
26 |
+
protected $_order = null;
|
27 |
+
protected $_response = self::ORDER_NOTPROCESSED;
|
28 |
+
|
29 |
+
public function getResponse()
|
30 |
+
{
|
31 |
+
return $this->_response;
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Runs before process any order
|
37 |
+
*/
|
38 |
+
protected function _beforeProcessOrder()
|
39 |
+
{
|
40 |
+
$this->log($this->__('%s--- Initializing order process ---', self::TABS));
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Runs before process any order
|
46 |
+
*/
|
47 |
+
protected function _afterProcessOrder()
|
48 |
+
{
|
49 |
+
$this->log($this->__('%s--- Finishing order process ---', self::TABS));
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Set current Order
|
55 |
+
*
|
56 |
+
* @param Mage_Sales_Model_Order $order
|
57 |
+
* @return OsStudios_PagSeguro_Model_Orders
|
58 |
+
*/
|
59 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
60 |
+
{
|
61 |
+
$this->_order = $order;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Unset current order
|
68 |
+
*
|
69 |
+
* @return OsStudios_PagSeguro_Model_Orders
|
70 |
+
*/
|
71 |
+
public function unsetOrder()
|
72 |
+
{
|
73 |
+
$this->_order = null;
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Process canceled orders
|
80 |
+
*
|
81 |
+
* @return OsStudios_PagSeguro_Model_Orders
|
82 |
+
*/
|
83 |
+
public function processOrderCanceled()
|
84 |
+
{
|
85 |
+
|
86 |
+
$this->_beforeProcessOrder();
|
87 |
+
|
88 |
+
if(!$this->_order) {
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
$order = $this->_order;
|
93 |
+
|
94 |
+
if ($order->canUnhold()) {
|
95 |
+
$order->unhold();
|
96 |
+
$this->log($this->__('%sThe order was unholded.', self::TABS));
|
97 |
+
}
|
98 |
+
|
99 |
+
if($this->_order->canCancel()) {
|
100 |
+
$state = $this->getConfigData('canceled_orders_change_to');
|
101 |
+
$status = $this->getConfigData('canceled_orders_change_to');
|
102 |
+
$comment = $this->__('Order was canceled by PagSeguro.');
|
103 |
+
|
104 |
+
$order->getPayment()->setMessage($comment)->save();
|
105 |
+
$order->setState($state, $status, $comment, true)->save();
|
106 |
+
$order->cancel();
|
107 |
+
|
108 |
+
$this->log($this->__('%sOrder was found in history: #%s', self::TABS, $order->getRealOrderId()));
|
109 |
+
$this->log($this->__('%sThe order was successfully processed.', self::TABS));
|
110 |
+
$this->log($this->__('%sNew status: %s.', self::TABS, $status));
|
111 |
+
|
112 |
+
$this->_response = self::ORDER_PROCESSED;
|
113 |
+
} else {
|
114 |
+
$this->log($this->__('%sThe order was not processed.', self::TABS));
|
115 |
+
$this->_response = self::ORDER_NOTPROCESSED;
|
116 |
+
}
|
117 |
+
|
118 |
+
$this->_afterProcessOrder();
|
119 |
+
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Process approved orders
|
126 |
+
*
|
127 |
+
* @return OsStudios_PagSeguro_Model_Orders
|
128 |
+
*/
|
129 |
+
public function processOrderApproved()
|
130 |
+
{
|
131 |
+
|
132 |
+
$this->_beforeProcessOrder();
|
133 |
+
|
134 |
+
if(!$this->_order) {
|
135 |
+
return $this;
|
136 |
+
}
|
137 |
+
|
138 |
+
$order = $this->_order;
|
139 |
+
|
140 |
+
if($order->canUnhold()) {
|
141 |
+
$order->unhold();
|
142 |
+
$this->log($this->__('%sThe order was unholded.', self::TABS));
|
143 |
+
}
|
144 |
+
|
145 |
+
if($order->canInvoice()) {
|
146 |
+
|
147 |
+
$state = $this->getConfigData('paid_orders_change_to');
|
148 |
+
$status = $this->getConfigData('paid_orders_change_to');
|
149 |
+
$comment = $this->__('Payment confirmed by PagSeguro (%s). PagSeguro Transaction: %s.', $this->getPaymentMethodType(), $this->getCode()) ;
|
150 |
+
$notify = true;
|
151 |
+
$visibleOnFront = true;
|
152 |
+
|
153 |
+
$invoice = $order->prepareInvoice();
|
154 |
+
$invoice->register()->pay();
|
155 |
+
$invoice->addComment($comment, $notify, $visibleOnFront)->save();
|
156 |
+
$invoice->sendUpdateEmail($visibleOnFront, $comment);
|
157 |
+
$invoice->setEmailSent(true);
|
158 |
+
|
159 |
+
Mage::getModel('core/resource_transaction')->addObject($invoice)
|
160 |
+
->addObject($invoice->getOrder())
|
161 |
+
->save();
|
162 |
+
|
163 |
+
$comment = $this->__('Invoice #%s was created.', $invoice->getIncrementId());
|
164 |
+
$order->setState($state, $status, $comment, true)->save();
|
165 |
+
|
166 |
+
$this->log($this->__('%sOrder was found in history: #%s', self::TABS, $order->getRealOrderId()));
|
167 |
+
$this->log($this->__('%sThe order was successfully processed.', self::TABS));
|
168 |
+
$this->log($this->__('%sNew status: %s.', self::TABS, $status));
|
169 |
+
|
170 |
+
$this->_response = self::ORDER_PROCESSED;
|
171 |
+
} else {
|
172 |
+
$this->log($this->__('%sThe order was not processed.', self::TABS));
|
173 |
+
$this->_response = self::ORDER_NOTPROCESSED;
|
174 |
+
}
|
175 |
+
|
176 |
+
$this->_afterProcessOrder();
|
177 |
+
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Process approved orders
|
184 |
+
*
|
185 |
+
* @return OsStudios_PagSeguro_Model_Orders
|
186 |
+
*/
|
187 |
+
public function processOrderWaiting()
|
188 |
+
{
|
189 |
+
|
190 |
+
$this->_beforeProcessOrder();
|
191 |
+
|
192 |
+
if(!$this->_order) {
|
193 |
+
return $this;
|
194 |
+
}
|
195 |
+
|
196 |
+
$order = $this->_order;
|
197 |
+
|
198 |
+
if($order->canHold()) {
|
199 |
+
$order->hold()->save();
|
200 |
+
|
201 |
+
$this->log($this->__('%sOrder was found in history: #%s', self::TABS, $order->getRealOrderId()));
|
202 |
+
$this->log($this->__('%sThe order was successfully holded.', self::TABS));
|
203 |
+
|
204 |
+
$this->_response = self::ORDER_PROCESSED;
|
205 |
+
} else {
|
206 |
+
$this->log($this->__('%sThe order was not processed.', self::TABS));
|
207 |
+
$this->_response = self::ORDER_NOTPROCESSED;
|
208 |
+
}
|
209 |
+
|
210 |
+
$this->_afterProcessOrder();
|
211 |
+
|
212 |
+
return $this;
|
213 |
+
}
|
214 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Abstract.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
abstract class OsStudios_PagSeguro_Model_Returns_Types_Abstract extends OsStudios_PagSeguro_Model_Returns
|
19 |
+
{
|
20 |
+
|
21 |
+
const TABS = ' ';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Handle the post data
|
25 |
+
*
|
26 |
+
* @var (array)
|
27 |
+
*/
|
28 |
+
protected $_post = null;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Handle the parameters used in consults
|
32 |
+
*
|
33 |
+
* @var (array)
|
34 |
+
*/
|
35 |
+
protected $_params = array();
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Handle the process result
|
39 |
+
*
|
40 |
+
* @var (bool)
|
41 |
+
*/
|
42 |
+
protected $_success = false;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Handle the response result
|
46 |
+
*
|
47 |
+
* @var (mixed)
|
48 |
+
*/
|
49 |
+
protected $_response = null;
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Runs before process any return
|
54 |
+
*/
|
55 |
+
protected function _beforeProcessReturn()
|
56 |
+
{
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Runs before process any return
|
63 |
+
*/
|
64 |
+
protected function _afterProcessReturn()
|
65 |
+
{
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Sets the post data
|
72 |
+
*
|
73 |
+
* @param (mixed) $post
|
74 |
+
*/
|
75 |
+
public function setPostData($post)
|
76 |
+
{
|
77 |
+
$this->_post = $post;
|
78 |
+
$this->setPost($this->_post);
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Return true if the returned has processed
|
85 |
+
*
|
86 |
+
* @return (bool)
|
87 |
+
*/
|
88 |
+
public function isSuccess()
|
89 |
+
{
|
90 |
+
return $this->_success;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Return response of the return
|
96 |
+
*
|
97 |
+
* @return (bool)
|
98 |
+
*/
|
99 |
+
public function getResponse()
|
100 |
+
{
|
101 |
+
return $this->_response;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Process return
|
107 |
+
*
|
108 |
+
* @return OsStudios_PagSeguro_Model_Returns_Types_Abstract
|
109 |
+
*/
|
110 |
+
public function processReturn()
|
111 |
+
{
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Api.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns_Types_Api extends OsStudios_PagSeguro_Model_Returns_Types_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Runs before process any return
|
23 |
+
*/
|
24 |
+
protected function _beforeProcessReturn()
|
25 |
+
{
|
26 |
+
$this->log($this->__('%s--- Initializing API Return Process ---', self::TABS));
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Runs before process any return
|
32 |
+
*/
|
33 |
+
protected function _afterProcessReturn()
|
34 |
+
{
|
35 |
+
$this->log($this->__('%s--- Finishing API Return Process ---', self::TABS));
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Request XML data information
|
41 |
+
*
|
42 |
+
* @return Varien_Simplexml_Config
|
43 |
+
*/
|
44 |
+
public function _requestTransactionInformation()
|
45 |
+
{
|
46 |
+
|
47 |
+
$this->log($this->__('%sRequesting Transaction Information to PagSeguro.', self::TABS));
|
48 |
+
|
49 |
+
$post = $this->getPost();
|
50 |
+
|
51 |
+
$client = new Zend_Http_Client(implode('/', array($this->getPagSeguroTransactionsUrl(), 'notifications', $post['notificationCode'])));
|
52 |
+
|
53 |
+
if( $this->getConfigData('use_curl') ) {
|
54 |
+
$adapter = new Zend_Http_Client_Adapter_Curl();
|
55 |
+
|
56 |
+
$config = array('timeout' => 30,
|
57 |
+
'curloptions' => array(
|
58 |
+
CURLOPT_SSL_VERIFYPEER => false
|
59 |
+
));
|
60 |
+
$adapter->setConfig($config);
|
61 |
+
$client->setAdapter($adapter);
|
62 |
+
}
|
63 |
+
|
64 |
+
try {
|
65 |
+
|
66 |
+
$credentials = Mage::getModel('pagseguro/credentials');
|
67 |
+
$this->_params['email'] = $this->getCredentials()->getAccountEmail();
|
68 |
+
$this->_params['token'] = $this->getCredentials()->getToken();
|
69 |
+
|
70 |
+
$client->setMethod(Zend_Http_Client::GET)
|
71 |
+
->setParameterGet($this->_params);
|
72 |
+
|
73 |
+
$content = $client->request();
|
74 |
+
$body = $content->getBody();
|
75 |
+
|
76 |
+
if($body == self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED) {
|
77 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED;
|
78 |
+
$this->log($this->__('%sResponse from PagSeguro: %s', self::TABS, $this->_response));
|
79 |
+
return $this;
|
80 |
+
} elseif(!Mage::helper('pagseguro')->isXml($body)) {
|
81 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_ERROR;
|
82 |
+
$this->log($this->__('%sResponse from PagSeguro: %s', self::TABS, $this->_response));
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
|
86 |
+
$xml = new Varien_Simplexml_Config($body);
|
87 |
+
$this->log($this->__('%sXML data successfully returned.', self::TABS));
|
88 |
+
|
89 |
+
return $xml;
|
90 |
+
|
91 |
+
} catch (Mage_Core_Exception $e) {
|
92 |
+
$this->log($this->__('%sValidation Error: %s.', self::TABS, $e->getMessage()));
|
93 |
+
} catch (Exception $e) {
|
94 |
+
$this->log($this->__('%sValidation Error: %s.', self::TABS, $e->getMessage()));
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Process return
|
102 |
+
*
|
103 |
+
* @return OsStudios_PagSeguro_Model_Returns_Types_Api
|
104 |
+
*/
|
105 |
+
public function processReturn()
|
106 |
+
{
|
107 |
+
$this->_beforeProcessReturn();
|
108 |
+
|
109 |
+
$xml = $this->_requestTransactionInformation();
|
110 |
+
|
111 |
+
$data = $xml->getNode();
|
112 |
+
|
113 |
+
$model = Mage::getModel('pagseguro/returns_types_transactions_transaction');
|
114 |
+
$model->setTransactionType(self::PAGSEGURO_RETURN_TYPE_API)
|
115 |
+
->setTransactionData($data->asArray())
|
116 |
+
->processTransaction();
|
117 |
+
|
118 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_AUTHORIZED;
|
119 |
+
$this->_success = true;
|
120 |
+
|
121 |
+
$this->_afterProcessReturn();
|
122 |
+
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Consult.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns_Types_Consult extends OsStudios_PagSeguro_Model_Returns_Types_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Consult initial date
|
23 |
+
*
|
24 |
+
* @var (datetime)
|
25 |
+
*/
|
26 |
+
protected $_initialDate = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Consult ending date
|
30 |
+
*
|
31 |
+
* @var (datetime)
|
32 |
+
*/
|
33 |
+
protected $_endingDate = null;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Runs before process any return
|
38 |
+
*/
|
39 |
+
protected function _beforeProcessReturn()
|
40 |
+
{
|
41 |
+
$this->log($this->__('%s--- Initializing Consult Return Process ---', self::TABS));
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Runs before process any return
|
47 |
+
*/
|
48 |
+
protected function _afterProcessReturn()
|
49 |
+
{
|
50 |
+
$this->log($this->__('%s--- Finishing Consult Return Process ---', self::TABS));
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Sets the initial date to consult transactions
|
56 |
+
*
|
57 |
+
* @param (mixed) $date
|
58 |
+
*/
|
59 |
+
public function setDateInitial($date = null)
|
60 |
+
{
|
61 |
+
$this->_initialDate = $date;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Returns the initial date to consult in 'YYYY-MM-DDTHH:MM' format
|
68 |
+
*
|
69 |
+
* @return (string)
|
70 |
+
* @example 2012-06-08T00:00
|
71 |
+
*/
|
72 |
+
public function getDateInitial($formated = true)
|
73 |
+
{
|
74 |
+
$daysBefore = $this->getConfigData('return_consult_range');
|
75 |
+
$this->_initialDate = strtotime("-{$daysBefore} days");
|
76 |
+
|
77 |
+
return $formated ? $this->getCoreDate()->date(self::PAGSEGURO_DATE_FORMAT, $this->_initialDate) : $this->_initialDate;
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Sets the ending date to consult transactions
|
83 |
+
*
|
84 |
+
* @param (mixed) $date
|
85 |
+
*/
|
86 |
+
public function setDateEnding($date = null)
|
87 |
+
{
|
88 |
+
$this->_endingDate = $date;
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Returns the ending date to consult in 'YYYY-MM-DDTHH:MM' format
|
95 |
+
*
|
96 |
+
* @return (string)
|
97 |
+
* @example 2012-06-08T00:00
|
98 |
+
*/
|
99 |
+
public function getDateEnding($formated = true)
|
100 |
+
{
|
101 |
+
if(!$this->_endingDate) {
|
102 |
+
$this->_endingDate = now();
|
103 |
+
}
|
104 |
+
return $formated ? $this->getCoreDate()->date(self::PAGSEGURO_DATE_FORMAT, $this->_endingDate) : $this->_endingDate;
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Consults and updates the order statuses with PagSeguro
|
110 |
+
*
|
111 |
+
* @return OsStudios_PagSeguro_Model_Returns_Types_Consult
|
112 |
+
*/
|
113 |
+
public function processReturn()
|
114 |
+
{
|
115 |
+
$this->_beforeProcessReturn();
|
116 |
+
|
117 |
+
$this->_params['initialDate'] = $this->getDateInitial();
|
118 |
+
$this->_params['finalDate'] = $this->getDateEnding();
|
119 |
+
$this->_params['page'] = '1';
|
120 |
+
$this->_params['maxPageResults'] = '100';
|
121 |
+
$this->_params['email'] = $this->getCredentials()->getAccountEmail();
|
122 |
+
$this->_params['token'] = $this->getCredentials()->getToken();
|
123 |
+
|
124 |
+
$this->log( $this->__('%sDate Range of Consult: %s to %s.', self::TABS, $this->_params['initialDate'], $this->_params['finalDate']) );
|
125 |
+
|
126 |
+
$client = new Zend_Http_Client($this->getPagSeguroTransactionsUrl());
|
127 |
+
$client->setMethod(Zend_Http_Client::GET)
|
128 |
+
->setParameterGet($this->_params);
|
129 |
+
|
130 |
+
$request = $client->request();
|
131 |
+
$body = $request->getBody();
|
132 |
+
|
133 |
+
if($body == self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED) {
|
134 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_UNAUTHORIZED;
|
135 |
+
$this->log($this->__('%sResponse from PagSeguro: %s', self::TABS, $this->_response));
|
136 |
+
return $this;
|
137 |
+
} elseif(!Mage::helper('pagseguro')->isXml($body)) {
|
138 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_ERROR;
|
139 |
+
$this->log($this->__('%sResponse from PagSeguro: %s', self::TABS, $this->_response));
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
$xml = new Varien_Simplexml_Config($body);
|
144 |
+
|
145 |
+
$return = $xml->getNode('transactions/transaction');
|
146 |
+
|
147 |
+
foreach( $return as $transaction )
|
148 |
+
{
|
149 |
+
$model = Mage::getModel('pagseguro/returns_types_transactions_transaction');
|
150 |
+
$model->setTransactionType(self::PAGSEGURO_RETURN_TYPE_CONSULT)
|
151 |
+
->setTransactionData($transaction->asArray())
|
152 |
+
->processTransaction();
|
153 |
+
}
|
154 |
+
|
155 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_AUTHORIZED;
|
156 |
+
$this->_success = true;
|
157 |
+
|
158 |
+
$this->_afterProcessReturn();
|
159 |
+
|
160 |
+
return $this;
|
161 |
+
}
|
162 |
+
|
163 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Default.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns_Types_Default extends OsStudios_PagSeguro_Model_Returns_Types_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Runs before process any return
|
23 |
+
*/
|
24 |
+
protected function _beforeProcessReturn()
|
25 |
+
{
|
26 |
+
$this->log($this->__('%s--- Initializing Default Return Process ---', self::TABS));
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Runs before process any return
|
32 |
+
*/
|
33 |
+
protected function _afterProcessReturn()
|
34 |
+
{
|
35 |
+
$this->log($this->__('%s--- Finishing Default Return Process ---', self::TABS));
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Process return
|
41 |
+
*
|
42 |
+
* @return OsStudios_PagSeguro_Model_Returns_Types_Default
|
43 |
+
*/
|
44 |
+
public function processReturn()
|
45 |
+
{
|
46 |
+
|
47 |
+
$this->_beforeProcessReturn();
|
48 |
+
|
49 |
+
$model = Mage::getModel('pagseguro/returns_types_transactions_transaction');
|
50 |
+
$model->setTransactionType(self::PAGSEGURO_RETURN_TYPE_DEFAULT)
|
51 |
+
->setTransactionData($this->getPost())
|
52 |
+
->processTransaction();
|
53 |
+
|
54 |
+
|
55 |
+
$this->_response = self::PAGSEGURO_RETURN_RESPONSE_SUCCESS;
|
56 |
+
$this->_success = true;
|
57 |
+
|
58 |
+
$this->_afterProcessReturn();
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/Returns/Types/Transactions/Transaction.php
ADDED
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class OsStudios_PagSeguro_Model_Returns_Types_Transactions_Transaction extends OsStudios_PagSeguro_Model_Returns
|
19 |
+
{
|
20 |
+
|
21 |
+
const TABS = ' ';
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* Paid with Credit Card
|
26 |
+
* @var (int)
|
27 |
+
*/
|
28 |
+
const PAYMENT_TYPE_CC = 1;
|
29 |
+
const PAYMENT_TYPE_CC_STRING = 'Cartão de Crédito';
|
30 |
+
|
31 |
+
const PAYMENT_TYPE_CC_CODE_VISA = 101;
|
32 |
+
const PAYMENT_TYPE_CC_CODE_VISA_STRING = 'Cartão de crédito Visa.';
|
33 |
+
|
34 |
+
const PAYMENT_TYPE_CC_CODE_MC = 102;
|
35 |
+
const PAYMENT_TYPE_CC_CODE_MC_STRING = 'Cartão de crédito MasterCard.';
|
36 |
+
|
37 |
+
const PAYMENT_TYPE_CC_CODE_AMEX = 103;
|
38 |
+
const PAYMENT_TYPE_CC_CODE_AMEX_STRING = 'Cartão de crédito American Express.';
|
39 |
+
|
40 |
+
const PAYMENT_TYPE_CC_CODE_DINERS = 104;
|
41 |
+
const PAYMENT_TYPE_CC_CODE_DINERS_STRING = 'Cartão de crédito Diners.';
|
42 |
+
|
43 |
+
const PAYMENT_TYPE_CC_CODE_HIPERCARD = 105;
|
44 |
+
const PAYMENT_TYPE_CC_CODE_HIPERCARD_STRING = 'Cartão de crédito Hipercard.';
|
45 |
+
|
46 |
+
const PAYMENT_TYPE_CC_CODE_AURA = 106;
|
47 |
+
const PAYMENT_TYPE_CC_CODE_AURA_STRING = 'Cartão de crédito Aura.';
|
48 |
+
|
49 |
+
const PAYMENT_TYPE_CC_CODE_ELO = 107;
|
50 |
+
const PAYMENT_TYPE_CC_CODE_ELO_STRING = 'Cartão de crédito Elo.';
|
51 |
+
|
52 |
+
const PAYMENT_TYPE_CC_CODE_PLENOCARD = 108;
|
53 |
+
const PAYMENT_TYPE_CC_CODE_PLENOCARD_STRING = 'Cartão de crédito PLENOCard.';
|
54 |
+
|
55 |
+
const PAYMENT_TYPE_CC_CODE_PERSONALCARD = 109;
|
56 |
+
const PAYMENT_TYPE_CC_CODE_PERSONALCARD_STRING = 'Cartão de crédito PersonalCard.';
|
57 |
+
|
58 |
+
const PAYMENT_TYPE_CC_CODE_JCB = 110;
|
59 |
+
const PAYMENT_TYPE_CC_CODE_JCB_STRING = 'Cartão de crédito JCB.';
|
60 |
+
|
61 |
+
const PAYMENT_TYPE_CC_CODE_DISCOVER = 111;
|
62 |
+
const PAYMENT_TYPE_CC_CODE_DISCOVER_STRING = 'Cartão de crédito Discover.';
|
63 |
+
|
64 |
+
const PAYMENT_TYPE_CC_CODE_BRASILCARD = 112;
|
65 |
+
const PAYMENT_TYPE_CC_CODE_BRASILCARD_STRING = 'Cartão de crédito BrasilCard.';
|
66 |
+
|
67 |
+
const PAYMENT_TYPE_CC_CODE_FORTBRASIL = 113;
|
68 |
+
const PAYMENT_TYPE_CC_CODE_FORTBRASIL_STRING = 'Cartão de crédito FORTBRASIL.';
|
69 |
+
|
70 |
+
/**
|
71 |
+
*
|
72 |
+
* Paid with Billet
|
73 |
+
* @var (int)
|
74 |
+
*/
|
75 |
+
const PAYMENT_TYPE_BILLET = 2;
|
76 |
+
const PAYMENT_TYPE_BILLET_STRING = 'Boleto';
|
77 |
+
|
78 |
+
const PAYMENT_TYPE_BILLET_CODE_BRADESCO = 201;
|
79 |
+
const PAYMENT_TYPE_BILLET_CODE_BRADESCO_STRING = 'Boleto Bradesco.';
|
80 |
+
|
81 |
+
const PAYMENT_TYPE_BILLET_CODE_SANTANDER = 202;
|
82 |
+
const PAYMENT_TYPE_BILLET_CODE_SANTANDER_STRING = 'Boleto Santander.';
|
83 |
+
|
84 |
+
/**
|
85 |
+
*
|
86 |
+
* Paid with Online Debit (TEF)
|
87 |
+
* @var (int)
|
88 |
+
*/
|
89 |
+
const PAYMENT_TYPE_DEBIT = 3;
|
90 |
+
const PAYMENT_TYPE_DEBIT_STRING = 'Pagamento Online';
|
91 |
+
|
92 |
+
const PAYMENT_TYPE_DEBIT_CODE_BRADESCO = 301;
|
93 |
+
const PAYMENT_TYPE_DEBIT_CODE_BRADESCO_STRING = 'Débito online Bradesco.';
|
94 |
+
|
95 |
+
const PAYMENT_TYPE_DEBIT_CODE_ITAU = 302;
|
96 |
+
const PAYMENT_TYPE_DEBIT_CODE_ITAU_STRING = 'Débito online Itaú.';
|
97 |
+
|
98 |
+
const PAYMENT_TYPE_DEBIT_CODE_UNIBANCO = 303;
|
99 |
+
const PAYMENT_TYPE_DEBIT_CODE_UNIBANCO_STRING = 'Débito online Unibanco.';
|
100 |
+
|
101 |
+
const PAYMENT_TYPE_DEBIT_CODE_BB = 304;
|
102 |
+
const PAYMENT_TYPE_DEBIT_CODE_BB_STRING = 'Débito online Banco do Brasil.';
|
103 |
+
|
104 |
+
const PAYMENT_TYPE_DEBIT_CODE_REAL = 305;
|
105 |
+
const PAYMENT_TYPE_DEBIT_CODE_REAL_STRING = 'Débito online Banco Real.';
|
106 |
+
|
107 |
+
const PAYMENT_TYPE_DEBIT_CODE_BANRISUL = 306;
|
108 |
+
const PAYMENT_TYPE_DEBIT_CODE_BANRISUL_STRING = 'Débito online Banrisul.';
|
109 |
+
|
110 |
+
const PAYMENT_TYPE_DEBIT_CODE_HSBC = 307;
|
111 |
+
const PAYMENT_TYPE_DEBIT_CODE_HSBC_STRING = 'Débito online HSBC.';
|
112 |
+
|
113 |
+
/**
|
114 |
+
*
|
115 |
+
* Paid with PagSeguro Account Credits
|
116 |
+
* @var (int)
|
117 |
+
*/
|
118 |
+
const PAYMENT_TYPE_PAGSEGUROCREDIT = 4;
|
119 |
+
const PAYMENT_TYPE_PAGSEGUROCREDIT_STRING = 'Pagamento';
|
120 |
+
|
121 |
+
const PAYMENT_TYPE_PAGSEGUROCREDIT_CODE = 401;
|
122 |
+
const PAYMENT_TYPE_PAGSEGUROCREDIT_CODE_STRING = 'Saldo PagSeguro.';
|
123 |
+
|
124 |
+
/**
|
125 |
+
*
|
126 |
+
* Paid with Oi Paggo via Celphones
|
127 |
+
* @var (int)
|
128 |
+
*/
|
129 |
+
const PAYMENT_TYPE_OIPAGGO = 5;
|
130 |
+
const PAYMENT_TYPE_OIPAGGO_STRING = 'Oi Paggo';
|
131 |
+
|
132 |
+
const PAYMENT_TYPE_OIPAGGO_CODE = 501;
|
133 |
+
const PAYMENT_TYPE_OIPAGGO_CODE_STRING = 'Oi Paggo.';
|
134 |
+
|
135 |
+
/**
|
136 |
+
*
|
137 |
+
* Status: Waiting for the payment
|
138 |
+
* @var (int)
|
139 |
+
*/
|
140 |
+
const STATUS_WAITING_PAYMENT = 1;
|
141 |
+
const STATUS_WAITING_PAYMENT_STRING = 'Aguardando Pagto';
|
142 |
+
|
143 |
+
/**
|
144 |
+
*
|
145 |
+
* Status: Payment is being analysed
|
146 |
+
* @var (int)
|
147 |
+
*/
|
148 |
+
const STATUS_ANALYSIS = 2;
|
149 |
+
const STATUS_ANALYSIS_STRING = 'Em Análise';
|
150 |
+
|
151 |
+
/**
|
152 |
+
*
|
153 |
+
* Status: The transaction was paid
|
154 |
+
* @var (int)
|
155 |
+
*/
|
156 |
+
const STATUS_PAID = 3;
|
157 |
+
const STATUS_PAID_STRING = 'Aprovado';
|
158 |
+
|
159 |
+
/**
|
160 |
+
*
|
161 |
+
* Status: The transaction was paid and the money is available to shopper in PagSeguro
|
162 |
+
* @var (int)
|
163 |
+
*/
|
164 |
+
const STATUS_AVAILABLE = 4;
|
165 |
+
const STATUS_AVAILABLE_STRING = 'Completo';
|
166 |
+
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* Status: A dispute was opened by customer
|
170 |
+
* @var (int)
|
171 |
+
*/
|
172 |
+
const STATUS_IN_DISPUTE = 5;
|
173 |
+
|
174 |
+
/**
|
175 |
+
*
|
176 |
+
* Status: The money was given back to customer
|
177 |
+
* @var (int)
|
178 |
+
*/
|
179 |
+
const STATUS_RETURNED = 6;
|
180 |
+
|
181 |
+
/**
|
182 |
+
*
|
183 |
+
* Status: The transaction was canceled for any reason
|
184 |
+
* @var (int)
|
185 |
+
*/
|
186 |
+
const STATUS_CANCELED = 7;
|
187 |
+
const STATUS_CANCELED_STRING = 'Cancelado';
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
*
|
192 |
+
* Handle the transaction type
|
193 |
+
* @var (int)
|
194 |
+
*/
|
195 |
+
protected $_transactionType = self::PAGSEGURO_RETURN_TYPE_DEFAULT;
|
196 |
+
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Runs before process any transaction
|
200 |
+
*/
|
201 |
+
protected function _beforeLogTransactionData()
|
202 |
+
{
|
203 |
+
$this->log($this->__('%s--- Transaction Data. ---', self::TABS));
|
204 |
+
|
205 |
+
$this->log($this->__('%sDate: %s.', self::TABS, $this->getDate()));
|
206 |
+
$this->log($this->__('%sReference: %s.', self::TABS, $this->getReference()));
|
207 |
+
$this->log($this->__('%sCode: %s.', self::TABS, $this->getCode()));
|
208 |
+
$this->log($this->__('%sType: %s.', self::TABS, $this->getType()));
|
209 |
+
$this->log($this->__('%sPayment Type: %s.', self::TABS, $this->getPaymentMethodType()));
|
210 |
+
$this->log($this->__('%sStatus: %s.', self::TABS, $this->getStatus()));
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Runs before process any transaction
|
216 |
+
*/
|
217 |
+
protected function _beforeProcessTransaction()
|
218 |
+
{
|
219 |
+
$this->log($this->__('%s--- Initializing Transaction Process. ---', self::TABS));
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Runs before process any transaction
|
225 |
+
*/
|
226 |
+
protected function _afterProcessTransaction()
|
227 |
+
{
|
228 |
+
$this->log($this->__('%s--- Finishing Transaction Process. ---', self::TABS));
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Sets the transaction type
|
234 |
+
*
|
235 |
+
* @param (int) $transactionType
|
236 |
+
* @return \OsStudios_PagSeguro_Model_Returns_Types_Transaction
|
237 |
+
*/
|
238 |
+
public function setTransactionType($transactionType = self::PAGSEGURO_RETURN_TYPE_DEFAULT)
|
239 |
+
{
|
240 |
+
$this->_transactionType = $transactionType;
|
241 |
+
return $this;
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Sets the transaction DATA
|
247 |
+
*
|
248 |
+
* @param array $transaction
|
249 |
+
* @return OsStudios_PagSeguro_Model_Returns_Types_Transaction
|
250 |
+
*/
|
251 |
+
public function setTransactionData($transaction = array())
|
252 |
+
{
|
253 |
+
switch ($this->_transactionType) {
|
254 |
+
case self::PAGSEGURO_RETURN_TYPE_API:
|
255 |
+
case self::PAGSEGURO_RETURN_TYPE_CONSULT:
|
256 |
+
|
257 |
+
$this->setDate($transaction['date'])
|
258 |
+
->setReference($transaction['reference'])
|
259 |
+
->setCode($transaction['code'])
|
260 |
+
->setType($transaction['type'])
|
261 |
+
->setStatus($transaction['status'])
|
262 |
+
->setGrossAmount($transaction['grossAmount'])
|
263 |
+
->setDiscountAmount($transaction['discountAmount'])
|
264 |
+
->setFeeAmount($transaction['feeAmount'])
|
265 |
+
->setNetAmount($transaction['netAmount'])
|
266 |
+
->setExtraAmount($transaction['extraAmount'])
|
267 |
+
->setLastEventDate($transaction['lastEventDate'])
|
268 |
+
;
|
269 |
+
|
270 |
+
switch ($transaction['paymentMethod']['type']) {
|
271 |
+
case self::PAYMENT_TYPE_CC:
|
272 |
+
$paymentType = $this->__('Credit Card');
|
273 |
+
break;
|
274 |
+
case self::PAYMENT_TYPE_BILLET:
|
275 |
+
$paymentType = $this->__('Billet');
|
276 |
+
break;
|
277 |
+
case self::PAYMENT_TYPE_DEBIT:
|
278 |
+
$paymentType = $this->__('Online Debit');
|
279 |
+
break;
|
280 |
+
case self::PAYMENT_TYPE_PAGSEGUROCREDIT:
|
281 |
+
$paymentType = $this->__('PagSeguro Credit');
|
282 |
+
break;
|
283 |
+
case self::PAYMENT_TYPE_OIPAGGO:
|
284 |
+
$paymentType = $this->__('Oi Paggo');
|
285 |
+
break;
|
286 |
+
default:
|
287 |
+
$paymentType = $this->__('Not Provided');
|
288 |
+
break;
|
289 |
+
}
|
290 |
+
|
291 |
+
$this->setPaymentMethodType($paymentType);
|
292 |
+
|
293 |
+
break;
|
294 |
+
case self::PAGSEGURO_RETURN_TYPE_DEFAULT:
|
295 |
+
default:
|
296 |
+
|
297 |
+
$this->setDate($transaction['DataTransacao'])
|
298 |
+
->setReference($transaction['Referencia'])
|
299 |
+
->setCode($transaction['TransacaoID'])
|
300 |
+
->setPaymentMethodType($transaction['TipoPagamento'])
|
301 |
+
->setStatus($transaction['StatusTransacao'])
|
302 |
+
;
|
303 |
+
|
304 |
+
break;
|
305 |
+
}
|
306 |
+
|
307 |
+
//$this->setStatus( self::STATUS_PAID );
|
308 |
+
|
309 |
+
return $this;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Process the current transaction
|
314 |
+
*/
|
315 |
+
public function processTransaction()
|
316 |
+
{
|
317 |
+
|
318 |
+
$this->_beforeProcessTransaction();
|
319 |
+
|
320 |
+
$order = $this->loadOrderByIncrementId($this->getReference());
|
321 |
+
|
322 |
+
if(($order instanceof Mage_Sales_Model_Order) && ($order->hasData())) {
|
323 |
+
|
324 |
+
if(($payment = $order->getPayment())) {
|
325 |
+
$methods = array(Mage::getModel('pagseguro/hpp')->getCode());
|
326 |
+
if(!in_array($payment->getMethod(), $methods)) {
|
327 |
+
return false;
|
328 |
+
}
|
329 |
+
} else {
|
330 |
+
return false;
|
331 |
+
}
|
332 |
+
|
333 |
+
$payment->setPagseguroTransactionId($this->getCode())
|
334 |
+
->setPagseguroPaymentMethod($this->getPaymentMethodType())
|
335 |
+
->save();
|
336 |
+
|
337 |
+
$ordersModel = Mage::getModel('pagseguro/returns_orders');
|
338 |
+
$ordersModel->setOrder($order);
|
339 |
+
|
340 |
+
$this->_beforeLogTransactionData();
|
341 |
+
|
342 |
+
switch ($this->getStatus()) {
|
343 |
+
case self::STATUS_PAID:
|
344 |
+
case self::STATUS_PAID_STRING:
|
345 |
+
case self::STATUS_AVAILABLE:
|
346 |
+
case self::STATUS_AVAILABLE_STRING:
|
347 |
+
|
348 |
+
$result = $ordersModel->processOrderApproved()->getResponse();
|
349 |
+
if($result === OsStudios_PagSeguro_Model_Returns_Orders::ORDER_NOTPROCESSED) {
|
350 |
+
return false;
|
351 |
+
}
|
352 |
+
|
353 |
+
break;
|
354 |
+
case self::STATUS_CANCELED:
|
355 |
+
case self::STATUS_CANCELED_STRING:
|
356 |
+
case self::STATUS_RETURNED:
|
357 |
+
|
358 |
+
$result = $ordersModel->processOrderCanceled()->getResponse();
|
359 |
+
if($result === OsStudios_PagSeguro_Model_Returns_Orders::ORDER_NOTPROCESSED) {
|
360 |
+
return false;
|
361 |
+
}
|
362 |
+
|
363 |
+
break;
|
364 |
+
case self::STATUS_WAITING_PAYMENT:
|
365 |
+
case self::STATUS_WAITING_PAYMENT_STRING:
|
366 |
+
case self::STATUS_ANALYSIS:
|
367 |
+
case self::STATUS_ANALYSIS_STRING:
|
368 |
+
case self::STATUS_IN_DISPUTE:
|
369 |
+
default:
|
370 |
+
|
371 |
+
$result = $ordersModel->processOrderWaiting()->getResponse();
|
372 |
+
if($result === OsStudios_PagSeguro_Model_Returns_Orders::ORDER_NOTPROCESSED) {
|
373 |
+
return false;
|
374 |
+
}
|
375 |
+
|
376 |
+
break;
|
377 |
+
}
|
378 |
+
|
379 |
+
$ordersModel->unsetOrder();
|
380 |
+
|
381 |
+
$this->_afterProcessTransaction();
|
382 |
+
|
383 |
+
return true;
|
384 |
+
}
|
385 |
+
}
|
386 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Consult/Daysrange.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Installments Source
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Consult_Daysrange
|
24 |
+
{
|
25 |
+
public function toOptionArray ()
|
26 |
+
{
|
27 |
+
$options = array();
|
28 |
+
|
29 |
+
for( $y=1; $y<=30; $y++ )
|
30 |
+
{
|
31 |
+
$options[] = array('value' => $y, 'label' => Mage::helper('pagseguro')->__('From %s day(s) before to now', $y));
|
32 |
+
}
|
33 |
+
|
34 |
+
return $options;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Installments.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Installments Source
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Installments
|
24 |
+
{
|
25 |
+
public function toOptionArray ()
|
26 |
+
{
|
27 |
+
$options = array();
|
28 |
+
|
29 |
+
$options[] = array('value' => 1 , 'label' => Mage::helper('pagseguro')->__('Deactivated (%sx)', 1));
|
30 |
+
|
31 |
+
for($y=2; $y<=18; $y++){
|
32 |
+
$options[] = array('value' => $y, 'label' => Mage::helper('pagseguro')->__('Max %sx', $y));
|
33 |
+
}
|
34 |
+
|
35 |
+
return $options;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Log/Types.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Log Types
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Log_Types
|
24 |
+
{
|
25 |
+
public function toOptionArray()
|
26 |
+
{
|
27 |
+
$options = array();
|
28 |
+
|
29 |
+
$options[] = array('value' => 'begend_tags' , 'label' => Mage::helper('pagseguro')->__('Beginning and Ending Tags'));
|
30 |
+
$options[] = array('value' => 'return_data' , 'label' => Mage::helper('pagseguro')->__('PagSeguro Return Data'));
|
31 |
+
$options[] = array('value' => 'confimation_status' , 'label' => Mage::helper('pagseguro')->__('PagSeguro Confirmation Status'));
|
32 |
+
$options[] = array('value' => 'order_status' , 'label' => Mage::helper('pagseguro')->__('PagSeguro Order Status'));
|
33 |
+
$options[] = array('value' => 'log_separator' , 'label' => Mage::helper('pagseguro')->__('Separator'));
|
34 |
+
|
35 |
+
return $options;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Order/Status/Canceled.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* 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_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2011 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 |
+
/**
|
28 |
+
* Order Statuses source model
|
29 |
+
*/
|
30 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Order_Status_Canceled
|
31 |
+
{
|
32 |
+
// set null to enable all possible
|
33 |
+
protected $_stateStatuses = array(
|
34 |
+
array('label' => 'Closed', 'value' => Mage_Sales_Model_Order::STATE_CLOSED),
|
35 |
+
array('label' => 'Canceled', 'value' => Mage_Sales_Model_Order::STATE_CANCELED),
|
36 |
+
);
|
37 |
+
|
38 |
+
public function toOptionArray()
|
39 |
+
{
|
40 |
+
$statuses = $this->_stateStatuses;
|
41 |
+
|
42 |
+
$options = array();
|
43 |
+
foreach ($statuses as $status) {
|
44 |
+
$options[] = array(
|
45 |
+
'value' => $status['value'],
|
46 |
+
'label' => Mage::helper('pagseguro')->__($status['label']),
|
47 |
+
);
|
48 |
+
}
|
49 |
+
return $options;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Order/Status/Paid.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* 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_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2011 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 |
+
/**
|
28 |
+
* Order Statuses source model
|
29 |
+
*/
|
30 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Order_Status_Paid
|
31 |
+
{
|
32 |
+
// set null to enable all possible
|
33 |
+
protected $_stateStatuses = array(
|
34 |
+
array('label' => 'Payment Review', 'value' => Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW),
|
35 |
+
array('label' => 'Processing', 'value' => Mage_Sales_Model_Order::STATE_PROCESSING),
|
36 |
+
array('label' => 'Holded', 'value' => Mage_Sales_Model_Order::STATE_HOLDED),
|
37 |
+
);
|
38 |
+
|
39 |
+
public function toOptionArray()
|
40 |
+
{
|
41 |
+
$statuses = $this->_stateStatuses;
|
42 |
+
|
43 |
+
$options = array();
|
44 |
+
foreach ($statuses as $status) {
|
45 |
+
$options[] = array(
|
46 |
+
'value' => $status['value'],
|
47 |
+
'label' => Mage::helper('pagseguro')->__($status['label'])
|
48 |
+
);
|
49 |
+
}
|
50 |
+
return $options;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Returnpage.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro CMS Return Page Source
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Returnpage
|
24 |
+
{
|
25 |
+
public function toOptionArray ()
|
26 |
+
{
|
27 |
+
$collection = Mage::getModel('cms/page')->getCollection();
|
28 |
+
$pages = array();
|
29 |
+
foreach ($collection as $page) {
|
30 |
+
if( $page->getIsActive() )
|
31 |
+
{
|
32 |
+
$pages[] = array('value' => $page->getIdentifier(), 'label' => $page->getTitle());
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return $pages;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/OsStudios/PagSeguro/Model/System/Config/Source/Shipping/Price.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Shipping Price Source
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Model_System_Config_Source_Shipping_Price
|
24 |
+
{
|
25 |
+
public function toOptionArray ()
|
26 |
+
{
|
27 |
+
$options = array();
|
28 |
+
|
29 |
+
$options[] = array('value' => 'separated' , 'label' => Mage::helper('pagseguro')->__('Separated'));
|
30 |
+
$options[] = array('value' => 'product' , 'label' => Mage::helper('pagseguro')->__('As Product'));
|
31 |
+
$options[] = array('value' => 'grouped' , 'label' => Mage::helper('pagseguro')->__('Grouped'));
|
32 |
+
|
33 |
+
return $options;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/OsStudios/PagSeguro/controllers/Adminhtml/ReturnsController.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* PagSeguro Adminhtml Returns Controller
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class OsStudios_PagSeguro_Adminhtml_ReturnsController extends Mage_Adminhtml_Controller_Action
|
24 |
+
{
|
25 |
+
|
26 |
+
public function updatesAction()
|
27 |
+
{
|
28 |
+
|
29 |
+
$model = Mage::getModel('pagseguro/data');
|
30 |
+
|
31 |
+
$returns = Mage::getModel('pagseguro/returns');
|
32 |
+
$returns->setReturnType(OsStudios_PagSeguro_Model_Returns::PAGSEGURO_RETURN_TYPE_CONSULT)
|
33 |
+
->runReturns();
|
34 |
+
|
35 |
+
$this->_redirect('adminhtml/sales_order/');
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/OsStudios/PagSeguro/controllers/PayController.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
* PagSeguro Payment Controller
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
|
24 |
+
class OsStudios_PagSeguro_PayController extends OsStudios_PagSeguro_Controller_Front_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Redirect Customer to PagSeguro Checkout Page
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
public function redirectAction()
|
32 |
+
{
|
33 |
+
$pagseguro = $this->getPagSeguro();
|
34 |
+
$session = $this->getCheckout();
|
35 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
36 |
+
|
37 |
+
if (empty($orderId)) {
|
38 |
+
$orderId = $session->getLastOrderId();
|
39 |
+
$session->clear(); //Cleans the cart session
|
40 |
+
}
|
41 |
+
|
42 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
43 |
+
|
44 |
+
if ($order->getId()) {
|
45 |
+
|
46 |
+
// Envia email de confirmação ao cliente
|
47 |
+
if(!$order->getEmailSent()) {
|
48 |
+
$order->sendNewOrderEmail();
|
49 |
+
$order->setEmailSent(true);
|
50 |
+
$order->save();
|
51 |
+
}
|
52 |
+
|
53 |
+
$order_redirect = false;
|
54 |
+
|
55 |
+
// Checks if Payment Method is really the PagSeguro Method
|
56 |
+
if ($order->getPayment()->getMethod() == $pagseguro->getCode()) {
|
57 |
+
|
58 |
+
switch ($order->getState()) {
|
59 |
+
|
60 |
+
case Mage_Sales_Model_Order::STATE_NEW:
|
61 |
+
// Stores Order ID in session and display redirect form to PagSeguro
|
62 |
+
Mage::getSingleton("core/session")->setPagseguroOrderId($orderId);
|
63 |
+
|
64 |
+
$html = $pagseguro->setOrder($order)->createRedirectForm();
|
65 |
+
|
66 |
+
$this->getResponse()->setHeader("Content-Type", "text/html; charset=ISO-8859-1", true);
|
67 |
+
$this->getResponse()->setBody($html);
|
68 |
+
break;
|
69 |
+
|
70 |
+
case Mage_Sales_Model_Order::STATE_HOLDED:
|
71 |
+
// Redirect to Print Billet Page
|
72 |
+
if ($order->getPayment()->getPagseguroPaymentMethod() == "Boleto") {
|
73 |
+
$this->_redirectUrl($pagseguro->getPagSeguroBoletoUrl($order->getPayment()->getPagseguroTransactionId(), false));
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
|
77 |
+
default:
|
78 |
+
// Redirect to Order's Page
|
79 |
+
$order_redirect = true;
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
|
83 |
+
} else {
|
84 |
+
$order_redirect = true;
|
85 |
+
}
|
86 |
+
|
87 |
+
if ($order_redirect) {
|
88 |
+
$params = array();
|
89 |
+
$params['_secure'] = true;
|
90 |
+
$params['order_id'] = $orderId;
|
91 |
+
$this->_redirect('sales/order/view', $params);
|
92 |
+
}
|
93 |
+
|
94 |
+
} else {
|
95 |
+
$this->_redirect('');
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Shows success page after payment.
|
102 |
+
*
|
103 |
+
*/
|
104 |
+
public function successAction()
|
105 |
+
{
|
106 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
107 |
+
if (!empty($orderId)) {
|
108 |
+
Mage::getSingleton("core/session")->setPagseguroOrderId($orderId);
|
109 |
+
} else {
|
110 |
+
$orderId = Mage::getSingleton("core/session")->getPagseguroOrderId();
|
111 |
+
}
|
112 |
+
|
113 |
+
if ($orderId) {
|
114 |
+
$storeId = $this->getOrderStoreId($orderId);
|
115 |
+
|
116 |
+
$pagseguro = $this->getPagSeguro();
|
117 |
+
if ($pagseguro->getConfigData('use_return_page_cms', $storeId)) {
|
118 |
+
$this->_redirect($pagseguro->getConfigData('return_page', $storeId));
|
119 |
+
} else {
|
120 |
+
$this->loadLayout();
|
121 |
+
$this->renderLayout();
|
122 |
+
}
|
123 |
+
|
124 |
+
Mage::getSingleton("core/session")->setPagseguroOrderId(null);
|
125 |
+
} else {
|
126 |
+
$this->_redirect('');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Returns the installments block
|
133 |
+
*
|
134 |
+
*/
|
135 |
+
public function installmentsAction()
|
136 |
+
{
|
137 |
+
$this->loadLayout();
|
138 |
+
$this->renderLayout();
|
139 |
+
}
|
140 |
+
}
|
app/code/community/OsStudios/PagSeguro/controllers/ReturnsController.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
* PagSeguro Returns Controller
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
|
24 |
+
class OsStudios_PagSeguro_ReturnsController extends OsStudios_PagSeguro_Controller_Front_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Used for two functionalities:
|
29 |
+
*
|
30 |
+
* 1) Redirect the response from PagSeguro to set success page after finishing an order in PagSeguro
|
31 |
+
* 2) Receive and control the requests from the auto data returns from PagSeguro when update order statuses
|
32 |
+
*
|
33 |
+
*/
|
34 |
+
public function indexAction()
|
35 |
+
{
|
36 |
+
$pagseguro = $this->getPagSeguro();
|
37 |
+
$request = $this->getRequest();
|
38 |
+
|
39 |
+
if (!$request->isPost()) {
|
40 |
+
// That is a $_GET. Redirect to set page.
|
41 |
+
$orderId = Mage::getSingleton("core/session")->getPagseguroOrderId();
|
42 |
+
|
43 |
+
if ($orderId) {
|
44 |
+
$storeId = $this->getOrderStoreId($orderId);
|
45 |
+
|
46 |
+
if ($pagseguro->getConfigData('use_return_page_cms', $storeId)) {
|
47 |
+
$url = $pagseguro->getConfigData('return_page', $storeId);
|
48 |
+
Mage::getSingleton("core/session")->setPagseguroOrderId(null);
|
49 |
+
} else {
|
50 |
+
$url = 'pagseguro/pay/success';
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
$url = '';
|
54 |
+
}
|
55 |
+
$this->_redirect($url);
|
56 |
+
}
|
57 |
+
|
58 |
+
if (($post = $request->getPost()) && $request->isPost()) {
|
59 |
+
|
60 |
+
$returns = Mage::getModel('pagseguro/returns');
|
61 |
+
$data = Mage::getModel('pagseguro/data');
|
62 |
+
|
63 |
+
if($data->isReturnApi($post))
|
64 |
+
{
|
65 |
+
$returns->setReturnType(OsStudios_PagSeguro_Model_Returns::PAGSEGURO_RETURN_TYPE_API);
|
66 |
+
} elseif ($data->isReturnDefault($post)) {
|
67 |
+
$returns->setReturnType(OsStudios_PagSeguro_Model_Returns::PAGSEGURO_RETURN_TYPE_DEFAULT);
|
68 |
+
} else {
|
69 |
+
/**
|
70 |
+
* None of allowed post types was sent
|
71 |
+
*/
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Process returns according to type
|
77 |
+
*/
|
78 |
+
$returns->setPostData($post)
|
79 |
+
->runReturns();
|
80 |
+
|
81 |
+
} else {
|
82 |
+
|
83 |
+
// That is a $_GET. Redirect to set page.
|
84 |
+
$orderId = Mage::getSingleton("core/session")->getPagseguroOrderId();
|
85 |
+
|
86 |
+
if ($orderId) {
|
87 |
+
$storeId = $this->getOrderStoreId($orderId);
|
88 |
+
|
89 |
+
if ($pagseguro->getConfigData('use_return_page_cms', $storeId)) {
|
90 |
+
$url = $pagseguro->getConfigData('return_page', $storeId);
|
91 |
+
Mage::getSingleton("core/session")->setPagseguroOrderId(null);
|
92 |
+
} else {
|
93 |
+
$url = 'pagseguro/pay/success';
|
94 |
+
}
|
95 |
+
} else {
|
96 |
+
$url = '';
|
97 |
+
}
|
98 |
+
$this->_redirect($url);
|
99 |
+
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
app/code/community/OsStudios/PagSeguro/etc/adminhtml.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category OsStudios
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
|
20 |
+
<config>
|
21 |
+
<menu>
|
22 |
+
<sales>
|
23 |
+
<children>
|
24 |
+
<pagseguro translate="title" module="pagseguro">
|
25 |
+
<title>PagSeguro</title>
|
26 |
+
<sort_order>1000</sort_order>
|
27 |
+
<children>
|
28 |
+
<update_check translate="title" module="pagseguro">
|
29 |
+
<title>Check for Order Updates</title>
|
30 |
+
<action>pagseguro/adminhtml_returns/updates</action>
|
31 |
+
<sort_order>0</sort_order>
|
32 |
+
</update_check>
|
33 |
+
</children>
|
34 |
+
</pagseguro>
|
35 |
+
</children>
|
36 |
+
</sales>
|
37 |
+
</menu>
|
38 |
+
<acl>
|
39 |
+
<resources>
|
40 |
+
<admin>
|
41 |
+
<children>
|
42 |
+
<system>
|
43 |
+
<children>
|
44 |
+
<config>
|
45 |
+
<children>
|
46 |
+
<payment>
|
47 |
+
<children>
|
48 |
+
<pagseguro translate="title" module="pagseguro">
|
49 |
+
<title>PagSeguro Configurations</title>
|
50 |
+
</pagseguro>
|
51 |
+
</children>
|
52 |
+
</payment>
|
53 |
+
</children>
|
54 |
+
</config>
|
55 |
+
</children>
|
56 |
+
</system>
|
57 |
+
<sales>
|
58 |
+
<children>
|
59 |
+
<pagseguro translate="title" module="pagseguro">
|
60 |
+
<title>PagSeguro</title>
|
61 |
+
<sort_order>0</sort_order>
|
62 |
+
<children>
|
63 |
+
<update_check translate="title" module="pagseguro">
|
64 |
+
<title>Check for Order Updates</title>
|
65 |
+
<sort_order>0</sort_order>
|
66 |
+
</update_check>
|
67 |
+
</children>
|
68 |
+
</pagseguro>
|
69 |
+
</children>
|
70 |
+
</sales>
|
71 |
+
</children>
|
72 |
+
</admin>
|
73 |
+
</resources>
|
74 |
+
</acl>
|
75 |
+
</config>
|
app/code/community/OsStudios/PagSeguro/etc/config.xml
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category OsStudios
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
|
20 |
+
<config>
|
21 |
+
<modules>
|
22 |
+
<OsStudios_PagSeguro>
|
23 |
+
<version>1.0.0</version>
|
24 |
+
</OsStudios_PagSeguro>
|
25 |
+
</modules>
|
26 |
+
<global>
|
27 |
+
<helpers>
|
28 |
+
<pagseguro>
|
29 |
+
<class>OsStudios_PagSeguro_Helper</class>
|
30 |
+
</pagseguro>
|
31 |
+
</helpers>
|
32 |
+
<blocks>
|
33 |
+
<pagseguro>
|
34 |
+
<class>OsStudios_PagSeguro_Block</class>
|
35 |
+
</pagseguro>
|
36 |
+
</blocks>
|
37 |
+
<models>
|
38 |
+
<pagseguro>
|
39 |
+
<class>OsStudios_PagSeguro_Model</class>
|
40 |
+
</pagseguro>
|
41 |
+
</models>
|
42 |
+
<resources>
|
43 |
+
<pagseguro_setup>
|
44 |
+
<setup>
|
45 |
+
<module>OsStudios_PagSeguro</module>
|
46 |
+
<class>Mage_Sales_Model_Mysql4_Setup</class>
|
47 |
+
</setup>
|
48 |
+
<connection>
|
49 |
+
<use>core_setup</use>
|
50 |
+
</connection>
|
51 |
+
</pagseguro_setup>
|
52 |
+
<pagseguro_write>
|
53 |
+
<connection>
|
54 |
+
<use>core_write</use>
|
55 |
+
</connection>
|
56 |
+
</pagseguro_write>
|
57 |
+
<pagseguro_read>
|
58 |
+
<connection>
|
59 |
+
<use>core_read</use>
|
60 |
+
</connection>
|
61 |
+
</pagseguro_read>
|
62 |
+
</resources>
|
63 |
+
</global>
|
64 |
+
<adminhtml>
|
65 |
+
<translate>
|
66 |
+
<modules>
|
67 |
+
<pagseguro>
|
68 |
+
<files>
|
69 |
+
<default>OsStudios_PagSeguro.csv</default>
|
70 |
+
</files>
|
71 |
+
</pagseguro>
|
72 |
+
</modules>
|
73 |
+
</translate>
|
74 |
+
<layout>
|
75 |
+
<updates>
|
76 |
+
<pagseguro>
|
77 |
+
<file>osstudios_pagseguro.xml</file>
|
78 |
+
</pagseguro>
|
79 |
+
</updates>
|
80 |
+
</layout>
|
81 |
+
</adminhtml>
|
82 |
+
<frontend>
|
83 |
+
<routers>
|
84 |
+
<pagseguro>
|
85 |
+
<use>standard</use>
|
86 |
+
<args>
|
87 |
+
<module>OsStudios_PagSeguro</module>
|
88 |
+
<frontName>pagseguro</frontName>
|
89 |
+
</args>
|
90 |
+
</pagseguro>
|
91 |
+
</routers>
|
92 |
+
<translate>
|
93 |
+
<modules>
|
94 |
+
<pagseguro>
|
95 |
+
<files>
|
96 |
+
<default>OsStudios_PagSeguro.csv</default>
|
97 |
+
</files>
|
98 |
+
</pagseguro>
|
99 |
+
</modules>
|
100 |
+
</translate>
|
101 |
+
<layout>
|
102 |
+
<updates>
|
103 |
+
<pagseguro>
|
104 |
+
<file>osstudios_pagseguro.xml</file>
|
105 |
+
</pagseguro>
|
106 |
+
</updates>
|
107 |
+
</layout>
|
108 |
+
</frontend>
|
109 |
+
<admin>
|
110 |
+
<routers>
|
111 |
+
<pagseguro>
|
112 |
+
<use>admin</use>
|
113 |
+
<args>
|
114 |
+
<module>OsStudios_PagSeguro</module>
|
115 |
+
<frontName>pagseguro</frontName>
|
116 |
+
</args>
|
117 |
+
</pagseguro>
|
118 |
+
</routers>
|
119 |
+
</admin>
|
120 |
+
<default>
|
121 |
+
<payment>
|
122 |
+
<pagseguro_config>
|
123 |
+
<pagseguro_url>https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx</pagseguro_url>
|
124 |
+
<pagseguro_npi_url>https://pagseguro.uol.com.br/pagseguro-ws/checkout/NPI.jhtml</pagseguro_npi_url>
|
125 |
+
<pagseguro_billet_url>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml</pagseguro_billet_url>
|
126 |
+
<pagseguro_transactions_url>https://ws.pagseguro.uol.com.br/v2/transactions</pagseguro_transactions_url>
|
127 |
+
<log_enable>0</log_enable>
|
128 |
+
<use_curl>1</use_curl>
|
129 |
+
<return_default_enable>1</return_default_enable>
|
130 |
+
<return_api_enable>1</return_api_enable>
|
131 |
+
<paid_orders_change_to>processing</paid_orders_change_to>
|
132 |
+
<canceled_orders_change_to>canceled</canceled_orders_change_to>
|
133 |
+
<return_consult_range>30</return_consult_range>
|
134 |
+
</pagseguro_config>
|
135 |
+
<pagseguro_hpp>
|
136 |
+
<model>OsStudios_PagSeguro_Model_Hpp</model>
|
137 |
+
<active>0</active>
|
138 |
+
<title>PagSeguro UOL</title>
|
139 |
+
<order_status>pending</order_status>
|
140 |
+
<custom_address_model>0</custom_address_model>
|
141 |
+
<msg_add>You will be redirected to PagSeguro after the order confirmation.</msg_add>
|
142 |
+
<installments_show>0</installments_show>
|
143 |
+
<installments_add>0</installments_add>
|
144 |
+
<installments_upfront>0</installments_upfront>
|
145 |
+
<price_grouping>0</price_grouping>
|
146 |
+
<shipping_price>separated</shipping_price>
|
147 |
+
<use_return_page_cms>0</use_return_page_cms>
|
148 |
+
<allowspecific>0</allowspecific>
|
149 |
+
</pagseguro_hpp>
|
150 |
+
</payment>
|
151 |
+
</default>
|
152 |
+
<crontab>
|
153 |
+
<jobs>
|
154 |
+
<pagseguro_orders_consult_states>
|
155 |
+
<schedule>
|
156 |
+
<cron_expr>*/15 * * * *</cron_expr>
|
157 |
+
</schedule>
|
158 |
+
<run>
|
159 |
+
<model>pagseguro/observer::cronConsultOrderStates</model>
|
160 |
+
</run>
|
161 |
+
</pagseguro_orders_consult_states>
|
162 |
+
</jobs>
|
163 |
+
</crontab>
|
164 |
+
</config>
|
app/code/community/OsStudios/PagSeguro/etc/system.xml
ADDED
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category OsStudios
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
|
20 |
+
<config>
|
21 |
+
<sections>
|
22 |
+
<payment translate="label" module="payment">
|
23 |
+
<groups>
|
24 |
+
|
25 |
+
<pagseguro_config translate="label">
|
26 |
+
<label>PagSeguro General Configuration</label>
|
27 |
+
<sort_order>2000</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
<comment>
|
32 |
+
<![CDATA[
|
33 |
+
Module Version: 1.0.0<br/>
|
34 |
+
Developed by <b>Tiago Sampaio</b> (<a href="mailto:tiago.sampaio@osstudios.com.br">tiago.sampaio@osstudios.com.br</a><br/>
|
35 |
+
Thanks for downloading our module. Visit Os Studios Website at <a href="http://www.osstudios.com.br" target="_blank">http://www.osstudios.com.br</a>
|
36 |
+
<br/><br/>
|
37 |
+
|
38 |
+
Versão do Módulo: 1.0.0<br/>
|
39 |
+
Desenvolvido por <b>Tiago Sampaio</b> (<a href="mailto:tiago.sampaio@osstudios.com.br">tiago.sampaio@osstudios.com.br</a><br/>
|
40 |
+
Obrigado por baixar nosso módulo. Visite o website da Os Studios em <a href="http://www.osstudios.com.br" target="_blank">http://www.osstudios.com.br</a>
|
41 |
+
<br/><br/>
|
42 |
+
<hr />
|
43 |
+
<br/>
|
44 |
+
The URL you need to configure for Automatic Returns and API Notifications is http://www.yourstore.com/pagseguro/returns/.
|
45 |
+
<br/><br/>
|
46 |
+
A URL para Retorno Automático e Notificações API do PagSeguro que você precisa configurar é http://www.sualoja.com.br/pagseguro/returns/.
|
47 |
+
<br/><br/>
|
48 |
+
<hr />
|
49 |
+
]]>
|
50 |
+
</comment>
|
51 |
+
<fields>
|
52 |
+
<account_email translate="label">
|
53 |
+
<label>PagSeguro Account E-mail</label>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<sort_order>4</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
</account_email>
|
60 |
+
<token translate="label, comment">
|
61 |
+
<label>Token</label>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<sort_order>5</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
<comment>To activate automatic return from PagSeguro access your account and generate a token code and paste it here.</comment>
|
68 |
+
</token>
|
69 |
+
|
70 |
+
<use_curl translate="label">
|
71 |
+
<label>Use cURL</label>
|
72 |
+
<frontend_type>select</frontend_type>
|
73 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
74 |
+
<sort_order>14</sort_order>
|
75 |
+
<show_in_default>1</show_in_default>
|
76 |
+
<show_in_website>1</show_in_website>
|
77 |
+
<show_in_store>1</show_in_store>
|
78 |
+
</use_curl>
|
79 |
+
|
80 |
+
<return_default_enable translate="label, comment">
|
81 |
+
<label>Enable Default Return Process</label>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
84 |
+
<sort_order>15</sort_order>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>1</show_in_website>
|
87 |
+
<show_in_store>1</show_in_store>
|
88 |
+
<comment>Enables the default return processo from PagSeguro.</comment>
|
89 |
+
</return_default_enable>
|
90 |
+
|
91 |
+
<return_api_enable translate="label, comment">
|
92 |
+
<label>Enable API Notifications Process</label>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
95 |
+
<sort_order>16</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
<comment>Enables notification via API from PagSeguro. To use this feature make sure this configuration is set into your account.</comment>
|
100 |
+
</return_api_enable>
|
101 |
+
|
102 |
+
<paid_orders_change_to translate="label, comment">
|
103 |
+
<label>Change Paid Orders to Status</label>
|
104 |
+
<frontend_type>select</frontend_type>
|
105 |
+
<source_model>pagseguro/system_config_source_order_status_paid</source_model>
|
106 |
+
<sort_order>17</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
<comment>Change the order to this status when PagSeguro send approved payments notifications.</comment>
|
111 |
+
</paid_orders_change_to>
|
112 |
+
|
113 |
+
<canceled_orders_change_to translate="label, comment">
|
114 |
+
<label>Change Canceled Orders to Status</label>
|
115 |
+
<frontend_type>select</frontend_type>
|
116 |
+
<source_model>pagseguro/system_config_source_order_status_canceled</source_model>
|
117 |
+
<sort_order>18</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>1</show_in_store>
|
121 |
+
<comment>Change the order to this status when PagSeguro send cancel notifications.</comment>
|
122 |
+
</canceled_orders_change_to>
|
123 |
+
|
124 |
+
<log_enable translate="label, comment">
|
125 |
+
<label>Enable Logging</label>
|
126 |
+
<frontend_type>select</frontend_type>
|
127 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
128 |
+
<sort_order>19</sort_order>
|
129 |
+
<show_in_default>1</show_in_default>
|
130 |
+
<show_in_website>1</show_in_website>
|
131 |
+
<show_in_store>1</show_in_store>
|
132 |
+
<comment>Enables log process. To use this make sure the Magento's log system is enabled.</comment>
|
133 |
+
</log_enable>
|
134 |
+
|
135 |
+
<return_consult_range translate="label, comment">
|
136 |
+
<label>Days Range for Consult Orders</label>
|
137 |
+
<frontend_type>select</frontend_type>
|
138 |
+
<source_model>pagseguro/system_config_source_Consult_daysrange</source_model>
|
139 |
+
<sort_order>20</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>1</show_in_store>
|
143 |
+
<comment>Range of days to consult orders in PagSeguro</comment>
|
144 |
+
</return_consult_range>
|
145 |
+
</fields>
|
146 |
+
</pagseguro_config>
|
147 |
+
|
148 |
+
<pagseguro_hpp translate="label">
|
149 |
+
<label>PagSeguro - HPP</label>
|
150 |
+
<sort_order>2010</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>1</show_in_store>
|
154 |
+
|
155 |
+
<fields>
|
156 |
+
<active translate="label">
|
157 |
+
<label>Enabled</label>
|
158 |
+
<frontend_type>select</frontend_type>
|
159 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
160 |
+
<sort_order>1</sort_order>
|
161 |
+
<show_in_default>1</show_in_default>
|
162 |
+
<show_in_website>1</show_in_website>
|
163 |
+
<show_in_store>1</show_in_store>
|
164 |
+
</active>
|
165 |
+
<title translate="label">
|
166 |
+
<label>Title</label>
|
167 |
+
<frontend_type>text</frontend_type>
|
168 |
+
<sort_order>2</sort_order>
|
169 |
+
<show_in_default>1</show_in_default>
|
170 |
+
<show_in_website>1</show_in_website>
|
171 |
+
<show_in_store>1</show_in_store>
|
172 |
+
</title>
|
173 |
+
<order_status translate="label">
|
174 |
+
<label>New Orders Status</label>
|
175 |
+
<frontend_type>select</frontend_type>
|
176 |
+
<source_model>adminhtml/system_config_source_order_status_new</source_model>
|
177 |
+
<sort_order>3</sort_order>
|
178 |
+
<show_in_default>1</show_in_default>
|
179 |
+
<show_in_website>1</show_in_website>
|
180 |
+
<show_in_store>1</show_in_store>
|
181 |
+
</order_status>
|
182 |
+
<custom_address_model translate="label, comment">
|
183 |
+
<label>Custom Address Model</label>
|
184 |
+
<frontend_type>select</frontend_type>
|
185 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
186 |
+
<sort_order>6</sort_order>
|
187 |
+
<show_in_default>1</show_in_default>
|
188 |
+
<show_in_website>1</show_in_website>
|
189 |
+
<show_in_store>1</show_in_store>
|
190 |
+
<comment>Check documentation to use this option.</comment>
|
191 |
+
</custom_address_model>
|
192 |
+
<msg_add translate="label, comment">
|
193 |
+
<label>Add Message</label>
|
194 |
+
<frontend_type>textarea</frontend_type>
|
195 |
+
<sort_order>10</sort_order>
|
196 |
+
<show_in_default>1</show_in_default>
|
197 |
+
<show_in_website>1</show_in_website>
|
198 |
+
<show_in_store>1</show_in_store>
|
199 |
+
<comment>This content is displayed when customer is choosing the payment method on checkout.</comment>
|
200 |
+
</msg_add>
|
201 |
+
|
202 |
+
<installments_show translate="label, comment">
|
203 |
+
<label>Show Installment</label>
|
204 |
+
<frontend_type>select</frontend_type>
|
205 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
206 |
+
<sort_order>7</sort_order>
|
207 |
+
<show_in_default>1</show_in_default>
|
208 |
+
<show_in_website>1</show_in_website>
|
209 |
+
<show_in_store>1</show_in_store>
|
210 |
+
<comment>To display this option please setup this into your account on PagSeguro.</comment>
|
211 |
+
</installments_show>
|
212 |
+
<installments_add translate="label">
|
213 |
+
<label>No Interest Installment</label>
|
214 |
+
<frontend_type>select</frontend_type>
|
215 |
+
<source_model>pagseguro/system_config_source_installments</source_model>
|
216 |
+
<sort_order>8</sort_order>
|
217 |
+
<show_in_default>1</show_in_default>
|
218 |
+
<show_in_website>1</show_in_website>
|
219 |
+
<show_in_store>1</show_in_store>
|
220 |
+
<depends>
|
221 |
+
<installments_show>1</installments_show>
|
222 |
+
</depends>
|
223 |
+
</installments_add>
|
224 |
+
<installments_upfront translate="label, comment">
|
225 |
+
<label>Discount to no Installments Payment</label>
|
226 |
+
<frontend_type>select</frontend_type>
|
227 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
228 |
+
<sort_order>9</sort_order>
|
229 |
+
<show_in_default>1</show_in_default>
|
230 |
+
<show_in_website>1</show_in_website>
|
231 |
+
<show_in_store>1</show_in_store>
|
232 |
+
<depends><installments_show>1</installments_show></depends>
|
233 |
+
<comment>This option only works when the No Interest Installment is active.</comment>
|
234 |
+
</installments_upfront>
|
235 |
+
|
236 |
+
<price_grouping translate="label, comment">
|
237 |
+
<label>Group Price</label>
|
238 |
+
<frontend_type>select</frontend_type>
|
239 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
240 |
+
<sort_order>10</sort_order>
|
241 |
+
<show_in_default>1</show_in_default>
|
242 |
+
<show_in_website>1</show_in_website>
|
243 |
+
<show_in_store>1</show_in_store>
|
244 |
+
<comment>Enabling this configuration only one product will be sent to PagSeguro Checkout with the grand total of the order.</comment>
|
245 |
+
</price_grouping>
|
246 |
+
<shipping_price translate="label, comment">
|
247 |
+
<label>Shipping Price</label>
|
248 |
+
<frontend_type>select</frontend_type>
|
249 |
+
<source_model>pagseguro/system_config_source_shipping_price</source_model>
|
250 |
+
<sort_order>11</sort_order>
|
251 |
+
<show_in_default>1</show_in_default>
|
252 |
+
<show_in_website>1</show_in_website>
|
253 |
+
<show_in_store>1</show_in_store>
|
254 |
+
<comment>Choose how the shipping price will be sent to PagSeguro Checkout.</comment>
|
255 |
+
</shipping_price>
|
256 |
+
|
257 |
+
<use_return_page_cms translate="label, comment">
|
258 |
+
<label>Use CMS Page as Return</label>
|
259 |
+
<frontend_type>select</frontend_type>
|
260 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
261 |
+
<sort_order>12</sort_order>
|
262 |
+
<show_in_default>1</show_in_default>
|
263 |
+
<show_in_website>1</show_in_website>
|
264 |
+
<show_in_store>1</show_in_store>
|
265 |
+
<comment>By default, this module uses the custom success page.</comment>
|
266 |
+
</use_return_page_cms>
|
267 |
+
|
268 |
+
<return_page translate="label">
|
269 |
+
<label>CMS Page to Return</label>
|
270 |
+
<frontend_type>select</frontend_type>
|
271 |
+
<source_model>pagseguro/system_config_source_returnpage</source_model>
|
272 |
+
<sort_order>13</sort_order>
|
273 |
+
<show_in_default>1</show_in_default>
|
274 |
+
<show_in_website>1</show_in_website>
|
275 |
+
<show_in_store>1</show_in_store>
|
276 |
+
<depends>
|
277 |
+
<use_return_page_cms>1</use_return_page_cms>
|
278 |
+
</depends>
|
279 |
+
</return_page>
|
280 |
+
|
281 |
+
<allowspecific translate="label">
|
282 |
+
<label>Allowed Coutries</label>
|
283 |
+
<frontend_type>select</frontend_type>
|
284 |
+
<sort_order>50</sort_order>
|
285 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
286 |
+
<show_in_default>1</show_in_default>
|
287 |
+
<show_in_website>1</show_in_website>
|
288 |
+
<show_in_store>1</show_in_store>
|
289 |
+
</allowspecific>
|
290 |
+
<specificcountry translate="label">
|
291 |
+
<label>Payments of Allowed Coutries</label>
|
292 |
+
<frontend_type>multiselect</frontend_type>
|
293 |
+
<sort_order>55</sort_order>
|
294 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
295 |
+
<show_in_default>1</show_in_default>
|
296 |
+
<show_in_website>1</show_in_website>
|
297 |
+
<show_in_store>1</show_in_store>
|
298 |
+
<depends>
|
299 |
+
<allowspecific>1</allowspecific>
|
300 |
+
</depends>
|
301 |
+
</specificcountry>
|
302 |
+
|
303 |
+
<sort_order translate="label">
|
304 |
+
<label>Sort Order</label>
|
305 |
+
<frontend_type>text</frontend_type>
|
306 |
+
<sort_order>129</sort_order>
|
307 |
+
<show_in_default>1</show_in_default>
|
308 |
+
<show_in_website>1</show_in_website>
|
309 |
+
<show_in_store>1</show_in_store>
|
310 |
+
</sort_order>
|
311 |
+
|
312 |
+
</fields>
|
313 |
+
</pagseguro_hpp>
|
314 |
+
<pagseguro_api translate="label, comment">
|
315 |
+
<label>PagSeguro - API</label>
|
316 |
+
<sort_order>2020</sort_order>
|
317 |
+
<show_in_default>1</show_in_default>
|
318 |
+
<show_in_website>1</show_in_website>
|
319 |
+
<show_in_store>1</show_in_store>
|
320 |
+
<comment>This feature will be available in next versions of this module.</comment>
|
321 |
+
</pagseguro_api>
|
322 |
+
</groups>
|
323 |
+
</payment>
|
324 |
+
</sections>
|
325 |
+
</config>
|
app/code/community/OsStudios/PagSeguro/sql/pagseguro_setup/mysql4-install-1.0.0.0.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category OsStudios
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
$installer = $this;
|
19 |
+
|
20 |
+
$installer->startSetup();
|
21 |
+
|
22 |
+
$installer->addAttribute('order_payment', 'pagseguro_transaction_id', array());
|
23 |
+
$installer->addAttribute('order_payment', 'pagseguro_payment_method', array());
|
24 |
+
|
25 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/osstudios_pagseguro.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category payment
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
|
20 |
+
<layout>
|
21 |
+
<pagseguro_adminhtml_index_index>
|
22 |
+
|
23 |
+
</pagseguro_adminhtml_index_index>
|
24 |
+
</layout>
|
app/design/frontend/base/default/layout/osstudios_pagseguro.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category payment
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
<layout>
|
20 |
+
|
21 |
+
<pagseguro_pay_success translate="label">
|
22 |
+
<label>Transaction successfully registered in PagSeguro</label>
|
23 |
+
<reference name="root">
|
24 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
25 |
+
</reference>
|
26 |
+
<reference name="content">
|
27 |
+
<block type="pagseguro/success" name="pagseguro.success" template="osstudios/pagseguro/success.phtml"/>
|
28 |
+
</reference>
|
29 |
+
</pagseguro_pay_success>
|
30 |
+
|
31 |
+
<pagseguro_pay_installments translate="label">
|
32 |
+
<label>PagSeguro Installment Table</label>
|
33 |
+
<reference name="root">
|
34 |
+
<action method="setTemplate">
|
35 |
+
<template>osstudios/pagseguro/installments_template.phtml</template>
|
36 |
+
</action>
|
37 |
+
</reference>
|
38 |
+
<reference name="content">
|
39 |
+
<block type="pagseguro/installments" name="pagseguro_installments" as="pagseguro_installments" />
|
40 |
+
</reference>
|
41 |
+
</pagseguro_pay_installments>
|
42 |
+
|
43 |
+
<sales_order_view>
|
44 |
+
<reference name="sales.order.view">
|
45 |
+
<block type="pagseguro/paylink" name="pagseguro_paylink" as="pagseguro_paylink" />
|
46 |
+
</reference>
|
47 |
+
</sales_order_view>
|
48 |
+
|
49 |
+
<catalog_product_view>
|
50 |
+
<reference name="product.info">
|
51 |
+
<block type="pagseguro/installments" name="pagseguro_installments" as="pagseguro_installments" />
|
52 |
+
</reference>
|
53 |
+
</catalog_product_view>
|
54 |
+
|
55 |
+
</layout>
|
app/design/frontend/base/default/template/osstudios/pagseguro/form.phtml
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ($this->getShowForm()): ?>
|
19 |
+
|
20 |
+
<fieldset class="form-list">
|
21 |
+
<ul id="payment_form_<?php echo $this->getMethodCode(); ?>" style="display:none;">
|
22 |
+
<?php if ($this->getShowMessage()): ?>
|
23 |
+
<li><?php echo $this->getMessage(); ?></li>
|
24 |
+
<?php endif; ?>
|
25 |
+
<?php if ($this->getShowInstallments()): ?>
|
26 |
+
<li>
|
27 |
+
<script type="text/javascript" >
|
28 |
+
function switch_installments() {
|
29 |
+
var installments_area = document.getElementById('installments_area');
|
30 |
+
var installments_keyword = document.getElementById('installments_keyword');
|
31 |
+
|
32 |
+
if (installments_area.style.display == 'none') {
|
33 |
+
installments_area.style.display = 'block';
|
34 |
+
installments_keyword.innerHTML = 'Ocultar';
|
35 |
+
} else {
|
36 |
+
installments_area.style.display = 'none';
|
37 |
+
installments_keyword.innerHTML = 'Visualizar';
|
38 |
+
}
|
39 |
+
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
</script>
|
43 |
+
<a href="#" onclick="return switch_installments();"><span id="installments_keyword">Visualizar</span> simulação de pagamentos</a>
|
44 |
+
</li>
|
45 |
+
<li id="installments_area" style="display: none;">
|
46 |
+
<style type="text/css">
|
47 |
+
#installments_table th, #installments_table td {
|
48 |
+
padding: 1px 15px;
|
49 |
+
text-align: left;
|
50 |
+
white-space: nowrap;
|
51 |
+
}
|
52 |
+
#installments_table th {
|
53 |
+
background-color: #F0F0F0;
|
54 |
+
font-weight: bold;
|
55 |
+
text-align: center;
|
56 |
+
}
|
57 |
+
#installments_table td {
|
58 |
+
border-top: 1px solid #999999;
|
59 |
+
text-align: left;
|
60 |
+
font-size: 11px;
|
61 |
+
}
|
62 |
+
#installments_table tr:hover td {
|
63 |
+
background-color: #F7F7F7;
|
64 |
+
}
|
65 |
+
#installments_table .first_col {
|
66 |
+
text-align: center;
|
67 |
+
}
|
68 |
+
#installments_table .highlight_col {
|
69 |
+
padding: 1px 15px 15px;
|
70 |
+
font-size: 13px;
|
71 |
+
}
|
72 |
+
#installments_table .subtitle_line th {
|
73 |
+
font-weight: normal;
|
74 |
+
}
|
75 |
+
</style>
|
76 |
+
<table id="installments_table">
|
77 |
+
<?php if ($this->getShowUpfrontPrice()): ?>
|
78 |
+
<tr>
|
79 |
+
<th colspan="4">Pagamento à vista (boleto, TEF ou saldo PagSeguro)</th>
|
80 |
+
</tr>
|
81 |
+
<tr>
|
82 |
+
<td colspan="4" class="highlight_col">R$ <?php echo $this->getUpfrontPrice(); ?> (<?php echo $this->getUpfrontDiscount(); ?>% de desconto)</td>
|
83 |
+
</tr>
|
84 |
+
<?php endif; ?>
|
85 |
+
<tr>
|
86 |
+
<th colspan="4">Cartão de crédito</th>
|
87 |
+
</tr>
|
88 |
+
<tr class="subtitle_line">
|
89 |
+
<th>Parcelas</th>
|
90 |
+
<th>Valor da parcela</th>
|
91 |
+
<th>Total</th>
|
92 |
+
<th></th>
|
93 |
+
</tr>
|
94 |
+
<?php
|
95 |
+
$installments = $this->getInstallments();
|
96 |
+
foreach ($installments as $parcels => $installment): ?>
|
97 |
+
|
98 |
+
<tr>
|
99 |
+
<td class="first_col"><?php echo $parcels + 1; ?></td>
|
100 |
+
<td>R$ <?php echo $installment['valor_parcela']; ?></td>
|
101 |
+
<td>R$ <?php echo $installment['valor_total']; ?></td>
|
102 |
+
<td><?php echo $installment['msg_extra']; ?></td>
|
103 |
+
</tr>
|
104 |
+
<?php endforeach; ?>
|
105 |
+
</table>
|
106 |
+
</li>
|
107 |
+
<?php endif; ?>
|
108 |
+
</ul>
|
109 |
+
</fieldset>
|
110 |
+
|
111 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/osstudios/pagseguro/info.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
<p>
|
19 |
+
<strong><?php echo $this->getMethod()->getTitle() ?></strong>
|
20 |
+
|
21 |
+
<?php if ($this->getShowPaylink()): ?>
|
22 |
+
(<a href="<?php echo $this->getPayUrl(); ?>" onclick="this.target='_blank'">pagar</a>)
|
23 |
+
<?php endif; ?>
|
24 |
+
|
25 |
+
<?php if ($this->getShowInfo()): ?>
|
26 |
+
<br/>ID da transação: <?php echo $this->getTransactionId(); ?>
|
27 |
+
<br/>Forma de pagamento: <?php echo $this->getPaymentMethod(); ?>
|
28 |
+
<?php endif; ?>
|
29 |
+
|
30 |
+
</p>
|
app/design/frontend/base/default/template/osstudios/pagseguro/installments.phtml
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
|
19 |
+
<?php if ($this->getShowInstallmentsScripts()): ?>
|
20 |
+
<script type="text/javascript">
|
21 |
+
var price_innerhtml;
|
22 |
+
function updateInstallments() {
|
23 |
+
var value = $$('.product-shop>.price-box .price')[0].innerHTML;
|
24 |
+
|
25 |
+
if (value != price_innerhtml) {
|
26 |
+
price_innerhtml = value;
|
27 |
+
|
28 |
+
if ($('installments_table')) {
|
29 |
+
$('installments_table').setStyle({visibility: 'hidden'});
|
30 |
+
$('installments_loading').setStyle({position: 'absolute'});
|
31 |
+
} else {
|
32 |
+
$('installments_loading').setStyle({position: 'relative'});
|
33 |
+
}
|
34 |
+
$('installments_loading').setStyle({display: 'inline'});
|
35 |
+
new Ajax.Updater('installments_area', '<?php echo Mage::getBaseUrl(); ?>pagseguro/pay/installments/price/'+value, {
|
36 |
+
method: 'get',
|
37 |
+
evalScripts: true,
|
38 |
+
onComplete: hideInstallmentsLoading
|
39 |
+
});
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
function hideInstallmentsLoading () {
|
44 |
+
$('installments_loading').setStyle({display: 'none'});
|
45 |
+
}
|
46 |
+
|
47 |
+
Event.observe(window, 'load', function() {
|
48 |
+
price_innerhtml = $$('.price')[0].innerHTML;
|
49 |
+
$$('#product-options-wrapper select, #product-options-wrapper input[type=text]').each( function(e) {
|
50 |
+
Event.observe(e, 'change', updateInstallments);
|
51 |
+
});
|
52 |
+
});
|
53 |
+
</script>
|
54 |
+
|
55 |
+
<style type="text/css">
|
56 |
+
#installments_loading {
|
57 |
+
padding: 20px 12px;
|
58 |
+
font-size: 13px;
|
59 |
+
font-weight: bold;
|
60 |
+
text-align: center;
|
61 |
+
}
|
62 |
+
#installments_table th, #installments_table td {
|
63 |
+
padding: 1px 12px;
|
64 |
+
text-align: left;
|
65 |
+
white-space: nowrap;
|
66 |
+
}
|
67 |
+
#installments_table th {
|
68 |
+
background-color: #F0F0F0;
|
69 |
+
font-weight: bold;
|
70 |
+
text-align: center;
|
71 |
+
}
|
72 |
+
#installments_table td {
|
73 |
+
border-top: 1px solid #999999;
|
74 |
+
text-align: left;
|
75 |
+
font-size: 11px;
|
76 |
+
}
|
77 |
+
#installments_table tr:hover td {
|
78 |
+
background-color: #F7F7F7;
|
79 |
+
}
|
80 |
+
#installments_table .first_col {
|
81 |
+
text-align: center;
|
82 |
+
}
|
83 |
+
#installments_table .highlight_col {
|
84 |
+
padding: 1px 12px 12px;
|
85 |
+
font-size: 13px;
|
86 |
+
}
|
87 |
+
#installments_table .subtitle_line th {
|
88 |
+
font-weight: normal;
|
89 |
+
}
|
90 |
+
</style>
|
91 |
+
<div id="installments_loading" style="display: none;">(Carregando parcelamento...)</div>
|
92 |
+
<div id="installments_area">
|
93 |
+
<?php endif; // $this->getShowInstallmentsScripts() ?>
|
94 |
+
<?php if ($this->getShowInstallments()): ?>
|
95 |
+
<table id="installments_table">
|
96 |
+
<?php if ($this->getShowUpfrontPrice()): ?>
|
97 |
+
<tr>
|
98 |
+
<th colspan="4">Pagamento à vista (boleto, TEF ou saldo PagSeguro)</th>
|
99 |
+
</tr>
|
100 |
+
<tr>
|
101 |
+
<td colspan="4" class="highlight_col">R$ <?php echo $this->getUpfrontPrice(); ?> (<?php echo $this->getUpfrontDiscount(); ?>% de desconto)</td>
|
102 |
+
</tr>
|
103 |
+
<?php endif; ?>
|
104 |
+
<tr>
|
105 |
+
<th colspan="4">Cartão de crédito</th>
|
106 |
+
</tr>
|
107 |
+
<tr class="subtitle_line">
|
108 |
+
<th>Parcelas</th>
|
109 |
+
<th>Valor da parcela</th>
|
110 |
+
<th>Total</th>
|
111 |
+
<th></th>
|
112 |
+
</tr>
|
113 |
+
<?php
|
114 |
+
$installments = $this->getInstallments();
|
115 |
+
foreach ($installments as $parcels => $installment): ?>
|
116 |
+
|
117 |
+
<tr>
|
118 |
+
<td class="first_col"><?php echo $parcels + 1; ?></td>
|
119 |
+
<td>R$ <?php echo $installment['valor_parcela']; ?></td>
|
120 |
+
<td>R$ <?php echo $installment['valor_total']; ?></td>
|
121 |
+
<td><?php echo $installment['msg_extra']; ?></td>
|
122 |
+
</tr>
|
123 |
+
<?php endforeach; ?>
|
124 |
+
</table>
|
125 |
+
<?php endif; // $this->getShowInstallments() ?>
|
126 |
+
<?php if ($this->getShowInstallmentsScripts()): ?>
|
127 |
+
</div>
|
128 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/osstudios/pagseguro/installments_template.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
|
19 |
+
<?php
|
20 |
+
echo $this->getChildHtml('content')
|
21 |
+
?>
|
app/design/frontend/base/default/template/osstudios/pagseguro/paylink.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
|
19 |
+
<?php
|
20 |
+
if ($this->isShowPaylink()): ?>
|
21 |
+
|
22 |
+
<div class="buttons-set">
|
23 |
+
<p>
|
24 |
+
Caso você não tenha efetuado o pagamento através do <strong>PagSeguro</strong> no momento da conclusão de seu pedido,<br />
|
25 |
+
você pode fazê-lo clicando no botão abaixo
|
26 |
+
</p>
|
27 |
+
|
28 |
+
<a href="<?php echo $this->getPaymentUrl() ?>" target="_blank"><img src="https://pagseguro.uol.com.br/Security/Imagens/btnPagueComBR.jpg" alt="Pague com o PagSeguro - é rápido, grátis e seguro!" /></a>
|
29 |
+
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/osstudios/pagseguro/success.phtml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Os Studios PagSeguro Payment Module
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category payment
|
12 |
+
* @package OsStudios_PagSeguro
|
13 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
|
19 |
+
<?php if ($this->getOrderId()):?>
|
20 |
+
|
21 |
+
<div class="page-title">
|
22 |
+
<h1>Pedido incluído com sucesso!</h1>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
26 |
+
|
27 |
+
<p>
|
28 |
+
<?php
|
29 |
+
if ($this->getCanViewOrder()) {
|
30 |
+
$order_link_msg = $this->__('Your order # is: %s', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId())));
|
31 |
+
} else {
|
32 |
+
$order_link_msg = $this->__('Your order # is: %s', $this->escapeHtml($this->getOrderId()));
|
33 |
+
}
|
34 |
+
?>
|
35 |
+
<strong><br /><?php echo $order_link_msg; ?>.</strong>
|
36 |
+
<?php if ($this->getPagseguroTransactionId()):?>
|
37 |
+
<br />
|
38 |
+
<strong>ID da transação PagSeguro:</strong> <?php echo $this->getPagseguroTransactionId();?>
|
39 |
+
<?php endif; ?>
|
40 |
+
</p>
|
41 |
+
<?php if ($this->getCanPrintOrder()):?>
|
42 |
+
<p><?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?></p>
|
43 |
+
<?php endif; ?>
|
44 |
+
|
45 |
+
<p><br />Uma mensagem com os detalhes desta transação foi enviada para o seu email. Você pode também acessar sua conta <strong>PagSeguro</strong> no endereço <a href="https://pagseguro.uol.com.br/" onclick="this.target='_blank'">https://pagseguro.uol.com.br</a> para mais informações.</p>
|
46 |
+
|
47 |
+
<?php if ($this->getPagseguroTransactionId()):?>
|
48 |
+
<?php if ($this->getIsOrderHolded()):?>
|
49 |
+
<p>
|
50 |
+
<?php if ($this->getPagseguroPaymentMethod() == 'Boleto'):?>
|
51 |
+
Por ter escolhido pagar por <strong>boleto bancário</strong>, basta <a href="<?php echo $this->getPagseguroBoletoUrl(); ?>" onclick="this.target='_blank'">imprimi-lo</a> e efetuar o pagamento que nosso sistema se encarregará do restante.
|
52 |
+
<?php else: ?>
|
53 |
+
Assim que seu pagamento for confirmado pelo PagSeguro, o pedido será enviado.
|
54 |
+
<?php endif;?>
|
55 |
+
</p>
|
56 |
+
<?php endif;?>
|
57 |
+
<?php else: ?>
|
58 |
+
<p>Clique <a href="<?php echo $this->getPagseguroPaymentUrl(); ?>">aqui para pagar</a> seu pedido.</p>
|
59 |
+
<?php endif;?>
|
60 |
+
|
61 |
+
<p><strong><?php echo $this->__('Thank you for your purchase!') ?></strong></p>
|
62 |
+
|
63 |
+
<?php else:?>
|
64 |
+
|
65 |
+
<div class="page-title">
|
66 |
+
<h1>Erro</h1>
|
67 |
+
</div>
|
68 |
+
|
69 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
70 |
+
|
71 |
+
<p>Pedido não encontrado.</p>
|
72 |
+
|
73 |
+
<?php endif;?>
|
74 |
+
|
75 |
+
<div class="buttons-set">
|
76 |
+
<button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
77 |
+
</div>
|
app/etc/modules/OsStudios_PagSeguro.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Os Studios PagSeguro Payment Module
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category payment
|
13 |
+
* @package OsStudios_PagSeguro
|
14 |
+
* @copyright Copyright (c) 2012 Os Studios (www.osstudios.com.br)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
* @author Tiago Sampaio <tiago.sampaio@osstudios.com.br>
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
|
20 |
+
<config>
|
21 |
+
<modules>
|
22 |
+
<OsStudios_PagSeguro>
|
23 |
+
<active>true</active>
|
24 |
+
<codePool>community</codePool>
|
25 |
+
<depends>
|
26 |
+
<Mage_Payment/>
|
27 |
+
<Mage_Sales/>
|
28 |
+
</depends>
|
29 |
+
</OsStudios_PagSeguro>
|
30 |
+
</modules>
|
31 |
+
</config>
|
app/locale/pt_BR/OsStudios_PagSeguro.csv
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Yes","Sim"
|
2 |
+
"No","Não"
|
3 |
+
"Enable","Habilitar"
|
4 |
+
"Disable","Desabilitar"
|
5 |
+
"Enabled","Habilitado"
|
6 |
+
"Title","Título"
|
7 |
+
"New Orders Status","Status Para Novos Pedidos"
|
8 |
+
"PagSeguro Account E-mail","E-mail da Conta do PagSeguro"
|
9 |
+
"Custom Address Model","Modelo de Endereço Personalizado"
|
10 |
+
"Show Installment","Exibir Parcelamento"
|
11 |
+
"No Interest Installment","Parcelamento Sem Juros"
|
12 |
+
"Discount to no Installments Payment","Desconto á Vista"
|
13 |
+
"Group Price","Agrupar Preço"
|
14 |
+
"Add Message","Mensagem Adicional"
|
15 |
+
"Shipping Price","Valor do Frete"
|
16 |
+
"Use CMS Page as Return","Utilizar Página CMS como Retorno"
|
17 |
+
"Use cURL","Usar cURL"
|
18 |
+
"Allowed Coutries","Países Permitidos"
|
19 |
+
"All Allowed Countries","Todos os Países Permitidos"
|
20 |
+
"Specific Countries","Países Específicos"
|
21 |
+
"Payments of Allowed Coutries","Permitir Pagamentos de Países"
|
22 |
+
"Enable Logging","Habilitar Log"
|
23 |
+
"Log Types","Tipos de Logs"
|
24 |
+
"Separated","Separado"
|
25 |
+
"As Product","Como Produto"
|
26 |
+
"Grouped","Agrupado"
|
27 |
+
"Max %sx","Até %sx"
|
28 |
+
"Deactivated (%sx)","Desativado (%sx)"
|
29 |
+
"Beginning and Ending Tags","Tags de Início e Fim"
|
30 |
+
"PagSeguro Return Data","Dados de Retorno do PagSeguro"
|
31 |
+
"PagSeguro Confirmation Status","Status de Confimação do PagSeguro"
|
32 |
+
"PagSeguro Order Status","Status do Pedido no PagSeguro"
|
33 |
+
"Separator","Separador"
|
34 |
+
"Sort Order","Ordenação"
|
35 |
+
"To activate automatic return from PagSeguro access your account and generate a token code and paste it here.","Para ativar o retorno automático do PagSeguro acesse sua conta, gere um código de token e cole aqui."
|
36 |
+
"Check documentation to use this option.","Leia a documentação para utilizar esta opção."
|
37 |
+
"To display this option please setup this into your account on PagSeguro.","Para mostrar esta opção, por favor, configure-a em sua conta no PagSeguro."
|
38 |
+
"This option only works when the No Interest Installment is active.","Esta opção só funciona quando a opção de parcelamento sem jutos está ativa."
|
39 |
+
"Enabling this configuration only one product will be sent to PagSeguro Checkout with the grand total of the order.","Habilitando esta configuração apenas um produto será enviado para o carrinho do PagSeguro com o total do pedido."
|
40 |
+
"You will be redirected to PagSeguro after the order confirmation.","Você será redirecionado(a) para o PagSeguro após a confirmação do pedido."
|
41 |
+
"This content is displayed when customer is choosing the payment method on checkout.","Esta mensagem será mostrada quando o cliente escolher PagSeguro UOL como opção de pagamento no checkout da compra."
|
42 |
+
"Choose how the shipping price will be sent to PagSeguro Checkout.","Escolha como o valor do frete será enviado ao PagSeguro"
|
43 |
+
"By default, this module uses the custom success page.","Por padrão, este módulo utiliza o página de sucesso personalizada."
|
44 |
+
"Beginning of Return","Início do Retorno"
|
45 |
+
"Post Data","Dados do Post"
|
46 |
+
"End of Post Data","Fim de Dados do Post"
|
47 |
+
"Ending of Return","Fim do Retorno"
|
48 |
+
"Confirmation Success!","Sucesso na Confirmação!"
|
49 |
+
"Confirmation Denied...","Confirmação Negada..."
|
50 |
+
"Order #%s: %s","Pedido #%s: %s"
|
51 |
+
"Payment confirmed (%s). PagSeguro Transaction: %s.","Pagamento confirmado (%s). Transação PagSeguro: %s."
|
52 |
+
"Invoice Created!","Fatura Criada!"
|
53 |
+
"Invoice Not Created!","Fatura Não Criada!"
|
54 |
+
"Payment Returned.","Pagamento Devolvido."
|
55 |
+
"Payment Canceled.","Pagamento Cancelado."
|
56 |
+
"Updated Order Status: %s.","Status do Pedido Atualizado: %s."
|
57 |
+
"ERROR: O value received is different from the stored one (STORED VALUE: %s / RECEIVED VALUE: %s).","ERRO: O valor recebido é diferente do valor original (VALOR ORIGINAL: %s / VALOR RECEBIDO: %s)."
|
58 |
+
"ERROR: This order was not placed with this payment method.","ERRO: Neste pedido não foi utilizado o PagSeguro como forma de pagamento."
|
59 |
+
"ERROR: The order reference was not found.","ERRO: Este número de pedido não foi encontrado no sistema."
|
60 |
+
"Enable Default Return Process","Habilitar Processo de Retorno Automático"
|
61 |
+
"Enable API Notifications Process","Habilitar Processo de Notificações API"
|
62 |
+
"Days Range for Consult Orders","Consultar pedidos de 'N' dias anteriores"
|
63 |
+
"This feature will be available in next versions of this module.","Este recurso estará disponível nas próximas versões deste módulo."
|
64 |
+
"From %s day(s) before to now","De %s dia(s) anterior(es) até o momento"
|
65 |
+
"PagSeguro General Configuration","Configurações Gerais do PagSeguro"
|
66 |
+
"Closed","Fechado"
|
67 |
+
"Canceled","Cancelado"
|
68 |
+
"Payment Review","Revisando Pagamento"
|
69 |
+
"Processing","Processando"
|
70 |
+
"Holded","Congelado"
|
71 |
+
"Range of days to consult orders in PagSeguro","Limite entre dias para consultar pedidos no PagSeguro"
|
72 |
+
"Enables log process. To use this make sure the Magento's log system is enabled.","Habilita processo de log. Para utilizar este recurso certifique-se de que o log de sistema do Magento está habilitado."
|
73 |
+
"Change the order to this status when PagSeguro send cancel notifications.","Alterar o pedido para este status quando o PagSeguro enviar notificações de cancelamento."
|
74 |
+
"Change the order to this status when PagSeguro send approved payments notifications.","Alterar o pedido para este status quando o PagSeguro enviar notificações de pedidos com pagamento aprovado."
|
75 |
+
"Enables notification via API from PagSeguro. To use this feature make sure this configuration is set into your account.","Habilita a notificação via API do PagSeguro. Para utilizar este recurso certifique-se de que esta opção está configurada em sua conta."
|
76 |
+
"Enables the default return processo from PagSeguro.","Habilita o processo de returno automático padrão do PagSeguro."
|
77 |
+
"Change Paid Orders to Status","Mudar Status de Pedidos Pagos Para"
|
78 |
+
"Change Canceled Orders to Status","Mudar Status de Pedidos Cancelados Para"
|
79 |
+
"Order was canceled by PagSeguro.","O pedido foi cancelado pelo PagSeguro."
|
80 |
+
"Invoice #%s was created.","Fatura #%s criada."
|
81 |
+
"Credit Card","Cartão de Crédito"
|
82 |
+
"Billet","Boleto"
|
83 |
+
"Online Debit","Débito Online"
|
84 |
+
"PagSeguro Credit","Crédito PagSeguro"
|
85 |
+
"Oi Paggo","Oi Paggo"
|
86 |
+
"Not Provided","Não Informado"
|
87 |
+
"Check for Order Updates","Verificar Status de Pedidos no PagSeguro"
|
package.xml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>OsStudios_PagSeguro</name>
|
4 |
+
<version>1.0.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>New Module for PagSeguro UOL and Magento Commerce Integration.
|
10 |
+
_________________________________________________________
|
11 |
+

|
12 |
+
Novo módulo para integração completa com PagSeguro da UOL.</summary>
|
13 |
+
<description>This is the newest module to integrate PagSeguro UOL and Magento Commerce. Available for Brazil only.
|
14 |
+
________________________________________________________________________________________________________
|
15 |
+

|
16 |
+
Este é mais novo módulo para uma integração completa com o sistema de pagamentos da UOL: O PagSeguro.
|
17 |
+
Com ele seus pedidos serão automaticamente atualizados e você poderá ter um log de todos os retornos que o PagSeguro enviou.
|
18 |
+
Este módulo inclui compatibilidade com os 3 tipos de retornos que o PagSeguro oferece atualmente: O retorno automático de dados, as notificações via API e consulta por datas. Isso mesmo, agora você mesmo pode consultar o status de seus pedidos no PagSeguro.
|
19 |
+
A intenção é melhorar este módulo e trazer aos usuários do Magento Community uma ferramenta que realmente funcione.
|
20 |
+

|
21 |
+
Mais novidades virão em novas versões do módulo.
|
22 |
+

|
23 |
+
Tiago Sampaio</description>
|
24 |
+
<notes>Principais características desta versão:
|
25 |
+

|
26 |
+
- Integração com Módulo de Pagamentos PagSeguro;
|
27 |
+
- Retorno Automático de Dados;
|
28 |
+
- Notificações API;
|
29 |
+
- Consulta de Pedidos;
|
30 |
+
- Rastreio por Logs;
|
31 |
+
- Mudança de Status de Pedido Automaticamente;
|
32 |
+

|
33 |
+
Novas funcionalidades serão implementadas em versões futuras.
|
34 |
+
Por favor, mandem sugestões de melhorias.
|
35 |
+

|
36 |
+
Tiago Sampaio</notes>
|
37 |
+
<authors><author><name>Tiago Sampaio</name><user>tiagosampaio</user><email>tiago.sampaio@osstudios.com.br</email></author></authors>
|
38 |
+
<date>2012-07-07</date>
|
39 |
+
<time>04:15:45</time>
|
40 |
+
<contents><target name="magecommunity"><dir name="OsStudios"><dir name="PagSeguro"><dir name="Block"><file name="Form.php" hash="85e0fe2291a2f552f8ffee3d5561cdd6"/><file name="Info.php" hash="48bea09184d59f6988d0227373ef7a6a"/><file name="Installments.php" hash="3d45ef51c55dbeed6c659de36674fd95"/><file name="Paylink.php" hash="a7470e6823f3315dd09fdfb0e67fb3aa"/><file name="Success.php" hash="1bd7869509fa55b5dcd846e71171d334"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="3247a8eff971714f2ff48231a07acec0"/></dir></dir><dir name="Helper"><file name="Data.php" hash="0da4017c42c01d3015f5ea55cf0431d1"/><file name="Visie.php" hash="2acce09b47957826fb6cbc8e2cb14a3c"/></dir><dir name="Model"><file name="Abstract.php" hash="2b312c44f3cd61c182ffe46b94a94889"/><file name="Credentials.php" hash="8549eb93ecdcedd57a3b069728628f45"/><file name="Data.php" hash="61eddf60cb710d9528a81a731a5bb411"/><file name="Hpp.php" hash="3d58ba66c3d8ea6871db1b15b69187c2"/><file name="Observer.php" hash="a8868681036d6458af2795b7061f8385"/><file name="Payment.php" hash="0436db471d26854d0f6b7a320b94c679"/><dir name="Returns"><file name="Orders.php" hash="7f4f5c93e51f6d731380c27858b241d0"/><dir name="Types"><file name="Abstract.php" hash="4202b796dcb5911707bbe271e0ab8766"/><file name="Api.php" hash="6a893399575730524eb3ba4873deeffd"/><file name="Consult.php" hash="6a70b87dfa80f576a661613b79a82f10"/><file name="Default.php" hash="4be1cd2c2dfc8190060345f6c8c9b675"/><dir name="Transactions"><file name="Transaction.php" hash="35f8808dcddb6f327746f39eddd5b6e8"/></dir></dir></dir><file name="Returns.php" hash="10562590c7edbd7819b7b86003f0b944"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Consult"><file name="Daysrange.php" hash="3ed461eebd5f2f3d3ae42504857c3b4d"/></dir><file name="Installments.php" hash="92b9f158728dddffa59019d55b02cd54"/><dir name="Log"><file name="Types.php" hash="d3531519b190e0292bf621d40a84d79e"/></dir><dir name="Order"><dir name="Status"><file name="Canceled.php" hash="915b1695727373e9406e943686554cac"/><file name="Paid.php" hash="68bab90c7deb65ebdf685066b7d1b891"/></dir></dir><file name="Returnpage.php" hash="043bb9e72a54689ed4a66bb42b5c80fd"/><dir name="Shipping"><file name="Price.php" hash="a4969209b222ba796bb02688ba1b8ec7"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ReturnsController.php" hash="22f02655a4df65fe17cd9f5a8ca70730"/></dir><file name="PayController.php" hash="f4311fc72544cc190316b772d00ba2b7"/><file name="ReturnsController.php" hash="eae1c1a55cfdb32a75d3b752b133d875"/></dir><dir name="etc"><file name="adminhtml.xml" hash="93d02fa37ade1e290b0b9e38c403895f"/><file name="config.xml" hash="ca3479edd642367bfaa7a71a9e1ab8a1"/><file name="system.xml" hash="3990314dec7bb01222c7fb725bc97b94"/></dir><dir name="sql"><dir name="pagseguro_setup"><file name="mysql4-install-1.0.0.0.php" hash="4662650efc35c4a18a5dcc83497a4259"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="osstudios_pagseguro.xml" hash="750ad708caea1153c14db343ebf238bc"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="osstudios_pagseguro.xml" hash="cbde89eb22841640a304778253af56a6"/></dir><dir name="template"><dir name="osstudios"><dir name="pagseguro"><file name="form.phtml" hash="1f19cc8d7a52a34592ac1b69b1d8bcc4"/><file name="info.phtml" hash="be06a349d56803db37a36f5565f194f6"/><file name="installments.phtml" hash="efa44d37350bd7b6b72e54c45cbb20d0"/><file name="installments_template.phtml" hash="e524c238796b7508086beed3da683ad2"/><file name="paylink.phtml" hash="604895889e401ba8156308b5ad4892e9"/><file name="success.phtml" hash="dbb9f8b5fa4090a9c1b075647d473859"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="pt_BR"><file name="OsStudios_PagSeguro.csv" hash="67f110cb567bcffec97c6d83a14cbb76"/></dir></target><target name="mage"><dir name="."><dir name="app"><dir name="etc"><dir name="modules"><file name="OsStudios_PagSeguro.xml" hash="d1d8999b039ca46c553a83e80457d56c"/></dir></dir></dir></dir></target></contents>
|
41 |
+
<compatible/>
|
42 |
+
<dependencies><required><php><min>5.3.0</min><max>5.4.4</max></php></required></dependencies>
|
43 |
+
</package>
|