OsStudios_PagSeguroApi - Version 1.0.0.2

Version Notes

Fixed Bugs

- Corrected translations

Download this release

Release Info

Developer Tiago Sampaio
Extension OsStudios_PagSeguroApi
Version 1.0.0.2
Comparing to
See all releases


Version 1.0.0.2

Files changed (58) hide show
  1. app/code/community/OsStudios/PagSeguroApi/Block/Adminhtml/Transaction.php +30 -0
  2. app/code/community/OsStudios/PagSeguroApi/Block/Adminhtml/Transaction/Grid.php +151 -0
  3. app/code/community/OsStudios/PagSeguroApi/Block/Api/Form.php +58 -0
  4. app/code/community/OsStudios/PagSeguroApi/Block/Api/Info.php +161 -0
  5. app/code/community/OsStudios/PagSeguroApi/Block/Api/Installments.php +93 -0
  6. app/code/community/OsStudios/PagSeguroApi/Block/Api/Success.php +71 -0
  7. app/code/community/OsStudios/PagSeguroApi/Controller/Adminhtml/Action.php +29 -0
  8. app/code/community/OsStudios/PagSeguroApi/Controller/Front/Action.php +57 -0
  9. app/code/community/OsStudios/PagSeguroApi/Helper/Data.php +137 -0
  10. app/code/community/OsStudios/PagSeguroApi/Helper/Visie.php +212 -0
  11. app/code/community/OsStudios/PagSeguroApi/Model/Abstract.php +197 -0
  12. app/code/community/OsStudios/PagSeguroApi/Model/Consulter.php +175 -0
  13. app/code/community/OsStudios/PagSeguroApi/Model/Credentials.php +53 -0
  14. app/code/community/OsStudios/PagSeguroApi/Model/Data.php +23 -0
  15. app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Payment/History.php +33 -0
  16. app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Payment/History/Collection.php +32 -0
  17. app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Returns/Transaction.php +33 -0
  18. app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Returns/Transaction/Collection.php +32 -0
  19. app/code/community/OsStudios/PagSeguroApi/Model/Observer.php +38 -0
  20. app/code/community/OsStudios/PagSeguroApi/Model/Payment.php +166 -0
  21. app/code/community/OsStudios/PagSeguroApi/Model/Payment/History.php +26 -0
  22. app/code/community/OsStudios/PagSeguroApi/Model/Payment/Method/Api.php +218 -0
  23. app/code/community/OsStudios/PagSeguroApi/Model/Payment/Method/Api/Xml.php +370 -0
  24. app/code/community/OsStudios/PagSeguroApi/Model/Resource/Payment/History.php +33 -0
  25. app/code/community/OsStudios/PagSeguroApi/Model/Resource/Payment/History/Collection.php +32 -0
  26. app/code/community/OsStudios/PagSeguroApi/Model/Resource/Returns/Transaction.php +33 -0
  27. app/code/community/OsStudios/PagSeguroApi/Model/Resource/Returns/Transaction/Collection.php +32 -0
  28. app/code/community/OsStudios/PagSeguroApi/Model/Returns.php +191 -0
  29. app/code/community/OsStudios/PagSeguroApi/Model/Returns/Transaction.php +183 -0
  30. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Config.php +43 -0
  31. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Error/Codes.php +32 -0
  32. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Shipping/Type.php +32 -0
  33. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Payment/Methods/Codes.php +32 -0
  34. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Payment/Methods/Types.php +32 -0
  35. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Sources.php +32 -0
  36. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Status.php +32 -0
  37. app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Types.php +32 -0
  38. app/code/community/OsStudios/PagSeguroApi/controllers/Adminhtml/ActionsController.php +38 -0
  39. app/code/community/OsStudios/PagSeguroApi/controllers/Adminhtml/TransactionController.php +101 -0
  40. app/code/community/OsStudios/PagSeguroApi/controllers/PayController.php +73 -0
  41. app/code/community/OsStudios/PagSeguroApi/controllers/ReturnsController.php +82 -0
  42. app/code/community/OsStudios/PagSeguroApi/etc/adminhtml.xml +105 -0
  43. app/code/community/OsStudios/PagSeguroApi/etc/config.xml +772 -0
  44. app/code/community/OsStudios/PagSeguroApi/etc/system.xml +273 -0
  45. app/code/community/OsStudios/PagSeguroApi/sql/pagseguroapi_setup/mysql4-install-1.0.0.0.php +72 -0
  46. app/design/adminhtml/default/default/layout/osstudios/pagseguroapi.xml +34 -0
  47. app/design/adminhtml/default/default/template/osstudios/pagseguroapi/info.phtml +53 -0
  48. app/design/frontend/base/default/layout/osstudios/pagseguroapi.xml +35 -0
  49. app/design/frontend/base/default/template/osstudios/pagseguroapi/form.phtml +26 -0
  50. app/design/frontend/base/default/template/osstudios/pagseguroapi/info.phtml +53 -0
  51. app/design/frontend/base/default/template/osstudios/pagseguroapi/installments.phtml +91 -0
  52. app/design/frontend/base/default/template/osstudios/pagseguroapi/success.phtml +61 -0
  53. app/etc/modules/OsStudios_PagSeguroApi.xml +31 -0
  54. app/locale/pt_BR/OsStudios/PagSeguroApi.csv +164 -0
  55. package.xml +65 -0
  56. skin/frontend/base/default/css/pagseguroapi/checkout.css +40 -0
  57. skin/frontend/base/default/images/pagseguroapi/cards-sprite.gif +0 -0
  58. skin/frontend/base/default/images/pagseguroapi/logo-pagseguro.gif +0 -0
