Pagantis_Pagantis - Version 2.2.6

Version Notes

Fix http 302 error on notifications when magento have SSL configured in frontend

Download this release

Release Info

Developer Magento Core Team
Extension Pagantis_Pagantis
Version 2.2.6
Comparing to
See all releases


Code changes from version 2.2.1 to 2.2.6

Files changed (23) hide show
  1. app/code/community/Pagantis/Pagantis/Model/Webservice/Request.php +5 -1
  2. app/code/community/Pagantis/Pagantis/Model/Webservice/Requestloan.php +18 -2
  3. app/code/community/Pagantis/Pagantis/Pagantis/Block/Adminhtml/System/Config/Fieldset/Payment.php +0 -27
  4. app/code/community/Pagantis/Pagantis/Pagantis/Block/Form.php +0 -74
  5. app/code/community/Pagantis/Pagantis/Pagantis/Block/Redirect.php +0 -36
  6. app/code/community/Pagantis/Pagantis/Pagantis/Helper/Data.php +0 -237
  7. app/code/community/Pagantis/Pagantis/Pagantis/Model/Currency.php +0 -17
  8. app/code/community/Pagantis/Pagantis/Pagantis/Model/Observer.php +0 -145
  9. app/code/community/Pagantis/Pagantis/Pagantis/Model/Payment.php +0 -113
  10. app/code/community/Pagantis/Pagantis/Pagantis/Model/Source/Payment/Currency.php +0 -49
  11. app/code/community/Pagantis/Pagantis/Pagantis/Model/Source/Payment/Environment.php +0 -48
  12. app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Client.php +0 -116
  13. app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Paymentrequest.php +0 -76
  14. app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Request.php +0 -353
  15. app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Requestloan.php +0 -422
  16. app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Response.php +0 -15
  17. app/code/community/Pagantis/Pagantis/Pagantis/controllers/PagantisController.php +0 -181
  18. app/code/community/Pagantis/Pagantis/Pagantis/etc/config.xml +0 -132
  19. app/code/community/Pagantis/Pagantis/Pagantis/etc/system.xml +0 -212
  20. app/code/community/Pagantis/Pagantis/Pagantis/sql/pagantis_setup/mysql4-install-1.0.0.php +0 -7
  21. app/code/community/Pagantis/Pagantis/controllers/PagantisController.php +13 -4
  22. app/code/community/Pagantis/Pagantis/etc/system.xml +14 -14
  23. package.xml +5 -5
app/code/community/Pagantis/Pagantis/Model/Webservice/Request.php CHANGED
@@ -270,7 +270,11 @@ class Pagantis_Pagantis_Model_Webservice_Request
270
  */
271
  public function setCacllbackUrl()
272
  {
273
- $this->_callback_url=Mage::getBaseUrl()."/pagantis/pagantis/notification";
 
 
 
 
274
  }
275
 
276
  /**
270
  */
271
  public function setCacllbackUrl()
272
  {
273
+ if (Mage::app()->getStore()->isFrontUrlSecure()){
274
+ $this->_callback_url=Mage::getUrl('',array('_forced_secure'=>true))."pagantis/pagantis/notification";
275
+ }else{
276
+ $this->_callback_url=Mage::getUrl('',array('_forced_secure'=>false))."pagantis/pagantis/notification";
277
+ }
278
  }
279
 
280
  /**
app/code/community/Pagantis/Pagantis/Model/Webservice/Requestloan.php CHANGED
@@ -207,8 +207,10 @@ class Pagantis_Pagantis_Model_Webservice_Requestloan
207
  if ($addressId) {
208
  $address = Mage::getModel('sales/order_address')->load($addressId);
209
  $street = $address->getStreet();
210
- if ($street){
211
  $this->_userData['street'] = $street[0];
 
 
212
  }
213
  $this->_userData['city'] = $address->getCity();
214
  $this->_userData['province'] = $address->getCity();
@@ -220,6 +222,16 @@ class Pagantis_Pagantis_Model_Webservice_Requestloan
220
  } else {
221
  throw new \Exception('Missing user data info');
222
  }
 
 
 
 
 
 
 
 
 
 
223
  }
224
 
225
  /**
@@ -334,7 +346,11 @@ class Pagantis_Pagantis_Model_Webservice_Requestloan
334
  */
335
  public function setCacllbackUrl()
336
  {
337
- $this->_callback_url=Mage::getBaseUrl()."/pagantis/pagantis/notification";
 
 
 
 
338
  }
339
 
340
 
207
  if ($addressId) {
208
  $address = Mage::getModel('sales/order_address')->load($addressId);
209
  $street = $address->getStreet();
210
+ if (is_array($street)){
211
  $this->_userData['street'] = $street[0];
212
+ }else{
213
+ $this->_userData['street'] = $street;
214
  }
215
  $this->_userData['city'] = $address->getCity();
216
  $this->_userData['province'] = $address->getCity();
222
  } else {
223
  throw new \Exception('Missing user data info');
224
  }
225
+
226
+ //fix to avoid empty fields
227
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
228
+ if (empty($this->_userData['email'])){
229
+ $this->_userData['email'] = $customer->getEmail();
230
+ }
231
+ if (empty($this->_userData['full_name'])){
232
+ $this->_userData['full_name'] = $customer->getFirstname() . ' ' . $customer->getLastname();
233
+ }
234
+
235
  }
236
 
237
  /**
346
  */
347
  public function setCacllbackUrl()
348
  {
349
+ if (Mage::app()->getStore()->isFrontUrlSecure()){
350
+ $this->_callback_url=Mage::getUrl('',array('_forced_secure'=>true))."pagantis/pagantis/notification";
351
+ }else{
352
+ $this->_callback_url=Mage::getUrl('',array('_forced_secure'=>false))."pagantis/pagantis/notification";
353
+ }
354
  }
355
 
356
 
