Version Notes
[EN] - template updates
[PT] - update dos templates
Download this release
Release Info
Developer | Eupago |
Extension | Eupago_MB |
Version | 1.1.9 |
Comparing to | |
See all releases |
Code changes from version 1.1.8 to 1.1.9
- app/code/community/Eupago/Multibanco/Model/Multibanco.php +1 -1
- app/code/community/Eupago/Multibanco/Model/System/Config/Template.php +2 -2
- app/code/community/Eupago/Multibanco/controllers/CallbackController.php +5 -118
- app/code/community/Eupago/Multibanco/etc/config.xml +10 -0
- app/code/community/Eupago/Multibanco/etc/system.xml +1 -1
- app/design/frontend/base/default/template/eupago/multibanco/info/multibanco.phtml +6 -6
- package.xml +6 -6
app/code/community/Eupago/Multibanco/Model/Multibanco.php
CHANGED
@@ -98,7 +98,7 @@ class Eupago_Multibanco_Model_Multibanco extends Mage_Payment_Model_Method_Abstr
|
|
98 |
if($result == false) {
|
99 |
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
100 |
} else {
|
101 |
-
if(($result->estado_referencia == 'paga' || $result->estado_referencia == 'transferida')
|
102 |
&& $payment->getOrder()->getBaseTotalDue() == $result->valor){
|
103 |
// neste sistema altera logo para pago
|
104 |
$payment->setTransactionId($referencia."-capture");
|
98 |
if($result == false) {
|
99 |
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
100 |
} else {
|
101 |
+
if(($result->estado_referencia == 'paga' || $result->estado_referencia == 'transferida' || $result->estado_referencia == "em processamento")
|
102 |
&& $payment->getOrder()->getBaseTotalDue() == $result->valor){
|
103 |
// neste sistema altera logo para pago
|
104 |
$payment->setTransactionId($referencia."-capture");
|
app/code/community/Eupago/Multibanco/Model/System/Config/Template.php
CHANGED
@@ -9,8 +9,8 @@ class Eupago_Multibanco_Model_System_Config_Template
|
|
9 |
public function toOptionArray()
|
10 |
{
|
11 |
return array(
|
12 |
-
array('value' => 'nenhum', 'label' => Mage::helper('adminhtml')->__('Nenhum')),
|
13 |
array('value' => 'multibanco', 'label' => Mage::helper('adminhtml')->__('Multibanco')),
|
|
|
14 |
);
|
15 |
}
|
16 |
|
@@ -22,8 +22,8 @@ class Eupago_Multibanco_Model_System_Config_Template
|
|
22 |
public function toArray()
|
23 |
{
|
24 |
return array(
|
25 |
-
'nenhum' => Mage::helper('adminhtml')->__('Nenhum'),
|
26 |
'multibanco' => Mage::helper('adminhtml')->__('Multibanco'),
|
|
|
27 |
);
|
28 |
}
|
29 |
}
|
9 |
public function toOptionArray()
|
10 |
{
|
11 |
return array(
|
|
|
12 |
array('value' => 'multibanco', 'label' => Mage::helper('adminhtml')->__('Multibanco')),
|
13 |
+
array('value' => 'nenhum', 'label' => Mage::helper('adminhtml')->__('Nenhum')),
|
14 |
);
|
15 |
}
|
16 |
|
22 |
public function toArray()
|
23 |
{
|
24 |
return array(
|
|
|
25 |
'multibanco' => Mage::helper('adminhtml')->__('Multibanco'),
|
26 |
+
'nenhum' => Mage::helper('adminhtml')->__('Nenhum'),
|
27 |
);
|
28 |
}
|
29 |
}
|
app/code/community/Eupago/Multibanco/controllers/CallbackController.php
CHANGED
@@ -24,7 +24,10 @@ class Eupago_Multibanco_CallbackController extends Mage_Core_Controller_Front_Ac
|
|
24 |
default:
|
25 |
exit("método de pagamento inválido");
|
26 |
}
|
27 |
-
|
|
|
|
|
|
|
28 |
// valida metodo de pagamento
|
29 |
if(!isset($callBack_params->mp) || $method != $metodo_callback)
|
30 |
exit("método de pagamento não corresponde ao da encomenda");
|
@@ -55,6 +58,7 @@ class Eupago_Multibanco_CallbackController extends Mage_Core_Controller_Front_Ac
|
|
55 |
|
56 |
// marca como paga ou gera fatura
|
57 |
if($this->validaTransacao($callBack_params, $order)){
|
|
|
58 |
if(class_exists('SOAPClient'))
|
59 |
$this->capture($order);
|
60 |
else
|
@@ -156,123 +160,6 @@ class Eupago_Multibanco_CallbackController extends Mage_Core_Controller_Front_Ac
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
-
// CALLBACK ANTIGO FICARÁ DEPRECATED NA PROXIMA VERSÃO
|
160 |
-
public function autorizeAction(){
|
161 |
-
|
162 |
-
///// dados vindos da api para comfirmar
|
163 |
-
$CallBack = $this->getRequest()->getParams();
|
164 |
-
$CallBack_valor = $CallBack['valor'];
|
165 |
-
$CallBack_referencia = $CallBack['referencia'];
|
166 |
-
$CallBack_chave_api = $CallBack['chave_api'];
|
167 |
-
$CallBack_orderId = $CallBack['identificador'];
|
168 |
-
|
169 |
-
////// dados de encomenda
|
170 |
-
$OrderNumber = $CallBack_orderId; //$CallBack_orderId vaem da api Eupago[order-id]
|
171 |
-
$order = Mage::getModel('sales/order')->load($OrderNumber, 'increment_id');
|
172 |
-
$valor_encomenda = $order->grand_total; //retirado do valor total da encomenda
|
173 |
-
|
174 |
-
/////// dados do pagamento
|
175 |
-
$pagamento = $order->getPayment();
|
176 |
-
|
177 |
-
// se não existir dados de pagamento antigos chama o novo callback
|
178 |
-
if($pagamento->eupago_referencia == null || $pagamento->eupago_referencia == "" ){
|
179 |
-
// carrega dados de callback e encomenda
|
180 |
-
$callBack_params = (object)$CallBack;
|
181 |
-
$method = $order->getPayment()->getMethod();
|
182 |
-
$metodo_callback = null;
|
183 |
-
switch(urldecode($callBack_params->mp)){
|
184 |
-
case 'PC:PT':
|
185 |
-
$metodo_callback = "multibanco";
|
186 |
-
break;
|
187 |
-
case 'MW:PT':
|
188 |
-
$metodo_callback = "mbway";
|
189 |
-
break;
|
190 |
-
default:
|
191 |
-
exit("método de pagamento inválido");
|
192 |
-
}
|
193 |
-
|
194 |
-
// valida metodo de pagamento
|
195 |
-
if(!isset($callBack_params->mp) || $method != $metodo_callback)
|
196 |
-
exit("método de pagamento não corresponde ao da encomenda");
|
197 |
-
|
198 |
-
// valida chave API
|
199 |
-
if($callBack_params->chave_api != Mage::getStoreConfig('payment/'.$metodo_callback.'/chave'))
|
200 |
-
exit("chave API inválida");
|
201 |
-
|
202 |
-
// valida order_id
|
203 |
-
if($order->getId() == null)
|
204 |
-
exit("a encomenda não existe");
|
205 |
-
|
206 |
-
// valida estado da encomenda
|
207 |
-
if($order->getStatus() == "canceled") // devemos validar se esta completa?
|
208 |
-
exit("não foi possivel concluir o pagamento porque o estado da encomenda é: ".$order_status);
|
209 |
-
|
210 |
-
// valida valor da encomenda -> comentar no caso de premitir pagamento parcial
|
211 |
-
if($order->getGrandTotal() != $callBack_params->valor)
|
212 |
-
exit ("O valor da encomenda e o valor pago não correspondem!");
|
213 |
-
|
214 |
-
// verifica se a encomenda já está paga
|
215 |
-
if($order->getBaseTotalDue() == 0)
|
216 |
-
exit("A encomenda já se encontra paga!");
|
217 |
-
|
218 |
-
// valida valor por pagar
|
219 |
-
if($order->getBaseTotalDue() < $callBack_params->valor)
|
220 |
-
exit("O valor a pagamento é inferior ao valor pago!");
|
221 |
-
|
222 |
-
// marca como paga ou gera fatura
|
223 |
-
if($this->validaTransacao($callBack_params, $order)){
|
224 |
-
if(class_exists('SOAPClient'))
|
225 |
-
$this->capture($order);
|
226 |
-
else
|
227 |
-
$this->marcaComoPaga($order, $callBack_params->valor, true); // -> para usar para marcar como paga sem gerar fatura
|
228 |
-
}
|
229 |
-
return;
|
230 |
-
}
|
231 |
-
|
232 |
-
/////// dados do pagamento antigos
|
233 |
-
$entidade = $pagamento->eupago_entidade;
|
234 |
-
$referencia = str_pad($pagamento->eupago_referencia, 9, "0", STR_PAD_LEFT);
|
235 |
-
$valor_gerado = $pagamento->eupago_montante;
|
236 |
-
|
237 |
-
/////// gera autorizacao
|
238 |
-
$chave_api = Mage::getStoreConfig('payment/multibanco/chave');
|
239 |
-
|
240 |
-
//////// Confere dados
|
241 |
-
$confere_montantes = (($valor_encomenda == $valor_gerado) == $CallBack_valor ? true : false);
|
242 |
-
$confere_referencia = ($referencia == $CallBack_referencia ? true : false);
|
243 |
-
$confere_chave_api = ($CallBack_chave_api == $chave_api ? true : false);
|
244 |
-
|
245 |
-
|
246 |
-
////// se tudo ok, faz o update do estado da encomenda e envia um email ao cliente
|
247 |
-
if($confere_montantes && $confere_chave_api && $confere_referencia){ /*futuro upgrade -> $confere_autorizacao*/
|
248 |
-
|
249 |
-
$order->setData('state', "complete");
|
250 |
-
$order->setStatus("processing");
|
251 |
-
$order->sendOrderUpdateEmail();
|
252 |
-
|
253 |
-
//////// hack for generate invoice automatically
|
254 |
-
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
255 |
-
if (!$invoice->getTotalQty()) {
|
256 |
-
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
|
257 |
-
}
|
258 |
-
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
|
259 |
-
$invoice->register();
|
260 |
-
$transactionSave = Mage::getModel('core/resource_transaction')
|
261 |
-
->addObject($invoice)
|
262 |
-
->addObject($invoice->getOrder());
|
263 |
-
$transactionSave->save();
|
264 |
-
////////////////
|
265 |
-
|
266 |
-
$history = $order->addStatusHistoryComment('Order marked as complete automatically.', false);
|
267 |
-
$history->setIsCustomerNotified(true);
|
268 |
-
$order->save();
|
269 |
-
|
270 |
-
echo "alterado para pago..";
|
271 |
-
}else{
|
272 |
-
echo "os valores de pagamento não correspondem com os da encomenda";
|
273 |
-
}
|
274 |
-
}
|
275 |
-
|
276 |
private function marcaComoPaga($order,$valor_pago,$geraFatura = false){
|
277 |
$order->setData('state', "complete");
|
278 |
$order->setStatus("processing");
|
24 |
default:
|
25 |
exit("método de pagamento inválido");
|
26 |
}
|
27 |
+
|
28 |
+
// devolvemos forbidden por defeito
|
29 |
+
http_response_code(403);
|
30 |
+
|
31 |
// valida metodo de pagamento
|
32 |
if(!isset($callBack_params->mp) || $method != $metodo_callback)
|
33 |
exit("método de pagamento não corresponde ao da encomenda");
|
58 |
|
59 |
// marca como paga ou gera fatura
|
60 |
if($this->validaTransacao($callBack_params, $order)){
|
61 |
+
http_response_code(200);
|
62 |
if(class_exists('SOAPClient'))
|
63 |
$this->capture($order);
|
64 |
else
|
160 |
}
|
161 |
}
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
private function marcaComoPaga($order,$valor_pago,$geraFatura = false){
|
164 |
$order->setData('state', "complete");
|
165 |
$order->setStatus("processing");
|
app/code/community/Eupago/Multibanco/etc/config.xml
CHANGED
@@ -41,7 +41,17 @@
|
|
41 |
</observers>
|
42 |
</sales_order_invoice_save_after>
|
43 |
</events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
</global>
|
|
|
45 |
<frontend>
|
46 |
<routers>
|
47 |
<Eupago_Multibanco>
|
41 |
</observers>
|
42 |
</sales_order_invoice_save_after>
|
43 |
</events>
|
44 |
+
<sales>
|
45 |
+
<order>
|
46 |
+
<states>
|
47 |
+
<pending_payment>
|
48 |
+
<visible_on_front>1</visible_on_front>
|
49 |
+
</pending_payment>
|
50 |
+
</states>
|
51 |
+
</order>
|
52 |
+
</sales>
|
53 |
</global>
|
54 |
+
|
55 |
<frontend>
|
56 |
<routers>
|
57 |
<Eupago_Multibanco>
|
app/code/community/Eupago/Multibanco/etc/system.xml
CHANGED
@@ -33,7 +33,7 @@
|
|
33 |
<frontend_type>text</frontend_type>
|
34 |
<sort_order>3</sort_order>
|
35 |
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>
|
37 |
<show_in_store>0</show_in_store>
|
38 |
</chave>
|
39 |
<send_invoice_email translate="label">
|
33 |
<frontend_type>text</frontend_type>
|
34 |
<sort_order>3</sort_order>
|
35 |
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
<show_in_store>0</show_in_store>
|
38 |
</chave>
|
39 |
<send_invoice_email translate="label">
|
app/design/frontend/base/default/template/eupago/multibanco/info/multibanco.phtml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<
|
2 |
<?php
|
3 |
$multibanco_data = $this->getMultibancoData();
|
4 |
if(isset($multibanco_data->referencia) && $multibanco_data->referencia != ""){?>
|
5 |
-
<
|
6 |
<div align='center'>
|
7 |
<table style="width:100%; padding:5px; font-size: 11px; color: #374953; margin:0 auto;">
|
8 |
<tbody>
|
@@ -33,11 +33,11 @@
|
|
33 |
</tbody>
|
34 |
</table>
|
35 |
</div>
|
36 |
-
</
|
37 |
<?php }else{
|
38 |
-
echo "<li>";
|
39 |
echo "<h4>Multibanco</h4>";
|
40 |
echo $this->__('Os dados para pagamento multibanco serão apresentados quando finalizar a sua encomenda e/ou enviados para o seu e-mail.');
|
41 |
-
echo "</li>";
|
42 |
}?>
|
43 |
-
</
|
1 |
+
<div id="payment_info_<?php echo $this->getMethodCode() ?>">
|
2 |
<?php
|
3 |
$multibanco_data = $this->getMultibancoData();
|
4 |
if(isset($multibanco_data->referencia) && $multibanco_data->referencia != ""){?>
|
5 |
+
<div style="min-width: 350px;">
|
6 |
<div align='center'>
|
7 |
<table style="width:100%; padding:5px; font-size: 11px; color: #374953; margin:0 auto;">
|
8 |
<tbody>
|
33 |
</tbody>
|
34 |
</table>
|
35 |
</div>
|
36 |
+
</div>
|
37 |
<?php }else{
|
38 |
+
echo "<ul><li>";
|
39 |
echo "<h4>Multibanco</h4>";
|
40 |
echo $this->__('Os dados para pagamento multibanco serão apresentados quando finalizar a sua encomenda e/ou enviados para o seu e-mail.');
|
41 |
+
echo "</li></ul>";
|
42 |
}?>
|
43 |
+
</div>
|
package.xml
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eupago_MB</name>
|
4 |
-
<version>1.1.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Pagamento por Multibanco</summary>
|
10 |
<description>Permite pagamentos através de referências multibanco</description>
|
11 |
-
<notes>[EN] -
|
12 |
-
[PT] - update
|
13 |
<authors><author><name>Eupago</name><user>eupago</user><email>suporte@eupago.pt</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="Eupago"><dir name="Multibanco"><dir name="Block"><dir name="Form"><file name="Multibanco.php" hash="a526f756cd407a159a5438efefa0d66f"/></dir><dir name="Info"><file name="Multibanco.php" hash="7cec344b458fb7f5b0eb49b488434e7a"/></dir><dir name="Onepage"><file name="Success.php" hash="9da0851f53a89abeb25602d3c94a2612"/></dir></dir><dir name="Model"><file name="Multibanco.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eupago_MB</name>
|
4 |
+
<version>1.1.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Pagamento por Multibanco</summary>
|
10 |
<description>Permite pagamentos através de referências multibanco</description>
|
11 |
+
<notes>[EN] - template updates
|
12 |
+
[PT] - update dos templates</notes>
|
13 |
<authors><author><name>Eupago</name><user>eupago</user><email>suporte@eupago.pt</email></author></authors>
|
14 |
+
<date>2017-05-15</date>
|
15 |
+
<time>15:48:37</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Eupago"><dir name="Multibanco"><dir name="Block"><dir name="Form"><file name="Multibanco.php" hash="a526f756cd407a159a5438efefa0d66f"/></dir><dir name="Info"><file name="Multibanco.php" hash="7cec344b458fb7f5b0eb49b488434e7a"/></dir><dir name="Onepage"><file name="Success.php" hash="9da0851f53a89abeb25602d3c94a2612"/></dir></dir><dir name="Model"><file name="Multibanco.php" hash="7d18ec7292dd7b1071ca2883ab94b181"/><file name="Observer.php" hash="e2d025bab8e439827612ce09f65030b7"/><dir name="System"><dir name="Config"><file name="Template.php" hash="a17992170858c4c05ef4e44e3c4a9ec7"/></dir></dir></dir><dir name="controllers"><file name="CallbackController.php" hash="83379164ea3260b41249e59fe02ae322"/></dir><dir name="etc"><file name="config.xml" hash="dafac2e1b2d0ebe16ad7d9bf963f5169"/><file name="system.xml" hash="e4bce2fe3ab31f60c8b122749bbc40b3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eupago_Multibanco.xml" hash="87ee673b7cd7ec1dbc44cf2a0ef0f0c3"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="eupago"><dir name="multibanco"><dir name="checkout"><file name="success.phtml" hash="65c0fbce628ecdb41855475826cbbc2b"/></dir><dir name="info"><file name="default.phtml" hash="587ea28be59d4ac1c18c857e429382da"/><file name="multibanco.phtml" hash="db684e15611d9bfed1e9c2d1d499205d"/></dir></dir></dir></dir><dir name="layout"><file name="eupago_multibanco.xml" hash="e3fbf5f655164991b363b305e09b0953"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="eupago"><dir name="multibanco"><dir name="info"><file name="multibanco.phtml" hash="47d133c69fb6121b648037995c868740"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="eupago"><dir name="multibanco"><file name="eupago_mb_p.png" hash="6db08f88f1f4770337db63105a4f0f08"/><file name="multibanco_icon.png" hash="87425d6e05c42ae6780b16ca8379d97a"/></dir></dir></dir></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|