app/code/community/OsStudios/PagSeguroApi/Block/Adminhtml/Transaction.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Block_Adminhtml_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ $this->_controller = 'adminhtml_transaction';
24
+ $this->_blockGroup = 'pagseguroapi';
25
+ $this->_headerText = Mage::helper('pagseguroapi')->__('Transaction History (Consults and Notifications)');
26
+ parent::__construct();
27
+ $this->_removeButton('add');
28
+ }
29
+
30
+ }
app/code/community/OsStudios/PagSeguroApi/Block/Adminhtml/Transaction/Grid.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Block_Adminhtml_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid
19
+ {
20
+
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ $this->setId('transactionGrid');
25
+ $this->setDefaultSort('created_at');
26
+ $this->setDefaultDir('DESC');
27
+ $this->setUseAjax(true);
28
+ $this->setSaveParametersInSession(true);
29
+ }
30
+
31
+
32
+ protected function _prepareCollection()
33
+ {
34
+ $collection = Mage::getModel("pagseguroapi/returns_transaction")->getCollection();
35
+ $this->setCollection($collection);
36
+ return parent::_prepareCollection();
37
+ }
38
+
39
+
40
+ protected function _prepareColumns()
41
+ {
42
+ $this->addColumn('reference', array(
43
+ 'header' => Mage::helper('pagseguroapi')->__('Reference'),
44
+ 'index' => 'reference',
45
+ 'width' => '50px',
46
+ ));
47
+
48
+ $this->addColumn('code', array(
49
+ 'header' => Mage::helper('pagseguroapi')->__('Transaction ID'),
50
+ 'index' => 'code',
51
+ ));
52
+
53
+ $this->addColumn('type', array(
54
+ 'header' => Mage::helper('pagseguroapi')->__('Type'),
55
+ 'index' => 'type',
56
+ 'type' => 'options',
57
+ 'options' => Mage::getModel('pagseguroapi/system_config_source_transaction_types')->getAssociativeArray(),
58
+ ));
59
+
60
+ $this->addColumn('payment_method_type', array(
61
+ 'header' => Mage::helper('pagseguroapi')->__('Payment Method Type'),
62
+ 'index' => 'payment_method_type',
63
+ 'type' => 'options',
64
+ 'options' => Mage::getModel('pagseguroapi/system_config_source_transaction_payment_methods_types')->getAssociativeArray(),
65
+ ));
66
+
67
+ $this->addColumn('payment_method_code', array(
68
+ 'header' => Mage::helper('pagseguroapi')->__('Payment Method Code'),
69
+ 'index' => 'payment_method_code',
70
+ 'type' => 'options',
71
+ 'options' => Mage::getModel('pagseguroapi/system_config_source_transaction_payment_methods_codes')->getAssociativeArray(),
72
+ ));
73
+
74
+ $this->addColumn('status', array(
75
+ 'header' => Mage::helper('pagseguroapi')->__('Status'),
76
+ 'index' => 'status',
77
+ 'type' => 'options',
78
+ 'options'=> Mage::getModel('pagseguroapi/system_config_source_transaction_status')->getAssociativeArray(),
79
+ 'width' => '150px',
80
+ ));
81
+
82
+ $this->addColumn('fee_amount', array(
83
+ 'header' => Mage::helper('pagseguroapi')->__('Fee Amount'),
84
+ 'index' => 'fee_amount',
85
+ 'type' => 'currency',
86
+ 'width' => '50px',
87
+ ));
88
+
89
+ $this->addColumn('installment_count', array(
90
+ 'header' => Mage::helper('pagseguroapi')->__('Installment Count'),
91
+ 'index' => 'installment_count',
92
+ 'width' => '50px',
93
+ 'align' => 'center',
94
+ 'type' => 'number',
95
+ ));
96
+
97
+ $this->addColumn('received_from', array(
98
+ 'header' => Mage::helper('pagseguroapi')->__('Received From'),
99
+ 'index' => 'received_from',
100
+ 'type' => 'options',
101
+ 'options' => Mage::getModel('pagseguroapi/system_config_source_transaction_sources')->getAssociativeArray(),
102
+ 'width' => '50px',
103
+ ));
104
+
105
+ $this->addColumn('last_event_date', array(
106
+ 'header' => Mage::helper('pagseguroapi')->__('Last Event Date'),
107
+ 'index' => 'last_event_date',
108
+ 'type' => 'datetime',
109
+ 'width' => '50px',
110
+ ));
111
+
112
+ $this->addColumn('created_at', array(
113
+ 'header' => Mage::helper('pagseguroapi')->__('Created At'),
114
+ 'index' => 'created_at',
115
+ 'type' => 'datetime',
116
+ 'width' => '50px',
117
+ ));
118
+
119
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
120
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
121
+
122
+ return parent::_prepareColumns();
123
+ }
124
+
125
+
126
+ public function getGridUrl()
127
+ {
128
+ return $this->getUrl('*/*/grid', array('_current'=> true));
129
+ }
130
+
131
+
132
+ public function getRowUrl($row)
133
+ {
134
+ return;
135
+ }
136
+
137
+
138
+ protected function _prepareMassaction()
139
+ {
140
+ $this->setMassactionIdField('id');
141
+ $this->getMassactionBlock()->setFormFieldName('ids');
142
+ $this->getMassactionBlock()->setUseSelectAll(true);
143
+ $this->getMassactionBlock()->addItem('remove_transaction', array(
144
+ 'label' => Mage::helper('pagseguroapi')->__('Remove Transaction(s)'),
145
+ 'url' => $this->getUrl('*/adminhtml_transaction/massRemove'),
146
+ 'confirm' => Mage::helper('pagseguroapi')->__('Are you sure?')
147
+ ));
148
+ return $this;
149
+ }
150
+
151
+ }
app/code/community/OsStudios/PagSeguroApi/Block/Api/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Block_Api_Form extends Mage_Payment_Block_Form
19
+ {
20
+
21
+ /**
22
+ * Sets the template
23
+ *
24
+ * @return OsStudios_PagSeguroApi_Block_Api_Form
25
+ */
26
+ public function _construct() {
27
+ parent::_construct();
28
+ $this->setTemplate('osstudios/pagseguroapi/form.phtml');
29
+
30
+ return $this;
31
+ }
32
+
33
+
34
+ /**
35
+ * Whether the message will be shown
36
+ *
37
+ * @return boolean
38
+ */
39
+ public function getShowMessage()
40
+ {
41
+ if(Mage::getSingleton('pagseguroapi/data')->getConfigData('message')) {
42
+ return true;
43
+ }
44
+ return false;;
45
+ }
46
+
47
+
48
+ /**
49
+ * Provides the message
50
+ *
51
+ * @return string
52
+ */
53
+ public function getMessage()
54
+ {
55
+ return Mage::getSingleton('pagseguroapi/data')->getConfigData('message');
56
+ }
57
+
58
+ }
app/code/community/OsStudios/PagSeguroApi/Block/Api/Info.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Payment Info Block
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Block_Api_Info extends Mage_Payment_Block_Info
24
+ {
25
+
26
+ /**
27
+ * Sets the template
28
+ *
29
+ * @return OsStudios_PagSeguroApi_Block_Api_Info
30
+ */
31
+ protected function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->setTemplate('osstudios/pagseguroapi/info.phtml');
35
+
36
+ return $this;
37
+ }
38
+
39
+
40
+ protected function _getOrder()
41
+ {
42
+ return $this->getInfo()->getOrder();
43
+ }
44
+
45
+
46
+ protected function _getPayment()
47
+ {
48
+ return $this->_getOrder()->getPayment();
49
+ }
50
+
51
+
52
+ protected function _beforeToHtml()
53
+ {
54
+ $this->_prepareInfo();
55
+ return parent::_beforeToHtml();
56
+ }
57
+
58
+
59
+ protected function _prepareInfo()
60
+ {
61
+ $order = $this->_getOrder();
62
+
63
+ if($order instanceof Mage_Sales_Model_Order) {
64
+ $payment = $order->getPayment();
65
+ $pagseguroInfo = $payment->getPagseguroInfo();
66
+
67
+ if($pagseguroInfo) {
68
+ $this->setPagseguroInfo($pagseguroInfo);
69
+ }
70
+ }
71
+ }
72
+
73
+
74
+ public function getShowInfo()
75
+ {
76
+ if($this->getPagseguroInfo()) {
77
+ return true;
78
+ }
79
+
80
+ return false;
81
+ }
82
+
83
+
84
+ public function isPaid()
85
+ {
86
+ return ($this->getPagseguroInfo()->getPagseguroTransactionStatus() == 1);
87
+ }
88
+
89
+
90
+ public function isCanceled()
91
+ {
92
+ return ($this->getPagseguroInfo()->getPagseguroTransactionStatus() == 7);
93
+ }
94
+
95
+
96
+ public function getShowPaylink()
97
+ {
98
+ if(!$this->isPaid() && !$this->isCanceled() && !$this->getShowPayBilletUrl()) {
99
+ return true;
100
+ }
101
+
102
+ return false;
103
+ }
104
+
105
+
106
+ public function getShowPayBilletUrl()
107
+ {
108
+ if(!$this->isPaid() && !$this->isCanceled() && ($this->getPagseguroInfo()->getPagseguroPaymentMethodType() == 2)) {
109
+ return true;
110
+ }
111
+
112
+ return false;
113
+ }
114
+
115
+
116
+ public function getBilletPayUrl()
117
+ {
118
+ if($this->getShowPayBilletUrl()) {
119
+ return Mage::getSingleton('pagseguroapi/data')->getPagSeguroBilletUrl($this->getPagseguroInfo()->getPagseguroTransactionId());
120
+ }
121
+
122
+ return;
123
+ }
124
+
125
+
126
+ public function getPayUrl()
127
+ {
128
+ if($this->getShowPaylink()) {
129
+ return Mage::getSingleton('pagseguroapi/data')->getPagseguroApiRedirectUrl($this->getPagseguroInfo()->getPagseguroPaymentIdentifierCode());
130
+ }
131
+
132
+ return;
133
+ }
134
+
135
+
136
+ public function getTransactionPaymentMethodTypeLabel()
137
+ {
138
+ $paymentMethodType = $this->_getPayment()->getPagseguroInfo()->getPagseguroPaymentMethodType();
139
+ $label = Mage::getSingleton('pagseguroapi/data')->getTransactionPaymentMethodTypeLabel($paymentMethodType);
140
+
141
+ return $label;
142
+ }
143
+
144
+
145
+ public function getTransactionPaymentMethodCodeLabel()
146
+ {
147
+ $paymentMethodCode = $this->_getPayment()->getPagseguroInfo()->getPagseguroPaymentMethodCode();
148
+ $label = Mage::getSingleton('pagseguroapi/data')->getTransactionPaymentMethodCodeLabel($paymentMethodCode);
149
+
150
+ return $label;
151
+ }
152
+
153
+
154
+ public function getTransactionStatusLabel()
155
+ {
156
+ $transactionStatus = $this->_getPayment()->getPagseguroInfo()->getPagseguroTransactionStatus();
157
+ $label = Mage::getSingleton('pagseguroapi/data')->getTransactionStatusLabel($transactionStatus);
158
+
159
+ return $label;
160
+ }
161
+ }
app/code/community/OsStudios/PagSeguroApi/Block/Api/Installments.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Payment Installments Block
20
+ * Reference https://pagseguro.uol.com.br/para_seu_negocio/parcelamento_com_acrescimo.jhtml#rmcl
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Block_Api_Installments extends Mage_Core_Block_Template
24
+ {
25
+
26
+ protected $_creditCards = null;
27
+ protected $_factors = null;
28
+
29
+
30
+ /**
31
+ * Sets the template
32
+ *
33
+ * @return Mage_Core_Block_Template
34
+ */
35
+ public function _construct()
36
+ {
37
+ $this->setTemplate('osstudios/pagseguroapi/installments.phtml');
38
+ return parent::_construct();
39
+ }
40
+
41
+
42
+ /**
43
+ * Provides the quote object
44
+ *
45
+ * @return Mage_Sales_Model_Quote
46
+ */
47
+ public function getQuote()
48
+ {
49
+ return Mage::getSingleton('checkout/session')->getQuote();
50
+ }
51
+
52
+
53
+ /**
54
+ * Provides the factor list to calculate the installments
55
+ *
56
+ * @return array
57
+ */
58
+ public function getFactors()
59
+ {
60
+ if(!$this->_factors) {
61
+ $this->_factors = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/installments/factors')->asArray();
62
+ }
63
+
64
+ return $this->_factors;
65
+ }
66
+
67
+
68
+ /**
69
+ * Provides the list of credit cards
70
+ *
71
+ * @return array
72
+ */
73
+ public function getCreditCards()
74
+ {
75
+ if(!$this->_creditCards) {
76
+ $this->_creditCards = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/installments/credit_cards')->asArray();
77
+ }
78
+
79
+ return $this->_creditCards;
80
+ }
81
+
82
+
83
+ /**
84
+ * Whether the installments will be displayed or not
85
+ *
86
+ * @return boolean
87
+ */
88
+ public function showInstallments()
89
+ {
90
+ return Mage::getStoreConfig('payment/pagseguro_api/show_installments');
91
+ }
92
+
93
+ }
app/code/community/OsStudios/PagSeguroApi/Block/Api/Success.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Block_Api_Success extends Mage_Core_Block_Template
19
+ {
20
+
21
+ /**
22
+ * Sets the template
23
+ *
24
+ * @return Mage_Core_Block_Template
25
+ */
26
+ public function _construct()
27
+ {
28
+ $this->setTemplate('osstudios/pagseguroapi/success.phtml');
29
+ return parent::_construct();
30
+ }
31
+
32
+
33
+ /**
34
+ * Before rendering html, but after trying to load cache
35
+ *
36
+ * @return Mage_Core_Block_Template
37
+ */
38
+ protected function _beforeToHtml()
39
+ {
40
+ if(($orderId = Mage::registry('osstudios_pagseguro_last_order_id'))) {
41
+ $order = Mage::getModel('sales/order')->load($orderId);
42
+
43
+ $isVisible = !in_array($order->getState(), Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
44
+ $isHolded = (boolean) ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED);
45
+
46
+ $payment = $order->getPayment();
47
+ $pagseguroInfo = $payment->getPagseguroInfo();
48
+
49
+ $this->addData(array(
50
+ 'order_id' => $order->getRealOrderId(),
51
+ 'is_order_visible' => $isVisible,
52
+ 'is_order_holded' => $isHolded,
53
+ 'can_print_order' => $isVisible,
54
+ 'can_view_order' => (boolean) (Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible),
55
+ 'view_order_url' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
56
+ 'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
57
+ ));
58
+
59
+ if($pagseguroInfo instanceof OsStudios_PagSeguroApi_Model_Payment_History) {
60
+ $this->addData(array(
61
+ 'pagseguro_transaction' => $pagseguroInfo,
62
+ 'pagseguro_boleto_url' => Mage::getSingleton('pagseguroapi/data')->getPagSeguroBilletUrl($pagseguroInfo->getPagseguroTransactionId()),
63
+ 'pagseguro_payment_url' => Mage::getSingleton('pagseguroapi/data')->getPagseguroApiRedirectUrl($pagseguroInfo->getPagseguroPaymentIdentifierCode()),
64
+ ));
65
+ }
66
+ }
67
+
68
+ return parent::_beforeToHtml();
69
+ }
70
+
71
+ }
app/code/community/OsStudios/PagSeguroApi/Controller/Adminhtml/Action.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Controller Admin Abstract
21
+ *
22
+ */
23
+
24
+ class OsStudios_PagSeguroApi_Controller_Adminhtml_Action extends Mage_Adminhtml_Controller_Action
25
+ {
26
+
27
+
28
+
29
+ }
app/code/community/OsStudios/PagSeguroApi/Controller/Front/Action.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Controller Front Abstract
21
+ *
22
+ */
23
+
24
+ class OsStudios_PagSeguroApi_Controller_Front_Action extends Mage_Core_Controller_Front_Action
25
+ {
26
+
27
+ /**
28
+ * Return Checkout Object
29
+ *
30
+ * @return Mage_Checkout_Model_Session
31
+ */
32
+ public function getCheckout()
33
+ {
34
+ return Mage::getSingleton('checkout/session');
35
+ }
36
+
37
+
38
+ /**
39
+ * Return Order's Store ID
40
+ *
41
+ */
42
+ function getOrderStoreId($orderId) {
43
+ return Mage::getModel('sales/order')->load($orderId)->getStoreId();
44
+ }
45
+
46
+
47
+ /**
48
+ * Get one page checkout model
49
+ *
50
+ * @return Mage_Checkout_Model_Type_Onepage
51
+ */
52
+ public function getOnepage()
53
+ {
54
+ return Mage::getSingleton('checkout/type_onepage');
55
+ }
56
+
57
+ }
app/code/community/OsStudios/PagSeguroApi/Helper/Data.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Payment Data Helper
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Helper_Data extends OsStudios_PagSeguroApi_Helper_Visie
24
+ {
25
+
26
+ const PARCEL_MAX_VALUE = 5;
27
+
28
+
29
+ /**
30
+ *
31
+ * Checks if the content is an XML file
32
+ * @param (mixed) $content
33
+ * @return (bool)
34
+ */
35
+ public function isXml($content)
36
+ {
37
+ libxml_use_internal_errors(true);
38
+ $doc = new DOMDocument('1.0', 'utf-8');
39
+ $doc->loadXML($content);
40
+
41
+ $errors = libxml_get_errors();
42
+ if (empty($errors))
43
+ {
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+
49
+
50
+ public function cleanStringToXml($string = null)
51
+ {
52
+
53
+ $chars = array(
54
+ 'a' => array('á', 'à', 'â', 'ã'),
55
+ 'A' => array('Á', 'À', 'Â', 'Ã'),
56
+ 'e' => array('é', 'è', 'ê'),
57
+ 'E' => array('É', 'È', 'Ê'),
58
+ 'i' => array('í', 'ì', 'î'),
59
+ 'I' => array('Í', 'Ì', 'Î'),
60
+ 'o' => array('ó', 'ò', 'ô', 'Õ'),
61
+ 'O' => array('Ó', 'Ò', 'Ô', 'Õ'),
62
+ 'u' => array('ú', 'ù', 'û'),
63
+ 'U' => array('Ú', 'Ù', 'Û'),
64
+ 'c' => array('ç'),
65
+ 'C' => array('Ç'),
66
+ );
67
+
68
+ foreach($chars as $char => $set) {
69
+ $string = str_replace($set, $char, $string);
70
+ }
71
+
72
+ return preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', trim($string));
73
+ }
74
+
75
+
76
+ public function getRegionCode($regionString = null)
77
+ {
78
+ $matches = array(
79
+ array('pattern' => '/^acre$/', 'result' => 'AC'),
80
+ array('pattern' => '/^alagoas$/', 'result' => 'AL'),
81
+ array('pattern' => '/^amap.?$/', 'result' => 'AP'),
82
+ array('pattern' => '/^amazona.?$/', 'result' => 'AM'),
83
+ array('pattern' => '/^bahia$/', 'result' => 'BA'),
84
+ array('pattern' => '/^cear.?$/', 'result' => 'CE'),
85
+ array('pattern' => '/^distrito.?federal$/', 'result' => 'DF'),
86
+ array('pattern' => '/^esp.?rito.?santo$/', 'result' => 'ES'),
87
+ array('pattern' => '/^goi.?s$/', 'result' => 'GO'),
88
+ array('pattern' => '/^maranh.?o$/', 'result' => 'MA'),
89
+ array('pattern' => '/^mato.?grosso$/', 'result' => 'MT'),
90
+ array('pattern' => '/^mato.?grosso.?do.?sul$/', 'result' => 'MS'),
91
+ array('pattern' => '/^minas.?gerais$/', 'result' => 'MG'),
92
+ array('pattern' => '/^par.?$/', 'result' => 'PA'),
93
+ array('pattern' => '/^para.?ba$/', 'result' => 'PB'),
94
+ array('pattern' => '/^paran.?$/', 'result' => 'PR'),
95
+ array('pattern' => '/^pernambuco$/', 'result' => 'PE'),
96
+ array('pattern' => '/^piau.?$/', 'result' => 'PI'),
97
+ array('pattern' => '/^rio.?de.?janeiro$/', 'result' => 'RJ'),
98
+ array('pattern' => '/^rio.?grande.?do.?norte$/', 'result' => 'RN'),
99
+ array('pattern' => '/^rio.?grande.?do.?sul$/', 'result' => 'RS'),
100
+ array('pattern' => '/^rond.?nia$/', 'result' => 'RO'),
101
+ array('pattern' => '/^roraima$/', 'result' => 'RR'),
102
+ array('pattern' => '/^santa.?catarina$/', 'result' => 'SC'),
103
+ array('pattern' => '/^s.?o.?paulo$/', 'result' => 'SP'),
104
+ array('pattern' => '/^sergipe$/', 'result' => 'SE'),
105
+ array('pattern' => '/^tocantins$/', 'result' => 'TO'),
106
+ );
107
+
108
+ if(($regionString = trim(strtolower($regionString)))) {
109
+ foreach($matches as $match) {
110
+ if(preg_match($match['pattern'], $regionString)) {
111
+ return strtoupper($match['result']);
112
+ break;
113
+ }
114
+ }
115
+
116
+ return 'SP';
117
+ }
118
+ }
119
+
120
+
121
+ /**
122
+ * Whether the PagSeguro must be opened in other page
123
+ *
124
+ * @return (boolean)
125
+ */
126
+ public function openPagSeguroInOtherPage()
127
+ {
128
+ return (bool) Mage::getStoreConfigFlag('payment/pagseguro_api/open_in_other_page');
129
+ }
130
+
131
+
132
+ public function getPagSeguroRedirectUrl()
133
+ {
134
+ return Mage::getStoreConfig('payment/pagseguro_api/pagseguro_api_redirect_url');
135
+ }
136
+
137
+ }
app/code/community/OsStudios/PagSeguroApi/Helper/Visie.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Payment Visie Helper
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Helper_Visie extends Mage_Core_Helper_Data
24
+ {
25
+
26
+ /**
27
+ * trataEndereco
28
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
29
+ *
30
+ * @param string $end Endereço a ser tratado
31
+ *
32
+ * @return array
33
+ */
34
+ function trataEndereco($end) {
35
+ $numeros = $this->dados('numeros');
36
+ $complementos = $this->dados('complementos');
37
+ if ($this->ehBrasilia($end)) {
38
+ $numero = 's/nº';
39
+ list($endereco, $complemento) = $this->brasiliaSeparaComplemento($end);
40
+ } else {
41
+ $endereco = $end;
42
+ $numero = 's/nº';
43
+ $complemento = '';
44
+ $quebrado = preg_split('/[-,]/', $end);
45
+ if (sizeof($quebrado) == 3){
46
+ list($endereco, $numero, $complemento) = $quebrado;
47
+ } elseif (sizeof($quebrado) == 2) {
48
+ list($endereco, $numero) = $quebrado;
49
+ } else {
50
+ list($endereco, $numero) = $this->buscaReversa($end);
51
+ }
52
+ $endereco = $this->tiraNumeroFinal($endereco);
53
+ if ($complemento == '')
54
+ list($numerob,$complemento) = $this->separaNumeroComplemento($numero);
55
+ }
56
+ return array($this->endtrim($endereco), $this->endtrim($numero), $this->endtrim($complemento));
57
+ }
58
+
59
+
60
+ /**
61
+ * separaNumeroComplemento
62
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
63
+ *
64
+ * @param string $n Número a ser tratado
65
+ *
66
+ * @return array
67
+ */
68
+ function separaNumeroComplemento($n) {
69
+ $semnumeros = $this->dados('semnumeros');
70
+ $n = $this->endtrim($n);
71
+ foreach ($semnumeros as $sn) {
72
+ if ($n == $sn)return array($n, '');
73
+ if (substr($n, 0, strlen($sn)) == $sn)
74
+ return array(substr($n, 0, strlen($sn)), substr($n, strlen($sn)));
75
+ }
76
+ $q = preg_split('/\D/', $n);
77
+ $pos = strlen($q[0]);
78
+ return array(substr($n, 0, $pos), substr($n,$pos));
79
+ }
80
+
81
+
82
+ /**
83
+ * endtrim
84
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
85
+ *
86
+ * Remove caracteres e espaços desnecessários
87
+ *
88
+ * @param string|int|double $e Texto que deseja alterar
89
+ *
90
+ * @return string
91
+ */
92
+ function endtrim($e){
93
+ return preg_replace('/^\W+|\W+$/', '', $e);
94
+ }
95
+
96
+
97
+ /**
98
+ * brasiliaSeparaComplemento
99
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
100
+ *
101
+ * @param string $end Endereço a ser tratado
102
+ *
103
+ * @return array
104
+ */
105
+ function brasiliaSeparaComplemento($end) {
106
+ $complementos = $this->dados('complementos');
107
+ foreach ($complementos as $c)
108
+ if ($pos = strpos(strtolower($end), $c))
109
+ return array(substr($end, 0 ,$pos), substr($end, $pos));
110
+ return array($end, '');
111
+ }
112
+
113
+
114
+ /**
115
+ * tiraNumeroFinal
116
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
117
+ *
118
+ * @param string $endereco Endereço a ser tratado
119
+ *
120
+ * @return string
121
+ */
122
+ function tiraNumeroFinal($endereco) {
123
+ $numeros = $this->dados('numeros');
124
+ foreach ($numeros as $n)
125
+ foreach (array(" $n"," $n ") as $N)
126
+ if (substr($endereco, -strlen($N)) == $N)
127
+ return substr($endereco, 0, -strlen($N));
128
+ return $endereco;
129
+ }
130
+
131
+
132
+ /**
133
+ * buscaReversa
134
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
135
+ *
136
+ * Encontra o primeiro caractere númerico dentre os últimos 10 da string informada
137
+ * e retorna a string separada na posição localizada
138
+ *
139
+ * @param string $texto Texto a ser procurado
140
+ *
141
+ * @return array
142
+ */
143
+ function buscaReversa($texto) {
144
+ $encontrar = substr($texto, -10);
145
+ for ($i = 0; $i < 10; $i++) {
146
+ if (is_numeric(substr($encontrar, $i, 1))) {
147
+ return array(
148
+ substr($texto, 0, -10+$i),
149
+ substr($texto, -10+$i)
150
+ );
151
+ }
152
+ }
153
+ }
154
+
155
+
156
+ /**
157
+ * ehBrasilia
158
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
159
+ *
160
+ * @param string $end Endereço a ser analisado
161
+ *
162
+ * @return bool
163
+ */
164
+ function ehBrasilia($end) {
165
+ $brasilias = $this->dados('brasilias');
166
+ $naobrasilias = $this->dados('naobrasilias');
167
+ $brasilia = false;
168
+ foreach ($brasilias as $b)
169
+ if (strpos(strtolower($end),$b) != false)
170
+ $brasilia = true;
171
+ if ($brasilia)
172
+ foreach ($naobrasilias as $b)
173
+ if (strpos(strtolower($end),$b) != false)
174
+ $brasilia = false;
175
+ return $brasilia;
176
+ }
177
+
178
+
179
+ /**
180
+ * dados
181
+ * (Extraída da biblioteca PHP do PagSeguro produzida pela Visie)
182
+ *
183
+ * Retorna dados auxiliares de acordo com o argumento passado,
184
+ * que podem ser:
185
+ * - 'complementos'
186
+ * - 'brasilias'
187
+ * - 'naobrasilias'
188
+ * - 'sems'
189
+ * - 'numeros'
190
+ * - 'semnumeros'
191
+ *
192
+ * @param string $v Código para escolha do retorno
193
+ *
194
+ * @return array
195
+ */
196
+ function dados($v) {
197
+
198
+ $dados = array();
199
+ $dados['complementos'] = array("casa", "ap", "apto", "apart", "frente", "fundos", "sala", "cj");
200
+ $dados['brasilias'] = array("bloco", "setor", "quadra", "lote");
201
+ $dados['naobrasilias'] = array("av", "avenida", "rua", "alameda", "al.", "travessa", "trv", "praça", "praca");
202
+ $dados['sems'] = array("sem ", "s.", "s/", "s. ", "s/ ");
203
+ $dados['numeros'] = array('n.º', 'nº', "numero", "num", "número", "núm", "n");
204
+ $dados['semnumeros'] = array();
205
+
206
+ foreach ($dados['numeros'] as $n)
207
+ foreach ($dados['sems'] as $s)
208
+ $dados['semnumeros'][] = "$s$n";
209
+ return $dados[$v];
210
+ }
211
+
212
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Abstract.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Abstract extends Mage_Core_Model_Abstract
19
+ {
20
+
21
+ const XPATH_CONFIG_TRANSACTION = 'osstudios_pagseguroapi/transaction/';
22
+
23
+
24
+ /**
25
+ * Get config instance
26
+ *
27
+ * @return Mage_Core_Model_Config
28
+ */
29
+ private function _getConfig()
30
+ {
31
+ return Mage::app()->getConfig();
32
+ }
33
+
34
+
35
+ /**
36
+ * Provide Helper to children classes
37
+ *
38
+ * @return OsStudios_PagSeguroApi_Helper_Data
39
+ */
40
+ protected function helper()
41
+ {
42
+ return Mage::helper('pagseguroapi');
43
+ }
44
+
45
+
46
+ /**
47
+ * Provides any module config option
48
+ *
49
+ */
50
+ protected function getConfigData($configNode)
51
+ {
52
+ return Mage::getStoreConfig('payment/pagseguro_api/'.$configNode);
53
+ }
54
+
55
+
56
+ /**
57
+ * Provides the credentials model
58
+ *
59
+ * @return OsStudios_PagSeguroApi_Model_Credentials
60
+ */
61
+ protected function _getCredentials()
62
+ {
63
+ return Mage::getSingleton('pagseguroapi/credentials');
64
+ }
65
+
66
+
67
+ /**
68
+ * Get Transaction Payment Method Type label
69
+ *
70
+ * @return string
71
+ */
72
+ public function getTransactionPaymentMethodTypeLabel($type)
73
+ {
74
+ $path = self::XPATH_CONFIG_TRANSACTION.'payment_methods/types/type_'.$type.'/label';
75
+ $label = Mage::getStoreConfig($path);
76
+ return $label;
77
+ }
78
+
79
+
80
+ /**
81
+ * Get Transaction Payment Method Code label
82
+ *
83
+ * @return string
84
+ */
85
+ public function getTransactionPaymentMethodCodeLabel($code)
86
+ {
87
+ $path = self::XPATH_CONFIG_TRANSACTION.'payment_methods/codes/code_'.$code.'/label';
88
+ $label = Mage::getStoreConfig($path);
89
+ return $label;
90
+ }
91
+
92
+
93
+ /**
94
+ * Get Transaction Status label
95
+ *
96
+ * @return string
97
+ */
98
+ public function getTransactionStatusLabel($code)
99
+ {
100
+ $path = self::XPATH_CONFIG_TRANSACTION.'status/status_'.$code.'/label';
101
+ $label = Mage::getStoreConfig($path);
102
+ return $label;
103
+ }
104
+
105
+
106
+ /**
107
+ * Returns the URL to generate the billets of PagSeguro
108
+ *
109
+ * @param string $transactionId
110
+ * @param boolean $escapeHtml
111
+ *
112
+ * @return (string)
113
+ */
114
+ public function getPagSeguroBilletUrl($transactionId = null, $escapeHtml = false)
115
+ {
116
+ $url = $this->getConfigData('pagseguro_billet_url');
117
+ if(!$url) {
118
+ Mage::throwException($this->helper()->__('The PagSeguro Billet URL could not be retrieved.'));
119
+ }
120
+
121
+ if(!is_null($transactionId)) {
122
+ $url = sprintf('%s?resizeBooklet=n&code=%s', $url, $transactionId);
123
+ }
124
+
125
+ return $escapeHtml ? $this->helper()->htmlEscape($url) : $url;
126
+ }
127
+
128
+
129
+ /**
130
+ * Returns the URL to consult the transactions in PagSeguro
131
+ *
132
+ * @param string $transactionId
133
+ * @param boolean $escapeHtml
134
+ *
135
+ * @return (string)
136
+ */
137
+ public function getPagSeguroTransactionUrl($transactionId = null, $escapeHtml = false)
138
+ {
139
+ $url = $this->getConfigData('pagseguro_transactions_url');
140
+ if(!$url) {
141
+ Mage::throwException($this->helper()->__('The PagSeguro Transaction URL could not be retrieved.'));
142
+ }
143
+
144
+ if(!is_null($transactionId)) {
145
+ $url = sprintf('%s/%s?email=%s&token=%s', $url, $transactionId, $this->_getCredentials()->getAccountEmail(), $this->_getCredentials()->getAccountToken());
146
+ }
147
+
148
+ return $escapeHtml ? $this->helper()->htmlEscape($url) : $url;
149
+ }
150
+
151
+
152
+ /**
153
+ * Returns the notifications URL to consult the transactions in PagSeguro
154
+ *
155
+ * @param string $notificationId
156
+ * @param boolean $escapeHtml
157
+ *
158
+ * @return (string)
159
+ */
160
+ public function getPagSeguroNotificationUrl($notificationId = null, $escapeHtml = false)
161
+ {
162
+ $url = $this->getConfigData('pagseguro_notifications_url');
163
+ if(!$url) {
164
+ Mage::throwException($this->helper()->__('The PagSeguro Notification URL could not be retrieved.'));
165
+ }
166
+
167
+ if(!is_null($notificationId)) {
168
+ $url = sprintf('%s/%s?email=%s&token=%s', $url, $notificationId, $this->_getCredentials()->getAccountEmail(), $this->_getCredentials()->getAccountToken());
169
+ }
170
+
171
+ return $escapeHtml ? $this->helper()->htmlEscape($url) : $url;
172
+ }
173
+
174
+
175
+ /**
176
+ * Returns the URL where the customer needs to be redirected to
177
+ *
178
+ * @param string $identifierCode
179
+ * @param boolean $escapeHtml
180
+ *
181
+ * @return (string)
182
+ */
183
+ public function getPagseguroApiRedirectUrl($identifierCode = null, $escapeHtml = false)
184
+ {
185
+ $url = $this->getConfigData('pagseguro_api_redirect_url');
186
+ if(!$url) {
187
+ Mage::throwException($this->helper()->__('The PagSeguro Redirect URL could not be retrieved.'));
188
+ }
189
+
190
+ if(!is_null($identifierCode)) {
191
+ $url = sprintf('%s?code=%s', $url, $identifierCode);
192
+ }
193
+
194
+ return $escapeHtml ? $this->helper()->htmlEscape($url) : $url;
195
+ }
196
+
197
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Consulter.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Consulter extends OsStudios_PagSeguroApi_Model_Returns
19
+ {
20
+
21
+ const PAGSEGURO_CONSULT_RESPONSE_UNAUTHORIZED = 'Unauthorized';
22
+ const PAGSEGURO_CONSULT_RESPONSE_AUTHORIZED = 'Authorized';
23
+ const PAGSEGURO_CONSULT_RESPONSE_ERROR = 'Process Error';
24
+ const PAGSEGURO_CONSULT_RESPONSE_NOT_FOUND = 'Not Found';
25
+
26
+
27
+ /**
28
+ * Makes the consult by Transaction ID
29
+ * The store is consulting a transaction in PagSeguro here
30
+ *
31
+ * @param (string) $transactionId
32
+ *
33
+ * @return OsStudios_PagSeguroApi_Model_Consulter
34
+ */
35
+ public function consultByTransactionId($transactionId)
36
+ {
37
+ if($transactionId) {
38
+ $url = $this->getPagSeguroTransactionUrl($transactionId);
39
+
40
+ $body = $this->_consult($url);
41
+
42
+ if($body) {
43
+ $xml = new Varien_Simplexml_Config($body);
44
+ $this->updateSingleTransaction($xml, 2);
45
+ }
46
+
47
+ return $this;
48
+ }
49
+ }
50
+
51
+
52
+ /**
53
+ * Makes the consult by Notification ID
54
+ * PagSeguro sent a notification to store
55
+ *
56
+ * @param (string) $notificationId
57
+ *
58
+ * @return OsStudios_PagSeguroApi_Model_Consulter
59
+ */
60
+ public function consultByNotificationId($notificationId)
61
+ {
62
+ $url = $this->getPagSeguroNotificationUrl($notificationId);
63
+
64
+ $body = $this->_consult($url);
65
+
66
+ if($body) {
67
+ $xml = new Varien_Simplexml_Config($body);
68
+ $this->updateSingleTransaction($xml, 1);
69
+ }
70
+
71
+ return $this;
72
+ }
73
+
74
+
75
+ /**
76
+ * Makes the mass consult
77
+ *
78
+ * @param (datetime) $initialDate
79
+ * @param (datetime) $finalDate
80
+ * @param (int) $page
81
+ * @param (int) $maxPageResults
82
+ *
83
+ * @return
84
+ */
85
+ public function massConsult($initialDate = null, $finalDate = null, $page = 1, $maxPageResults = 100)
86
+ {
87
+ /**
88
+ * @example https://ws.pagseguro.uol.com.br/v2/transactions
89
+ * ?initialDate=2011-01-01T00:00
90
+ * &finalDate=2011-01-28T00:00
91
+ * &page=1
92
+ * &maxPageResults=100
93
+ * &email=suporte@lojamodelo.com.br
94
+ * &token=95112EE828D94278BD394E91C4388F20
95
+ */
96
+
97
+ $url = Mage::getStoreConfig('payment/pagseguro_api/pagseguro_transactions_url');
98
+
99
+ $credentials = Mage::getModel('pagseguroapi/credentials');
100
+
101
+ $date = array();
102
+
103
+ if(is_null($initialDate)) {
104
+ $date['from'] = strtotime(date('Y-m-d', time()).' - 30 DAYS');
105
+ } else {
106
+ $date['from'] = $initialDate;
107
+ }
108
+
109
+ if(is_null($finalDate)) {
110
+ $date['to'] = time();
111
+ } else {
112
+ $date['to'] = $finalDate;
113
+ }
114
+
115
+ $date['from'] = Mage::getSingleton('core/date')->date('Y-m-d\T00:00', $date['from']);
116
+ $date['to'] = Mage::getSingleton('core/date')->date('Y-m-d\TH:m', $date['to']);
117
+
118
+ $fullUrl = sprintf('%s?initialDate=%s&finalDate=%s&page=%s&maxPageResults=%s&email=%s&token=%s', $url, $date['from'], $date['to'], $page, $maxPageResults, $credentials->getAccountEmail(), $credentials->getAccountToken());
119
+
120
+ $body = $this->_consult($fullUrl);
121
+
122
+ if($body) {
123
+ $xml = new SimpleXMLElement($body);
124
+
125
+ $a = 0; /* Count of consults */
126
+ $y = 0; /* Success on Update */
127
+ $w = 0; /* Not Updated */
128
+ foreach($xml->transactions->transaction as $trans) {
129
+ $transaction = new Varien_Simplexml_Config($trans->asXML());
130
+ if($this->updateSingleTransaction($transaction, 3)) {
131
+ $y++;
132
+ } else {
133
+ $w++;
134
+ };
135
+
136
+ $a++;
137
+ }
138
+ }
139
+
140
+ if($a) {
141
+ Mage::getSingleton('admin/session')->addSuccess($this->helper()->__('%s transactions were consulted in PagSeguro. %s successfully updated a transaction in the store.', $a, $y));
142
+ }
143
+
144
+ if($w) {
145
+ Mage::getSingleton('admin/session')->addNotice($this->helper()->__('%s transactions was not validated by the system.', $w));
146
+ }
147
+
148
+ return true;
149
+ }
150
+
151
+
152
+ /**
153
+ * Abstract method that makes the real consult in PagSeguro
154
+ * but not process the result itself, only gets the response
155
+ *
156
+ * @param (string) $url
157
+ *
158
+ * @return xml format
159
+ */
160
+ protected function _consult($url)
161
+ {
162
+ $client = new Zend_Http_Client($url);
163
+ $client->setMethod(Zend_Http_Client::GET);
164
+
165
+ $request = $client->request();
166
+ $body = $request->getBody();
167
+
168
+ if(!$this->helper()->isXml($body)) {
169
+ return;
170
+ }
171
+
172
+ return $body;
173
+ }
174
+
175
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Credentials.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Credentials extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+ /**
22
+ * PagSeguro Account E-mail
23
+ *
24
+ * @var (string)
25
+ */
26
+ protected $_accountEmail = null;
27
+
28
+
29
+ /**
30
+ * PagSeguro Account Token
31
+ *
32
+ * @var (string)
33
+ */
34
+ protected $_token = null;
35
+
36
+
37
+ /**
38
+ * Sets the credentials data to this model
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+
45
+ $this->_accountEmail = $this->getConfigData('account_email');
46
+ $this->_token = $this->getConfigData('account_token');
47
+
48
+ $data = array('account_email' => $this->_accountEmail, 'account_token' => $this->_token);
49
+
50
+ $this->setData($data);
51
+ }
52
+
53
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Data extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+
22
+
23
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Payment/History.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Mysql4_Payment_History extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/payment_history', 'history_id');
24
+ }
25
+
26
+
27
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
28
+ {
29
+ $object->setCreatedAt(now());
30
+ return parent::_beforeSave($object);
31
+ }
32
+
33
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Payment/History/Collection.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Mysql4_Payment_History_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/payment_history');
24
+ }
25
+
26
+
27
+ protected function _afterLoad()
28
+ {
29
+ parent::_afterLoad();
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Returns/Transaction.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Mysql4_Returns_Transaction extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/returns_transaction', 'id');
24
+ }
25
+
26
+
27
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
28
+ {
29
+ $object->setCreatedAt(now());
30
+ return parent::_beforeSave($object);
31
+ }
32
+
33
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Mysql4/Returns/Transaction/Collection.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Mysql4_Returns_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/returns_transaction');
24
+ }
25
+
26
+
27
+ protected function _afterLoad()
28
+ {
29
+ parent::_afterLoad();
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Observer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Observer extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+ public function salesOrderPaymentLoadAfter(Varien_Event_Observer $observer)
22
+ {
23
+ $order = $observer->getOrder();
24
+
25
+ if($order->getId() && ($order instanceof Mage_Sales_Model_Order)) {
26
+ $payment = $order->getPayment();
27
+
28
+ $history = Mage::getModel('pagseguroapi/payment_history')->load($order->getId(), 'order_id');
29
+
30
+ if($history->getHistoryId()) {
31
+ $payment->addData(array(
32
+ 'pagseguro_info' => $history,
33
+ ));
34
+ }
35
+ }
36
+ }
37
+
38
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Payment.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_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
+ *
30
+ * Current Quote
31
+ * @var Mage_Sales_Model_Quote
32
+ */
33
+ protected $_quote = null;
34
+
35
+
36
+ const PAGSEGURO_METHOD_CODE_API = 'pagseguro_api';
37
+
38
+
39
+ /**
40
+ *
41
+ * Status: Complete
42
+ * @var (string)
43
+ */
44
+ const PAGSEGURO_STATUS_COMPLETE = 'Completo';
45
+
46
+
47
+ /**
48
+ *
49
+ * Status: Waiting for Payment
50
+ * @var (string)
51
+ */
52
+ const PAGSEGURO_STATUS_WAITING_PAYMENT = 'Aguardando Pagto';
53
+
54
+
55
+ /**
56
+ *
57
+ * Status: Approved
58
+ * @var (string)
59
+ */
60
+ const PAGSEGURO_STATUS_APPROVED = 'Aprovado';
61
+
62
+
63
+ /**
64
+ *
65
+ * Status: In Analysis
66
+ * @var (string)
67
+ */
68
+ const PAGSEGURO_STATUS_ANALYSING = 'Em Análise';
69
+
70
+ /**
71
+ *
72
+ * Status: Canceled
73
+ * @var (string)
74
+ */
75
+ const PAGSEGURO_STATUS_CANCELED = 'Cancelado';
76
+
77
+ /**
78
+ *
79
+ * Status: Returned
80
+ * @var (string)
81
+ */
82
+ const PAGSEGURO_STATUS_RETURNED = 'Devolvido';
83
+
84
+
85
+ /**
86
+ * Return Quote Object
87
+ *
88
+ * @return Mage_Sales_Model_Order
89
+ */
90
+ public function getQuote()
91
+ {
92
+ if ($this->_quote == null) {
93
+ if(!$this->_quote = Mage::getSingleton('checkout/session')->getQuote()) {
94
+ return false;
95
+ }
96
+ }
97
+ return $this->_quote;
98
+ }
99
+
100
+
101
+ /**
102
+ *
103
+ * Set Current Quote Object
104
+ *
105
+ * @param Mage_Sales_Model_Quote $quote
106
+ */
107
+ public function setQuote(Mage_Sales_Model_Quote $quote)
108
+ {
109
+ $this->_quote = $quote;
110
+ return $this;
111
+ }
112
+
113
+
114
+ /**
115
+ * Return Order
116
+ *
117
+ * @return Mage_Sales_Model_Order
118
+ */
119
+ public function getOrder()
120
+ {
121
+ if ($this->_order == null) {
122
+ if(!$this->_order = Mage::getSingleton('checkout/session')->getOrder()) {
123
+ return false;
124
+ }
125
+ }
126
+ return $this->_order;
127
+ }
128
+
129
+
130
+ /**
131
+ *
132
+ * Set Current Order
133
+ *
134
+ * @param Mage_Sales_Model_Order $order
135
+ */
136
+ public function setOrder(Mage_Sales_Model_Order $order)
137
+ {
138
+ $this->_order = $order;
139
+ return $this;
140
+ }
141
+
142
+
143
+ /**
144
+ * Provide Helper to children classes
145
+ *
146
+ * @return OsStudios_PagSeguroApi_Helper_Data
147
+ */
148
+ protected function helper()
149
+ {
150
+ return Mage::helper('pagseguroapi');
151
+ }
152
+
153
+
154
+ /**
155
+ * Returns the URL where the customer needs to be redirected to
156
+ *
157
+ * @param string $identifierCode
158
+ *
159
+ * @return (string)
160
+ */
161
+ protected function getPagseguroApiRedirectUrl($identifierCode = null)
162
+ {
163
+ return Mage::getModel('pagseguroapi/data')->getPagseguroApiRedirectUrl($identifierCode);
164
+ }
165
+
166
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Payment/History.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Payment_History extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/payment_history');
24
+ }
25
+
26
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Payment/Method/Api.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Payment_Method_Api extends OsStudios_PagSeguroApi_Model_Payment
19
+ {
20
+
21
+ protected $_code = self::PAGSEGURO_METHOD_CODE_API;
22
+ protected $_formBlockType = 'pagseguroapi/api_form';
23
+ protected $_infoBlockType = 'pagseguroapi/api_info';
24
+
25
+ protected $_isInitializeNeeded = true;
26
+ protected $_canUseInternal = true;
27
+ protected $_canUseForMultishipping = false;
28
+
29
+ protected $_isGateway = true;
30
+ protected $_canOrder = true;
31
+
32
+ protected $_identifierCodeRegistry = 'pagseguroapi_payment_identifier_code';
33
+
34
+
35
+ /**
36
+ * Return the URL to be redirected to when finish purchasing
37
+ *
38
+ * @return boolean | string
39
+ */
40
+ public function getOrderPlaceRedirectUrl($orderId = null)
41
+ {
42
+ if($this->helper()->openPagSeguroInOtherPage()) {
43
+ return Mage::getUrl('pagseguroapi/pay/success');
44
+ } else {
45
+ $_code = Mage::registry($this->_identifierCodeRegistry);
46
+
47
+ if($this->_isValidPagSeguroResultCode($_code)) {
48
+ $url = $this->getPagseguroApiRedirectUrl($_code);
49
+
50
+ Mage::unregister($this->_identifierCodeRegistry);
51
+ return $url;
52
+ }
53
+ }
54
+
55
+ return false;
56
+ }
57
+
58
+
59
+ /**
60
+ * Method that will be executed instead of authorize or capture
61
+ * if flag isInitializeNeeded set to true
62
+ *
63
+ * @param string $paymentAction
64
+ * @param object $stateObject
65
+ *
66
+ * @return Mage_Payment_Model_Abstract
67
+ */
68
+ public function initialize($paymentAction, $stateObject)
69
+ {
70
+ return $this->$paymentAction();
71
+ }
72
+
73
+
74
+ /**
75
+ * Creates a new order request in PagSeguro via Api method
76
+ *
77
+ * @return OsStudios_PagSeguroApi_Model_Payment_Method_Api
78
+ */
79
+ public function createTransaction()
80
+ {
81
+ $credentials = Mage::getSingleton('pagseguroapi/credentials');
82
+ $url = sprintf('%s?email=%s&token=%s', $this->getConfigData('pagseguro_api_url'), $credentials->getAccountEmail(), $credentials->getAccountToken());
83
+
84
+ $xml = Mage::getSingleton('pagseguroapi/payment_method_api_xml')->setOrder($this->_getOrder())->getXml();
85
+
86
+ $client = new Zend_Http_Client($url);
87
+ $client->setMethod(Zend_Http_Client::POST)
88
+ ->setHeaders('Content-Type: application/xml; charset=ISO-8859-1')
89
+ ->setRawData($xml->asXML(), 'text/xml');
90
+
91
+ $request = $client->request();
92
+
93
+ if(!$this->helper()->isXml(($body = $request->getBody()))) {
94
+ Mage::log($this->helper()->__("When the system tried to authorize with login '%s' and token '%s' got '%s' as result.", $credentials->getAccountEmail(), $credentials->getAccountToken(), $request->getBody()), null, 'osstudios_pagseguro_unauthorized.log');
95
+ Mage::throwException($this->helper()->__('A problem has occured while trying to authorize the transaction in PagSeguro.'));
96
+ }
97
+
98
+ $hasErrors = $this->_hasErrorInReturn($body);
99
+ if(is_array($hasErrors)) {
100
+ $message = implode("\n", $hasErrors);
101
+ Mage::throwException($message);
102
+ }
103
+
104
+ $config = new Varien_Simplexml_Config($body);
105
+ $result = $config->getNode()->asArray();
106
+
107
+ if((!isset($result['code']) || !$this->_isValidPagSeguroResultCode($result['code'])) || !isset($result['date'])) {
108
+ Mage::throwException($this->helper()->__('Your payment could not be processed by PagSeguro.'));
109
+ }
110
+
111
+ Mage::register($this->_identifierCodeRegistry, $result['code']);
112
+
113
+ $history = Mage::getModel('pagseguroapi/payment_history');
114
+ $history->setOrderId($this->_getOrder()->getId())
115
+ ->setOrderIncrementId($this->_getOrder()->getRealOrderId())
116
+ ->setPagseguroPaymentIdentifierCode($result['code'])
117
+ ->setPagseguroTransactionDate($result['date'])
118
+ ->save();
119
+
120
+ return $this;
121
+ }
122
+
123
+
124
+ /**
125
+ * Get Order Object
126
+ *
127
+ * @return Mage_Sales_Model_Order
128
+ */
129
+ protected function _getOrder()
130
+ {
131
+ return Mage::getModel('sales/order')->loadByIncrementId($this->_getOrderIncrementId());
132
+ }
133
+
134
+
135
+ /**
136
+ * Order increment ID getter (either real from order or a reserved from quote)
137
+ *
138
+ * @return string
139
+ */
140
+ private function _getOrderIncrementId()
141
+ {
142
+ $info = $this->getInfoInstance();
143
+
144
+ if ($this->_isPlaceOrder()) {
145
+ return $info->getOrder()->getIncrementId();
146
+ } else {
147
+ if (!$info->getQuote()->getReservedOrderId()) {
148
+ $info->getQuote()->reserveOrderId();
149
+ }
150
+ return $info->getQuote()->getReservedOrderId();
151
+ }
152
+ }
153
+
154
+
155
+ /**
156
+ * Whether current operation is order placement
157
+ *
158
+ * @return bool
159
+ */
160
+ private function _isPlaceOrder()
161
+ {
162
+ $info = $this->getInfoInstance();
163
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
164
+ return false;
165
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
166
+ return true;
167
+ }
168
+ }
169
+
170
+
171
+ /**
172
+ * Validates the result code from PagSeguro call
173
+ *
174
+ * @param (string) $code
175
+ *
176
+ * @return bool
177
+ */
178
+ protected function _isValidPagSeguroResultCode($code)
179
+ {
180
+ if($code && (strlen($code) == 32)) {
181
+ return true;
182
+ }
183
+
184
+ return false;
185
+ }
186
+
187
+
188
+ /**
189
+ * Checks if exists errors in the result
190
+ *
191
+ * @param (xml) $code
192
+ *
193
+ * @return || Array
194
+ */
195
+ protected function _hasErrorInReturn($body)
196
+ {
197
+ if($this->helper()->isXml($body)) {
198
+ $xml = new SimpleXMLElement($body);
199
+
200
+ if(count($xml->error)) {
201
+
202
+ $resultArr = array();
203
+
204
+ foreach($xml->error as $error) {
205
+ if($error->code) {
206
+ $codes = Mage::getSingleton('pagseguroapi/system_config_source_error_codes');
207
+ $message = $codes->getNodeByAttribute($error->code, 'value', 'message');
208
+
209
+ $resultArr[] = $this->helper()->__($message);
210
+ }
211
+ }
212
+ return $resultArr;
213
+ }
214
+ }
215
+ return;
216
+ }
217
+
218
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Payment/Method/Api/Xml.php ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Payment_Method_Api_Xml extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+ /**
22
+ * Handles the Quote Object
23
+ *
24
+ * @var Mage_Sales_Model_Quote
25
+ */
26
+ protected $_quote = null;
27
+
28
+
29
+ /**
30
+ * Handles the Order Object
31
+ *
32
+ * @var Mage_Sales_Model_Order
33
+ */
34
+ protected $_order = null;
35
+
36
+
37
+ /**
38
+ * Handles the XML Object
39
+ *
40
+ * @var SimpleXMLElement
41
+ */
42
+ protected $_xml = null;
43
+
44
+
45
+ /**
46
+ * Sets the Quote Object
47
+ *
48
+ * @param Mage_Sales_Model_Quote $quote
49
+ * @return OsStudios_PagSeguro_Model_Api_Xml
50
+ */
51
+ public function setQuote(Mage_Sales_Model_Quote $quote)
52
+ {
53
+ if($quote->getId()) {
54
+ $this->_quote = $quote;
55
+ }
56
+
57
+ return $this;
58
+ }
59
+
60
+
61
+ /**
62
+ * Returns the Quote Object
63
+ *
64
+ * @return Mage_Sales_Model_Quote
65
+ */
66
+ public function getQuote()
67
+ {
68
+ if(!$this->_quote) {
69
+ $this->_quote = Mage::getSingleton('checkout/session')->getQuote();
70
+ }
71
+ return $this->_quote;
72
+ }
73
+
74
+
75
+ /**
76
+ * Sets the Order Object
77
+ *
78
+ * @param Mage_Sales_Model_Order $order
79
+ * @return OsStudios_PagSeguro_Model_Api_Xml
80
+ */
81
+ public function setOrder(Mage_Sales_Model_Order $order)
82
+ {
83
+ if($order->getId()) {
84
+ $this->_order = $order;
85
+ }
86
+
87
+ return $this;
88
+ }
89
+
90
+
91
+ /**
92
+ * Returns the Order Object
93
+ *
94
+ * @return Mage_Sales_Model_Order
95
+ */
96
+ public function getOrder()
97
+ {
98
+ if(!$this->_order) {
99
+ $this->_order = Mage::getSingleton('checkout/session')->getOrder();
100
+ }
101
+
102
+ /**
103
+ * Remove......
104
+ */
105
+ //return $this->getQuote();
106
+ return $this->_order;
107
+ }
108
+
109
+
110
+ /**
111
+ * Point of entry to external classes get a XML Object
112
+ *
113
+ * @return SimpleXMLElement
114
+ */
115
+ public function getXml()
116
+ {
117
+ if(!$this->_xml) {
118
+ $this->_getBaseXml();
119
+ }
120
+
121
+ return $this->_xml;
122
+ }
123
+
124
+
125
+ /**
126
+ * Sets the base XML object
127
+ *
128
+ * @param SimpleXMLElement $xml
129
+ * @return OsStudios_PagSeguro_Model_Api_Xml
130
+ */
131
+ protected function _setBaseXml(SimpleXMLElement $xml)
132
+ {
133
+ $this->_xml = $xml;
134
+ return $this;
135
+ }
136
+
137
+
138
+ /**
139
+ * Parent method to generate the XML Object
140
+ * It calls the responsible for generate the other nodes
141
+ *
142
+ * @return SimpleXMLElement
143
+ */
144
+ protected function _getBaseXml()
145
+ {
146
+ $xml = new SimpleXMLElement('<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><checkout/>');
147
+
148
+ $this->_setBaseXml($xml);
149
+
150
+ $this->_getNodeReceiver()
151
+ ->_getNodeCurrency()
152
+ ->_getNodeMaxUses()
153
+ ->_getNodeMaxAge()
154
+ ->_getNodeExtraAmount()
155
+ ->_getNodeRedirectURL()
156
+ ->_getNodeItems()
157
+ ->_getNodeReference()
158
+ ->_getNodeSender()
159
+ ->_getNodeShipping();
160
+
161
+ return $xml;
162
+ }
163
+
164
+
165
+ /**
166
+ * Generates the <receiver/> node
167
+ *
168
+ * @return OsStudios_PagSeguro_Model_Api_Xml
169
+ */
170
+ protected function _getNodeReceiver()
171
+ {
172
+ $credentials = Mage::getSingleton('pagseguroapi/credentials');
173
+
174
+ if($credentials->getAccountEmail()) {
175
+ $xmlReceiver = $this->_xml->addChild('receiver');
176
+ $xmlReceiver->addChild('email', $credentials->getAccountEmail());
177
+ }
178
+ return $this;
179
+ }
180
+
181
+
182
+ /**
183
+ * Generates the <currency/> node
184
+ *
185
+ * @return OsStudios_PagSeguro_Model_Api_Xml
186
+ */
187
+ protected function _getNodeCurrency()
188
+ {
189
+ if($this->getOrder()) {
190
+ //$this->_xml->addChild('currency', $this->getOrder()->getStoreCurrencyCode());
191
+ $this->_xml->addChild('currency', 'BRL');
192
+ }
193
+ return $this;
194
+ }
195
+
196
+
197
+ /**
198
+ * Generates the <maxUses/> node
199
+ *
200
+ * @return OsStudios_PagSeguro_Model_Api_Xml
201
+ */
202
+ protected function _getNodeMaxUses()
203
+ {
204
+ $this->_xml->addChild('maxUses', Mage::getStoreConfig('payment/pagseguro_api/max_uses'));
205
+ return $this;
206
+ }
207
+
208
+
209
+ /**
210
+ * Generates the <maxAge/> node
211
+ *
212
+ * @return OsStudios_PagSeguro_Model_Api_Xml
213
+ */
214
+ protected function _getNodeMaxAge()
215
+ {
216
+ $this->_xml->addChild('maxAge', Mage::getStoreConfig('payment/pagseguro_api/max_age'));
217
+ return $this;
218
+ }
219
+
220
+
221
+ /**
222
+ * Generates the <extraAmount/> node
223
+ *
224
+ * @return OsStudios_PagSeguro_Model_Api_Xml
225
+ */
226
+ protected function _getNodeExtraAmount()
227
+ {
228
+ $this->_xml->addChild('extraAmount', $this->_formatNumberToXml(Mage::getStoreConfig('payment/pagseguro_api/extra_amount')));
229
+ return $this;
230
+ }
231
+
232
+
233
+ /**
234
+ * Generates the <redirectURL/> node
235
+ *
236
+ * @return OsStudios_PagSeguro_Model_Api_Xml
237
+ */
238
+ protected function _getNodeRedirectURL()
239
+ {
240
+ $this->_xml->addChild('redirectURL', Mage::getUrl('pagseguroapi/pay/success'));
241
+ return $this;
242
+ }
243
+
244
+
245
+ /**
246
+ * Generates the <items/> node
247
+ *
248
+ * @return OsStudios_PagSeguro_Model_Api_Xml
249
+ */
250
+ protected function _getNodeItems()
251
+ {
252
+
253
+ $xmlItems = $this->_xml->addChild('items');
254
+
255
+ if($this->getOrder()) {
256
+ foreach($this->getOrder()->getAllVisibleItems() as $item) {
257
+ $xmlItem = $xmlItems->addChild('item');
258
+
259
+ $xmlItem->addChild('id', (string) $item->getProductId());
260
+ $xmlItem->addChild('description', $item->getName());
261
+ $xmlItem->addChild('amount', $this->_formatNumberToXml(($item->getRowTotal() / $item->getQtyOrdered())));
262
+ $xmlItem->addChild('quantity', (int) $item->getQtyOrdered());
263
+ $xmlItem->addChild('shippingCost', '0.00');
264
+ $xmlItem->addChild('weight', (int) $item->getWeight());
265
+ }
266
+ }
267
+
268
+ return $this;
269
+ }
270
+
271
+
272
+ /**
273
+ * Generates the <reference/> node
274
+ *
275
+ * @return OsStudios_PagSeguro_Model_Api_Xml
276
+ */
277
+ protected function _getNodeReference()
278
+ {
279
+ if($this->getOrder()) {
280
+ $this->_xml->addChild('reference', $this->getOrder()->getRealOrderId());
281
+ }
282
+ return $this;
283
+ }
284
+
285
+
286
+ /**
287
+ * Generates the <sender/> node
288
+ *
289
+ * @return OsStudios_PagSeguro_Model_Api_Xml
290
+ */
291
+ protected function _getNodeSender()
292
+ {
293
+ $xmlSender = $this->_xml->addChild('sender');
294
+
295
+ if($this->getOrder()) {
296
+ $xmlSender->addChild('name', $this->getOrder()->getCustomerFirstname() . ' ' . $this->getOrder()->getCustomerLastname());
297
+ $xmlSender->addChild('email', $this->getOrder()->getCustomerEmail());
298
+
299
+ /**
300
+ * @todo: Find another way to threat the phone number.
301
+ *
302
+ */
303
+ $phone = preg_replace('/[^0-9]/', null, $this->getOrder()->getShippingAddress()->getTelephone());
304
+
305
+ $digitCount = 8;
306
+ if(($len = strlen($phone)) >= 11) {
307
+ $digitCount = 9;
308
+ } elseif($len == 10) {
309
+ $digitCount = 8;
310
+ }
311
+
312
+ $areaCode = substr($phone, 0, ($len-$digitCount));
313
+ $number = substr($phone, ($len-$digitCount), $digitCount);
314
+
315
+ $xmlPhone = $xmlSender->addChild('phone');
316
+ $xmlPhone->addChild('areaCode', $areaCode);
317
+ $xmlPhone->addChild('number', $number);
318
+ }
319
+
320
+ return $this;
321
+ }
322
+
323
+
324
+ /**
325
+ * Generates the <shipping/> node
326
+ *
327
+ * @return OsStudios_PagSeguro_Model_Api_Xml
328
+ */
329
+ protected function _getNodeShipping()
330
+ {
331
+ $xmlShipping = $this->_xml->addChild('shipping');
332
+
333
+ if($this->getOrder()) {
334
+ $shipping = $this->getOrder()->getShippingAddress();
335
+
336
+ $xmlShipping->addChild('cost', $this->_formatNumberToXml($this->getOrder()->getShippingAmount()));
337
+
338
+ $xmlShipping->addChild('type', Mage::getStoreConfig('payment/'.OsStudios_PagSeguroApi_Model_Payment::PAGSEGURO_METHOD_CODE_API.'/shipping_type'));
339
+ $xmlAddress = $xmlShipping->addChild('address');
340
+
341
+ if(is_array($shipping->getStreet())) {
342
+ $street = implode(' - ', $shipping->getStreet());
343
+ } elseif(is_string($shipping->getStreet())) {
344
+ $street = $shipping->getStreet();
345
+ }
346
+
347
+ $address = $this->helper()->trataEndereco($street);
348
+
349
+ $xmlAddress->addChild('street', $this->helper()->cleanStringToXml($address[0]));
350
+ $xmlAddress->addChild('number', preg_replace('/[^0-9]/', null, $address[1]));
351
+ $xmlAddress->addChild('complement');
352
+ $xmlAddress->addChild('district', $this->helper()->cleanStringToXml($address[2]));
353
+ $xmlAddress->addChild('postalCode', preg_replace('/[^0-9]/', null, $shipping->getPostcode()));
354
+ $xmlAddress->addChild('city', $this->helper()->cleanStringToXml($shipping->getCity()));
355
+
356
+ $regionCode = $this->helper()->cleanStringToXml($shipping->getRegionCode());
357
+
358
+ $xmlAddress->addChild('state', (strlen($regionCode)==2) ? $regionCode : $this->helper()->getRegionCode($regionCode) );
359
+ $xmlAddress->addChild('country', $this->helper()->cleanStringToXml($shipping->getCountryId()));
360
+ }
361
+
362
+ return $this;
363
+ }
364
+
365
+
366
+ protected function _formatNumberToXml($value = 0.00)
367
+ {
368
+ return number_format($value, 2, '.', '');
369
+ }
370
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Resource/Payment/History.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Resource_Payment_History extends Mage_Core_Model_Resource_Db_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/payment_history', 'history_id');
24
+ }
25
+
26
+
27
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
28
+ {
29
+ $object->setCreatedAt(now());
30
+ return parent::_beforeSave($object);
31
+ }
32
+
33
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Resource/Payment/History/Collection.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Resource_Payment_History_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/payment_history');
24
+ }
25
+
26
+
27
+ protected function _afterLoad()
28
+ {
29
+ parent::_afterLoad();
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Resource/Returns/Transaction.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Resource_Returns_Transaction extends Mage_Core_Model_Resource_Db_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/returns_transaction', 'id');
24
+ }
25
+
26
+
27
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
28
+ {
29
+ $object->setCreatedAt(now());
30
+ return parent::_beforeSave($object);
31
+ }
32
+
33
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Resource/Returns/Transaction/Collection.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Resource_Returns_Transaction_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
19
+ {
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('pagseguroapi/returns_transaction');
24
+ }
25
+
26
+
27
+ protected function _afterLoad()
28
+ {
29
+ parent::_afterLoad();
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Returns.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Returns extends OsStudios_PagSeguroApi_Model_Abstract
19
+ {
20
+
21
+ /**
22
+ * Updates a single transaction by return or consulting process
23
+ *
24
+ * @param Varien_Simplexml_Config $xml
25
+ *
26
+ * @return (boolean)
27
+ */
28
+ public function updateSingleTransaction(Varien_Simplexml_Config $xml, $receivedFrom = 1)
29
+ {
30
+ $transaction = Mage::getModel('pagseguroapi/returns_transaction');
31
+ $transaction->setReceivedFrom($receivedFrom)->importData($xml);
32
+
33
+ if($transaction->getIsValid()) {
34
+ $this->_updatePaymentHistory($transaction);
35
+
36
+ if($this->getConfigData('automatically_change_orders')) {
37
+ $this->_updateOrderByTransaction($transaction);
38
+ }
39
+
40
+ return true;
41
+ }
42
+
43
+ return false;
44
+ }
45
+
46
+
47
+ /**
48
+ * Updates the order according to transaction
49
+ *
50
+ * @param OsStudios_PagSeguroApi_Model_Returns_Transaction $transaction
51
+ *
52
+ * @return OsStudios_PagSeguroApi_Model_Returns
53
+ */
54
+ protected function _updateOrderByTransaction(OsStudios_PagSeguroApi_Model_Returns_Transaction $transaction)
55
+ {
56
+
57
+ $order = $transaction->getOrder();
58
+
59
+ //$transaction->setStatus(3);
60
+
61
+ switch ((int) $transaction->getStatus()) {
62
+ case 1:
63
+ case 2:
64
+ /**
65
+ * 1: Aguardando pagamento: o comprador iniciou a transação, mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.
66
+ * 2: Em análise: o comprador optou por pagar com um cartão de crédito e o PagSeguro está analisando o risco da transação.
67
+ */
68
+
69
+ if($transaction->getPaymentMethod()->getType() == 2) {
70
+ if($this->getConfigData('automatically_hold_orders_for_billet')) {
71
+ try {
72
+ if($order->canHold()) {
73
+ Mage::dispatchEvent('osstudios_pagseguroapi_return_order_hold_before', array('order' => $order, 'transaction' => $transaction));
74
+ $order->hold();
75
+ //$order->addStatusHistoryComment($this->helper()->__('Automatically holded by PagSeguroApi. Payment method is billet.'), false);
76
+ $order->save();
77
+ Mage::dispatchEvent('osstudios_pagseguroapi_return_order_hold_after', array('order' => $order, 'transaction' => $transaction));
78
+ }
79
+ } catch (Exception $e) {
80
+ Mage::log($this->helper()->__('PagSeguroApi: Exception occurred when trying to hold order automatically. Exception message: %s.', $e->getMessage()), null, 'pagseguroapi_returns_exceptions.log');
81
+ }
82
+ }
83
+ }
84
+
85
+ break;
86
+ case 3:
87
+ case 4:
88
+ /**
89
+ * 3: Paga: a transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação da instituição financeira responsável pelo processamento.
90
+ * 4: Disponível: a transação foi paga e chegou ao final de seu prazo de liberação sem ter sido retornada e sem que haja nenhuma disputa aberta.
91
+ */
92
+
93
+ if($this->getConfigData('automatically_invoice_orders')) {
94
+ try {
95
+ if($order->canUnhold()) {
96
+ $order->unhold();
97
+ }
98
+ if(!$order->canInvoice()) {
99
+ $order->addStatusHistoryComment('PagSeguroApi: Order cannot be invoiced automatically.', false)->save();
100
+ break;
101
+ }
102
+ Mage::dispatchEvent('osstudios_pagseguroapi_return_order_invoice_before', array('order' => $order, 'transaction' => $transaction));
103
+ //START Handle Invoice
104
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
105
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
106
+ $invoice->register();
107
+ $invoice->getOrder()->setCustomerNoteNotify(false);
108
+ $invoice->getOrder()->setIsInProcess(true);
109
+ $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
110
+ $transactionSave->save();
111
+ $order->addStatusHistoryComment($this->helper()->__('PagSeguroApi: Automatically invoiced by PagSeguroApi. PagSeguro confirmed the payment.'), false);
112
+ $order->save();
113
+ //END Handle Invoice
114
+ Mage::dispatchEvent('osstudios_pagseguroapi_return_order_invoice_after', array('order' => $order, 'transaction' => $transaction));
115
+ } catch (Exception $e) {
116
+ Mage::log($this->helper()->__('PagSeguroApi: Exception occurred when trying to invoice order automatically. Exception message: %s.', $e->getMessage()), null, 'pagseguroapi_returns_exceptions.log');
117
+ }
118
+ }
119
+
120
+ break;
121
+ case 5:
122
+ /**
123
+ * 5: Em disputa: o comprador, dentro do prazo de liberação da transação, abriu uma disputa.
124
+ */
125
+
126
+ break;
127
+ case 6:
128
+ case 7:
129
+ /**
130
+ * 6: Devolvida: o valor da transação foi devolvido para o comprador.
131
+ * 7: Cancelada: a transação foi cancelada sem ter sido finalizada.
132
+ */
133
+
134
+ if($this->getConfigData('automatically_cancel_orders')) {
135
+ try {
136
+ if($order->canUnhold()) {
137
+ $order->unhold();
138
+ }
139
+ if($order->canCancel()) {
140
+ Mage::dispatchEvent('osstudios_pagseguroapi_return_order_cancel_before', array('order' => $order, 'transaction' => $transaction));
141
+ $order->getPayment()->cancel();
142
+ $order->registerCancellation($this->helper()->__('PagSeguroApi: Automatically canceled by PagSeguroApi. PagSeguro has canceled the payment.'));
143
+ Mage::dispatchEvent('order_cancel_after', array('order' => $this));
144
+ $order->save();
145
+ } else {
146
+ if($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
147
+ $order->addStatusHistoryComment($this->helper()->__('PagSeguroApi: The order could not be automatically canceled by PagSeguroApi. PagSeguro has canceled the payment.'), false)->save();
148
+ }
149
+ }
150
+ } catch (Exception $e) {
151
+ Mage::log($this->helper()->__('PagSeguroApi: Exception occurred when trying to cancel order automatically. Exception message: %s.', $e->getMessage()), null, 'pagseguroapi_return_exceptions.log');
152
+ }
153
+ }
154
+
155
+ break;
156
+ }
157
+ }
158
+
159
+
160
+ /**
161
+ * Updates the history with these new information
162
+ *
163
+ * @param OsStudios_PagSeguroApi_Model_Returns_Transaction $transaction
164
+ *
165
+ * @return OsStudios_PagSeguroApi_Model_Returns
166
+ */
167
+ protected function _updatePaymentHistory(OsStudios_PagSeguroApi_Model_Returns_Transaction $transaction, $forceUpdate = true)
168
+ {
169
+ try {
170
+ $history = Mage::getModel('pagseguroapi/payment_history')->load($transaction->getOrder()->getEntityId(), 'order_id');
171
+
172
+ if($history->getHistoryId()) {
173
+ $history->setPagseguroTransactionId($transaction->getCode())
174
+ ->setPagseguroTransactionStatus($transaction->getStatus())
175
+ ->setPagseguroTransactionFeeAmount($transaction->getFeeAmount())
176
+ ->setPagseguroPaymentMethodType($transaction->getPaymentMethod()->getType())
177
+ ->setPagseguroPaymentMethodCode($transaction->getPaymentMethod()->getCode())
178
+ ->setPagseguroPaymentInstallmentCount($transaction->getInstallmentCount())
179
+ ->setUpdatedAt(now());
180
+
181
+ $history->save();
182
+ }
183
+ } catch (Exception $e) {
184
+ /* @todo */
185
+ }
186
+
187
+ return $this;
188
+ }
189
+
190
+
191
+ }
app/code/community/OsStudios/PagSeguroApi/Model/Returns/Transaction.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Model_Returns_Transaction extends OsStudios_PagSeguroApi_Model_Returns
19
+ {
20
+
21
+ /**
22
+ * Prefix of model events names
23
+ *
24
+ * @var string
25
+ */
26
+ protected $_eventPrefix = 'pagseguroapi_transaction';
27
+
28
+ /**
29
+ * Parameter name in event
30
+ *
31
+ * In observe method you can use $observer->getEvent()->getObject() in this case
32
+ *
33
+ * @var string
34
+ */
35
+ protected $_eventObject = 'transaction';
36
+
37
+
38
+ protected function _construct()
39
+ {
40
+ $this->_init('pagseguroapi/returns_transaction');
41
+ }
42
+
43
+
44
+ /**
45
+ * Import data to model
46
+ *
47
+ * @param Varien_Simplexml_Config $xml
48
+ *
49
+ * @var string
50
+ */
51
+ public function importData(Varien_Simplexml_Config $xml)
52
+ {
53
+ $arr = $xml->getNode()->asArray();
54
+
55
+ $data = array(
56
+ 'date' => $arr['date'],
57
+ 'reference' => $arr['reference'],
58
+ 'type' => $arr['type'],
59
+ 'status' => $arr['status'],
60
+ 'last_event_date' => $arr['lastEventDate'],
61
+ 'gross_amount' => $arr['grossAmount'],
62
+ 'discount_amount' => $arr['discountAmount'],
63
+ 'fee_amount' => $arr['feeAmount'],
64
+ 'net_amount' => $arr['netAmount'],
65
+ 'extra_amount' => $arr['extraAmount'],
66
+ );
67
+
68
+ if(isset($arr['installmentCount'])) {
69
+ $data['installment_count'] = $arr['installmentCount'];
70
+ }
71
+
72
+ if(isset($arr['itemCount'])) {
73
+ $data['item_count'] = $arr['itemCount'];
74
+ }
75
+
76
+ if(isset($arr['code'])) {
77
+ $data['code'] = $arr['code'];
78
+ }
79
+
80
+ /* Payment Method */
81
+ $paymentMethod = new Varien_Object();
82
+ if(isset($arr['paymentMethod'])) {
83
+ if(isset($arr['paymentMethod']['type'])) {
84
+ $paymentMethod->setType($arr['paymentMethod']['type']);
85
+ $data['payment_method_type'] = $paymentMethod->getType();
86
+ }
87
+
88
+ if(isset($arr['paymentMethod']['code'])) {
89
+ $paymentMethod->setCode($arr['paymentMethod']['code']);
90
+ $data['payment_method_code'] = $paymentMethod->getCode();
91
+ }
92
+ }
93
+ $data['payment_method'] = $paymentMethod;
94
+
95
+ /* Sender */
96
+ $sender = new Varien_Object();
97
+ if(isset($arr['sender'])) {
98
+ if(isset($arr['sender']['name'])) {
99
+ $sender->setName($arr['sender']['name']);
100
+ $data['sender_name'] = $sender->getName();
101
+ }
102
+
103
+ if(isset($arr['sender']['email'])) {
104
+ $sender->setEmail($arr['sender']['email']);
105
+ $data['sender_email'] = $sender->getEmail();
106
+ }
107
+ }
108
+ $data['sender'] = $sender;
109
+
110
+ if($data['reference']) {
111
+ $order = Mage::getModel('sales/order')->loadByIncrementId($data['reference']);
112
+ if($order->getId()) {
113
+ $this->setOrder($order)
114
+ ->setOrderId($order->getEntityId());
115
+ }
116
+ }
117
+
118
+ $this->addData($data);
119
+
120
+ $this->setIsValid($this->_isTransactionCompatible());
121
+
122
+ if($this->getIsValid()) {
123
+ switch ($this->getReceivedFrom()) {
124
+ case 1:
125
+ $canSave = Mage::getStoreConfigFlag('payment/pagseguro_api/allow_log_notifications');
126
+ break;
127
+ case 2:
128
+ $canSave = Mage::getStoreConfigFlag('payment/pagseguro_api/allow_log_consults');
129
+ break;
130
+ case 3:
131
+ $canSave = Mage::getStoreConfigFlag('payment/pagseguro_api/allow_log_mass_consults');
132
+ break;
133
+ }
134
+
135
+ if($canSave) {
136
+ $this->save();
137
+ }
138
+ }
139
+
140
+ return $this;
141
+ }
142
+
143
+
144
+ /**
145
+ * Processing object before save data
146
+ *
147
+ * @return OsStudios_PagSeguroApi_Model_Returns_Transaction
148
+ */
149
+ protected function _beforeSave()
150
+ {
151
+ return parent::_beforeSave();
152
+ }
153
+
154
+
155
+ /**
156
+ * Verifies if the transaction passed is compatible with the order in the system.
157
+ *
158
+ * @return (boolean)
159
+ */
160
+ private function _isTransactionCompatible()
161
+ {
162
+ if(!$this->getOrder() || !($this->getOrder() instanceof Mage_Sales_Model_Order)) {
163
+ return false;
164
+ } elseif(round(((float) $this->getOrder()->getGrandTotal() - (float) $this->getGrossAmount()), 2) != (float) 0.00) {
165
+ return false;
166
+ }
167
+
168
+ /**
169
+ * Validates only if the consult was made by massaction option
170
+ *
171
+ */
172
+ if($this->getReceivedFrom() != 3) {
173
+ if($this->getOrder()->getCustomerEmail() !== $this->getSender()->getEmail()) {
174
+ return false;
175
+ } elseif((int) count($this->getOrder()->getAllVisibleItems()) !== (int) $this->getItemCount()) {
176
+ return false;
177
+ }
178
+ }
179
+
180
+ return true;
181
+ }
182
+
183
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Config.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function getAssociativeArray($index = 'value', $label = 'label')
27
+ {
28
+ $options = $this->toOptionArray();
29
+ $associative = array();
30
+ foreach($options as $key => $option) {
31
+ $associative[$option[$index]] = Mage::helper('pagseguroapi')->__($option[$label]);
32
+ }
33
+
34
+ return $associative;
35
+ }
36
+
37
+ public function getNodeByAttribute($value, $index, $attribute)
38
+ {
39
+ $arr = $this->getAssociativeArray($index, $attribute);
40
+ return $arr[$value];
41
+ }
42
+
43
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Error/Codes.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Error_Codes extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/error_codes')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Shipping/Type.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Shipping_Type
24
+ {
25
+
26
+ public function toOptionArray ()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/shipping/types')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Payment/Methods/Codes.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Transaction_Payment_Methods_Codes extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/payment_methods/codes')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Payment/Methods/Types.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Transaction_Payment_Methods_Types extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/payment_methods/types')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Sources.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Status Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Transaction_Sources extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/sources')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Status.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Status Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Transaction_Status extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/status')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/Model/System/Config/Source/Transaction/Types.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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 Api Shipping Type Source
20
+ *
21
+ */
22
+
23
+ class OsStudios_PagSeguroApi_Model_System_Config_Source_Transaction_Types extends OsStudios_PagSeguroApi_Model_System_Config_Source_Config
24
+ {
25
+
26
+ public function toOptionArray()
27
+ {
28
+ $options = Mage::app()->getConfig()->getNode('default/osstudios_pagseguroapi/transaction/types')->asArray();
29
+ return $options;
30
+ }
31
+
32
+ }
app/code/community/OsStudios/PagSeguroApi/controllers/Adminhtml/ActionsController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Adminhtml_ActionsController extends OsStudios_PagSeguroApi_Controller_Adminhtml_Action
19
+ {
20
+
21
+ public function updateordersAction()
22
+ {
23
+ try {
24
+ $consulter = Mage::getModel('pagseguroapi/consulter');
25
+ $consulter->massConsult();
26
+ } catch (Exception $e) {
27
+ Mage::getSingleton('admin/session')->addError($e->getMessage());
28
+ }
29
+
30
+ $this->_redirect('*/adminhtml_transaction/history');
31
+ }
32
+
33
+ protected function _isAllowed()
34
+ {
35
+ return Mage::getSingleton('admin/session')->isAllowed('pagseguroapi/actions');
36
+ }
37
+
38
+ }
app/code/community/OsStudios/PagSeguroApi/controllers/Adminhtml/TransactionController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_Adminhtml_TransactionController extends OsStudios_PagSeguroApi_Controller_Adminhtml_Action
19
+ {
20
+
21
+ /**
22
+ * View Transaction History
23
+ *
24
+ */
25
+ public function historyAction()
26
+ {
27
+ $this->_title($this->__('PagSeguro API'))->_title($this->__('Transaction'))->_title($this->__('View History'));
28
+
29
+ $this->loadLayout();
30
+ $this->_initLayoutMessages('admin/session');
31
+ $this->renderLayout();
32
+ }
33
+
34
+
35
+ /**
36
+ * Mass remove
37
+ *
38
+ */
39
+ public function massRemoveAction()
40
+ {
41
+ try {
42
+ $ids = $this->getRequest()->getPost('ids', array());
43
+ foreach ($ids as $id) {
44
+ $model = Mage::getModel('pagseguroapi/returns_transaction');
45
+ $model->setId($id)->delete();
46
+ }
47
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('%s transaction(s) was successfully removed.', count($ids)));
48
+ }
49
+ catch (Exception $e) {
50
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
51
+ }
52
+ $this->_redirect('*/*/history');
53
+ }
54
+
55
+
56
+ /**
57
+ * Export order grid to CSV format
58
+ *
59
+ */
60
+ public function exportCsvAction()
61
+ {
62
+ $fileName = 'osstudios_pagseguro_returns_transactions.csv';
63
+ $grid = $this->getLayout()->createBlock('pagseguroapi/adminhtml_transaction_grid');
64
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
65
+ }
66
+
67
+
68
+ /**
69
+ * Export order grid to Excel XML format
70
+ *
71
+ */
72
+ public function exportExcelAction()
73
+ {
74
+ $fileName = 'osstudios_pagseguro_returns_transactions.xml';
75
+ $grid = $this->getLayout()->createBlock('pagseguroapi/adminhtml_transaction_grid');
76
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
77
+ }
78
+
79
+
80
+ /**
81
+ * Used for ajax update in transaction history grid
82
+ *
83
+ */
84
+ public function gridAction()
85
+ {
86
+ $this->loadLayout();
87
+ $this->renderLayout();
88
+ }
89
+
90
+
91
+ /**
92
+ * ACL Checks
93
+ *
94
+ * @return boolean
95
+ */
96
+ protected function _isAllowed()
97
+ {
98
+ return Mage::getSingleton('admin/session')->isAllowed('pagseguroapi/returns');
99
+ }
100
+
101
+ }
app/code/community/OsStudios/PagSeguroApi/controllers/PayController.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_PayController extends OsStudios_PagSeguroApi_Controller_Front_Action
19
+ {
20
+
21
+ /**
22
+ * Shows success page after payment.
23
+ *
24
+ */
25
+ public function successAction()
26
+ {
27
+ $session = $this->getOnepage()->getCheckout();
28
+ if (!$session->getLastSuccessQuoteId()) {
29
+ $this->_redirect('checkout/cart');
30
+ return;
31
+ }
32
+
33
+ $lastQuoteId = $session->getLastQuoteId();
34
+ $lastOrderId = $session->getLastOrderId();
35
+ $lastRecurringProfiles = $session->getLastRecurringProfileIds();
36
+ if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
37
+ $this->_redirect('checkout/cart');
38
+ return;
39
+ }
40
+
41
+ Mage::register('osstudios_pagseguro_last_order_id', $lastOrderId);
42
+ Mage::dispatchEvent('osstudios_pagseguroapi_controller_success_action', array('order_ids' => array($lastOrderId)));
43
+
44
+ try {
45
+ $order = Mage::getModel('sales/order')->load($lastOrderId);
46
+ if ($order->getCanSendNewEmailFlag()){
47
+ $order->sendNewOrderEmail();
48
+ }
49
+ } catch (Exception $e) {
50
+ Mage::logException($e);
51
+ }
52
+
53
+ $this->loadLayout();
54
+ $this->_initLayoutMessages('checkout/session');
55
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
56
+ $this->renderLayout();
57
+
58
+ $session->clear();
59
+
60
+ Mage::unregister('osstudios_pagseguro_last_order_id');
61
+ }
62
+
63
+
64
+ /**
65
+ * Returns the installments block
66
+ *
67
+ */
68
+ public function installmentsAction()
69
+ {
70
+ $this->loadLayout();
71
+ $this->renderLayout();
72
+ }
73
+ }
app/code/community/OsStudios/PagSeguroApi/controllers/ReturnsController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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_PagSeguroApi_ReturnsController extends OsStudios_PagSeguroApi_Controller_Front_Action
19
+ {
20
+
21
+ public function indexAction()
22
+ {
23
+ $request = $this->getRequest();
24
+
25
+ if($this->_validateRequest($request)) {
26
+ $post = $request->getPost();
27
+ $url = Mage::getSingleton('pagseguroapi/data')->getPagSeguroNotificationUrl($post['notificationCode']);
28
+
29
+ $consulter = Mage::getModel('pagseguroapi/consulter');
30
+ $consulter->consultByNotificationId($post['notificationCode']);
31
+ }
32
+ }
33
+
34
+
35
+ /**
36
+ * JUST FOR TESTS
37
+ *
38
+ * @todo remove this method for release
39
+ */
40
+ public function consultAction()
41
+ {
42
+ $request = $this->getRequest();
43
+
44
+ $transactionId = $request->getParam('transaction_id');
45
+
46
+ if($transactionId) {
47
+ $consulter = Mage::getModel('pagseguroapi/consulter');
48
+ $consulter->consultByTransactionId($transactionId);
49
+ } else {
50
+ $transactions = Mage::getModel('pagseguroapi/returns_transaction')->getCollection();
51
+ echo 'Minha collection: ' . $transactions->count();
52
+ }
53
+ }
54
+
55
+
56
+ protected function _validateRequest($request)
57
+ {
58
+ if(!$request->isPost()) {
59
+ return false;
60
+ }
61
+
62
+ $post = $request->getPost();
63
+
64
+ if(!$post['notificationCode'] || !$post['notificationType']) {
65
+ return false;
66
+ }
67
+
68
+ if(!($post['notificationType'] == 'transaction')) {
69
+ return false;
70
+ }
71
+
72
+ /**
73
+ * Validates Format: XXXXXX-XXXXXXXXXXXX-XXXXXXXXXXXX-XXXXXX
74
+ */
75
+ if(!preg_match('/^[0-9A-Z]{6}\-[0-9A-Z]{12}\-[0-9A-Z]{12}\-[0-9A-Z]{6}$/', strtoupper($post['notificationCode']))) {
76
+ return false;
77
+ }
78
+
79
+ return true;
80
+ }
81
+
82
+ }
app/code/community/OsStudios/PagSeguroApi/etc/adminhtml.xml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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
+ <pagseguroapi translate="title" module="pagseguroapi">
23
+ <title>PagSeguro API</title>
24
+ <sort_order>85</sort_order>
25
+ <children>
26
+ <returns translate="title">
27
+ <title>API Returns and Consults</title>
28
+ <sort_order>10</sort_order>
29
+ <children>
30
+ <view_history translate="title">
31
+ <title>View History</title>
32
+ <action>pagseguroapi/adminhtml_transaction/history</action>
33
+ <sort_order>10</sort_order>
34
+ </view_history>
35
+ </children>
36
+ </returns>
37
+ <actions translate="title">
38
+ <title>Actions</title>
39
+ <sort_order>20</sort_order>
40
+ <children>
41
+ <request_update_orders translate="title">
42
+ <title>Check for Order Updates</title>
43
+ <action>pagseguroapi/adminhtml_actions/updateorders</action>
44
+ <sort_order>10</sort_order>
45
+ </request_update_orders>
46
+ </children>
47
+ </actions>
48
+ <payment_configurations translate="title">
49
+ <title>Configurations</title>
50
+ <action>adminhtml/system_config/edit/section/payment</action>
51
+ <sort_order>100</sort_order>
52
+ </payment_configurations>
53
+ </children>
54
+ </pagseguroapi>
55
+ </menu>
56
+ <acl>
57
+ <resources>
58
+ <admin>
59
+ <children>
60
+ <system>
61
+ <children>
62
+ <config>
63
+ <children>
64
+ <payment>
65
+ <children>
66
+ <pagseguroapi translate="title" module="pagseguroapi">
67
+ <title>PagSeguroApi Configurations</title>
68
+ </pagseguroapi>
69
+ </children>
70
+ </payment>
71
+ </children>
72
+ </config>
73
+ </children>
74
+ </system>
75
+ <pagseguroapi translate="title" module="pagseguroapi">
76
+ <title>PagSeguro API</title>
77
+ <sort_order>1000</sort_order>
78
+ <children>
79
+ <returns translate="title">
80
+ <title>API Returns and Consults</title>
81
+ <sort_order>10</sort_order>
82
+ <children>
83
+ <view_history translate="title">
84
+ <title>View History</title>
85
+ <sort_order>10</sort_order>
86
+ </view_history>
87
+ </children>
88
+ </returns>
89
+ <actions translate="title">
90
+ <title>Actions</title>
91
+ <sort_order>20</sort_order>
92
+ <children>
93
+ <request_update_orders translate="title">
94
+ <title>Check for Order Updates</title>
95
+ <sort_order>10</sort_order>
96
+ </request_update_orders>
97
+ </children>
98
+ </actions>
99
+ </children>
100
+ </pagseguroapi>
101
+ </children>
102
+ </admin>
103
+ </resources>
104
+ </acl>
105
+ </config>
app/code/community/OsStudios/PagSeguroApi/etc/config.xml ADDED
@@ -0,0 +1,772 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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_PagSeguroApi>
23
+ <version>1.0.0.2</version>
24
+ </OsStudios_PagSeguroApi>
25
+ </modules>
26
+ <global>
27
+ <helpers>
28
+ <pagseguroapi>
29
+ <class>OsStudios_PagSeguroApi_Helper</class>
30
+ </pagseguroapi>
31
+ </helpers>
32
+ <blocks>
33
+ <pagseguroapi>
34
+ <class>OsStudios_PagSeguroApi_Block</class>
35
+ </pagseguroapi>
36
+ </blocks>
37
+ <models>
38
+ <pagseguroapi>
39
+ <class>OsStudios_PagSeguroApi_Model</class>
40
+ <resourceModel>osstudios_pagseguroapi_mysql4</resourceModel>
41
+ </pagseguroapi>
42
+ <osstudios_pagseguroapi_mysql4>
43
+ <class>OsStudios_PagSeguroApi_Model_Mysql4</class>
44
+ <!--<deprecatedNode>osstudios_pagseguroapi_mysql4</deprecatedNode>-->
45
+ <entities>
46
+ <payment_history>
47
+ <table>osstudios_pagseguroapi_payment_history</table>
48
+ </payment_history>
49
+ <returns_transaction>
50
+ <table>osstudios_pagseguroapi_returns_transaction</table>
51
+ </returns_transaction>
52
+ </entities>
53
+ </osstudios_pagseguroapi_mysql4>
54
+ </models>
55
+ <resources>
56
+ <pagseguroapi_setup>
57
+ <setup>
58
+ <module>OsStudios_PagSeguroApi</module>
59
+ </setup>
60
+ </pagseguroapi_setup>
61
+ </resources>
62
+ <events>
63
+ <sales_order_load_after>
64
+ <observers>
65
+ <osstudios_pagseguroapi_sales_order_payment_load_after>
66
+ <type>model</type>
67
+ <class>pagseguroapi/observer</class>
68
+ <method>salesOrderPaymentLoadAfter</method>
69
+ </osstudios_pagseguroapi_sales_order_payment_load_after>
70
+ </observers>
71
+ </sales_order_load_after>
72
+ </events>
73
+ </global>
74
+ <admin>
75
+ <routers>
76
+ <pagseguroapi>
77
+ <use>admin</use>
78
+ <args>
79
+ <module>OsStudios_PagSeguroApi</module>
80
+ <frontName>pagseguroapi</frontName>
81
+ </args>
82
+ </pagseguroapi>
83
+ </routers>
84
+ </admin>
85
+ <adminhtml>
86
+ <translate>
87
+ <modules>
88
+ <pagseguroapi>
89
+ <files>
90
+ <default>OsStudios/PagSeguroApi.csv</default>
91
+ </files>
92
+ </pagseguroapi>
93
+ </modules>
94
+ </translate>
95
+ <layout>
96
+ <updates>
97
+ <pagseguroapi>
98
+ <file>osstudios/pagseguroapi.xml</file>
99
+ </pagseguroapi>
100
+ </updates>
101
+ </layout>
102
+ </adminhtml>
103
+ <frontend>
104
+ <routers>
105
+ <pagseguroapi>
106
+ <use>standard</use>
107
+ <args>
108
+ <module>OsStudios_PagSeguroApi</module>
109
+ <frontName>pagseguroapi</frontName>
110
+ </args>
111
+ </pagseguroapi>
112
+ </routers>
113
+ <translate>
114
+ <modules>
115
+ <pagseguroapi>
116
+ <files>
117
+ <default>OsStudios/PagSeguroApi.csv</default>
118
+ </files>
119
+ </pagseguroapi>
120
+ </modules>
121
+ </translate>
122
+ <layout>
123
+ <updates>
124
+ <pagseguroapi>
125
+ <file>osstudios/pagseguroapi.xml</file>
126
+ </pagseguroapi>
127
+ </updates>
128
+ </layout>
129
+ <events>
130
+
131
+ </events>
132
+ </frontend>
133
+ <default>
134
+ <payment>
135
+ <pagseguro_api>
136
+ <account_email/>
137
+ <account_token/>
138
+ <model>OsStudios_PagSeguroApi_Model_Payment_Method_Api</model>
139
+ <active>0</active>
140
+ <title>PagSeguro UOL - API</title>
141
+ <order_status>pending</order_status>
142
+ <show_message>1</show_message>
143
+ <message>You will be redirected to PagSeguro after the order confirmation using API features.</message>
144
+ <max_uses>100</max_uses>
145
+ <max_age>3600</max_age>
146
+ <extra_amount>0.00</extra_amount>
147
+ <shipping_type>3</shipping_type>
148
+ <show_installments>1</show_installments>
149
+ <allow_log_notifications>1</allow_log_notifications>
150
+ <allow_log_consults>1</allow_log_consults>
151
+ <allow_log_mass_consults>1</allow_log_mass_consults>
152
+ <payment_action>createTransaction</payment_action>
153
+ <pagseguro_api_url>https://ws.pagseguro.uol.com.br/v2/checkout</pagseguro_api_url>
154
+ <pagseguro_api_redirect_url>https://pagseguro.uol.com.br/v2/checkout/payment.html</pagseguro_api_redirect_url>
155
+ <pagseguro_billet_url>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml</pagseguro_billet_url>
156
+ <pagseguro_transactions_url>https://ws.pagseguro.uol.com.br/v2/transactions</pagseguro_transactions_url>
157
+ <pagseguro_notifications_url>https://ws.pagseguro.uol.com.br/v2/transactions/notifications</pagseguro_notifications_url>
158
+ <open_in_other_page>0</open_in_other_page>
159
+ <automatically_change_orders>1</automatically_change_orders>
160
+ <automatically_cancel_orders>1</automatically_cancel_orders>
161
+ <automatically_invoice_orders>1</automatically_invoice_orders>
162
+ <automatically_hold_orders_for_billet>1</automatically_hold_orders_for_billet>
163
+ <debug>1</debug>
164
+ </pagseguro_api>
165
+ </payment>
166
+ <osstudios_pagseguroapi>
167
+ <transaction>
168
+ <sources>
169
+ <sources_1>
170
+ <value>1</value>
171
+ <label>Notifications</label>
172
+ </sources_1>
173
+ <sources_2>
174
+ <value>2</value>
175
+ <label>Consults</label>
176
+ </sources_2>
177
+ <sources_3>
178
+ <value>3</value>
179
+ <label>Mass Consults</label>
180
+ </sources_3>
181
+ </sources>
182
+ <types>
183
+ <type_1>
184
+ <value>1</value>
185
+ <label>Payment</label>
186
+ </type_1>
187
+ </types>
188
+ <status>
189
+ <status_1>
190
+ <value>1</value>
191
+ <label>Aguardando Pagamento</label>
192
+ </status_1>
193
+ <status_2>
194
+ <value>2</value>
195
+ <label>Em Análise</label>
196
+ </status_2>
197
+ <status_3>
198
+ <value>3</value>
199
+ <label>Pago</label>
200
+ </status_3>
201
+ <status_4>
202
+ <value>4</value>
203
+ <label>Disponível</label>
204
+ </status_4>
205
+ <status_5>
206
+ <value>5</value>
207
+ <label>Em Disputa</label>
208
+ </status_5>
209
+ <status_6>
210
+ <value>6</value>
211
+ <label>Devolvido</label>
212
+ </status_6>
213
+ <status_7>
214
+ <value>7</value>
215
+ <label>Cancelado</label>
216
+ </status_7>
217
+ </status>
218
+ <payment_methods>
219
+ <types>
220
+ <type_1>
221
+ <value>1</value>
222
+ <label>Cartão de Crédito</label>
223
+ </type_1>
224
+ <type_2>
225
+ <value>2</value>
226
+ <label>Boleto</label>
227
+ </type_2>
228
+ <type_3>
229
+ <value>3</value>
230
+ <label>Débito Online (TEF)</label>
231
+ </type_3>
232
+ <type_4>
233
+ <value>4</value>
234
+ <label>Saldo PagSeguro</label>
235
+ </type_4>
236
+ <type_5>
237
+ <value>5</value>
238
+ <label>Oi Paggo</label>
239
+ </type_5>
240
+ </types>
241
+ <codes>
242
+ <!-- Cartão de Crédito -->
243
+ <code_101>
244
+ <value>101</value>
245
+ <label>Cartão de Crédito Visa</label>
246
+ </code_101>
247
+ <code_102>
248
+ <value>102</value>
249
+ <label>Cartão de Crédito MasterCard</label>
250
+ </code_102>
251
+ <code_103>
252
+ <value>103</value>
253
+ <label>Cartão de Crédito American Express</label>
254
+ </code_103>
255
+ <code_104>
256
+ <value>104</value>
257
+ <label>Cartão de Crédito Diners</label>
258
+ </code_104>
259
+ <code_105>
260
+ <value>105</value>
261
+ <label>Cartão de Crédito Hipercard</label>
262
+ </code_105>
263
+ <code_106>
264
+ <value>106</value>
265
+ <label>Cartão de Crédito Aura</label>
266
+ </code_106>
267
+ <code_107>
268
+ <value>107</value>
269
+ <label>Cartão de Crédito Elo</label>
270
+ </code_107>
271
+ <code_108>
272
+ <value>108</value>
273
+ <label>Cartão de Crédito PLENOCard</label>
274
+ </code_108>
275
+ <code_109>
276
+ <value>109</value>
277
+ <label>Cartão de Crédito PersonalCard</label>
278
+ </code_109>
279
+ <code_110>
280
+ <value>110</value>
281
+ <label>Cartão de Crédito JCB</label>
282
+ </code_110>
283
+ <code_111>
284
+ <value>111</value>
285
+ <label>Cartão de Crédito Discover</label>
286
+ </code_111>
287
+ <code_112>
288
+ <value>112</value>
289
+ <label>Cartão de Crédito BrasilCard</label>
290
+ </code_112>
291
+ <code_113>
292
+ <value>113</value>
293
+ <label>Cartão de Crédito FORTBRASIL</label>
294
+ </code_113>
295
+ <!-- Boleto-->
296
+ <code_201>
297
+ <value>201</value>
298
+ <label>Boleto Bradesco</label>
299
+ </code_201>
300
+ <code_202>
301
+ <value>202</value>
302
+ <label>Boleto Santander</label>
303
+ </code_202>
304
+ <!-- Débito online (TEF) -->
305
+ <code_301>
306
+ <value>301</value>
307
+ <label>Débito Online Bradesco</label>
308
+ </code_301>
309
+ <code_302>
310
+ <value>302</value>
311
+ <label>Débito Online Itaú</label>
312
+ </code_302>
313
+ <code_303>
314
+ <value>303</value>
315
+ <label>Débito Online Unibanco</label>
316
+ </code_303>
317
+ <code_304>
318
+ <value>304</value>
319
+ <label>Débito Online Banco do Brasil</label>
320
+ </code_304>
321
+ <code_305>
322
+ <value>305</value>
323
+ <label>Débito Online Banco Real</label>
324
+ </code_305>
325
+ <code_306>
326
+ <value>306</value>
327
+ <label>Débito Online Banrisul</label>
328
+ </code_306>
329
+ <code_307>
330
+ <value>307</value>
331
+ <label>Débito Online HSBC</label>
332
+ </code_307>
333
+ <!-- Saldo PagSeguro -->
334
+ <code_401>
335
+ <value>401</value>
336
+ <label>Saldo PagSeguro</label>
337
+ </code_401>
338
+ <!-- Oi Paggo -->
339
+ <code_501>
340
+ <value>501</value>
341
+ <label>Oi Paggo</label>
342
+ </code_501>
343
+ </codes>
344
+ </payment_methods>
345
+ <installments>
346
+ <min>5.00000</min>
347
+ <credit_cards>
348
+ <visa>
349
+ <active>1</active>
350
+ <value></value>
351
+ <label>Cartão de crédito Visa</label>
352
+ <max_installment>12</max_installment>
353
+ </visa>
354
+ <mastercard>
355
+ <active>1</active>
356
+ <value></value>
357
+ <label>Cartão de crédito MasterCard</label>
358
+ <max_installment>12</max_installment>
359
+ </mastercard>
360
+ <amex>
361
+ <active>1</active>
362
+ <value></value>
363
+ <label>Cartão de crédito American Express</label>
364
+ <max_installment>15</max_installment>
365
+ </amex>
366
+ <diners>
367
+ <active>1</active>
368
+ <value></value>
369
+ <label>Cartão de crédito Diners</label>
370
+ <max_installment>12</max_installment>
371
+ </diners>
372
+ <hipercard>
373
+ <active>1</active>
374
+ <value></value>
375
+ <label>Cartão de crédito Hipercard</label>
376
+ <max_installment>12</max_installment>
377
+ </hipercard>
378
+ <aura>
379
+ <active>1</active>
380
+ <value></value>
381
+ <label>Cartão de crédito Aura</label>
382
+ <max_installment>18</max_installment>
383
+ </aura>
384
+ <elo>
385
+ <active>1</active>
386
+ <value></value>
387
+ <label>Cartão de crédito Elo</label>
388
+ <max_installment>12</max_installment>
389
+ </elo>
390
+ <plenocard>
391
+ <active>1</active>
392
+ <value></value>
393
+ <label>Cartão de crédito PLENOCard</label>
394
+ <max_installment>3</max_installment>
395
+ </plenocard>
396
+ <personalcard>
397
+ <active>1</active>
398
+ <value></value>
399
+ <label>Cartão de crédito PersonalCard</label>
400
+ <max_installment>3</max_installment>
401
+ </personalcard>
402
+ <jcb>
403
+ <active>1</active>
404
+ <value></value>
405
+ <label>Cartão de crédito JCB</label>
406
+ <max_installment>12</max_installment>
407
+ </jcb>
408
+ <discover>
409
+ <active>1</active>
410
+ <value></value>
411
+ <label>Cartão de crédito Discover</label>
412
+ <max_installment>12</max_installment>
413
+ </discover>
414
+ <brasilcard>
415
+ <active>1</active>
416
+ <value></value>
417
+ <label>Cartão de crédito BrasilCard</label>
418
+ <max_installment>3</max_installment>
419
+ </brasilcard>
420
+ <fortbrasil>
421
+ <active>1</active>
422
+ <value></value>
423
+ <label>Cartão de crédito FORTBRASIL</label>
424
+ <max_installment>12</max_installment>
425
+ </fortbrasil>
426
+ <cardban>
427
+ <active>1</active>
428
+ <value></value>
429
+ <label>Cartão de crédito CARDBAN</label>
430
+ <max_installment>12</max_installment>
431
+ </cardban>
432
+ <valecard>
433
+ <active>1</active>
434
+ <value></value>
435
+ <label>Cartão de crédito VALECARD</label>
436
+ <max_installment>3</max_installment>
437
+ </valecard>
438
+ <cabal>
439
+ <active>1</active>
440
+ <value></value>
441
+ <label>Cartão de crédito CABAL</label>
442
+ <max_installment>12</max_installment>
443
+ </cabal>
444
+ </credit_cards>
445
+ <factors>
446
+ <factor_1>1.00000</factor_1>
447
+ <factor_2>0.51875</factor_2>
448
+ <factor_3>0.35007</factor_3>
449
+ <factor_4>0.26575</factor_4>
450
+ <factor_5>0.21518</factor_5>
451
+ <factor_6>0.18148</factor_6>
452
+ <factor_7>0.15743</factor_7>
453
+ <factor_8>0.13941</factor_8>
454
+ <factor_9>0.12540</factor_9>
455
+ <factor_10>0.11420</factor_10>
456
+ <factor_11>0.10505</factor_11>
457
+ <factor_12>0.09743</factor_12>
458
+ <factor_13>0.09099</factor_13>
459
+ <factor_14>0.08548</factor_14>
460
+ <factor_15>0.08071</factor_15>
461
+ <factor_16>0.07654</factor_16>
462
+ <factor_17>0.07287</factor_17>
463
+ <factor_18>0.06961</factor_18>
464
+ </factors>
465
+ </installments>
466
+ <shipping>
467
+ <types>
468
+ <pac>
469
+ <value>1</value>
470
+ <label>Encomenda normal (PAC)</label>
471
+ </pac>
472
+ <sedex>
473
+ <value>2</value>
474
+ <label>SEDEX</label>
475
+ </sedex>
476
+ <not_specified>
477
+ <value>3</value>
478
+ <label>Tipo de frete não especificado</label>
479
+ </not_specified>
480
+ </types>
481
+ </shipping>
482
+ </transaction>
483
+ <error_codes>
484
+ <code_11001>
485
+ <value>11001</value>
486
+ <label>receiverEmail is required.</label>
487
+ <message>receiverEmail is required.</message>
488
+ </code_11001>
489
+ <code_11002>
490
+ <value>11002</value>
491
+ <label>receiverEmail invalid length: {0}</label>
492
+ <message>receiverEmail invalid length: {0}</message>
493
+ </code_11002>
494
+ <code_11003>
495
+ <value>11003</value>
496
+ <label>receiverEmail invalid value.</label>
497
+ <message>receiverEmail invalid value.</message>
498
+ </code_11003>
499
+ <code_11004>
500
+ <value>11004</value>
501
+ <label>Currency is required.</label>
502
+ <message>Currency is required.</message>
503
+ </code_11004>
504
+ <code_11005>
505
+ <value>11005</value>
506
+ <label>Currency invalid value: {0}</label>
507
+ <message>Currency invalid value: {0}</message>
508
+ </code_11005>
509
+ <code_11006>
510
+ <value>11006</value>
511
+ <label>redirectURL invalid length: {0}</label>
512
+ <message>redirectURL invalid length: {0}</message>
513
+ </code_11006>
514
+ <code_11007>
515
+ <value>11007</value>
516
+ <label>redirectURL invalid value: {0}</label>
517
+ <message>redirectURL invalid value: {0}</message>
518
+ </code_11007>
519
+ <code_11008>
520
+ <value>11008</value>
521
+ <label>reference invalid length: {0}</label>
522
+ <message>reference invalid length: {0}</message>
523
+ </code_11008>
524
+ <code_11009>
525
+ <value>11009</value>
526
+ <label>senderEmail invalid length: {0}</label>
527
+ <message>senderEmail invalid length: {0}</message>
528
+ </code_11009>
529
+ <code_11010>
530
+ <value>11010</value>
531
+ <label>senderEmail invalid value: {0}</label>
532
+ <message>senderEmail invalid value: {0}</message>
533
+ </code_11010>
534
+ <code_11011>
535
+ <value>11011</value>
536
+ <label>senderName invalid length: {0}</label>
537
+ <message>senderName invalid length: {0}</message>
538
+ </code_11011>
539
+ <code_11012>
540
+ <value>11012</value>
541
+ <label>senderName invalid value: {0}</label>
542
+ <message>senderName invalid value: {0}</message>
543
+ </code_11012>
544
+ <code_11013>
545
+ <value>11013</value>
546
+ <label>senderAreaCode invalid value: {0}</label>
547
+ <message>senderAreaCode invalid value: {0}</message>
548
+ </code_11013>
549
+ <code_11014>
550
+ <value>11014</value>
551
+ <label>senderPhone invalid value: {0}</label>
552
+ <message>senderPhone invalid value: {0}</message>
553
+ </code_11014>
554
+ <code_11015>
555
+ <value>11015</value>
556
+ <label>ShippingType is required.</label>
557
+ <message>ShippingType is required.</message>
558
+ </code_11015>
559
+ <code_11016>
560
+ <value>11016</value>
561
+ <label>shippingType invalid type: {0}</label>
562
+ <message>shippingType invalid type: {0}</message>
563
+ </code_11016>
564
+ <code_11017>
565
+ <value>11017</value>
566
+ <label>shippingPostalCode invalid Value: {0}</label>
567
+ <message>shippingPostalCode invalid Value: {0}</message>
568
+ </code_11017>
569
+ <code_11018>
570
+ <value>11018</value>
571
+ <label>shippingAddressStreet invalid length: {0}</label>
572
+ <message>shippingAddressStreet invalid length: {0}</message>
573
+ </code_11018>
574
+ <code_11019>
575
+ <value>11019</value>
576
+ <label>shippingAddressNumber invalid length: {0}</label>
577
+ <message>shippingAddressNumber invalid length: {0}</message>
578
+ </code_11019>
579
+ <code_11020>
580
+ <value>11020</value>
581
+ <label>shippingAddressComplement invalid length: {0}</label>
582
+ <message>shippingAddressComplement invalid length: {0}</message>
583
+ </code_11020>
584
+ <code_11021>
585
+ <value>11021</value>
586
+ <label>shippingAddressDistrict invalid length: {0}</label>
587
+ <message>shippingAddressDistrict invalid length: {0}</message>
588
+ </code_11021>
589
+ <code_11022>
590
+ <value>11022</value>
591
+ <label>shippingAddressCity invalid length: {0}</label>
592
+ <message>shippingAddressCity invalid length: {0}</message>
593
+ </code_11022>
594
+ <code_11023>
595
+ <value>11023</value>
596
+ <label>shippingAddressState invalid value: {0}, must fit the pattern: \w\{2\} (e. g. "SP")</label>
597
+ <message>shippingAddressState invalid value: {0}, must fit the pattern: \w\{2\} (e. g. "SP")</message>
598
+ </code_11023>
599
+ <code_11024>
600
+ <value>11024</value>
601
+ <label>Itens invalid quantity.</label>
602
+ <message>Itens invalid quantity.</message>
603
+ </code_11024>
604
+ <code_11025>
605
+ <value>11025</value>
606
+ <label>Item Id is required.</label>
607
+ <message>Item Id is required.</message>
608
+ </code_11025>
609
+ <code_11026>
610
+ <value>11026</value>
611
+ <label>Item quantity is required.</label>
612
+ <message>Item quantity is required.</message>
613
+ </code_11026>
614
+ <code_11027>
615
+ <value>11027</value>
616
+ <label>Item quantity out of range: {0}</label>
617
+ <message>Item quantity out of range: {0}</message>
618
+ </code_11027>
619
+ <code_11028>
620
+ <value>11028</value>
621
+ <label>Item amount is required. (e.g. "12.00")</label>
622
+ <message>Item amount is required. (e.g. "12.00")</message>
623
+ </code_11028>
624
+ <code_11029>
625
+ <value>11029</value>
626
+ <label>Item amount invalid pattern: {0}. Must fit the patern: \d+.\d\{2\}</label>
627
+ <message>Item amount invalid pattern: {0}. Must fit the patern: \d+.\d\{2\}</message>
628
+ </code_11029>
629
+ <code_11030>
630
+ <value>11030</value>
631
+ <label>Item amount out of range: {0}</label>
632
+ <message>Item amount out of range: {0}</message>
633
+ </code_11030>
634
+ <code_11031>
635
+ <value>11031</value>
636
+ <label>Item shippingCost invalid pattern: {0}. Must fit the patern: \d+.\d\{2\}</label>
637
+ <message>Item shippingCost invalid pattern: {0}. Must fit the patern: \d+.\d\{2\}</message>
638
+ </code_11031>
639
+ <code_11032>
640
+ <value>11032</value>
641
+ <label>Item shippingCost out of range: {0}</label>
642
+ <message>Item shippingCost out of range: {0}</message>
643
+ </code_11032>
644
+ <code_11033>
645
+ <value>11033</value>
646
+ <label>Item description is required.</label>
647
+ <message>Item description is required.</message>
648
+ </code_11033>
649
+ <code_11034>
650
+ <value>11034</value>
651
+ <label>Item description invalid length: {0}</label>
652
+ <message>Item description invalid length: {0}</message>
653
+ </code_11034>
654
+ <code_11035>
655
+ <value>11035</value>
656
+ <label>Item weight invalid Value: {0}</label>
657
+ <message>Item weight invalid Value: {0}</message>
658
+ </code_11035>
659
+ <code_11036>
660
+ <value>11036</value>
661
+ <label>Extra amount invalid pattern: {0}. Must fit the patern: -?\d+.\d\{2\}</label>
662
+ <message>Extra amount invalid pattern: {0}. Must fit the patern: -?\d+.\d\{2\}</message>
663
+ </code_11036>
664
+ <code_11037>
665
+ <value>11037</value>
666
+ <label>Extra amount out of range: {0}</label>
667
+ <message>Extra amount out of range: {0}</message>
668
+ </code_11037>
669
+ <code_11038>
670
+ <value>11038</value>
671
+ <label>Invalid receiver for checkout: {0}, verify receiver's account status.</label>
672
+ <message>Invalid receiver for checkout: {0}, verify receiver's account status.</message>
673
+ </code_11038>
674
+ <code_11039>
675
+ <value>11039</value>
676
+ <label>Malformed request XML: {0}.</label>
677
+ <message>Malformed request XML: {0}.</message>
678
+ </code_11039>
679
+ <code_11040>
680
+ <value>11040</value>
681
+ <label>maxAge invalid pattern: {0}. Must fit the patern: \d+</label>
682
+ <message>maxAge invalid pattern: {0}. Must fit the patern: \d+</message>
683
+ </code_11040>
684
+ <code_11041>
685
+ <value>11041</value>
686
+ <label>maxAge out of range: {0}</label>
687
+ <message>maxAge out of range: {0}</message>
688
+ </code_11041>
689
+ <code_11042>
690
+ <value>11042</value>
691
+ <label>maxUses invalid pattern: {0}. Must fit the patern: \d+</label>
692
+ <message>maxUses invalid pattern: {0}. Must fit the patern: \d+</message>
693
+ </code_11042>
694
+ <code_11043>
695
+ <value>11043</value>
696
+ <label>maxUses out of range.</label>
697
+ <message>maxUses out of range.</message>
698
+ </code_11043>
699
+ <code_11044>
700
+ <value>11044</value>
701
+ <label>initialDate is required.</label>
702
+ <message>initialDate is required.</message>
703
+ </code_11044>
704
+ <code_11045>
705
+ <value>11045</value>
706
+ <label>initialDate must be lower than allowed limit.</label>
707
+ <message>initialDate must be lower than allowed limit.</message>
708
+ </code_11045>
709
+ <code_11046>
710
+ <value>11046</value>
711
+ <label>initialDate must not be older than 6 months.</label>
712
+ <message>initialDate must not be older than 6 months.</message>
713
+ </code_11046>
714
+ <code_11047>
715
+ <value>11047</value>
716
+ <label>initialDate must be lower than or equal finalDate.</label>
717
+ <message>initialDate must be lower than or equal finalDate.</message>
718
+ </code_11047>
719
+ <code_11048>
720
+ <value>11048</value>
721
+ <label>search interval must be lower than or equal 30 days.</label>
722
+ <message>search interval must be lower than or equal 30 days.</message>
723
+ </code_11048>
724
+ <code_11049>
725
+ <value>11049</value>
726
+ <label>finalDate must be lower than allowed limit.</label>
727
+ <message>finalDate must be lower than allowed limit.</message>
728
+ </code_11049>
729
+ <code_11050>
730
+ <value>11050</value>
731
+ <label>initialDate invalid format, use 'yyyy-MM-ddTHH:mm' (eg. 2010-01-27T17:25).</label>
732
+ <message>initialDate invalid format, use 'yyyy-MM-ddTHH:mm' (eg. 2010-01-27T17:25).</message>
733
+ </code_11050>
734
+ <code_11051>
735
+ <value>11051</value>
736
+ <label>finalDate invalid format, use 'yyyy-MM-ddTHH:mm' (eg. 2010-01-27T17:25).</label>
737
+ <message>finalDate invalid format, use 'yyyy-MM-ddTHH:mm' (eg. 2010-01-27T17:25).</message>
738
+ </code_11051>
739
+ <code_11052>
740
+ <value>11052</value>
741
+ <label>page invalid value.</label>
742
+ <message>page invalid value.</message>
743
+ </code_11052>
744
+ <code_11053>
745
+ <value>11053</value>
746
+ <label>maxPageResults invalid value (must be between 1 and 1000).</label>
747
+ <message>maxPageResults invalid value (must be between 1 and 1000).</message>
748
+ </code_11053>
749
+ <code_11054>
750
+ <value>11054</value>
751
+ <label>abandonURL invalid length: {0}</label>
752
+ <message>abandonURL invalid length: {0}</message>
753
+ </code_11054>
754
+ <code_11055>
755
+ <value>11055</value>
756
+ <label>abandonURL invalid value: {0}</label>
757
+ <message>abandonURL invalid value: {0}</message>
758
+ </code_11055>
759
+ <code_11056>
760
+ <value>11056</value>
761
+ <label>sender address required invalid value: {0}</label>
762
+ <message>sender address required invalid value: {0}</message>
763
+ </code_11056>
764
+ <code_11057>
765
+ <value>11057</value>
766
+ <label>sender address not required with address data filled</label>
767
+ <message>sender address not required with address data filled</message>
768
+ </code_11057>
769
+ </error_codes>
770
+ </osstudios_pagseguroapi>
771
+ </default>
772
+ </config>
app/code/community/OsStudios/PagSeguroApi/etc/system.xml ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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
+ <pagseguro_api translate="label, comment">
25
+ <label>PagSeguro API</label>
26
+ <sort_order>2020</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <comment>
31
+ <![CDATA[
32
+ <a href="http://www.osstudios.com.br/" target="_blank" title="Os Studios Design - Desenvolvendo o Futuro Online!"><img style="border:none;" src="http://www.osstudios.com.br/skin/frontend/osstudios/osstudios/images/logo.png"/></a><br/><br/>
33
+ Versão do Módulo: 1.0.0.0<br/>
34
+ Desenvolvido por <b><a href="mailto:tiago.sampaio@osstudios.com.br">Tiago Sampaio</a></b><br/>
35
+ Visite o website da <a href="http://www.osstudios.com.br" target="_blank">Os Studios Design</a>.
36
+ <br/><br/>
37
+ <hr style="border:none; border-top:1px solid #ccc; border-bottom:1px solid white;" />
38
+ <br/>
39
+ A URL para Retorno Automático e Notificações API do PagSeguro que você precisa configurar é http://www.sualoja.com.br/pagseguroapi/returns/.
40
+ <br/>
41
+ A URL para o redirecionamento de retorno á loja após a conclusão do pagamento no PagSeguro é http://www.sualoja.com.br/pagseguroapi/pay/success/
42
+ <br/><br/>
43
+ <hr style="border:none; border-top:1px solid #ccc; border-bottom:1px solid white;" />
44
+ ]]>
45
+ </comment>
46
+ <fields>
47
+ <active translate="label">
48
+ <label>Enabled</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <sort_order>10</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </active>
56
+
57
+ <title translate="label">
58
+ <label>Title</label>
59
+ <frontend_type>text</frontend_type>
60
+ <sort_order>20</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </title>
65
+
66
+ <order_status translate="label">
67
+ <label>New Orders Status</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
70
+ <sort_order>30</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </order_status>
75
+
76
+ <sort_order translate="label">
77
+ <label>Sort Order</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>35</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <frontend_class>validate-number</frontend_class>
84
+ </sort_order>
85
+
86
+ <account_email translate="label">
87
+ <label>PagSeguro Account E-mail</label>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>40</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ <validate>validate-email</validate>
94
+ </account_email>
95
+
96
+ <account_token translate="label, comment">
97
+ <label>Token</label>
98
+ <frontend_type>text</frontend_type>
99
+ <sort_order>50</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ <comment>To activate automatic return from PagSeguro access your account and generate a token code and paste it here.</comment>
104
+ </account_token>
105
+
106
+ <max_uses translate="label, comment">
107
+ <label>Max Uses</label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>60</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ <comment>Defines the max times the payment code created by API call can be used. This parameter can be used as a secure control.</comment>
114
+ <validate>validate-number</validate>
115
+ </max_uses>
116
+
117
+ <max_age translate="label, comment">
118
+ <label>Max Age (Seconds)</label>
119
+ <frontend_type>text</frontend_type>
120
+ <sort_order>70</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <comment>Defines the time limit (in seconds) to use a payment code created by API call. This parameter can be used as a secure control.</comment>
125
+ <validate>validate-number</validate>
126
+ </max_age>
127
+
128
+ <extra_amount translate="label, comment">
129
+ <label>Extra Amount</label>
130
+ <frontend_type>text</frontend_type>
131
+ <sort_order>80</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ <comment>Defines an extra amount to be added or discounted from the payment. This value can be presented as an additional tax amount or a dicount in case it is negative.</comment>
136
+ <validate>validate-number</validate>
137
+ </extra_amount>
138
+
139
+ <shipping_type translate="label, comment">
140
+ <label>Shipping Method (PagSeguro)</label>
141
+ <frontend_type>select</frontend_type>
142
+ <source_model>pagseguroapi/system_config_source_shipping_type</source_model>
143
+ <sort_order>90</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ <comment>Defines the type of shipping method to be used. This information is used by PagSeguro to calculate, using Correios System, the shipping value based on the weight of the items.</comment>
148
+ </shipping_type>
149
+
150
+ <message translate="label, comment">
151
+ <label>Add Message</label>
152
+ <frontend_type>textarea</frontend_type>
153
+ <sort_order>100</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ <comment>This content is displayed when customer is choosing the payment method on checkout.</comment>
158
+ </message>
159
+
160
+ <show_installments translate="label, comment">
161
+ <label>Show Installments Simulator</label>
162
+ <frontend_type>select</frontend_type>
163
+ <source_model>adminhtml/system_config_source_yesno</source_model>
164
+ <sort_order>110</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ <comment>Activates option to show installments simulator in checkout page.</comment>
169
+ </show_installments>
170
+
171
+ <open_in_other_page translate="label, comment">
172
+ <label>Open PagSeguro in Other Page</label>
173
+ <frontend_type>select</frontend_type>
174
+ <source_model>adminhtml/system_config_source_yesno</source_model>
175
+ <sort_order>120</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ <comment>If set to true the PagSeguro page will be opened in other page and the current page will be the success page.</comment>
180
+ </open_in_other_page>
181
+
182
+ <automatically_change_orders translate="label, comment">
183
+ <label>Change Orders Automatically</label>
184
+ <frontend_type>select</frontend_type>
185
+ <source_model>adminhtml/system_config_source_yesno</source_model>
186
+ <sort_order>130</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>If set to true the orders can be changed automatically by API returns from PagSeguro.</comment>
191
+ </automatically_change_orders>
192
+
193
+ <automatically_cancel_orders translate="label, comment">
194
+ <label>Cancel Orders Automatically</label>
195
+ <frontend_type>select</frontend_type>
196
+ <source_model>adminhtml/system_config_source_yesno</source_model>
197
+ <sort_order>140</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ <comment>If set to true the order will be canceled automatically when PagSeguro cancel it.</comment>
202
+ <depends>
203
+ <automatically_change_orders>1</automatically_change_orders>
204
+ </depends>
205
+ </automatically_cancel_orders>
206
+
207
+ <automatically_invoice_orders translate="label, comment">
208
+ <label>Invoice Orders Automatically</label>
209
+ <frontend_type>select</frontend_type>
210
+ <source_model>adminhtml/system_config_source_yesno</source_model>
211
+ <sort_order>150</sort_order>
212
+ <show_in_default>1</show_in_default>
213
+ <show_in_website>1</show_in_website>
214
+ <show_in_store>1</show_in_store>
215
+ <comment>If set to true the order will be invoiced automatically when PagSeguro approve the payment.</comment>
216
+ <depends>
217
+ <automatically_change_orders>1</automatically_change_orders>
218
+ </depends>
219
+ </automatically_invoice_orders>
220
+
221
+ <automatically_hold_orders_for_billet translate="label, comment">
222
+ <label>Hold Order for Billet Payment Method</label>
223
+ <frontend_type>select</frontend_type>
224
+ <source_model>adminhtml/system_config_source_yesno</source_model>
225
+ <sort_order>160</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ <comment>If set to true the order will be held until PagSeguro approves or cancels the payment.</comment>
230
+ <depends>
231
+ <automatically_change_orders>1</automatically_change_orders>
232
+ </depends>
233
+ </automatically_hold_orders_for_billet>
234
+
235
+ <allow_log_notifications translate="label, comment">
236
+ <label>Allow Log Notifications</label>
237
+ <frontend_type>select</frontend_type>
238
+ <source_model>adminhtml/system_config_source_yesno</source_model>
239
+ <sort_order>170</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>1</show_in_store>
243
+ <comment>Allow or disallow to log transaction by notifications.</comment>
244
+ </allow_log_notifications>
245
+
246
+ <allow_log_consults translate="label, comment">
247
+ <label>Allow Log Consults</label>
248
+ <frontend_type>select</frontend_type>
249
+ <source_model>adminhtml/system_config_source_yesno</source_model>
250
+ <sort_order>180</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>Allow or disallow to log transaction by consults.</comment>
255
+ </allow_log_consults>
256
+
257
+ <allow_log_mass_consults translate="label, comment">
258
+ <label>Allow Log Mass Consults</label>
259
+ <frontend_type>select</frontend_type>
260
+ <source_model>adminhtml/system_config_source_yesno</source_model>
261
+ <sort_order>190</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>Allow or disallow to log transaction by mass consults.</comment>
266
+ </allow_log_mass_consults>
267
+
268
+ </fields>
269
+ </pagseguro_api>
270
+ </groups>
271
+ </payment>
272
+ </sections>
273
+ </config>
app/code/community/OsStudios/PagSeguroApi/sql/pagseguroapi_setup/mysql4-install-1.0.0.0.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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->run("
23
+ DROP TABLE IF EXISTS `{$this->getTable('pagseguroapi/payment_history')}`;
24
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('pagseguroapi/payment_history')}` (
25
+ `history_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
26
+ `order_id` INT(10) NOT NULL ,
27
+ `order_increment_id` INT(10) NOT NULL ,
28
+ `pagseguro_payment_identifier_code` VARCHAR(36) NULL ,
29
+ `pagseguro_transaction_id` VARCHAR(36) NULL ,
30
+ `pagseguro_transaction_date` DATETIME NULL ,
31
+ `pagseguro_transaction_status` INT NULL DEFAULT 1,
32
+ `pagseguro_transaction_fee_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
33
+ `pagseguro_payment_method_type` INT UNSIGNED NULL ,
34
+ `pagseguro_payment_method_code` INT UNSIGNED NULL ,
35
+ `pagseguro_payment_installment_count` SMALLINT(5) NULL ,
36
+ `times_redirected` INT UNSIGNED DEFAULT 0 ,
37
+ `created_at` DATETIME NULL ,
38
+ `updated_at` DATETIME NULL ,
39
+ PRIMARY KEY (`history_id`) )
40
+ ENGINE = MyISAM
41
+ DEFAULT CHARACTER SET = utf8
42
+ COLLATE = utf8_general_ci
43
+ ");
44
+
45
+ $installer->run("
46
+ DROP TABLE IF EXISTS `{$this->getTable('pagseguroapi/returns_transaction')}`;
47
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('pagseguroapi/returns_transaction')}` (
48
+ `id` INT NOT NULL AUTO_INCREMENT ,
49
+ `order_id` VARCHAR(45) NOT NULL ,
50
+ `reference` INT(10) NOT NULL ,
51
+ `code` VARCHAR(36) NOT NULL ,
52
+ `type` SMALLINT(5) NOT NULL ,
53
+ `status` SMALLINT(5) NOT NULL ,
54
+ `last_event_date` DATETIME NULL ,
55
+ `payment_method_type` SMALLINT(5) NOT NULL ,
56
+ `payment_method_code` SMALLINT(5) NOT NULL ,
57
+ `gross_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
58
+ `discount_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
59
+ `fee_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
60
+ `net_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
61
+ `extra_amount` DECIMAL(12,4) NULL DEFAULT 0 ,
62
+ `installment_count` SMALLINT(5) NULL ,
63
+ `item_count` SMALLINT(5) NULL ,
64
+ `sender_name` VARCHAR(255) NOT NULL ,
65
+ `sender_email` VARCHAR(255) NOT NULL ,
66
+ `received_from` SMALLINT(5) NULL ,
67
+ `created_at` DATETIME NULL ,
68
+ PRIMARY KEY (`id`) )
69
+ ENGINE = InnoDB
70
+ ");
71
+
72
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/osstudios/pagseguroapi.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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
+ <pagseguroapi_adminhtml_transaction_history>
22
+ <reference name="content">
23
+ <block type="pagseguroapi/adminhtml_transaction" name="pagseguroapi.returns.transaction" />
24
+ </reference>
25
+ </pagseguroapi_adminhtml_transaction_history>
26
+ <pagseguroapi_adminhtml_transaction_grid>
27
+ <block type="core/text_list" name="root" output="toHtml">
28
+ <block type="pagseguroapi/adminhtml_transaction_grid" name="pagseguroapi.returns.transaction.grid"/>
29
+ </block>
30
+ </pagseguroapi_adminhtml_transaction_grid>
31
+ <pagseguroapi_adminhtml_actions_updateorders>
32
+
33
+ </pagseguroapi_adminhtml_actions_updateorders>
34
+ </layout>
app/design/adminhtml/default/default/template/osstudios/pagseguroapi/info.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
20
+
21
+ <?php if ($this->getShowInfo()): ?>
22
+ <br/>
23
+ <ul class="pagseguro-infos">
24
+ <li><label><strong><?php echo $this->__('Transaction ID')?></strong></label></li>
25
+ <li><?php echo $this->getPagseguroInfo()->getPagseguroTransactionId() ?></li>
26
+
27
+ <li><label><strong><?php echo $this->__('Transaction Date')?></strong></label></li>
28
+ <li><?php echo Mage::getModel('core/date')->date('d/m/Y H:i:s', $this->getPagseguroInfo()->getPagseguroTransactionDate()) ?></li>
29
+
30
+ <li><label><strong><?php echo $this->__('Payment Method')?></strong></label></li>
31
+ <li>
32
+ <?php if($this->getTransactionPaymentMethodTypeLabel()):?>
33
+ <?php echo $this->__('%s (%s)', $this->getTransactionPaymentMethodTypeLabel(), $this->getTransactionPaymentMethodCodeLabel()) ?>
34
+ <?php endif;?>
35
+ </li>
36
+
37
+ <li><label><strong><?php echo $this->__('Payment Status')?></strong></label></li>
38
+ <li>
39
+ <?php if($this->isPaid()):?>
40
+ <?php echo $this->__('The payment was successfully registered in PagSeguro.') ?>
41
+ <?php else:?>
42
+ <span><?php echo $this->__('The status of the order is <b><i>%s</i></b> in PagSeguro.', $this->getTransactionStatusLabel()) ?></span><br/>
43
+ <?php if($this->getShowPayBilletUrl()):?>
44
+ <?php echo $this->__('By clicking <a href="%s" target="_blank">here</a> you can generate the billet againg for the customer.', $this->getBilletPayUrl())?>
45
+ <?php endif;?>
46
+ <?php if ($this->getShowPaylink()): ?>
47
+ <?php echo $this->__('By clicking <a href="%s" target="_blank">here</a> you can help the customer to pay his order.', $this->getPayUrl())?></p>
48
+ <?php endif; ?>
49
+ <?php endif;?>
50
+ </li>
51
+ </ul>
52
+ <br/>
53
+ <?php endif; ?>
app/design/frontend/base/default/layout/osstudios/pagseguroapi.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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
+ <pagseguroapi_pay_success translate="label" module="pagseguroapi">
22
+ <label>Transaction successfully registered in PagSeguro</label>
23
+ <reference name="root">
24
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
25
+ </reference>
26
+ <reference name="content">
27
+ <block type="pagseguroapi/api_success" name="pagseguro.success" />
28
+ </reference>
29
+ </pagseguroapi_pay_success>
30
+ <checkout_onepage_index>
31
+ <reference name="head">
32
+ <action method="addCss"><stylesheet>css/pagseguroapi/checkout.css</stylesheet></action>
33
+ </reference>
34
+ </checkout_onepage_index>
35
+ </layout>
app/design/frontend/base/default/template/osstudios/pagseguroapi/form.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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
+ <fieldset class="form-list">
19
+ <ul id="payment_form_<?php echo $this->getMethodCode(); ?>" class="pagseguroapi-payment-method" style="display:none;">
20
+ <?php if ($this->getShowMessage()): ?>
21
+ <li><?php echo $this->getMessage(); ?></li>
22
+ <?php endif; ?>
23
+ <!--<li><img src="<?php echo $this->getSkinUrl('images/pagseguroapi/logo-pagseguro.gif')?>"/></li>-->
24
+ <li><?php echo $this->getLayout()->createBlock('pagseguroapi/api_installments')->toHtml();?></li>
25
+ </ul>
26
+ </fieldset>
app/design/frontend/base/default/template/osstudios/pagseguroapi/info.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
20
+
21
+ <?php if ($this->getShowInfo()): ?>
22
+ <br/>
23
+ <ul class="pagseguro-infos">
24
+ <li><label><strong><?php echo $this->__('Transaction ID')?></strong></label></li>
25
+ <li><?php echo $this->getPagseguroInfo()->getPagseguroTransactionId() ?></li>
26
+
27
+ <li><label><strong><?php echo $this->__('Transaction Date')?></strong></label></li>
28
+ <li><?php echo Mage::getModel('core/date')->date('d/m/Y H:i:s', $this->getPagseguroInfo()->getPagseguroTransactionDate()) ?></li>
29
+
30
+ <li><label><strong><?php echo $this->__('Payment Method')?></strong></label></li>
31
+ <li>
32
+ <?php if($this->getTransactionPaymentMethodTypeLabel()):?>
33
+ <?php echo $this->__('%s (%s)', $this->getTransactionPaymentMethodTypeLabel(), $this->getTransactionPaymentMethodCodeLabel()) ?>
34
+ <?php endif;?>
35
+ </li>
36
+
37
+ <li><label><strong><?php echo $this->__('Payment Status')?></strong></label></li>
38
+ <li>
39
+ <?php if($this->isPaid()):?>
40
+ <?php echo $this->__('The payment was successfully registered in PagSeguro.') ?>
41
+ <?php else:?>
42
+ <span><?php echo $this->__('The status of the order is <b><i>%s</i></b> in PagSeguro.', $this->getTransactionStatusLabel()) ?></span><br/>
43
+ <?php if($this->getShowPayBilletUrl()):?>
44
+ <?php echo $this->__('Click <a href="%s" target="_blank">here</a> to generate your billet again.', $this->getBilletPayUrl())?>
45
+ <?php endif;?>
46
+ <?php if ($this->getShowPaylink()): ?>
47
+ <?php echo $this->__('Click <a href="%s" target="_blank">here</a> to pay your order.', $this->getPayUrl())?></p>
48
+ <?php endif; ?>
49
+ <?php endif;?>
50
+ </li>
51
+ </ul>
52
+ <br/>
53
+ <?php endif; ?>
app/design/frontend/base/default/template/osstudios/pagseguroapi/installments.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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
+ <?php
19
+ $quote = $this->getQuote();
20
+ $grandTotal = $quote->getGrandTotal();
21
+ ?>
22
+ <div class="pagseguroapi-installments">
23
+ <!--<p><?php echo $this->__('Billet')?></p>-->
24
+ <ul class="payment-method-list billet-list">
25
+ <li class="payment-item">
26
+ <a href="javascript:void(0);" class="payment-link-flag billet" title="">Boletos</a>
27
+ </li>
28
+ </ul>
29
+ <!--<p><?php echo $this->__('Online Debit')?></p>-->
30
+ <ul class="payment-method-list bank-list">
31
+ <li class="payment-item">
32
+ <a href="javascript:void(0);" class="payment-link-flag bradesco" title="">Bradesco</a>
33
+ </li>
34
+ <li class="payment-item">
35
+ <a href="javascript:void(0);" class="payment-link-flag itau" title="">Itaú</a>
36
+ </li>
37
+ <li class="payment-item">
38
+ <a href="javascript:void(0);" class="payment-link-flag hsbc" title="">HSBC</a>
39
+ </li>
40
+ <li class="payment-item">
41
+ <a href="javascript:void(0);" class="payment-link-flag bb" title="">Banco do Brasil</a>
42
+ </li>
43
+ </ul>
44
+ <!--<p><?php echo $this->__('Credit Cards')?></p>-->
45
+ <ul class="payment-method-list creditcard-list">
46
+ <?php foreach($this->getCreditCards() as $code => $attributes):?>
47
+ <?php if($attributes['active']):?>
48
+ <li class="payment-item creditcard-item <?php echo $code?>">
49
+ <a id="creditcard-<?php echo $code?>" href="javascript:void(0);" class="payment-link-flag creditcard-link-flag <?php echo $code?>" title="<?php echo $attributes['label']?>"><?php echo $attributes['label']?></a>
50
+ </li>
51
+ <?php endif;?>
52
+ <?php endforeach;?>
53
+ </ul>
54
+ <?php if($this->showInstallments()):?>
55
+ <div class="installment-table-container" style="display:block;">
56
+ <p><?php echo $this->__('Take a look at the installments simulator for credit cards.')?></p>
57
+ <table class="installment-table">
58
+ <colgroup>
59
+ <col width="150"/>
60
+ <col width="120"/>
61
+ <col width="150"/>
62
+ </colgroup>
63
+ <thead>
64
+ <th class="grandtotal"><strong><?php echo $this->__('Grand Total')?></strong></th>
65
+ <th class="qty"><strong><?php echo $this->__('Installment Qty.')?></strong></th>
66
+ <th class="totalvalue"><strong><?php echo $this->__('Final Value')?></strong></th>
67
+ </thead>
68
+ <tbody>
69
+ <?php $y = 1; ?>
70
+ <?php foreach($this->getFactors() as $key => $factor):?>
71
+ <?php
72
+ $min = (float) Mage::getStoreConfig('osstudios_pagseguroapi/transaction/installments/min');
73
+ if(!$min) {
74
+ $min = 5;
75
+ }
76
+ if(($grandTotal * $factor) < $min) {
77
+ break;
78
+ }
79
+ ?>
80
+ <tr>
81
+ <td class="grandtotal"><?php echo Mage::helper('core')->currency($grandTotal); ?></td>
82
+ <td class="qty"><?php echo $this->__('%s time(s)', $y) ?></td>
83
+ <td class="totalvalue"><?php echo Mage::helper('core')->currency($grandTotal * $factor)?></td>
84
+ </tr>
85
+ <?php $y++; ?>
86
+ <?php endforeach;?>
87
+ </tbody>
88
+ </table>
89
+ </div>
90
+ <?php endif;?>
91
+ </div>
app/design/frontend/base/default/template/osstudios/pagseguroapi/success.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Os Studios PagSeguro Api 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_PagSeguroApi
13
+ * @copyright Copyright (c) 2013 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
+ <?php
19
+
20
+ $transaction = $this->getPagseguroTransaction();
21
+
22
+ ?>
23
+ <?php if((Mage::helper('pagseguroapi')->openPagSeguroInOtherPage() && $this->getPagseguroPaymentUrl())):?>
24
+ <script type="text/javascript">
25
+ void(open('<?php echo $this->getPagseguroPaymentUrl()?>','_blank','resizable,location,menubar,toolbar,scrollbars,status'));
26
+ </script>
27
+ <?php endif;?>
28
+
29
+ <div class="page-title">
30
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
31
+ </div>
32
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
33
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
34
+
35
+ <?php if ($this->getOrderId()):?>
36
+ <?php if ($this->getCanViewOrder()) :?>
37
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
38
+ <?php else :?>
39
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
40
+ <?php endif;?>
41
+
42
+ <?php if($transaction && $transaction->getPagseguroTransactionId()): ?>
43
+ <p><?php echo $this->__('The transaction ID for your order in PagSeguro is: %s.', $transaction->getPagseguroTransactionId())?></p>
44
+ <?php endif;?>
45
+
46
+ <?php if($this->getPagseguroPaymentUrl()):?>
47
+ <p><?php echo $this->__('Click <a href="%s" target="_blank">here</a> to pay your order.', $this->getPagseguroPaymentUrl())?></p>
48
+ <?php endif;?>
49
+
50
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
51
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
52
+ <p>
53
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
54
+ <?php echo $this->getChildHtml() ?>
55
+ </p>
56
+ <?php endif;?>
57
+ <?php endif;?>
58
+
59
+ <div class="buttons-set">
60
+ <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>
61
+ </div>
app/etc/modules/OsStudios_PagSeguroApi.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Os Studios PagSeguro Api 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_PagSeguroApi
14
+ * @copyright Copyright (c) 2013 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_PagSeguroApi>
23
+ <active>true</active>
24
+ <codePool>community</codePool>
25
+ <depends>
26
+ <Mage_Payment/>
27
+ <Mage_Sales/>
28
+ </depends>
29
+ </OsStudios_PagSeguroApi>
30
+ </modules>
31
+ </config>
app/locale/pt_BR/OsStudios/PagSeguroApi.csv ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"
88
+ "Update Orders When Payment Update is Sent by PagSeguro","Atualizar Pedidos Quando Receber Atualizações do PagSeguro"
89
+ "Enable the order to be updated when receive returns from PagSeguro.","Permite que o pedido seja atualizado automaticamente quando forem recebidas atualizações de pedidos pelo PagSeguro."
90
+ "Defines the max times the payment code created by API call can be used. This parameter can be used as a secure control.","Determina o número máximo de vezes que o código de pagamento criado pela chamada à API de Pagamentos poderá ser usado. Este parâmetro pode ser usado como um controle de segurança."
91
+ "Defines the time limit (in seconds) to use a payment code created by API call. This parameter can be used as a secure control.","Determina o prazo (em segundos) durante o qual o código de pagamento criado pela chamada à API de Pagamentos poderá ser usado. Este parâmetro pode ser usado como um controle de segurança."
92
+ "Defines an extra amount to be added or discounted from the payment. This value can be presented as an additional tax amount or a dicount in case it is negative.","Especifica um valor extra que deve ser adicionado ou subtraído ao valor total do pagamento. Esse valor pode representar uma taxa extra a ser cobrada no pagamento ou um desconto a ser concedido, caso o valor seja negativo."
93
+ "Defines the type of shipping method to be used. This information is used by PagSeguro to calculate, using Correios System, the shipping value based on the weight of the items.","Informa o tipo de frete a ser usado para o envio do produto. Esta informação é usada pelo PagSeguro para calcular, junto aos Correios, o valor do frete a partir do peso dos itens."
94
+ "Max Uses","Número Máximo de Usos para o Código de Pagamento"
95
+ "Max Age (Seconds)","Prazo de Validade do Código de Pagamento (Segundos)"
96
+ "Extra Amount","Valor Adicional ou Desconto"
97
+ "Shipping Method (PagSeguro)","Método de Frete (PagSeguro)"
98
+ "Transaction ID","ID da Transação"
99
+ "Transaction Date","Data da Transação"
100
+ "Payment Method","Método de Pagamento"
101
+ "Payment Status","Status do Pagamento"
102
+ "The payment was successfully registered in PagSeguro.","O pagamento foi registrado com sucesso no PagSeguro."
103
+ "The status of the order is <b><i>%s</i></b> in PagSeguro.","O pedido está com o status <b><i>%s</i></b> no PagSeguro."
104
+ "By clicking <a href=""%s"" target=""_blank"">here</a> you can generate the billet againg for the customer.","Clicando <a href=""%s"" target=""_blank"">aqui</a> você poderá gerar o boleto novamente para o cliente."
105
+ "By clicking <a href=""%s"" target=""_blank"">here</a> you can help the customer to pay his order.","Clicando <a href=""%s"" target=""_blank"">aqui</a> você poderá ajudar o cliente a pagar seu pedido."
106
+ "Click <a href=""%s"" target=""_blank"">here</a> to generate your billet again.","Clique <a href=""%s"" target=""_blank"">aqui</a> para gerar seu boleto novamente."
107
+ "Click <a href=""%s"" target=""_blank"">here</a> to pay your order.","Clique <a href=""%s"" target=""_blank"">aqui</a> para pagar seu pedido."
108
+ "Open PagSeguro in Other Page","Abrir o PagSeguro em Outra Página"
109
+ "Change Orders Automatically","Alterar Pedidos Automaticamente"
110
+ "Cancel Orders Automatically","Cancelar Pedidos Automaticamente"
111
+ "Invoice Orders Automatically","Faturar Pedidos Automaticamente"
112
+ "Hold Order for Billet Payment Method","Congelar Pedido para Pagamentos Feitos com Boleto"
113
+ "If set to true the PagSeguro page will be opened in other page and the current page will be the success page.","Se habilitado a página do PagSeguro será aberta em outra página do navegador enquanto a loja irá para a página de sucess."
114
+ "If set to true the orders can be changed automatically by API returns from PagSeguro.","Se habilitado os pedidos poderão ser alterados automaticamente quando houver um retorno API do PagSeguro."
115
+ "If set to true the order will be canceled automatically when PagSeguro cancel it.","Se habilitado o pedido será cancelado automaticamente quando o PagSeguro cancelar o pagamento."
116
+ "If set to true the order will be invoiced automatically when PagSeguro approve the payment.","Se habilitado o pedido será faturado automaticamente quando o PagSeguro aprovar o pagamento."
117
+ "If set to true the order will be holded until PagSeguro approve or cancel the payment.","Se habilitado o pedido será congelado até que o PagSeguro aprove ou cancele o pagamento."
118
+ "PagSeguroApi: Exception occurred when trying to hold order automatically. Exception message: %s.","PagSeguroApi: Um erro ocorreu ao tentar congelar o pedido automaticamente. Mensagem de rrro: %s."
119
+ "PagSeguroApi: Order cannot be invoiced automatically.","PagSeguroApi: O pedido não pode ser faturado automaticamente."
120
+ "PagSeguroApi: Automatically invoiced by PagSeguroApi. PagSeguro confirmed the payment.","PagSeguroApi: Faturado automaticamente pelo PagSeguroApi. O PagSeguro confirmou o pagamento."
121
+ "PagSeguroApi: Exception occurred when trying to invoice order automatically. Exception message: %s.","PagSeguroApi: Um erro ocorrou ao tentar faturar o pedido automaticamente. Mensagem de erro: %s."
122
+ "PagSeguroApi: Automatically canceled by PagSeguroApi. PagSeguro has canceled the payment.","PagSeguroApi: Cancelado automaticamente pelo PagSeguroApi. O PagSeguro cancelou o pagamento."
123
+ "PagSeguroApi: The order could not be automatically canceled by PagSeguroApi. PagSeguro has canceled the payment.","PagSeguroApi: O pedido não pode ser cancelado automaticamente pelo PagSeguroApi. O PagSeguro cancelou o pagamento."
124
+ "PagSeguroApi: Exception occurred when trying to cancel order automatically. Exception message: %s.","PagSeguroApi: Um erro ocorreu ao tentar cancelar o pedido automaticamente. Mensagem de erro: %s."
125
+ "Grand Total","Total do Pedido"
126
+ "Installment Qty.","Qtd. de Parcelas"
127
+ "Final Value","Valor Final"
128
+ "%s time(s)","%s vez(es)"
129
+ "Take a look at the installments simulator for credit cards.","A tabela abaixo é o simulador de parcelamento para cartões de crédito."
130
+ "Billet","Boleto"
131
+ "Online Debit","Débito Online"
132
+ "Credit Cards","Cartões de Crédito"
133
+ "Show Installments Simulator","Mostrar Simulador de Parcelamento"
134
+ "Activates option to show installments simulator in checkout page.","Ativa a opção de mostrar o simulador de parcelamento na página de checkout."
135
+ "Configurations","Configurações"
136
+ "Transaction","Transação"
137
+ "View History","Visualizar Histórico"
138
+ "Transaction History (Consults and Notifications)","Histórico de Transações (Consultas e Notificações)"
139
+ "Actions","Ações"
140
+ "API Returns and Consults","Consultas e Retornos API"
141
+ "Reference","Referência"
142
+ "Type","Tipo"
143
+ "Payment Method Type","Método de Pagamento"
144
+ "Payment Method Code","Tipo do Método"
145
+ "Fee Amount","Taxa do PagSeguro"
146
+ "Installment Count","Qtd. Parcelas"
147
+ "Received From","Fonte da Transação"
148
+ "Last Event Date","Última Atualização"
149
+ "Created At","Criado em"
150
+ "Remove Transaction(s)","Excluir Transações"
151
+ "Consults","Consultas"
152
+ "Mass Consults","Consulta em Massa"
153
+ "Notifications","Notificações"
154
+ "Payment","Pagamento"
155
+ "%s transaction(s) was successfully removed.","%s transações foram excluídas com sucesso."
156
+ "Are you sure?","Você tem certeza?"
157
+ "%s transactions was not validated by the system.","%s transações não foram validadas pelo sistema."
158
+ "%s transactions were consulted in PagSeguro. %s successfully updated a transaction in the store.","%s transações foram consultadas no PagSeguro. %s foram atualizadas com sucesso na loja."
159
+ "Allow Log Notifications","Permitir Logs de Notificação"
160
+ "Allow Log Consults","Permitir Logs de Consultas"
161
+ "Allow Log Mass Consults","Permitir Logs de Consultas em Massa"
162
+ "Allow or disallow to log transaction by notifications.","Permite ou não logar as transações retornadas nas notificações do PagSeguro."
163
+ "Allow or disallow to log transaction by consults.","Permite ou não logar as transações retornadas nas consultas ao PagSeguro."
164
+ "Allow or disallow to log transaction by mass consults.","Permite ou não logar as transações retornadas nas consultas em massa ao PagSeguro."
package.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>OsStudios_PagSeguroApi</name>
4
+ <version>1.0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The most powerful module for PagSeguro API integration!</summary>
10
+ <description>&lt;div id="product-view-tabs-branding"&gt;&#xD;
11
+ &lt;/div&gt;&#xD;
12
+ &lt;h2&gt;PagSeguroApi by Os Studios&lt;/h2&gt;&#xD;
13
+ &lt;p&gt;&#xD;
14
+ The newest module for Magento with UOL's PagSeguro new API system integration. It's full of new features!&#xD;
15
+ With PagSeguroApi by Os Studios module you will be able to integrate your Magento Store with PagSeguro easily.&#xD;
16
+ &lt;/p&gt;&#xD;
17
+ &#xD;
18
+ &lt;p&gt;&lt;strong&gt;See below some of the new features:&lt;/strong&gt;&lt;/p&gt;&#xD;
19
+ &#xD;
20
+ &lt;p&gt;&#xD;
21
+ &lt;/p&gt;&lt;ul&gt;&#xD;
22
+ &lt;li&gt;The blank page before redirect was removed and now you are redirected directly from the checkout page&lt;/li&gt;&#xD;
23
+ &lt;li&gt;A new log panel where you can see all the notifications made by PagSeguro&lt;/li&gt;&#xD;
24
+ &lt;li&gt;Now you can consult of orders up to 30 days old&lt;/li&gt;&#xD;
25
+ &lt;li&gt;Now you don't need to configure the redirect page in PagSeguro panel: it's automatic*&lt;/li&gt;&#xD;
26
+ &lt;li&gt;You can choose if the orders will be automatically invoiced, holded or canceled by the module&lt;/li&gt;&#xD;
27
+ &lt;/ul&gt;&#xD;
28
+ &lt;p&gt;&lt;/p&gt;&#xD;
29
+ &#xD;
30
+ &lt;p&gt;And so much more! Take a look!&lt;/p&gt;&#xD;
31
+ &#xD;
32
+ * It's necessary to setup PagSeguro to accept only API transactions in PagSeguro customer panel.&#xD;
33
+ &#xD;
34
+ &lt;hr&gt;&#xD;
35
+ &#xD;
36
+ &lt;p&gt;&#xD;
37
+ O novo m&#xF3;dulo para integra&#xE7;&#xE3;o do Magento com a API do PagSeguro est&#xE1; cheio de novidades!&#xD;
38
+ Com o PagSeguroApi by Os Studios voc&#xEA; ser&#xE1; capaz de integrar sua loja em Magento com o PagSeguro de uma forma muito mais pr&#xE1;tica e f&#xE1;cil.&#xD;
39
+ &lt;/p&gt;&#xD;
40
+ &#xD;
41
+ &lt;p&gt;&lt;strong&gt;Veja abaixo algumas das novidades:&lt;/strong&gt;&lt;/p&gt;&#xD;
42
+ &#xD;
43
+ &lt;p&gt;&#xD;
44
+ &lt;/p&gt;&lt;ul&gt;&#xD;
45
+ &lt;li&gt;Remo&#xE7;&#xE3;o da p&#xE1;gina intermedi&#xE1;rio com a mensagem "Voc&#xEA; ser&#xE1; redirecionado ao site do PagSeguro"&lt;/li&gt;&#xD;
46
+ &lt;li&gt;Voc&#xEA; ter&#xE1; um painel administrativo de log aonde poder&#xE1; ver todas as consultas feitas e notifica&#xE7;&#xF5;es enviadas pelo PagSeguro&lt;/li&gt;&#xD;
47
+ &lt;li&gt;Voc&#xEA; poder&#xE1; fazer a consulta dos pedidos de at&#xE9; 30 dias anterioes&lt;/li&gt;&#xD;
48
+ &lt;li&gt;N&#xE3;o &#xE9; necess&#xE1;rio configurar a p&#xE1;gina de redirecionamento no painel do PagSeguro, pois foi implementada uma p&#xE1;gina de redirecionamento din&#xE2;mica*&lt;/li&gt;&#xD;
49
+ &lt;li&gt;Agora voc&#xEA; escolhe se os pedidos ser&#xE3;o faturados, congelados ou cancelados automaticamente pelo m&#xF3;dulo&lt;/li&gt;&#xD;
50
+ &lt;/ul&gt;&#xD;
51
+ &lt;p&gt;&lt;/p&gt;&#xD;
52
+ &#xD;
53
+ &lt;p&gt;E muito mais! Confira!&lt;/p&gt;&#xD;
54
+ &#xD;
55
+ * &#xC9; necess&#xE1;rio configurar o PagSeguro para aceitar apenas transa&#xE7;&#xF5;es via API.</description>
56
+ <notes>Fixed Bugs&#xD;
57
+ &#xD;
58
+ - Corrected translations</notes>
59
+ <authors><author><name>Tiago Sampaio</name><user>tiagosampaio</user><email>tiago.sampaio@osstudios.com.br</email></author></authors>
60
+ <date>2013-05-04</date>
61
+ <time>21:53:27</time>
62
+ <contents><target name="magecommunity"><dir name="OsStudios"><dir name="PagSeguroApi"><dir name="Block"><dir name="Adminhtml"><dir name="Transaction"><file name="Grid.php" hash="a438969228b818ce32ff5d823d86a961"/></dir><file name="Transaction.php" hash="f55424b92529ff2b8c1b01d40c736288"/></dir><dir name="Api"><file name="Form.php" hash="a9f4868afa280d3b65405d5ad1652643"/><file name="Info.php" hash="18e5f655fe1dbd757cae6352cf98fdc1"/><file name="Installments.php" hash="9f4c1952f3e1b0b6f4c17472b3f15169"/><file name="Success.php" hash="5db8d1091ade7123af4acdb947dc9d23"/></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="Action.php" hash="89d2d0198afcc5fa8de2719cfbfa9494"/></dir><dir name="Front"><file name="Action.php" hash="dbcc3d9d1244b1128f61dedb38021ace"/></dir></dir><dir name="Helper"><file name="Data.php" hash="63f2320f4c7aebd375dd99f2e9666e86"/><file name="Visie.php" hash="824cf37c63d0fc497b25ad96e0cd0994"/></dir><dir name="Model"><file name="Abstract.php" hash="a5aef6993a8e16c5dd88d955906b0b8b"/><file name="Consulter.php" hash="5c25ff86326446ad4857046448900787"/><file name="Credentials.php" hash="59bceca387245280be81517bfb634cec"/><file name="Data.php" hash="4f139eab7c0e42710c3332db14ff0b35"/><dir name="Mysql4"><dir name="Payment"><dir name="History"><file name="Collection.php" hash="11c8648fcdc754a044b34a323120af85"/></dir><file name="History.php" hash="0618029aba8b7fe0f87aebf0600799c5"/></dir><dir name="Returns"><dir name="Transaction"><file name="Collection.php" hash="8c300445dc4f8c561e597ee9b1763ac0"/></dir><file name="Transaction.php" hash="a5b57527e2fd1a437e025ff206fabc70"/></dir></dir><file name="Observer.php" hash="eeba7d441f7d4f0ae0fc499db98dc3bf"/><dir name="Payment"><file name="History.php" hash="7112c8650830a337ac91718dfe3e6349"/><dir name="Method"><dir name="Api"><file name="Xml.php" hash="d33f502e4aadf0195b177b9dedd05690"/></dir><file name="Api.php" hash="89f6d3a2a1d91f5af1e4da007fbe344c"/></dir></dir><file name="Payment.php" hash="101fb3cd591c070b89aaa243a3cfc153"/><dir name="Resource"><dir name="Payment"><dir name="History"><file name="Collection.php" hash="329bcc58751e14b640e3d1b8c727a994"/></dir><file name="History.php" hash="0c8f78f4c21bd8e9621041ca0ccadfb0"/></dir><dir name="Returns"><dir name="Transaction"><file name="Collection.php" hash="2567d3b30cc3860f3e93bbaa5e62096d"/></dir><file name="Transaction.php" hash="456db82eb7cc61aa6eb9e856ca5f18e2"/></dir></dir><dir name="Returns"><file name="Transaction.php" hash="e02492a4d9c61c1f72b96fb2c3029bdb"/></dir><file name="Returns.php" hash="04a106a3966dced44e8e5a8eb921217c"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Config.php" hash="63aa7dd2805cd1fe3f19aa4ccd1b8602"/><dir name="Error"><file name="Codes.php" hash="ad905374b5e9ad09e7793dab32dbb3e5"/></dir><dir name="Shipping"><file name="Type.php" hash="5699c4a2973f0e33a8effb1239a77492"/></dir><dir name="Transaction"><dir name="Payment"><dir name="Methods"><file name="Codes.php" hash="d863e2f9772de9959b3ce785df36e8d2"/><file name="Types.php" hash="2137324a473da7267c03c67432e6641d"/></dir></dir><file name="Sources.php" hash="db0c9497894d84dc5cd6620a78e88acf"/><file name="Status.php" hash="3f7263f546087f190a07afb0d5002cef"/><file name="Types.php" hash="0f78fc633fb95f62795a85f91f605956"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ActionsController.php" hash="4c70b0afbf6d9f0ca32dfeef74935ec9"/><file name="TransactionController.php" hash="be83d9d5c5451f82957eecee62b2c0bf"/></dir><file name="PayController.php" hash="0cbc73ee29cb2e06d2409086e028d0e8"/><file name="ReturnsController.php" hash="3cdfa76198965181c9b42be89cd7c5aa"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6b602630e00354a545d81625f42d5c1d"/><file name="config.xml" hash="24eeef14584720550b13a2ca41876dc5"/><file name="system.xml" hash="e597ab280a0f28550bb14d4bad5147bb"/></dir><dir name="sql"><dir name="pagseguroapi_setup"><file name="mysql4-install-1.0.0.0.php" hash="4cdb7970ccbaee3f3c8832b468f815c7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OsStudios_PagSeguroApi.xml" hash="b002e963d42cdabbc0221b9cd688e138"/></dir></target><target name="magelocale"><dir name="pt_BR"><dir name="OsStudios"><file name="PagSeguroApi.csv" hash="83679c0fa1293d1a778efc934c84ce76"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="osstudios"><file name="pagseguroapi.xml" hash="2b6dcd4e87a39e9c35bfa12e38746dfb"/></dir></dir><dir name="template"><dir name="osstudios"><dir name="pagseguroapi"><file name="info.phtml" hash="b2f9f7797631edb32cb09be38dadfbb9"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="osstudios"><file name="pagseguroapi.xml" hash="2ad1a01422f3be4a86eb1fe136177d1b"/></dir></dir><dir name="template"><dir name="osstudios"><dir name="pagseguroapi"><file name="form.phtml" hash="05188cb5f3186d4eba7a1bd92f722762"/><file name="info.phtml" hash="3e1c34b8612fda60243ebf217d726338"/><file name="installments.phtml" hash="4b5b338c3bd3b7e83f2197176bbb8010"/><file name="success.phtml" hash="71d20b8543253c9a19cc2dc98024f0af"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="pagseguroapi"><file name="checkout.css" hash="43c548dbb2e93f06dcd8dd18c0a01868"/></dir></dir><dir name="images"><dir name="pagseguroapi"><file name="cards-sprite.gif" hash="f2f7adf6e43729bcd2f40ed63d14a384"/><file name="logo-pagseguro.gif" hash="60ac1276c27b4b400e1f15c42cc8b2ed"/></dir></dir></dir></dir></dir></target></contents>
63
+ <compatible/>
64
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
65
+ </package>
skin/frontend/base/default/css/pagseguroapi/checkout.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .pagseguroapi-installments { overflow:auto; }
2
+
3
+ .pagseguroapi-installments .payment-method-list { display:block; overflow:auto; margin-bottom:15px; }
4
+ .pagseguroapi-installments .payment-method-list .payment-item { float:left; border:none; margin:2px; }
5
+ .pagseguroapi-installments .payment-method-list .payment-item a.payment-link-flag { display:block; text-indent:-99999px; width:71px; height:28px; background:url('../../images/pagseguroapi/cards-sprite.gif') no-repeat white; border:none; }
6
+
7
+ .pagseguroapi-installments .payment-method-list .payment-item a.visa { background-position:0 0; }
8
+ .pagseguroapi-installments .payment-method-list .payment-item a.mastercard { background-position:0 -28px; }
9
+ .pagseguroapi-installments .payment-method-list .payment-item a.diners { background-position:0 -56px; }
10
+ .pagseguroapi-installments .payment-method-list .payment-item a.amex { background-position:0 -84px; }
11
+ .pagseguroapi-installments .payment-method-list .payment-item a.hipercard { background-position:0 -112px; }
12
+ .pagseguroapi-installments .payment-method-list .payment-item a.aura { background-position:0 -140px; }
13
+ .pagseguroapi-installments .payment-method-list .payment-item a.elo { background-position:0 -476px; }
14
+ .pagseguroapi-installments .payment-method-list .payment-item a.plenocard { background-position:0 -504px; }
15
+ .pagseguroapi-installments .payment-method-list .payment-item a.personalcard { background-position:0 -532px; }
16
+ .pagseguroapi-installments .payment-method-list .payment-item a.brasilcard { background-position:0 -560px; }
17
+ .pagseguroapi-installments .payment-method-list .payment-item a.jcb { background-position:0 -588px; }
18
+ .pagseguroapi-installments .payment-method-list .payment-item a.discover { background-position:0 -616px; }
19
+ .pagseguroapi-installments .payment-method-list .payment-item a.fortbrasil { background-position:0 -644px; }
20
+ .pagseguroapi-installments .payment-method-list .payment-item a.cardban { background-position:0 -672px; }
21
+ .pagseguroapi-installments .payment-method-list .payment-item a.valecard { background-position:0 -700px; }
22
+ .pagseguroapi-installments .payment-method-list .payment-item a.cabal { background-position:0 -728px; }
23
+
24
+ .pagseguroapi-installments .payment-method-list .payment-item a.billet { background-position:0 -308px; }
25
+
26
+ .pagseguroapi-installments .payment-method-list .payment-item a.bradesco { background-position:0 -168px; }
27
+ .pagseguroapi-installments .payment-method-list .payment-item a.itau { background-position:0 -196px; }
28
+ .pagseguroapi-installments .payment-method-list .payment-item a.hsbc { background-position:0 -224px; }
29
+ .pagseguroapi-installments .payment-method-list .payment-item a.bb { background-position:0 -252px; }
30
+
31
+ .pagseguroapi-installments .installment-table { border:solid 1px #ccc; }
32
+ .pagseguroapi-installments .installment-table th,
33
+ .pagseguroapi-installments .installment-table td { padding:2px 5px; border-bottom:solid 1px #efefef; }
34
+
35
+ .pagseguroapi-installments .installment-table th { color:#5E8AB4; background-color:#D0DCE1; }
36
+
37
+
38
+ .pagseguroapi-installments .installment-table .grandtotal,
39
+ .pagseguroapi-installments .installment-table .totalvalue { text-align:right; }
40
+ .pagseguroapi-installments .installment-table .qty { text-align:center; }
skin/frontend/base/default/images/pagseguroapi/cards-sprite.gif ADDED
Binary file
skin/frontend/base/default/images/pagseguroapi/logo-pagseguro.gif ADDED
Binary file