app/code/community/Pagantis/Pagantis/Pagantis/Block/Adminhtml/System/Config/Fieldset/Payment.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Pagantis_Pagantis payment form
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Block_Adminhtml_System_Config_Fieldset_Payment
12
- extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
13
- {
14
-
15
- /**
16
- * Return header comment part of html for payment solution
17
- *
18
- * @param Varien_Data_Form_Element_Abstract $element
19
- * @return string
20
- */
21
- protected function _getHeaderCommentHtml($element)
22
- {
23
- return '<div class="adminLogoPagantis"></div>';
24
- }
25
-
26
-
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Block/Form.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Pagantis_Pagantis payment form
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Block_Form extends Mage_Payment_Block_Form
12
- {
13
-
14
- protected function _construct()
15
- {
16
-
17
- $title="Financiación:";
18
- $session = Mage::getSingleton('checkout/session');
19
- $mark = Mage::getConfig()->getBlockClassName('core/template');
20
- $mark = new $mark;
21
- $quote = Mage::getModel('checkout/session')->getQuote();
22
- $quoteData= $quote->getData();
23
- $amount=$quoteData['grand_total'];
24
- $config = Mage::getStoreConfig('payment/pagantis');
25
- $discount = $config['discount'];
26
- if ($discount == 'true'){
27
- $mark->setData('discount',1);
28
- }else{
29
- $mark->setData('discount',0);
30
- }
31
- $mark->setData('inst2',$this->instAmount(2));
32
- $mark->setData('inst3',$this->instAmount(3));
33
- $mark->setData('inst4',$this->instAmount(4));
34
- $mark->setData('inst5',$this->instAmount(5));
35
- $mark->setData('inst6',$this->instAmount(6));
36
- $mark->setData('total',$amount);
37
- $mark->setTemplate('pagantis/form.phtml');
38
- $this->setTemplate('pagantis/pagantis.phtml')
39
- ->setMethodLabelAfterHtml($mark->toHtml())
40
- ->setMethodTitle($title)
41
-
42
- ;
43
- return parent::_construct();
44
- }
45
-
46
- /*
47
- * function instAmount
48
- * calculate the price of the installment
49
- * param $amount : amount in cents of the total loan
50
- * param $num_installments: number of installments, integer
51
- * return float with amount of the installment
52
- */
53
- protected function instAmount ($num_installments) {
54
- $quote = Mage::getModel('checkout/session')->getQuote();
55
- $quoteData= $quote->getData();
56
- $amount=$quoteData['grand_total']*100;
57
- $config = Mage::getStoreConfig('payment/pagantis');
58
- $discount = $config['discount'];
59
- if ( $discount ){
60
- $result= ($amount/100) / $num_installments;
61
- }else{
62
- $r = 0.25/365; #daily int
63
- $X = $amount/100; #total loan
64
- $aux = 1; #first inst value
65
- for ($i=0; $i<= $num_installments-2;$i++) {
66
- $aux = $aux + pow(1/(1+$r) ,(45+30*$i));
67
- }
68
- $result= (float)($X/$aux);
69
- }
70
- //add result to template
71
- return $result;
72
- }
73
-
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Block/Redirect.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Pagantis_Pagantis payment form
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Block_Redirect extends Mage_Core_Block_Template
12
- {
13
-
14
- protected function _construct()
15
- {
16
- parent::_construct();
17
- $helperPagantis = Mage::helper('pagantis_pagantis');
18
- $urlPagantis = $helperPagantis->getUrlPagantis();
19
- $paymentMethod = Mage::getModel('pagantis_pagantis/payment');
20
- $form = new Varien_Data_Form();
21
-
22
-
23
- $form->setAction($urlPagantis)
24
- ->setId('pagantis_pagantis_checkout')
25
- ->setLabel('Pagantis')
26
- ->setMethod('POST')
27
- ->setUseContainer(true);
28
-
29
- foreach ($paymentMethod->getFormFields() as $field => $value) {
30
- $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
31
- }
32
- $form->addField('submitButton', 'submit', array('name' => 'submitButton', 'value' => 'Continue'));
33
- $this->setFormRedirect($form->toHtml());
34
- }
35
-
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Helper/Data.php DELETED
@@ -1,237 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Pagantis_Pagantis Helper
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Helper_Data extends Mage_Core_Helper_Abstract
12
- {
13
-
14
- private $languages = array(
15
- 'es_ES' => 'es',
16
- 'en_US' => 'en',
17
- 'en_UK' => 'en',
18
- 'ca_ES' => 'ca',
19
- 'eu_ES' => 'es',
20
- 'gl_ES' => 'es',
21
- 'fr_FR' => 'fr',
22
- 'it_IT' => 'it',
23
- 'ru_RU' => 'ru'
24
- );
25
-
26
- public function __construct()
27
- {
28
- $this->_config = Mage::getStoreConfig('payment/pagantis');
29
- }
30
-
31
- /**
32
- * Restore last active quote based on checkout session
33
- *
34
- * @return bool True if quote restored successfully, false otherwise
35
- */
36
- public function restoreQuote()
37
- {
38
- $lastOrderId = $this->_getCheckoutSession()->getLastRealOrderId();
39
- if ($lastOrderId) {
40
- $order = Mage::getModel('sales/order')->loadByIncrementId($lastOrderId);
41
- if ($order->getId()) {
42
- $quote = $this->_getQuote($order->getQuoteId());
43
- if ($quote->getId()) {
44
- $quote->setIsActive(1)
45
- ->setReservedOrderId(null)
46
- ->save();
47
- $this->_getCheckoutSession()
48
- ->replaceQuote($quote)
49
- ->unsLastRealOrderId();
50
- return true;
51
- }
52
- }
53
- }
54
- return false;
55
- }
56
-
57
- /**
58
- * Return checkout session instance
59
- *
60
- * @return Mage_Checkout_Model_Session
61
- */
62
- protected function _getCheckoutSession()
63
- {
64
- return Mage::getSingleton('checkout/session');
65
- }
66
-
67
- /**
68
- * Return sales quote instance for specified ID
69
- *
70
- * @param int $quoteId Quote identifier
71
- * @return Mage_Sales_Model_Quote
72
- */
73
- protected function _getQuote($quoteId)
74
- {
75
- return Mage::getModel('sales/quote')->load($quoteId);
76
- }
77
-
78
-
79
- /**
80
- * Returns a Request object with common parameters
81
- * @todo Retrieve language, currency based on config
82
- * @param float $amount
83
- * @param string $orderId
84
- * @param string $localeCode TBD
85
- * @return Pagantis_Pagantis_Model_Webservice_Request
86
- */
87
- public function getRequest($amount, $orderId, $localeCode)
88
- {
89
- $language = $this->getConsumerLanguage($localeCode);
90
- $request = Mage::getModel('pagantis_pagantis/webservice_request');
91
- $request->setAmount($amount);
92
- $request->setLanguagePagantis($language);
93
- $request->setUrlPagantis($this->_config['url_pagantis']);
94
- $request->setAuthMethod($this->_config['auth_method']);
95
- $request->setOrderId($orderId);
96
- $request->setAmount($amount);
97
- $request->setDiscount($this->_config['discount']);
98
- switch($this->_config['environment']) {
99
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING:
100
- $request->setAccountCode($this->_config['account_code_test']);
101
- $request->setAccountKey($this->_config['account_key_test']);
102
- //$request->setAccountApiKey($this->_config['account_api_key_test']);
103
- break;
104
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION:
105
- $request->setAccountCode($this->_config['account_code_real']);
106
- $request->setAccountKey($this->_config['account_key_real']);
107
- //$request->setAccountApiKey($this->_config['account_api_key_real']);
108
- break;
109
- }
110
- $request->setUrlOk();
111
- $request->setUrlKo();
112
- $request->setCacllbackUrl();
113
- $request->setFirma();
114
- return $request;
115
- }
116
-
117
- /**
118
- * Returns a Request object with common parameters
119
- * @todo Retrieve language, currency based on config
120
- * @param float $amount
121
- * @param string $orderId
122
- * @param string $localeCode TBD
123
- * @return Pagantis_Pagantis_Model_Webservice_Request
124
- */
125
- public function getRequestloan($amount, $orderId, $localeCode)
126
- {
127
- $language = $this->getConsumerLanguage($localeCode);
128
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
129
- $addressId = $order->getShippingAddress()->getId();
130
-
131
-
132
- $request = Mage::getModel('pagantis_pagantis/webservice_requestloan');
133
- $request->setOrderId($orderId);
134
- $request->setAmount($amount);
135
- $request->setLanguagePagantis($language);
136
- //$request->setUrlPagantis($this->_config['url_pagantis_mastarde']);
137
- $request->setUrlPagantis (Pagantis_Pagantis_Model_Payment::PMT_URL);
138
- $request->setUserData($addressId);
139
- $request->setOrderItems($orderId);
140
- $request->setAmount($amount);
141
- $request->setDiscount($this->_config['discount']);
142
- switch($this->_config['environment']) {
143
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING:
144
- $request->setAccountCode($this->_config['account_code_test']);
145
- $request->setAccountKey($this->_config['account_key_test']);
146
- break;
147
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION:
148
- $request->setAccountCode($this->_config['account_code_real']);
149
- $request->setAccountKey($this->_config['account_key_real']);
150
- break;
151
- }
152
- $request->setUrlOk();
153
- $request->setUrlKo();
154
- $request->setCacllbackUrl();
155
- $request->setFirma();
156
-
157
- return $request;
158
- }
159
-
160
- /**
161
- * Returns a Request object with common parameters
162
- * @todo Retrieve language, currency based on config
163
- * @param float $amount
164
- * @param string $orderId
165
- * @param string $localeCode TBD
166
- * @return Pagantis_Pagantis_Model_Webservice_Request
167
- */
168
- public function getTransactionInfo($transaction)
169
- {
170
- $paymentRequest = Mage::getModel('pagantis_pagantis/webservice_paymentrequest');
171
- switch($this->_config['environment']) {
172
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING:
173
- $paymentRequest->setBearer($this->_config['account_api_key_test']);
174
- break;
175
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION:
176
- $paymentRequest->setBearer($this->_config['account_api_key_real']);
177
- break;
178
- }
179
- $paymentRequest->setTransaction($transaction);
180
- $client = Mage::getModel('pagantis_pagantis/webservice_client');
181
- $result = $client->getCurlResultPaymentRequest($paymentRequest);
182
- return $result;
183
- }
184
-
185
-
186
- public function getUrlPagantis() {
187
-
188
- return Pagantis_Pagantis_Model_Payment::PMT_URL;
189
- //allways same url, no need to make this check
190
- /*
191
- $paymentDetails = $this->_getCheckoutSession()->getPaymentMethodDetail();
192
- switch($paymentDetails) {
193
- case Pagantis_Pagantis_Model_Payment::PAYMENT_UNIQUE:
194
- return $this->_config['url_pagantis'];
195
- break;
196
- case Pagantis_Pagantis_Model_Payment::PAYMENT_LOAN:
197
- return $this->_config['url_pagantis_mastarde'];
198
- break;
199
- }
200
- */
201
- }
202
-
203
- /**
204
- * Returns a string with the corresponding CECA consumer language, given a ISO locale code
205
- * Eg. es_ES
206
- *
207
- * @param $localeCode
208
- * @return mixed
209
- */
210
- private function getConsumerLanguage($localeCode)
211
- {
212
- return $this->languages[$localeCode];
213
- }
214
-
215
- /**
216
- * @param $states
217
- * @param $statuses
218
- * @return mixed
219
- */
220
- public function getOrdersToExport($states)
221
- {
222
- $methodPayment = $this->_config['title'];
223
-
224
- $pendingProcessingOrdersPagantis = Mage::getModel('sales/order')
225
- ->getCollection()
226
- ->join(
227
- array('payment' => 'sales/order_payment'),
228
- 'main_table.entity_id=payment.parent_id',
229
- array('payment_method' => 'payment.method')
230
- );
231
- $pendingProcessingOrdersPagantis->addFieldToFilter('payment.method',array('like'=>$methodPayment))
232
- ->addFieldToFilter('state',array('in'=>$states));
233
-
234
- return $pendingProcessingOrdersPagantis;
235
- }
236
-
237
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Currency.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Pagantis_Pagantis
5
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
6
- * @author Yameveo <yameveo@yameveo.com>
7
- * @link http://www.yameveo.com
8
- */
9
-
10
- class Pagantis_Pagantis_Model_Currency
11
- {
12
-
13
- const EUR = 'EUR';
14
- const USD = 'USD';
15
- const GBP = 'GBP';
16
-
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Observer.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Observer for cron jobs
5
- *
6
- * @package Pagantis_Pagantis
7
- * @author Yameveo <support@yameveo.com>
8
- * @link http://www.yameveo.com
9
- */
10
- class Pagantis_Pagantis_Model_Observer
11
- {
12
-
13
- const PAGANTIS_TR_ERROR = 'Error';
14
-
15
-
16
- public function exportOrders()
17
- {
18
- $start = $this->chrono();
19
- $startGetCollection = $this->chrono();
20
-
21
- $orders = Mage::helper('pagantis_pagantis')->getOrdersToExport(array(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT));//,Mage_Sales_Model_Order::STATE_PROCESSING));//, array(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,Mage_Sales_Model_Order::STATE_PROCESSING));
22
-
23
- $endGetCollection = $this->chrono();
24
- $chronoCollection = round($endGetCollection - $startGetCollection, 3);
25
- Mage::log("Loading orders collection executed in $chronoCollection seconds.", Zend_Log::DEBUG, $this->_logFile);
26
- $ordersCount = $orders->count();
27
- Mage::log("Exporting $ordersCount orders", Zend_Log::DEBUG, $this->_logFile);
28
-
29
- $count = 1;
30
- $result = array();
31
- $orderCanceled = 0;
32
- $orderProcessing = 0;
33
- foreach ($orders as $order) {
34
- $transaction = $order->getPagantisTransaction();
35
- if ($transaction) {
36
- $paymentRequestResult = Mage::helper('pagantis_pagantis')->getTransactionInfo($transaction);
37
- if (!$paymentRequestResult['paid']) {
38
- $order->setState(Mage_Sales_Model_Order::STATE_CANCELED,true);
39
- $order->save();
40
- $orderCanceled++;
41
- } else {
42
- // @todo move this try in helper
43
- try {
44
- $sendMail = (int) Mage::getStoreConfig('payment/pagantis/sendmail');
45
- $createInvoice = (int) Mage::getStoreConfig('payment/pagantis/invoice');
46
- if ($order->getId()) {
47
- //if ($response->isDsValid()) {
48
- $orderStatus = Mage_Sales_Model_Order::STATE_PROCESSING;
49
- if ($order->canInvoice() && $createInvoice) {
50
- $invoice = $this->_createInvoice($order);
51
- $comment = Mage::helper('pagantis_pagantis')->__('Authorized transaction. Created invoice %s', $invoice->getIncrementId());
52
- } else {
53
- $comment = Mage::helper('pagantis_pagantis')->__('Authorized transaction, but invoice not created');
54
- }
55
- $order->setState($orderStatus, $orderStatus, $comment, true);
56
- $order->save();
57
- if ($sendMail) {
58
- if ($orderStatus == Mage_Sales_Model_Order::STATE_PROCESSING) {
59
- $order->sendNewOrderEmail();
60
- } else {
61
- $order->sendOrderUpdateEmail(true);
62
- }
63
- }
64
- }
65
- $orderProcessing++;
66
- } catch (Exception $e) {
67
- Mage::logException($e);
68
- }
69
- }
70
- }
71
- }
72
- return "Updated " . $orderCanceled . " orders in steta Canceled and " . $orderProcessing . " orders in Processing";
73
- }
74
-
75
- /**
76
- * Create an invoice for the order and send an email
77
- * @todo move to helper
78
- * @param Mage_Sales_Model_Order $order
79
- * @return Mage_Sales_Model_Order_Invoice
80
- */
81
- private function _createInvoice($order)
82
- {
83
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
84
- if (!$invoice->getTotalQty()) {
85
- Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
86
- }
87
-
88
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
89
- $invoice->register();
90
- $transactionSave = Mage::getModel('core/resource_transaction')
91
- ->addObject($invoice)
92
- ->addObject($invoice->getOrder());
93
-
94
- $transactionSave->save();
95
- $invoice->sendEmail();
96
- return $invoice;
97
- }
98
-
99
- /**
100
- * Returns the actual microtime in seconds
101
- * @return float seconds
102
- */
103
- protected function chrono()
104
- {
105
- list($msec, $sec) = explode(' ', microtime());
106
- return ((float)$msec + (float)$sec);
107
- }
108
-
109
-
110
- /*
111
- autmatically cancel the not paid orders afer 60 minutes
112
- */
113
- public function cancelPendingOrders()
114
- {
115
- $orderCollection = Mage::getResourceModel('sales/order_collection');
116
-
117
- $orderCollection
118
- ->addFieldToFilter('state', 'pending_payment')
119
- ->addFieldToFilter('created_at', array(
120
- 'lt' => new Zend_Db_Expr("DATE_ADD('".now()."', INTERVAL -'60:00' HOUR_MINUTE)")))
121
- ->getSelect()
122
- ->limit(20)
123
- ;
124
-
125
-
126
- $orders ="";
127
- foreach($orderCollection->getItems() as $order)
128
- {
129
- $orderModel = Mage::getModel('sales/order');
130
- $orderModel->load($order['entity_id']);
131
-
132
-
133
- if(!$orderModel->canCancel())
134
- continue;
135
-
136
- $orderModel->cancel();
137
- $orderModel->setStatus('canceled');
138
- $orderModel->save();
139
-
140
- }
141
- }
142
-
143
-
144
-
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Payment.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Payment class
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
-
12
- class Pagantis_Pagantis_Model_Payment extends Mage_Payment_Model_Method_Abstract
13
- {
14
-
15
- protected $_code = 'pagantis';
16
- protected $_formBlockType = 'pagantis_pagantis/form';
17
- protected $_isInitializeNeeded = true;
18
- protected $_canUseInternal = false;
19
- protected $_canUseForMultishipping = false;
20
- protected $_config = null;
21
-
22
- const PAYMENT_UNIQUE = 'unico';
23
- const PAYMENT_LOAN = 'financiacion';
24
- const PMT_URL = 'https://pmt.pagantis.com/v1/installments/';
25
-
26
- /**
27
- * Get checkout session namespace
28
- *
29
- * @return Mage_Checkout_Model_Session
30
- */
31
- public function getCheckout()
32
- {
33
- return Mage::getSingleton('checkout/session');
34
- }
35
-
36
- /**
37
- * Get current quote
38
- *
39
- * @return Mage_Sales_Model_Quote
40
- */
41
- public function getQuote()
42
- {
43
- return $this->getCheckout()->getQuote();
44
- }
45
-
46
- /**
47
- * Create main block for standard form
48
- *
49
- */
50
- public function createFormBlock($name)
51
- {
52
- $block = $this->getLayout()->createBlock($this->_formBlockType, $name)
53
- ->setMethod('pagantis')
54
- ->setPayment($this->getPayment())
55
- ->setTemplate('pagantis/form.phtml');
56
-
57
- return $block;
58
- }
59
-
60
- /**
61
- * Return Order place redirect url
62
- *
63
- * @return string
64
- */
65
- public function getOrderPlaceRedirectUrl()
66
- {
67
- return Mage::getUrl('pagantis/pagantis/redirect', array('_secure' => true));
68
- }
69
-
70
- /**
71
- * Instantiate state and set it to state object
72
- * @param string $paymentAction
73
- * @param Varien_Object
74
- */
75
- public function initialize($paymentAction, $stateObject)
76
- {
77
- /*
78
- $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
79
- $paymentDetailArray = Mage::app()->getRequest()->getPost('paymentdetail');
80
- $paymentDetail = $paymentDetailArray[0];
81
- $this->getCheckout()->setPaymentMethodDetail($paymentDetail);
82
- $stateObject->setState($state);
83
- $stateObject->setStatus('pending_payment');
84
- $stateObject->setIsNotified(false);
85
- */
86
- }
87
-
88
- public function getFormFields()
89
- {
90
- $orderIncrementId = $this->getCheckout()->getLastRealOrderId();
91
- $paymentDetails = $this->getCheckout()->getPaymentMethodDetail();
92
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
93
- // For EUR last 2 position are considered decimals
94
- $amount = $order->getTotalDue() * 100;
95
- $orderId = $order->increment_id;
96
-
97
- $localeCode = Mage::app()->getLocale()->getLocaleCode();
98
- /*
99
- switch($paymentDetails) {
100
- case self::PAYMENT_UNIQUE:
101
- $request = Mage::helper('pagantis_pagantis')->getRequest($amount, $orderId, $localeCode);
102
- break;
103
- case self::PAYMENT_LOAN:
104
- $request = Mage::helper('pagantis_pagantis')->getRequestloan($amount, $orderId, $localeCode);
105
- break;
106
- }
107
- */
108
- $request = Mage::helper('pagantis_pagantis')->getRequestloan($amount, $orderId, $localeCode);
109
- return $request->toArray();
110
- }
111
-
112
-
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Source/Payment/Currency.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Currencies for Pagantis_Pagantis config
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Model_Source_Payment_Currency
12
- {
13
-
14
- /**
15
- * Options list as array
16
- *
17
- * @var array
18
- */
19
- protected $_options = null;
20
-
21
- /**
22
- * Retrieve all currencies
23
- *
24
- * @return array
25
- */
26
- public function getAllOptions()
27
- {
28
- if ($this->_options === null) {
29
- $this->_options = array();
30
-
31
- $this->_options[] = array('label' => Mage::helper('pagantis_pagantis')->__('Euro'), 'value' => Pagantis_Pagantis_Model_Currency::EUR);
32
- $this->_options[] = array('label' => Mage::helper('pagantis_pagantis')->__('Pound'), 'value' => Pagantis_Pagantis_Model_Currency::GBP);
33
- $this->_options[] = array('label' => Mage::helper('pagantis_pagantis')->__('US Dollar'), 'value' => Pagantis_Pagantis_Model_Currency::USD);
34
- }
35
-
36
- return $this->_options;
37
- }
38
-
39
- /**
40
- * To option array conversion
41
- *
42
- * @return array
43
- */
44
- public function toOptionArray()
45
- {
46
- return $this->getAllOptions();
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Source/Payment/Environment.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Enviroments for Pagantis_Pagantis config
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_Model_Source_Payment_Environment
12
- {
13
-
14
- /**
15
- * Options list as array
16
- *
17
- * @var array
18
- */
19
- protected $_options = null;
20
-
21
- /**
22
- * Retrieve all environments
23
- *
24
- * @return array
25
- */
26
- public function getAllOptions()
27
- {
28
- if ($this->_options === null) {
29
- $this->_options = array();
30
-
31
- $this->_options[] = array('label' => Mage::helper('pagantis_pagantis')->__('Real'), 'value' => Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION);
32
- $this->_options[] = array('label' => Mage::helper('pagantis_pagantis')->__('Testing'), 'value' => Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING);
33
- }
34
-
35
- return $this->_options;
36
- }
37
-
38
- /**
39
- * To option array conversion
40
- *
41
- * @return array
42
- */
43
- public function toOptionArray()
44
- {
45
- return $this->getAllOptions();
46
- }
47
-
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Client.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class Pagantis_Pagantis_Model_Webservice_Client
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
-
12
- class Pagantis_Pagantis_Model_Webservice_Client
13
- {
14
-
15
- // Environments
16
- const ENV_TESTING = 'testing';
17
- const ENV_PRODUCTION = 'production';
18
-
19
-
20
-
21
-
22
- private $_pathConfig;
23
-
24
- /**
25
- * Pagantis_Pagantis_Model_Webservice_Client constructor
26
- * @param array $path_config
27
- */
28
- public function __construct($path_config = null)
29
- {
30
- if ($path_config != null) {
31
- $this->_pathConfig = $path_config['config'];
32
- }
33
- $this->_session = Mage::getSingleton('checkout/session');
34
- }
35
-
36
- /**
37
- * Send a request and process response
38
- *
39
- * @param Pagantis_Pagantis_Model_Webservice_Request $request
40
- * @return Pagantis_Pagantis_Model_Webservice_Response
41
- */
42
- public function makeRequest(Pagantis_Pagantis_Model_Webservice_Request $request)
43
- {
44
- $response = $this->sendRequest($request);
45
- return $this->processResponse($response);
46
- }
47
-
48
- /**
49
- * Send a request and process response
50
- *
51
- * @param Pagantis_Pagantis_Model_Webservice_Request $request
52
- * @return array
53
- */
54
- public function getCurlResultPaymentRequest(Pagantis_Pagantis_Model_Webservice_PaymentRequest $paymentRequest)
55
- {
56
- $bearer = (string)$paymentRequest->getBearer();
57
- $urlApi = (string)$paymentRequest->getUrlPagantis().$paymentRequest->getTransaction();
58
-
59
- $crl = curl_init();
60
-
61
- $header = array();
62
- $header[] = 'Content-length: 0';
63
- $header[] = 'Content-type: application/json';
64
- $header[] = 'Authorization: Bearer '.$bearer;
65
-
66
- curl_setopt($crl, CURLOPT_HTTPHEADER,$header);
67
- curl_setopt($crl,CURLOPT_RETURNTRANSFER, 1);
68
- curl_setopt($crl,CURLOPT_URL, $urlApi);
69
- $result = json_decode(curl_exec($crl),true);
70
- curl_close($crl);
71
- return $result['response'];
72
- }
73
-
74
- /**
75
- * Send a request
76
- *
77
- * @param Pagantis_Pagantis_Model_Webservice_Request $request
78
- * @return Object
79
- */
80
- private function sendPaymentRequest(Pagantis_Pagantis_Model_Webservice_PaymentRequest $request)
81
- {
82
-
83
- $xmlRequest = $request->toXml();
84
- $response = $this->trataPeticion(array(
85
- self::SOAP_REQUEST_WRAPPER => $xmlRequest
86
- ));
87
-
88
- return $response;
89
- }
90
-
91
- /**
92
- * Process response
93
- *
94
- * @param Pagantis_Pagantis_Model_Webservice_Response $response
95
- */
96
- /*private function processResponse($response)
97
- {
98
- $response = new Pagantis_Pagantis_Model_Webservice_Response($response->trataPeticionReturn);
99
- return $response;
100
- }*/
101
-
102
- public function getUrl()
103
- {
104
- $conf = Mage::getStoreConfig('payment/pagantis');
105
- $environment = $conf['environment'];
106
- switch($environment){
107
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING:
108
- return $conf['url_pagantis_test'];
109
- break;
110
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION:
111
- return $conf['url_pagantis_real'];
112
- break;
113
- }
114
- }
115
-
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Paymentrequest.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class Pagantis_Pagantis_Model_Webservice_Request
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
-
12
- class Pagantis_Pagantis_Model_Webservice_Paymentrequest
13
- {
14
- const BASE = 'pagantis/pagantis';
15
- const URL_PAYMENT_REQUEST = 'https://psp.pagantis.com/api/1/charges/';
16
-
17
- /**
18
- * @var string $_urlPagantis Redirect url for payment
19
- */
20
- protected $_urlPagantis;
21
-
22
- /**
23
- * @var string $_amount Order Amount
24
- */
25
- protected $_bearer;
26
-
27
- /**
28
- * @var string $_currency Order Amount
29
- */
30
- protected $_transaction;
31
-
32
-
33
-
34
- public function __construct()
35
- {
36
- $this->_urlPagantis = self::URL_PAYMENT_REQUEST;
37
- }
38
-
39
- /**
40
- * Assign bearer for call
41
- * @param string $bearer
42
- * @throws Exception
43
- */
44
- public function setBearer($bearer = '')
45
- {
46
- if (strlen(trim($bearer)) > 0) {
47
- $this->_bearer = $bearer;
48
- } else {
49
- throw new \Exception('Missing bearer for call');
50
- }
51
- }
52
-
53
- /**
54
- * Assign transaction for call
55
- * @param string $transaction
56
- * @throws Exception
57
- */
58
- public function setTransaction($transaction = '')
59
- {
60
- if (strlen(trim($transaction)) > 0) {
61
- $this->_transaction = $transaction;
62
- } else {
63
- throw new \Exception('Missing transaction for call');
64
- }
65
- }
66
-
67
- public function getTransaction(){
68
- return $this->_transaction;
69
- }
70
- public function getBearer(){
71
- return $this->_bearer;
72
- }
73
- public function getUrlPagantis(){
74
- return $this->_urlPagantis;
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Request.php DELETED
@@ -1,353 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class Pagantis_Pagantis_Model_Webservice_Request
5
- * @package Pagantis_Pagantis
6
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
7
- * @author Yameveo <yameveo@yameveo.com>
8
- * @link http://www.yameveo.com
9
- */
10
-
11
- class Pagantis_Pagantis_Model_Webservice_Request
12
- {
13
- const BASE = 'pagantis/pagantis';
14
-
15
- /**
16
- * @var string $_urlPagantis Redirect url for payment
17
- */
18
- protected $_urlPagantis;
19
-
20
- /**
21
- * @var string $_amount Order Amount
22
- */
23
- protected $_amount;
24
-
25
- /**
26
- * @var string $_currency Order Amount
27
- */
28
- protected $_currency;
29
-
30
- /**
31
- * @var string $_orderId Increment order Id
32
- */
33
- protected $_orderId;
34
- /**
35
- * @var string $_languagePagantis Force language on bank page
36
- */
37
- protected $_languagePagantis;
38
-
39
- /**
40
- * @var string $_authMethod Authentication method for payment redirect.
41
- */
42
- protected $_authMethod;
43
-
44
- /**
45
- * @var string $_accountCode
46
- */
47
- protected $_accountCode;
48
-
49
- /**
50
- * @var string $accountKey
51
- */
52
- protected $_accountKey;
53
-
54
- /**
55
- * @var string $_accountApiKey
56
- */
57
- protected $_accountApiKey;
58
-
59
- /**
60
- * @var string $_urlOk Requerido 500 URL completa.
61
- */
62
- protected $_urlOk;
63
-
64
- /**
65
- *
66
- * @var string $_urlKo Requerido 500 URL completa.
67
- */
68
- protected $_urlKo;
69
-
70
- /**
71
- *
72
- * @var string $_callback_url Requerido 500 URL completa.
73
- */
74
- protected $_callback_url;
75
-
76
- /**
77
- * @var string $_firma created by clave_de_firma + account_id + order_id + amount + currency + auth_method + ok_url + nok_url
78
- */
79
- protected $_firma;
80
-
81
- /**
82
- * @var dicount
83
- */
84
- protected $_dicount;
85
-
86
-
87
- public function __construct()
88
- {
89
- $this->_languagePagantis = $this->setLanguagePagantis(); //Por defecto español
90
- $this->_currency = $this->setCurrency();
91
- }
92
-
93
- /**
94
- * Return the array version of the Request to be sent through the form
95
- *
96
- * @return string
97
- */
98
- public function toArray()
99
- {
100
- $array = array();
101
- $array['locale'] = $this->_languagePagantis;
102
- $array['ok_url'] = $this->_urlOk;
103
- $array['nok_url'] = $this->_urlKo;
104
- $array['callback_url'] = $this->_callback_url;
105
- $array['discount'] = $this->_discount;
106
- //$array['urlPagantis'] = $this->_urlPagantis;
107
- $array['account_id'] = $this->_accountCode;
108
- $array['amount'] = $this->_amount;
109
- $array['auth_method'] = $this->_authMethod;
110
- $array['currency'] = $this->_currency;
111
- $array['signature'] = $this->_firma;
112
- $array['order_id'] = $this->_orderId;
113
- return $array;
114
- }
115
-
116
- /**
117
- * Assign url for redirect
118
- * @param string $urlPagantis
119
- * @throws Exception
120
- */
121
- public function setUrlPagantis($urlPagantis = '')
122
- {
123
- if (strlen(trim($urlPagantis)) > 0) {
124
- $this->_urlPagantis = $urlPagantis;
125
- } else {
126
- throw new \Exception('Missing url for redirect to page bank');
127
- }
128
- }
129
-
130
- /**
131
- * Assign url for redirect
132
- * @param string $urlPagantis
133
- * @throws Exception
134
- */
135
- public function setOrderId($orderId = '')
136
- {
137
- if (strlen(trim($orderId)) > 0) {
138
- $this->_orderId = $orderId;
139
- } else {
140
- throw new \Exception('Missing orderId');
141
- }
142
- }
143
-
144
- /**
145
- * Assign currency for redirect
146
- * @param string $currency
147
- * @throws Exception
148
- */
149
- public function setCurrency()
150
- {
151
- return Pagantis_Pagantis_Model_Currency::EUR;
152
- }
153
-
154
- /**
155
- * Assign url for redirect
156
- * @param string $urlPagantis
157
- * @throws Exception
158
- */
159
- public function setAmount($amount = '')
160
- {
161
- if (strlen(trim($amount)) > 0) {
162
- $this->_amount = $amount;
163
- } else {
164
- throw new \Exception('Missing amount');
165
- }
166
- }
167
-
168
- /**
169
- * Assign language for bank page
170
- * @param string $language Language for bank page
171
- */
172
- public function setLanguagePagantis($language = 'es')
173
- {
174
- return $language;
175
- }
176
-
177
- /**
178
- * Assign authentication method
179
- * @param string $authMethod Auth method.
180
- */
181
- public function setAuthMethod($authMethod = 'SHA1')
182
- {
183
- $this->_authMethod = $authMethod;
184
- }
185
-
186
- /**
187
- * Assign account code
188
- * @param string $accountCode
189
- * @throws Exception
190
- */
191
- public function setAccountCode($accountCode=''){
192
- if (strlen(trim($accountCode)) > 0) {
193
- $this->_accountCode = $accountCode;
194
- } else {
195
- throw new \Exception('Missing account code');
196
- }
197
- }
198
-
199
- /**
200
- * Assign discount
201
- * @param string $discount
202
- * @throws Exception
203
- */
204
- public function setDiscount($discount=''){
205
- if ($discount == 1) {
206
- $this->_discount = 'true';
207
- } else {
208
- $this->_discount = 'false';
209
- }
210
- }
211
-
212
- /**
213
- * Assign account key
214
- * @param string $accountKey
215
- * @throws Exception
216
- */
217
- public function setAccountKey($accountKey=''){
218
- if (strlen(trim($accountKey)) > 0) {
219
- $this->_accountKey = $accountKey;
220
- } else {
221
- throw new \Exception('Missing account key');
222
- }
223
- }
224
-
225
- /**
226
- * Assign account key
227
- * @param string $accountApiKey
228
- * @throws Exception
229
- */
230
- public function setAccountApiKey($accountApiKey=''){
231
- if (strlen(trim($accountApiKey)) > 0) {
232
- $this->_accountApiKey = $accountApiKey;
233
- } else {
234
- throw new \Exception('Missing account API key');
235
- }
236
- }
237
-
238
- /**
239
- * @param string $urlok
240
- * @throws Exception
241
- */
242
- public function setUrlOk()
243
- {
244
- $urlOk = $this->getUrl('success');
245
- if (strlen(trim($urlOk)) > 0) {
246
- $this->_urlOk = $urlOk;
247
- } else {
248
- throw new \Exception('UrlOk not defined');
249
- }
250
-
251
- }
252
-
253
- /**
254
- * @param string $urlnok
255
- * @throws Exception
256
- */
257
- public function setUrlKo($urlKo = '')
258
- {
259
- $urlKo = $this->getUrl('cancel');
260
- if (strlen(trim($urlKo)) > 0) {
261
- $this->_urlKo = $urlKo;
262
- } else {
263
- throw new \Exception('UrlKo not defined');
264
- }
265
- }
266
-
267
- /**
268
- * @param string $urlnok
269
- * @throws Exception
270
- */
271
- public function setCacllbackUrl($url = '')
272
- {
273
- $this->_callback_url=Mage::getBaseUrl()."/pagantis/pagantis/notification";
274
- }
275
-
276
- /**
277
- * Firm generation
278
- * Generated with SHA1 of _accountKey + _accountCode + _orderId + _amount + _currency + _authMethod + _urlOk + _urlKo
279
- * @throws Exception
280
- * @return string
281
- */
282
- public function setFirma()
283
- {
284
-
285
- if (strlen(trim($textToEncode)) > 0) {
286
- // Retrieve del SHA1
287
- $this->_firma = sha1($textToEncode);
288
- } else {
289
- throw new Exception('Missing SHA1');
290
- }
291
- }
292
-
293
- //Utilities
294
- //http://stackoverflow.com/a/9111049/444225
295
- private function priceToSQL($price)
296
- {
297
- $price = preg_replace('/[^0-9\.,]*/i', '', $price);
298
- $price = str_replace(',', '.', $price);
299
-
300
- if (substr($price, -3, 1) == '.') {
301
- $price = explode('.', $price);
302
- $last = array_pop($price);
303
- $price = join($price, '') . '.' . $last;
304
- } else {
305
- $price = str_replace('.', '', $price);
306
- }
307
-
308
- return $price;
309
- }
310
-
311
- public function getUrl($path)
312
- {
313
- $url = Mage::getUrl(self::BASE . "/$path");
314
- return Mage::getModel('core/url')->sessionUrlVar($url);
315
- }
316
-
317
- /**
318
- * Converts field names for setters and getters
319
- *
320
- * @param string $name
321
- * @return string
322
- */
323
- private function underscore($name)
324
- {
325
- $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
326
- return $result;
327
- }
328
-
329
- /**
330
- * Checks if received response is correct
331
- * Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+TipoMoneda+ Exponente+Referencia
332
- * @param Yameveo_Ceca_Model_Webservice_Response $response
333
- * @return boolean
334
- */
335
- /*public function checkResponseSignature(Pagantis_Pagantis_Model_Webservice_Response $response)
336
- {
337
- $txt = $this->_clave_encriptacion;
338
- $txt .= $response->getMerchantId();
339
- $txt .= $response->getAcquirerBin();
340
- $txt .= $response->getTerminalId();
341
- $txt .= $response->getNumOperacion();
342
- $txt .= $response->getImporte();
343
- $txt .= $response->getTipoMoneda();
344
- $txt .= $response->getExponente();
345
- $txt .= $response->getReferencia();
346
-
347
- // Calculate signature
348
- $signature = sha1($txt);
349
-
350
- // Compare received signature with calculated
351
- return strtolower($signature) === strtolower($response->getFirma());
352
- }*/
353
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Requestloan.php DELETED
@@ -1,422 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class Pagantis_Pagantis_Model_Webservice_Request
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
-
12
- class Pagantis_Pagantis_Model_Webservice_Requestloan
13
- {
14
- const BASE = 'pagantis/pagantis';
15
-
16
- /**
17
- * @var string $_urlPagantis Redirect url for payment
18
- */
19
- protected $_urlPagantis;
20
-
21
- /**
22
- * @var string $_amount Order Amount
23
- */
24
- protected $_amount;
25
-
26
- /**
27
- * @var string $_currency Order Amount
28
- */
29
- protected $_currency;
30
-
31
- /**
32
- * @var string $_orderId Increment order Id
33
- */
34
- protected $_orderId;
35
- /**
36
- * @var string $_languagePagantis Force language on bank page
37
- */
38
- protected $_languagePagantis;
39
-
40
- /**
41
- * @var string $_authMethod Authentication method for payment redirect.
42
- */
43
- protected $_authMethod;
44
-
45
- /**
46
- * @var string $_accountCode
47
- */
48
- protected $_accountCode;
49
-
50
- /**
51
- * @var string $accountKey
52
- */
53
- protected $_accountKey;
54
-
55
-
56
- /**
57
- * @var string $_urlOk Requerido 500 URL completa.
58
- */
59
- protected $_urlOk;
60
-
61
- /**
62
- *
63
- * @var string $_urlKo Requerido 500 URL completa.
64
- */
65
- protected $_urlKo;
66
-
67
- /**
68
- *
69
- * @var string $_urlKo Requerido 500 URL completa.
70
- */
71
- protected $_callback_url;
72
-
73
-
74
- /**
75
- * @var string $_firma created by clave_de_firma + account_id + order_id + amount + currency + ok_url + nok_url
76
- */
77
- protected $_firma;
78
-
79
- /**
80
- * @var array
81
- */
82
- protected $_userData;
83
-
84
- /**
85
- * @var array
86
- */
87
- protected $_items;
88
-
89
- /**
90
- * @var dicount
91
- */
92
- protected $_dicount;
93
-
94
- public function __construct()
95
- {
96
- $this->_languagePagantis = $this->setLanguagePagantis(); //Por defecto español
97
- $this->_currency = $this->setCurrency();
98
- }
99
-
100
- /**
101
- * Return the array version of the Request to be sent through the form
102
- *
103
- * @return string
104
- */
105
- public function toArray()
106
- {
107
- $array = array();
108
- $array['order_id'] = $this->_orderId;
109
- $array['amount'] = $this->_amount;
110
- $array['currency'] = $this->_currency;
111
-
112
- $array['ok_url'] = $this->_urlOk;
113
- $array['nok_url'] = $this->_urlKo;
114
- $array['callback_url'] = $this->_callback_url;
115
- $array['discount[full]'] = $this->_discount;
116
-
117
- $array['locale'] = $this->_languagePagantis;
118
- $array['phone'] = $this->_userData['phone'];
119
- $array['full_name'] = $this->_userData['full_name'];
120
- $array['email'] = $this->_userData['email'];
121
- $array['address[street]'] = $this->_userData['street'];
122
- $array['address[city]'] = $this->_userData['city'];
123
- $array['address[province]'] = $this->_userData['province'];
124
- $array['address[zipcode]'] = $this->_userData['zipcode'];
125
- $array['dni'] = $this->_userData['dni'];
126
-
127
- foreach($this->_items as $key => $value){
128
- $array['items[' . $key . '][description]'] = $value['description'];
129
- $array['items[' . $key . '][quantity]'] = $value['quantity'];
130
- $array['items[' . $key . '][amount]'] = $value['amount'];
131
- }
132
-
133
- $array['account_id'] = $this->_accountCode;
134
- $array['signature'] = $this->_firma;
135
-
136
- return $array;
137
- }
138
-
139
- /**
140
- * Assign url for redirect
141
- * @param string $urlPagantis
142
- * @throws Exception
143
- */
144
- public function setUrlPagantis($urlPagantis = '')
145
- {
146
- if (strlen(trim($urlPagantis)) > 0) {
147
- $this->_urlPagantis = $urlPagantis;
148
- } else {
149
- throw new \Exception('Missing url for redirect to page bank');
150
- }
151
- }
152
-
153
- /**
154
- * Assign url for redirect
155
- * @param string $urlPagantis
156
- * @throws Exception
157
- */
158
- public function setOrderId($orderId = '')
159
- {
160
- if (strlen(trim($orderId)) > 0) {
161
- $this->_orderId = $orderId;
162
- } else {
163
- throw new \Exception('Missing orderId');
164
- }
165
- }
166
-
167
- /**
168
- * Assign currency for redirect
169
- * @param string $currency
170
- * @throws Exception
171
- */
172
- public function setCurrency()
173
- {
174
- return Pagantis_Pagantis_Model_Currency::EUR;
175
- }
176
-
177
- /**
178
- * Assign url for redirect
179
- * @param string $urlPagantis
180
- * @throws Exception
181
- */
182
- public function setAmount($amount = '')
183
- {
184
- if (strlen(trim($amount)) > 0) {
185
- $this->_amount = $amount;
186
- } else {
187
- throw new \Exception('Missing amount');
188
- }
189
- }
190
-
191
- /**
192
- * Assign language for bank page
193
- * @param string $language Language for bank page
194
- */
195
- public function setLanguagePagantis($language = 'es')
196
- {
197
- return $language;
198
- }
199
-
200
- /**
201
- * Assign user data
202
- * @param string $addressId
203
- * @throws Exception
204
- */
205
- public function setUserData($addressId)
206
- {
207
- if ($addressId) {
208
- $address = Mage::getModel('sales/order_address')->load($addressId);
209
- $street = $address->getStreet();
210
- if ($street){
211
- $this->_userData['street'] = $street[0];
212
- }
213
- $this->_userData['city'] = $address->getCity();
214
- $this->_userData['province'] = $address->getCity();
215
- $this->_userData['zipcode'] = $address->getPostcode();
216
- $this->_userData['dni'] = $address->getVatId();
217
- $this->_userData['full_name'] = $address->getFirstname() . ' ' . $address->getLastname();
218
- $this->_userData['email'] = $address->getEmail();
219
- $this->_userData['phone'] = $address->getTelephone();
220
- } else {
221
- throw new \Exception('Missing user data info');
222
- }
223
- }
224
-
225
- /**
226
- * Assign user data
227
- * @param string $addressId
228
- * @throws Exception
229
- */
230
- public function setOrderItems($orderId)
231
- {
232
- if ($orderId) {
233
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
234
- $items = $order->getAllVisibleItems();
235
- $i = 0;
236
- foreach($items as $item){
237
- $amount = round($item->getPriceInclTax(),2);
238
- $quantity = round($item->getQtyOrdered());
239
- $this->_items[$i]['description'] = $item->getName();
240
- $this->_items[$i]['quantity'] = $quantity;
241
- $this->_items[$i]['amount'] = round($amount*$quantity,2);
242
- $i++;
243
- }
244
- $shippingAmount = round($order->getShippingAmount(),2);
245
- if($shippingAmount){
246
- $this->_items[$i]['description'] = "Gastos de envío";
247
- $this->_items[$i]['quantity'] = "1";
248
- $this->_items[$i]['amount'] = $shippingAmount;
249
- $i++;
250
- }
251
- $discountAmount = round($order->getBaseDiscountAmount(),2);
252
- if($discountAmount){
253
- $this->_items[$i]['description'] = "Descuento";
254
- $this->_items[$i]['quantity'] = "1";
255
- $this->_items[$i]['amount'] = $discountAmount;
256
- }
257
-
258
- } else {
259
- throw new \Exception('Missing user data info');
260
- }
261
- }
262
-
263
- /**
264
- * Assign account code
265
- * @param string $accountCode
266
- * @throws Exception
267
- */
268
- public function setAccountCode($accountCode=''){
269
- if (strlen(trim($accountCode)) > 0) {
270
- $this->_accountCode = $accountCode;
271
- } else {
272
- throw new \Exception('Missing account code');
273
- }
274
- }
275
-
276
- /**
277
- * Assign discount
278
- * @param string $discount
279
- * @throws Exception
280
- */
281
- public function setDiscount($discount=''){
282
- if ($discount == 1) {
283
- $this->_discount = 'true';
284
- } else {
285
- $this->_discount = 'false';
286
- }
287
- }
288
- /**
289
- * Assign account key
290
- * @param string $accountKey
291
- * @throws Exception
292
- */
293
- public function setAccountKey($accountKey=''){
294
- if (strlen(trim($accountKey)) > 0) {
295
- $this->_accountKey = $accountKey;
296
- } else {
297
- throw new \Exception('Missing account key');
298
- }
299
- }
300
-
301
-
302
- /**
303
- * @param string $urlok
304
- * @throws Exception
305
- */
306
- public function setUrlOk()
307
- {
308
- $urlOk = $this->getUrl('success');
309
- if (strlen(trim($urlOk)) > 0) {
310
- $this->_urlOk = $urlOk;
311
- } else {
312
- throw new \Exception('UrlOk not defined');
313
- }
314
-
315
- }
316
-
317
- /**
318
- * @param string $urlnok
319
- * @throws Exception
320
- */
321
- public function setUrlKo($urlKo = '')
322
- {
323
- $urlKo = $this->getUrl('cancel');
324
- if (strlen(trim($urlKo)) > 0) {
325
- $this->_urlKo = $urlKo;
326
- } else {
327
- throw new \Exception('UrlKo not defined');
328
- }
329
- }
330
-
331
- /**
332
- * @param string $urlnok
333
- * @throws Exception
334
- */
335
- public function setCacllbackUrl($ur = '')
336
- {
337
- $this->_callback_url=Mage::getBaseUrl()."/pagantis/pagantis/notification";
338
- }
339
-
340
-
341
- /**
342
- * Firm generation
343
- * Generated with SHA1 of _accountKey + _accountCode + _orderId + _amount + _currency + _urlOk + _urlKo
344
- * @throws Exception
345
- * @return string
346
- */
347
- public function setFirma()
348
- {
349
- $textToEncode = $this->_accountKey . $this->_accountCode . $this->_orderId . $this->_amount . $this->_currency . $this->_urlOk . $this->_urlKo . $this->_callback_url . $this->_discount;
350
- //encoding is SHA1
351
- $this->_firma = sha1($textToEncode);
352
- /*
353
- if (strlen(trim($textToEncode)) > 0) {
354
- // Retrieve del SHA1
355
- $this->_firma = sha1($textToEncode);
356
- } else {
357
- throw new Exception('Missing SHA1');
358
- }
359
- */
360
- }
361
-
362
- //Utilities
363
- //http://stackoverflow.com/a/9111049/444225
364
- private function priceToSQL($price)
365
- {
366
- $price = preg_replace('/[^0-9\.,]*/i', '', $price);
367
- $price = str_replace(',', '.', $price);
368
-
369
- if (substr($price, -3, 1) == '.') {
370
- $price = explode('.', $price);
371
- $last = array_pop($price);
372
- $price = join($price, '') . '.' . $last;
373
- } else {
374
- $price = str_replace('.', '', $price);
375
- }
376
-
377
- return $price;
378
- }
379
-
380
- public function getUrl($path)
381
- {
382
- $url = Mage::getUrl(self::BASE . "/$path");
383
- return Mage::getModel('core/url')->sessionUrlVar($url);
384
- }
385
-
386
- /**
387
- * Converts field names for setters and getters
388
- *
389
- * @param string $name
390
- * @return string
391
- */
392
- private function underscore($name)
393
- {
394
- $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
395
- return $result;
396
- }
397
-
398
- /**
399
- * Checks if received response is correct
400
- * Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+TipoMoneda+ Exponente+Referencia
401
- * @param Yameveo_Ceca_Model_Webservice_Response $response
402
- * @return boolean
403
- */
404
- /*public function checkResponseSignature(Pagantis_Pagantis_Model_Webservice_Response $response)
405
- {
406
- $txt = $this->_clave_encriptacion;
407
- $txt .= $response->getMerchantId();
408
- $txt .= $response->getAcquirerBin();
409
- $txt .= $response->getTerminalId();
410
- $txt .= $response->getNumOperacion();
411
- $txt .= $response->getImporte();
412
- $txt .= $response->getTipoMoneda();
413
- $txt .= $response->getExponente();
414
- $txt .= $response->getReferencia();
415
-
416
- // Calculate signature
417
- $signature = sha1($txt);
418
-
419
- // Compare received signature with calculated
420
- return strtolower($signature) === strtolower($response->getFirma());
421
- }*/
422
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/Model/Webservice/Response.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * @package Pagantis_Pagantis
6
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
7
- * @author Yameveo <yameveo@yameveo.com>
8
- * @link http://www.yameveo.com
9
- */
10
-
11
- class Pagantis_Pagantis_Model_Webservice_Response
12
- {
13
-
14
-
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/controllers/PagantisController.php DELETED
@@ -1,181 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Pagantis Checkout Controller
5
- *
6
- * @package Pagantis_Pagantis
7
- * @copyright Copyright (c) 2015 Yameveo (http://www.yameveo.com)
8
- * @author Yameveo <yameveo@yameveo.com>
9
- * @link http://www.yameveo.com
10
- */
11
- class Pagantis_Pagantis_PagantisController extends Mage_Core_Controller_Front_Action
12
- {
13
- /**
14
- * When a customer chooses Pagantis on Checkout/Payment page
15
- *
16
- */
17
- public function redirectAction()
18
- {
19
- /*$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
20
- $session = Mage::getSingleton('checkout/session');
21
- $order = Mage::getModel('sales/order')->load($session->getLastOrderId());
22
- $order->setState($state, $state, Mage::helper('pagantis_pagantis')->__('Redirected to Pagantis'), false);
23
- $order->save();
24
- */
25
- $this->loadLayout();
26
- $this->renderLayout();
27
- }
28
-
29
- /**
30
- * When customer cancel payment from CECA (UrlKO)
31
- *
32
- */
33
- public function cancelAction()
34
- {
35
- $session = Mage::getSingleton('checkout/session');
36
- //Mage::getSingleton(‘core/session’)->addError(‘Error message’);
37
- $session->addError('Lo sentimos, se ha producido algún error en el pago, le agradeceríamos que volviera a intentarlo.');
38
- if ($session->getLastRealOrderId()) {
39
- $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
40
- if ($order->getId()) {
41
- $order->cancel()->save();
42
- }
43
- Mage::helper('pagantis_pagantis')->restoreQuote();
44
- }
45
- $this->_redirect('checkout/cart');
46
- }
47
-
48
- public function notificationAction(){
49
- //$json = json_decode(file_get_contents(Mage::getBaseDir().'/charge.created.txt'),true);
50
- //Notification url mush be like http://mydomain.com/pagantis/pagantis/notification
51
-
52
- $json = file_get_contents('php://input');
53
- $temp = json_decode($json,true);
54
- //verify notification
55
- $conf = Mage::getStoreConfig('payment/pagantis');
56
- $environment = $conf['environment'];
57
- switch($environment){
58
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_TESTING:
59
- $key=$conf['account_key_test'];
60
- break;
61
- case Pagantis_Pagantis_Model_Webservice_Client::ENV_PRODUCTION:
62
- $key=$conf['account_key_real'];
63
- break;
64
- }
65
- $signature_check = sha1($key.$temp['account_id'].$temp['api_version'].$temp['event'].$temp['data']['id']);
66
- if ($signature_check != $temp['signature'] ){
67
- //hack detected
68
- $this->cancelAction();
69
- return false;
70
- }
71
- $data = $temp['data'];
72
- $orderId = $data['order_id'];
73
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
74
- Mage::log('Pagantis notification received for orderId '.$orderId);
75
- //Mage::log($data,null,'logfile.txt');
76
- if ($order->getId()) {
77
- switch ($temp['event']) {
78
- case 'charge.created':
79
- $order->setPagantisTransaction($data['id']);
80
- $order->save();
81
- $this->_processOrder($order);
82
- break;
83
- case 'charge.failed':
84
- $order->setPagantisTransaction($data['id']);
85
- $order->setState(Mage_Sales_Model_Order::STATE_CANCELED,true);
86
- $order->save();
87
- break;
88
- }
89
- }
90
- }
91
-
92
- /**
93
- * When customer returns from Pagantis (UrlOK)
94
- * The order information at this point is in POST
95
- * variables. Order processing is done on callbackAction
96
- */
97
- public function successAction()
98
- {
99
- Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
100
- $this->_redirect('checkout/onepage/success', array('_secure' => true));
101
- }
102
-
103
- public function callbackAction()
104
- {
105
- $params = $this->getRequest()->getPost();
106
- $response = Mage::getModel('pagantis_pagantis/webservice_response', $params);
107
- $request = Mage::helper('pagantis_pagantis')->getRequest();
108
-
109
- if ($request->checkResponseSignature($response)) {
110
- // Process order
111
- $this->_processOrder($response->getOrder(), $response);
112
- } else {
113
- // Log invalid signature and redirect to home
114
- Mage::log('Pagantis: invalid signature on callback', Zend_Log::WARN);
115
- $this->_redirect('');
116
- }
117
- }
118
-
119
- /**
120
- * Process order
121
- *
122
- * @param $order
123
- */
124
- private function _processOrder($order)
125
- {
126
- try {
127
- $sendMail = (int) Mage::getStoreConfig('payment/pagantis/sendmail');
128
- $createInvoice = (int) Mage::getStoreConfig('payment/pagantis/invoice');
129
- if ($order->getId()) {
130
- //if ($response->isDsValid()) {
131
- $orderStatus = Mage_Sales_Model_Order::STATE_PROCESSING;
132
- if ($order->canInvoice() && $createInvoice) {
133
- $invoice = $this->_createInvoice($order);
134
- $comment = Mage::helper('pagantis_pagantis')->__('Transacción authorizada. Creada factura %s', $invoice->getIncrementId());
135
- } else {
136
- $comment = Mage::helper('pagantis_pagantis')->__('Transacción authorizada, factura no creada');
137
- }
138
- // } else {
139
- // $orderStatus = Mage_Sales_Model_Order::STATE_CANCELED;
140
- // $comment = Mage::helper('yameveo_ceca')->__($response->getErrorMessage());
141
- // }
142
- $order->setState($orderStatus, $orderStatus, $comment, true);
143
- $order->save();
144
- if ($sendMail) {
145
- if ($orderStatus == Mage_Sales_Model_Order::STATE_PROCESSING) {
146
- $order->sendNewOrderEmail();
147
- } else {
148
- $order->sendOrderUpdateEmail(true);
149
- }
150
- }
151
- }
152
- } catch (Exception $e) {
153
- Mage::logException($e);
154
- }
155
- }
156
-
157
- /**
158
- * Create an invoice for the order and send an email
159
- *
160
- * @param Mage_Sales_Model_Order $order
161
- * @return Mage_Sales_Model_Order_Invoice
162
- */
163
- private function _createInvoice($order)
164
- {
165
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
166
- if (!$invoice->getTotalQty()) {
167
- Mage::throwException(Mage::helper('core')->__('No se puede crear una factura sin productos.'));
168
- }
169
-
170
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
171
- $invoice->register();
172
- $transactionSave = Mage::getModel('core/resource_transaction')
173
- ->addObject($invoice)
174
- ->addObject($invoice->getOrder());
175
-
176
- $transactionSave->save();
177
- $invoice->sendEmail();
178
- return $invoice;
179
- }
180
-
181
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/etc/config.xml DELETED
@@ -1,132 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Pagantis_Pagantis>
5
- <version>1.0.0</version>
6
- </Pagantis_Pagantis>
7
- </modules>
8
- <adminhtml>
9
- <layout>
10
- <updates>
11
- <bar>
12
- <file>pagantis.xml</file>
13
- </bar>
14
- </updates>
15
- </layout>
16
- <translate>
17
- <modules>
18
- <pagantis_pagantis>
19
- <files>
20
- <default>Pagantis_Pagantis.csv</default>
21
- </files>
22
- </pagantis_pagantis>
23
- </modules>
24
- </translate>
25
- </adminhtml>
26
- <global>
27
- <resources>
28
- <pagantis_setup>
29
- <setup>
30
- <module>Pagantis_Pagantis</module>
31
- <class>Mage_Sales_Model_Mysql4_Setup</class>
32
- </setup>
33
- <connection>
34
- <use>core_setup</use>
35
- </connection>
36
- </pagantis_setup>
37
- </resources>
38
- <blocks>
39
- <pagantis_pagantis>
40
- <class>Pagantis_Pagantis_Block</class>
41
- </pagantis_pagantis>
42
- </blocks>
43
- <helpers>
44
- <pagantis_pagantis>
45
- <class>Pagantis_Pagantis_Helper</class>
46
- </pagantis_pagantis>
47
- </helpers>
48
- <models>
49
- <pagantis_pagantis>
50
- <class>Pagantis_Pagantis_Model</class>
51
- </pagantis_pagantis>
52
- </models>
53
- </global>
54
- <default>
55
- <payment>
56
- <pagantis>
57
- <active>1</active>
58
- <model>pagantis_pagantis/payment</model>
59
- <order_status>1</order_status>
60
- <title>Paga Mas Tarde</title>
61
- <url_pagantis>https://psp.pagantis.com/2/charges</url_pagantis>
62
- <url_pagantis_mastarde>https://pmt.pagantis.com/v1/installments</url_pagantis_mastarde>
63
- <environment></environment>
64
- <language_payment_page>ES</language_payment_page>
65
- <auth_method>SHA1</auth_method>
66
- <account_code_test></account_code_test>
67
- <account_key_test></account_key_test>
68
- <account_api_key_test></account_api_key_test>
69
- <account_code_real></account_code_real>
70
- <account_key_real></account_key_real>
71
- <discount></discount>
72
- <account_api_key_real></account_api_key_real>
73
- <sendmail>1</sendmail>
74
- <invoice>1</invoice>
75
- <!--<sort_order></sort_order>-->
76
- <payment_action>authorize_capture</payment_action>
77
- </pagantis>
78
- </payment>
79
- </default>
80
- <frontend>
81
- <translate>
82
- <modules>
83
- <pagantis_pagantis>
84
- <files>
85
- <default>Pagantis_Pagantis.csv</default>
86
- </files>
87
- </pagantis_pagantis>
88
- </modules>
89
- </translate>
90
- <secure_url>
91
- <pagantis>/pagantis/pagantis</pagantis>
92
- </secure_url>
93
- <routers>
94
- <pagantis>
95
- <use>standard</use>
96
- <args>
97
- <module>Pagantis_Pagantis</module>
98
- <frontName>pagantis</frontName>
99
- </args>
100
- </pagantis>
101
- </routers>
102
- <layout>
103
- <updates>
104
- <pagantis_pagantis_redirect>
105
- <file>pagantis.xml</file>
106
- </pagantis_pagantis_redirect>
107
- </updates>
108
- </layout>
109
- </frontend>
110
- <!--<crontab>
111
- <jobs>
112
- <pagantis_pagantis>
113
- <schedule>
114
- <config_path>pagantis_config/settings/cron_settings</config_path>
115
- </schedule>
116
- <run>
117
- <model>pagantis_pagantis/observer::exportOrders</model>
118
- </run>
119
- </pagantis_pagantis>
120
- </jobs>
121
- </crontab>-->
122
- <crontab>
123
- <jobs>
124
- <pagantis_pagantis>
125
- <schedule><cron_expr>*/30 * * * *</cron_expr></schedule>
126
- <run>
127
- <model>pagantis_pagantis/observer::cancelPendingOrders</model>
128
- </run>
129
- </pagantis_pagantis>
130
- </jobs>
131
- </crontab>
132
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/etc/system.xml DELETED
@@ -1,212 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <sections>
4
- <payment>
5
- <groups>
6
- <pagantis translate="label" module="pagantis_pagantis">
7
- <label>Pagamastarde Payment</label>
8
- <sort_order>10</sort_order>
9
- <show_in_default>1</show_in_default>
10
- <show_in_website>1</show_in_website>
11
- <show_in_store>1</show_in_store>
12
- <frontend_model>pagantis_pagantis/adminhtml_system_config_fieldset_payment</frontend_model>
13
- <fields>
14
- <active translate="label" module="pagantis_pagantis">
15
- <label>Habilitado</label>
16
- <comment>Habilitar esta forma de pago?</comment>
17
- <frontend_type>select</frontend_type>
18
- <source_model>adminhtml/system_config_source_yesno</source_model>
19
- <sort_order>1</sort_order>
20
- <show_in_default>1</show_in_default>
21
- <show_in_website>1</show_in_website>
22
- <show_in_store>1</show_in_store>
23
- </active>
24
- <title translate="label" module="pagantis_pagantis">
25
- <label>Título</label>
26
- <sort_order>2</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
- </title>
31
- <!--<title_pagamastarde translate="label" module="pagantis_pagantis">
32
- <label>Título Paga Mas Tarde</label>
33
- <sort_order>3</sort_order>
34
- <show_in_default>1</show_in_default>
35
- <show_in_website>1</show_in_website>
36
- <show_in_store>1</show_in_store>
37
- </title_pagamastarde>-->
38
- <!-- remove pagantis payment, pmt url moved to settings and automatically enabled -->
39
- <!-- <url_pagantis translate="label" module="pagantis_pagantis">
40
- <label>URL Pago Cobro Único</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>10</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- </url_pagantis>
47
- <url_pagantis_activated translate="label" module="pagantis_pagantis">
48
- <label>Activar forma de Pago Cobro Único</label>
49
- <comment>Abilitando esta forma de pago el cliente podrá eligirla al momento de la compra</comment>
50
- <frontend_type>select</frontend_type>
51
- <source_model>adminhtml/system_config_source_yesno</source_model>
52
- <sort_order>11</sort_order>
53
- <show_in_default>1</show_in_default>
54
- <show_in_website>1</show_in_website>
55
- <show_in_store>1</show_in_store>
56
- </url_pagantis_activated>
57
- <url_pagantis_mastarde translate="label" module="pagantis_pagantis">
58
- <label>URL Paga+Tarde</label>
59
- <frontend_type>text</frontend_type>
60
- <sort_order>12</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
- </url_pagantis_mastarde>
65
- <url_pagantis_mastarde_activated translate="label" module="pagantis_pagantis">
66
- <label>Activar forma de Paga+Tarde</label>
67
- <comment>Abilitando esta forma de pago el cliente podrá eligirla al momento de la compra</comment>
68
- <frontend_type>select</frontend_type>
69
- <source_model>adminhtml/system_config_source_yesno</source_model>
70
- <sort_order>13</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
- </url_pagantis_mastarde_activated>
75
- -->
76
- <environment translate="label" module="pagantis_pagantis">
77
- <label>Entorno</label>
78
- <comment>Elegir entorno de Test o Real</comment>
79
- <frontend_type>select</frontend_type>
80
- <source_model>pagantis_pagantis/source_payment_environment</source_model>
81
- <sort_order>14</sort_order>
82
- <show_in_default>1</show_in_default>
83
- <show_in_website>1</show_in_website>
84
- <show_in_store>1</show_in_store>
85
- </environment>
86
- <!-- we remove this to have easier config and same template in all modules, we try to get user locale -->
87
- <!--
88
- <language_payment_page translate="label" module="pagantis_pagantis">
89
- <label>Idioma Pagina De Pago</label>
90
- <comment>Elegir el idioma con el cual se abrirá la pagina de pago Pagantis. Por ejemplo ES, FR, EN</comment>
91
- <frontend_type>text</frontend_type>
92
- <sort_order>25</sort_order>
93
- <show_in_default>1</show_in_default>
94
- <show_in_website>1</show_in_website>
95
- <show_in_store>1</show_in_store>
96
- </language_payment_page>
97
-
98
- -->
99
- <!-- sha1 customer don't care about this -->
100
- <!--
101
- <auth_method translate="label" module="pagantis_pagantis">
102
- <label>Metodo de autenticación</label>
103
- <comment>Valor necesario para pagos con cobro único (SHA1)</comment>
104
- <frontend_type>text</frontend_type>
105
- <sort_order>15</sort_order>
106
- <show_in_default>1</show_in_default>
107
- <show_in_website>1</show_in_website>
108
- <show_in_store>1</show_in_store>
109
- </auth_method>
110
- -->
111
- <account_code_test translate="label" module="pagantis_pagantis">
112
- <label>Código de cuenta de Test</label>
113
- <frontend_type>text</frontend_type>
114
- <sort_order>17</sort_order>
115
- <show_in_default>1</show_in_default>
116
- <show_in_website>1</show_in_website>
117
- <show_in_store>1</show_in_store>
118
- </account_code_test>
119
- <account_key_test translate="label" module="pagantis_pagantis">
120
- <label>Clave de cuenta de Test</label>
121
- <frontend_type>text</frontend_type>
122
- <sort_order>18</sort_order>
123
- <show_in_default>1</show_in_default>
124
- <show_in_website>1</show_in_website>
125
- <show_in_store>1</show_in_store>
126
- </account_key_test>
127
- <!-- api key not needed to perform payment -->
128
- <!--
129
- <account_api_key_test translate="label" module="pagantis_pagantis">
130
- <label>API Key Test</label>
131
- <frontend_type>text</frontend_type>
132
- <sort_order>19</sort_order>
133
- <show_in_default>1</show_in_default>
134
- <show_in_website>1</show_in_website>
135
- <show_in_store>1</show_in_store>
136
- </account_api_key_test>
137
- -->
138
- <account_code_real translate="label" module="pagantis_pagantis">
139
- <label>Código de cuenta Real</label>
140
- <frontend_type>text</frontend_type>
141
- <sort_order>20</sort_order>
142
- <show_in_default>1</show_in_default>
143
- <show_in_website>1</show_in_website>
144
- <show_in_store>1</show_in_store>
145
- </account_code_real>
146
- <account_key_real translate="label" module="pagantis_pagantis">
147
- <label>Clave de cuenta Real</label>
148
- <frontend_type>text</frontend_type>
149
- <sort_order>21</sort_order>
150
- <show_in_default>1</show_in_default>
151
- <show_in_website>1</show_in_website>
152
- <show_in_store>1</show_in_store>
153
- </account_key_real>
154
- <!--
155
- <account_api_key_real translate="label" module="pagantis_pagantis">
156
- <label>API Key Real</label>
157
- <frontend_type>text</frontend_type>
158
- <sort_order>22</sort_order>
159
- <show_in_default>1</show_in_default>
160
- <show_in_website>1</show_in_website>
161
- <show_in_store>1</show_in_store>
162
- </account_api_key_real>
163
- -->
164
- <discount translate="label" module="pagantis_pagantis">
165
- <label>Descuento - asumir comisiones</label>
166
- <frontend_type>Select</frontend_type>
167
- <source_model>adminhtml/system_config_source_yesno</source_model>
168
- <sort_order>22</sort_order>
169
- <show_in_default>1</show_in_default>
170
- <show_in_website>1</show_in_website>
171
- <show_in_store>1</show_in_store>
172
- </discount>
173
- <sendmail translate="label" module="pagantis_pagantis">
174
- <label>Envía correo de confirma</label>
175
- <frontend_type>Select</frontend_type>
176
- <sort_order>40</sort_order>
177
- <source_model>adminhtml/system_config_source_yesno</source_model>
178
- <show_in_default>1</show_in_default>
179
- <show_in_website>1</show_in_website>
180
- <show_in_store>1</show_in_store>
181
- </sendmail>
182
- <invoice translate="label" module="pagantis_pagantis">
183
- <label>Crea factura automaticamente</label>
184
- <frontend_type>Select</frontend_type>
185
- <sort_order>50</sort_order>
186
- <source_model>adminhtml/system_config_source_yesno</source_model>
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
- </invoice>
191
- <sort_order translate="label" module="pagantis_pagantis">
192
- <label>Ordenación metodo de pago</label>
193
- <comment>Elegir en que posición tiene que salir el metodo de Pago Pagantis en el checkout</comment>
194
- <frontend_type>text</frontend_type>
195
- <sort_order>100</sort_order>
196
- <show_in_default>1</show_in_default>
197
- <show_in_website>1</show_in_website>
198
- <show_in_store>1</show_in_store>
199
- </sort_order>
200
- <!--<cron_settings translate="label comment" module="pagantis_pagantis">
201
- <label>Cuantas veces quieres ejecutar el proceso de sincronización de los pedidos?</label>
202
- <frontend_type>text</frontend_type>
203
- <sort_order>60</sort_order>
204
- <comment>Utiliza el formato Crontab (p.e. "0 4 * * *" para cada día a las 4 a.m.)</comment>
205
- <show_in_default>1</show_in_default>
206
- </cron_settings>-->
207
- </fields>
208
- </pagantis>
209
- </groups>
210
- </payment>
211
- </sections>
212
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/Pagantis/sql/pagantis_setup/mysql4-install-1.0.0.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- $installer->startSetup();
5
- $installer->addAttribute("order", "pagantis_transaction", array("type" => "varchar"));
6
- $installer->getConnection()->addColumn($installer->getTable('sales_flat_order_grid'), 'pagantis_transaction', 'varchar(255)');
7
- $installer->endSetup();
 
 
 
 
 
 
 
app/code/community/Pagantis/Pagantis/controllers/PagantisController.php CHANGED
@@ -19,10 +19,19 @@ class Pagantis_Pagantis_PagantisController extends Mage_Core_Controller_Front_Ac
19
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
20
  $session = Mage::getSingleton('checkout/session');
21
  $order = Mage::getModel('sales/order')->load($session->getLastOrderId());
22
- $order->setState($state, $state, Mage::helper('pagantis_pagantis')->__('Redirected to Pagantis'), false);
23
- $order->save();
24
- $session->getQuote()->setIsActive(false)->save();
25
- $session->clear();
 
 
 
 
 
 
 
 
 
26
 
27
  $cart = Mage::getSingleton('checkout/cart');
28
  $items = $order->getItemsCollection();
19
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
20
  $session = Mage::getSingleton('checkout/session');
21
  $order = Mage::getModel('sales/order')->load($session->getLastOrderId());
22
+ if ($order->data['total_due'] > 0){
23
+ //we come back from the form, we try to not duplicate the order
24
+ if ($order->data['total_due'] != $order->data['subtotal_incl_tax']){
25
+ //order changed
26
+ $order->setState($state, $state, Mage::helper('pagantis_pagantis')->__('Redirected to Pagantis'), false);
27
+ $order->save();
28
+ }else{
29
+ //order is the same, not saving new order
30
+ }
31
+ }
32
+
33
+ //$session->getQuote()->setIsActive(false)->save();
34
+ //$session->clear();
35
 
36
  $cart = Mage::getSingleton('checkout/cart');
37
  $items = $order->getItemsCollection();
app/code/community/Pagantis/Pagantis/etc/system.xml CHANGED
@@ -19,7 +19,7 @@
19
  <sort_order>1</sort_order>
20
  <show_in_default>1</show_in_default>
21
  <show_in_website>1</show_in_website>
22
- <show_in_store>0</show_in_store>
23
  </active>
24
  <title translate="label" module="pagantis_pagantis">
25
  <label>Título</label>
@@ -81,7 +81,7 @@
81
  <sort_order>14</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
84
- <show_in_store>0</show_in_store>
85
  </environment>
86
  <!-- we remove this to have easier config and same template in all modules, we try to get user locale -->
87
  <!--
@@ -109,20 +109,20 @@
109
  </auth_method>
110
  -->
111
  <account_code_test translate="label" module="pagantis_pagantis">
112
- <label>Código de cuenta de Test</label>
113
  <frontend_type>text</frontend_type>
114
  <sort_order>17</sort_order>
115
  <show_in_default>1</show_in_default>
116
  <show_in_website>1</show_in_website>
117
- <show_in_store>0</show_in_store>
118
  </account_code_test>
119
  <account_key_test translate="label" module="pagantis_pagantis">
120
- <label>Clave de cuenta de Test</label>
121
  <frontend_type>text</frontend_type>
122
  <sort_order>18</sort_order>
123
  <show_in_default>1</show_in_default>
124
  <show_in_website>1</show_in_website>
125
- <show_in_store>0</show_in_store>
126
  </account_key_test>
127
  <!-- api key not needed to perform payment -->
128
  <!--
@@ -136,20 +136,20 @@
136
  </account_api_key_test>
137
  -->
138
  <account_code_real translate="label" module="pagantis_pagantis">
139
- <label>Código de cuenta Real</label>
140
  <frontend_type>text</frontend_type>
141
  <sort_order>20</sort_order>
142
  <show_in_default>1</show_in_default>
143
  <show_in_website>1</show_in_website>
144
- <show_in_store>0</show_in_store>
145
  </account_code_real>
146
  <account_key_real translate="label" module="pagantis_pagantis">
147
- <label>Clave de cuenta Real</label>
148
  <frontend_type>text</frontend_type>
149
  <sort_order>21</sort_order>
150
  <show_in_default>1</show_in_default>
151
  <show_in_website>1</show_in_website>
152
- <show_in_store>0</show_in_store>
153
  </account_key_real>
154
  <!--
155
  <account_api_key_real translate="label" module="pagantis_pagantis">
@@ -169,7 +169,7 @@
169
  <sort_order>22</sort_order>
170
  <show_in_default>1</show_in_default>
171
  <show_in_website>1</show_in_website>
172
- <show_in_store>0</show_in_store>
173
  </discount>
174
  <sendmail translate="label" module="pagantis_pagantis">
175
  <label>Envía correo de confirmación</label>
@@ -178,7 +178,7 @@
178
  <source_model>adminhtml/system_config_source_yesno</source_model>
179
  <show_in_default>1</show_in_default>
180
  <show_in_website>1</show_in_website>
181
- <show_in_store>0</show_in_store>
182
  </sendmail>
183
  <invoice translate="label" module="pagantis_pagantis">
184
  <label>Crea factura automaticamente</label>
@@ -187,7 +187,7 @@
187
  <source_model>adminhtml/system_config_source_yesno</source_model>
188
  <show_in_default>1</show_in_default>
189
  <show_in_website>1</show_in_website>
190
- <show_in_store>0</show_in_store>
191
  </invoice>
192
  <sort_order translate="label" module="pagantis_pagantis">
193
  <label>Ordenación metodo de pago</label>
@@ -196,7 +196,7 @@
196
  <sort_order>100</sort_order>
197
  <show_in_default>1</show_in_default>
198
  <show_in_website>1</show_in_website>
199
- <show_in_store>0</show_in_store>
200
  </sort_order>
201
  <!--<cron_settings translate="label comment" module="pagantis_pagantis">
202
  <label>Cuantas veces quieres ejecutar el proceso de sincronización de los pedidos?</label>
19
  <sort_order>1</sort_order>
20
  <show_in_default>1</show_in_default>
21
  <show_in_website>1</show_in_website>
22
+ <show_in_store>1</show_in_store>
23
  </active>
24
  <title translate="label" module="pagantis_pagantis">
25
  <label>Título</label>
81
  <sort_order>14</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
  </environment>
86
  <!-- we remove this to have easier config and same template in all modules, we try to get user locale -->
87
  <!--
109
  </auth_method>
110
  -->
111
  <account_code_test translate="label" module="pagantis_pagantis">
112
+ <label>TEST Public Key</label>
113
  <frontend_type>text</frontend_type>
114
  <sort_order>17</sort_order>
115
  <show_in_default>1</show_in_default>
116
  <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
  </account_code_test>
119
  <account_key_test translate="label" module="pagantis_pagantis">
120
+ <label>TEST Secret Key</label>
121
  <frontend_type>text</frontend_type>
122
  <sort_order>18</sort_order>
123
  <show_in_default>1</show_in_default>
124
  <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
  </account_key_test>
127
  <!-- api key not needed to perform payment -->
128
  <!--
136
  </account_api_key_test>
137
  -->
138
  <account_code_real translate="label" module="pagantis_pagantis">
139
+ <label>REAL Public Key</label>
140
  <frontend_type>text</frontend_type>
141
  <sort_order>20</sort_order>
142
  <show_in_default>1</show_in_default>
143
  <show_in_website>1</show_in_website>
144
+ <show_in_store>1</show_in_store>
145
  </account_code_real>
146
  <account_key_real translate="label" module="pagantis_pagantis">
147
+ <label>Real Secret Key</label>
148
  <frontend_type>text</frontend_type>
149
  <sort_order>21</sort_order>
150
  <show_in_default>1</show_in_default>
151
  <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
  </account_key_real>
154
  <!--
155
  <account_api_key_real translate="label" module="pagantis_pagantis">
169
  <sort_order>22</sort_order>
170
  <show_in_default>1</show_in_default>
171
  <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
  </discount>
174
  <sendmail translate="label" module="pagantis_pagantis">
175
  <label>Envía correo de confirmación</label>
178
  <source_model>adminhtml/system_config_source_yesno</source_model>
179
  <show_in_default>1</show_in_default>
180
  <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
  </sendmail>
183
  <invoice translate="label" module="pagantis_pagantis">
184
  <label>Crea factura automaticamente</label>
187
  <source_model>adminhtml/system_config_source_yesno</source_model>
188
  <show_in_default>1</show_in_default>
189
  <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
  </invoice>
192
  <sort_order translate="label" module="pagantis_pagantis">
193
  <label>Ordenación metodo de pago</label>
196
  <sort_order>100</sort_order>
197
  <show_in_default>1</show_in_default>
198
  <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
  </sort_order>
201
  <!--<cron_settings translate="label comment" module="pagantis_pagantis">
202
  <label>Cuantas veces quieres ejecutar el proceso de sincronización de los pedidos?</label>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Pagantis_Pagantis</name>
4
- <version>2.2.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GPL</license>
7
  <channel>community</channel>
@@ -10,11 +10,11 @@
10
  <description>Paga+Tarde is an online payment method through which e-commerce websites offer their customers an easy and safe way to make deferred payments.&#xD;
11
  &#xD;
12
  Buyers can choose to pay in up to 12 installments. At the same time, the shops will receive the total amount of the sale, without taking any risk.</description>
13
- <notes>- the cart is kept if user goes back from payment page</notes>
14
  <authors><author><name>Albert Fatsini</name><user>auto-converted</user><email>afatsini@digitalorigin.com</email></author></authors>
15
- <date>2016-01-12</date>
16
- <time>12:03:36</time>
17
- <contents><target name="magecommunity"><dir name="Pagantis"><dir name="Pagantis"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="7c2b0d3c7a7bf6d4a9ac02a5b6125af3"/></dir></dir></dir></dir><file name="Form.php" hash="9ad1e01301a0edd832eb472d2a8a8161"/><file name="Redirect.php" hash="24fef0caf8b76c629b75e2d4acc81443"/></dir><dir name="Helper"><file name="Data.php" hash="e90849a9b9310979d58f7a092d2d2a28"/></dir><dir name="Model"><dir name="Source"><dir name="Payment"><file name="Currency.php" hash="7e51124f09e2028198fb9587df820809"/><file name="Environment.php" hash="30d6400967acdd8975c5748994c100e6"/></dir></dir><dir name="Webservice"><file name="Client.php" hash="6a14e0ae7ef5180445a3a99aec4717bb"/><file name="Paymentrequest.php" hash="dcf473ea7211a82b55b5374549c3cfc0"/><file name="Request.php" hash="2ec10b3effa42ddacb97b626ec359b02"/><file name="Requestloan.php" hash="dcda641a815368e5c2c4c0b70c4f668c"/><file name="Response.php" hash="bb1ade5931c5580f4585fc0fdb2bc4b0"/></dir><file name="Currency.php" hash="a5557e10938898b0213a90dd7be15540"/><file name="Observer.php" hash="0c2a7b1b4ca273b482600b6e9e030ad9"/><file name="Payment.php" hash="737a295dbc465fe2333b187716c81077"/><file name=".Payment.php.swp" hash="3d8604107de061df66cb45ae029bd394"/></dir><dir name="Pagantis"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="285814ecab6b4e338e75a370f41fdc12"/></dir></dir></dir></dir><file name="Form.php" hash="7d934dc68b5c92d438d32ffa0727a0f9"/><file name="Redirect.php" hash="24fef0caf8b76c629b75e2d4acc81443"/></dir><dir name="Helper"><file name="Data.php" hash="e90849a9b9310979d58f7a092d2d2a28"/></dir><dir name="Model"><dir name="Source"><dir name="Payment"><file name="Currency.php" hash="7e51124f09e2028198fb9587df820809"/><file name="Environment.php" hash="30d6400967acdd8975c5748994c100e6"/></dir></dir><dir name="Webservice"><file name="Client.php" hash="6a14e0ae7ef5180445a3a99aec4717bb"/><file name="Paymentrequest.php" hash="dcf473ea7211a82b55b5374549c3cfc0"/><file name="Request.php" hash="76506a6627d6523aae845169854f4ece"/><file name="Requestloan.php" hash="6b3a8045810226ed72362772d84012bd"/><file name="Response.php" hash="bb1ade5931c5580f4585fc0fdb2bc4b0"/></dir><file name="Currency.php" hash="a5557e10938898b0213a90dd7be15540"/><file name="Observer.php" hash="0c2a7b1b4ca273b482600b6e9e030ad9"/><file name="Payment.php" hash="13002f5a27466a85d020d7fb41cf8633"/></dir><dir name="controllers"><file name="PagantisController.php" hash="f3a77cb8fc003bd03bd680913ace6f40"/></dir><dir name="etc"><file name="config.xml" hash="a10e521ef5101e10d0b7aa61c2b76370"/><file name="system.xml" hash="6d15f34f3aa3429501cb6d1f9b8ec458"/></dir><dir name="sql"><dir name="pagantis_setup"><file name="mysql4-install-1.0.0.php" hash="4ec10724709f8d381758409f55cff99d"/></dir></dir></dir><dir name="controllers"><file name="PagantisController.php" hash="70d7adfd427aba6427e2bcc2ff0c177a"/></dir><dir name="etc"><file name="config.xml" hash="a10e521ef5101e10d0b7aa61c2b76370"/><file name="system.xml" hash="854549934e085e76ee932727fed64f23"/></dir><dir name="sql"><dir name="pagantis_setup"><file name="mysql4-install-1.0.0.php" hash="4ec10724709f8d381758409f55cff99d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pagantis.xml" hash="4328e44e218a0996f4e2412c545a8e9b"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pagantis.xml" hash="6a13e760f9edb35dc2b5ac4cd2ac11f0"/></dir><dir name="template"><dir name="pagantis"><file name="form.phtml" hash="11cf70a55d8ec9e8ae3c1d94a832eeab"/><file name="pagantis.phtml" hash="3024436be4e339669f7ebf590f6c03a9"/><file name="redirect.phtml" hash="3d7d1a5076fc98269e5a7f476be27650"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pagantis_Pagantis.xml" hash="c57db60bd03314d7a45f27acc9a9475a"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><file name="pagantis.css" hash="7d1b6daea9f42c2552ebb5bd5c15596d"/></dir></dir><dir name="default"><dir name="default"><dir name="images"><dir name="pagantis"><file name="logopagamastarde.png" hash="d51fa42e42d9811653df55710a395d07"/><file name="pagantis.png" hash="292403ede1f62affccf06df004ddfe12"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="pagantis"><file name="logopagamastarde.png" hash="d51fa42e42d9811653df55710a395d07"/><file name="pagantis-fav.png" hash="c4e162b51c0792ff25385506d7998818"/><file name="pagantis.png" hash="292403ede1f62affccf06df004ddfe12"/></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Pagantis_Pagantis</name>
4
+ <version>2.2.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GPL</license>
7
  <channel>community</channel>
10
  <description>Paga+Tarde is an online payment method through which e-commerce websites offer their customers an easy and safe way to make deferred payments.&#xD;
11
  &#xD;
12
  Buyers can choose to pay in up to 12 installments. At the same time, the shops will receive the total amount of the sale, without taking any risk.</description>
13
+ <notes>Fix http 302 error on notifications when magento have SSL configured in frontend</notes>
14
  <authors><author><name>Albert Fatsini</name><user>auto-converted</user><email>afatsini@digitalorigin.com</email></author></authors>
15
+ <date>2016-03-08</date>
16
+ <time>08:41:38</time>
17
+ <contents><target name="magecommunity"><dir name="Pagantis"><dir name="Pagantis"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="7c2b0d3c7a7bf6d4a9ac02a5b6125af3"/></dir></dir></dir></dir><file name="Form.php" hash="9ad1e01301a0edd832eb472d2a8a8161"/><file name="Redirect.php" hash="24fef0caf8b76c629b75e2d4acc81443"/></dir><dir name="Helper"><file name="Data.php" hash="e90849a9b9310979d58f7a092d2d2a28"/></dir><dir name="Model"><dir name="Source"><dir name="Payment"><file name="Currency.php" hash="7e51124f09e2028198fb9587df820809"/><file name="Environment.php" hash="30d6400967acdd8975c5748994c100e6"/></dir></dir><dir name="Webservice"><file name="Client.php" hash="6a14e0ae7ef5180445a3a99aec4717bb"/><file name="Paymentrequest.php" hash="dcf473ea7211a82b55b5374549c3cfc0"/><file name="Request.php" hash="0b01db7cdb0cbc691218fb84c2e8ce1e"/><file name="Requestloan.php" hash="df7dd8bb75a64ef9b0e48b3ee7795f98"/><file name="Response.php" hash="bb1ade5931c5580f4585fc0fdb2bc4b0"/></dir><file name="Currency.php" hash="a5557e10938898b0213a90dd7be15540"/><file name="Observer.php" hash="0c2a7b1b4ca273b482600b6e9e030ad9"/><file name="Payment.php" hash="737a295dbc465fe2333b187716c81077"/><file name=".Payment.php.swp" hash="3d8604107de061df66cb45ae029bd394"/></dir><dir name="controllers"><file name="PagantisController.php" hash="a7a4524e8e353e917f3867da669ffba3"/></dir><dir name="etc"><file name="config.xml" hash="a10e521ef5101e10d0b7aa61c2b76370"/><file name="system.xml" hash="494ce967feb8149a15666c95a3dbf03f"/></dir><dir name="sql"><dir name="pagantis_setup"><file name="mysql4-install-1.0.0.php" hash="4ec10724709f8d381758409f55cff99d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pagantis.xml" hash="4328e44e218a0996f4e2412c545a8e9b"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pagantis.xml" hash="6a13e760f9edb35dc2b5ac4cd2ac11f0"/></dir><dir name="template"><dir name="pagantis"><file name="form.phtml" hash="11cf70a55d8ec9e8ae3c1d94a832eeab"/><file name="pagantis.phtml" hash="3024436be4e339669f7ebf590f6c03a9"/><file name="redirect.phtml" hash="3d7d1a5076fc98269e5a7f476be27650"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pagantis_Pagantis.xml" hash="c57db60bd03314d7a45f27acc9a9475a"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><file name="pagantis.css" hash="7d1b6daea9f42c2552ebb5bd5c15596d"/></dir></dir><dir name="default"><dir name="default"><dir name="images"><dir name="pagantis"><file name="logopagamastarde.png" hash="d51fa42e42d9811653df55710a395d07"/><file name="pagantis.png" hash="292403ede1f62affccf06df004ddfe12"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="pagantis"><file name="logopagamastarde.png" hash="d51fa42e42d9811653df55710a395d07"/><file name="pagantis-fav.png" hash="c4e162b51c0792ff25385506d7998818"/><file name="pagantis.png" hash="292403ede1f62affccf06df004ddfe12"/></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>