Version Notes
"MercadoPago v2.1.2
New internal module file structure
- Javascript code refactored
- New plugin configuration layout
- Added Customers & Cards feature
- Magento orders now contain subtotals related to MP coupons and financing cost.
- Document type and card token validation on checkout
- Venezuela added as available country.
- Compatibility with OSC extensions innovarti and ideasa
MercadoEnvios 0.1.0
- New module available for Argentina, Brazil and Mexico only with Standard Checkout
- Package size and weight attributes can be mapped with magento attributes, and its units can be converted through admin panel.
- Different shipping methods per country can be enabled/disabled.
- Shipping cost is calculated and shown in cart page and checkout.
- Free shipping option is available.
- Tracking information order can be accessed through order details admin section or my account.
- Shipping label can be printed through order details admin section."
Release Info
Developer | Developers MercadoPago Brasil |
Extension | MercadoPagoTransparent |
Version | 0.0.4 |
Comparing to | |
See all releases |
Code changes from version 0.0.3 to 0.0.4
- app/code/community/MercadoPago/Block/Custom/Form.php +0 -72
- app/code/community/MercadoPago/Block/Custom/Info.php +0 -37
- app/code/community/MercadoPago/Block/Customticket/Form.php +0 -69
- app/code/community/MercadoPago/Block/Customticket/Info.php +0 -38
- app/code/community/MercadoPago/Block/Standard/Form.php +0 -27
- app/code/community/MercadoPago/Block/Standard/Info.php +0 -40
- app/code/community/MercadoPago/Block/Standard/Pay.php +0 -27
- app/code/community/MercadoPago/Core/Block/AbstractForm.php +35 -0
- app/code/community/MercadoPago/{Block/Success.php → Core/Block/AbstractSuccess.php} +37 -48
- app/code/community/MercadoPago/Core/Block/Adminhtml/System/Config/Fieldset/Payment.php +50 -0
- app/code/community/MercadoPago/Core/Block/Custom/Form.php +55 -0
- app/code/community/MercadoPago/Core/Block/Custom/Info.php +39 -0
- app/code/community/MercadoPago/Core/Block/Custom/Success.php +12 -0
- app/code/community/MercadoPago/Core/Block/Customticket/Form.php +44 -0
- app/code/community/MercadoPago/Core/Block/Customticket/Info.php +40 -0
- app/code/community/MercadoPago/Core/Block/Customticket/Success.php +12 -0
- app/code/community/MercadoPago/Core/Block/Discount.php +26 -0
- app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Discount/Coupon.php +29 -0
- app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Finance/Cost.php +29 -0
- app/code/community/MercadoPago/Core/Block/Standard/Form.php +27 -0
- app/code/community/MercadoPago/Core/Block/Standard/Info.php +40 -0
- app/code/community/MercadoPago/Core/Block/Standard/Pay.php +27 -0
- app/code/community/MercadoPago/Core/Block/Standard/Success.php +12 -0
- app/code/community/MercadoPago/Core/Helper/Data.php +221 -0
- app/code/community/MercadoPago/Core/Helper/Message/Abstract.php +26 -0
- app/code/community/MercadoPago/Core/Helper/Response.php +32 -0
- app/code/community/MercadoPago/Core/Helper/StatusDetailMessage.php +28 -0
- app/code/community/MercadoPago/Core/Helper/StatusMessage.php +47 -0
- app/code/community/MercadoPago/Core/Helper/StatusOrderMessage.php +21 -0
- app/code/community/MercadoPago/Core/Model/Api/Exception.php +34 -0
- app/code/community/MercadoPago/Core/Model/Api/V0/Exception.php +20 -0
- app/code/community/MercadoPago/Core/Model/Api/V1/Exception.php +43 -0
- app/code/community/MercadoPago/Core/Model/Core.php +552 -0
- app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost.php +59 -0
- app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Creditmemo.php +24 -0
- app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Invoice.php +24 -0
- app/code/community/MercadoPago/Core/Model/Custom/Payment.php +279 -0
- app/code/community/MercadoPago/Core/Model/CustomPayment.php +94 -0
- app/code/community/MercadoPago/Core/Model/CustomTicket/Payment.php +115 -0
- app/code/community/MercadoPago/Core/Model/Discount/Coupon.php +57 -0
- app/code/community/MercadoPago/Core/Model/Discount/Coupon/Creditmemo.php +24 -0
- app/code/community/MercadoPago/Core/Model/Discount/Coupon/Invoice.php +24 -0
- app/code/community/MercadoPago/Core/Model/Observer.php +181 -0
- app/code/community/MercadoPago/Core/Model/Source/CategoryId.php +47 -0
- app/code/community/MercadoPago/Core/Model/Source/Country.php +46 -0
- app/code/community/MercadoPago/Core/Model/Source/Installments.php +43 -0
- app/code/community/MercadoPago/Core/Model/Source/Order/Status.php +18 -0
- app/code/community/MercadoPago/Core/Model/Source/PaymentMethods.php +65 -0
- app/code/community/MercadoPago/{Block/Discount.php → Core/Model/Source/TypeCheckout.php} +11 -7
- app/code/community/MercadoPago/Core/Model/Standard/Payment.php +318 -0
- app/code/community/MercadoPago/Core/controllers/ApiController.php +82 -0
- app/code/community/MercadoPago/Core/controllers/NotificationsController.php +207 -0
- app/code/community/MercadoPago/Core/controllers/PayController.php +44 -0
- app/code/community/MercadoPago/Core/controllers/SuccessController.php +67 -0
- app/code/community/MercadoPago/{etc → Core/etc}/config.xml +103 -55
- app/code/community/MercadoPago/Core/etc/system.xml +448 -0
- app/code/community/MercadoPago/Core/sql/mercadopago_setup/install-2.1.0.php +22 -0
- app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.0-2.1.1.php +23 -0
- app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.1-2.1.2.php +25 -0
- app/code/community/MercadoPago/Helper/Data.php +0 -32
- app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Carrier.php +60 -0
- app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Mapping.php +51 -0
- app/code/community/MercadoPago/MercadoEnvios/Helper/Data.php +266 -0
- app/code/community/MercadoPago/MercadoEnvios/Helper/ItemData.php +20 -0
- app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Attribute/Validation/Mapping.php +22 -0
- app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/FreeMethod.php +14 -0
- app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/Method.php +30 -0
- app/code/community/MercadoPago/MercadoEnvios/Model/Observer.php +176 -0
- app/code/community/MercadoPago/MercadoEnvios/Model/Shipping/Carrier/MercadoEnvios.php +197 -0
- app/code/community/MercadoPago/MercadoEnvios/etc/config.xml +123 -0
- app/code/community/MercadoPago/MercadoEnvios/etc/system.xml +169 -0
- app/code/community/MercadoPago/Model/Core.php +0 -314
- app/code/community/MercadoPago/Model/Custom/Payment.php +0 -436
- app/code/community/MercadoPago/Model/CustomTicket/Payment.php +0 -82
- app/code/community/MercadoPago/Model/Observer.php +0 -146
- app/code/community/MercadoPago/Model/Source/CategoryId.php +0 -48
- app/code/community/MercadoPago/Model/Source/Country.php +0 -32
- app/code/community/MercadoPago/Model/Source/Installments.php +0 -41
- app/code/community/MercadoPago/Model/Source/PaymentMethods.php +0 -45
- app/code/community/MercadoPago/Model/Source/TypeCheckout.php +0 -31
- app/code/community/MercadoPago/Model/Standard/Payment.php +0 -298
- app/code/community/MercadoPago/OneStepCheckout/Block/Custom/Form.php +51 -0
- app/code/community/MercadoPago/OneStepCheckout/Block/Customticket/Form.php +42 -0
- app/code/community/MercadoPago/OneStepCheckout/Helper/Data.php +12 -0
- app/code/community/MercadoPago/OneStepCheckout/Model/Observer.php +16 -0
- app/code/community/MercadoPago/OneStepCheckout/etc/config.xml +52 -0
- app/code/community/MercadoPago/OneStepCheckout/etc/system.xml +23 -0
- app/code/community/MercadoPago/controllers/ApiController.php +0 -81
- app/code/community/MercadoPago/controllers/NotificationsController.php +0 -347
- app/code/community/MercadoPago/controllers/PayController.php +0 -43
- app/code/community/MercadoPago/controllers/SuccessController.php +0 -37
- app/code/community/MercadoPago/etc/system.xml +0 -403
- app/design/adminhtml/default/default/layout/mercadopago.xml +53 -0
- app/design/adminhtml/default/default/template/mercadopago/array_dropdown.phtml +50 -0
- app/design/adminhtml/default/default/template/mercadopago/custom/info.phtml +0 -0
- app/design/adminhtml/default/default/template/mercadopago/custom_ticket/info.phtml +4 -4
- app/design/adminhtml/default/default/template/mercadopago/standard/info.phtml +0 -0
- app/design/frontend/base/default/layout/mercadopago.xml +103 -0
- app/design/frontend/base/default/template/mercadopago/clean.phtml +0 -0
- app/design/frontend/base/default/template/mercadopago/custom/form.phtml +192 -187
- app/design/frontend/base/default/template/mercadopago/custom/info.phtml +0 -0
- app/design/frontend/base/default/template/mercadopago/custom/success.phtml +45 -0
- app/design/frontend/base/default/template/mercadopago/custom_ticket/form.phtml +62 -61
- app/design/frontend/base/default/template/mercadopago/custom_ticket/info.phtml +4 -4
- app/design/frontend/base/default/template/mercadopago/custom_ticket/success.phtml +38 -0
- app/design/frontend/base/default/template/mercadopago/discount.phtml +5 -5
- app/design/frontend/base/default/template/mercadopago/onestepcheckout/custom/form.phtml +218 -0
- app/design/frontend/base/default/template/mercadopago/standard/form.phtml +12 -12
- app/design/frontend/base/default/template/mercadopago/standard/info.phtml +0 -0
- app/design/frontend/base/default/template/mercadopago/standard/pay.phtml +0 -0
- app/design/frontend/base/default/template/mercadopago/standard/success.phtml +45 -0
- app/design/frontend/base/default/template/mercadopago/success.phtml +0 -135
- app/etc/modules/{MercadoPago.xml → MercadoPago_Core.xml} +2 -2
- app/etc/modules/MercadoPago_MercadoEnvios.xml +12 -0
- app/etc/modules/MercadoPago_OneStepCheckout.xml +12 -0
- app/locale/en_US/MercadoPago_Core.csv +166 -0
- app/locale/es_AR/MercadoPago_Core.csv +172 -0
- app/locale/es_CL/MercadoPago_Core.csv +115 -0
- app/locale/es_CO/{mercadopago.csv → MercadoPago_Core.csv} +17 -17
- app/locale/es_ES/{mercadopago.csv → MercadoPago_Core.csv} +17 -17
- app/locale/{es_AR/mercadopago.csv → es_MX/MercadoPago_Core.csv} +23 -18
- app/locale/{es_MX/mercadopago.csv → es_VE/MercadoPago_Core.csv} +2 -1
- app/locale/pt_BR/{mercadopago.csv → MercadoPago_Core.csv} +64 -18
- js/mercadopago/jquery-1.11.0.min.js +0 -0
- js/mercadopago/mercadopago.js +1034 -532
- js/mercadopago/mercadopago_osc.js +1179 -0
- js/mercadopago/tiny.min.js +1 -0
- js/mercadopago/tinyJ.js +198 -0
- lib/{mercadopago/mercadopago.php → MercadoPago/Lib/Api.php} +81 -142
- lib/MercadoPago/Lib/RestClient.php +105 -0
- package.xml +50 -13
- skin/adminhtml/default/default/mercadopago/images/cards.jpg +0 -0
- skin/adminhtml/default/default/mercadopago/images/logo.png +0 -0
- skin/adminhtml/default/default/mercadopago/images/mercadoenvios.png +0 -0
- skin/adminhtml/default/default/mercadopago/styles.css +52 -0
- skin/frontend/base/default/mercadopago/css/style-success.css +56 -0
- skin/frontend/base/default/mercadopago/css/style.css +69 -91
- skin/frontend/base/default/mercadopago/images/loading.gif +0 -0
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Custom_Form extends Mage_Payment_Block_Form_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
parent::_construct();
|
22 |
-
$this->setTemplate('mercadopago/custom/form.phtml');
|
23 |
-
}
|
24 |
-
|
25 |
-
protected function _prepareLayout(){
|
26 |
-
|
27 |
-
//pega public key para settar no aquivo mercadopago.js
|
28 |
-
$model = Mage::getModel('mercadopago/custom_payment');
|
29 |
-
$public_key = $model->getConfigData('public_key');
|
30 |
-
|
31 |
-
//init js no header
|
32 |
-
$block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
|
33 |
-
$block->setText(
|
34 |
-
sprintf(
|
35 |
-
'
|
36 |
-
<script type="text/javascript">var PublicKeyMercadoPagoTransparent = "' . $public_key .'";</script>
|
37 |
-
<script type="text/javascript" src="%s"></script>',
|
38 |
-
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js'
|
39 |
-
)
|
40 |
-
);
|
41 |
-
|
42 |
-
$head = Mage::app()->getLayout()->getBlock('after_body_start');
|
43 |
-
|
44 |
-
if($head){
|
45 |
-
$head->append($block);
|
46 |
-
}
|
47 |
-
|
48 |
-
return parent::_prepareLayout();
|
49 |
-
}
|
50 |
-
|
51 |
-
/*
|
52 |
-
*
|
53 |
-
* fun��o especifica para mexico
|
54 |
-
*
|
55 |
-
*/
|
56 |
-
function getCardsPaymentMethods(){
|
57 |
-
$payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
|
58 |
-
$payment_methods_types = array("credit_card", "debit_card", "prepaid_card");
|
59 |
-
$types = array();
|
60 |
-
|
61 |
-
//percorre todos os payments methods
|
62 |
-
foreach($payment_methods['response'] as $pm){
|
63 |
-
|
64 |
-
//filtra por payment_methods
|
65 |
-
if(in_array($pm['payment_type_id'], $payment_methods_types)){
|
66 |
-
$types[] = $pm;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
return $types;
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Custom_Info extends Mage_Payment_Block_Info_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
parent::_construct();
|
22 |
-
$this->setTemplate('mercadopago/custom/info.phtml');
|
23 |
-
$this->setModuleName('Mage_Payment');
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getOrder() {
|
27 |
-
return $this->getInfo();
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getInfoPayment(){
|
31 |
-
|
32 |
-
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
33 |
-
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
34 |
-
|
35 |
-
return $info_payments;
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Customticket_Form extends Mage_Payment_Block_Form_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
|
22 |
-
parent::_construct();
|
23 |
-
|
24 |
-
$this->setTemplate('mercadopago/custom_ticket/form.phtml');
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
protected function _prepareLayout(){
|
29 |
-
|
30 |
-
//pega public key para settar no aquivo mercadopago.js
|
31 |
-
$model = Mage::getModel('mercadopago/custom_payment');
|
32 |
-
$public_key = $model->getConfigData('public_key');
|
33 |
-
|
34 |
-
//init js no header
|
35 |
-
$block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
|
36 |
-
$block->setText(
|
37 |
-
sprintf(
|
38 |
-
'
|
39 |
-
<script type="text/javascript">var PublicKeyMercadoPagoTransparent = "' . $public_key .'";</script>
|
40 |
-
<script type="text/javascript" src="%s"></script>',
|
41 |
-
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js'
|
42 |
-
)
|
43 |
-
);
|
44 |
-
|
45 |
-
$head = Mage::app()->getLayout()->getBlock('after_body_start');
|
46 |
-
|
47 |
-
if($head){
|
48 |
-
$head->append($block);
|
49 |
-
}
|
50 |
-
|
51 |
-
return parent::_prepareLayout();
|
52 |
-
}
|
53 |
-
|
54 |
-
function getTicketsOptions(){
|
55 |
-
$payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
|
56 |
-
$tickets = array();
|
57 |
-
|
58 |
-
//percorre todos os payments methods
|
59 |
-
foreach($payment_methods['response'] as $pm){
|
60 |
-
|
61 |
-
//filtra por tickets
|
62 |
-
if($pm['payment_type_id'] == "ticket"){
|
63 |
-
$tickets[] = $pm;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
return $tickets;
|
68 |
-
}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_CustomTicket_Info extends Mage_Payment_Block_Info_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
parent::_construct();
|
22 |
-
$this->setTemplate('mercadopago/custom_ticket/info.phtml');
|
23 |
-
$this->setModuleName('Mage_Payment');
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
public function getOrder() {
|
28 |
-
return $this->getInfo();
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getInfoPayment(){
|
32 |
-
|
33 |
-
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
34 |
-
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
35 |
-
|
36 |
-
return $info_payments;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Standard_Form extends Mage_Payment_Block_Form_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
|
22 |
-
parent::_construct();
|
23 |
-
|
24 |
-
$this->setTemplate('mercadopago/standard/form.phtml');
|
25 |
-
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Standard_Info extends Mage_Payment_Block_Info_Cc{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
parent::_construct();
|
22 |
-
$this->setTemplate('mercadopago/standard/info.phtml');
|
23 |
-
$this->setModuleName('Mage_Payment');
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
public function getOrder() {
|
28 |
-
|
29 |
-
return $this->getInfo();
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getInfoPayment(){
|
34 |
-
|
35 |
-
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
36 |
-
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
37 |
-
|
38 |
-
return $info_payments;
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* NOTICE OF LICENSE
|
5 |
-
*
|
6 |
-
* This source file is subject to the Open Software License (OSL).
|
7 |
-
* It is also available through the world-wide-web at this URL:
|
8 |
-
* http://opensource.org/licenses/osl-3.0.php
|
9 |
-
*
|
10 |
-
* @category Payment Gateway
|
11 |
-
* @package MercadoPago
|
12 |
-
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Standard_Pay extends Mage_Core_Block_Template{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
|
22 |
-
parent::_construct();
|
23 |
-
|
24 |
-
$this->setTemplate('mercadopago/standard/pay.phtml');
|
25 |
-
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_AbstractForm
|
4 |
+
extends Mage_Payment_Block_Form_Cc
|
5 |
+
{
|
6 |
+
protected function _prepareLayout()
|
7 |
+
{
|
8 |
+
|
9 |
+
$public_key = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_PUBLIC_KEY);
|
10 |
+
|
11 |
+
//init js no header
|
12 |
+
$block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
|
13 |
+
$block->setText(
|
14 |
+
sprintf(
|
15 |
+
'
|
16 |
+
<script type="text/javascript">var PublicKeyMercadoPagoCustom = "' . $public_key . '";</script>
|
17 |
+
<script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script>
|
18 |
+
<script type="text/javascript" src="%s"></script>
|
19 |
+
<script type="text/javascript" src="%s"></script>
|
20 |
+
<script type="text/javascript" src="%s"></script>',
|
21 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js',
|
22 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tiny.min.js',
|
23 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tinyJ.js'
|
24 |
+
)
|
25 |
+
);
|
26 |
+
|
27 |
+
$head = Mage::app()->getLayout()->getBlock('after_body_start');
|
28 |
+
|
29 |
+
if ($head) {
|
30 |
+
$head->append($block);
|
31 |
+
}
|
32 |
+
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
}
|
@@ -1,74 +1,63 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
class MercadoPago_Block_Success extends Mage_Core_Block_Template{
|
19 |
-
|
20 |
-
protected function _construct(){
|
21 |
-
|
22 |
-
parent::_construct();
|
23 |
-
$this->setTemplate('mercadopago/success.phtml');
|
24 |
-
|
25 |
}
|
26 |
-
|
27 |
-
public function getOrder()
|
|
|
28 |
$orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
29 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
|
|
30 |
return $order;
|
31 |
}
|
32 |
-
|
33 |
-
public function
|
34 |
-
|
35 |
-
$payment = $order->getPayment();
|
36 |
-
return $payment;
|
37 |
-
}
|
38 |
-
|
39 |
-
public function getTotal(){
|
40 |
$order = $this->getOrder();
|
41 |
$total = $order->getBaseGrandTotal();
|
42 |
-
|
43 |
if (!$total) {
|
44 |
$total = $order->getBasePrice() + $order->getBaseShippingAmount();
|
45 |
}
|
46 |
-
|
47 |
$total = number_format($total, 2, '.', '');
|
48 |
-
|
49 |
return $total;
|
50 |
}
|
51 |
-
|
52 |
-
public function getEntityId
|
|
|
53 |
$order = $this->getOrder();
|
54 |
-
|
55 |
return $order->getEntityId();
|
56 |
}
|
57 |
-
|
58 |
-
public function getPaymentMethod
|
|
|
59 |
$payment_method = $this->getPayment()->getMethodInstance()->getCode();
|
60 |
-
|
61 |
return $payment_method;
|
62 |
}
|
63 |
-
|
64 |
-
public function getInfoPayment
|
|
|
65 |
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
66 |
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
67 |
-
|
68 |
return $info_payments;
|
69 |
}
|
70 |
-
|
71 |
-
public function getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment
|
|
|
72 |
return Mage::getModel('mercadopago/core')->getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment);
|
73 |
}
|
74 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_AbstractSuccess
|
4 |
+
extends Mage_Core_Block_Template
|
5 |
+
{
|
6 |
+
|
7 |
+
public function getPayment()
|
8 |
+
{
|
9 |
+
$order = $this->getOrder();
|
10 |
+
$payment = $order->getPayment();
|
11 |
+
|
12 |
+
return $payment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
+
|
15 |
+
public function getOrder()
|
16 |
+
{
|
17 |
$orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
18 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
19 |
+
|
20 |
return $order;
|
21 |
}
|
22 |
+
|
23 |
+
public function getTotal()
|
24 |
+
{
|
|
|
|
|
|
|
|
|
|
|
25 |
$order = $this->getOrder();
|
26 |
$total = $order->getBaseGrandTotal();
|
27 |
+
|
28 |
if (!$total) {
|
29 |
$total = $order->getBasePrice() + $order->getBaseShippingAmount();
|
30 |
}
|
31 |
+
|
32 |
$total = number_format($total, 2, '.', '');
|
33 |
+
|
34 |
return $total;
|
35 |
}
|
36 |
+
|
37 |
+
public function getEntityId()
|
38 |
+
{
|
39 |
$order = $this->getOrder();
|
40 |
+
|
41 |
return $order->getEntityId();
|
42 |
}
|
43 |
+
|
44 |
+
public function getPaymentMethod()
|
45 |
+
{
|
46 |
$payment_method = $this->getPayment()->getMethodInstance()->getCode();
|
47 |
+
|
48 |
return $payment_method;
|
49 |
}
|
50 |
+
|
51 |
+
public function getInfoPayment()
|
52 |
+
{
|
53 |
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
54 |
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
55 |
+
|
56 |
return $info_payments;
|
57 |
}
|
58 |
+
|
59 |
+
public function getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment)
|
60 |
+
{
|
61 |
return Mage::getModel('mercadopago/core')->getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment);
|
62 |
}
|
63 |
+
}
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Adminhtml_System_Config_Fieldset_Payment
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Return header title part of html for payment solution
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getHeaderTitleHtml($element)
|
15 |
+
{
|
16 |
+
$configData = $this->getData('config_data');
|
17 |
+
$imageUrl = $configData['payment/mercadopago_standard/banner_checkout'];
|
18 |
+
|
19 |
+
$html = '<div class="config-heading meli" ><div class="heading"><strong id="meli-logo">' . $element->getLegend();
|
20 |
+
$html .= '</strong></div>';
|
21 |
+
|
22 |
+
$html .= '<div class="button-container meli-cards" style="background: url(' . $imageUrl . ') no-repeat 0 0px;"><button type="button"'
|
23 |
+
. ' class="meli-payment-btn button'
|
24 |
+
. '" id="' . $element->getHtmlId()
|
25 |
+
. '-head" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \''
|
26 |
+
. $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">'
|
27 |
+
. $this->__('Configure') . '</span><span class="state-opened">'
|
28 |
+
. $this->__('Close') . '</span></button></div></div>';
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
return $html;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Collapsed or expanded fieldset when page loaded
|
37 |
+
*
|
38 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*
|
42 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
43 |
+
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
|
44 |
+
*/
|
45 |
+
protected function _getCollapseState($element)
|
46 |
+
{
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL).
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Payment Gateway
|
12 |
+
* @package MercadoPago
|
13 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
14 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class MercadoPago_Core_Block_Custom_Form
|
18 |
+
extends MercadoPago_Core_Block_AbstractForm
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
$this->setTemplate('mercadopago/custom/form.phtml');
|
24 |
+
}
|
25 |
+
|
26 |
+
/*
|
27 |
+
*
|
28 |
+
* Only used in Mexico
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
public function getCardsPaymentMethods()
|
32 |
+
{
|
33 |
+
$payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
|
34 |
+
$payment_methods_types = array("credit_card", "debit_card", "prepaid_card");
|
35 |
+
$types = array();
|
36 |
+
|
37 |
+
//percorre todos os payments methods
|
38 |
+
foreach ($payment_methods['response'] as $pm) {
|
39 |
+
|
40 |
+
//filtra por payment_methods
|
41 |
+
if (in_array($pm['payment_type_id'], $payment_methods_types)) {
|
42 |
+
$types[] = $pm;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
return $types;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getCustomerAndCards()
|
50 |
+
{
|
51 |
+
$customer = Mage::getModel('mercadopago/custom_payment')->getCustomerAndCards();
|
52 |
+
|
53 |
+
return $customer;
|
54 |
+
}
|
55 |
+
}
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Custom_Info
|
19 |
+
extends Mage_Payment_Block_Info_Cc
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('mercadopago/custom/info.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getOrder()
|
28 |
+
{
|
29 |
+
return $this->getInfo();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getInfoPayment()
|
33 |
+
{
|
34 |
+
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
35 |
+
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
36 |
+
|
37 |
+
return $info_payments;
|
38 |
+
}
|
39 |
+
}
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Custom_Success
|
4 |
+
extends MercadoPago_Core_Block_AbstractSuccess
|
5 |
+
{
|
6 |
+
protected function _construct()
|
7 |
+
{
|
8 |
+
parent::_construct();
|
9 |
+
$this->setTemplate('mercadopago/custom/success.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Customticket_Form
|
19 |
+
extends MercadoPago_Core_Block_AbstractForm
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
|
25 |
+
$this->setTemplate('mercadopago/custom_ticket/form.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getTicketsOptions()
|
29 |
+
{
|
30 |
+
$payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
|
31 |
+
$tickets = array();
|
32 |
+
|
33 |
+
//percorre todos os payments methods
|
34 |
+
foreach ($payment_methods['response'] as $pm) {
|
35 |
+
|
36 |
+
//filtra por tickets
|
37 |
+
if ($pm['payment_type_id'] == "ticket") {
|
38 |
+
$tickets[] = $pm;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
return $tickets;
|
43 |
+
}
|
44 |
+
}
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Customticket_Info
|
19 |
+
extends Mage_Payment_Block_Info_Cc
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('mercadopago/custom_ticket/info.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
public function getOrder()
|
29 |
+
{
|
30 |
+
return $this->getInfo();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getInfoPayment()
|
34 |
+
{
|
35 |
+
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
36 |
+
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
37 |
+
|
38 |
+
return $info_payments;
|
39 |
+
}
|
40 |
+
}
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Customticket_Success
|
4 |
+
extends MercadoPago_Core_Block_AbstractSuccess
|
5 |
+
{
|
6 |
+
protected function _construct()
|
7 |
+
{
|
8 |
+
parent::_construct();
|
9 |
+
$this->setTemplate('mercadopago/custom_ticket/success.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Discount
|
19 |
+
extends Mage_Core_Block_Template
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('mercadopago/discount.phtml');
|
25 |
+
}
|
26 |
+
}
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Sales_Order_Totals_Discount_Coupon
|
4 |
+
extends Mage_Core_Block_Abstract
|
5 |
+
{
|
6 |
+
public function getSource()
|
7 |
+
{
|
8 |
+
return $this->getParentBlock()->getSource();
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Add this total to parent
|
13 |
+
*/
|
14 |
+
public function initTotals()
|
15 |
+
{
|
16 |
+
if ((float)$this->getSource()->getDiscountCouponAmount() == 0) {
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
$total = new Varien_Object(array(
|
20 |
+
'code' => 'discount_coupon',
|
21 |
+
'field' => 'discount_coupon_amount',
|
22 |
+
'value' => $this->getSource()->getDiscountCouponAmount(),
|
23 |
+
'label' => $this->__('Discount Mercado Pago'),
|
24 |
+
));
|
25 |
+
$this->getParentBlock()->addTotalBefore($total, 'shipping');
|
26 |
+
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
}
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Sales_Order_Totals_Finance_Cost
|
4 |
+
extends Mage_Core_Block_Abstract
|
5 |
+
{
|
6 |
+
public function getSource()
|
7 |
+
{
|
8 |
+
return $this->getParentBlock()->getSource();
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Add this total to parent
|
13 |
+
*/
|
14 |
+
public function initTotals()
|
15 |
+
{
|
16 |
+
if ((float)$this->getSource()->getFinanceCostAmount() == 0) {
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
$total = new Varien_Object(array(
|
20 |
+
'code' => 'financing_cost',
|
21 |
+
'field' => 'financing_cost_amount',
|
22 |
+
'value' => $this->getSource()->getFinanceCostAmount(),
|
23 |
+
'label' => $this->__('Financing Cost'),
|
24 |
+
));
|
25 |
+
$this->getParentBlock()->addTotalBefore($total, 'shipping');
|
26 |
+
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
}
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Standard_Form
|
19 |
+
extends Mage_Payment_Block_Form_Cc
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
|
25 |
+
$this->setTemplate('mercadopago/standard/form.phtml');
|
26 |
+
}
|
27 |
+
}
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Standard_Info
|
19 |
+
extends Mage_Payment_Block_Info_Cc
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('mercadopago/standard/info.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
public function getOrder()
|
29 |
+
{
|
30 |
+
return $this->getInfo();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getInfoPayment()
|
34 |
+
{
|
35 |
+
$order_id = $this->getInfo()->getOrder()->getIncrementId();
|
36 |
+
$info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
|
37 |
+
|
38 |
+
return $info_payments;
|
39 |
+
}
|
40 |
+
}
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL).
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://opensource.org/licenses/osl-3.0.php
|
9 |
+
*
|
10 |
+
* @category Payment Gateway
|
11 |
+
* @package MercadoPago
|
12 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
13 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
|
18 |
+
class MercadoPago_Core_Block_Standard_Pay
|
19 |
+
extends Mage_Core_Block_Template
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
|
25 |
+
$this->setTemplate('mercadopago/standard/pay.phtml');
|
26 |
+
}
|
27 |
+
}
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Block_Standard_Success
|
4 |
+
extends MercadoPago_Core_Block_AbstractSuccess
|
5 |
+
{
|
6 |
+
protected function _construct()
|
7 |
+
{
|
8 |
+
parent::_construct();
|
9 |
+
$this->setTemplate('mercadopago/standard/success.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL).
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Payment Gateway
|
12 |
+
* @package MercadoPago
|
13 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
14 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class MercadoPago_Core_Helper_Data
|
18 |
+
extends Mage_Payment_Helper_Data
|
19 |
+
{
|
20 |
+
|
21 |
+
const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
|
22 |
+
const XML_PATH_PUBLIC_KEY = 'payment/mercadopago_custom_checkout/public_key';
|
23 |
+
const XML_PATH_CLIENT_ID = 'payment/mercadopago_standard/client_id';
|
24 |
+
const XML_PATH_CLIENT_SECRET = 'payment/mercadopago_standard/client_secret';
|
25 |
+
|
26 |
+
const PLATFORM_V1_WHITELABEL = 'v1-whitelabel';
|
27 |
+
const PLATFORM_DESKTOP = 'Desktop';
|
28 |
+
const TYPE = 'magento';
|
29 |
+
|
30 |
+
public function log($message, $file = "mercadopago.log", $array = null)
|
31 |
+
{
|
32 |
+
$actionLog = Mage::getStoreConfig('payment/mercadopago/logs');
|
33 |
+
|
34 |
+
if ($actionLog) {
|
35 |
+
if (!is_null($array)) {
|
36 |
+
$message .= " - " . json_encode($array);
|
37 |
+
}
|
38 |
+
|
39 |
+
Mage::log($message, null, $file, $actionLog);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getApiInstance()
|
44 |
+
{
|
45 |
+
$params = func_num_args();
|
46 |
+
if ($params > 2 || $params < 1) {
|
47 |
+
Mage::throwException("Invalid arguments. Use CLIENT_ID and CLIENT SECRET, or ACCESS_TOKEN");
|
48 |
+
}
|
49 |
+
if ($params == 1) {
|
50 |
+
$api = new MercadoPago_Lib_Api(func_get_arg(0));
|
51 |
+
$api->set_platform(self::PLATFORM_V1_WHITELABEL);
|
52 |
+
} else {
|
53 |
+
$api = new MercadoPago_Lib_Api(func_get_arg(0), func_get_arg(1));
|
54 |
+
$api->set_platform(self::PLATFORM_DESKTOP);
|
55 |
+
}
|
56 |
+
if (Mage::getStoreConfigFlag('payment/mercadopago_standard/sandbox_mode')) {
|
57 |
+
$api->sandbox_mode(true);
|
58 |
+
}
|
59 |
+
|
60 |
+
$api->set_type(self::TYPE . ' ' . (string) Mage::getConfig()->getModuleConfig("MercadoPago_Core")->version);
|
61 |
+
|
62 |
+
return $api;
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
public function isValidAccessToken($accessToken)
|
67 |
+
{
|
68 |
+
$mp = Mage::helper('mercadopago')->getApiInstance($accessToken);
|
69 |
+
$response = $mp->get("/v1/payment_methods");
|
70 |
+
if ($response['status'] == 401 || $response['status'] == 400) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function isValidClientCredentials($clientId, $clientSecret)
|
78 |
+
{
|
79 |
+
$mp = Mage::helper('mercadopago')->getApiInstance($clientId, $clientSecret);
|
80 |
+
try {
|
81 |
+
$mp->get_access_token();
|
82 |
+
} catch (Exception $e) {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getAccessToken()
|
90 |
+
{
|
91 |
+
$clientId = Mage::getStoreConfig(self::XML_PATH_CLIENT_ID);
|
92 |
+
$clientSecret = Mage::getStoreConfig(self::XML_PATH_CLIENT_SECRET);
|
93 |
+
try {
|
94 |
+
$accessToken = $this->getApiInstance($clientId, $clientSecret)->get_access_token();
|
95 |
+
} catch (\Exception $e) {
|
96 |
+
$accessToken = false;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $accessToken;
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getStatusOrder($status)
|
103 |
+
{
|
104 |
+
switch ($status) {
|
105 |
+
case 'approved': {
|
106 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_approved');
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
case 'refunded': {
|
110 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_refunded');
|
111 |
+
break;
|
112 |
+
}
|
113 |
+
case 'in_mediation': {
|
114 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_in_mediation');
|
115 |
+
break;
|
116 |
+
}
|
117 |
+
case 'cancelled': {
|
118 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_cancelled');
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
case 'rejected': {
|
122 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_rejected');
|
123 |
+
break;
|
124 |
+
}
|
125 |
+
case 'chargeback': {
|
126 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_chargeback');
|
127 |
+
break;
|
128 |
+
}
|
129 |
+
default: {
|
130 |
+
$status = Mage::getStoreConfig('payment/mercadopago/order_status_in_process');
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
return $status;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Get the assigned state of an order status
|
139 |
+
*
|
140 |
+
* @param string $status
|
141 |
+
*/
|
142 |
+
public function _getAssignedState($status)
|
143 |
+
{
|
144 |
+
$item = Mage::getResourceModel('sales/order_status_collection')
|
145 |
+
->joinStates()
|
146 |
+
->addFieldToFilter('main_table.status', $status);
|
147 |
+
|
148 |
+
return array_pop($item->getItems())->getState();
|
149 |
+
}
|
150 |
+
|
151 |
+
public function getMessage($status, $payment)
|
152 |
+
{
|
153 |
+
$rawMessage = Mage::helper('mercadopago')->__(Mage::helper('mercadopago/statusOrderMessage')->getMessage($status));
|
154 |
+
$rawMessage .= Mage::helper('mercadopago')->__('<br/> Payment id: %s', $payment['id']);
|
155 |
+
$rawMessage .= Mage::helper('mercadopago')->__('<br/> Status: %s', $payment['status']);
|
156 |
+
$rawMessage .= Mage::helper('mercadopago')->__('<br/> Status Detail: %s', $payment['status_detail']);
|
157 |
+
|
158 |
+
return $rawMessage;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function setOrderSubtotals($data, $order)
|
162 |
+
{
|
163 |
+
if (isset($data['total_paid_amount'])){
|
164 |
+
$balance = $this->_getMultiCardValue($data['total_paid_amount']);
|
165 |
+
} else {
|
166 |
+
$balance = $data['transaction_details']['total_paid_amount'];
|
167 |
+
}
|
168 |
+
$shippingCost = $this->_getMultiCardValue($data['shipping_cost']);
|
169 |
+
|
170 |
+
$order->setGrandTotal($balance);
|
171 |
+
$order->setBaseGrandTotal($balance);
|
172 |
+
if ($shippingCost > 0) {
|
173 |
+
$order->setBaseShippingAmount($shippingCost);
|
174 |
+
$order->setShippingAmount($shippingCost);
|
175 |
+
}
|
176 |
+
|
177 |
+
$couponAmount = $this->_getMultiCardValue($data['coupon_amount']);
|
178 |
+
$transactionAmount = $this->_getMultiCardValue($data['transaction_amount']);
|
179 |
+
|
180 |
+
if ($couponAmount) {
|
181 |
+
$order->setDiscountCouponAmount($couponAmount * -1);
|
182 |
+
$order->setBaseDiscountCouponAmount($couponAmount * -1);
|
183 |
+
$balance = $balance - ($transactionAmount - $couponAmount + $shippingCost);
|
184 |
+
} else {
|
185 |
+
$balance = $balance - $transactionAmount - $shippingCost;
|
186 |
+
}
|
187 |
+
|
188 |
+
if (Zend_Locale_Math::round($balance,4) > 0) {
|
189 |
+
$order->setFinanceCostAmount($balance);
|
190 |
+
$order->setBaseFinanceCostAmount($balance);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @param $payment
|
196 |
+
*
|
197 |
+
* @return mixed
|
198 |
+
*/
|
199 |
+
public function setPayerInfo(&$payment)
|
200 |
+
{
|
201 |
+
$payment["trunc_card"] = "xxxx xxxx xxxx " . $payment['card']["last_four_digits"];
|
202 |
+
$payment["cardholder_name"] = $payment['card']["cardholder"]["name"];
|
203 |
+
$payment['payer_first_name'] = $payment['payer']['first_name'];
|
204 |
+
$payment['payer_last_name'] = $payment['payer']['last_name'];
|
205 |
+
$payment['payer_email'] = $payment['payer']['email'];
|
206 |
+
|
207 |
+
return $payment;
|
208 |
+
}
|
209 |
+
|
210 |
+
protected function _getMultiCardValue($fullValue) {
|
211 |
+
$finalValue = 0;
|
212 |
+
$values = explode('|', $fullValue);
|
213 |
+
foreach ($values as $value) {
|
214 |
+
$value = (float) str_replace(' ', '', $value);
|
215 |
+
$finalValue = $finalValue + $value;
|
216 |
+
}
|
217 |
+
|
218 |
+
return $finalValue;
|
219 |
+
}
|
220 |
+
|
221 |
+
}
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class MercadoPago_Core_Helper_Message_Abstract
|
4 |
+
extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
|
7 |
+
public abstract function getMessageMap();
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @param $key
|
12 |
+
* @param null $args array()
|
13 |
+
*
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function getMessage($key)
|
17 |
+
{
|
18 |
+
$messageMap = $this->getMessageMap();
|
19 |
+
if (isset($messageMap[$key])) {
|
20 |
+
return $messageMap[$key];
|
21 |
+
}
|
22 |
+
|
23 |
+
return '';
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL).
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Payment Gateway
|
12 |
+
* @package MercadoPago
|
13 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
14 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class MercadoPago_Core_Helper_Response
|
18 |
+
{
|
19 |
+
/*
|
20 |
+
* HTTP Response Codes
|
21 |
+
*/
|
22 |
+
const HTTP_OK = 200;
|
23 |
+
const HTTP_CREATED = 201;
|
24 |
+
const HTTP_MULTI_STATUS = 207;
|
25 |
+
const HTTP_BAD_REQUEST = 400;
|
26 |
+
const HTTP_UNAUTHORIZED = 401;
|
27 |
+
const HTTP_FORBIDDEN = 403;
|
28 |
+
const HTTP_NOT_FOUND = 404;
|
29 |
+
const HTTP_METHOD_NOT_ALLOWED = 405;
|
30 |
+
const HTTP_NOT_ACCEPTABLE = 406;
|
31 |
+
const HTTP_INTERNAL_ERROR = 500;
|
32 |
+
}
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Helper_StatusDetailMessage
|
4 |
+
extends MercadoPago_Core_Helper_Message_Abstract
|
5 |
+
{
|
6 |
+
protected $messagesMap = [
|
7 |
+
"cc_rejected_bad_filled_card_number" => 'Check the card number.',
|
8 |
+
"cc_rejected_bad_filled_date" => 'Check the expiration date.',
|
9 |
+
"cc_rejected_bad_filled_other" => 'Check the data.',
|
10 |
+
"cc_rejected_bad_filled_security_code" => 'Check the security code.',
|
11 |
+
"cc_rejected_blacklist" => 'We could not process your payment.',
|
12 |
+
"cc_rejected_call_for_authorize" => 'You must authorize to %s the payment of $ %s to MercadoPago.',
|
13 |
+
"cc_rejected_card_disabled" => 'Call %s to activate your card.<br/>The phone is on the back of your card.',
|
14 |
+
"cc_rejected_card_error" => 'We could not process your payment.',
|
15 |
+
"cc_rejected_duplicated_payment" => 'You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.',
|
16 |
+
"cc_rejected_high_risk" => 'Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.',
|
17 |
+
"cc_rejected_insufficient_amount" => 'Your %s do not have sufficient funds.',
|
18 |
+
"cc_rejected_invalid_installments" => '%s does not process payments in %s installments.',
|
19 |
+
"cc_rejected_max_attempts" => 'You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.',
|
20 |
+
"cc_rejected_other_reason" => '%s did not process the payment.',
|
21 |
+
];
|
22 |
+
|
23 |
+
public function getMessageMap()
|
24 |
+
{
|
25 |
+
return $this->messagesMap;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Helper_StatusMessage
|
4 |
+
extends MercadoPago_Core_Helper_Message_Abstract
|
5 |
+
{
|
6 |
+
protected $messagesMap = [
|
7 |
+
"approved" => [
|
8 |
+
'title' => 'Done, your payment was accredited!',
|
9 |
+
'message' => ''
|
10 |
+
],
|
11 |
+
|
12 |
+
"in_process" => [
|
13 |
+
'title' => 'We are processing the payment.',
|
14 |
+
'message' => 'In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.'
|
15 |
+
],
|
16 |
+
|
17 |
+
"authorized" => [
|
18 |
+
'title' => 'We are processing the payment.',
|
19 |
+
'message' => 'In less than an hour we will send you by e-mail the result.'
|
20 |
+
],
|
21 |
+
|
22 |
+
"pending" => [
|
23 |
+
'title' => 'We are processing the payment.',
|
24 |
+
'message' => 'In less than an hour we will send you by e-mail the result.'
|
25 |
+
],
|
26 |
+
|
27 |
+
"rejected" => [
|
28 |
+
'title' => 'We could not process your payment.',
|
29 |
+
'message' => ''
|
30 |
+
],
|
31 |
+
|
32 |
+
"cancelled" => [
|
33 |
+
'title' => 'Payments were canceled.',
|
34 |
+
'message' => 'Contact for more information.'
|
35 |
+
],
|
36 |
+
|
37 |
+
"other" => [
|
38 |
+
'title' => 'Thank you for your purchase!',
|
39 |
+
'message' => ''
|
40 |
+
]
|
41 |
+
];
|
42 |
+
|
43 |
+
public function getMessageMap()
|
44 |
+
{
|
45 |
+
return $this->messagesMap;
|
46 |
+
}
|
47 |
+
}
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MercadoPago_Core_Helper_StatusOrderMessage
|
4 |
+
extends MercadoPago_Core_Helper_Message_Abstract
|
5 |
+
{
|
6 |
+
protected $messagesMap = [
|
7 |
+
"approved" => 'Automatic notification of the Mercado Pago: The payment was approved.',
|
8 |
+
"refunded" => 'Automatic notification of the Mercado Pago: The payment was refunded.',
|
9 |
+
"pending" => 'Automatic notification of the Mercado Pago: The payment is being processed.',
|
10 |
+
"in_process" => 'Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.',
|
11 |
+
"in_mediation" => 'Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.',
|
12 |
+
"cancelled" => 'Automatic notification of the Mercado Pago: The payment was cancelled.',
|
13 |
+
"rejected" => 'Automatic notification of the Mercado Pago: The payment was rejected.',
|
14 |
+
"chargeback" => 'Automatic notification of the Mercado Pago: One chargeback was initiated for this payment.',
|
15 |
+
];
|
16 |
+
|
17 |
+
public function getMessageMap()
|
18 |
+
{
|
19 |
+
return $this->messagesMap;
|
20 |
+
}
|
21 |
+
}
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Exception which thrown by MercadoPago API in case of processable error codes
|
5 |
+
*/
|
6 |
+
class MercadoPago_Core_Model_Api_Exception
|
7 |
+
extends Mage_Core_Exception
|
8 |
+
{
|
9 |
+
|
10 |
+
const GENERIC_USER_MESSAGE = "We could not process your payment in this moment. Please check the form data and retry later";
|
11 |
+
|
12 |
+
protected $messagesMap;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get error message which can be displayed to website user
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getUserMessage($error=null)
|
20 |
+
{
|
21 |
+
if (!empty($error)) {
|
22 |
+
if (Mage::getStoreConfigFlag('payment/mercadopago/debug_mode')) {
|
23 |
+
return $error['description'];
|
24 |
+
} else {
|
25 |
+
$code = $error['code'];
|
26 |
+
if (isset($this->messagesMap[$code])) {
|
27 |
+
return Mage::helper('mercadopago')->__($this->messagesMap[$code]);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
return Mage::helper('mercadopago')->__(self::GENERIC_USER_MESSAGE);
|
33 |
+
}
|
34 |
+
}
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Exception which thrown by MercadoPago API in case of processable error codes
|
5 |
+
*/
|
6 |
+
class MercadoPago_Core_Model_Api_V0_Exception extends MercadoPago_Core_Model_Api_Exception
|
7 |
+
{
|
8 |
+
protected $messagesMap =
|
9 |
+
array(
|
10 |
+
106 => 'Cannot operate between users from different countries.',
|
11 |
+
109 => 'Payment method does not process installments.',
|
12 |
+
129 => 'Cannot pay this amount with this paymentMethod.',
|
13 |
+
150 => 'You user cannot do payments currently',
|
14 |
+
151 => 'You user cannot do payments currently with this payment method.',
|
15 |
+
204 => 'Unavailable paymentmethod currently.',
|
16 |
+
801 => 'Already posted the same request in the last minute.',
|
17 |
+
'campaign_code_doesnt_match' => "Doesn't find a campaign with the given code."
|
18 |
+
);
|
19 |
+
|
20 |
+
}
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Exception which thrown by MercadoPago API in case of processable error codes from api v1
|
5 |
+
*/
|
6 |
+
class MercadoPago_Core_Model_Api_V1_Exception
|
7 |
+
extends MercadoPago_Core_Model_Api_Exception
|
8 |
+
{
|
9 |
+
protected $messagesMap =
|
10 |
+
[
|
11 |
+
1000 => 'The items Quantity has exceeded the limits. We could not process your payment.',
|
12 |
+
2001 => 'Already posted the same request in the last minute.',
|
13 |
+
2017 => 'The transaction amount is invalid. We could not process your payment.',
|
14 |
+
2020 => 'You user cannot do payments currently',
|
15 |
+
2022 => 'You have exceeded the max number of refunds for this payment.',
|
16 |
+
2024 => 'Payment too old to be refunded',
|
17 |
+
2034 => 'You user cannot do payments currently',
|
18 |
+
2039 => 'Coupon code is invalid',
|
19 |
+
2040 => 'Your user e-mail does not exist. Please check data and retry later',
|
20 |
+
2043 => 'Coupon code is invalid',
|
21 |
+
3000 => 'You must provide your cardholder name with your card data',
|
22 |
+
3011 => 'Not found payment method or credit card. Please check the form data and retry.',
|
23 |
+
3012 => 'Security code is invalid. Please check the form data and retry.',
|
24 |
+
3013 => 'Security code is a required field. Please check the form data and retry.',
|
25 |
+
3014 => 'Payment method or credit card invalid. Please check the form data and retry.',
|
26 |
+
3015 => 'Credit card number is invalid. Please check the form data and retry.',
|
27 |
+
3016 => 'Credit card number is invalid. Please check the form data and retry.',
|
28 |
+
3018 => 'Expiration month can not be empty. Please check the form data and retry.',
|
29 |
+
3019 => 'Expiration year can not be empty. Please check the form data and retry.',
|
30 |
+
3020 => 'Cardholder name can not empty. Please check the form data and retry.',
|
31 |
+
3021 => 'Cardholder document number can not be empty. Please check the form data and retry.',
|
32 |
+
3022 => 'Cardholder document type can not be empty. Please check the form data and retry.',
|
33 |
+
3023 => 'Cardholder document subtype can not be empty. Please check the form data and retry.',
|
34 |
+
3029 => 'Expiration month is invalid. Please check the form data and retry.',
|
35 |
+
3030 => 'Expiration year is invalid. Please check the form data and retry.',
|
36 |
+
4004 => 'Installments attribute can not be empty. Please check the form data and retry.',
|
37 |
+
4026 => 'Coupon amount is invalid. Please check the form data and retry.',
|
38 |
+
'campaign_code_doesnt_match' => "Doesn't find a campaign with the given code.",
|
39 |
+
'amount_doesnt_match' => "Doesn't find a campaign to amount given",
|
40 |
+
'transaction_amount_invalid' => "Amount discount is invalid"
|
41 |
+
];
|
42 |
+
|
43 |
+
}
|
@@ -0,0 +1,552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL).
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Payment Gateway
|
12 |
+
* @package MercadoPago
|
13 |
+
* @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
|
14 |
+
* @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class MercadoPago_Core_Model_Core
|
18 |
+
extends Mage_Payment_Model_Method_Abstract
|
19 |
+
{
|
20 |
+
protected $_code = 'mercadopago';
|
21 |
+
|
22 |
+
protected $_isGateway = true;
|
23 |
+
protected $_canOrder = true;
|
24 |
+
protected $_canAuthorize = true;
|
25 |
+
protected $_canCapture = true;
|
26 |
+
protected $_canCapturePartial = true;
|
27 |
+
protected $_canRefund = true;
|
28 |
+
protected $_canRefundInvoicePartial = true;
|
29 |
+
protected $_canVoid = true;
|
30 |
+
protected $_canUseInternal = true;
|
31 |
+
protected $_canUseCheckout = true;
|
32 |
+
protected $_canUseForMultishipping = true;
|
33 |
+
protected $_canFetchTransactionInfo = true;
|
34 |
+
protected $_canCreateBillingAgreement = true;
|
35 |
+
protected $_canReviewPayment = true;
|
36 |
+
|
37 |
+
const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
|
38 |
+
const LOG_FILE = 'mercadopago-custom.log';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return Mage_Checkout_Model_Session
|
42 |
+
*/
|
43 |
+
protected function _getCheckout()
|
44 |
+
{
|
45 |
+
return Mage::getSingleton('checkout/session');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get admin checkout session namespace
|
50 |
+
*
|
51 |
+
* @return Mage_Adminhtml_Model_Session_Quote
|
52 |
+
*/
|
53 |
+
protected function _getAdminCheckout()
|
54 |
+
{
|
55 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Retrieves Quote
|
60 |
+
*
|
61 |
+
* @param integer $quoteId
|
62 |
+
*
|
63 |
+
* @return Mage_Sales_Model_Quote
|
64 |
+
*/
|
65 |
+
protected function _getQuote($quoteId = null)
|
66 |
+
{
|
67 |
+
if (!empty($quoteId)) {
|
68 |
+
return Mage::getModel('sales/quote')->load($quoteId);
|
69 |
+
} else {
|
70 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
71 |
+
return $this->_getAdminCheckout()->getQuote();
|
72 |
+
} else {
|
73 |
+
return $this->_getCheckout()->getQuote();
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Retrieves Order
|
80 |
+
*
|
81 |
+
* @param integer $incrementId
|
82 |
+
*
|
83 |
+
* @return Mage_Sales_Model_Order
|
84 |
+
*/
|
85 |
+
protected function _getOrder($incrementId)
|
86 |
+
{
|
87 |
+
return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getInfoPaymentByOrder($order_id)
|
91 |
+
{
|
92 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
93 |
+
$payment = $order->getPayment();
|
94 |
+
$info_payments = array();
|
95 |
+
$fields = array(
|
96 |
+
array("field" => "cardholderName", "title" => "Card Holder Name: %s"),
|
97 |
+
array("field" => "trunc_card", "title" => "Card Number: %s"),
|
98 |
+
array("field" => "payment_method", "title" => "Payment Method: %s"),
|
99 |
+
array("field" => "expiration_date", "title" => "Expiration Date: %s"),
|
100 |
+
array("field" => "installments", "title" => "Installments: %s"),
|
101 |
+
array("field" => "statement_descriptor", "title" => "Statement Descriptor: %s"),
|
102 |
+
array("field" => "payment_id", "title" => "Payment id (MercadoPago): %s"),
|
103 |
+
array("field" => "status", "title" => "Payment Status: %s"),
|
104 |
+
array("field" => "status_detail", "title" => "Payment Detail: %s"),
|
105 |
+
array("field" => "activation_uri", "title" => "Generate Ticket")
|
106 |
+
);
|
107 |
+
|
108 |
+
foreach ($fields as $field):
|
109 |
+
if ($payment->getAdditionalInformation($field['field']) != ""):
|
110 |
+
$text = Mage::helper('mercadopago')->__($field['title'], $payment->getAdditionalInformation($field['field']));
|
111 |
+
$info_payments[$field['field']] = array(
|
112 |
+
"text" => $text,
|
113 |
+
"value" => $payment->getAdditionalInformation($field['field'])
|
114 |
+
);
|
115 |
+
endif;
|
116 |
+
endforeach;
|
117 |
+
|
118 |
+
return $info_payments;
|
119 |
+
}
|
120 |
+
|
121 |
+
protected function validStatusTwoPayments($status)
|
122 |
+
{
|
123 |
+
$array_status = explode(" | ", $status);
|
124 |
+
$status_verif = true;
|
125 |
+
$status_final = "";
|
126 |
+
foreach ($array_status as $status):
|
127 |
+
|
128 |
+
if ($status_final == "") {
|
129 |
+
$status_final = $status;
|
130 |
+
} else {
|
131 |
+
if ($status_final != $status) {
|
132 |
+
$status_verif = false;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
endforeach;
|
136 |
+
|
137 |
+
if ($status_verif === false) {
|
138 |
+
$status_final = "other";
|
139 |
+
}
|
140 |
+
|
141 |
+
return $status_final;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function getMessageByStatus($status, $status_detail, $payment_method, $installment, $amount)
|
145 |
+
{
|
146 |
+
$status = $this->validStatusTwoPayments($status);
|
147 |
+
$status_detail = $this->validStatusTwoPayments($status_detail);
|
148 |
+
|
149 |
+
$message = array(
|
150 |
+
"title" => "",
|
151 |
+
"message" => ""
|
152 |
+
);
|
153 |
+
|
154 |
+
$rawMessage = Mage::helper('mercadopago/statusMessage')->getMessage($status);
|
155 |
+
$message['title'] = Mage::helper('mercadopago')->__($rawMessage['title']);
|
156 |
+
|
157 |
+
if ($status == 'rejected') {
|
158 |
+
if ($status_detail == 'cc_rejected_invalid_installments') {
|
159 |
+
$message['message'] = Mage::helper('mercadopago')
|
160 |
+
->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method), $installment);
|
161 |
+
} elseif ($status_detail == 'cc_rejected_call_for_authorize') {
|
162 |
+
$message['message'] = Mage::helper('mercadopago')
|
163 |
+
->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method), $amount);
|
164 |
+
} else {
|
165 |
+
$message['message'] = Mage::helper('mercadopago')
|
166 |
+
->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method));
|
167 |
+
}
|
168 |
+
} else {
|
169 |
+
$message['message'] = Mage::helper('mercadopago')->__($rawMessage['message']);
|
170 |
+
}
|
171 |
+
|
172 |
+
return $message;
|
173 |
+
}
|
174 |
+
|
175 |
+
protected function getCustomerInfo($customer, $order)
|
176 |
+
{
|
177 |
+
$email = htmlentities($customer->getEmail());
|
178 |
+
if ($email == "") {
|
179 |
+
$email = $order['customer_email'];
|
180 |
+
}
|
181 |
+
|
182 |
+
$first_name = htmlentities($customer->getFirstname());
|
183 |
+
if ($first_name == "") {
|
184 |
+
$first_name = $order->getBillingAddress()->getFirstname();
|
185 |
+
}
|
186 |
+
|
187 |
+
$last_name = htmlentities($customer->getLastname());
|
188 |
+
if ($last_name == "") {
|
189 |
+
$last_name = $order->getBillingAddress()->getLastname();
|
190 |
+
}
|
191 |
+
|
192 |
+
return array('email' => $email, 'first_name' => $first_name, 'last_name' => $last_name);
|
193 |
+
}
|
194 |
+
|
195 |
+
protected function getItemsInfo($order)
|
196 |
+
{
|
197 |
+
$dataItems = array();
|
198 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
199 |
+
$product = $item->getProduct();
|
200 |
+
$image = (string)Mage::helper('catalog/image')->init($product, 'image');
|
201 |
+
|
202 |
+
$dataItems[] = array(
|
203 |
+
"id" => $item->getSku(),
|
204 |
+
"title" => $product->getName(),
|
205 |
+
"description" => $product->getName(),
|
206 |
+
"picture_url" => $image,
|
207 |
+
"category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
|
208 |
+
"quantity" => (int)number_format($item->getQtyOrdered(), 0, '.', ''),
|
209 |
+
"unit_price" => (float)number_format($product->getPrice(), 2, '.', '')
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
/* verify discount and add it like an item */
|
214 |
+
$discount = $this->getDiscount();
|
215 |
+
if ($discount != 0) {
|
216 |
+
$dataItems[] = array(
|
217 |
+
"title" => "Discount by the Store",
|
218 |
+
"description" => "Discount by the Store",
|
219 |
+
"quantity" => 1,
|
220 |
+
"unit_price" => (float)number_format($discount, 2, '.', '')
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
return $dataItems;
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
protected function getCouponInfo($coupon, $coupon_code)
|
229 |
+
{
|
230 |
+
$infoCoupon = array();
|
231 |
+
$infoCoupon['coupon_amount'] = (float)$coupon['response']['coupon_amount'];
|
232 |
+
$infoCoupon['coupon_code'] = $coupon_code;
|
233 |
+
$infoCoupon['campaign_id'] = $coupon['response']['id'];
|
234 |
+
if ($coupon['status'] == 200) {
|
235 |
+
Mage::helper('mercadopago')->log("Coupon applied. API response 200.", self::LOG_FILE);
|
236 |
+
} else {
|
237 |
+
Mage::helper('mercadopago')->log("Coupon invalid, not applied.", self::LOG_FILE);
|
238 |
+
}
|
239 |
+
|
240 |
+
return $infoCoupon;
|
241 |
+
}
|
242 |
+
|
243 |
+
public function makeDefaultPreferencePaymentV1($payment_info = array())
|
244 |
+
{
|
245 |
+
$quote = $this->_getQuote();
|
246 |
+
$order_id = $quote->getReservedOrderId();
|
247 |
+
$order = $this->_getOrder($order_id);
|
248 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
249 |
+
|
250 |
+
$billing_address = $quote->getBillingAddress()->getData();
|
251 |
+
$customerInfo = $this->getCustomerInfo($customer, $order);
|
252 |
+
|
253 |
+
/* INIT PREFERENCE */
|
254 |
+
$preference = array();
|
255 |
+
|
256 |
+
$preference['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . "mercadopago/notifications/custom";
|
257 |
+
|
258 |
+
$preference['transaction_amount'] = (float)$this->getAmount();
|
259 |
+
|
260 |
+
$preference['external_reference'] = $order_id;
|
261 |
+
$preference['payer']['email'] = $customerInfo['email'];
|
262 |
+
|
263 |
+
if (!empty($payment_info['identification_type'])) {
|
264 |
+
$preference['payer']['identification']['type'] = $payment_info['identification_type'];
|
265 |
+
$preference['payer']['identification']['number'] = $payment_info['identification_number'];
|
266 |
+
}
|
267 |
+
$preference['additional_info']['items'] = $this->getItemsInfo($order);
|
268 |
+
|
269 |
+
$preference['additional_info']['payer']['first_name'] = $customerInfo['first_name'];
|
270 |
+
$preference['additional_info']['payer']['last_name'] = $customerInfo['last_name'];
|
271 |
+
|
272 |
+
$preference['additional_info']['payer']['address'] = array(
|
273 |
+
"zip_code" => $billing_address['postcode'],
|
274 |
+
"street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
|
275 |
+
"street_number" => ''
|
276 |
+
);
|
277 |
+
|
278 |
+
$preference['additional_info']['payer']['registration_date'] = date('Y-m-d', $customer->getCreatedAtTimestamp()) . "T" . date('H:i:s', $customer->getCreatedAtTimestamp());
|
279 |
+
|
280 |
+
$shipping = $order->getShippingAddress()->getData();
|
281 |
+
|
282 |
+
$preference['additional_info']['shipments']['receiver_address'] = array(
|
283 |
+
"zip_code" => $shipping['postcode'],
|
284 |
+
"street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
|
285 |
+
"street_number" => '',
|
286 |
+
"floor" => "-",
|
287 |
+
"apartment" => "-",
|
288 |
+
|
289 |
+
|