Version Notes
Este módulo es Compatible con las versiones de Magento: 1.8.0.0, 1.7.0.1 y 1.7.0.2
Download this release
Release Info
| Developer | Ebcomm |
| Extension | magento_community_Ebcomm_PaypalMx |
| Version | 1.0.2 |
| Comparing to | |
| See all releases | |
Version 1.0.2
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Details/Form.php +90 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Report.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Report/Grid.php +112 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/ApiWizard.php +50 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Field/Country.php +127 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Field/Hidden.php +48 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Expanded.php +52 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Global.php +241 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Group.php +77 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Hint.php +98 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Location.php +353 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Payment.php +100 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Store.php +86 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Payflowlink/Advanced.php +43 -0
- app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Payflowlink/Info.php +85 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito/Form.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito/Review.php +209 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Billing.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Shipping.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Form.php +35 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review.php +209 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Billing.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Shipping.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Debito2/Shortcut.php +152 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Form.php +35 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Review.php +209 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Billing.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Shipping.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Express/Shortcut.php +154 -0
- app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Form.php +46 -0
- app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Iframe.php +58 -0
- app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Info.php +45 -0
- app/code/community/Ebcomm/PaypalMx/Block/Iframe.php +205 -0
- app/code/community/Ebcomm/PaypalMx/Block/Logo.php +43 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Form.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review.php +209 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Billing.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Shipping.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Form.php +36 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review.php +209 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Billing.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Details.php +28 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Shipping.php +21 -0
- app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Shortcut.php +152 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Form.php +56 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Iframe.php +67 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Info.php +37 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Review.php +38 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Form.php +56 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Iframe.php +101 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Info.php +45 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Review.php +47 -0
- app/code/community/Ebcomm/PaypalMx/Block/Payment/Info.php +39 -0
- app/code/community/Ebcomm/PaypalMx/Block/Standard/Form.php +46 -0
- app/code/community/Ebcomm/PaypalMx/Block/Standard/Redirect.php +32 -0
- app/code/community/Ebcomm/PaypalMx/Controller/Express/Abstract.php +442 -0
- app/code/community/Ebcomm/PaypalMx/Helper/Data.php +51 -0
- app/code/community/Ebcomm/PaypalMx/Helper/Hss.php +41 -0
- app/code/community/Ebcomm/PaypalMx/Model/Api/Abstract.php +582 -0
- app/code/community/Ebcomm/PaypalMx/Model/Api/Nvp.php +1441 -0
- app/code/community/Ebcomm/PaypalMx/Model/Api/Standard.php +230 -0
- app/code/community/Ebcomm/PaypalMx/Model/Cart.php +474 -0
- app/code/community/Ebcomm/PaypalMx/Model/Config.php +1350 -0
- app/code/community/Ebcomm/PaypalMx/Model/Debito2.php +685 -0
- app/code/community/Ebcomm/PaypalMx/Model/Debito2/Checkout.php +967 -0
- app/code/community/Ebcomm/PaypalMx/Model/Express.php +685 -0
- app/code/community/Ebcomm/PaypalMx/Model/Express/Checkout.php +967 -0
- app/code/community/Ebcomm/PaypalMx/Model/Info.php +637 -0
- app/code/community/Ebcomm/PaypalMx/Model/Mensualidades2.php +685 -0
- app/code/community/Ebcomm/PaypalMx/Model/Mensualidades2/Checkout.php +967 -0
- app/code/community/Ebcomm/PaypalMx/Model/Pro.php +450 -0
- app/code/community/Ebcomm/PaypalMx/Model/Report/Settlement.php +476 -0
- app/code/community/Ebcomm/PaypalMx/Model/Report/Settlement/Row.php +230 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Cert.php +83 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Payment/Transaction.php +124 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Payment/Transaction/Collection.php +97 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement.php +93 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement/Row.php +12 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement/Row/Collection.php +42 -0
- app/code/community/Ebcomm/PaypalMx/Model/Resource/Setup.php +37 -0
- app/code/community/Ebcomm/PaypalMx/Model/Session.php +15 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/Cert.php +45 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/Cron.php +29 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/MerchantCountry.php +27 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/AuthorizationAmounts.php +14 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/BuyerCountry.php +18 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/FetchingSchedule.php +20 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/Logo.php +13 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/MerchantCountry.php +18 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/PaymentActions.php +14 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/PaymentActions/Express.php +18 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/RequireBillingAddress.php +18 -0
- app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/UrlMethod.php +20 -0
- app/code/community/Ebcomm/PaypalMx/controllers/Adminhtml/Paypal/ReportssController.php +111 -0
- app/code/community/Ebcomm/PaypalMx/controllers/ExpressController.php +28 -0
- app/code/community/Ebcomm/PaypalMx/etc/adminhtml.xml +56 -0
- app/code/community/Ebcomm/PaypalMx/etc/config.xml +196 -0
- app/code/community/Ebcomm/PaypalMx/etc/system.xml +449 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/install-1.6.0.0.php +161 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-install-0.7.0.php +51 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-install-1.4.0.0.php +48 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php +30 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php +42 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php +72 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php +47 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +307 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php +55 -0
- app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php +35 -0
- app/design/adminhtml/default/default/template/paypalmx/system/config/api_wizard.phtml +13 -0
- app/design/adminhtml/default/default/template/paypalmx/system/config/fieldset/global.phtml +600 -0
- app/design/adminhtml/default/default/template/paypalmx/system/config/fieldset/store.phtml +101 -0
- app/design/adminhtml/default/default/template/paypalmx/system/config/payflowlink/advanced.phtml +40 -0
- app/design/adminhtml/default/default/template/paypalmx/system/config/payflowlink/info.phtml +41 -0
- app/design/frontend/base/default/layout/paypalmx.xml +201 -0
- app/design/frontend/base/default/template/paypalmx/express/review.phtml +254 -0
- app/design/frontend/base/default/template/paypalmx/express/review/address.phtml +145 -0
- app/design/frontend/base/default/template/paypalmx/express/review/details.phtml +64 -0
- app/design/frontend/base/default/template/paypalmx/express/review/shipping/method.phtml +53 -0
- app/design/frontend/base/default/template/paypalmx/express/shortcut.phtml +332 -0
- app/design/frontend/base/default/template/paypalmx/hss/form.phtml +45 -0
- app/design/frontend/base/default/template/paypalmx/hss/iframe.phtml +48 -0
- app/design/frontend/base/default/template/paypalmx/hss/info.phtml +35 -0
- app/design/frontend/base/default/template/paypalmx/hss/js.phtml +66 -0
- app/design/frontend/base/default/template/paypalmx/hss/redirect.phtml +62 -0
- app/design/frontend/base/default/template/paypalmx/hss/review/button.phtml +27 -0
- app/design/frontend/base/default/template/paypalmx/partner/logo.phtml +10 -0
- app/design/frontend/base/default/template/paypalmx/payflowadvanced/form.phtml +45 -0
- app/design/frontend/base/default/template/paypalmx/payflowadvanced/iframe.phtml +48 -0
- app/design/frontend/base/default/template/paypalmx/payflowadvanced/info.phtml +35 -0
- app/design/frontend/base/default/template/paypalmx/payflowadvanced/redirect.phtml +71 -0
- app/design/frontend/base/default/template/paypalmx/payflowlink/form.phtml +45 -0
- app/design/frontend/base/default/template/paypalmx/payflowlink/iframe.phtml +48 -0
- app/design/frontend/base/default/template/paypalmx/payflowlink/info.phtml +35 -0
- app/design/frontend/base/default/template/paypalmx/payflowlink/redirect.phtml +71 -0
- app/design/frontend/base/default/template/paypalmx/payment/mark.phtml +39 -0
- app/design/frontend/base/default/template/paypalmx/payment/redirect.phtml +16 -0
- app/etc/modules/Ebcomm_PaypalMx.xml +10 -0
- app/locale/es_ES/Ebcomm_PaypalMx.csv +487 -0
- app/locale/es_MX/Ebcomm_PaypalMx.csv +487 -0
- package.xml +80 -0
- skin/adminhtml/default/default/images/paypalmx/accpmark_mensualidades_SP.PNG +0 -0
- skin/adminhtml/default/default/images/paypalmx/accpmark_tarjdeb_SP.PNG +0 -0
- skin/adminhtml/default/default/images/paypalmx/accpmark_visa_mc_SP.PNG +0 -0
- skin/adminhtml/default/default/images/paypalmx/logo-paypal.png +0 -0
- skin/adminhtml/default/default/images/paypalmx/pp-alt.png +0 -0
- skin/frontend/base/default/images/paypalmx/accpmark_mensualidades_SP.PNG +0 -0
- skin/frontend/base/default/images/paypalmx/accpmark_tarjdeb_SP.PNG +0 -0
- skin/frontend/base/default/images/paypalmx/accpmark_visa_mc_SP.PNG +0 -0
- skin/frontend/base/default/images/paypalmx/bdg_compra_segura_pp_.PNG +0 -0
- skin/frontend/base/default/images/paypalmx/logo-paypal.png +0 -0
- skin/frontend/base/default/images/paypalmx/paypalmx_loader.gif +0 -0
- skin/frontend/base/default/images/paypalmx/pp-alt.png +0 -0
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_Settlement_Details extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Block construction
|
| 6 |
+
* Initialize titles, buttons
|
| 7 |
+
*/
|
| 8 |
+
public function __construct()
|
| 9 |
+
{
|
| 10 |
+
parent::__construct();
|
| 11 |
+
$this->_controller = '';
|
| 12 |
+
$this->_headerText = Mage::helper('paypalmx')->__('Ver detalles de la transacción');
|
| 13 |
+
$this->_removeButton('reset')
|
| 14 |
+
->_removeButton('delete')
|
| 15 |
+
->_removeButton('save');
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Initialize form
|
| 20 |
+
* @return Mage_Paypal_Block_Adminhtml_Settlement_Details
|
| 21 |
+
*/
|
| 22 |
+
protected function _prepareLayout()
|
| 23 |
+
{
|
| 24 |
+
parent::_prepareLayout();
|
| 25 |
+
$this->setChild('form', $this->getLayout()->createBlock('paypalmx/adminhtml_settlement_details_form'));
|
| 26 |
+
return $this;
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Details/Form.php
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_Settlement_Details_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Prepare read-only data and group it by fieldsets
|
| 6 |
+
* @return Mage_Paypal_Block_Adminhtml_Settlement_Details_Form
|
| 7 |
+
*/
|
| 8 |
+
protected function _prepareForm()
|
| 9 |
+
{
|
| 10 |
+
$model = Mage::registry('current_transaction');
|
| 11 |
+
/* @var $model Mage_Paypal_Model_Report_Settlement_Row */
|
| 12 |
+
$settlement = Mage::getSingleton('paypalmx/report_settlement');
|
| 13 |
+
/* @var $settlement Mage_Paypal_Model_Report_Settlement */
|
| 14 |
+
|
| 15 |
+
$fieldsets = array(
|
| 16 |
+
'reference_fieldset' => array(
|
| 17 |
+
'fields' => array(
|
| 18 |
+
'transaction_id' => array('label' => $settlement->getFieldLabel('transaction_id')),
|
| 19 |
+
'invoice_id' => array('label' => $settlement->getFieldLabel('invoice_id')),
|
| 20 |
+
'paypal_reference_id' => array('label' => $settlement->getFieldLabel('paypal_reference_id')),
|
| 21 |
+
'paypal_reference_id_type' => array(
|
| 22 |
+
'label' => $settlement->getFieldLabel('paypal_reference_id_type'),
|
| 23 |
+
'value' => $model->getReferenceType($model->getData('paypal_reference_id_type'))
|
| 24 |
+
),
|
| 25 |
+
'custom_field' => array('label' => $settlement->getFieldLabel('custom_field')),
|
| 26 |
+
),
|
| 27 |
+
'legend' => Mage::helper('paypalmx')->__('Información de Referencia')
|
| 28 |
+
),
|
| 29 |
+
|
| 30 |
+
'transaction_fieldset' => array(
|
| 31 |
+
'fields' => array(
|
| 32 |
+
'transaction_event_code' => array(
|
| 33 |
+
'label' => $settlement->getFieldLabel('transaction_event_code'),
|
| 34 |
+
'value' => sprintf('%s (%s)', $model->getData('transaction_event_code'), $model->getTransactionEvent($model->getData('transaction_event_code')))
|
| 35 |
+
),
|
| 36 |
+
'transaction_initiation_date' => array(
|
| 37 |
+
'label' => $settlement->getFieldLabel('transaction_initiation_date'),
|
| 38 |
+
'value' => $this->helper('core')->formatDate($model->getData('transaction_initiation_date'), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true)
|
| 39 |
+
),
|
| 40 |
+
'transaction_completion_date' => array(
|
| 41 |
+
'label' => $settlement->getFieldLabel('transaction_completion_date'),
|
| 42 |
+
'value' => $this->helper('core')->formatDate($model->getData('transaction_completion_date'), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true)
|
| 43 |
+
),
|
| 44 |
+
'transaction_debit_or_credit' => array(
|
| 45 |
+
'label' => $settlement->getFieldLabel('transaction_debit_or_credit'),
|
| 46 |
+
'value' => $model->getDebitCreditText($model->getData('transaction_debit_or_credit'))
|
| 47 |
+
),
|
| 48 |
+
'gross_transaction_amount' => array(
|
| 49 |
+
'label' => $settlement->getFieldLabel('gross_transaction_amount'),
|
| 50 |
+
'value' => Mage::app()->getLocale()
|
| 51 |
+
->currency($model->getData('gross_transaction_currency'))
|
| 52 |
+
->toCurrency($model->getData('gross_transaction_amount'))
|
| 53 |
+
),
|
| 54 |
+
),
|
| 55 |
+
'legend' => Mage::helper('paypalmx')->__('Información de Pago Recibido')
|
| 56 |
+
),
|
| 57 |
+
|
| 58 |
+
'fee_fieldset' => array(
|
| 59 |
+
'fields' => array(
|
| 60 |
+
/*'fee_debit_or_credit' => array(
|
| 61 |
+
'label' => $settlement->getFieldLabel('fee_debit_or_credit'),
|
| 62 |
+
'value' => $model->getDebitCreditText($model->getData('fee_debit_or_credit'))
|
| 63 |
+
),*/
|
| 64 |
+
'fee_amount' => array(
|
| 65 |
+
'label' => $settlement->getFieldLabel('fee_amount'),
|
| 66 |
+
'value' => Mage::app()->getLocale()
|
| 67 |
+
->currency($model->getData('fee_currency'))
|
| 68 |
+
->toCurrency($model->getData('fee_amount'))
|
| 69 |
+
),
|
| 70 |
+
),
|
| 71 |
+
'legend' => Mage::helper('paypalmx')->__('Información de comisión de PayPal')
|
| 72 |
+
),
|
| 73 |
+
);
|
| 74 |
+
|
| 75 |
+
$form = new Varien_Data_Form();
|
| 76 |
+
foreach ($fieldsets as $key => $data) {
|
| 77 |
+
$fieldset = $form->addFieldset($key, array('legend' => $data['legend']));
|
| 78 |
+
foreach ($data['fields'] as $id => $info) {
|
| 79 |
+
$fieldset->addField($id, 'label', array(
|
| 80 |
+
'name' => $id,
|
| 81 |
+
'label' => $info['label'],
|
| 82 |
+
'title' => $info['label'],
|
| 83 |
+
'value' => isset($info['value']) ? $info['value'] : $model->getData($id),
|
| 84 |
+
));
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
$this->setForm($form);
|
| 88 |
+
return parent::_prepareForm();
|
| 89 |
+
}
|
| 90 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Report.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_Settlement_Report extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Prepare grid container, add additional buttons
|
| 6 |
+
*/
|
| 7 |
+
public function __construct()
|
| 8 |
+
{
|
| 9 |
+
$this->_blockGroup = 'paypalmx';
|
| 10 |
+
$this->_controller = 'adminhtml_settlement_report';
|
| 11 |
+
$this->_headerText = Mage::helper('paypalmx')->__('Reportes de Solución PayPal México');
|
| 12 |
+
parent::__construct();
|
| 13 |
+
$this->_removeButton('add');
|
| 14 |
+
$message = Mage::helper('paypalmx')->__('Conectando al servidor de PayPal para buscar nuevos reportes. ¿Estas seguro que deseas contuniar?');
|
| 15 |
+
$this->_addButton('fetch', array(
|
| 16 |
+
'label' => Mage::helper('paypalmx')->__('Buscar Actualizaciones'),
|
| 17 |
+
'onclick' => "confirmSetLocation('{$message}', '{$this->getUrl('*/*/fetch')}')",
|
| 18 |
+
'class' => 'task'
|
| 19 |
+
));
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/Settlement/Report/Grid.php
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_Settlement_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Retain filter parameters in session
|
| 6 |
+
*
|
| 7 |
+
* @var bool
|
| 8 |
+
*/
|
| 9 |
+
protected $_saveParametersInSession = true;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Constructor
|
| 13 |
+
* Set main configuration of grid
|
| 14 |
+
*/
|
| 15 |
+
public function __construct()
|
| 16 |
+
{
|
| 17 |
+
parent::__construct();
|
| 18 |
+
$this->setId('settlementGrid');
|
| 19 |
+
$this->setUseAjax(true);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Prepare collection for grid
|
| 24 |
+
* @return Mage_Paypal_Block_Adminhtml_Settlement_Grid
|
| 25 |
+
*/
|
| 26 |
+
protected function _prepareCollection()
|
| 27 |
+
{
|
| 28 |
+
$collection = Mage::getResourceModel('paypalmx/report_settlement_row_collection');
|
| 29 |
+
$this->setCollection($collection);
|
| 30 |
+
if (!$this->getParam($this->getVarNameSort())) {
|
| 31 |
+
$collection->setOrder('row_id', 'desc');
|
| 32 |
+
}
|
| 33 |
+
return parent::_prepareCollection();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Prepare grid columns
|
| 38 |
+
* @return Mage_Paypal_Block_Adminhtml_Settlement_Grid
|
| 39 |
+
*/
|
| 40 |
+
protected function _prepareColumns()
|
| 41 |
+
{
|
| 42 |
+
$settlement = Mage::getSingleton('paypalmx/report_settlement');
|
| 43 |
+
$this->addColumn('report_date', array(
|
| 44 |
+
'header' => $settlement->getFieldLabel('report_date'),
|
| 45 |
+
'index' => 'report_date',
|
| 46 |
+
'type' => 'date'
|
| 47 |
+
));
|
| 48 |
+
$this->addColumn('account_id', array(
|
| 49 |
+
'header' => $settlement->getFieldLabel('account_id'),
|
| 50 |
+
'index' => 'account_id'
|
| 51 |
+
));
|
| 52 |
+
$this->addColumn('transaction_id', array(
|
| 53 |
+
'header' => $settlement->getFieldLabel('transaction_id'),
|
| 54 |
+
'index' => 'transaction_id'
|
| 55 |
+
));
|
| 56 |
+
$this->addColumn('invoice_id', array(
|
| 57 |
+
'header' => $settlement->getFieldLabel('invoice_id'),
|
| 58 |
+
'index' => 'invoice_id'
|
| 59 |
+
));
|
| 60 |
+
$this->addColumn('paypal_reference_id', array(
|
| 61 |
+
'header' => $settlement->getFieldLabel('paypal_reference_id'),
|
| 62 |
+
'index' => 'paypal_reference_id'
|
| 63 |
+
));
|
| 64 |
+
$this->addColumn('transaction_event_code', array(
|
| 65 |
+
'header' => $settlement->getFieldLabel('transaction_event'),
|
| 66 |
+
'index' => 'transaction_event_code',
|
| 67 |
+
'type' => 'options',
|
| 68 |
+
'options' => Mage::getModel('paypal/report_settlement_row')->getTransactionEvents()
|
| 69 |
+
));
|
| 70 |
+
$this->addColumn('transaction_initiation_date', array(
|
| 71 |
+
'header' => $settlement->getFieldLabel('transaction_initiation_date'),
|
| 72 |
+
'index' => 'transaction_initiation_date',
|
| 73 |
+
'type' => 'datetime'
|
| 74 |
+
));
|
| 75 |
+
$this->addColumn('transaction_completion_date', array(
|
| 76 |
+
'header' => $settlement->getFieldLabel('transaction_completion_date'),
|
| 77 |
+
'index' => 'transaction_completion_date',
|
| 78 |
+
'type' => 'datetime'
|
| 79 |
+
));
|
| 80 |
+
$this->addColumn('gross_transaction_amount', array(
|
| 81 |
+
'header' => $settlement->getFieldLabel('gross_transaction_amount'),
|
| 82 |
+
'index' => 'gross_transaction_amount',
|
| 83 |
+
'type' => 'currency',
|
| 84 |
+
'currency' => 'gross_transaction_currency',
|
| 85 |
+
));
|
| 86 |
+
$this->addColumn('fee_amount', array(
|
| 87 |
+
'header' => $settlement->getFieldLabel('fee_amount'),
|
| 88 |
+
'index' => 'fee_amount',
|
| 89 |
+
'type' => 'currency',
|
| 90 |
+
'currency' => 'gross_transaction_currency',
|
| 91 |
+
));
|
| 92 |
+
return parent::_prepareColumns();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Return grid URL
|
| 97 |
+
* @return string
|
| 98 |
+
*/
|
| 99 |
+
public function getGridUrl()
|
| 100 |
+
{
|
| 101 |
+
return $this->getUrl('*/*/grid');
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* Return item view URL
|
| 106 |
+
* @return string
|
| 107 |
+
*/
|
| 108 |
+
public function getRowUrl($item)
|
| 109 |
+
{
|
| 110 |
+
return $this->getUrl('*/*/details', array('id' => $item->getId()));
|
| 111 |
+
}
|
| 112 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/ApiWizard.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Custom renderer for PayPal API credentials wizard popup
|
| 4 |
+
*/
|
| 5 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_ApiWizard extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Set template to itself
|
| 9 |
+
*/
|
| 10 |
+
protected function _prepareLayout()
|
| 11 |
+
{
|
| 12 |
+
parent::_prepareLayout();
|
| 13 |
+
if (!$this->getTemplate()) {
|
| 14 |
+
$this->setTemplate('paypalmx/system/config/api_wizard.phtml');
|
| 15 |
+
}
|
| 16 |
+
return $this;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Unset some non-related element parameters
|
| 21 |
+
*
|
| 22 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 23 |
+
* @return string
|
| 24 |
+
*/
|
| 25 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 26 |
+
{
|
| 27 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
| 28 |
+
return parent::render($element);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Get the button and scripts contents
|
| 33 |
+
*
|
| 34 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 35 |
+
* @return string
|
| 36 |
+
*/
|
| 37 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 38 |
+
{
|
| 39 |
+
$originalData = $element->getOriginalData();
|
| 40 |
+
$this->addData(array(
|
| 41 |
+
'button_label' => Mage::helper('paypalmx')->__($originalData['button_label']),
|
| 42 |
+
'button_url' => $originalData['button_url'],
|
| 43 |
+
'html_id' => $element->getHtmlId(),
|
| 44 |
+
'sandbox_button_label' => Mage::helper('paypalmx')->__($originalData['sandbox_button_label']),
|
| 45 |
+
'sandbox_button_url' => $originalData['sandbox_button_url'],
|
| 46 |
+
'sandbox_html_id' => 'sandbox_' . $element->getHtmlId(),
|
| 47 |
+
));
|
| 48 |
+
return $this->_toHtml();
|
| 49 |
+
}
|
| 50 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Field/Country.php
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Field renderer for PayPal merchant country selector
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Field_Country
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 36 |
+
{
|
| 37 |
+
/**#@+
|
| 38 |
+
*
|
| 39 |
+
* Request parameters names
|
| 40 |
+
*/
|
| 41 |
+
const REQUEST_PARAM_COUNTRY = 'country';
|
| 42 |
+
const REQUEST_PARAM_DEFAULT = 'default_country';
|
| 43 |
+
/**#@-*/
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Country of default scope
|
| 47 |
+
*
|
| 48 |
+
* @var string
|
| 49 |
+
*/
|
| 50 |
+
protected $_defaultCountry;
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Render country field considering request parameter
|
| 54 |
+
*
|
| 55 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 56 |
+
* @return string
|
| 57 |
+
*/
|
| 58 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 59 |
+
{
|
| 60 |
+
$country = $this->getRequest()->getParam(self::REQUEST_PARAM_COUNTRY);
|
| 61 |
+
if ($country) {
|
| 62 |
+
$element->setValue($country);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if ($element->getCanUseDefaultValue()) {
|
| 66 |
+
$defaultConfigNode = Mage::getConfig()->getNode(null, 'default');
|
| 67 |
+
if ($defaultConfigNode) {
|
| 68 |
+
$this->_defaultCountry = (string)$defaultConfigNode->descend('paypalmx/general/merchant_country');
|
| 69 |
+
}
|
| 70 |
+
if (!$this->_defaultCountry) {
|
| 71 |
+
$this->_defaultCountry = Mage::helper('core')->getDefaultCountry();
|
| 72 |
+
}
|
| 73 |
+
if ($country) {
|
| 74 |
+
$shouldInherit = $country == $this->_defaultCountry
|
| 75 |
+
&& $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT);
|
| 76 |
+
$element->setInherit($shouldInherit);
|
| 77 |
+
}
|
| 78 |
+
if ($element->getInherit()) {
|
| 79 |
+
$this->_defaultCountry = null;
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return parent::render($element);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Get country selector html
|
| 88 |
+
*
|
| 89 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 90 |
+
* @return string
|
| 91 |
+
*/
|
| 92 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 93 |
+
{
|
| 94 |
+
$configDataModel = Mage::getSingleton('adminhtml/config_data');
|
| 95 |
+
$urlParams = array(
|
| 96 |
+
'section' => $configDataModel->getSection(),
|
| 97 |
+
'website' => $configDataModel->getWebsite(),
|
| 98 |
+
'store' => $configDataModel->getStore(),
|
| 99 |
+
self::REQUEST_PARAM_COUNTRY => '__country__',
|
| 100 |
+
);
|
| 101 |
+
$urlString = $this->helper('core')
|
| 102 |
+
->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams));
|
| 103 |
+
$jsString = '
|
| 104 |
+
$("' . $element->getHtmlId() . '").observe("change", function () {
|
| 105 |
+
location.href = \'' . $urlString . '\'.replace("__country__", this.value);
|
| 106 |
+
});
|
| 107 |
+
';
|
| 108 |
+
|
| 109 |
+
if ($this->_defaultCountry) {
|
| 110 |
+
$urlParams[self::REQUEST_PARAM_DEFAULT] = '__default__';
|
| 111 |
+
$urlString = $this->helper('core')
|
| 112 |
+
->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams));
|
| 113 |
+
$jsParentCountry = $this->helper('core')->jsQuoteEscape($this->_defaultCountry);
|
| 114 |
+
$jsString .= '
|
| 115 |
+
$("' . $element->getHtmlId() . '_inherit").observe("click", function () {
|
| 116 |
+
if (this.checked) {
|
| 117 |
+
location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\')
|
| 118 |
+
.replace("__default__", "1");
|
| 119 |
+
}
|
| 120 |
+
});
|
| 121 |
+
';
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return parent::_getElementHtml($element) . $this->helper('adminhtml/js')
|
| 125 |
+
->getScript('document.observe("dom:loaded", function() {' . $jsString . '});');
|
| 126 |
+
}
|
| 127 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Field/Hidden.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Field renderer for hidden fields
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Field_Hidden
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Decorate field row html to be invisible
|
| 39 |
+
*
|
| 40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 41 |
+
* @param string $html
|
| 42 |
+
* @return string
|
| 43 |
+
*/
|
| 44 |
+
protected function _decorateRowHtml($element, $html)
|
| 45 |
+
{
|
| 46 |
+
return '<tr id="row_' . $element->getHtmlId() . '" style="display: none;">' . $html . '</tr>';
|
| 47 |
+
}
|
| 48 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Expanded.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Fielset renderer which expanded by default
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Expanded
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Return collapse state
|
| 39 |
+
*
|
| 40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 41 |
+
* @return bool
|
| 42 |
+
*/
|
| 43 |
+
protected function _getCollapseState($element)
|
| 44 |
+
{
|
| 45 |
+
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
|
| 46 |
+
if (isset($extra['configState'][$element->getId()])) {
|
| 47 |
+
return $extra['configState'][$element->getId()];
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
return true;
|
| 51 |
+
}
|
| 52 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Global.php
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Fieldset renderer for PayPal global settings
|
| 29 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 30 |
+
* @deprecated since 1.7.0.1
|
| 31 |
+
*/
|
| 32 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Global
|
| 33 |
+
extends Mage_Adminhtml_Block_Abstract
|
| 34 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Associative array of PayPal product selection elements
|
| 38 |
+
*
|
| 39 |
+
* @var array
|
| 40 |
+
*/
|
| 41 |
+
protected $_elements = array();
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Custom template
|
| 45 |
+
*
|
| 46 |
+
* @var string
|
| 47 |
+
*/
|
| 48 |
+
protected $_template = 'paypal/system/config/fieldset/global.phtml';
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Render fieldset html
|
| 52 |
+
*
|
| 53 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
| 54 |
+
* @return string
|
| 55 |
+
*/
|
| 56 |
+
public function render(Varien_Data_Form_Element_Abstract $fieldset)
|
| 57 |
+
{
|
| 58 |
+
foreach ($fieldset->getSortedElements() as $element) {
|
| 59 |
+
$htmlId = $element->getHtmlId();
|
| 60 |
+
$this->_elements[$htmlId] = $element;
|
| 61 |
+
}
|
| 62 |
+
$originalData = $fieldset->getOriginalData();
|
| 63 |
+
$this->addData(array(
|
| 64 |
+
'fieldset_label' => $fieldset->getLegend(),
|
| 65 |
+
'fieldset_help_url' => isset($originalData['help_url']) ? $originalData['help_url'] : '',
|
| 66 |
+
));
|
| 67 |
+
return $this->toHtml();
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Get array of element objects
|
| 72 |
+
*
|
| 73 |
+
* @return array
|
| 74 |
+
*/
|
| 75 |
+
public function getElements()
|
| 76 |
+
{
|
| 77 |
+
return $this->_elements;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Get element by id
|
| 82 |
+
*
|
| 83 |
+
* @param string $elementId
|
| 84 |
+
* @return Varien_Data_Form_Element_Abstract
|
| 85 |
+
*/
|
| 86 |
+
public function getElement($elementId)
|
| 87 |
+
{
|
| 88 |
+
if (isset($this->_elements[$elementId])) {
|
| 89 |
+
return $this->_elements[$elementId];
|
| 90 |
+
}
|
| 91 |
+
return false;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Return checkbox html with hidden field for correct config values
|
| 96 |
+
*
|
| 97 |
+
* @param string $elementId
|
| 98 |
+
* @return string
|
| 99 |
+
*/
|
| 100 |
+
public function getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 101 |
+
{
|
| 102 |
+
$configValue = (string)$element->getValue();
|
| 103 |
+
if ($configValue) {
|
| 104 |
+
$element->setChecked(true);
|
| 105 |
+
} else {
|
| 106 |
+
$element->setValue('1');
|
| 107 |
+
}
|
| 108 |
+
if ($element->getCanUseDefaultValue() && $element->getInherit()) {
|
| 109 |
+
$element->setDisabled(true);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
$hidden = new Varien_Data_Form_Element_Hidden(array(
|
| 113 |
+
'html_id' => $element->getHtmlId() . '_value',
|
| 114 |
+
'name' => $element->getName(),
|
| 115 |
+
'value' => '0'
|
| 116 |
+
));
|
| 117 |
+
$hidden->setForm($element->getForm());
|
| 118 |
+
return $hidden->getElementHtml() . $element->getElementHtml();
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Whether element should be rendered in "simplified" mode
|
| 123 |
+
*
|
| 124 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 125 |
+
* @return bool
|
| 126 |
+
*/
|
| 127 |
+
public function getIsElementSimplified(Varien_Data_Form_Element_Abstract $element)
|
| 128 |
+
{
|
| 129 |
+
$originalData = $element->getOriginalData();
|
| 130 |
+
return isset($originalData['is_simplified']) && 1 == $originalData['is_simplified'];
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Getter for element label
|
| 135 |
+
*
|
| 136 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 137 |
+
* @return string
|
| 138 |
+
*/
|
| 139 |
+
public function getElementLabel(Varien_Data_Form_Element_Abstract $element)
|
| 140 |
+
{
|
| 141 |
+
return $element->getLabel();
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Getter for element comment
|
| 146 |
+
*
|
| 147 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 148 |
+
* @return string
|
| 149 |
+
*/
|
| 150 |
+
public function getElementComment(Varien_Data_Form_Element_Abstract $element)
|
| 151 |
+
{
|
| 152 |
+
return $element->getComment();
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Getter for element comment
|
| 157 |
+
*
|
| 158 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 159 |
+
* @return string
|
| 160 |
+
*/
|
| 161 |
+
public function getElementOriginalData(Varien_Data_Form_Element_Abstract $element, $key)
|
| 162 |
+
{
|
| 163 |
+
$data = $element->getOriginalData();
|
| 164 |
+
return isset($data[$key]) ? $data[$key] : '';
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Check whether checkbox has "Use default" option or not
|
| 169 |
+
*
|
| 170 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 171 |
+
* @return bool
|
| 172 |
+
*/
|
| 173 |
+
public function hasInheritElement(Varien_Data_Form_Element_Abstract $element)
|
| 174 |
+
{
|
| 175 |
+
return (bool)$element->getCanUseDefaultValue();
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* Return "Use default" checkbox html
|
| 180 |
+
*
|
| 181 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 182 |
+
* @return string
|
| 183 |
+
*/
|
| 184 |
+
public function getInheritElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 185 |
+
{
|
| 186 |
+
$elementId = $element->getHtmlId();
|
| 187 |
+
$inheritCheckbox = new Varien_Data_Form_Element_Checkbox(array(
|
| 188 |
+
'html_id' => $elementId . '_inherit',
|
| 189 |
+
'name' => preg_replace('/\[value\](\[\])?$/', '[inherit]', $element->getName()),
|
| 190 |
+
'value' => '1',
|
| 191 |
+
'class' => 'checkbox config-inherit',
|
| 192 |
+
'onclick' => 'toggleValueElements(this, $(\'' . $elementId . '\').up())'
|
| 193 |
+
));
|
| 194 |
+
if ($element->getInherit()) {
|
| 195 |
+
$inheritCheckbox->setChecked(true);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
$inheritCheckbox->setForm($element->getForm());
|
| 199 |
+
return $inheritCheckbox->getElementHtml();
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* Return label for "Use default" checkbox
|
| 204 |
+
*
|
| 205 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 206 |
+
* @return string
|
| 207 |
+
*/
|
| 208 |
+
public function getInheritElementLabelHtml(Varien_Data_Form_Element_Abstract $element)
|
| 209 |
+
{
|
| 210 |
+
return sprintf('<label for="%s" class="inherit" title="%s">%s</label>',
|
| 211 |
+
$element->getHtmlId() . '_inherit',
|
| 212 |
+
$element->getDefaultValue(),
|
| 213 |
+
Mage::helper('adminhtml')->__('Use Default')
|
| 214 |
+
);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Return element label with tag SPAN
|
| 219 |
+
*
|
| 220 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 221 |
+
* @return string
|
| 222 |
+
*/
|
| 223 |
+
public function getElementLabelTextHtml(Varien_Data_Form_Element_Abstract $element)
|
| 224 |
+
{
|
| 225 |
+
return sprintf('<span id="%s">%s</span>',
|
| 226 |
+
$element->getHtmlId() . '_label_text',
|
| 227 |
+
$this->escapeHtml($this->getElementLabel($element))
|
| 228 |
+
);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Return backend config for element like JSON
|
| 233 |
+
*
|
| 234 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 235 |
+
* @return string
|
| 236 |
+
*/
|
| 237 |
+
public function getElementBackendConfig(Varien_Data_Form_Element_Abstract $element)
|
| 238 |
+
{
|
| 239 |
+
return Mage::helper('paypalmx')->getElementBackendConfig($element);
|
| 240 |
+
}
|
| 241 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Group.php
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Fieldset renderer for PayPal solutions group
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Group
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Return header comment part of html for fieldset
|
| 39 |
+
*
|
| 40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 41 |
+
* @return string
|
| 42 |
+
*/
|
| 43 |
+
protected function _getHeaderCommentHtml($element)
|
| 44 |
+
{
|
| 45 |
+
$groupConfig = $this->getGroup($element)->asArray();
|
| 46 |
+
|
| 47 |
+
if (empty($groupConfig['help_url']) || !$element->getComment()) {
|
| 48 |
+
return parent::_getHeaderCommentHtml($element);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
$html = '<div class="comment">' . $element->getComment()
|
| 52 |
+
. ' <a target="_blank" href="' . $groupConfig['help_url'] . '">'
|
| 53 |
+
. Mage::helper('paypalmx')->__('Help') . '</a></div>';
|
| 54 |
+
|
| 55 |
+
return $html;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Return collapse state
|
| 60 |
+
*
|
| 61 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 62 |
+
* @return bool
|
| 63 |
+
*/
|
| 64 |
+
protected function _getCollapseState($element)
|
| 65 |
+
{
|
| 66 |
+
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
|
| 67 |
+
if (isset($extra['configState'][$element->getId()])) {
|
| 68 |
+
return $extra['configState'][$element->getId()];
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
if ($element->getExpanded() !== null) {
|
| 72 |
+
return 1;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
return false;
|
| 76 |
+
}
|
| 77 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Hint.php
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Renderer for PayPal banner in System Configuration
|
| 30 |
+
*
|
| 31 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 32 |
+
*/
|
| 33 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Hint
|
| 34 |
+
extends Mage_Adminhtml_Block_Abstract
|
| 35 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
| 36 |
+
{
|
| 37 |
+
protected $_template = 'paypal/system/config/fieldset/hint.phtml';
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Render fieldset html
|
| 41 |
+
*
|
| 42 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 43 |
+
* @return string
|
| 44 |
+
*/
|
| 45 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 46 |
+
{
|
| 47 |
+
$elementOriginalData = $element->getOriginalData();
|
| 48 |
+
if (isset($elementOriginalData['help_link'])) {
|
| 49 |
+
$this->setHelpLink($elementOriginalData['help_link']);
|
| 50 |
+
}
|
| 51 |
+
$js = '
|
| 52 |
+
paypalToggleSolution = function(id, url) {
|
| 53 |
+
var doScroll = false;
|
| 54 |
+
Fieldset.toggleCollapse(id, url);
|
| 55 |
+
if ($(this).hasClassName("open")) {
|
| 56 |
+
$$(".with-button button.button").each(function(anotherButton) {
|
| 57 |
+
if (anotherButton != this && $(anotherButton).hasClassName("open")) {
|
| 58 |
+
$(anotherButton).click();
|
| 59 |
+
doScroll = true;
|
| 60 |
+
}
|
| 61 |
+
}.bind(this));
|
| 62 |
+
}
|
| 63 |
+
if (doScroll) {
|
| 64 |
+
var pos = Element.cumulativeOffset($(this));
|
| 65 |
+
window.scrollTo(pos[0], pos[1] - 45);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
togglePaypalSolutionConfigureButton = function(button, enable) {
|
| 70 |
+
var $button = $(button);
|
| 71 |
+
$button.disabled = !enable;
|
| 72 |
+
if ($button.hasClassName("disabled") && enable) {
|
| 73 |
+
$button.removeClassName("disabled");
|
| 74 |
+
} else if (!$button.hasClassName("disabled") && !enable) {
|
| 75 |
+
$button.addClassName("disabled");
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// check store-view disabling Express Checkout
|
| 80 |
+
document.observe("dom:loaded", function() {
|
| 81 |
+
var ecButton = $$(".pp-method-express button.button")[0];
|
| 82 |
+
var ecEnabler = $$(".paypal-ec-enabler")[0];
|
| 83 |
+
if (typeof ecButton == "undefined" || typeof ecEnabler != "undefined") {
|
| 84 |
+
return;
|
| 85 |
+
}
|
| 86 |
+
var $ecButton = $(ecButton);
|
| 87 |
+
$$(".with-button button.button").each(function(configureButton) {
|
| 88 |
+
if (configureButton != ecButton && !configureButton.disabled
|
| 89 |
+
&& !$(configureButton).hasClassName("paypal-ec-separate")
|
| 90 |
+
) {
|
| 91 |
+
togglePaypalSolutionConfigureButton(ecButton, false);
|
| 92 |
+
}
|
| 93 |
+
});
|
| 94 |
+
});
|
| 95 |
+
';
|
| 96 |
+
return $this->toHtml() . $this->helper('adminhtml/js')->getScript($js);
|
| 97 |
+
}
|
| 98 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Location.php
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Fieldset renderer for PayPal Merchant Location fieldset
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Location
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Add conflicts resolution js code to the fieldset
|
| 39 |
+
*
|
| 40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 41 |
+
* @param bool $tooltipsExist Init tooltips observer or not
|
| 42 |
+
* @return string
|
| 43 |
+
*/
|
| 44 |
+
protected function _getExtraJs($element, $tooltipsExist = false)
|
| 45 |
+
{
|
| 46 |
+
$js = '
|
| 47 |
+
document.observe("dom:loaded", function() {
|
| 48 |
+
$$(".with-button button.button").each(function(configureButton) {
|
| 49 |
+
togglePaypalSolutionConfigureButton(configureButton, true);
|
| 50 |
+
});
|
| 51 |
+
var paypalConflictsObject = {
|
| 52 |
+
"isConflict": false,
|
| 53 |
+
"ecMissed": false,
|
| 54 |
+
sharePayflowEnabling: function(enabler, isEvent) {
|
| 55 |
+
var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
|
| 56 |
+
if (typeof ecPayflowEnabler == "undefined") {
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
|
| 60 |
+
|
| 61 |
+
if (!enabler.enablerObject.ecPayflow) {
|
| 62 |
+
if ((!ecPayflowScopeElement || !ecPayflowScopeElement.checked) && isEvent
|
| 63 |
+
&& enabler.value == 1
|
| 64 |
+
) {
|
| 65 |
+
ecPayflowEnabler.value = 0;
|
| 66 |
+
fireEvent(ecPayflowEnabler, "change");
|
| 67 |
+
}
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
var enablerScopeElement = adminSystemConfig.getScopeElement(enabler);
|
| 72 |
+
if (enablerScopeElement && ecPayflowScopeElement
|
| 73 |
+
&& enablerScopeElement.checked != ecPayflowScopeElement.checked
|
| 74 |
+
&& (isEvent || ecPayflowScopeElement.checked)
|
| 75 |
+
) {
|
| 76 |
+
$(ecPayflowScopeElement).click();
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
var ecEnabler = $$(".paypal-ec-enabler")[0];
|
| 80 |
+
if (ecPayflowEnabler.value != enabler.value && (isEvent || enabler.value == 1)) {
|
| 81 |
+
ecPayflowEnabler.value = enabler.value;
|
| 82 |
+
fireEvent(ecPayflowEnabler, "change");
|
| 83 |
+
if (ecPayflowEnabler.value == 1) {
|
| 84 |
+
if (typeof ecEnabler != "undefined") {
|
| 85 |
+
var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
|
| 86 |
+
ecEnabler.value = 1;
|
| 87 |
+
if (ecEnablerScopeElement && ecEnablerScopeElement.checked) {
|
| 88 |
+
paypalConflictsObject.checklessEventAction(ecEnablerScopeElement, false);
|
| 89 |
+
}
|
| 90 |
+
paypalConflictsObject.checklessEventAction(ecEnabler, true);
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
if (!isEvent && ecPayflowEnabler.value == 1 && typeof ecEnabler != "undefined") {
|
| 95 |
+
var ecSolution = $$(".pp-method-express")[0];
|
| 96 |
+
if (typeof ecSolution != "undefined" && !$(ecSolution).hasClassName("enabled")) {
|
| 97 |
+
ecSolution.addClassName("enabled");
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
onChangeEnabler: function(event) {
|
| 102 |
+
paypalConflictsObject.checkPaymentConflicts($(Event.element(event)), "change");
|
| 103 |
+
},
|
| 104 |
+
onClickEnablerScope: function(event) {
|
| 105 |
+
paypalConflictsObject.checkPaymentConflicts(
|
| 106 |
+
$(adminSystemConfig.getUpTr($(Event.element(event))).select(".paypal-enabler")[0]),
|
| 107 |
+
"click"
|
| 108 |
+
);
|
| 109 |
+
},
|
| 110 |
+
getSharedElements: function(element) {
|
| 111 |
+
var sharedElements = [];
|
| 112 |
+
adminSystemConfig.mapClasses(element, true, function(elementClassName) {
|
| 113 |
+
$$("." + elementClassName).each(function(sharedElement) {
|
| 114 |
+
if (sharedElements.indexOf(sharedElement) == -1) {
|
| 115 |
+
sharedElements.push(sharedElement);
|
| 116 |
+
}
|
| 117 |
+
});
|
| 118 |
+
});
|
| 119 |
+
if (sharedElements.length == 0) {
|
| 120 |
+
sharedElements.push(element);
|
| 121 |
+
}
|
| 122 |
+
return sharedElements;
|
| 123 |
+
},
|
| 124 |
+
checklessEventAction: function(element, isChange) {
|
| 125 |
+
var action = isChange ? "change" : "click";
|
| 126 |
+
var handler = isChange
|
| 127 |
+
? paypalConflictsObject.onChangeEnabler
|
| 128 |
+
: paypalConflictsObject.onClickEnablerScope;
|
| 129 |
+
paypalConflictsObject.getSharedElements(element).each(function(sharedElement) {
|
| 130 |
+
Event.stopObserving(sharedElement, action, handler);
|
| 131 |
+
if (isChange) {
|
| 132 |
+
sharedElement.value = element.value;
|
| 133 |
+
if ($(sharedElement).requiresObj) {
|
| 134 |
+
$(sharedElement).requiresObj.indicateEnabled();
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
});
|
| 138 |
+
if (isChange) {
|
| 139 |
+
fireEvent(element, "change");
|
| 140 |
+
} else {
|
| 141 |
+
$(element).click();
|
| 142 |
+
}
|
| 143 |
+
paypalConflictsObject.getSharedElements(element).each(function(sharedElement) {
|
| 144 |
+
Event.observe(sharedElement, action, handler);
|
| 145 |
+
});
|
| 146 |
+
},
|
| 147 |
+
ecCheckAvailability: function() {
|
| 148 |
+
var ecButton = $$(".pp-method-express button.button")[0];
|
| 149 |
+
if (typeof ecButton == "undefined") {
|
| 150 |
+
return;
|
| 151 |
+
}
|
| 152 |
+
var couldBeConfigured = true;
|
| 153 |
+
$$(".paypal-enabler").each(function(enabler) {
|
| 154 |
+
if (enabler.enablerObject.ecEnabler || enabler.enablerObject.ecConflicts
|
| 155 |
+
|| enabler.enablerObject.ecSeparate
|
| 156 |
+
) {
|
| 157 |
+
return;
|
| 158 |
+
}
|
| 159 |
+
if (enabler.value == 1) {
|
| 160 |
+
couldBeConfigured = false;
|
| 161 |
+
}
|
| 162 |
+
});
|
| 163 |
+
if (couldBeConfigured) {
|
| 164 |
+
togglePaypalSolutionConfigureButton(ecButton, true);
|
| 165 |
+
} else {
|
| 166 |
+
togglePaypalSolutionConfigureButton(ecButton, false);
|
| 167 |
+
}
|
| 168 |
+
},
|
| 169 |
+
// type could be "initial", "change", "click"
|
| 170 |
+
checkPaymentConflicts: function(enabler, type) {
|
| 171 |
+
var isEvent = (type != "initial");
|
| 172 |
+
var ecEnabler = $$(".paypal-ec-enabler")[0];
|
| 173 |
+
|
| 174 |
+
if (enabler.value == 0) {
|
| 175 |
+
if (!enabler.enablerObject.ecIndependent && type == "change") {
|
| 176 |
+
if (typeof ecEnabler != "undefined" && ecEnabler.value == 1) {
|
| 177 |
+
var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
|
| 178 |
+
if (!ecEnablerScopeElement || !ecEnablerScopeElement.checked) {
|
| 179 |
+
ecEnabler.value = 0;
|
| 180 |
+
paypalConflictsObject.checklessEventAction(ecEnabler, true);
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
paypalConflictsObject.ecCheckAvailability();
|
| 185 |
+
paypalConflictsObject.sharePayflowEnabling(enabler, isEvent);
|
| 186 |
+
return;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
var confirmationApproved = isEvent;
|
| 190 |
+
var confirmationShowed = false;
|
| 191 |
+
// check other solutions
|
| 192 |
+
$$(".paypal-enabler").each(function(anotherEnabler) {
|
| 193 |
+
var anotherEnablerScopeElement = adminSystemConfig.getScopeElement(anotherEnabler);
|
| 194 |
+
if (!confirmationApproved && isEvent || $(anotherEnabler) == enabler
|
| 195 |
+
|| anotherEnabler.value == 0
|
| 196 |
+
&& (!anotherEnablerScopeElement || !anotherEnablerScopeElement.checked)
|
| 197 |
+
) {
|
| 198 |
+
return;
|
| 199 |
+
}
|
| 200 |
+
var conflict = enabler.enablerObject.ecConflicts && anotherEnabler.enablerObject.ecEnabler
|
| 201 |
+
|| enabler.enablerObject.ecEnabler && anotherEnabler.enablerObject.ecConflicts
|
| 202 |
+
|| !enabler.enablerObject.ecIndependent && anotherEnabler.enablerObject.ecConflicts
|
| 203 |
+
|| !enabler.enablerObject.ecEnabler && !anotherEnabler.enablerObject.ecEnabler;
|
| 204 |
+
|
| 205 |
+
if (conflict && !confirmationShowed && anotherEnabler.value == 1) {
|
| 206 |
+
if (isEvent) {
|
| 207 |
+
confirmationApproved = confirm(\'' . $this->helper('core')->jsQuoteEscape($this->__('There is already another PayPal solution enabled. Enable this solution instead?')) . '\');
|
| 208 |
+
} else {
|
| 209 |
+
paypalConflictsObject.isConflict = true;
|
| 210 |
+
}
|
| 211 |
+
confirmationShowed = true;
|
| 212 |
+
}
|
| 213 |
+
if (conflict && confirmationApproved) {
|
| 214 |
+
anotherEnabler.value = 0;
|
| 215 |
+
if (anotherEnablerScopeElement && anotherEnablerScopeElement.checked && isEvent) {
|
| 216 |
+
paypalConflictsObject.checklessEventAction(anotherEnablerScopeElement, false);
|
| 217 |
+
}
|
| 218 |
+
paypalConflictsObject.checklessEventAction(anotherEnabler, true);
|
| 219 |
+
}
|
| 220 |
+
});
|
| 221 |
+
|
| 222 |
+
if (!enabler.enablerObject.ecIndependent) {
|
| 223 |
+
if (!isEvent && (typeof ecEnabler == "undefined" || ecEnabler.value == 0)) {
|
| 224 |
+
if (!enabler.enablerObject.ecPayflow) {
|
| 225 |
+
paypalConflictsObject.ecMissed = true;
|
| 226 |
+
}
|
| 227 |
+
} else if (isEvent && typeof ecEnabler != "undefined" && confirmationApproved) {
|
| 228 |
+
var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
|
| 229 |
+
if (ecEnablerScopeElement && ecEnablerScopeElement.checked) {
|
| 230 |
+
paypalConflictsObject.checklessEventAction(ecEnablerScopeElement, false);
|
| 231 |
+
}
|
| 232 |
+
if (ecEnabler.value == 0) {
|
| 233 |
+
ecEnabler.value = 1;
|
| 234 |
+
paypalConflictsObject.checklessEventAction(ecEnabler, true);
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
if (!confirmationApproved && isEvent) {
|
| 240 |
+
enabler.value = 0;
|
| 241 |
+
paypalConflictsObject.checklessEventAction(enabler, true);
|
| 242 |
+
}
|
| 243 |
+
paypalConflictsObject.ecCheckAvailability();
|
| 244 |
+
paypalConflictsObject.sharePayflowEnabling(enabler, isEvent);
|
| 245 |
+
}
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
// fill enablers with conflict data
|
| 249 |
+
$$(".paypal-enabler").each(function(enablerElement) {
|
| 250 |
+
var enablerObj = {
|
| 251 |
+
ecIndependent: false,
|
| 252 |
+
ecConflicts: false,
|
| 253 |
+
ecEnabler: false,
|
| 254 |
+
ecSeparate: false,
|
| 255 |
+
ecPayflow: false
|
| 256 |
+
};
|
| 257 |
+
$(enablerElement).classNames().each(function(className) {
|
| 258 |
+
switch (className) {
|
| 259 |
+
case "paypal-ec-conflicts":
|
| 260 |
+
enablerObj.ecConflicts = true;
|
| 261 |
+
case "paypal-ec-independent":
|
| 262 |
+
enablerObj.ecIndependent = true;
|
| 263 |
+
break;
|
| 264 |
+
case "paypal-ec-enabler":
|
| 265 |
+
enablerObj.ecEnabler = true;
|
| 266 |
+
enablerObj.ecIndependent = true;
|
| 267 |
+
break;
|
| 268 |
+
case "paypal-ec-separate":
|
| 269 |
+
enablerObj.ecSeparate = true;
|
| 270 |
+
enablerObj.ecIndependent = true;
|
| 271 |
+
break;
|
| 272 |
+
case "paypal-ec-pe":
|
| 273 |
+
enablerObj.ecPayflow = true;
|
| 274 |
+
break;
|
| 275 |
+
}
|
| 276 |
+
});
|
| 277 |
+
enablerElement.enablerObject = enablerObj;
|
| 278 |
+
|
| 279 |
+
Event.observe(enablerElement, "change", paypalConflictsObject.onChangeEnabler);
|
| 280 |
+
var enablerScopeElement = adminSystemConfig.getScopeElement(enablerElement);
|
| 281 |
+
if (enablerScopeElement) {
|
| 282 |
+
Event.observe(enablerScopeElement, "click", paypalConflictsObject.onClickEnablerScope);
|
| 283 |
+
}
|
| 284 |
+
});
|
| 285 |
+
|
| 286 |
+
// initially uncheck payflow
|
| 287 |
+
var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
|
| 288 |
+
if (typeof ecPayflowEnabler != "undefined") {
|
| 289 |
+
if (ecPayflowEnabler.value == 1) {
|
| 290 |
+
ecPayflowEnabler.value = 0;
|
| 291 |
+
fireEvent(ecPayflowEnabler, "change");
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
|
| 295 |
+
if (ecPayflowScopeElement && !ecPayflowScopeElement.checked) {
|
| 296 |
+
$(ecPayflowScopeElement).click();
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
$$(".paypal-enabler").each(function(enablerElement) {
|
| 301 |
+
paypalConflictsObject.checkPaymentConflicts(enablerElement, "initial");
|
| 302 |
+
});
|
| 303 |
+
if (paypalConflictsObject.isConflict || paypalConflictsObject.ecMissed) {
|
| 304 |
+
var notification = \'' . $this->helper('core')->jsQuoteEscape($this->__('The following error(s) occured:')) . '\';
|
| 305 |
+
if (paypalConflictsObject.isConflict) {
|
| 306 |
+
notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('Some PayPal solutions conflict.')) . '\';
|
| 307 |
+
}
|
| 308 |
+
if (paypalConflictsObject.ecMissed) {
|
| 309 |
+
notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('PayPal Express Checkout is not enabled.')) . '\';
|
| 310 |
+
}
|
| 311 |
+
notification += "\\n" + \'' . $this->helper('core')->jsQuoteEscape($this->__('Please re-enable the previously enabled payment solutions.')) . '\';
|
| 312 |
+
setTimeout(function() {
|
| 313 |
+
alert(notification);
|
| 314 |
+
}, 1);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
$$(".requires").each(function(dependent) {
|
| 318 |
+
var $dependent = $(dependent);
|
| 319 |
+
if ($dependent.hasClassName("paypal-ec-enabler")) {
|
| 320 |
+
$dependent.requiresObj.callback = function(required) {
|
| 321 |
+
if ($(required).hasClassName("paypal-enabler") && required.value == 0) {
|
| 322 |
+
$dependent.disable();
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
$dependent.requiresObj.requires.each(function(required) {
|
| 326 |
+
$dependent.requiresObj.callback(required);
|
| 327 |
+
});
|
| 328 |
+
}
|
| 329 |
+
});
|
| 330 |
+
|
| 331 |
+
var originalFormValidation = configForm.validator.options.onFormValidate;
|
| 332 |
+
configForm.validator.options.onFormValidate = function(result, form) {
|
| 333 |
+
originalFormValidation(result, form);
|
| 334 |
+
if (result) {
|
| 335 |
+
var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
|
| 336 |
+
if (typeof ecPayflowEnabler == "undefined") {
|
| 337 |
+
return;
|
| 338 |
+
}
|
| 339 |
+
var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
|
| 340 |
+
if ((typeof ecPayflowScopeElement == "undefined" || !ecPayflowScopeElement.checked)
|
| 341 |
+
&& ecPayflowEnabler.value == 1
|
| 342 |
+
) {
|
| 343 |
+
$$(".paypal-ec-enabler").each(function(ecEnabler) {
|
| 344 |
+
ecEnabler.value = 0;
|
| 345 |
+
});
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
});
|
| 350 |
+
';
|
| 351 |
+
return parent::_getExtraJs($element, $tooltipsExist) . $this->helper('adminhtml/js')->getScript($js);
|
| 352 |
+
}
|
| 353 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Payment.php
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Payment
|
| 3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Add custom css class
|
| 7 |
+
*
|
| 8 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 9 |
+
* @return string
|
| 10 |
+
*/
|
| 11 |
+
protected function _getFrontendClass($element)
|
| 12 |
+
{
|
| 13 |
+
return parent::_getFrontendClass($element) . ' with-button '
|
| 14 |
+
. ($this->_isPaymentEnabled($element) ? ' enabled' : '');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Check whether current payment method is enabled
|
| 19 |
+
*
|
| 20 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 21 |
+
* @return bool
|
| 22 |
+
*/
|
| 23 |
+
protected function _isPaymentEnabled($element)
|
| 24 |
+
{
|
| 25 |
+
$groupConfig = $this->getGroup($element)->asArray();
|
| 26 |
+
$activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : '';
|
| 27 |
+
|
| 28 |
+
if (empty($activityPath)) {
|
| 29 |
+
return false;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
$isPaymentEnabled = (string)Mage::getSingleton('adminhtml/config_data')->getConfigDataValue($activityPath);
|
| 33 |
+
|
| 34 |
+
return (bool)$isPaymentEnabled;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Return header title part of html for payment solution
|
| 39 |
+
*
|
| 40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 41 |
+
* @return string
|
| 42 |
+
*/
|
| 43 |
+
protected function _getHeaderTitleHtml($element)
|
| 44 |
+
{
|
| 45 |
+
$html = '<div class="config-heading" style="display:block; clear:both; content:"."; font-size:0; line-height:0; height:0; overflow:hidden;" ><div class="heading" style="padding-left:56px; background:url('.$this->getSkinUrl('images/paypalmx/logo-paypal.png').') no-repeat 0 2px;"><strong>' . $element->getLegend();
|
| 46 |
+
|
| 47 |
+
$groupConfig = $this->getGroup($element)->asArray();
|
| 48 |
+
if (!empty($groupConfig['learn_more_link'])) {
|
| 49 |
+
$html .= '<a class="link-more" href="' . $groupConfig['learn_more_link'] . '" target="_blank">'
|
| 50 |
+
. $this->__('Aprende más') . '</a>';
|
| 51 |
+
}
|
| 52 |
+
if (!empty($groupConfig['demo_link'])) {
|
| 53 |
+
$html .= '<a class="link-demo" href="' . $groupConfig['demo_link'] . '" target="_blank">'
|
| 54 |
+
. $this->__('Vér Demo') . '</a>';
|
| 55 |
+
}
|
| 56 |
+
$html .= '</strong>';
|
| 57 |
+
|
| 58 |
+
if ($element->getComment()) {
|
| 59 |
+
$html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
|
| 60 |
+
}
|
| 61 |
+
$html .= '</div>';
|
| 62 |
+
|
| 63 |
+
$html .= '<div class="button-containermx" style="float:right; padding:0 0 0 0; ">
|
| 64 |
+
<img src="'.$this->getSkinUrl('images/paypalmx/accpmark_mensualidades_SP.PNG').'" width="160px" height="30px">
|
| 65 |
+
<img src="'.$this->getSkinUrl('images/paypalmx/accpmark_tarjdeb_SP.PNG').'" width="160px" height="30px" style=" padding: 0 0 0 5px;">
|
| 66 |
+
<img src="'.$this->getSkinUrl('images/paypalmx/accpmark_visa_mc_SP.PNG').'" width="75px" height="30px" style=" margin: 0 10px 0 5px; ">
|
| 67 |
+
<button type="button"'
|
| 68 |
+
. ($this->_isPaymentEnabled($element) ? '' : ' disabled="disabled"') . ' class="button'
|
| 69 |
+
. (empty($groupConfig['paypal_ec_separate']) ? '' : ' paypal-ec-separate')
|
| 70 |
+
. ($this->_isPaymentEnabled($element) ? '' : ' disabled') . '" id="' . $element->getHtmlId()
|
| 71 |
+
. '-head" onclick="paypalToggleSolution.call(this, \'' . $element->getHtmlId() . '\', \''
|
| 72 |
+
. $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">'
|
| 73 |
+
. $this->__('Configurar') . '</span><span class="state-opened">'
|
| 74 |
+
. $this->__('Cerrar') . '</span></button></div></div>';
|
| 75 |
+
|
| 76 |
+
return $html;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Return header comment part of html for payment solution
|
| 81 |
+
*
|
| 82 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 83 |
+
* @return string
|
| 84 |
+
*/
|
| 85 |
+
protected function _getHeaderCommentHtml($element)
|
| 86 |
+
{
|
| 87 |
+
return '';
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* Get collapsed state on-load
|
| 92 |
+
*
|
| 93 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 94 |
+
* @return bool
|
| 95 |
+
*/
|
| 96 |
+
protected function _getCollapseState($element)
|
| 97 |
+
{
|
| 98 |
+
return false;
|
| 99 |
+
}
|
| 100 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Fieldset/Store.php
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Renderer for service JavaScript code that disables corresponding paypal methods on page load
|
| 30 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 31 |
+
*/
|
| 32 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Fieldset_Store
|
| 33 |
+
extends Mage_Adminhtml_Block_Abstract
|
| 34 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Path to template file
|
| 38 |
+
*
|
| 39 |
+
* @var string
|
| 40 |
+
*/
|
| 41 |
+
protected $_template = 'paypal/system/config/fieldset/store.phtml';
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Render service JavaScript code
|
| 45 |
+
*
|
| 46 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 47 |
+
* @return string
|
| 48 |
+
*/
|
| 49 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 50 |
+
{
|
| 51 |
+
return $this->toHtml();
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Returns list of disabled (in the Default or the Website Scope) paypal methods
|
| 56 |
+
*
|
| 57 |
+
* @return array
|
| 58 |
+
*/
|
| 59 |
+
protected function getPaypalDisabledMethods()
|
| 60 |
+
{
|
| 61 |
+
// Assoc array that contains info about paypal methods (their IDs and corresponding Config Paths)
|
| 62 |
+
$methods = array(
|
| 63 |
+
'express' => 'payment/paypal_express/active',
|
| 64 |
+
'ppmx' => 'payment/paypal_mexico/active',
|
| 65 |
+
'wps' => 'payment/paypal_standard/active',
|
| 66 |
+
'wpp' => 'payment/paypal_direct/active',
|
| 67 |
+
'wpppe' => 'payment/paypaluk_direct/active',
|
| 68 |
+
'verisign' => 'payment/verisign/active',
|
| 69 |
+
'expresspe' => 'payment/paypaluk_express/active'
|
| 70 |
+
);
|
| 71 |
+
// Retrieve a code of the current website
|
| 72 |
+
$website = $this->getRequest()->getParam('website');
|
| 73 |
+
|
| 74 |
+
$configRoot = Mage::getConfig()->getNode(null, 'website', $website);
|
| 75 |
+
|
| 76 |
+
$disabledMethods = array();
|
| 77 |
+
foreach ($methods as $methodId => $methodPath) {
|
| 78 |
+
$isEnabled = (int) $configRoot->descend($methodPath);
|
| 79 |
+
if ($isEnabled === 0) {
|
| 80 |
+
$disabledMethods[$methodId] = $isEnabled;
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
return $disabledMethods;
|
| 85 |
+
}
|
| 86 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Payflowlink/Advanced.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Renderer for Payments Advanced information
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Payflowlink_Advanced
|
| 35 |
+
extends Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Template path
|
| 39 |
+
*
|
| 40 |
+
* @var string
|
| 41 |
+
*/
|
| 42 |
+
protected $_template = 'paypal/system/config/payflowlink/advanced.phtml';
|
| 43 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Adminhtml/System/Config/Payflowlink/Info.php
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Renderer for Payflow Link information
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ebcomm_PaypalMx_Block_Adminhtml_System_Config_Payflowlink_Info
|
| 35 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Template path
|
| 39 |
+
*
|
| 40 |
+
* @var string
|
| 41 |
+
*/
|
| 42 |
+
protected $_template = 'paypal/system/config/payflowlink/info.phtml';
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Render fieldset html
|
| 46 |
+
*
|
| 47 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 48 |
+
* @return string
|
| 49 |
+
*/
|
| 50 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 51 |
+
{
|
| 52 |
+
$columns = ($this->getRequest()->getParam('website') || $this->getRequest()->getParam('store')) ? 5 : 4;
|
| 53 |
+
return $this->_decorateRowHtml($element, "<td colspan='$columns'>" . $this->toHtml() . '</td>');
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Get frontend url
|
| 59 |
+
*
|
| 60 |
+
* @deprecated since 1.7.0.1
|
| 61 |
+
* @param string $routePath
|
| 62 |
+
* @return strting
|
| 63 |
+
*/
|
| 64 |
+
public function getFrontendUrl($routePath)
|
| 65 |
+
{
|
| 66 |
+
if ($this->getRequest()->getParam('website')) {
|
| 67 |
+
$website = Mage::getModel('core/website')->load($this->getRequest()->getParam('website'));
|
| 68 |
+
$secure = Mage::getStoreConfigFlag(
|
| 69 |
+
Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT,
|
| 70 |
+
$website->getDefaultStore()
|
| 71 |
+
);
|
| 72 |
+
$path = $secure ?
|
| 73 |
+
Mage_Core_Model_Store::XML_PATH_SECURE_BASE_LINK_URL :
|
| 74 |
+
Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_LINK_URL;
|
| 75 |
+
$websiteUrl = Mage::getStoreConfig($path, $website->getDefaultStore());
|
| 76 |
+
} else {
|
| 77 |
+
$secure = Mage::getStoreConfigFlag(
|
| 78 |
+
Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT
|
| 79 |
+
);
|
| 80 |
+
$websiteUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return $websiteUrl . $routePath;
|
| 84 |
+
}
|
| 85 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito/Form.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Debito_Form extends Ebcomm_PaypalMx_Block_Standard_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Payment method code
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_DEBITO;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Set template and redirect message
|
| 13 |
+
*/
|
| 14 |
+
protected function _construct()
|
| 15 |
+
{
|
| 16 |
+
$result = parent::_construct();
|
| 17 |
+
$this->setRedirectMessage(Mage::helper('paypalmx')->__(''));
|
| 18 |
+
return $result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito/Review.php
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Debito_Review extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @var Mage_Sales_Model_Quote
|
| 7 |
+
*/
|
| 8 |
+
protected $_quote;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Currently selected shipping rate
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 14 |
+
*/
|
| 15 |
+
protected $_currentShippingRate = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Paypal action prefix
|
| 19 |
+
*
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
protected $_paypalActionPrefix = 'paypalmx';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Quote object setter
|
| 26 |
+
*
|
| 27 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 28 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 29 |
+
*/
|
| 30 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 31 |
+
{
|
| 32 |
+
$this->_quote = $quote;
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Return quote billing address
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getBillingAddress()
|
| 42 |
+
{
|
| 43 |
+
return $this->_quote->getBillingAddress();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Return quote shipping address
|
| 48 |
+
*
|
| 49 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 50 |
+
*/
|
| 51 |
+
public function getShippingAddress()
|
| 52 |
+
{
|
| 53 |
+
if ($this->_quote->getIsVirtual()) {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
return $this->_quote->getShippingAddress();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Get HTML output for specified address
|
| 61 |
+
*
|
| 62 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function renderAddress($address)
|
| 66 |
+
{
|
| 67 |
+
return $address->getFormated(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return carrier name from config, base on carrier code
|
| 72 |
+
*
|
| 73 |
+
* @param $carrierCode string
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getCarrierName($carrierCode)
|
| 77 |
+
{
|
| 78 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 79 |
+
return $name;
|
| 80 |
+
}
|
| 81 |
+
return $carrierCode;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get either shipping rate code or empty value on error
|
| 86 |
+
*
|
| 87 |
+
* @param Varien_Object $rate
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 91 |
+
{
|
| 92 |
+
if ($rate->getErrorMessage()) {
|
| 93 |
+
return '';
|
| 94 |
+
}
|
| 95 |
+
return $rate->getCode();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Get shipping rate code title and its price or error message
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $rate
|
| 102 |
+
* @param string $format
|
| 103 |
+
* @param string $inclTaxFormat
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 107 |
+
{
|
| 108 |
+
$renderedInclTax = '';
|
| 109 |
+
if ($rate->getErrorMessage()) {
|
| 110 |
+
$price = $rate->getErrorMessage();
|
| 111 |
+
} else {
|
| 112 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 113 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 114 |
+
|
| 115 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 116 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 117 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Getter for current shipping rate
|
| 125 |
+
*
|
| 126 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 127 |
+
*/
|
| 128 |
+
public function getCurrentShippingRate()
|
| 129 |
+
{
|
| 130 |
+
return $this->_currentShippingRate;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Set paypal actions prefix
|
| 135 |
+
*/
|
| 136 |
+
public function setPaypalActionPrefix($prefix)
|
| 137 |
+
{
|
| 138 |
+
$this->_paypalActionPrefix = $prefix;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return formatted shipping price
|
| 143 |
+
*
|
| 144 |
+
* @param float $price
|
| 145 |
+
* @param bool $isInclTax
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 150 |
+
{
|
| 151 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Format price base on store convert price method
|
| 156 |
+
*
|
| 157 |
+
* @param float $price
|
| 158 |
+
* @return string
|
| 159 |
+
*/
|
| 160 |
+
protected function _formatPrice($price)
|
| 161 |
+
{
|
| 162 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Retrieve payment method and assign additional template values
|
| 167 |
+
*
|
| 168 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 169 |
+
*/
|
| 170 |
+
protected function _beforeToHtml()
|
| 171 |
+
{
|
| 172 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 173 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 174 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 175 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 176 |
+
|
| 177 |
+
$this->setShippingRateRequired(true);
|
| 178 |
+
if ($this->_quote->getIsVirtual()) {
|
| 179 |
+
$this->setShippingRateRequired(false);
|
| 180 |
+
} else {
|
| 181 |
+
// prepare shipping rates
|
| 182 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 183 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 184 |
+
if ($groups && $this->_address) {
|
| 185 |
+
$this->setShippingRateGroups($groups);
|
| 186 |
+
// determine current selected code & name
|
| 187 |
+
foreach ($groups as $code => $rates) {
|
| 188 |
+
foreach ($rates as $rate) {
|
| 189 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 190 |
+
$this->_currentShippingRate = $rate;
|
| 191 |
+
break(2);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// misc shipping parameters
|
| 198 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 199 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 200 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 201 |
+
;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 205 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 206 |
+
|
| 207 |
+
return parent::_beforeToHtml();
|
| 208 |
+
}
|
| 209 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Billing.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 14 |
+
if (!$this->_address->getFirstname()) {
|
| 15 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 16 |
+
}
|
| 17 |
+
if (!$this->_address->getLastname()) {
|
| 18 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 19 |
+
}
|
| 20 |
+
} else {
|
| 21 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return $this->_address;
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
protected $_address;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Return review shipping address
|
| 8 |
+
*
|
| 9 |
+
* @return Mage_Sales_Model_Order_Address
|
| 10 |
+
*/
|
| 11 |
+
public function getAddress()
|
| 12 |
+
{
|
| 13 |
+
if (empty($this->_address)) {
|
| 14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 15 |
+
}
|
| 16 |
+
return $this->_address;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Return review quote totals
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function getTotals()
|
| 25 |
+
{
|
| 26 |
+
return $this->getQuote()->getTotals();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito/Review/Shipping.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model (shipping address)
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 14 |
+
} else {
|
| 15 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return $this->_address;
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito2/Form.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Debito2_Form extends Ebcomm_PaypalMx_Block_Standard_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Payment method code
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_DEBITO;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Set template and redirect message
|
| 13 |
+
*/
|
| 14 |
+
protected function _construct()
|
| 15 |
+
{
|
| 16 |
+
$result = parent::_construct();
|
| 17 |
+
$this->setRedirectMessage(Mage::helper('paypalmx')->__(''));
|
| 18 |
+
return $result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Set data to block
|
| 23 |
+
*
|
| 24 |
+
* @return Mage_Core_Block_Abstract
|
| 25 |
+
*/
|
| 26 |
+
protected function _beforeToHtml()
|
| 27 |
+
{
|
| 28 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
| 29 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($this->_config, $customerId)
|
| 30 |
+
&& $this->canCreateBillingAgreement()) {
|
| 31 |
+
$this->setCreateBACode(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 32 |
+
}
|
| 33 |
+
return parent::_beforeToHtml();
|
| 34 |
+
}
|
| 35 |
+
}
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Debito2_Review extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @var Mage_Sales_Model_Quote
|
| 7 |
+
*/
|
| 8 |
+
protected $_quote;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Currently selected shipping rate
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 14 |
+
*/
|
| 15 |
+
protected $_currentShippingRate = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Paypal action prefix
|
| 19 |
+
*
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
protected $_paypalActionPrefix = 'paypalmx';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Quote object setterEbcomm_PaypalMx_Block_Express_Review_Details
|
| 26 |
+
*
|
| 27 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 28 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 29 |
+
*/
|
| 30 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 31 |
+
{
|
| 32 |
+
$this->_quote = $quote;
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Return quote billing address
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getBillingAddress()
|
| 42 |
+
{
|
| 43 |
+
return $this->_quote->getBillingAddress();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Return quote shipping address
|
| 48 |
+
*
|
| 49 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 50 |
+
*/
|
| 51 |
+
public function getShippingAddress()
|
| 52 |
+
{
|
| 53 |
+
if ($this->_quote->getIsVirtual()) {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
return $this->_quote->getShippingAddress();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Get HTML output for specified address
|
| 61 |
+
*
|
| 62 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function renderAddress($address)
|
| 66 |
+
{
|
| 67 |
+
return $address->getFormated(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return carrier name from config, base on carrier code
|
| 72 |
+
*
|
| 73 |
+
* @param $carrierCode string
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getCarrierName($carrierCode)
|
| 77 |
+
{
|
| 78 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 79 |
+
return $name;
|
| 80 |
+
}
|
| 81 |
+
return $carrierCode;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get either shipping rate code or empty value on error
|
| 86 |
+
*
|
| 87 |
+
* @param Varien_Object $rate
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 91 |
+
{
|
| 92 |
+
if ($rate->getErrorMessage()) {
|
| 93 |
+
return '';
|
| 94 |
+
}
|
| 95 |
+
return $rate->getCode();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Get shipping rate code title and its price or error message
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $rate
|
| 102 |
+
* @param string $format
|
| 103 |
+
* @param string $inclTaxFormat
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 107 |
+
{
|
| 108 |
+
$renderedInclTax = '';
|
| 109 |
+
if ($rate->getErrorMessage()) {
|
| 110 |
+
$price = $rate->getErrorMessage();
|
| 111 |
+
} else {
|
| 112 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 113 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 114 |
+
|
| 115 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 116 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 117 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Getter for current shipping rate
|
| 125 |
+
*
|
| 126 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 127 |
+
*/
|
| 128 |
+
public function getCurrentShippingRate()
|
| 129 |
+
{
|
| 130 |
+
return $this->_currentShippingRate;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Set paypal actions prefix
|
| 135 |
+
*/
|
| 136 |
+
public function setPaypalActionPrefix($prefix)
|
| 137 |
+
{
|
| 138 |
+
$this->_paypalActionPrefix = $prefix;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return formatted shipping price
|
| 143 |
+
*
|
| 144 |
+
* @param float $price
|
| 145 |
+
* @param bool $isInclTax
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 150 |
+
{
|
| 151 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Format price base on store convert price method
|
| 156 |
+
*
|
| 157 |
+
* @param float $price
|
| 158 |
+
* @return string
|
| 159 |
+
*/
|
| 160 |
+
protected function _formatPrice($price)
|
| 161 |
+
{
|
| 162 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Retrieve payment method and assign additional template values
|
| 167 |
+
*
|
| 168 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 169 |
+
*/
|
| 170 |
+
protected function _beforeToHtml()
|
| 171 |
+
{
|
| 172 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 173 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 174 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 175 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 176 |
+
|
| 177 |
+
$this->setShippingRateRequired(true);
|
| 178 |
+
if ($this->_quote->getIsVirtual()) {
|
| 179 |
+
$this->setShippingRateRequired(false);
|
| 180 |
+
} else {
|
| 181 |
+
// prepare shipping rates
|
| 182 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 183 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 184 |
+
if ($groups && $this->_address) {
|
| 185 |
+
$this->setShippingRateGroups($groups);
|
| 186 |
+
// determine current selected code & name
|
| 187 |
+
foreach ($groups as $code => $rates) {
|
| 188 |
+
foreach ($rates as $rate) {
|
| 189 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 190 |
+
$this->_currentShippingRate = $rate;
|
| 191 |
+
break(2);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// misc shipping parameters
|
| 198 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 199 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 200 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 201 |
+
;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 205 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 206 |
+
|
| 207 |
+
return parent::_beforeToHtml();
|
| 208 |
+
}
|
| 209 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Billing.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Debito2_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 14 |
+
if (!$this->_address->getFirstname()) {
|
| 15 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 16 |
+
}
|
| 17 |
+
if (!$this->_address->getLastname()) {
|
| 18 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 19 |
+
}
|
| 20 |
+
} else {
|
| 21 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return $this->_address;
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Debito2_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
protected $_address;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Return review shipping address
|
| 8 |
+
*
|
| 9 |
+
* @return Mage_Sales_Model_Order_Address
|
| 10 |
+
*/
|
| 11 |
+
public function getAddress()
|
| 12 |
+
{
|
| 13 |
+
if (empty($this->_address)) {
|
| 14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 15 |
+
}
|
| 16 |
+
return $this->_address;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Return review quote totals
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function getTotals()
|
| 25 |
+
{
|
| 26 |
+
return $this->getQuote()->getTotals();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito2/Review/Shipping.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Debito2_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model (shipping address)
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 14 |
+
} else {
|
| 15 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return $this->_address;
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Debito2/Shortcut.php
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Paypal expess checkout shortcut link
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Block_Debito2_Shortcut extends Mage_Core_Block_Template
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Position of "OR" label against shortcut
|
| 10 |
+
*/
|
| 11 |
+
const POSITION_BEFORE = 'before';
|
| 12 |
+
const POSITION_AFTER = 'after';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Whether the block should be eventually rendered
|
| 16 |
+
*
|
| 17 |
+
* @var bool
|
| 18 |
+
*/
|
| 19 |
+
protected $_shouldRender = true;
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Payment method code
|
| 23 |
+
*
|
| 24 |
+
* @var string
|
| 25 |
+
*/
|
| 26 |
+
protected $_paymentMethodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_DEBITO;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Start express action
|
| 30 |
+
*
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
protected $_startAction = 'paypalmx/express/start';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Express checkout model factory name
|
| 37 |
+
*
|
| 38 |
+
* @var string
|
| 39 |
+
*/
|
| 40 |
+
protected $_checkoutType = 'paypalmx/express_checkout';
|
| 41 |
+
|
| 42 |
+
protected function _beforeToHtml()
|
| 43 |
+
{
|
| 44 |
+
$result = parent::_beforeToHtml();
|
| 45 |
+
$config = Mage::getModel('paypalmx/config', array($this->_paymentMethodCode));
|
| 46 |
+
$isInCatalog = $this->getIsInCatalogProduct();
|
| 47 |
+
$isInCart = $this->getIsInCart();
|
| 48 |
+
$quote = ($isInCatalog || '' == $this->getIsQuoteAllowed())
|
| 49 |
+
? null : Mage::getSingleton('checkout/session')->getQuote();
|
| 50 |
+
|
| 51 |
+
// check visibility on cart, product page or shiping
|
| 52 |
+
$context = ($isInCatalog) ? 'visible_on_product' : (($isInCart) ? 'visible_on_cart' : 'visible_on_shipping');
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if ($isInCatalog) {
|
| 56 |
+
// Show PayPal shortcut on a product view page only if product has nonzero price
|
| 57 |
+
/** @var $currentProduct Mage_Catalog_Model_Product */
|
| 58 |
+
$currentProduct = Mage::registry('current_product');
|
| 59 |
+
if (!is_null($currentProduct)) {
|
| 60 |
+
$productPrice = (float)$currentProduct->getFinalPrice();
|
| 61 |
+
if (empty($productPrice) && !$currentProduct->isGrouped()) {
|
| 62 |
+
$this->_shouldRender = false;
|
| 63 |
+
return $result;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// validate minimum quote amount and validate quote for zero grandtotal
|
| 69 |
+
if (null !== $quote && (!$quote->validateMinimumAmount()
|
| 70 |
+
|| (!$quote->getGrandTotal() && !$quote->hasNominalItems()))) {
|
| 71 |
+
$this->_shouldRender = false;
|
| 72 |
+
return $result;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// check payment method availability
|
| 76 |
+
$methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
|
| 77 |
+
if (!$methodInstance || !$methodInstance->isContextAvailable($context,$this->_paymentMethodCode) ){
|
| 78 |
+
|
| 79 |
+
$this->_shouldRender = false;
|
| 80 |
+
|
| 81 |
+
return $result;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
|
| 85 |
+
$this->_shouldRender = false;
|
| 86 |
+
return $result;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// set misc data
|
| 90 |
+
$this->setShortcutHtmlId($this->helper('core')->uniqHash('ec_shortcut_'))
|
| 91 |
+
->setCheckoutUrl($this->getUrl($this->_startAction))
|
| 92 |
+
;
|
| 93 |
+
|
| 94 |
+
// use static image if in catalog
|
| 95 |
+
if ($isInCatalog || null === $quote) {
|
| 96 |
+
$this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode()));
|
| 97 |
+
} else {
|
| 98 |
+
$this->setImageUrl(Mage::getModel($this->_checkoutType, array(
|
| 99 |
+
'quote' => $quote,
|
| 100 |
+
'config' => $config,
|
| 101 |
+
))->getCheckoutShortcutImageUrl());
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
// ask whether to create a billing agreement
|
| 105 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching
|
| 106 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($config, $customerId)) {
|
| 107 |
+
$this->setConfirmationUrl($this->getUrl($this->_startAction,
|
| 108 |
+
array(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1)
|
| 109 |
+
));
|
| 110 |
+
$this->setConfirmationMessage(Mage::helper('paypalmx')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
return $result;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Render the block if needed
|
| 118 |
+
*
|
| 119 |
+
* @return string
|
| 120 |
+
*/
|
| 121 |
+
protected function _toHtml()
|
| 122 |
+
{
|
| 123 |
+
|
| 124 |
+
if (!$this->_shouldRender) {
|
| 125 |
+
return '';
|
| 126 |
+
}
|
| 127 |
+
return parent::_toHtml();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Check is "OR" label position before shortcut
|
| 132 |
+
*
|
| 133 |
+
* @return bool
|
| 134 |
+
*/
|
| 135 |
+
public function isOrPositionBefore()
|
| 136 |
+
{
|
| 137 |
+
return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 138 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
|
| 139 |
+
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Check is "OR" label position after shortcut
|
| 144 |
+
*
|
| 145 |
+
* @return bool
|
| 146 |
+
*/
|
| 147 |
+
public function isOrPositionAfter()
|
| 148 |
+
{
|
| 149 |
+
return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 150 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
|
| 151 |
+
}
|
| 152 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Form.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Express_Form extends Ebcomm_PaypalMx_Block_Standard_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Payment method code
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Set template and redirect message
|
| 13 |
+
*/
|
| 14 |
+
protected function _construct()
|
| 15 |
+
{
|
| 16 |
+
$result = parent::_construct();
|
| 17 |
+
$this->setRedirectMessage(Mage::helper('paypalmx')->__(''));
|
| 18 |
+
return $result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Set data to block
|
| 23 |
+
*
|
| 24 |
+
* @return Mage_Core_Block_Abstract
|
| 25 |
+
*/
|
| 26 |
+
protected function _beforeToHtml()
|
| 27 |
+
{
|
| 28 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
| 29 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($this->_config, $customerId)
|
| 30 |
+
&& $this->canCreateBillingAgreement()) {
|
| 31 |
+
$this->setCreateBACode(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 32 |
+
}
|
| 33 |
+
return parent::_beforeToHtml();
|
| 34 |
+
}
|
| 35 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Review.php
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Express_Review extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @var Mage_Sales_Model_Quote
|
| 7 |
+
*/
|
| 8 |
+
protected $_quote;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Currently selected shipping rate
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 14 |
+
*/
|
| 15 |
+
protected $_currentShippingRate = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Paypal action prefix
|
| 19 |
+
*
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
protected $_paypalActionPrefix = 'paypalmx';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Quote object setter
|
| 26 |
+
*
|
| 27 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 28 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 29 |
+
*/
|
| 30 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 31 |
+
{
|
| 32 |
+
$this->_quote = $quote;
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Return quote billing address
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getBillingAddress()
|
| 42 |
+
{
|
| 43 |
+
return $this->_quote->getBillingAddress();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Return quote shipping address
|
| 48 |
+
*
|
| 49 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 50 |
+
*/
|
| 51 |
+
public function getShippingAddress()
|
| 52 |
+
{
|
| 53 |
+
if ($this->_quote->getIsVirtual()) {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
return $this->_quote->getShippingAddress();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Get HTML output for specified address
|
| 61 |
+
*
|
| 62 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function renderAddress($address)
|
| 66 |
+
{
|
| 67 |
+
return $address->getFormated(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return carrier name from config, base on carrier code
|
| 72 |
+
*
|
| 73 |
+
* @param $carrierCode string
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getCarrierName($carrierCode)
|
| 77 |
+
{
|
| 78 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 79 |
+
return $name;
|
| 80 |
+
}
|
| 81 |
+
return $carrierCode;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get either shipping rate code or empty value on error
|
| 86 |
+
*
|
| 87 |
+
* @param Varien_Object $rate
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 91 |
+
{
|
| 92 |
+
if ($rate->getErrorMessage()) {
|
| 93 |
+
return '';
|
| 94 |
+
}
|
| 95 |
+
return $rate->getCode();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Get shipping rate code title and its price or error message
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $rate
|
| 102 |
+
* @param string $format
|
| 103 |
+
* @param string $inclTaxFormat
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 107 |
+
{
|
| 108 |
+
$renderedInclTax = '';
|
| 109 |
+
if ($rate->getErrorMessage()) {
|
| 110 |
+
$price = $rate->getErrorMessage();
|
| 111 |
+
} else {
|
| 112 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 113 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 114 |
+
|
| 115 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 116 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 117 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Getter for current shipping rate
|
| 125 |
+
*
|
| 126 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 127 |
+
*/
|
| 128 |
+
public function getCurrentShippingRate()
|
| 129 |
+
{
|
| 130 |
+
return $this->_currentShippingRate;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Set paypal actions prefix
|
| 135 |
+
*/
|
| 136 |
+
public function setPaypalActionPrefix($prefix)
|
| 137 |
+
{
|
| 138 |
+
$this->_paypalActionPrefix = $prefix;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return formatted shipping price
|
| 143 |
+
*
|
| 144 |
+
* @param float $price
|
| 145 |
+
* @param bool $isInclTax
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 150 |
+
{
|
| 151 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Format price base on store convert price method
|
| 156 |
+
*
|
| 157 |
+
* @param float $price
|
| 158 |
+
* @return string
|
| 159 |
+
*/
|
| 160 |
+
protected function _formatPrice($price)
|
| 161 |
+
{
|
| 162 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Retrieve payment method and assign additional template values
|
| 167 |
+
*
|
| 168 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 169 |
+
*/
|
| 170 |
+
protected function _beforeToHtml()
|
| 171 |
+
{
|
| 172 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 173 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 174 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 175 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 176 |
+
|
| 177 |
+
$this->setShippingRateRequired(true);
|
| 178 |
+
if ($this->_quote->getIsVirtual()) {
|
| 179 |
+
$this->setShippingRateRequired(false);
|
| 180 |
+
} else {
|
| 181 |
+
// prepare shipping rates
|
| 182 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 183 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 184 |
+
if ($groups && $this->_address) {
|
| 185 |
+
$this->setShippingRateGroups($groups);
|
| 186 |
+
// determine current selected code & name
|
| 187 |
+
foreach ($groups as $code => $rates) {
|
| 188 |
+
foreach ($rates as $rate) {
|
| 189 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 190 |
+
$this->_currentShippingRate = $rate;
|
| 191 |
+
break(2);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// misc shipping parameters
|
| 198 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 199 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 200 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 201 |
+
;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 205 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 206 |
+
|
| 207 |
+
return parent::_beforeToHtml();
|
| 208 |
+
}
|
| 209 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Billing.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 14 |
+
if (!$this->_address->getFirstname()) {
|
| 15 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 16 |
+
}
|
| 17 |
+
if (!$this->_address->getLastname()) {
|
| 18 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 19 |
+
}
|
| 20 |
+
} else {
|
| 21 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return $this->_address;
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
protected $_address;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Return review shipping address
|
| 8 |
+
*
|
| 9 |
+
* @return Mage_Sales_Model_Order_Address
|
| 10 |
+
*/
|
| 11 |
+
public function getAddress()
|
| 12 |
+
{
|
| 13 |
+
if (empty($this->_address)) {
|
| 14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 15 |
+
}
|
| 16 |
+
return $this->_address;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Return review quote totals
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function getTotals()
|
| 25 |
+
{
|
| 26 |
+
return $this->getQuote()->getTotals();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Review/Shipping.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model (shipping address)
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 14 |
+
} else {
|
| 15 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return $this->_address;
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Express/Shortcut.php
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Paypal expess checkout shortcut link
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Block_Express_Shortcut extends Mage_Core_Block_Template
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Position of "OR" label against shortcut
|
| 10 |
+
*/
|
| 11 |
+
const POSITION_BEFORE = 'before';
|
| 12 |
+
const POSITION_AFTER = 'after';
|
| 13 |
+
/**
|
| 14 |
+
* Whether the block should be eventually rendered
|
| 15 |
+
*
|
| 16 |
+
* @var bool
|
| 17 |
+
*/
|
| 18 |
+
protected $_shouldRender = true;
|
| 19 |
+
protected $_shouldRenderButton = true;
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Payment method code
|
| 23 |
+
*
|
| 24 |
+
* @var string
|
| 25 |
+
*/
|
| 26 |
+
protected $_paymentMethodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Start express action
|
| 30 |
+
*
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
protected $_startAction = 'paypalmx/express/start';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Express checkout model factory name
|
| 37 |
+
*
|
| 38 |
+
* @var string
|
| 39 |
+
*/
|
| 40 |
+
protected $_checkoutType = 'paypalmx/express_checkout';
|
| 41 |
+
|
| 42 |
+
protected function _beforeToHtml()
|
| 43 |
+
{
|
| 44 |
+
$result = parent::_beforeToHtml();
|
| 45 |
+
$config = Mage::getModel('paypalmx/config', array($this->_paymentMethodCode));
|
| 46 |
+
$isInCatalog = false;
|
| 47 |
+
$isInCart = $this->getIsInCart();
|
| 48 |
+
$quote = ($isInCatalog || '' == $this->getIsQuoteAllowed())
|
| 49 |
+
? null : Mage::getSingleton('checkout/session')->getQuote();
|
| 50 |
+
|
| 51 |
+
// check visibility on cart, product page or shiping
|
| 52 |
+
$context = 'visible_on_shipping';
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if ($isInCatalog) {
|
| 56 |
+
// Show PayPal shortcut on a product view page only if product has nonzero price
|
| 57 |
+
/** @var $currentProduct Mage_Catalog_Model_Product */
|
| 58 |
+
$currentProduct = Mage::registry('current_product');
|
| 59 |
+
if (!is_null($currentProduct)) {
|
| 60 |
+
$productPrice = (float)$currentProduct->getFinalPrice();
|
| 61 |
+
if (empty($productPrice) && !$currentProduct->isGrouped()) {
|
| 62 |
+
$this->_shouldRender = false;
|
| 63 |
+
return $result;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// validate minimum quote amount and validate quote for zero grandtotal
|
| 69 |
+
if (null !== $quote && (!$quote->validateMinimumAmount()
|
| 70 |
+
|| (!$quote->getGrandTotal() && !$quote->hasNominalItems()))) {
|
| 71 |
+
$this->_shouldRender = false;
|
| 72 |
+
return $result;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// check payment method availability
|
| 76 |
+
$methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
|
| 77 |
+
if (!$methodInstance || !$methodInstance->isContextAvailable($context,$this->_paymentMethodCode) ){
|
| 78 |
+
|
| 79 |
+
$this->_shouldRenderButton = false;
|
| 80 |
+
|
| 81 |
+
return $result;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
|
| 85 |
+
$this->_shouldRender = false;
|
| 86 |
+
return $result;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// set misc data
|
| 90 |
+
$this->setShortcutHtmlId($this->helper('core')->uniqHash('ec_shortcut_'))
|
| 91 |
+
->setCheckoutUrl($this->getUrl($this->_startAction))
|
| 92 |
+
;
|
| 93 |
+
|
| 94 |
+
// use static image if in catalog
|
| 95 |
+
if ($isInCatalog || null === $quote) {
|
| 96 |
+
$this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode()));
|
| 97 |
+
} else {
|
| 98 |
+
$this->setImageUrl(Mage::getModel($this->_checkoutType, array(
|
| 99 |
+
'quote' => $quote,
|
| 100 |
+
'config' => $config,
|
| 101 |
+
))->getCheckoutShortcutImageUrl());
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
// ask whether to create a billing agreement
|
| 105 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching
|
| 106 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($config, $customerId)) {
|
| 107 |
+
$this->setConfirmationUrl($this->getUrl($this->_startAction,
|
| 108 |
+
array(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1)
|
| 109 |
+
));
|
| 110 |
+
$this->setConfirmationMessage(Mage::helper('paypalmx')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
return $result;
|
| 114 |
+
}
|
| 115 |
+
protected function prueba(){
|
| 116 |
+
return $this->_shouldRenderButton;
|
| 117 |
+
}
|
| 118 |
+
/**
|
| 119 |
+
* Render the block if needed
|
| 120 |
+
*
|
| 121 |
+
* @return string
|
| 122 |
+
*/
|
| 123 |
+
protected function _toHtml()
|
| 124 |
+
{
|
| 125 |
+
|
| 126 |
+
if (!$this->_shouldRender) {
|
| 127 |
+
return '';
|
| 128 |
+
}
|
| 129 |
+
return parent::_toHtml();
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* Check is "OR" label position before shortcut
|
| 134 |
+
*
|
| 135 |
+
* @return bool
|
| 136 |
+
*/
|
| 137 |
+
public function isOrPositionBefore()
|
| 138 |
+
{
|
| 139 |
+
return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 140 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
|
| 141 |
+
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Check is "OR" label position after shortcut
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
public function isOrPositionAfter()
|
| 150 |
+
{
|
| 151 |
+
return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 152 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
|
| 153 |
+
}
|
| 154 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Form.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Hosted Pro link form
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Hosted_Pro_Form extends Mage_Payment_Block_Form
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Internal constructor
|
| 38 |
+
* Set info template for payment step
|
| 39 |
+
*
|
| 40 |
+
*/
|
| 41 |
+
protected function _construct()
|
| 42 |
+
{
|
| 43 |
+
parent::_construct();
|
| 44 |
+
$this->setTemplate('paypal/hss/info.phtml');
|
| 45 |
+
}
|
| 46 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Iframe.php
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Hosted Pro iframe block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Hosted_Pro_Iframe extends Mage_Paypal_Block_Iframe
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Internal constructor
|
| 38 |
+
* Set payment method code
|
| 39 |
+
*
|
| 40 |
+
*/
|
| 41 |
+
protected function _construct()
|
| 42 |
+
{
|
| 43 |
+
parent::_construct();
|
| 44 |
+
$this->_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_HOSTEDPRO;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Get iframe action URL
|
| 49 |
+
*
|
| 50 |
+
* @return string
|
| 51 |
+
*/
|
| 52 |
+
public function getFrameActionUrl()
|
| 53 |
+
{
|
| 54 |
+
return $this->_getOrder()
|
| 55 |
+
->getPayment()
|
| 56 |
+
->getAdditionalInformation('secure_form_url');
|
| 57 |
+
}
|
| 58 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Hosted/Pro/Info.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Hosted Pro link infoblock
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Hosted_Pro_Info extends Mage_Paypal_Block_Payment_Info
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Don't show CC type
|
| 38 |
+
*
|
| 39 |
+
* @return false
|
| 40 |
+
*/
|
| 41 |
+
public function getCcTypeName()
|
| 42 |
+
{
|
| 43 |
+
return false;
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Iframe.php
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Whether the block should be eventually rendered
|
| 7 |
+
*
|
| 8 |
+
* @var bool
|
| 9 |
+
*/
|
| 10 |
+
protected $_shouldRender = false;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Order object
|
| 14 |
+
*
|
| 15 |
+
* @var Mage_Sales_Model_Order
|
| 16 |
+
*/
|
| 17 |
+
protected $_order;
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Payment method code
|
| 21 |
+
*
|
| 22 |
+
* @var string
|
| 23 |
+
*/
|
| 24 |
+
protected $_paymentMethodCode;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Current iframe block instance
|
| 28 |
+
*
|
| 29 |
+
* @var Mage_Payment_Block_Form
|
| 30 |
+
*/
|
| 31 |
+
protected $_block;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Internal constructor
|
| 35 |
+
* Set info template for payment step
|
| 36 |
+
*
|
| 37 |
+
*/
|
| 38 |
+
protected function _construct()
|
| 39 |
+
{
|
| 40 |
+
parent::_construct();
|
| 41 |
+
$paymentCode = $this->_getCheckout()
|
| 42 |
+
->getQuote()
|
| 43 |
+
->getPayment()
|
| 44 |
+
->getMethod();
|
| 45 |
+
if (in_array($paymentCode, $this->helper('paypalmx/hss')->getHssMethods())) {
|
| 46 |
+
$this->_paymentMethodCode = $paymentCode;
|
| 47 |
+
$templatePath = str_replace('_', '', $paymentCode);
|
| 48 |
+
$templateFile = "paypalmx/{$templatePath}/iframe.phtml";
|
| 49 |
+
if (file_exists(Mage::getDesign()->getTemplateFilename($templateFile))) {
|
| 50 |
+
$this->setTemplate($templateFile);
|
| 51 |
+
} else {
|
| 52 |
+
$this->setTemplate('paypalmx/hss/iframe.phtml');
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Get current block instance
|
| 59 |
+
*
|
| 60 |
+
* @return Mage_Paypal_Block_Iframe
|
| 61 |
+
*/
|
| 62 |
+
protected function _getBlock()
|
| 63 |
+
{
|
| 64 |
+
if (!$this->_block) {
|
| 65 |
+
$this->_block = $this->getAction()
|
| 66 |
+
->getLayout()
|
| 67 |
+
->createBlock('paypalmx/'.$this->_paymentMethodCode.'_iframe');
|
| 68 |
+
if (!$this->_block instanceof Mage_Paypal_Block_Iframe) {
|
| 69 |
+
Mage::throwException('Invalid block type');
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
return $this->_block;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Get order object
|
| 78 |
+
*
|
| 79 |
+
* @return Mage_Sales_Model_Order
|
| 80 |
+
*/
|
| 81 |
+
protected function _getOrder()
|
| 82 |
+
{
|
| 83 |
+
if (!$this->_order) {
|
| 84 |
+
$incrementId = $this->_getCheckout()->getLastRealOrderId();
|
| 85 |
+
$this->_order = Mage::getModel('sales/order')
|
| 86 |
+
->loadByIncrementId($incrementId);
|
| 87 |
+
}
|
| 88 |
+
return $this->_order;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Get frontend checkout session object
|
| 93 |
+
*
|
| 94 |
+
* @return Mage_Checkout_Model_Session
|
| 95 |
+
*/
|
| 96 |
+
protected function _getCheckout()
|
| 97 |
+
{
|
| 98 |
+
return Mage::getSingleton('checkout/session');
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Before rendering html, check if is block rendering needed
|
| 103 |
+
*
|
| 104 |
+
* @return Mage_Core_Block_Abstract
|
| 105 |
+
*/
|
| 106 |
+
protected function _beforeToHtml()
|
| 107 |
+
{
|
| 108 |
+
if ($this->_getOrder()->getId() &&
|
| 109 |
+
$this->_getOrder()->getQuoteId() == $this->_getCheckout()->getLastQuoteId() &&
|
| 110 |
+
$this->_paymentMethodCode) {
|
| 111 |
+
$this->_shouldRender = true;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
if ($this->getGotoSection() || $this->getGotoSuccessPage()) {
|
| 115 |
+
$this->_shouldRender = true;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
return parent::_beforeToHtml();
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Render the block if needed
|
| 123 |
+
*
|
| 124 |
+
* @return string
|
| 125 |
+
*/
|
| 126 |
+
protected function _toHtml()
|
| 127 |
+
{
|
| 128 |
+
if ($this->_isAfterPaymentSave()) {
|
| 129 |
+
$this->setTemplate('paypalmx/hss/js.phtml');
|
| 130 |
+
return parent::_toHtml();
|
| 131 |
+
}
|
| 132 |
+
if (!$this->_shouldRender) {
|
| 133 |
+
return '';
|
| 134 |
+
}
|
| 135 |
+
return parent::_toHtml();
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Check whether block is rendering after save payment
|
| 140 |
+
*
|
| 141 |
+
* @return bool
|
| 142 |
+
*/
|
| 143 |
+
protected function _isAfterPaymentSave()
|
| 144 |
+
{
|
| 145 |
+
$quote = $this->_getCheckout()->getQuote();
|
| 146 |
+
if ($quote->getPayment()->getMethod() == $this->_paymentMethodCode &&
|
| 147 |
+
$quote->getIsActive() &&
|
| 148 |
+
$this->getTemplate() &&
|
| 149 |
+
$this->getRequest()->getActionName() == 'savePayment') {
|
| 150 |
+
return true;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
return false;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Get iframe action URL
|
| 158 |
+
*
|
| 159 |
+
* @return string
|
| 160 |
+
*/
|
| 161 |
+
public function getFrameActionUrl()
|
| 162 |
+
{
|
| 163 |
+
return $this->_getBlock()->getFrameActionUrl();
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Get secure token
|
| 168 |
+
*
|
| 169 |
+
* @return string
|
| 170 |
+
*/
|
| 171 |
+
public function getSecureToken()
|
| 172 |
+
{
|
| 173 |
+
return $this->_getBlock()->getSecureToken();
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Get secure token ID
|
| 178 |
+
*
|
| 179 |
+
* @return string
|
| 180 |
+
*/
|
| 181 |
+
public function getSecureTokenId()
|
| 182 |
+
{
|
| 183 |
+
return $this->_getBlock()->getSecureTokenId();
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
* Get payflow transaction URL
|
| 188 |
+
*
|
| 189 |
+
* @return string
|
| 190 |
+
*/
|
| 191 |
+
public function getTransactionUrl()
|
| 192 |
+
{
|
| 193 |
+
return $this->_getBlock()->getTransactionUrl();
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Check sandbox mode
|
| 198 |
+
*
|
| 199 |
+
* @return bool
|
| 200 |
+
*/
|
| 201 |
+
public function isTestMode()
|
| 202 |
+
{
|
| 203 |
+
return $this->_getBlock()->isTestMode();
|
| 204 |
+
}
|
| 205 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Logo.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* PayPal online logo with additional options
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Block_Logo extends Mage_Core_Block_Template
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Return URL for Paypal Landing page
|
| 10 |
+
*
|
| 11 |
+
* @return string
|
| 12 |
+
*/
|
| 13 |
+
public function getAboutPaypalPageUrl()
|
| 14 |
+
{
|
| 15 |
+
return $this->_getConfig()->getPaymentMarkWhatIsPaypalUrl(Mage::app()->getLocale());
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Getter for paypal config
|
| 20 |
+
*
|
| 21 |
+
* @return Mage_Paypal_Model_Config
|
| 22 |
+
*/
|
| 23 |
+
protected function _getConfig()
|
| 24 |
+
{
|
| 25 |
+
return Mage::getSingleton('paypalmx/config');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Disable block output if logo turned off
|
| 30 |
+
*
|
| 31 |
+
* @return string
|
| 32 |
+
*/
|
| 33 |
+
protected function _toHtml()
|
| 34 |
+
{
|
| 35 |
+
$type = $this->getLogoType(); // assigned in layout etc.
|
| 36 |
+
$logoUrl = $this->_getConfig()->getAdditionalOptionsLogoUrl(Mage::app()->getLocale()->getLocaleCode(), $type);
|
| 37 |
+
if (!$logoUrl) {
|
| 38 |
+
return '';
|
| 39 |
+
}
|
| 40 |
+
$this->setLogoImageUrl($logoUrl);
|
| 41 |
+
return parent::_toHtml();
|
| 42 |
+
}
|
| 43 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Form.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Mensualidades_Form extends Ebcomm_PaypalMx_Block_Standard_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Payment method code
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_MENSUALIDADES;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Set template and redirect message
|
| 13 |
+
*/
|
| 14 |
+
protected function _construct()
|
| 15 |
+
{
|
| 16 |
+
$result = parent::_construct();
|
| 17 |
+
$this->setRedirectMessage(Mage::helper('paypalmx')->__(''));
|
| 18 |
+
return $result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review.php
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Mensualidades_Review extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @var Mage_Sales_Model_Quote
|
| 7 |
+
*/
|
| 8 |
+
protected $_quote;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Currently selected shipping rate
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 14 |
+
*/
|
| 15 |
+
protected $_currentShippingRate = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Paypal action prefix
|
| 19 |
+
*
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
protected $_paypalActionPrefix = 'paypalmx';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Quote object setter
|
| 26 |
+
*
|
| 27 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 28 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 29 |
+
*/
|
| 30 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 31 |
+
{
|
| 32 |
+
$this->_quote = $quote;
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Return quote billing address
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getBillingAddress()
|
| 42 |
+
{
|
| 43 |
+
return $this->_quote->getBillingAddress();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Return quote shipping address
|
| 48 |
+
*
|
| 49 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 50 |
+
*/
|
| 51 |
+
public function getShippingAddress()
|
| 52 |
+
{
|
| 53 |
+
if ($this->_quote->getIsVirtual()) {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
return $this->_quote->getShippingAddress();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Get HTML output for specified address
|
| 61 |
+
*
|
| 62 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function renderAddress($address)
|
| 66 |
+
{
|
| 67 |
+
return $address->getFormated(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return carrier name from config, base on carrier code
|
| 72 |
+
*
|
| 73 |
+
* @param $carrierCode string
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getCarrierName($carrierCode)
|
| 77 |
+
{
|
| 78 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 79 |
+
return $name;
|
| 80 |
+
}
|
| 81 |
+
return $carrierCode;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get either shipping rate code or empty value on error
|
| 86 |
+
*
|
| 87 |
+
* @param Varien_Object $rate
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 91 |
+
{
|
| 92 |
+
if ($rate->getErrorMessage()) {
|
| 93 |
+
return '';
|
| 94 |
+
}
|
| 95 |
+
return $rate->getCode();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Get shipping rate code title and its price or error message
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $rate
|
| 102 |
+
* @param string $format
|
| 103 |
+
* @param string $inclTaxFormat
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 107 |
+
{
|
| 108 |
+
$renderedInclTax = '';
|
| 109 |
+
if ($rate->getErrorMessage()) {
|
| 110 |
+
$price = $rate->getErrorMessage();
|
| 111 |
+
} else {
|
| 112 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 113 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 114 |
+
|
| 115 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 116 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 117 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Getter for current shipping rate
|
| 125 |
+
*
|
| 126 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 127 |
+
*/
|
| 128 |
+
public function getCurrentShippingRate()
|
| 129 |
+
{
|
| 130 |
+
return $this->_currentShippingRate;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Set paypal actions prefix
|
| 135 |
+
*/
|
| 136 |
+
public function setPaypalActionPrefix($prefix)
|
| 137 |
+
{
|
| 138 |
+
$this->_paypalActionPrefix = $prefix;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return formatted shipping price
|
| 143 |
+
*
|
| 144 |
+
* @param float $price
|
| 145 |
+
* @param bool $isInclTax
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 150 |
+
{
|
| 151 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Format price base on store convert price method
|
| 156 |
+
*
|
| 157 |
+
* @param float $price
|
| 158 |
+
* @return string
|
| 159 |
+
*/
|
| 160 |
+
protected function _formatPrice($price)
|
| 161 |
+
{
|
| 162 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Retrieve payment method and assign additional template values
|
| 167 |
+
*
|
| 168 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 169 |
+
*/
|
| 170 |
+
protected function _beforeToHtml()
|
| 171 |
+
{
|
| 172 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 173 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 174 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 175 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 176 |
+
|
| 177 |
+
$this->setShippingRateRequired(true);
|
| 178 |
+
if ($this->_quote->getIsVirtual()) {
|
| 179 |
+
$this->setShippingRateRequired(false);
|
| 180 |
+
} else {
|
| 181 |
+
// prepare shipping rates
|
| 182 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 183 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 184 |
+
if ($groups && $this->_address) {
|
| 185 |
+
$this->setShippingRateGroups($groups);
|
| 186 |
+
// determine current selected code & name
|
| 187 |
+
foreach ($groups as $code => $rates) {
|
| 188 |
+
foreach ($rates as $rate) {
|
| 189 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 190 |
+
$this->_currentShippingRate = $rate;
|
| 191 |
+
break(2);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// misc shipping parameters
|
| 198 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 199 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 200 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 201 |
+
;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 205 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 206 |
+
|
| 207 |
+
return parent::_beforeToHtml();
|
| 208 |
+
}
|
| 209 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Billing.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 14 |
+
if (!$this->_address->getFirstname()) {
|
| 15 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 16 |
+
}
|
| 17 |
+
if (!$this->_address->getLastname()) {
|
| 18 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 19 |
+
}
|
| 20 |
+
} else {
|
| 21 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return $this->_address;
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
protected $_address;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Return review shipping address
|
| 8 |
+
*
|
| 9 |
+
* @return Mage_Sales_Model_Order_Address
|
| 10 |
+
*/
|
| 11 |
+
public function getAddress()
|
| 12 |
+
{
|
| 13 |
+
if (empty($this->_address)) {
|
| 14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 15 |
+
}
|
| 16 |
+
return $this->_address;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Return review quote totals
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function getTotals()
|
| 25 |
+
{
|
| 26 |
+
return $this->getQuote()->getTotals();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades/Review/Shipping.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Express_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model (shipping address)
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 14 |
+
} else {
|
| 15 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return $this->_address;
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Form.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Mensualidades2_Form extends Ebcomm_PaypalMx_Block_Standard_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Payment method code
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_MENSUALIDADES;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Set template and redirect message
|
| 13 |
+
*/
|
| 14 |
+
protected function _construct()
|
| 15 |
+
{
|
| 16 |
+
$result = parent::_construct();
|
| 17 |
+
$this->setRedirectMessage(Mage::helper('paypalmx')->__(''));
|
| 18 |
+
$this->setMensualidadesAcvtive($this->_config->getIsMensualidadesActive());
|
| 19 |
+
return $result;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Set data to block
|
| 24 |
+
*
|
| 25 |
+
* @return Mage_Core_Block_Abstract
|
| 26 |
+
*/
|
| 27 |
+
protected function _beforeToHtml()
|
| 28 |
+
{
|
| 29 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
| 30 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($this->_config, $customerId)
|
| 31 |
+
&& $this->canCreateBillingAgreement()) {
|
| 32 |
+
$this->setCreateBACode(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 33 |
+
}
|
| 34 |
+
return parent::_beforeToHtml();
|
| 35 |
+
}
|
| 36 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review.php
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Block_Mensualidades2_Review extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @var Mage_Sales_Model_Quote
|
| 7 |
+
*/
|
| 8 |
+
protected $_quote;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Currently selected shipping rate
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 14 |
+
*/
|
| 15 |
+
protected $_currentShippingRate = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Paypal action prefix
|
| 19 |
+
*
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
protected $_paypalActionPrefix = 'paypalmx';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Quote object setterEbcomm_PaypalMx_Block_Express_Review_Details
|
| 26 |
+
*
|
| 27 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 28 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 29 |
+
*/
|
| 30 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 31 |
+
{
|
| 32 |
+
$this->_quote = $quote;
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Return quote billing address
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getBillingAddress()
|
| 42 |
+
{
|
| 43 |
+
return $this->_quote->getBillingAddress();
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Return quote shipping address
|
| 48 |
+
*
|
| 49 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 50 |
+
*/
|
| 51 |
+
public function getShippingAddress()
|
| 52 |
+
{
|
| 53 |
+
if ($this->_quote->getIsVirtual()) {
|
| 54 |
+
return false;
|
| 55 |
+
}
|
| 56 |
+
return $this->_quote->getShippingAddress();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Get HTML output for specified address
|
| 61 |
+
*
|
| 62 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function renderAddress($address)
|
| 66 |
+
{
|
| 67 |
+
return $address->getFormated(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return carrier name from config, base on carrier code
|
| 72 |
+
*
|
| 73 |
+
* @param $carrierCode string
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getCarrierName($carrierCode)
|
| 77 |
+
{
|
| 78 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 79 |
+
return $name;
|
| 80 |
+
}
|
| 81 |
+
return $carrierCode;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get either shipping rate code or empty value on error
|
| 86 |
+
*
|
| 87 |
+
* @param Varien_Object $rate
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 91 |
+
{
|
| 92 |
+
if ($rate->getErrorMessage()) {
|
| 93 |
+
return '';
|
| 94 |
+
}
|
| 95 |
+
return $rate->getCode();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Get shipping rate code title and its price or error message
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $rate
|
| 102 |
+
* @param string $format
|
| 103 |
+
* @param string $inclTaxFormat
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 107 |
+
{
|
| 108 |
+
$renderedInclTax = '';
|
| 109 |
+
if ($rate->getErrorMessage()) {
|
| 110 |
+
$price = $rate->getErrorMessage();
|
| 111 |
+
} else {
|
| 112 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 113 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 114 |
+
|
| 115 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 116 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 117 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Getter for current shipping rate
|
| 125 |
+
*
|
| 126 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 127 |
+
*/
|
| 128 |
+
public function getCurrentShippingRate()
|
| 129 |
+
{
|
| 130 |
+
return $this->_currentShippingRate;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Set paypal actions prefix
|
| 135 |
+
*/
|
| 136 |
+
public function setPaypalActionPrefix($prefix)
|
| 137 |
+
{
|
| 138 |
+
$this->_paypalActionPrefix = $prefix;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return formatted shipping price
|
| 143 |
+
*
|
| 144 |
+
* @param float $price
|
| 145 |
+
* @param bool $isInclTax
|
| 146 |
+
*
|
| 147 |
+
* @return bool
|
| 148 |
+
*/
|
| 149 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 150 |
+
{
|
| 151 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Format price base on store convert price method
|
| 156 |
+
*
|
| 157 |
+
* @param float $price
|
| 158 |
+
* @return string
|
| 159 |
+
*/
|
| 160 |
+
protected function _formatPrice($price)
|
| 161 |
+
{
|
| 162 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Retrieve payment method and assign additional template values
|
| 167 |
+
*
|
| 168 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 169 |
+
*/
|
| 170 |
+
protected function _beforeToHtml()
|
| 171 |
+
{
|
| 172 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 173 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 174 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 175 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 176 |
+
|
| 177 |
+
$this->setShippingRateRequired(true);
|
| 178 |
+
if ($this->_quote->getIsVirtual()) {
|
| 179 |
+
$this->setShippingRateRequired(false);
|
| 180 |
+
} else {
|
| 181 |
+
// prepare shipping rates
|
| 182 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 183 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 184 |
+
if ($groups && $this->_address) {
|
| 185 |
+
$this->setShippingRateGroups($groups);
|
| 186 |
+
// determine current selected code & name
|
| 187 |
+
foreach ($groups as $code => $rates) {
|
| 188 |
+
foreach ($rates as $rate) {
|
| 189 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 190 |
+
$this->_currentShippingRate = $rate;
|
| 191 |
+
break(2);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// misc shipping parameters
|
| 198 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 199 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 200 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 201 |
+
;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 205 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 206 |
+
|
| 207 |
+
return parent::_beforeToHtml();
|
| 208 |
+
}
|
| 209 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Billing.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Mensualidades2_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 14 |
+
if (!$this->_address->getFirstname()) {
|
| 15 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 16 |
+
}
|
| 17 |
+
if (!$this->_address->getLastname()) {
|
| 18 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 19 |
+
}
|
| 20 |
+
} else {
|
| 21 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return $this->_address;
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Details.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Mensualidades2_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
protected $_address;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Return review shipping address
|
| 8 |
+
*
|
| 9 |
+
* @return Mage_Sales_Model_Order_Address
|
| 10 |
+
*/
|
| 11 |
+
public function getAddress()
|
| 12 |
+
{
|
| 13 |
+
if (empty($this->_address)) {
|
| 14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 15 |
+
}
|
| 16 |
+
return $this->_address;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Return review quote totals
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function getTotals()
|
| 25 |
+
{
|
| 26 |
+
return $this->getQuote()->getTotals();
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Review/Shipping.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Debito2_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Sales Quote Address model (shipping address)
|
| 6 |
+
*
|
| 7 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 8 |
+
*/
|
| 9 |
+
public function getAddress()
|
| 10 |
+
{
|
| 11 |
+
if (is_null($this->_address)) {
|
| 12 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 13 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 14 |
+
} else {
|
| 15 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return $this->_address;
|
| 20 |
+
}
|
| 21 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Mensualidades2/Shortcut.php
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Paypal expess checkout shortcut link
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Block_Mensualidades2_Shortcut extends Mage_Core_Block_Template
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Position of "OR" label against shortcut
|
| 10 |
+
*/
|
| 11 |
+
const POSITION_BEFORE = 'before';
|
| 12 |
+
const POSITION_AFTER = 'after';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Whether the block should be eventually rendered
|
| 16 |
+
*
|
| 17 |
+
* @var bool
|
| 18 |
+
*/
|
| 19 |
+
protected $_shouldRender = true;
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Payment method code
|
| 23 |
+
*
|
| 24 |
+
* @var string
|
| 25 |
+
*/
|
| 26 |
+
protected $_paymentMethodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_MENSUALIDADES;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Start express action
|
| 30 |
+
*
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
protected $_startAction = 'paypalmx/express/start';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Express checkout model factory name
|
| 37 |
+
*
|
| 38 |
+
* @var string
|
| 39 |
+
*/
|
| 40 |
+
protected $_checkoutType = 'paypalmx/express_checkout';
|
| 41 |
+
|
| 42 |
+
protected function _beforeToHtml()
|
| 43 |
+
{
|
| 44 |
+
$result = parent::_beforeToHtml();
|
| 45 |
+
$config = Mage::getModel('paypalmx/config', array($this->_paymentMethodCode));
|
| 46 |
+
$isInCatalog = $this->getIsInCatalogProduct();
|
| 47 |
+
$isInCart = $this->getIsInCart();
|
| 48 |
+
$quote = ($isInCatalog || '' == $this->getIsQuoteAllowed())
|
| 49 |
+
? null : Mage::getSingleton('checkout/session')->getQuote();
|
| 50 |
+
|
| 51 |
+
// check visibility on cart, product page or shiping
|
| 52 |
+
$context = ($isInCatalog) ? 'visible_on_product' : (($isInCart) ? 'visible_on_cart' : 'visible_on_shipping');
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if ($isInCatalog) {
|
| 56 |
+
// Show PayPal shortcut on a product view page only if product has nonzero price
|
| 57 |
+
/** @var $currentProduct Mage_Catalog_Model_Product */
|
| 58 |
+
$currentProduct = Mage::registry('current_product');
|
| 59 |
+
if (!is_null($currentProduct)) {
|
| 60 |
+
$productPrice = (float)$currentProduct->getFinalPrice();
|
| 61 |
+
if (empty($productPrice) && !$currentProduct->isGrouped()) {
|
| 62 |
+
$this->_shouldRender = false;
|
| 63 |
+
return $result;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// validate minimum quote amount and validate quote for zero grandtotal
|
| 69 |
+
if (null !== $quote && (!$quote->validateMinimumAmount()
|
| 70 |
+
|| (!$quote->getGrandTotal() && !$quote->hasNominalItems()))) {
|
| 71 |
+
$this->_shouldRender = false;
|
| 72 |
+
return $result;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// check payment method availability
|
| 76 |
+
$methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
|
| 77 |
+
if (!$methodInstance || !$methodInstance->isContextAvailable($context,$this->_paymentMethodCode) ){
|
| 78 |
+
|
| 79 |
+
$this->_shouldRender = false;
|
| 80 |
+
|
| 81 |
+
return $result;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
|
| 85 |
+
$this->_shouldRender = false;
|
| 86 |
+
return $result;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// set misc data
|
| 90 |
+
$this->setShortcutHtmlId($this->helper('core')->uniqHash('ec_shortcut_'))
|
| 91 |
+
->setCheckoutUrl($this->getUrl($this->_startAction))
|
| 92 |
+
;
|
| 93 |
+
|
| 94 |
+
// use static image if in catalog
|
| 95 |
+
if ($isInCatalog || null === $quote) {
|
| 96 |
+
$this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode()));
|
| 97 |
+
} else {
|
| 98 |
+
$this->setImageUrl(Mage::getModel($this->_checkoutType, array(
|
| 99 |
+
'quote' => $quote,
|
| 100 |
+
'config' => $config,
|
| 101 |
+
))->getCheckoutShortcutImageUrl());
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
// ask whether to create a billing agreement
|
| 105 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching
|
| 106 |
+
if (Mage::helper('paypalmx')->shouldAskToCreateBillingAgreement($config, $customerId)) {
|
| 107 |
+
$this->setConfirmationUrl($this->getUrl($this->_startAction,
|
| 108 |
+
array(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1)
|
| 109 |
+
));
|
| 110 |
+
$this->setConfirmationMessage(Mage::helper('paypalmx')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
return $result;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Render the block if needed
|
| 118 |
+
*
|
| 119 |
+
* @return string
|
| 120 |
+
*/
|
| 121 |
+
protected function _toHtml()
|
| 122 |
+
{
|
| 123 |
+
|
| 124 |
+
if (!$this->_shouldRender) {
|
| 125 |
+
return '';
|
| 126 |
+
}
|
| 127 |
+
return parent::_toHtml();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Check is "OR" label position before shortcut
|
| 132 |
+
*
|
| 133 |
+
* @return bool
|
| 134 |
+
*/
|
| 135 |
+
public function isOrPositionBefore()
|
| 136 |
+
{
|
| 137 |
+
return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 138 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
|
| 139 |
+
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Check is "OR" label position after shortcut
|
| 144 |
+
*
|
| 145 |
+
* @return bool
|
| 146 |
+
*/
|
| 147 |
+
public function isOrPositionAfter()
|
| 148 |
+
{
|
| 149 |
+
return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 150 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
|
| 151 |
+
}
|
| 152 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Form.php
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow Advanced iframe block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Advanced_Form extends Mage_Paypal_Block_Payflow_Link_Form
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Internal constructor
|
| 38 |
+
* Set payment method code
|
| 39 |
+
*
|
| 40 |
+
*/
|
| 41 |
+
protected function _construct()
|
| 42 |
+
{
|
| 43 |
+
parent::_construct();
|
| 44 |
+
$this->setTemplate('paypal/payflowadvanced/info.phtml');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Get frame action URL
|
| 49 |
+
*
|
| 50 |
+
* @return string
|
| 51 |
+
*/
|
| 52 |
+
public function getFrameActionUrl()
|
| 53 |
+
{
|
| 54 |
+
return $this->getUrl('paypal/payflowadvanced/form', array('_secure' => true));
|
| 55 |
+
}
|
| 56 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Iframe.php
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow Advanced iframe block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Advanced_Iframe extends Mage_Paypal_Block_Payflow_Link_Iframe
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Set payment method code
|
| 38 |
+
*/
|
| 39 |
+
protected function _construct()
|
| 40 |
+
{
|
| 41 |
+
parent::_construct();
|
| 42 |
+
$this->_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_PAYFLOWADVANCED;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Get frame action URL
|
| 47 |
+
*
|
| 48 |
+
* @return string
|
| 49 |
+
*/
|
| 50 |
+
public function getFrameActionUrl()
|
| 51 |
+
{
|
| 52 |
+
return $this->getUrl('paypal/payflowadvanced/form', array('_secure' => true));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Check sandbox mode
|
| 57 |
+
*
|
| 58 |
+
* @return bool
|
| 59 |
+
*/
|
| 60 |
+
public function isTestMode()
|
| 61 |
+
{
|
| 62 |
+
$mode = Mage::helper('payment')
|
| 63 |
+
->getMethodInstance(Mage_Paypal_Model_Config::METHOD_PAYFLOWADVANCED)
|
| 64 |
+
->getConfigData('sandbox_flag');
|
| 65 |
+
return (bool) $mode;
|
| 66 |
+
}
|
| 67 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Info.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow Advanced infoblock
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Advanced_Info extends Mage_Paypal_Block_Payflow_Link_Info
|
| 35 |
+
{
|
| 36 |
+
|
| 37 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Advanced/Review.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal Payflow Advanced Express Onepage checkout block
|
| 29 |
+
*
|
| 30 |
+
* @deprecated since 1.6.2.0
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Block_Payflow_Advanced_Review extends Mage_Paypal_Block_Payflow_Link_Review
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Form.php
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow link iframe block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Link_Form extends Mage_Payment_Block_Form
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Internal constructor
|
| 38 |
+
* Set payment method code
|
| 39 |
+
*
|
| 40 |
+
*/
|
| 41 |
+
protected function _construct()
|
| 42 |
+
{
|
| 43 |
+
parent::_construct();
|
| 44 |
+
$this->setTemplate('paypal/payflowlink/info.phtml');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Get frame action URL
|
| 49 |
+
*
|
| 50 |
+
* @return string
|
| 51 |
+
*/
|
| 52 |
+
public function getFrameActionUrl()
|
| 53 |
+
{
|
| 54 |
+
return $this->getUrl('paypal/payflow/form', array('_secure' => true));
|
| 55 |
+
}
|
| 56 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Iframe.php
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow link iframe block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Link_Iframe extends Mage_Paypal_Block_Iframe
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Set payment method code
|
| 38 |
+
*/
|
| 39 |
+
protected function _construct()
|
| 40 |
+
{
|
| 41 |
+
parent::_construct();
|
| 42 |
+
$this->_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_PAYFLOWLINK;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Get frame action URL
|
| 47 |
+
*
|
| 48 |
+
* @return string
|
| 49 |
+
*/
|
| 50 |
+
public function getFrameActionUrl()
|
| 51 |
+
{
|
| 52 |
+
return $this->getUrl('paypal/payflow/form', array('_secure' => true));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Get secure token
|
| 57 |
+
*
|
| 58 |
+
* @return string
|
| 59 |
+
*/
|
| 60 |
+
public function getSecureToken()
|
| 61 |
+
{
|
| 62 |
+
return $this->_getOrder()
|
| 63 |
+
->getPayment()
|
| 64 |
+
->getAdditionalInformation('secure_token');
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Get secure token ID
|
| 69 |
+
*
|
| 70 |
+
* @return string
|
| 71 |
+
*/
|
| 72 |
+
public function getSecureTokenId()
|
| 73 |
+
{
|
| 74 |
+
return $this->_getOrder()
|
| 75 |
+
->getPayment()
|
| 76 |
+
->getAdditionalInformation('secure_token_id');
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Get payflow transaction URL
|
| 81 |
+
*
|
| 82 |
+
* @return string
|
| 83 |
+
*/
|
| 84 |
+
public function getTransactionUrl()
|
| 85 |
+
{
|
| 86 |
+
return Mage_Paypal_Model_Payflowlink::TRANSACTION_PAYFLOW_URL;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Check sandbox mode
|
| 91 |
+
*
|
| 92 |
+
* @return bool
|
| 93 |
+
*/
|
| 94 |
+
public function isTestMode()
|
| 95 |
+
{
|
| 96 |
+
$mode = Mage::helper('payment')
|
| 97 |
+
->getMethodInstance($this->_paymentMethodCode)
|
| 98 |
+
->getConfigData('sandbox_flag');
|
| 99 |
+
return (bool) $mode;
|
| 100 |
+
}
|
| 101 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Info.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payflow link infoblock
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Mage_Paypal_Block_Payflow_Link_Info extends Mage_Paypal_Block_Payment_Info
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Don't show CC type
|
| 38 |
+
*
|
| 39 |
+
* @return false
|
| 40 |
+
*/
|
| 41 |
+
public function getCcTypeName()
|
| 42 |
+
{
|
| 43 |
+
return false;
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payflow/Link/Review.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal PayflowLink Express Onepage checkout block
|
| 29 |
+
*
|
| 30 |
+
* @deprecated since 1.6.2.0
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Block_Payflow_Link_Review extends Mage_Paypal_Block_Express_Review
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Retrieve payment method and assign additional template values
|
| 40 |
+
*
|
| 41 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 42 |
+
*/
|
| 43 |
+
protected function _beforeToHtml()
|
| 44 |
+
{
|
| 45 |
+
return parent::_beforeToHtml();
|
| 46 |
+
}
|
| 47 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Payment/Info.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* PayPal common payment info block
|
| 5 |
+
* Uses default templates
|
| 6 |
+
*/
|
| 7 |
+
class Ebcomm_PaypalMx_Block_Payment_Info extends Mage_Payment_Block_Info_Cc
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* Don't show CC type for non-CC methods
|
| 11 |
+
*
|
| 12 |
+
* @return string|null
|
| 13 |
+
*/
|
| 14 |
+
public function getCcTypeName()
|
| 15 |
+
{
|
| 16 |
+
if (Ebcomm_PaypalMx_Model_Config::getIsCreditCardMethod($this->getInfo()->getMethod())) {
|
| 17 |
+
return parent::getCcTypeName();
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Prepare PayPal-specific payment information
|
| 23 |
+
*
|
| 24 |
+
* @param Varien_Object|array $transport
|
| 25 |
+
* return Varien_Object
|
| 26 |
+
*/
|
| 27 |
+
protected function _prepareSpecificInformation($transport = null)
|
| 28 |
+
{
|
| 29 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
| 30 |
+
$payment = $this->getInfo();
|
| 31 |
+
$paypalInfo = Mage::getModel('paypalmx/info');
|
| 32 |
+
if (!$this->getIsSecureMode()) {
|
| 33 |
+
$info = $paypalInfo->getPaymentInfo($payment, true);
|
| 34 |
+
} else {
|
| 35 |
+
$info = $paypalInfo->getPublicPaymentInfo($payment, true);
|
| 36 |
+
}
|
| 37 |
+
return $transport->addData($info);
|
| 38 |
+
}
|
| 39 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Standard/Form.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Standard_Form extends Mage_Payment_Block_Form
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Payment method code
|
| 6 |
+
* @var string
|
| 7 |
+
*/
|
| 8 |
+
protected $_methodCode = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Config model instance
|
| 12 |
+
*
|
| 13 |
+
* @var Mage_Paypal_Model_Config
|
| 14 |
+
*/
|
| 15 |
+
protected $_config;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Set template and redirect message
|
| 19 |
+
*/
|
| 20 |
+
protected function _construct()
|
| 21 |
+
{
|
| 22 |
+
$this->_config = Mage::getModel('paypalmx/config')->setMethod($this->getMethodCode());
|
| 23 |
+
$locale = Mage::app()->getLocale();
|
| 24 |
+
$mark = Mage::getConfig()->getBlockClassName('core/template');
|
| 25 |
+
$mark = new $mark;
|
| 26 |
+
$mark->setTemplate('paypalmx/payment/mark.phtml')
|
| 27 |
+
->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($locale))
|
| 28 |
+
->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($locale->getLocaleCode()))
|
| 29 |
+
->setNoPosAH($this->_config->getnoposah())
|
| 30 |
+
; // known issue: code above will render only static mark image
|
| 31 |
+
$this->setTemplate('paypalmx/payment/redirect.phtml')
|
| 32 |
+
->setMethodTitle('') // Output PayPal mark, omit title
|
| 33 |
+
->setMethodLabelAfterHtml($mark->toHtml())
|
| 34 |
+
;
|
| 35 |
+
return parent::_construct();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Payment method code getter
|
| 40 |
+
* @return string
|
| 41 |
+
*/
|
| 42 |
+
public function getMethodCode()
|
| 43 |
+
{
|
| 44 |
+
return $this->_methodCode;
|
| 45 |
+
}
|
| 46 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Block/Standard/Redirect.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Block_Standard_Redirect extends Mage_Core_Block_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _toHtml()
|
| 5 |
+
{
|
| 6 |
+
$standard = Mage::getModel('paypalmx/standard');
|
| 7 |
+
|
| 8 |
+
$form = new Varien_Data_Form();
|
| 9 |
+
$form->setAction($standard->getConfig()->getPaypalUrl())
|
| 10 |
+
->setId('paypal_standard_checkout')
|
| 11 |
+
->setName('paypal_standard_checkout')
|
| 12 |
+
->setMethod('POST')
|
| 13 |
+
->setUseContainer(true);
|
| 14 |
+
foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) {
|
| 15 |
+
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
| 16 |
+
}
|
| 17 |
+
$idSuffix = Mage::helper('core')->uniqHash();
|
| 18 |
+
$submitButton = new Varien_Data_Form_Element_Submit(array(
|
| 19 |
+
'value' => $this->__('Click here if you are not redirected within 10 seconds...'),
|
| 20 |
+
));
|
| 21 |
+
$id = "submit_to_paypal_button_{$idSuffix}";
|
| 22 |
+
$submitButton->setId($id);
|
| 23 |
+
$form->addElement($submitButton);
|
| 24 |
+
$html = '<html><body>';
|
| 25 |
+
$html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
|
| 26 |
+
$html.= $form->toHtml();
|
| 27 |
+
$html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
|
| 28 |
+
$html.= '</body></html>';
|
| 29 |
+
|
| 30 |
+
return $html;
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Controller/Express/Abstract.php
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Abstract Express Checkout Controller
|
| 4 |
+
*/
|
| 5 |
+
abstract class Ebcomm_PaypalMx_Controller_Express_Abstract extends Mage_Core_Controller_Front_Action
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* @var Mage_Paypal_Model_Express_Checkout
|
| 9 |
+
*/
|
| 10 |
+
protected $_checkout = null;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @var Mage_Paypal_Model_Config
|
| 14 |
+
*/
|
| 15 |
+
protected $_config = null;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @var Mage_Sales_Model_Quote
|
| 19 |
+
*/
|
| 20 |
+
protected $_quote = false;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Instantiate config
|
| 24 |
+
*/
|
| 25 |
+
protected function _construct()
|
| 26 |
+
{
|
| 27 |
+
parent::_construct();
|
| 28 |
+
$this->_config = Mage::getModel($this->_configType, array($this->_configMethod));
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Start Express Checkout by requesting initial token and dispatching customer to PayPal
|
| 33 |
+
*/
|
| 34 |
+
public function startAction()
|
| 35 |
+
{
|
| 36 |
+
try {
|
| 37 |
+
$this->_initCheckout();
|
| 38 |
+
|
| 39 |
+
if ($this->_getQuote()->getIsMultiShipping()) {
|
| 40 |
+
$this->_getQuote()->setIsMultiShipping(false);
|
| 41 |
+
$this->_getQuote()->removeAllAddresses();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 45 |
+
if ($customer && $customer->getId()) {
|
| 46 |
+
$this->_checkout->setCustomerWithAddressChange(
|
| 47 |
+
$customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()
|
| 48 |
+
);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// billing agreement
|
| 52 |
+
$isBARequested = (bool)$this->getRequest()
|
| 53 |
+
->getParam(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 54 |
+
if ($customer && $customer->getId()) {
|
| 55 |
+
$this->_checkout->setIsBillingAgreementRequested($isBARequested);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// giropay
|
| 59 |
+
$this->_checkout->prepareGiropayUrls(
|
| 60 |
+
Mage::getUrl('checkout/onepage/success'),
|
| 61 |
+
Mage::getUrl('paypalmx/express/cancel'),
|
| 62 |
+
Mage::getUrl('checkout/onepage/success')
|
| 63 |
+
);
|
| 64 |
+
|
| 65 |
+
$token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel'));
|
| 66 |
+
if ($token && $url = $this->_checkout->getRedirectUrl()) {
|
| 67 |
+
$this->_initToken($token);
|
| 68 |
+
$this->getResponse()->setRedirect($url);
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
} catch (Mage_Core_Exception $e) {
|
| 72 |
+
$this->_getCheckoutSession()->addError($e->getMessage());
|
| 73 |
+
} catch (Exception $e) {
|
| 74 |
+
$this->_getCheckoutSession()->addError($this->__('Unable to start Express Checkout.'));
|
| 75 |
+
Mage::logException($e);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
$this->_redirect('checkout/cart');
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Return shipping options items for shipping address from request
|
| 83 |
+
*/
|
| 84 |
+
public function shippingOptionsCallbackAction()
|
| 85 |
+
{
|
| 86 |
+
try {
|
| 87 |
+
$quoteId = $this->getRequest()->getParam('quote_id');
|
| 88 |
+
$this->_quote = Mage::getModel('sales/quote')->load($quoteId);
|
| 89 |
+
$this->_initCheckout();
|
| 90 |
+
$response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams());
|
| 91 |
+
$this->getResponse()->setBody($response);
|
| 92 |
+
} catch (Exception $e) {
|
| 93 |
+
Mage::logException($e);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Cancel Express Checkout
|
| 99 |
+
*/
|
| 100 |
+
public function cancelAction()
|
| 101 |
+
{
|
| 102 |
+
try {
|
| 103 |
+
$this->_initToken(false);
|
| 104 |
+
// TODO verify if this logic of order cancelation is deprecated
|
| 105 |
+
// if there is an order - cancel it
|
| 106 |
+
$orderId = $this->_getCheckoutSession()->getLastOrderId();
|
| 107 |
+
$order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false;
|
| 108 |
+
if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) {
|
| 109 |
+
$order->cancel()->save();
|
| 110 |
+
$this->_getCheckoutSession()
|
| 111 |
+
->unsLastQuoteId()
|
| 112 |
+
->unsLastSuccessQuoteId()
|
| 113 |
+
->unsLastOrderId()
|
| 114 |
+
->unsLastRealOrderId()
|
| 115 |
+
->addSuccess($this->__('Express Checkout and Order have been canceled.'))
|
| 116 |
+
;
|
| 117 |
+
} else {
|
| 118 |
+
$this->_getCheckoutSession()->addSuccess($this->__('Express Checkout has been canceled.'));
|
| 119 |
+
}
|
| 120 |
+
} catch (Mage_Core_Exception $e) {
|
| 121 |
+
$this->_getCheckoutSession()->addError($e->getMessage());
|
| 122 |
+
} catch (Exception $e) {
|
| 123 |
+
$this->_getCheckoutSession()->addError($this->__('Unable to cancel Express Checkout.'));
|
| 124 |
+
Mage::logException($e);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
$this->_redirect('checkout/cart');
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Return from PayPal and dispatch customer to order review page
|
| 132 |
+
*/
|
| 133 |
+
public function returnAction()
|
| 134 |
+
{
|
| 135 |
+
try {
|
| 136 |
+
$this->_initCheckout();
|
| 137 |
+
$this->_checkout->returnFromPaypal($this->_initToken());
|
| 138 |
+
$this->_redirect('*/*/review');
|
| 139 |
+
return;
|
| 140 |
+
}
|
| 141 |
+
catch (Mage_Core_Exception $e) {
|
| 142 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
| 143 |
+
}
|
| 144 |
+
catch (Exception $e) {
|
| 145 |
+
Mage::getSingleton('checkout/session')->addError($this->__('Unable to process Express Checkout approval.'));
|
| 146 |
+
Mage::logException($e);
|
| 147 |
+
}
|
| 148 |
+
$this->_redirect('checkout/cart');
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* Review order after returning from PayPal
|
| 153 |
+
*/
|
| 154 |
+
public function reviewAction()
|
| 155 |
+
{
|
| 156 |
+
try {
|
| 157 |
+
$this->_initCheckout();
|
| 158 |
+
$this->_checkout->prepareOrderReview($this->_initToken());
|
| 159 |
+
$this->loadLayout();
|
| 160 |
+
$this->_initLayoutMessages('paypalmx/session');
|
| 161 |
+
$reviewBlock = $this->getLayout()->getBlock('paypalmx.express.review');
|
| 162 |
+
$reviewBlock->setQuote($this->_getQuote());
|
| 163 |
+
$reviewBlock->getChild('details')->setQuote($this->_getQuote());
|
| 164 |
+
if ($reviewBlock->getChild('shipping_method')) {
|
| 165 |
+
$reviewBlock->getChild('shipping_method')->setQuote($this->_getQuote());
|
| 166 |
+
}
|
| 167 |
+
$this->renderLayout();
|
| 168 |
+
return;
|
| 169 |
+
}
|
| 170 |
+
catch (Mage_Core_Exception $e) {
|
| 171 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
| 172 |
+
}
|
| 173 |
+
catch (Exception $e) {
|
| 174 |
+
Mage::getSingleton('checkout/session')->addError(
|
| 175 |
+
$this->__('Unable to initialize Express Checkout review.')
|
| 176 |
+
);
|
| 177 |
+
Mage::logException($e);
|
| 178 |
+
}
|
| 179 |
+
$this->_redirect('checkout/cart');
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Dispatch customer back to PayPal for editing payment information
|
| 184 |
+
*/
|
| 185 |
+
public function editAction()
|
| 186 |
+
{
|
| 187 |
+
try {
|
| 188 |
+
$this->getResponse()->setRedirect($this->_config->getExpressCheckoutEditUrl($this->_initToken()));
|
| 189 |
+
}
|
| 190 |
+
catch (Mage_Core_Exception $e) {
|
| 191 |
+
$this->_getSession()->addError($e->getMessage());
|
| 192 |
+
$this->_redirect('*/*/review');
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Update shipping method (combined action for ajax and regular request)
|
| 198 |
+
*/
|
| 199 |
+
public function saveShippingMethodAction()
|
| 200 |
+
{
|
| 201 |
+
try {
|
| 202 |
+
$isAjax = $this->getRequest()->getParam('isAjax');
|
| 203 |
+
$this->_initCheckout();
|
| 204 |
+
$this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method'));
|
| 205 |
+
if ($isAjax) {
|
| 206 |
+
$this->loadLayout('paypalmx_express_review_details');
|
| 207 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('root')
|
| 208 |
+
->setQuote($this->_getQuote())
|
| 209 |
+
->toHtml());
|
| 210 |
+
return;
|
| 211 |
+
}
|
| 212 |
+
} catch (Mage_Core_Exception $e) {
|
| 213 |
+
$this->_getSession()->addError($e->getMessage());
|
| 214 |
+
} catch (Exception $e) {
|
| 215 |
+
$this->_getSession()->addError($this->__('Unable to update shipping method.'));
|
| 216 |
+
Mage::logException($e);
|
| 217 |
+
}
|
| 218 |
+
if ($isAjax) {
|
| 219 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
| 220 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
| 221 |
+
} else {
|
| 222 |
+
$this->_redirect('*/*/review');
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/**
|
| 227 |
+
* Update Order (combined action for ajax and regular request)
|
| 228 |
+
*/
|
| 229 |
+
public function updateShippingMethodsAction()
|
| 230 |
+
{
|
| 231 |
+
try {
|
| 232 |
+
$this->_initCheckout();
|
| 233 |
+
$this->_checkout->prepareOrderReview($this->_initToken());
|
| 234 |
+
$this->loadLayout('paypalmx_express_review');
|
| 235 |
+
|
| 236 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method')
|
| 237 |
+
->setQuote($this->_getQuote())
|
| 238 |
+
->toHtml());
|
| 239 |
+
return;
|
| 240 |
+
} catch (Mage_Core_Exception $e) {
|
| 241 |
+
$this->_getSession()->addError($e->getMessage());
|
| 242 |
+
} catch (Exception $e) {
|
| 243 |
+
$this->_getSession()->addError($this->__('Unable to update Order data.'));
|
| 244 |
+
Mage::logException($e);
|
| 245 |
+
}
|
| 246 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
| 247 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* Update Order (combined action for ajax and regular request)
|
| 252 |
+
*/
|
| 253 |
+
public function updateOrderAction()
|
| 254 |
+
{
|
| 255 |
+
try {
|
| 256 |
+
$isAjax = $this->getRequest()->getParam('isAjax');
|
| 257 |
+
$this->_initCheckout();
|
| 258 |
+
$this->_checkout->updateOrder($this->getRequest()->getParams());
|
| 259 |
+
if ($isAjax) {
|
| 260 |
+
$this->loadLayout('paypalmx_express_review_details');
|
| 261 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('root')
|
| 262 |
+
->setQuote($this->_getQuote())
|
| 263 |
+
->toHtml());
|
| 264 |
+
return;
|
| 265 |
+
}
|
| 266 |
+
} catch (Mage_Core_Exception $e) {
|
| 267 |
+
$this->_getSession()->addError($e->getMessage());
|
| 268 |
+
} catch (Exception $e) {
|
| 269 |
+
$this->_getSession()->addError($this->__('Unable to update Order data.'));
|
| 270 |
+
Mage::logException($e);
|
| 271 |
+
}
|
| 272 |
+
if ($isAjax) {
|
| 273 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
| 274 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
| 275 |
+
} else {
|
| 276 |
+
$this->_redirect('*/*/review');
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/**
|
| 281 |
+
* Submit the order
|
| 282 |
+
*/
|
| 283 |
+
public function placeOrderAction()
|
| 284 |
+
{
|
| 285 |
+
try {
|
| 286 |
+
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
|
| 287 |
+
if ($requiredAgreements) {
|
| 288 |
+
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
|
| 289 |
+
if (array_diff($requiredAgreements, $postedAgreements)) {
|
| 290 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Please agree to all the terms and conditions before placing the order.'));
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
$this->_initCheckout();
|
| 295 |
+
$this->_checkout->place($this->_initToken());
|
| 296 |
+
|
| 297 |
+
// prepare session to success or cancellation page
|
| 298 |
+
$session = $this->_getCheckoutSession();
|
| 299 |
+
$session->clearHelperData();
|
| 300 |
+
|
| 301 |
+
// "last successful quote"
|
| 302 |
+
$quoteId = $this->_getQuote()->getId();
|
| 303 |
+
$session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
|
| 304 |
+
|
| 305 |
+
// an order may be created
|
| 306 |
+
$order = $this->_checkout->getOrder();
|
| 307 |
+
if ($order) {
|
| 308 |
+
$session->setLastOrderId($order->getId())
|
| 309 |
+
->setLastRealOrderId($order->getIncrementId());
|
| 310 |
+
// as well a billing agreement can be created
|
| 311 |
+
$agreement = $this->_checkout->getBillingAgreement();
|
| 312 |
+
if ($agreement) {
|
| 313 |
+
$session->setLastBillingAgreementId($agreement->getId());
|
| 314 |
+
}
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
// recurring profiles may be created along with the order or without it
|
| 318 |
+
$profiles = $this->_checkout->getRecurringPaymentProfiles();
|
| 319 |
+
if ($profiles) {
|
| 320 |
+
$ids = array();
|
| 321 |
+
foreach($profiles as $profile) {
|
| 322 |
+
$ids[] = $profile->getId();
|
| 323 |
+
}
|
| 324 |
+
$session->setLastRecurringProfileIds($ids);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
// redirect if PayPal specified some URL (for example, to Giropay bank)
|
| 328 |
+
$url = $this->_checkout->getRedirectUrl();
|
| 329 |
+
if ($url) {
|
| 330 |
+
$this->getResponse()->setRedirect($url);
|
| 331 |
+
return;
|
| 332 |
+
}
|
| 333 |
+
$this->_initToken(false); // no need in token anymore
|
| 334 |
+
$this->_redirect('checkout/onepage/success');
|
| 335 |
+
return;
|
| 336 |
+
}
|
| 337 |
+
catch (Mage_Core_Exception $e) {
|
| 338 |
+
$this->_getSession()->addError($e->getMessage());
|
| 339 |
+
}
|
| 340 |
+
catch (Exception $e) {
|
| 341 |
+
$this->_getSession()->addError($this->__('Unable to place the order.'));
|
| 342 |
+
Mage::logException($e);
|
| 343 |
+
}
|
| 344 |
+
$this->_redirect('*/*/review');
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* Instantiate quote and checkout
|
| 349 |
+
* @throws Mage_Core_Exception
|
| 350 |
+
*/
|
| 351 |
+
private function _initCheckout()
|
| 352 |
+
{
|
| 353 |
+
$quote = $this->_getQuote();
|
| 354 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 355 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
| 356 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Unable to initialize Express Checkout.'));
|
| 357 |
+
}
|
| 358 |
+
$this->_checkout = Mage::getSingleton($this->_checkoutType, array(
|
| 359 |
+
'config' => $this->_config,
|
| 360 |
+
'quote' => $quote,
|
| 361 |
+
));
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
/**
|
| 365 |
+
* Search for proper checkout token in request or session or (un)set specified one
|
| 366 |
+
* Combined getter/setter
|
| 367 |
+
*
|
| 368 |
+
* @param string $setToken
|
| 369 |
+
* @return Mage_Paypal_ExpressController|string
|
| 370 |
+
*/
|
| 371 |
+
protected function _initToken($setToken = null)
|
| 372 |
+
{
|
| 373 |
+
if (null !== $setToken) {
|
| 374 |
+
if (false === $setToken) {
|
| 375 |
+
// security measure for avoid unsetting token twice
|
| 376 |
+
if (!$this->_getSession()->getExpressCheckoutToken()) {
|
| 377 |
+
Mage::throwException($this->__('PayPal Express Checkout Token does not exist.'));
|
| 378 |
+
}
|
| 379 |
+
$this->_getSession()->unsExpressCheckoutToken();
|
| 380 |
+
} else {
|
| 381 |
+
$this->_getSession()->setExpressCheckoutToken($setToken);
|
| 382 |
+
}
|
| 383 |
+
return $this;
|
| 384 |
+
}
|
| 385 |
+
if ($setToken = $this->getRequest()->getParam('token')) {
|
| 386 |
+
if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) {
|
| 387 |
+
Mage::throwException($this->__('Wrong PayPal Express Checkout Token specified.'));
|
| 388 |
+
}
|
| 389 |
+
} else {
|
| 390 |
+
$setToken = $this->_getSession()->getExpressCheckoutToken();
|
| 391 |
+
}
|
| 392 |
+
return $setToken;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/**
|
| 396 |
+
* PayPal session instance getter
|
| 397 |
+
*
|
| 398 |
+
* @return Mage_PayPal_Model_Session
|
| 399 |
+
*/
|
| 400 |
+
private function _getSession()
|
| 401 |
+
{
|
| 402 |
+
return Mage::getSingleton('paypalmx/session');
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
/**
|
| 406 |
+
* Return checkout session object
|
| 407 |
+
*
|
| 408 |
+
* @return Mage_Checkout_Model_Session
|
| 409 |
+
*/
|
| 410 |
+
private function _getCheckoutSession()
|
| 411 |
+
{
|
| 412 |
+
return Mage::getSingleton('checkout/session');
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* Return checkout quote object
|
| 417 |
+
*
|
| 418 |
+
* @return Mage_Sale_Model_Quote
|
| 419 |
+
*/
|
| 420 |
+
private function _getQuote()
|
| 421 |
+
{
|
| 422 |
+
if (!$this->_quote) {
|
| 423 |
+
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
| 424 |
+
}
|
| 425 |
+
return $this->_quote;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/**
|
| 429 |
+
* Redirect to login page
|
| 430 |
+
*
|
| 431 |
+
*/
|
| 432 |
+
public function redirectLogin()
|
| 433 |
+
{
|
| 434 |
+
$this->setFlag('', 'no-dispatch', true);
|
| 435 |
+
$this->getResponse()->setRedirect(
|
| 436 |
+
Mage::helper('core/url')->addRequestParam(
|
| 437 |
+
Mage::helper('customer')->getLoginUrl(),
|
| 438 |
+
array('context' => 'checkout')
|
| 439 |
+
)
|
| 440 |
+
);
|
| 441 |
+
}
|
| 442 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Helper/Data.php
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cache for shouldAskToCreateBillingAgreement()
|
| 6 |
+
*
|
| 7 |
+
* @var bool
|
| 8 |
+
*/
|
| 9 |
+
protected static $_shouldAskToCreateBillingAgreement = null;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Check whether customer should be asked confirmation whether to sign a billing agreement
|
| 13 |
+
*
|
| 14 |
+
* @param Mage_Paypal_Model_Config $config
|
| 15 |
+
* @param int $customerId
|
| 16 |
+
* @return bool
|
| 17 |
+
*/
|
| 18 |
+
public function shouldAskToCreateBillingAgreement(Ebcomm_PaypalMx_Model_Config $config, $customerId)
|
| 19 |
+
{
|
| 20 |
+
if (null === self::$_shouldAskToCreateBillingAgreement) {
|
| 21 |
+
self::$_shouldAskToCreateBillingAgreement = false;
|
| 22 |
+
if ($customerId && $config->shouldAskToCreateBillingAgreement()) {
|
| 23 |
+
if (Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($customerId)) {
|
| 24 |
+
self::$_shouldAskToCreateBillingAgreement = true;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
return self::$_shouldAskToCreateBillingAgreement;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Return backend config for element like JSON
|
| 33 |
+
*
|
| 34 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 35 |
+
* @return string
|
| 36 |
+
*/
|
| 37 |
+
public function getElementBackendConfig(Varien_Data_Form_Element_Abstract $element) {
|
| 38 |
+
$config = $element->getFieldConfig()->backend_congif;
|
| 39 |
+
if (!$config) {
|
| 40 |
+
return false;
|
| 41 |
+
}
|
| 42 |
+
$config = $config->asCanonicalArray();
|
| 43 |
+
if (isset($config['enable_for_countries'])) {
|
| 44 |
+
$config['enable_for_countries'] = explode(',', str_replace(' ', '', $config['enable_for_countries']));
|
| 45 |
+
}
|
| 46 |
+
if (isset($config['disable_for_countries'])) {
|
| 47 |
+
$config['disable_for_countries'] = explode(',', str_replace(' ', '', $config['disable_for_countries']));
|
| 48 |
+
}
|
| 49 |
+
return Mage::helper('core')->jsonEncode($config);
|
| 50 |
+
}
|
| 51 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Helper/Hss.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Helper_Hss extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected $_hssMethods = array(
|
| 5 |
+
Ebcomm_PaypalMx_Model_Config::METHOD_PAYPALMX,
|
| 6 |
+
);
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Get template for button in order review page if HSS method was selected
|
| 10 |
+
*
|
| 11 |
+
* @param string $name template name
|
| 12 |
+
* @param string $block buttons block name
|
| 13 |
+
* @return string
|
| 14 |
+
*/
|
| 15 |
+
public function getReviewButtonTemplate($name, $block)
|
| 16 |
+
{
|
| 17 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
| 18 |
+
if ($quote) {
|
| 19 |
+
$payment = $quote->getPayment();
|
| 20 |
+
if ($payment && in_array($payment->getMethod(), $this->_hssMethods)) {
|
| 21 |
+
return $name;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
if ($blockObject = Mage::getSingleton('core/layout')->getBlock($block)) {
|
| 26 |
+
return $blockObject->getTemplate();
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
return '';
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Get methods
|
| 34 |
+
*
|
| 35 |
+
* @return array
|
| 36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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Abstract class for Paypal API wrappers
|
| 5 |
+
*
|
| 6 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 7 |
+
*/
|
| 8 |
+
abstract class Ebcomm_PaypalMx_Model_Api_Abstract extends Varien_Object
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Config instance
|
| 12 |
+
* @var Ebcomm_PaypalMx_Model_Config
|
| 13 |
+
*/
|
| 14 |
+
protected $_config = null;
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Global private to public interface map
|
| 18 |
+
* @var array
|
| 19 |
+
*/
|
| 20 |
+
protected $_globalMap = array();
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Filter callbacks for exporting $this data to API call
|
| 24 |
+
*
|
| 25 |
+
* @var array
|
| 26 |
+
*/
|
| 27 |
+
protected $_exportToRequestFilters = array();
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Filter callbacks for importing API result to $this data
|
| 31 |
+
*
|
| 32 |
+
* @var array
|
| 33 |
+
*/
|
| 34 |
+
protected $_importFromRequestFilters = array();
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Line items export to request mapping settings
|
| 38 |
+
* @var array
|
| 39 |
+
*/
|
| 40 |
+
protected $_lineItemExportItemsFormat = array();
|
| 41 |
+
protected $_lineItemExportItemsFilters = array();
|
| 42 |
+
protected $_lineItemTotalExportMap = array();
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* PayPal shopping cart instance
|
| 46 |
+
*
|
| 47 |
+
* @var Ebcomm_PaypalMx_Model_Cart
|
| 48 |
+
*/
|
| 49 |
+
protected $_cart = null;
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Shipping options export to request mapping settings
|
| 53 |
+
* @var array
|
| 54 |
+
*/
|
| 55 |
+
protected $_shippingOptionsExportItemsFormat = array();
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Imported recurring profiles array
|
| 59 |
+
*
|
| 60 |
+
* @var array
|
| 61 |
+
*/
|
| 62 |
+
protected $_recurringPaymentProfiles = array();
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Fields that should be replaced in debug with '***'
|
| 66 |
+
*
|
| 67 |
+
* @var array
|
| 68 |
+
*/
|
| 69 |
+
protected $_debugReplacePrivateDataKeys = array();
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Return Paypal Api user name based on config data
|
| 73 |
+
*
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getApiUsername()
|
| 77 |
+
{
|
| 78 |
+
return $this->_config->apiUsername;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Return Paypal Api password based on config data
|
| 83 |
+
*
|
| 84 |
+
* @return string
|
| 85 |
+
*/
|
| 86 |
+
public function getApiPassword()
|
| 87 |
+
{
|
| 88 |
+
return $this->_config->apiPassword;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Return Paypal Api signature based on config data
|
| 93 |
+
*
|
| 94 |
+
* @return string
|
| 95 |
+
*/
|
| 96 |
+
public function getApiSignature()
|
| 97 |
+
{
|
| 98 |
+
return $this->_config->apiSignature;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Return Paypal Api certificate based on config data
|
| 103 |
+
*
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function getApiCertificate()
|
| 107 |
+
{
|
| 108 |
+
return $this->_config->getApiCertificate();
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* BN code getter
|
| 113 |
+
*
|
| 114 |
+
* @return string
|
| 115 |
+
*/
|
| 116 |
+
public function getBuildNotationCode()
|
| 117 |
+
{
|
| 118 |
+
return $this->_config->getBuildNotationCode();
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Return Paypal Api proxy status based on config data
|
| 123 |
+
*
|
| 124 |
+
* @return bool
|
| 125 |
+
*/
|
| 126 |
+
public function getUseProxy()
|
| 127 |
+
{
|
| 128 |
+
return $this->_getDataOrConfig('use_proxy', false);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Return Paypal Api proxy host based on config data
|
| 133 |
+
*
|
| 134 |
+
* @return string
|
| 135 |
+
*/
|
| 136 |
+
public function getProxyHost()
|
| 137 |
+
{
|
| 138 |
+
return $this->_getDataOrConfig('proxy_host', '127.0.0.1');
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Return Paypal Api proxy port based on config data
|
| 143 |
+
*
|
| 144 |
+
* @return string
|
| 145 |
+
*/
|
| 146 |
+
public function getProxyPort()
|
| 147 |
+
{
|
| 148 |
+
return $this->_getDataOrConfig('proxy_port', '808');
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* @deprecated after 1.4.1.0
|
| 153 |
+
*
|
| 154 |
+
* @return bool
|
| 155 |
+
*/
|
| 156 |
+
public function getDebug()
|
| 157 |
+
{
|
| 158 |
+
return $this->getDebugFlag();
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* PayPal page CSS getter
|
| 163 |
+
*
|
| 164 |
+
* @return string
|
| 165 |
+
*/
|
| 166 |
+
public function getPageStyle()
|
| 167 |
+
{
|
| 168 |
+
return $this->_getDataOrConfig('page_style');
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
* PayPal page header image URL getter
|
| 173 |
+
*
|
| 174 |
+
* @return string
|
| 175 |
+
*/
|
| 176 |
+
public function getHdrimg()
|
| 177 |
+
{
|
| 178 |
+
return $this->_getDataOrConfig('paypal_hdrimg');
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* PayPal page header border color getter
|
| 183 |
+
*
|
| 184 |
+
* @return string
|
| 185 |
+
*/
|
| 186 |
+
public function getHdrbordercolor()
|
| 187 |
+
{
|
| 188 |
+
return $this->_getDataOrConfig('paypal_hdrbordercolor');
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
/**
|
| 192 |
+
* PayPal page header background color getter
|
| 193 |
+
*
|
| 194 |
+
* @return string
|
| 195 |
+
*/
|
| 196 |
+
public function getHdrbackcolor()
|
| 197 |
+
{
|
| 198 |
+
return $this->_getDataOrConfig('paypal_hdrbackcolor');
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* PayPal page "payflow color" (?) getter
|
| 203 |
+
*
|
| 204 |
+
* @return string
|
| 205 |
+
*/
|
| 206 |
+
public function getPayflowcolor()
|
| 207 |
+
{
|
| 208 |
+
return $this->_getDataOrConfig('paypal_payflowcolor');
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* Payment action getter
|
| 213 |
+
*
|
| 214 |
+
* @return string
|
| 215 |
+
*/
|
| 216 |
+
public function getPaymentAction()
|
| 217 |
+
{
|
| 218 |
+
return "Sale";
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
/**
|
| 222 |
+
* PayPal merchant email getter
|
| 223 |
+
*/
|
| 224 |
+
public function getBusinessAccount()
|
| 225 |
+
{
|
| 226 |
+
return $this->_getDataOrConfig('business_account');
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Import $this public data to specified object or array
|
| 231 |
+
*
|
| 232 |
+
* @param array|Varien_Object $to
|
| 233 |
+
* @param array $publicMap
|
| 234 |
+
* @return array|Varien_Object
|
| 235 |
+
*/
|
| 236 |
+
public function &import($to, array $publicMap = array())
|
| 237 |
+
{
|
| 238 |
+
return Varien_Object_Mapper::accumulateByMap(array($this, 'getDataUsingMethod'), $to, $publicMap);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* Export $this public data from specified object or array
|
| 243 |
+
*
|
| 244 |
+
* @param array|Varien_Object $from
|
| 245 |
+
* @param array $publicMap
|
| 246 |
+
* @return Ebcomm_PaypalMx_Model_Api_Abstract
|
| 247 |
+
*/
|
| 248 |
+
public function export($from, array $publicMap = array())
|
| 249 |
+
{
|
| 250 |
+
Varien_Object_Mapper::accumulateByMap($from, array($this, 'setDataUsingMethod'), $publicMap);
|
| 251 |
+
return $this;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Set PayPal cart instance
|
| 256 |
+
*
|
| 257 |
+
* @param Ebcomm_PaypalMx_Model_Cart $cart
|
| 258 |
+
* @return Ebcomm_PaypalMx_Model_Api_Abstract
|
| 259 |
+
*/
|
| 260 |
+
public function setPaypalCart(Ebcomm_PaypalMx_Model_Cart $cart)
|
| 261 |
+
{
|
| 262 |
+
$this->_cart = $cart;
|
| 263 |
+
return $this;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* Config instance setter
|
| 268 |
+
* @param Ebcomm_PaypalMx_Model_Config $config
|
| 269 |
+
* @return Ebcomm_PaypalMx_Model_Api_Abstract
|
| 270 |
+
*/
|
| 271 |
+
public function setConfigObject(Ebcomm_PaypalMx_Model_Config $config)
|
| 272 |
+
{
|
| 273 |
+
$this->_config = $config;
|
| 274 |
+
return $this;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* Current locale code getter
|
| 279 |
+
*
|
| 280 |
+
* @return string
|
| 281 |
+
*/
|
| 282 |
+
public function getLocaleCode()
|
| 283 |
+
{
|
| 284 |
+
return Mage::app()->getLocale()->getLocaleCode();
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Always take into accoun
|
| 289 |
+
*/
|
| 290 |
+
public function getFraudManagementFiltersEnabled()
|
| 291 |
+
{
|
| 292 |
+
return 1;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Set recurring profiles
|
| 297 |
+
*
|
| 298 |
+
* @param array $items
|
| 299 |
+
* @return Ebcomm_PaypalMx_Model_Api_Abstract
|
| 300 |
+
*/
|
| 301 |
+
public function addRecurringPaymentProfiles(array $items)
|
| 302 |
+
{
|
| 303 |
+
if ($items) {
|
| 304 |
+
$this->_recurringPaymentProfiles = $items;
|
| 305 |
+
}
|
| 306 |
+
return $this;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
* Export $this public data to private request array
|
| 311 |
+
*
|
| 312 |
+
* @param array $internalRequestMap
|
| 313 |
+
* @param array $request
|
| 314 |
+
* @return array
|
| 315 |
+
*/
|
| 316 |
+
protected function &_exportToRequest(array $privateRequestMap, array $request = array())
|
| 317 |
+
{
|
| 318 |
+
$map = array();
|
| 319 |
+
foreach ($privateRequestMap as $key) {
|
| 320 |
+
if (isset($this->_globalMap[$key])) {
|
| 321 |
+
$map[$this->_globalMap[$key]] = $key;
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
$result = Varien_Object_Mapper::accumulateByMap(array($this, 'getDataUsingMethod'), $request, $map);
|
| 325 |
+
foreach ($privateRequestMap as $key) {
|
| 326 |
+
if (isset($this->_exportToRequestFilters[$key]) && isset($result[$key])) {
|
| 327 |
+
$callback = $this->_exportToRequestFilters[$key];
|
| 328 |
+
$privateKey = $result[$key];
|
| 329 |
+
$publicKey = $map[$this->_globalMap[$key]];
|
| 330 |
+
$result[$key] = call_user_func(array($this, $callback), $privateKey, $publicKey);
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
return $result;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* Import $this public data from a private response array
|
| 338 |
+
*
|
| 339 |
+
* @param array $privateResponseMap
|
| 340 |
+
* @param array $response
|
| 341 |
+
*/
|
| 342 |
+
protected function _importFromResponse(array $privateResponseMap, array $response)
|
| 343 |
+
{
|
| 344 |
+
$map = array();
|
| 345 |
+
foreach ($privateResponseMap as $key) {
|
| 346 |
+
if (isset($this->_globalMap[$key])) {
|
| 347 |
+
$map[$key] = $this->_globalMap[$key];
|
| 348 |
+
}
|
| 349 |
+
if (isset($response[$key]) && isset($this->_importFromRequestFilters[$key])) {
|
| 350 |
+
$callback = $this->_importFromRequestFilters[$key];
|
| 351 |
+
$response[$key] = call_user_func(array($this, $callback), $response[$key], $key, $map[$key]);
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
Varien_Object_Mapper::accumulateByMap($response, array($this, 'setDataUsingMethod'), $map);
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
/**
|
| 358 |
+
* Prepare line items request
|
| 359 |
+
*
|
| 360 |
+
* Returns true if there were line items added
|
| 361 |
+
*
|
| 362 |
+
* @param array &$request
|
| 363 |
+
* @param int $i
|
| 364 |
+
* @return true|bool
|
| 365 |
+
*/
|
| 366 |
+
protected function _exportLineItems(array &$request, $i = 0)
|
| 367 |
+
{
|
| 368 |
+
if (!$this->_cart) {
|
| 369 |
+
return;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
// always add cart totals, even if line items are not requested
|
| 373 |
+
if ($this->_lineItemTotalExportMap) {
|
| 374 |
+
foreach ($this->_cart->getTotals() as $key => $total) {
|
| 375 |
+
if (isset($this->_lineItemTotalExportMap[$key])) { // !empty($total)
|
| 376 |
+
$privateKey = $this->_lineItemTotalExportMap[$key];
|
| 377 |
+
$request[$privateKey] = $this->_filterAmount($total);
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
// add cart line items
|
| 383 |
+
$items = $this->_cart->getItems();
|
| 384 |
+
if (empty($items) || !$this->getIsLineItemsEnabled()) {
|
| 385 |
+
return;
|
| 386 |
+
}
|
| 387 |
+
$result = null;
|
| 388 |
+
foreach ($items as $item) {
|
| 389 |
+
foreach ($this->_lineItemExportItemsFormat as $publicKey => $privateFormat) {
|
| 390 |
+
$result = true;
|
| 391 |
+
$value = $item->getDataUsingMethod($publicKey);
|
| 392 |
+
if (isset($this->_lineItemExportItemsFilters[$publicKey])) {
|
| 393 |
+
$callback = $this->_lineItemExportItemsFilters[$publicKey];
|
| 394 |
+
$value = call_user_func(array($this, $callback), $value);
|
| 395 |
+
}
|
| 396 |
+
if (is_float($value)) {
|
| 397 |
+
$value = $this->_filterAmount($value);
|
| 398 |
+
}
|
| 399 |
+
$request[sprintf($privateFormat, $i)] = $value;
|
| 400 |
+
}
|
| 401 |
+
$i++;
|
| 402 |
+
}
|
| 403 |
+
return $result;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* Prepare shipping options request
|
| 408 |
+
* Returns false if there are no shipping options
|
| 409 |
+
*
|
| 410 |
+
* @param array &$request
|
| 411 |
+
* @param int $i
|
| 412 |
+
* @return bool
|
| 413 |
+
*/
|
| 414 |
+
protected function _exportShippingOptions(array &$request, $i = 0)
|
| 415 |
+
{
|
| 416 |
+
$options = $this->getShippingOptions();
|
| 417 |
+
if (empty($options)) {
|
| 418 |
+
return false;
|
| 419 |
+
}
|
| 420 |
+
foreach ($options as $option) {
|
| 421 |
+
foreach ($this->_shippingOptionsExportItemsFormat as $publicKey => $privateFormat) {
|
| 422 |
+
$value = $option->getDataUsingMethod($publicKey);
|
| 423 |
+
if (is_float($value)) {
|
| 424 |
+
$value = $this->_filterAmount($value);
|
| 425 |
+
}
|
| 426 |
+
if (is_bool($value)) {
|
| 427 |
+
$value = $this->_filterBool($value);
|
| 428 |
+
}
|
| 429 |
+
$request[sprintf($privateFormat, $i)] = $value;
|
| 430 |
+
}
|
| 431 |
+
$i++;
|
| 432 |
+
}
|
| 433 |
+
return true;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
/**
|
| 437 |
+
* Filter amounts in API calls
|
| 438 |
+
* @param float|string $value
|
| 439 |
+
* @return string
|
| 440 |
+
*/
|
| 441 |
+
protected function _filterAmount($value)
|
| 442 |
+
{
|
| 443 |
+
return sprintf('%.2F', $value);
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
/**
|
| 447 |
+
* Filter boolean values in API calls
|
| 448 |
+
*
|
| 449 |
+
* @param mixed $value
|
| 450 |
+
* @return string
|
| 451 |
+
*/
|
| 452 |
+
protected function _filterBool($value)
|
| 453 |
+
{
|
| 454 |
+
return ($value) ? 'true' : 'false';
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
/**
|
| 458 |
+
* Filter int values in API calls
|
| 459 |
+
*
|
| 460 |
+
* @param mixed $value
|
| 461 |
+
* @return int
|
| 462 |
+
*/
|
| 463 |
+
protected function _filterInt($value)
|
| 464 |
+
{
|
| 465 |
+
return (int)$value;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/**
|
| 469 |
+
* Unified getter that looks in data or falls back to config
|
| 470 |
+
*
|
| 471 |
+
* @param string $key
|
| 472 |
+
* @param mixed $default
|
| 473 |
+
* @return mixed
|
| 474 |
+
*/
|
| 475 |
+
protected function _getDataOrConfig($key, $default = null)
|
| 476 |
+
{
|
| 477 |
+
if ($this->hasData($key)) {
|
| 478 |
+
return $this->getData($key);
|
| 479 |
+
}
|
| 480 |
+
return $this->_config->$key ? $this->_config->$key : $default;
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* region_id workaround: PayPal requires state code, try to find one in the address
|
| 486 |
+
*
|
| 487 |
+
* @param Varien_Object $address
|
| 488 |
+
* @return string
|
| 489 |
+
*/
|
| 490 |
+
protected function _lookupRegionCodeFromAddress(Varien_Object $address)
|
| 491 |
+
{
|
| 492 |
+
if ($regionId = $address->getData('region_id')) {
|
| 493 |
+
$region = Mage::getModel('directory/region')->load($regionId);
|
| 494 |
+
if ($region->getId()) {
|
| 495 |
+
return $region->getCode();
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
return '';
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/**
|
| 502 |
+
* Street address workaround: divides address lines into parts by specified keys
|
| 503 |
+
* (keys should go as 3rd, 4th[...] parameters)
|
| 504 |
+
*
|
| 505 |
+
* @param Varien_Object $address
|
| 506 |
+
* @param array $request
|
| 507 |
+
*/
|
| 508 |
+
protected function _importStreetFromAddress(Varien_Object $address, array &$to)
|
| 509 |
+
{
|
| 510 |
+
$keys = func_get_args(); array_shift($keys); array_shift($keys);
|
| 511 |
+
$street = $address->getStreet();
|
| 512 |
+
if (!$keys || !$street || !is_array($street)) {
|
| 513 |
+
return;
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
$street = Mage::helper('customer/address')
|
| 517 |
+
->convertStreetLines($address->getStreet(), count($keys));
|
| 518 |
+
|
| 519 |
+
$i = 0;
|
| 520 |
+
foreach ($keys as $key) {
|
| 521 |
+
$to[$key] = isset($street[$i]) ? $street[$i]: '';
|
| 522 |
+
$i++;
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
/**
|
| 527 |
+
* Build query string from request
|
| 528 |
+
*
|
| 529 |
+
* @param array $request
|
| 530 |
+
* @return string
|
| 531 |
+
*/
|
| 532 |
+
protected function _buildQuery($request)
|
| 533 |
+
{
|
| 534 |
+
return http_build_query($request);
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
/**
|
| 538 |
+
* Filter qty in API calls
|
| 539 |
+
* Paypal note: The value for quantity must be a positive integer. Null, zero, or negative numbers are not allowed.
|
| 540 |
+
*
|
| 541 |
+
* @param float|string|int $value
|
| 542 |
+
* @return string
|
| 543 |
+
*/
|
| 544 |
+
protected function _filterQty($value)
|
| 545 |
+
{
|
| 546 |
+
return intval($value);
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
/**
|
| 550 |
+
* Log debug data to file
|
| 551 |
+
*
|
| 552 |
+
* @param mixed $debugData
|
| 553 |
+
*/
|
| 554 |
+
protected function _debug($debugData)
|
| 555 |
+
{
|
| 556 |
+
if ($this->getDebugFlag()) {
|
| 557 |
+
Mage::getModel('core/log_adapter', 'payment_' . $this->_config->getMethodCode() . '.log')
|
| 558 |
+
->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
|
| 559 |
+
->log($debugData);
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
/**
|
| 564 |
+
* Define if debugging is enabled
|
| 565 |
+
*
|
| 566 |
+
* @return bool
|
| 567 |
+
*/
|
| 568 |
+
public function getDebugFlag()
|
| 569 |
+
{
|
| 570 |
+
return $this->_config->debug;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Check whether API certificate authentication should be used
|
| 575 |
+
*
|
| 576 |
+
* @return bool
|
| 577 |
+
*/
|
| 578 |
+
public function getUseCertAuthentication()
|
| 579 |
+
{
|
| 580 |
+
return (bool)$this->_config->apiAuthentication;
|
| 581 |
+
}
|
| 582 |
+
}
|
app/code/community/Ebcomm/PaypalMx/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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* NVP API wrappers model
|
| 4 |
+
* @TODO: move some parts to abstract, don't hesitate to throw exceptions on api calls
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_Api_Nvp extends Ebcomm_PaypalMx_Model_Api_Abstract
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Paypal methods definition
|
| 10 |
+
*/
|
| 11 |
+
const DO_DIRECT_PAYMENT = 'DoDirectPayment';
|
| 12 |
+
const DO_CAPTURE = 'DoCapture';
|
| 13 |
+
const DO_AUTHORIZATION = 'DoAuthorization';
|
| 14 |
+
const DO_VOID = 'DoVoid';
|
| 15 |
+
const REFUND_TRANSACTION = 'RefundTransaction';
|
| 16 |
+
const SET_EXPRESS_CHECKOUT = 'SetExpressCheckout';
|
| 17 |
+
const GET_EXPRESS_CHECKOUT_DETAILS = 'GetExpressCheckoutDetails';
|
| 18 |
+
const DO_EXPRESS_CHECKOUT_PAYMENT = 'DoExpressCheckoutPayment';
|
| 19 |
+
const CALLBACK_RESPONSE = 'CallbackResponse';
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Paypal ManagePendingTransactionStatus actions
|
| 23 |
+
*/
|
| 24 |
+
const PENDING_TRANSACTION_ACCEPT = 'Accept';
|
| 25 |
+
const PENDING_TRANSACTION_DENY = 'Deny';
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Capture types (make authorization close or remain open)
|
| 29 |
+
* @var string
|
| 30 |
+
*/
|
| 31 |
+
protected $_captureTypeComplete = 'Complete';
|
| 32 |
+
protected $_captureTypeNotcomplete = 'NotComplete';
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Global public interface map
|
| 36 |
+
* @var array
|
| 37 |
+
*/
|
| 38 |
+
protected $_globalMap = array(
|
| 39 |
+
// each call
|
| 40 |
+
'VERSION' => 'version',
|
| 41 |
+
'USER' => 'api_username',
|
| 42 |
+
'PWD' => 'api_password',
|
| 43 |
+
'SIGNATURE' => 'api_signature',
|
| 44 |
+
'BUTTONSOURCE' => 'build_notation_code',
|
| 45 |
+
|
| 46 |
+
// for Unilateral payments
|
| 47 |
+
'SUBJECT' => 'business_account',
|
| 48 |
+
|
| 49 |
+
// commands
|
| 50 |
+
'PAYMENTACTION' => 'payment_action',
|
| 51 |
+
'RETURNURL' => 'return_url',
|
| 52 |
+
'CANCELURL' => 'cancel_url',
|
| 53 |
+
'INVNUM' => 'inv_num',
|
| 54 |
+
'TOKEN' => 'token',
|
| 55 |
+
'CORRELATIONID' => 'correlation_id',
|
| 56 |
+
'SOLUTIONTYPE' => 'solution_type',
|
| 57 |
+
'GIROPAYCANCELURL' => 'giropay_cancel_url',
|
| 58 |
+
'GIROPAYSUCCESSURL' => 'giropay_success_url',
|
| 59 |
+
'BANKTXNPENDINGURL' => 'giropay_bank_txn_pending_url',
|
| 60 |
+
'IPADDRESS' => 'ip_address',
|
| 61 |
+
'NOTIFYURL' => 'notify_url',
|
| 62 |
+
'RETURNFMFDETAILS' => 'fraud_management_filters_enabled',
|
| 63 |
+
'NOTE' => 'note',
|
| 64 |
+
'REFUNDTYPE' => 'refund_type',
|
| 65 |
+
'ACTION' => 'action',
|
| 66 |
+
'REDIRECTREQUIRED' => 'redirect_required',
|
| 67 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => 'redirect_requested',
|
| 68 |
+
'REQBILLINGADDRESS' => 'require_billing_address',
|
| 69 |
+
// style settings
|
| 70 |
+
'PAGESTYLE' => 'page_style',
|
| 71 |
+
'HDRIMG' => 'hdrimg',
|
| 72 |
+
'HDRBORDERCOLOR' => 'hdrbordercolor',
|
| 73 |
+
'HDRBACKCOLOR' => 'hdrbackcolor',
|
| 74 |
+
'PAYFLOWCOLOR' => 'payflowcolor',
|
| 75 |
+
'LOCALECODE' => 'locale_code',
|
| 76 |
+
'PAL' => 'pal',
|
| 77 |
+
|
| 78 |
+
// transaction info
|
| 79 |
+
'TRANSACTIONID' => 'transaction_id',
|
| 80 |
+
'AUTHORIZATIONID' => 'authorization_id',
|
| 81 |
+
'REFUNDTRANSACTIONID' => 'refund_transaction_id',
|
| 82 |
+
'COMPLETETYPE' => 'complete_type',
|
| 83 |
+
'AMT' => 'amount',
|
| 84 |
+
'ITEMAMT' => 'subtotal_amount',
|
| 85 |
+
'GROSSREFUNDAMT' => 'refunded_amount', // possible mistake, check with API reference
|
| 86 |
+
|
| 87 |
+
// payment/billing info
|
| 88 |
+
'CURRENCYCODE' => 'currency_code',
|
| 89 |
+
'PAYMENTSTATUS' => 'payment_status',
|
| 90 |
+
'PENDINGREASON' => 'pending_reason',
|
| 91 |
+
'PROTECTIONELIGIBILITY' => 'protection_eligibility',
|
| 92 |
+
'PAYERID' => 'payer_id',
|
| 93 |
+
'PAYERSTATUS' => 'payer_status',
|
| 94 |
+
'ADDRESSID' => 'address_id',
|
| 95 |
+
'ADDRESSSTATUS' => 'address_status',
|
| 96 |
+
'EMAIL' => 'email',
|
| 97 |
+
// backwards compatibility
|
| 98 |
+
'FIRSTNAME' => 'firstname',
|
| 99 |
+
'LASTNAME' => 'lastname',
|
| 100 |
+
|
| 101 |
+
// shipping rate
|
| 102 |
+
'SHIPPINGOPTIONNAME' => 'shipping_rate_code',
|
| 103 |
+
'NOSHIPPING' => 'suppress_shipping',
|
| 104 |
+
|
| 105 |
+
// paypal direct credit card information
|
| 106 |
+
'CREDITCARDTYPE' => 'credit_card_type',
|
| 107 |
+
'ACCT' => 'credit_card_number',
|
| 108 |
+
'EXPDATE' => 'credit_card_expiration_date',
|
| 109 |
+
'CVV2' => 'credit_card_cvv2',
|
| 110 |
+
'STARTDATE' => 'maestro_solo_issue_date', // MMYYYY, always six chars, including leading zero
|
| 111 |
+
'ISSUENUMBER' => 'maestro_solo_issue_number',
|
| 112 |
+
'CVV2MATCH' => 'cvv2_check_result',
|
| 113 |
+
'AVSCODE' => 'avs_result',
|
| 114 |
+
// cardinal centinel
|
| 115 |
+
'AUTHSTATUS3DS' => 'centinel_authstatus',
|
| 116 |
+
'MPIVENDOR3DS' => 'centinel_mpivendor',
|
| 117 |
+
'CAVV' => 'centinel_cavv',
|
| 118 |
+
'ECI3DS' => 'centinel_eci',
|
| 119 |
+
'XID' => 'centinel_xid',
|
| 120 |
+
'VPAS' => 'centinel_vpas_result',
|
| 121 |
+
'ECISUBMITTED3DS' => 'centinel_eci_result',
|
| 122 |
+
|
| 123 |
+
// recurring payment profiles
|
| 124 |
+
//'TOKEN' => 'token',
|
| 125 |
+
'SUBSCRIBERNAME' =>'subscriber_name',
|
| 126 |
+
'PROFILESTARTDATE' => 'start_datetime',
|
| 127 |
+
'PROFILEREFERENCE' => 'internal_reference_id',
|
| 128 |
+
'DESC' => 'schedule_description',
|
| 129 |
+
'MAXFAILEDPAYMENTS' => 'suspension_threshold',
|
| 130 |
+
'AUTOBILLAMT' => 'bill_failed_later',
|
| 131 |
+
'BILLINGPERIOD' => 'period_unit',
|
| 132 |
+
'BILLINGFREQUENCY' => 'period_frequency',
|
| 133 |
+
'TOTALBILLINGCYCLES' => 'period_max_cycles',
|
| 134 |
+
//'AMT' => 'billing_amount', // have to use 'amount', see above
|
| 135 |
+
'TRIALBILLINGPERIOD' => 'trial_period_unit',
|
| 136 |
+
'TRIALBILLINGFREQUENCY' => 'trial_period_frequency',
|
| 137 |
+
'TRIALTOTALBILLINGCYCLES' => 'trial_period_max_cycles',
|
| 138 |
+
'TRIALAMT' => 'trial_billing_amount',
|
| 139 |
+
// 'CURRENCYCODE' => 'currency_code',
|
| 140 |
+
'SHIPPINGAMT' => 'shipping_amount',
|
| 141 |
+
'TAXAMT' => 'tax_amount',
|
| 142 |
+
'INITAMT' => 'init_amount',
|
| 143 |
+
'FAILEDINITAMTACTION' => 'init_may_fail',
|
| 144 |
+
'PROFILEID' => 'recurring_profile_id',
|
| 145 |
+
'PROFILESTATUS' => 'recurring_profile_status',
|
| 146 |
+
'STATUS' => 'status',
|
| 147 |
+
|
| 148 |
+
//Next two fields are used for Brazil only
|
| 149 |
+
'TAXID' => 'buyer_tax_id',
|
| 150 |
+
'TAXIDTYPE' => 'buyer_tax_id_type',
|
| 151 |
+
|
| 152 |
+
'BILLINGAGREEMENTID' => 'billing_agreement_id',
|
| 153 |
+
'REFERENCEID' => 'reference_id',
|
| 154 |
+
'BILLINGAGREEMENTSTATUS' => 'billing_agreement_status',
|
| 155 |
+
'BILLINGTYPE' => 'billing_type',
|
| 156 |
+
'SREET' => 'street',
|
| 157 |
+
'CITY' => 'city',
|
| 158 |
+
'STATE' => 'state',
|
| 159 |
+
'COUNTRYCODE' => 'countrycode',
|
| 160 |
+
'ZIP' => 'zip',
|
| 161 |
+
'PAYERBUSINESS' => 'payer_business',
|
| 162 |
+
);
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Filter callbacks for preparing internal amounts to NVP request
|
| 166 |
+
*
|
| 167 |
+
* @var array
|
| 168 |
+
*/
|
| 169 |
+
protected $_exportToRequestFilters = array(
|
| 170 |
+
'AMT' => '_filterAmount',
|
| 171 |
+
'ITEMAMT' => '_filterAmount',
|
| 172 |
+
'TRIALAMT' => '_filterAmount',
|
| 173 |
+
'SHIPPINGAMT' => '_filterAmount',
|
| 174 |
+
'TAXAMT' => '_filterAmount',
|
| 175 |
+
'INITAMT' => '_filterAmount',
|
| 176 |
+
'CREDITCARDTYPE' => '_filterCcType',
|
| 177 |
+
// 'PROFILESTARTDATE' => '_filterToPaypalDate',
|
| 178 |
+
'AUTOBILLAMT' => '_filterBillFailedLater',
|
| 179 |
+
'BILLINGPERIOD' => '_filterPeriodUnit',
|
| 180 |
+
'TRIALBILLINGPERIOD' => '_filterPeriodUnit',
|
| 181 |
+
'FAILEDINITAMTACTION' => '_filterInitialAmountMayFail',
|
| 182 |
+
'BILLINGAGREEMENTSTATUS' => '_filterBillingAgreementStatus',
|
| 183 |
+
'NOSHIPPING' => '_filterInt',
|
| 184 |
+
);
|
| 185 |
+
|
| 186 |
+
protected $_importFromRequestFilters = array(
|
| 187 |
+
'REDIRECTREQUIRED' => '_filterToBool',
|
| 188 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => '_filterToBool',
|
| 189 |
+
'PAYMENTSTATUS' => '_filterPaymentStatusFromNvpToInfo',
|
| 190 |
+
);
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* Request map for each API call
|
| 194 |
+
* @var array
|
| 195 |
+
*/
|
| 196 |
+
protected $_eachCallRequest = array('VERSION', 'USER', 'PWD', 'SIGNATURE', 'BUTTONSOURCE',);
|
| 197 |
+
|
| 198 |
+
/**
|
| 199 |
+
* SetExpressCheckout request/response map
|
| 200 |
+
* @var array
|
| 201 |
+
*/
|
| 202 |
+
protected $_setExpressCheckoutRequest = array(
|
| 203 |
+
'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'RETURNURL', 'CANCELURL', 'INVNUM', 'SOLUTIONTYPE', 'NOSHIPPING',
|
| 204 |
+
'GIROPAYCANCELURL', 'GIROPAYSUCCESSURL', 'BANKTXNPENDINGURL',
|
| 205 |
+
'PAGESTYLE', 'HDRIMG', 'HDRBORDERCOLOR', 'HDRBACKCOLOR', 'PAYFLOWCOLOR', 'LOCALECODE',
|
| 206 |
+
'BILLINGTYPE', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT', 'REQBILLINGADDRESS',
|
| 207 |
+
);
|
| 208 |
+
protected $_setExpressCheckoutResponse = array('TOKEN');
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* GetExpressCheckoutDetails request/response map
|
| 212 |
+
* @var array
|
| 213 |
+
*/
|
| 214 |
+
protected $_getExpressCheckoutDetailsRequest = array('TOKEN', 'SUBJECT',);
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* DoExpressCheckoutPayment request/response map
|
| 218 |
+
* @var array
|
| 219 |
+
*/
|
| 220 |
+
protected $_doExpressCheckoutPaymentRequest = array(
|
| 221 |
+
'TOKEN', 'PAYERID', 'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'IPADDRESS', 'BUTTONSOURCE', 'NOTIFYURL',
|
| 222 |
+
'RETURNFMFDETAILS', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT',
|
| 223 |
+
);
|
| 224 |
+
protected $_doExpressCheckoutPaymentResponse = array(
|
| 225 |
+
'TRANSACTIONID', 'AMT', 'PAYMENTSTATUS', 'PENDINGREASON', 'REDIRECTREQUIRED'
|
| 226 |
+
);
|
| 227 |
+
|
| 228 |
+
/**
|
| 229 |
+
* DoDirectPayment request/response map
|
| 230 |
+
* @var array
|
| 231 |
+
*/
|
| 232 |
+
protected $_doDirectPaymentRequest = array(
|
| 233 |
+
'PAYMENTACTION', 'IPADDRESS', 'RETURNFMFDETAILS',
|
| 234 |
+
'AMT', 'CURRENCYCODE', 'INVNUM', 'NOTIFYURL', 'EMAIL', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT',
|
| 235 |
+
'CREDITCARDTYPE', 'ACCT', 'EXPDATE', 'CVV2', 'STARTDATE', 'ISSUENUMBER',
|
| 236 |
+
'AUTHSTATUS3DS', 'MPIVENDOR3DS', 'CAVV', 'ECI3DS', 'XID',
|
| 237 |
+
);
|
| 238 |
+
protected $_doDirectPaymentResponse = array(
|
| 239 |
+
'TRANSACTIONID', 'AMT', 'AVSCODE', 'CVV2MATCH', 'VPAS', 'ECISUBMITTED3DS'
|
| 240 |
+
);
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* DoReauthorization request/response map
|
| 244 |
+
* @var array
|
| 245 |
+
*/
|
| 246 |
+
protected $_doReauthorizationRequest = array('AUTHORIZATIONID', 'AMT', 'CURRENCYCODE');
|
| 247 |
+
protected $_doReauthorizationResponse = array(
|
| 248 |
+
'AUTHORIZATIONID', 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY'
|
| 249 |
+
);
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
* DoCapture request/response map
|
| 253 |
+
* @var array
|
| 254 |
+
*/
|
| 255 |
+
protected $_doCaptureRequest = array('AUTHORIZATIONID', 'COMPLETETYPE', 'AMT', 'CURRENCYCODE', 'NOTE', 'INVNUM',);
|
| 256 |
+
protected $_doCaptureResponse = array('TRANSACTIONID', 'CURRENCYCODE', 'AMT', 'PAYMENTSTATUS', 'PENDINGREASON',);
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* DoAuthorization request/response map
|
| 261 |
+
* @var array
|
| 262 |
+
*/
|
| 263 |
+
protected $_doAuthorizationRequest = array('TRANSACTIONID', 'AMT', 'CURRENCYCODE');
|
| 264 |
+
protected $_doAuthorizationResponse = array('TRANSACTIONID', 'AMT');
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* DoVoid request map
|
| 268 |
+
* @var array
|
| 269 |
+
*/
|
| 270 |
+
protected $_doVoidRequest = array('AUTHORIZATIONID', 'NOTE',);
|
| 271 |
+
|
| 272 |
+
/**
|
| 273 |
+
* GetTransactionDetailsRequest
|
| 274 |
+
* @var array
|
| 275 |
+
*/
|
| 276 |
+
protected $_getTransactionDetailsRequest = array('TRANSACTIONID');
|
| 277 |
+
protected $_getTransactionDetailsResponse = array(
|
| 278 |
+
'PAYERID', 'FIRSTNAME', 'LASTNAME', 'TRANSACTIONID', 'PARENTTRANSACTIONID', 'CURRENCYCODE', 'AMT',
|
| 279 |
+
'PAYMENTSTATUS', 'PENDINGREASON',
|
| 280 |
+
);
|
| 281 |
+
|
| 282 |
+
/**
|
| 283 |
+
* RefundTransaction request/response map
|
| 284 |
+
* @var array
|
| 285 |
+
*/
|
| 286 |
+
protected $_refundTransactionRequest = array('TRANSACTIONID', 'REFUNDTYPE', 'CURRENCYCODE', 'NOTE',);
|
| 287 |
+
protected $_refundTransactionResponse = array('REFUNDTRANSACTIONID', 'GROSSREFUNDAMT',);
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* ManagePendingTransactionStatus request/response map
|
| 291 |
+
*/
|
| 292 |
+
protected $_managePendingTransactionStatusRequest = array('TRANSACTIONID', 'ACTION');
|
| 293 |
+
protected $_managePendingTransactionStatusResponse = array('TRANSACTIONID', 'STATUS');
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* GetPalDetails response map
|
| 297 |
+
* @var array
|
| 298 |
+
*/
|
| 299 |
+
protected $_getPalDetailsResponse = array('PAL');
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* CreateRecurringPaymentsProfile request/response map
|
| 303 |
+
*
|
| 304 |
+
* @var array
|
| 305 |
+
*/
|
| 306 |
+
protected $_createRecurringPaymentsProfileRequest = array(
|
| 307 |
+
'TOKEN', 'SUBSCRIBERNAME', 'PROFILESTARTDATE', 'PROFILEREFERENCE', 'DESC', 'MAXFAILEDPAYMENTS', 'AUTOBILLAMT',
|
| 308 |
+
'BILLINGPERIOD', 'BILLINGFREQUENCY', 'TOTALBILLINGCYCLES', 'AMT', 'TRIALBILLINGPERIOD', 'TRIALBILLINGFREQUENCY',
|
| 309 |
+
'TRIALTOTALBILLINGCYCLES', 'TRIALAMT', 'CURRENCYCODE', 'SHIPPINGAMT', 'TAXAMT', 'INITAMT', 'FAILEDINITAMTACTION'
|
| 310 |
+
);
|
| 311 |
+
protected $_createRecurringPaymentsProfileResponse = array(
|
| 312 |
+
'PROFILEID', 'PROFILESTATUS'
|
| 313 |
+
);
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* Request/response for ManageRecurringPaymentsProfileStatus map
|
| 317 |
+
*
|
| 318 |
+
* @var array
|
| 319 |
+
*/
|
| 320 |
+
protected $_manageRecurringPaymentsProfileStatusRequest = array('PROFILEID', 'ACTION');
|
| 321 |
+
// protected $_manageRecurringPaymentsProfileStatusResponse = array('PROFILEID');
|
| 322 |
+
|
| 323 |
+
/**
|
| 324 |
+
* Request/response for GetRecurringPaymentsProfileDetails
|
| 325 |
+
*
|
| 326 |
+
* @var array
|
| 327 |
+
*/
|
| 328 |
+
protected $_getRecurringPaymentsProfileDetailsRequest = array('PROFILEID');
|
| 329 |
+
protected $_getRecurringPaymentsProfileDetailsResponse = array('STATUS', /* TODO: lot of other stuff */);
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* Map for billing address import/export
|
| 333 |
+
* @var array
|
| 334 |
+
*/
|
| 335 |
+
protected $_billingAddressMap = array (
|
| 336 |
+
'BUSINESS' => 'company',
|
| 337 |
+
'NOTETEXT' => 'customer_notes',
|
| 338 |
+
'EMAIL' => 'email',
|
| 339 |
+
'FIRSTNAME' => 'firstname',
|
| 340 |
+
'LASTNAME' => 'lastname',
|
| 341 |
+
'MIDDLENAME' => 'middlename',
|
| 342 |
+
'SALUTATION' => 'prefix',
|
| 343 |
+
'SUFFIX' => 'suffix',
|
| 344 |
+
|
| 345 |
+
'COUNTRYCODE' => 'country_id', // iso-3166 two-character code
|
| 346 |
+
'STATE' => 'region',
|
| 347 |
+
'CITY' => 'city',
|
| 348 |
+
'STREET' => 'street',
|
| 349 |
+
'STREET2' => 'street2',
|
| 350 |
+
'ZIP' => 'postcode',
|
| 351 |
+
'PHONENUM' => 'telephone',
|
| 352 |
+
);
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* Map for billing address to do request (not response)
|
| 356 |
+
* Merging with $_billingAddressMap
|
| 357 |
+
*
|
| 358 |
+
* @var array
|
| 359 |
+
*/
|
| 360 |
+
protected $_billingAddressMapRequest = array ();
|
| 361 |
+
|
| 362 |
+
/**
|
| 363 |
+
* Map for shipping address import/export (extends billing address mapper)
|
| 364 |
+
* @var array
|
| 365 |
+
*/
|
| 366 |
+
protected $_shippingAddressMap = array(
|
| 367 |
+
'SHIPTOCOUNTRYCODE' => 'country_id',
|
| 368 |
+
'SHIPTOSTATE' => 'region',
|
| 369 |
+
'SHIPTOCITY' => 'city',
|
| 370 |
+
'SHIPTOSTREET' => 'street',
|
| 371 |
+
'SHIPTOSTREET2' => 'street2',
|
| 372 |
+
'SHIPTOZIP' => 'postcode',
|
| 373 |
+
'SHIPTOPHONENUM' => 'telephone',
|
| 374 |
+
// 'SHIPTONAME' will be treated manually in address import/export methods
|
| 375 |
+
);
|
| 376 |
+
|
| 377 |
+
/**
|
| 378 |
+
* Map for callback request
|
| 379 |
+
* @var array
|
| 380 |
+
*/
|
| 381 |
+
protected $_callbackRequestMap = array(
|
| 382 |
+
'SHIPTOCOUNTRY' => 'country_id',
|
| 383 |
+
'SHIPTOSTATE' => 'region',
|
| 384 |
+
'SHIPTOCITY' => 'city',
|
| 385 |
+
'SHIPTOSTREET' => 'street',
|
| 386 |
+
'SHIPTOSTREET2' => 'street2',
|
| 387 |
+
'SHIPTOZIP' => 'postcode'
|
| 388 |
+
);
|
| 389 |
+
|
| 390 |
+
/**
|
| 391 |
+
* Payment information response specifically to be collected after some requests
|
| 392 |
+
* @var array
|
| 393 |
+
*/
|
| 394 |
+
protected $_paymentInformationResponse = array(
|
| 395 |
+
'PAYERID', 'PAYERSTATUS', 'CORRELATIONID', 'ADDRESSID', 'ADDRESSSTATUS',
|
| 396 |
+
'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', 'SHIPPINGOPTIONNAME', 'TAXID', 'TAXIDTYPE'
|
| 397 |
+
);
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
* Line items export mapping settings
|
| 401 |
+
* @var array
|
| 402 |
+
*/
|
| 403 |
+
protected $_lineItemTotalExportMap = array(
|
| 404 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_SUBTOTAL => 'ITEMAMT',
|
| 405 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_TAX => 'TAXAMT',
|
| 406 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_SHIPPING => 'SHIPPINGAMT',
|
| 407 |
+
);
|
| 408 |
+
protected $_lineItemExportItemsFormat = array(
|
| 409 |
+
'id' => 'L_NUMBER%d',
|
| 410 |
+
'name' => 'L_NAME%d',
|
| 411 |
+
'qty' => 'L_QTY%d',
|
| 412 |
+
'amount' => 'L_AMT%d',
|
| 413 |
+
);
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* Shipping options export to request mapping settings
|
| 417 |
+
* @var array
|
| 418 |
+
*/
|
| 419 |
+
protected $_shippingOptionsExportItemsFormat = array(
|
| 420 |
+
'is_default' => 'L_SHIPPINGOPTIONISDEFAULT%d',
|
| 421 |
+
'amount' => 'L_SHIPPINGOPTIONAMOUNT%d',
|
| 422 |
+
'code' => 'L_SHIPPINGOPTIONNAME%d',
|
| 423 |
+
'name' => 'L_SHIPPINGOPTIONLABEL%d',
|
| 424 |
+
'tax_amount' => 'L_TAXAMT%d',
|
| 425 |
+
);
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* init Billing Agreement request/response map
|
| 429 |
+
* @var array
|
| 430 |
+
*/
|
| 431 |
+
protected $_customerBillingAgreementRequest = array('RETURNURL', 'CANCELURL', 'BILLINGTYPE');
|
| 432 |
+
protected $_customerBillingAgreementResponse = array('TOKEN');
|
| 433 |
+
|
| 434 |
+
/**
|
| 435 |
+
* Billing Agreement details request/response map
|
| 436 |
+
* @var array
|
| 437 |
+
*/
|
| 438 |
+
protected $_billingAgreementCustomerDetailsRequest = array('TOKEN');
|
| 439 |
+
protected $_billingAgreementCustomerDetailsResponse = array('EMAIL', 'PAYERID', 'PAYERSTATUS', 'SHIPTOCOUNTRYCODE',
|
| 440 |
+
'PAYERBUSINESS'
|
| 441 |
+
);
|
| 442 |
+
|
| 443 |
+
/**
|
| 444 |
+
* Create Billing Agreement request/response map
|
| 445 |
+
* @var array
|
| 446 |
+
*/
|
| 447 |
+
protected $_createBillingAgreementRequest = array('TOKEN');
|
| 448 |
+
protected $_createBillingAgreementResponse = array('BILLINGAGREEMENTID');
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* Update Billing Agreement request/response map
|
| 452 |
+
* @var array
|
| 453 |
+
*/
|
| 454 |
+
protected $_updateBillingAgreementRequest = array(
|
| 455 |
+
'REFERENCEID', 'BILLINGAGREEMENTDESCRIPTION', 'BILLINGAGREEMENTSTATUS', 'BILLINGAGREEMENTCUSTOM'
|
| 456 |
+
);
|
| 457 |
+
protected $_updateBillingAgreementResponse = array(
|
| 458 |
+
'REFERENCEID', 'BILLINGAGREEMENTDESCRIPTION', 'BILLINGAGREEMENTSTATUS', 'BILLINGAGREEMENTCUSTOM'
|
| 459 |
+
);
|
| 460 |
+
|
| 461 |
+
/**
|
| 462 |
+
* Do Reference Transaction request/response map
|
| 463 |
+
*
|
| 464 |
+
* @var array
|
| 465 |
+
*/
|
| 466 |
+
protected $_doReferenceTransactionRequest = array('REFERENCEID', 'PAYMENTACTION', 'AMT', 'ITEMAMT', 'SHIPPINGAMT',
|
| 467 |
+
'TAXAMT', 'INVNUM', 'NOTIFYURL'
|
| 468 |
+
);
|
| 469 |
+
|
| 470 |
+
protected $_doReferenceTransactionResponse = array('BILLINGAGREEMENTID', 'TRANSACTIONID');
|
| 471 |
+
|
| 472 |
+
/**
|
| 473 |
+
* Fields that should be replaced in debug with '***'
|
| 474 |
+
*
|
| 475 |
+
* @var array
|
| 476 |
+
*/
|
| 477 |
+
protected $_debugReplacePrivateDataKeys = array(
|
| 478 |
+
|
| 479 |
+
'ACCT', 'EXPDATE', 'CVV2', 'CARDISSUE', 'CARDSTART', 'CREDITCARDTYPE', 'USER', 'PWD', 'SIGNATURE'
|
| 480 |
+
|
| 481 |
+
);
|
| 482 |
+
|
| 483 |
+
/**
|
| 484 |
+
* Map of credit card types supported by this API
|
| 485 |
+
* @var array
|
| 486 |
+
*/
|
| 487 |
+
protected $_supportedCcTypes = array(
|
| 488 |
+
'VI' => 'Visa', 'MC' => 'MasterCard', 'DI' => 'Discover', 'AE' => 'Amex', 'SM' => 'Maestro', 'SO' => 'Solo');
|
| 489 |
+
|
| 490 |
+
/**
|
| 491 |
+
* Required fields in the response
|
| 492 |
+
*
|
| 493 |
+
* @var array
|
| 494 |
+
*/
|
| 495 |
+
protected $_requiredResponseParams = array(
|
| 496 |
+
self::DO_DIRECT_PAYMENT => array('ACK', 'CORRELATIONID', 'AMT')
|
| 497 |
+
);
|
| 498 |
+
|
| 499 |
+
/**
|
| 500 |
+
* Warning codes recollected after each API call
|
| 501 |
+
*
|
| 502 |
+
* @var array
|
| 503 |
+
*/
|
| 504 |
+
protected $_callWarnings = array();
|
| 505 |
+
|
| 506 |
+
/**
|
| 507 |
+
* Error codes recollected after each API call
|
| 508 |
+
*
|
| 509 |
+
* @var array
|
| 510 |
+
*/
|
| 511 |
+
protected $_callErrors = array();
|
| 512 |
+
|
| 513 |
+
/**
|
| 514 |
+
* Whether to return raw response information after each call
|
| 515 |
+
*
|
| 516 |
+
* @var bool
|
| 517 |
+
*/
|
| 518 |
+
protected $_rawResponseNeeded = false;
|
| 519 |
+
|
| 520 |
+
/**
|
| 521 |
+
* API endpoint getter
|
| 522 |
+
*
|
| 523 |
+
* @return string
|
| 524 |
+
*/
|
| 525 |
+
public function getApiEndpoint()
|
| 526 |
+
{
|
| 527 |
+
$url = $this->getUseCertAuthentication() ? 'https://api%s.paypal.com/nvp' : 'https://api-3t%s.paypal.com/nvp';
|
| 528 |
+
return sprintf($url, $this->_config->sandboxFlag ? '.sandbox' : '');
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
/**
|
| 532 |
+
* Return Paypal Api version
|
| 533 |
+
*
|
| 534 |
+
* @return string
|
| 535 |
+
*/
|
| 536 |
+
public function getVersion()
|
| 537 |
+
{
|
| 538 |
+
return '72.0';
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* Retrieve billing agreement type
|
| 543 |
+
*
|
| 544 |
+
* @return string
|
| 545 |
+
*/
|
| 546 |
+
public function getBillingAgreementType()
|
| 547 |
+
{
|
| 548 |
+
return 'MerchantInitiatedBilling';
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
/**
|
| 552 |
+
* SetExpressCheckout call
|
| 553 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
|
| 554 |
+
* TODO: put together style and giropay settings
|
| 555 |
+
*/
|
| 556 |
+
public function callSetExpressCheckout()
|
| 557 |
+
{
|
| 558 |
+
$this->_prepareExpressCheckoutCallRequest($this->_setExpressCheckoutRequest);
|
| 559 |
+
$request = $this->_exportToRequest($this->_setExpressCheckoutRequest);
|
| 560 |
+
$this->_exportLineItems($request);
|
| 561 |
+
|
| 562 |
+
// import/suppress shipping address, if any
|
| 563 |
+
$options = $this->getShippingOptions();
|
| 564 |
+
if ($this->getAddress()) {
|
| 565 |
+
$request = $this->_importAddresses($request);
|
| 566 |
+
$request['ADDROVERRIDE'] = 1;
|
| 567 |
+
} elseif ($options && (count($options) <= 10)) { // doesn't support more than 10 shipping options
|
| 568 |
+
$request['CALLBACK'] = $this->getShippingOptionsCallbackUrl();
|
| 569 |
+
$request['CALLBACKTIMEOUT'] = 6; // max value
|
| 570 |
+
$request['MAXAMT'] = $request['AMT'] + 999.00; // it is impossible to calculate max amount
|
| 571 |
+
$this->_exportShippingOptions($request);
|
| 572 |
+
}
|
| 573 |
+
$request['BUTTONSOURCE'] = "MagentoMXExtension_SI_MagentoCE";
|
| 574 |
+
// add recurring profiles information
|
| 575 |
+
$i = 0;
|
| 576 |
+
foreach ($this->_recurringPaymentProfiles as $profile) {
|
| 577 |
+
$request["L_BILLINGTYPE{$i}"] = 'RecurringPayments';
|
| 578 |
+
$request["L_BILLINGAGREEMENTDESCRIPTION{$i}"] = $profile->getScheduleDescription();
|
| 579 |
+
$i++;
|
| 580 |
+
}
|
| 581 |
+
$response = $this->call(self::SET_EXPRESS_CHECKOUT, $request);
|
| 582 |
+
$this->_importFromResponse($this->_setExpressCheckoutResponse, $response);
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
/**
|
| 586 |
+
* GetExpressCheckoutDetails call
|
| 587 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails
|
| 588 |
+
*/
|
| 589 |
+
function callGetExpressCheckoutDetails()
|
| 590 |
+
{
|
| 591 |
+
$this->_prepareExpressCheckoutCallRequest($this->_getExpressCheckoutDetailsRequest);
|
| 592 |
+
$request = $this->_exportToRequest($this->_getExpressCheckoutDetailsRequest);
|
| 593 |
+
$response = $this->call(self::GET_EXPRESS_CHECKOUT_DETAILS, $request);
|
| 594 |
+
$this->_importFromResponse($this->_paymentInformationResponse, $response);
|
| 595 |
+
$this->_exportAddressses($response);
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
/**
|
| 599 |
+
* DoExpressCheckout call
|
| 600 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment
|
| 601 |
+
*/
|
| 602 |
+
public function callDoExpressCheckoutPayment()
|
| 603 |
+
{
|
| 604 |
+
$this->_prepareExpressCheckoutCallRequest($this->_doExpressCheckoutPaymentRequest);
|
| 605 |
+
$request = $this->_exportToRequest($this->_doExpressCheckoutPaymentRequest);
|
| 606 |
+
$this->_exportLineItems($request);
|
| 607 |
+
|
| 608 |
+
if ($this->getAddress()) {
|
| 609 |
+
$request = $this->_importAddresses($request);
|
| 610 |
+
$request['ADDROVERRIDE'] = 1;
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
$response = $this->call(self::DO_EXPRESS_CHECKOUT_PAYMENT, $request);
|
| 614 |
+
$this->_importFromResponse($this->_paymentInformationResponse, $response);
|
| 615 |
+
$this->_importFromResponse($this->_doExpressCheckoutPaymentResponse, $response);
|
| 616 |
+
$this->_importFromResponse($this->_createBillingAgreementResponse, $response);
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
/**
|
| 620 |
+
* Process a credit card payment
|
| 621 |
+
*/
|
| 622 |
+
public function callDoDirectPayment()
|
| 623 |
+
{
|
| 624 |
+
$request = $this->_exportToRequest($this->_doDirectPaymentRequest);
|
| 625 |
+
$this->_exportLineItems($request);
|
| 626 |
+
if ($this->getAddress()) {
|
| 627 |
+
$request = $this->_importAddresses($request);
|
| 628 |
+
}
|
| 629 |
+
$response = $this->call(self::DO_DIRECT_PAYMENT, $request);
|
| 630 |
+
$this->_importFromResponse($this->_doDirectPaymentResponse, $response);
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
/**
|
| 634 |
+
* Do Reference Transaction call
|
| 635 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoReferenceTransaction
|
| 636 |
+
*/
|
| 637 |
+
public function callDoReferenceTransaction()
|
| 638 |
+
{
|
| 639 |
+
$request = $this->_exportToRequest($this->_doReferenceTransactionRequest);
|
| 640 |
+
$this->_exportLineItems($request);
|
| 641 |
+
$response = $this->call('DoReferenceTransaction', $request);
|
| 642 |
+
$this->_importFromResponse($this->_doReferenceTransactionResponse, $response);
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
/**
|
| 646 |
+
* Check whether the last call was returned with fraud warning
|
| 647 |
+
*
|
| 648 |
+
* @return bool
|
| 649 |
+
*/
|
| 650 |
+
public function getIsFraudDetected()
|
| 651 |
+
{
|
| 652 |
+
return in_array(11610, $this->_callWarnings);
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* Made additional request to paypal to get autharization id
|
| 657 |
+
*/
|
| 658 |
+
public function callDoReauthorization()
|
| 659 |
+
{
|
| 660 |
+
$request = $this->_export($this->_doReauthorizationRequest);
|
| 661 |
+
$response = $this->call('DoReauthorization', $request);
|
| 662 |
+
$this->_import($response, $this->_doReauthorizationResponse);
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
/**
|
| 666 |
+
* DoCapture call
|
| 667 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoCapture
|
| 668 |
+
*/
|
| 669 |
+
public function callDoCapture()
|
| 670 |
+
{
|
| 671 |
+
$this->setCompleteType($this->_getCaptureCompleteType());
|
| 672 |
+
$request = $this->_exportToRequest($this->_doCaptureRequest);
|
| 673 |
+
$response = $this->call(self::DO_CAPTURE, $request);
|
| 674 |
+
$this->_importFromResponse($this->_paymentInformationResponse, $response);
|
| 675 |
+
$this->_importFromResponse($this->_doCaptureResponse, $response);
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
/**
|
| 679 |
+
* DoAuthorization call
|
| 680 |
+
*
|
| 681 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoAuthorization
|
| 682 |
+
* @return Ebcomm_PaypalMx_Model_Api_Nvp
|
| 683 |
+
*/
|
| 684 |
+
public function callDoAuthorization()
|
| 685 |
+
{
|
| 686 |
+
$request = $this->_exportToRequest($this->_doAuthorizationRequest);
|
| 687 |
+
$response = $this->call(self::DO_AUTHORIZATION, $request);
|
| 688 |
+
$this->_importFromResponse($this->_paymentInformationResponse, $response);
|
| 689 |
+
$this->_importFromResponse($this->_doAuthorizationResponse, $response);
|
| 690 |
+
|
| 691 |
+
return $this;
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
|
| 695 |
+
/**
|
| 696 |
+
* DoVoid call
|
| 697 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoVoid
|
| 698 |
+
*/
|
| 699 |
+
public function callDoVoid()
|
| 700 |
+
{
|
| 701 |
+
$request = $this->_exportToRequest($this->_doVoidRequest);
|
| 702 |
+
$this->call(self::DO_VOID, $request);
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
/**
|
| 706 |
+
* GetTransactionDetails
|
| 707 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails
|
| 708 |
+
*/
|
| 709 |
+
public function callGetTransactionDetails()
|
| 710 |
+
{
|
| 711 |
+
$request = $this->_exportToRequest($this->_getTransactionDetailsRequest);
|
| 712 |
+
$response = $this->call('GetTransactionDetails', $request);
|
| 713 |
+
$this->_importFromResponse($this->_getTransactionDetailsResponse, $response);
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
/**
|
| 717 |
+
* RefundTransaction call
|
| 718 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_RefundTransaction
|
| 719 |
+
*/
|
| 720 |
+
public function callRefundTransaction()
|
| 721 |
+
{
|
| 722 |
+
$request = $this->_exportToRequest($this->_refundTransactionRequest);
|
| 723 |
+
if ($this->getRefundType() === Ebcomm_PaypalMx_Model_Config::REFUND_TYPE_PARTIAL) {
|
| 724 |
+
$request['AMT'] = $this->getAmount();
|
| 725 |
+
}
|
| 726 |
+
$response = $this->call(self::REFUND_TRANSACTION, $request);
|
| 727 |
+
$this->_importFromResponse($this->_refundTransactionResponse, $response);
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
/**
|
| 731 |
+
* ManagePendingTransactionStatus
|
| 732 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_ManagePendingTransactionStatus
|
| 733 |
+
*/
|
| 734 |
+
public function callManagePendingTransactionStatus()
|
| 735 |
+
{
|
| 736 |
+
$request = $this->_exportToRequest($this->_managePendingTransactionStatusRequest);
|
| 737 |
+
if (isset($request['ACTION'])) {
|
| 738 |
+
$request['ACTION'] = $this->_filterPaymentReviewAction($request['ACTION']);
|
| 739 |
+
}
|
| 740 |
+
$response = $this->call('ManagePendingTransactionStatus', $request);
|
| 741 |
+
$this->_importFromResponse($this->_managePendingTransactionStatusResponse, $response);
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
/**
|
| 745 |
+
* getPalDetails call
|
| 746 |
+
* @link https://www.x.com/docs/DOC-1300
|
| 747 |
+
* @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration
|
| 748 |
+
*/
|
| 749 |
+
public function callGetPalDetails()
|
| 750 |
+
{
|
| 751 |
+
$response = $this->call('getPalDetails', array());
|
| 752 |
+
$this->_importFromResponse($this->_getPalDetailsResponse, $response);
|
| 753 |
+
}
|
| 754 |
+
|
| 755 |
+
/**
|
| 756 |
+
* Set Customer BillingA greement call
|
| 757 |
+
*
|
| 758 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetCustomerBillingAgreement
|
| 759 |
+
*/
|
| 760 |
+
public function callSetCustomerBillingAgreement()
|
| 761 |
+
{
|
| 762 |
+
$request = $this->_exportToRequest($this->_customerBillingAgreementRequest);
|
| 763 |
+
$response = $this->call('SetCustomerBillingAgreement', $request);
|
| 764 |
+
$this->_importFromResponse($this->_customerBillingAgreementResponse, $response);
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
/**
|
| 768 |
+
* Get Billing Agreement Customer Details call
|
| 769 |
+
*
|
| 770 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetBillingAgreementCustomerDetails
|
| 771 |
+
*/
|
| 772 |
+
public function callGetBillingAgreementCustomerDetails()
|
| 773 |
+
{
|
| 774 |
+
$request = $this->_exportToRequest($this->_billingAgreementCustomerDetailsRequest);
|
| 775 |
+
$response = $this->call('GetBillingAgreementCustomerDetails', $request);
|
| 776 |
+
$this->_importFromResponse($this->_billingAgreementCustomerDetailsResponse, $response);
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
/**
|
| 780 |
+
* Create Billing Agreement call
|
| 781 |
+
*
|
| 782 |
+
*/
|
| 783 |
+
public function callCreateBillingAgreement()
|
| 784 |
+
{
|
| 785 |
+
$request = $this->_exportToRequest($this->_createBillingAgreementRequest);
|
| 786 |
+
$response = $this->call('CreateBillingAgreement', $request);
|
| 787 |
+
$this->_importFromResponse($this->_createBillingAgreementResponse, $response);
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
/**
|
| 791 |
+
* Billing Agreement Update call
|
| 792 |
+
*
|
| 793 |
+
*/
|
| 794 |
+
public function callUpdateBillingAgreement()
|
| 795 |
+
{
|
| 796 |
+
$request = $this->_exportToRequest($this->_updateBillingAgreementRequest);
|
| 797 |
+
try {
|
| 798 |
+
$response = $this->call('BillAgreementUpdate', $request);
|
| 799 |
+
} catch (Mage_Core_Exception $e) {
|
| 800 |
+
if (in_array(10201, $this->_callErrors)) {
|
| 801 |
+
$this->setIsBillingAgreementAlreadyCancelled(true);
|
| 802 |
+
}
|
| 803 |
+
throw $e;
|
| 804 |
+
}
|
| 805 |
+
$this->_importFromResponse($this->_updateBillingAgreementResponse, $response);
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
/**
|
| 809 |
+
* CreateRecurringPaymentsProfile call
|
| 810 |
+
*/
|
| 811 |
+
public function callCreateRecurringPaymentsProfile()
|
| 812 |
+
{
|
| 813 |
+
$request = $this->_exportToRequest($this->_createRecurringPaymentsProfileRequest);
|
| 814 |
+
$response = $this->call('CreateRecurringPaymentsProfile', $request);
|
| 815 |
+
$this->_importFromResponse($this->_createRecurringPaymentsProfileResponse, $response);
|
| 816 |
+
$this->_analyzeRecurringProfileStatus($this->getRecurringProfileStatus(), $this);
|
| 817 |
+
}
|
| 818 |
+
|
| 819 |
+
/**
|
| 820 |
+
* ManageRecurringPaymentsProfileStatus call
|
| 821 |
+
*/
|
| 822 |
+
public function callManageRecurringPaymentsProfileStatus()
|
| 823 |
+
{
|
| 824 |
+
$request = $this->_exportToRequest($this->_manageRecurringPaymentsProfileStatusRequest);
|
| 825 |
+
if (isset($request['ACTION'])) {
|
| 826 |
+
$request['ACTION'] = $this->_filterRecurringProfileActionToNvp($request['ACTION']);
|
| 827 |
+
}
|
| 828 |
+
try {
|
| 829 |
+
$response = $this->call('ManageRecurringPaymentsProfileStatus', $request);
|
| 830 |
+
} catch (Mage_Core_Exception $e) {
|
| 831 |
+
if ((in_array(11556, $this->_callErrors) && 'Cancel' === $request['ACTION'])
|
| 832 |
+
|| (in_array(11557, $this->_callErrors) && 'Suspend' === $request['ACTION'])
|
| 833 |
+
|| (in_array(11558, $this->_callErrors) && 'Reactivate' === $request['ACTION'])
|
| 834 |
+
) {
|
| 835 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Unable to change status. Current status is not correspond to real status.'));
|
| 836 |
+
}
|
| 837 |
+
throw $e;
|
| 838 |
+
}
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
/**
|
| 842 |
+
* GetRecurringPaymentsProfileDetails call
|
| 843 |
+
*/
|
| 844 |
+
public function callGetRecurringPaymentsProfileDetails(Varien_Object $result)
|
| 845 |
+
{
|
| 846 |
+
$request = $this->_exportToRequest($this->_getRecurringPaymentsProfileDetailsRequest);
|
| 847 |
+
$response = $this->call('GetRecurringPaymentsProfileDetails', $request);
|
| 848 |
+
$this->_importFromResponse($this->_getRecurringPaymentsProfileDetailsResponse, $response);
|
| 849 |
+
$this->_analyzeRecurringProfileStatus($this->getStatus(), $result);
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
/**
|
| 853 |
+
* Import callback request array into $this public data
|
| 854 |
+
*
|
| 855 |
+
* @param array $request
|
| 856 |
+
* @return Varien_Object
|
| 857 |
+
*/
|
| 858 |
+
public function prepareShippingOptionsCallbackAddress(array $request)
|
| 859 |
+
{
|
| 860 |
+
$address = new Varien_Object();
|
| 861 |
+
Varien_Object_Mapper::accumulateByMap($request, $address, $this->_callbackRequestMap);
|
| 862 |
+
$address->setExportedKeys(array_values($this->_callbackRequestMap));
|
| 863 |
+
$this->_applyStreetAndRegionWorkarounds($address);
|
| 864 |
+
return $address;
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
/**
|
| 868 |
+
* Prepare response for shipping options callback
|
| 869 |
+
*
|
| 870 |
+
* @return string
|
| 871 |
+
*/
|
| 872 |
+
public function formatShippingOptionsCallback()
|
| 873 |
+
{
|
| 874 |
+
$response = array();
|
| 875 |
+
if (!$this->_exportShippingOptions($response)) {
|
| 876 |
+
$response['NO_SHIPPING_OPTION_DETAILS'] = '1';
|
| 877 |
+
}
|
| 878 |
+
$response = $this->_addMethodToRequest(self::CALLBACK_RESPONSE, $response);
|
| 879 |
+
return $this->_buildQuery($response);
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
/**
|
| 883 |
+
* Add method to request array
|
| 884 |
+
*
|
| 885 |
+
* @param string $methodName
|
| 886 |
+
* @param array $request
|
| 887 |
+
* @return array
|
| 888 |
+
*/
|
| 889 |
+
protected function _addMethodToRequest($methodName, $request)
|
| 890 |
+
{
|
| 891 |
+
$request['METHOD'] = $methodName;
|
| 892 |
+
return $request;
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
/**
|
| 896 |
+
* Do the API call
|
| 897 |
+
*
|
| 898 |
+
* @param string $methodName
|
| 899 |
+
* @param array $request
|
| 900 |
+
* @return array
|
| 901 |
+
* @throws Mage_Core_Exception
|
| 902 |
+
*/
|
| 903 |
+
public function call($methodName, array $request)
|
| 904 |
+
{
|
| 905 |
+
$request = $this->_addMethodToRequest($methodName, $request);
|
| 906 |
+
$eachCallRequest = $this->_prepareEachCallRequest($methodName);
|
| 907 |
+
if ($this->getUseCertAuthentication()) {
|
| 908 |
+
if ($key = array_search('SIGNATURE', $eachCallRequest)) {
|
| 909 |
+
unset($eachCallRequest[$key]);
|
| 910 |
+
}
|
| 911 |
+
}
|
| 912 |
+
$request = $this->_exportToRequest($eachCallRequest, $request);
|
| 913 |
+
$debugData = array('url' => $this->getApiEndpoint(), $methodName => $request);
|
| 914 |
+
Mage::log($request);
|
| 915 |
+
try {
|
| 916 |
+
$http = new Varien_Http_Adapter_Curl();
|
| 917 |
+
$config = array(
|
| 918 |
+
'timeout' => 30,
|
| 919 |
+
'verifypeer' => $this->_config->verifyPeer
|
| 920 |
+
);
|
| 921 |
+
|
| 922 |
+
if ($this->getUseProxy()) {
|
| 923 |
+
$config['proxy'] = $this->getProxyHost(). ':' . $this->getProxyPort();
|
| 924 |
+
}
|
| 925 |
+
if ($this->getUseCertAuthentication()) {
|
| 926 |
+
$config['ssl_cert'] = $this->getApiCertificate();
|
| 927 |
+
}
|
| 928 |
+
$http->setConfig($config);
|
| 929 |
+
$http->write(Zend_Http_Client::POST, $this->getApiEndpoint(), '1.1', array(), $this->_buildQuery($request));
|
| 930 |
+
$response = $http->read();
|
| 931 |
+
} catch (Exception $e) {
|
| 932 |
+
$debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
| 933 |
+
$this->_debug($debugData);
|
| 934 |
+
throw $e;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
$response = preg_split('/^\r?$/m', $response, 2);
|
| 938 |
+
$response = trim($response[1]);
|
| 939 |
+
$response = $this->_deformatNVP($response);
|
| 940 |
+
|
| 941 |
+
$debugData['response'] = $response;
|
| 942 |
+
$this->_debug($debugData);
|
| 943 |
+
|
| 944 |
+
// handle transport error
|
| 945 |
+
if ($http->getErrno()) {
|
| 946 |
+
Mage::logException(new Exception(
|
| 947 |
+
sprintf('PayPal NVP CURL connection error #%s: %s', $http->getErrno(), $http->getError())
|
| 948 |
+
));
|
| 949 |
+
$http->close();
|
| 950 |
+
|
| 951 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Unable to communicate with the PayPal gateway.'));
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
// cUrl resource must be closed after checking it for errors
|
| 955 |
+
$http->close();
|
| 956 |
+
|
| 957 |
+
if (!$this->_validateResponse($methodName, $response)) {
|
| 958 |
+
Mage::logException(new Exception(
|
| 959 |
+
Mage::helper('paypalmx')->__("PayPal response hasn't required fields.")
|
| 960 |
+
));
|
| 961 |
+
Mage::throwException(Mage::helper('paypalmx')->__('There was an error processing your order. Please contact us or try again later.'));
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
$this->_callErrors = array();
|
| 965 |
+
if ($this->_isCallSuccessful($response)) {
|
| 966 |
+
if ($this->_rawResponseNeeded) {
|
| 967 |
+
$this->setRawSuccessResponseData($response);
|
| 968 |
+
}
|
| 969 |
+
return $response;
|
| 970 |
+
}
|
| 971 |
+
$this->_handleCallErrors($response);
|
| 972 |
+
return $response;
|
| 973 |
+
}
|
| 974 |
+
|
| 975 |
+
/**
|
| 976 |
+
* Setter for 'raw response needed' flag
|
| 977 |
+
*
|
| 978 |
+
* @param bool $flag
|
| 979 |
+
* @return Ebcomm_PaypalMx_Model_Api_Nvp
|
| 980 |
+
*/
|
| 981 |
+
public function setRawResponseNeeded($flag)
|
| 982 |
+
{
|
| 983 |
+
$this->_rawResponseNeeded = $flag;
|
| 984 |
+
return $this;
|
| 985 |
+
}
|
| 986 |
+
|
| 987 |
+
/**
|
| 988 |
+
* Handle logical errors
|
| 989 |
+
*
|
| 990 |
+
* @param array
|
| 991 |
+
*/
|
| 992 |
+
protected function _handleCallErrors($response)
|
| 993 |
+
{
|
| 994 |
+
$errors = array();
|
| 995 |
+
for ($i = 0; isset($response["L_ERRORCODE{$i}"]); $i++) {
|
| 996 |
+
$longMessage = isset($response["L_LONGMESSAGE{$i}"])
|
| 997 |
+
? preg_replace('/\.$/', '', $response["L_LONGMESSAGE{$i}"]) : '';
|
| 998 |
+
$shortMessage = preg_replace('/\.$/', '', $response["L_SHORTMESSAGE{$i}"]);
|
| 999 |
+
$errors[] = $longMessage
|
| 1000 |
+
? sprintf('%s (#%s: %s).', $longMessage, $response["L_ERRORCODE{$i}"], $shortMessage)
|
| 1001 |
+
: sprintf('#%s: %s.', $response["L_ERRORCODE{$i}"], $shortMessage);
|
| 1002 |
+
$this->_callErrors[] = $response["L_ERRORCODE{$i}"];
|
| 1003 |
+
}
|
| 1004 |
+
if ($errors) {
|
| 1005 |
+
$errors = implode(' ', $errors);
|
| 1006 |
+
$e = Mage::exception('Mage_Core', sprintf('PayPal NVP gateway errors: %s Correlation ID: %s. Version: %s.',
|
| 1007 |
+
$errors,
|
| 1008 |
+
isset($response['CORRELATIONID']) ? $response['CORRELATIONID'] : '',
|
| 1009 |
+
isset($response['VERSION']) ? $response['VERSION'] : ''
|
| 1010 |
+
));
|
| 1011 |
+
Mage::logException($e);
|
| 1012 |
+
$e->setMessage(Mage::helper('paypalmx')->__('PayPal gateway has rejected request. %s', $errors));
|
| 1013 |
+
throw $e;
|
| 1014 |
+
}
|
| 1015 |
+
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
/**
|
| 1019 |
+
* Catch success calls and collect warnings
|
| 1020 |
+
*
|
| 1021 |
+
* @param array
|
| 1022 |
+
* @return bool| success flag
|
| 1023 |
+
*/
|
| 1024 |
+
protected function _isCallSuccessful($response)
|
| 1025 |
+
{
|
| 1026 |
+
if (!isset($response['ACK'])) {
|
| 1027 |
+
return false;
|
| 1028 |
+
}
|
| 1029 |
+
|
| 1030 |
+
$ack = strtoupper($response['ACK']);
|
| 1031 |
+
$this->_callWarnings = array();
|
| 1032 |
+
if ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING') {
|
| 1033 |
+
// collect warnings
|
| 1034 |
+
if ($ack == 'SUCCESSWITHWARNING') {
|
| 1035 |
+
for ($i = 0; isset($response["L_ERRORCODE{$i}"]); $i++) {
|
| 1036 |
+
$this->_callWarnings[] = $response["L_ERRORCODE{$i}"];
|
| 1037 |
+
}
|
| 1038 |
+
}
|
| 1039 |
+
return true;
|
| 1040 |
+
}
|
| 1041 |
+
return false;
|
| 1042 |
+
}
|
| 1043 |
+
|
| 1044 |
+
/**
|
| 1045 |
+
* Validate response array.
|
| 1046 |
+
*
|
| 1047 |
+
* @param string $method
|
| 1048 |
+
* @param array $response
|
| 1049 |
+
* @return bool
|
| 1050 |
+
*/
|
| 1051 |
+
protected function _validateResponse($method, $response)
|
| 1052 |
+
{
|
| 1053 |
+
if (isset($this->_requiredResponseParams[$method])) {
|
| 1054 |
+
foreach ($this->_requiredResponseParams[$method] as $param) {
|
| 1055 |
+
if (!isset($response[$param])) {
|
| 1056 |
+
return false;
|
| 1057 |
+
}
|
| 1058 |
+
}
|
| 1059 |
+
}
|
| 1060 |
+
return true;
|
| 1061 |
+
}
|
| 1062 |
+
|
| 1063 |
+
/**
|
| 1064 |
+
* Parse an NVP response string into an associative array
|
| 1065 |
+
* @param string $nvpstr
|
| 1066 |
+
* @return array
|
| 1067 |
+
*/
|
| 1068 |
+
protected function _deformatNVP($nvpstr)
|
| 1069 |
+
{
|
| 1070 |
+
$intial=0;
|
| 1071 |
+
$nvpArray = array();
|
| 1072 |
+
|
| 1073 |
+
$nvpstr = strpos($nvpstr, "\r\n\r\n")!==false ? substr($nvpstr, strpos($nvpstr, "\r\n\r\n")+4) : $nvpstr;
|
| 1074 |
+
|
| 1075 |
+
while(strlen($nvpstr)) {
|
| 1076 |
+
//postion of Key
|
| 1077 |
+
$keypos= strpos($nvpstr,'=');
|
| 1078 |
+
//position of value
|
| 1079 |
+
$valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);
|
| 1080 |
+
|
| 1081 |
+
/*getting the Key and Value values and storing in a Associative Array*/
|
| 1082 |
+
$keyval=substr($nvpstr,$intial,$keypos);
|
| 1083 |
+
$valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
|
| 1084 |
+
//decoding the respose
|
| 1085 |
+
$nvpArray[urldecode($keyval)] =urldecode( $valval);
|
| 1086 |
+
$nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
|
| 1087 |
+
}
|
| 1088 |
+
return $nvpArray;
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
/**
|
| 1092 |
+
* NVP doesn't support passing discount total as a separate amount - add it as a line item
|
| 1093 |
+
*
|
| 1094 |
+
* @param array $request
|
| 1095 |
+
* @param int $i
|
| 1096 |
+
* @return true|null
|
| 1097 |
+
*/
|
| 1098 |
+
protected function _exportLineItems(array &$request, $i = 0)
|
| 1099 |
+
{
|
| 1100 |
+
if (!$this->_cart) {
|
| 1101 |
+
return;
|
| 1102 |
+
}
|
| 1103 |
+
$this->_cart->isDiscountAsItem(true);
|
| 1104 |
+
return parent::_exportLineItems($request, $i);
|
| 1105 |
+
}
|
| 1106 |
+
|
| 1107 |
+
/**
|
| 1108 |
+
* Create billing and shipping addresses basing on response data
|
| 1109 |
+
* @param array $data
|
| 1110 |
+
*/
|
| 1111 |
+
protected function _exportAddressses($data)
|
| 1112 |
+
{
|
| 1113 |
+
$address = new Varien_Object();
|
| 1114 |
+
Varien_Object_Mapper::accumulateByMap($data, $address, $this->_billingAddressMap);
|
| 1115 |
+
$address->setExportedKeys(array_values($this->_billingAddressMap));
|
| 1116 |
+
$this->_applyStreetAndRegionWorkarounds($address);
|
| 1117 |
+
$this->setExportedBillingAddress($address);
|
| 1118 |
+
// assume there is shipping address if there is at least one field specific to shipping
|
| 1119 |
+
if (isset($data['SHIPTONAME'])) {
|
| 1120 |
+
$shippingAddress = clone $address;
|
| 1121 |
+
Varien_Object_Mapper::accumulateByMap($data, $shippingAddress, $this->_shippingAddressMap);
|
| 1122 |
+
$this->_applyStreetAndRegionWorkarounds($shippingAddress);
|
| 1123 |
+
// PayPal doesn't provide detailed shipping name fields, so the name will be overwritten
|
| 1124 |
+
$firstName = $data['SHIPTONAME'];
|
| 1125 |
+
$lastName = null;
|
| 1126 |
+
if (isset($data['FIRSTNAME']) && $data['LASTNAME']) {
|
| 1127 |
+
$firstName = $data['FIRSTNAME'];
|
| 1128 |
+
$lastName = $data['LASTNAME'];
|
| 1129 |
+
}
|
| 1130 |
+
$shippingAddress->addData(array(
|
| 1131 |
+
'prefix' => null,
|
| 1132 |
+
'firstname' => $firstName,
|
| 1133 |
+
'middlename' => null,
|
| 1134 |
+
'lastname' => $lastName,
|
| 1135 |
+
'suffix' => null,
|
| 1136 |
+
));
|
| 1137 |
+
$this->setExportedShippingAddress($shippingAddress);
|
| 1138 |
+
}
|
| 1139 |
+
}
|
| 1140 |
+
|
| 1141 |
+
/**
|
| 1142 |
+
* Adopt specified address object to be compatible with Magento
|
| 1143 |
+
*
|
| 1144 |
+
* @param Varien_Object $address
|
| 1145 |
+
*/
|
| 1146 |
+
protected function _applyStreetAndRegionWorkarounds(Varien_Object $address)
|
| 1147 |
+
{
|
| 1148 |
+
// merge street addresses into 1
|
| 1149 |
+
if ($address->hasStreet2()) {
|
| 1150 |
+
$address->setStreet(implode("\n", array($address->getStreet(), $address->getStreet2())));
|
| 1151 |
+
$address->unsStreet2();
|
| 1152 |
+
}
|
| 1153 |
+
// attempt to fetch region_id from directory
|
| 1154 |
+
if ($address->getCountryId() && $address->getRegion()) {
|
| 1155 |
+
$regions = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getRegionCollection()
|
| 1156 |
+
->addRegionCodeFilter($address->getRegion())
|
| 1157 |
+
->setPageSize(1)
|
| 1158 |
+
;
|
| 1159 |
+
foreach ($regions as $region) {
|
| 1160 |
+
$address->setRegionId($region->getId());
|
| 1161 |
+
$address->setExportedKeys(array_merge($address->getExportedKeys(), array('region_id')));
|
| 1162 |
+
break;
|
| 1163 |
+
}
|
| 1164 |
+
}
|
| 1165 |
+
}
|
| 1166 |
+
|
| 1167 |
+
/**
|
| 1168 |
+
* Adopt specified request array to be compatible with Paypal
|
| 1169 |
+
* Puerto Rico should be as state of USA and not as a country
|
| 1170 |
+
*
|
| 1171 |
+
* @param array $request
|
| 1172 |
+
*/
|
| 1173 |
+
protected function _applyCountryWorkarounds(&$request)
|
| 1174 |
+
{
|
| 1175 |
+
if (isset($request['SHIPTOCOUNTRYCODE']) && $request['SHIPTOCOUNTRYCODE'] == 'PR') {
|
| 1176 |
+
$request['SHIPTOCOUNTRYCODE'] = 'US';
|
| 1177 |
+
$request['SHIPTOSTATE'] = 'PR';
|
| 1178 |
+
}
|
| 1179 |
+
}
|
| 1180 |
+
|
| 1181 |
+
/**
|
| 1182 |
+
* Prepare request data basing on provided address
|
| 1183 |
+
*
|
| 1184 |
+
* @deprecated after 1.4.2.0-beta1, use _importAddresses() instead
|
| 1185 |
+
*
|
| 1186 |
+
* @param Varien_Object $address
|
| 1187 |
+
* @param array $to
|
| 1188 |
+
* @return array
|
| 1189 |
+
*/
|
| 1190 |
+
protected function _importAddress(Varien_Object $address, array $to)
|
| 1191 |
+
{
|
| 1192 |
+
$this->setAddress($address);
|
| 1193 |
+
return $this->_importAddresses($to);
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
/**
|
| 1197 |
+
* Prepare request data basing on provided addresses
|
| 1198 |
+
*
|
| 1199 |
+
* @param array $to
|
| 1200 |
+
* @return array
|
| 1201 |
+
*/
|
| 1202 |
+
protected function _importAddresses(array $to)
|
| 1203 |
+
{
|
| 1204 |
+
$billingAddress = ($this->getBillingAddress()) ? $this->getBillingAddress() : $this->getAddress();
|
| 1205 |
+
$shippingAddress = $this->getAddress();
|
| 1206 |
+
|
| 1207 |
+
$to = Varien_Object_Mapper::accumulateByMap(
|
| 1208 |
+
$billingAddress,
|
| 1209 |
+
$to,
|
| 1210 |
+
array_merge(array_flip($this->_billingAddressMap), $this->_billingAddressMapRequest)
|
| 1211 |
+
);
|
| 1212 |
+
if ($regionCode = $this->_lookupRegionCodeFromAddress($billingAddress)) {
|
| 1213 |
+
$to['STATE'] = $regionCode;
|
| 1214 |
+
}
|
| 1215 |
+
if (!$this->getSuppressShipping()) {
|
| 1216 |
+
$to = Varien_Object_Mapper::accumulateByMap($shippingAddress, $to, array_flip($this->_shippingAddressMap));
|
| 1217 |
+
if ($regionCode = $this->_lookupRegionCodeFromAddress($shippingAddress)) {
|
| 1218 |
+
$to['SHIPTOSTATE'] = $regionCode;
|
| 1219 |
+
}
|
| 1220 |
+
$this->_importStreetFromAddress($shippingAddress, $to, 'SHIPTOSTREET', 'SHIPTOSTREET2');
|
| 1221 |
+
$this->_importStreetFromAddress($billingAddress, $to, 'STREET', 'STREET2');
|
| 1222 |
+
$to['SHIPTONAME'] = $shippingAddress->getName();
|
| 1223 |
+
}
|
| 1224 |
+
$this->_applyCountryWorkarounds($to);
|
| 1225 |
+
return $to;
|
| 1226 |
+
}
|
| 1227 |
+
|
| 1228 |
+
/**
|
| 1229 |
+
* Filter for credit card type
|
| 1230 |
+
*
|
| 1231 |
+
* @param string $value
|
| 1232 |
+
* @return string
|
| 1233 |
+
*/
|
| 1234 |
+
protected function _filterCcType($value)
|
| 1235 |
+
{
|
| 1236 |
+
if (isset($this->_supportedCcTypes[$value])) {
|
| 1237 |
+
return $this->_supportedCcTypes[$value];
|
| 1238 |
+
}
|
| 1239 |
+
return '';
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
/**
|
| 1243 |
+
* Filter for true/false values (converts to boolean)
|
| 1244 |
+
*
|
| 1245 |
+
* @param mixed $value
|
| 1246 |
+
* @return mixed
|
| 1247 |
+
*/
|
| 1248 |
+
protected function _filterToBool($value)
|
| 1249 |
+
{
|
| 1250 |
+
if ('false' === $value || '0' === $value) {
|
| 1251 |
+
return false;
|
| 1252 |
+
} elseif ('true' === $value || '1' === $value) {
|
| 1253 |
+
return true;
|
| 1254 |
+
}
|
| 1255 |
+
return $value;
|
| 1256 |
+
}
|
| 1257 |
+
|
| 1258 |
+
/**
|
| 1259 |
+
* Filter for 'AUTOBILLAMT'
|
| 1260 |
+
*
|
| 1261 |
+
* @param string $value
|
| 1262 |
+
* @return string
|
| 1263 |
+
*/
|
| 1264 |
+
protected function _filterBillFailedLater($value)
|
| 1265 |
+
{
|
| 1266 |
+
return $value ? 'AddToNextBilling' : 'NoAutoBill';
|
| 1267 |
+
}
|
| 1268 |
+
|
| 1269 |
+
/**
|
| 1270 |
+
* Filter for 'BILLINGPERIOD' and 'TRIALBILLINGPERIOD'
|
| 1271 |
+
*
|
| 1272 |
+
* @param string $value
|
| 1273 |
+
* @return string
|
| 1274 |
+
*/
|
| 1275 |
+
protected function _filterPeriodUnit($value)
|
| 1276 |
+
{
|
| 1277 |
+
switch ($value) {
|
| 1278 |
+
case 'day': return 'Day';
|
| 1279 |
+
case 'week': return 'Week';
|
| 1280 |
+
case 'semi_month': return 'SemiMonth';
|
| 1281 |
+
case 'month': return 'Month';
|
| 1282 |
+
case 'year': return 'Year';
|
| 1283 |
+
}
|
| 1284 |
+
}
|
| 1285 |
+
|
| 1286 |
+
/**
|
| 1287 |
+
* Filter for 'FAILEDINITAMTACTION'
|
| 1288 |
+
*
|
| 1289 |
+
* @param string $value
|
| 1290 |
+
* @return string
|
| 1291 |
+
*/
|
| 1292 |
+
protected function _filterInitialAmountMayFail($value)
|
| 1293 |
+
{
|
| 1294 |
+
return $value ? 'ContinueOnFailure' : 'CancelOnFailure';
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
+
/**
|
| 1298 |
+
* Filter for billing agreement status
|
| 1299 |
+
*
|
| 1300 |
+
* @param string $value
|
| 1301 |
+
* @return string
|
| 1302 |
+
*/
|
| 1303 |
+
protected function _filterBillingAgreementStatus($value)
|
| 1304 |
+
{
|
| 1305 |
+
switch ($value) {
|
| 1306 |
+
case 'canceled': return 'Canceled';
|
| 1307 |
+
case 'active': return 'Active';
|
| 1308 |
+
}
|
| 1309 |
+
}
|
| 1310 |
+
|
| 1311 |
+
/**
|
| 1312 |
+
* Convert payment status from NVP format to paypal/info model format
|
| 1313 |
+
*
|
| 1314 |
+
* @param string $value
|
| 1315 |
+
* @return string|null
|
| 1316 |
+
*/
|
| 1317 |
+
protected function _filterPaymentStatusFromNvpToInfo($value)
|
| 1318 |
+
{
|
| 1319 |
+
switch ($value) {
|
| 1320 |
+
case 'None': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_NONE;
|
| 1321 |
+
case 'Completed': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_COMPLETED;
|
| 1322 |
+
case 'Denied': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_DENIED;
|
| 1323 |
+
case 'Expired': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_EXPIRED;
|
| 1324 |
+
case 'Failed': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_FAILED;
|
| 1325 |
+
case 'In-Progress': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_INPROGRESS;
|
| 1326 |
+
case 'Pending': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_PENDING;
|
| 1327 |
+
case 'Refunded': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_REFUNDED;
|
| 1328 |
+
case 'Partially-Refunded': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_REFUNDEDPART;
|
| 1329 |
+
case 'Reversed': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_REVERSED;
|
| 1330 |
+
case 'Canceled-Reversal': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_UNREVERSED;
|
| 1331 |
+
case 'Processed': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_PROCESSED;
|
| 1332 |
+
case 'Voided': return Ebcomm_PaypalMx_Model_Info::PAYMENTSTATUS_VOIDED;
|
| 1333 |
+
}
|
| 1334 |
+
}
|
| 1335 |
+
|
| 1336 |
+
/**
|
| 1337 |
+
* Convert payment review action to NVP-compatible value
|
| 1338 |
+
*
|
| 1339 |
+
* @param string $value
|
| 1340 |
+
* @return string|null
|
| 1341 |
+
*/
|
| 1342 |
+
protected function _filterPaymentReviewAction($value)
|
| 1343 |
+
{
|
| 1344 |
+
switch ($value) {
|
| 1345 |
+
case Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_ACCEPT:
|
| 1346 |
+
return 'Accept';
|
| 1347 |
+
case Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_DENY:
|
| 1348 |
+
return 'Deny';
|
| 1349 |
+
}
|
| 1350 |
+
}
|
| 1351 |
+
|
| 1352 |
+
/**
|
| 1353 |
+
* Convert RP management action to NVP format
|
| 1354 |
+
*
|
| 1355 |
+
* @param string $value
|
| 1356 |
+
* @return string|null
|
| 1357 |
+
*/
|
| 1358 |
+
protected function _filterRecurringProfileActionToNvp($value)
|
| 1359 |
+
{
|
| 1360 |
+
switch ($value) {
|
| 1361 |
+
case 'cancel': return 'Cancel';
|
| 1362 |
+
case 'suspend': return 'Suspend';
|
| 1363 |
+
case 'activate': return 'Reactivate';
|
| 1364 |
+
}
|
| 1365 |
+
}
|
| 1366 |
+
|
| 1367 |
+
/**
|
| 1368 |
+
* Check the obtained RP status in NVP format and specify the profile state
|
| 1369 |
+
*
|
| 1370 |
+
* @param string $value
|
| 1371 |
+
* @param Varien_Object $result
|
| 1372 |
+
*/
|
| 1373 |
+
protected function _analyzeRecurringProfileStatus($value, Varien_Object $result)
|
| 1374 |
+
{
|
| 1375 |
+
switch ($value) {
|
| 1376 |
+
case 'ActiveProfile':
|
| 1377 |
+
case 'Active':
|
| 1378 |
+
$result->setIsProfileActive(true);
|
| 1379 |
+
break;
|
| 1380 |
+
case 'PendingProfile':
|
| 1381 |
+
$result->setIsProfilePending(true);
|
| 1382 |
+
break;
|
| 1383 |
+
case 'CancelledProfile':
|
| 1384 |
+
case 'Cancelled':
|
| 1385 |
+
$result->setIsProfileCanceled(true);
|
| 1386 |
+
break;
|
| 1387 |
+
case 'SuspendedProfile':
|
| 1388 |
+
case 'Suspended':
|
| 1389 |
+
$result->setIsProfileSuspended(true);
|
| 1390 |
+
break;
|
| 1391 |
+
case 'ExpiredProfile':
|
| 1392 |
+
case 'Expired': // ??
|
| 1393 |
+
$result->setIsProfileExpired(true);
|
| 1394 |
+
break;
|
| 1395 |
+
}
|
| 1396 |
+
}
|
| 1397 |
+
|
| 1398 |
+
/**
|
| 1399 |
+
* Return capture type
|
| 1400 |
+
*
|
| 1401 |
+
* @param Varien_Object $payment
|
| 1402 |
+
* @return string
|
| 1403 |
+
*/
|
| 1404 |
+
protected function _getCaptureCompleteType()
|
| 1405 |
+
{
|
| 1406 |
+
return ($this->getIsCaptureComplete())
|
| 1407 |
+
? $this->_captureTypeComplete
|
| 1408 |
+
: $this->_captureTypeNotcomplete;
|
| 1409 |
+
}
|
| 1410 |
+
|
| 1411 |
+
/**
|
| 1412 |
+
* Return each call request without unused fields in case of Express Checkout Unilateral payments
|
| 1413 |
+
*
|
| 1414 |
+
* @param string $methodName Current method name
|
| 1415 |
+
* @return array
|
| 1416 |
+
*/
|
| 1417 |
+
protected function _prepareEachCallRequest($methodName)
|
| 1418 |
+
{
|
| 1419 |
+
$expressCheckooutMetods = array(
|
| 1420 |
+
self::SET_EXPRESS_CHECKOUT, self::GET_EXPRESS_CHECKOUT_DETAILS, self::DO_EXPRESS_CHECKOUT_PAYMENT
|
| 1421 |
+
);
|
| 1422 |
+
if (!in_array($methodName, $expressCheckooutMetods) || !$this->_config->shouldUseUnilateralPayments()) {
|
| 1423 |
+
return $this->_eachCallRequest;
|
| 1424 |
+
}
|
| 1425 |
+
return array_diff($this->_eachCallRequest, array('USER', 'PWD', 'SIGNATURE'));
|
| 1426 |
+
}
|
| 1427 |
+
|
| 1428 |
+
/**
|
| 1429 |
+
* Check the EC request against unilateral payments mode and remove the SUBJECT if needed
|
| 1430 |
+
*
|
| 1431 |
+
* @param &array $requestFields
|
| 1432 |
+
*/
|
| 1433 |
+
protected function _prepareExpressCheckoutCallRequest(&$requestFields)
|
| 1434 |
+
{
|
| 1435 |
+
if (!$this->_config->shouldUseUnilateralPayments()) {
|
| 1436 |
+
if ($key = array_search('SUBJECT', $requestFields)) {
|
| 1437 |
+
unset($requestFields[$key]);
|
| 1438 |
+
}
|
| 1439 |
+
}
|
| 1440 |
+
}
|
| 1441 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Api/Standard.php
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* PayPal Standard checkout request API
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_Api_Standard extends Ebcomm_PaypalMx_Model_Api_Abstract
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Global interface map and export filters
|
| 10 |
+
* @var array
|
| 11 |
+
*/
|
| 12 |
+
protected $_globalMap = array(
|
| 13 |
+
// commands
|
| 14 |
+
'business' => 'business_account',
|
| 15 |
+
'notify_url' => 'notify_url',
|
| 16 |
+
'return' => 'return_url',
|
| 17 |
+
'cancel_return' => 'cancel_url',
|
| 18 |
+
'bn' => 'build_notation_code',
|
| 19 |
+
'paymentaction' => 'payment_action',
|
| 20 |
+
// payment
|
| 21 |
+
'invoice' => 'order_id',
|
| 22 |
+
'currency_code' => 'currency_code',
|
| 23 |
+
'amount' => 'amount',
|
| 24 |
+
'shipping' => 'shipping_amount',
|
| 25 |
+
'tax' => 'tax_amount',
|
| 26 |
+
'discount_amount' => 'discount_amount',
|
| 27 |
+
// misc
|
| 28 |
+
'item_name' => 'cart_summary',
|
| 29 |
+
// page design settings
|
| 30 |
+
'page_style' => 'page_style',
|
| 31 |
+
'cpp_header_image' => 'hdrimg',
|
| 32 |
+
'cpp_headerback_color' => 'hdrbackcolor',
|
| 33 |
+
'cpp_headerborder_color' => 'hdrbordercolor',
|
| 34 |
+
'cpp_payflow_color' => 'payflowcolor',
|
| 35 |
+
// 'cs' => '', // TODO
|
| 36 |
+
'lc' => 'locale',
|
| 37 |
+
);
|
| 38 |
+
protected $_exportToRequestFilters = array(
|
| 39 |
+
'amount' => '_filterAmount',
|
| 40 |
+
'shipping' => '_filterAmount',
|
| 41 |
+
'tax' => '_filterAmount',
|
| 42 |
+
'discount_amount' => '_filterAmount',
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Interface for common and "aggregated order" specific fields
|
| 47 |
+
* @var array
|
| 48 |
+
*/
|
| 49 |
+
protected $_commonRequestFields = array(
|
| 50 |
+
'business', 'invoice', 'currency_code', 'paymentaction', 'return', 'cancel_return', 'notify_url', 'bn',
|
| 51 |
+
'page_style', 'cpp_header_image', 'cpp_headerback_color', 'cpp_headerborder_color', 'cpp_payflow_color',
|
| 52 |
+
'amount', 'shipping', 'tax', 'discount_amount', 'item_name', 'lc',
|
| 53 |
+
);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Fields that should be replaced in debug with '***'
|
| 57 |
+
*
|
| 58 |
+
* @var array
|
| 59 |
+
*/
|
| 60 |
+
protected $_debugReplacePrivateDataKeys = array('business');
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Line items export mapping settings
|
| 64 |
+
* @var array
|
| 65 |
+
*/
|
| 66 |
+
protected $_lineItemTotalExportMap = array(
|
| 67 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_SUBTOTAL => 'amount',
|
| 68 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_DISCOUNT => 'discount_amount',
|
| 69 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_TAX => 'tax',
|
| 70 |
+
Ebcomm_PaypalMx_Model_Cart::TOTAL_SHIPPING => 'shipping',
|
| 71 |
+
);
|
| 72 |
+
protected $_lineItemExportItemsFormat = array(
|
| 73 |
+
'id' => 'item_number_%d',
|
| 74 |
+
'name' => 'item_name_%d',
|
| 75 |
+
'qty' => 'quantity_%d',
|
| 76 |
+
'amount' => 'amount_%d',
|
| 77 |
+
);
|
| 78 |
+
|
| 79 |
+
protected $_lineItemExportItemsFilters = array(
|
| 80 |
+
'qty' => '_filterQty'
|
| 81 |
+
);
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Address export to request map
|
| 85 |
+
* @var array
|
| 86 |
+
*/
|
| 87 |
+
protected $_addressMap = array(
|
| 88 |
+
'city' => 'city',
|
| 89 |
+
'country' => 'country_id',
|
| 90 |
+
'email' => 'email',
|
| 91 |
+
'first_name' => 'firstname',
|
| 92 |
+
'last_name' => 'lastname',
|
| 93 |
+
'zip' => 'postcode',
|
| 94 |
+
'state' => 'region',
|
| 95 |
+
'address1' => 'street',
|
| 96 |
+
'address2' => 'street2',
|
| 97 |
+
);
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Generate PayPal Standard checkout request fields
|
| 101 |
+
* Depending on whether there are cart line items set, will aggregate everything or display items specifically
|
| 102 |
+
* Shipping amount in cart line items is implemented as a separate "fake" line item
|
| 103 |
+
*/
|
| 104 |
+
public function getStandardCheckoutRequest()
|
| 105 |
+
{
|
| 106 |
+
$request = $this->_exportToRequest($this->_commonRequestFields);
|
| 107 |
+
$request['charset'] = 'utf-8';
|
| 108 |
+
|
| 109 |
+
$isLineItems = $this->_exportLineItems($request);
|
| 110 |
+
if ($isLineItems) {
|
| 111 |
+
$request = array_merge($request, array(
|
| 112 |
+
'cmd' => '_cart',
|
| 113 |
+
'upload' => 1,
|
| 114 |
+
));
|
| 115 |
+
if (isset($request['tax'])) {
|
| 116 |
+
$request['tax_cart'] = $request['tax'];
|
| 117 |
+
}
|
| 118 |
+
if (isset($request['discount_amount'])) {
|
| 119 |
+
$request['discount_amount_cart'] = $request['discount_amount'];
|
| 120 |
+
}
|
| 121 |
+
} else {
|
| 122 |
+
$request = array_merge($request, array(
|
| 123 |
+
'cmd' => '_ext-enter',
|
| 124 |
+
'redirect_cmd' => '_xclick',
|
| 125 |
+
));
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// payer address
|
| 129 |
+
$this->_importAddress($request);
|
| 130 |
+
$this->_debug(array('request' => $request)); // TODO: this is not supposed to be called in getter
|
| 131 |
+
return $request;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Merchant account email getter
|
| 136 |
+
* @return string
|
| 137 |
+
*/
|
| 138 |
+
public function getBusinessAccount()
|
| 139 |
+
{
|
| 140 |
+
return $this->_getDataOrConfig('business_account');
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* Payment action getter
|
| 145 |
+
* @return string
|
| 146 |
+
*/
|
| 147 |
+
public function getPaymentAction()
|
| 148 |
+
{
|
| 149 |
+
return strtolower(parent::getPaymentAction());
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* @deprecated after 1.4.1.0
|
| 154 |
+
*
|
| 155 |
+
* @param array $request
|
| 156 |
+
*/
|
| 157 |
+
public function debugRequest($request)
|
| 158 |
+
{
|
| 159 |
+
return;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Add shipping total as a line item.
|
| 164 |
+
* For some reason PayPal ignores shipping total variables exactly when line items is enabled
|
| 165 |
+
* Note that $i = 1
|
| 166 |
+
*
|
| 167 |
+
* @param array $request
|
| 168 |
+
* @param int $i
|
| 169 |
+
* @return true|null
|
| 170 |
+
*/
|
| 171 |
+
protected function _exportLineItems(array &$request, $i = 1)
|
| 172 |
+
{
|
| 173 |
+
if (!$this->_cart) {
|
| 174 |
+
return;
|
| 175 |
+
}
|
| 176 |
+
if ($this->getIsLineItemsEnabled()) {
|
| 177 |
+
$this->_cart->isShippingAsItem(true);
|
| 178 |
+
}
|
| 179 |
+
return parent::_exportLineItems($request, $i);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Import address object, if set, to the request
|
| 184 |
+
*
|
| 185 |
+
* @param array $request
|
| 186 |
+
*/
|
| 187 |
+
protected function _importAddress(&$request)
|
| 188 |
+
{
|
| 189 |
+
$address = $this->getAddress();
|
| 190 |
+
if (!$address) {
|
| 191 |
+
if ($this->getNoShipping()) {
|
| 192 |
+
$request['no_shipping'] = 1;
|
| 193 |
+
}
|
| 194 |
+
return;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
$request = Varien_Object_Mapper::accumulateByMap($address, $request, array_flip($this->_addressMap));
|
| 198 |
+
|
| 199 |
+
// Address may come without email info (user is not always required to enter it), so add email from order
|
| 200 |
+
if (!$request['email']) {
|
| 201 |
+
$order = $this->getOrder();
|
| 202 |
+
if ($order) {
|
| 203 |
+
$request['email'] = $order->getCustomerEmail();
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
$regionCode = $this->_lookupRegionCodeFromAddress($address);
|
| 208 |
+
if ($regionCode) {
|
| 209 |
+
$request['state'] = $regionCode;
|
| 210 |
+
}
|
| 211 |
+
$this->_importStreetFromAddress($address, $request, 'address1', 'address2');
|
| 212 |
+
$this->_applyCountryWorkarounds($request);
|
| 213 |
+
|
| 214 |
+
$request['address_override'] = 1;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Adopt specified request array to be compatible with Paypal
|
| 219 |
+
* Puerto Rico should be as state of USA and not as a country
|
| 220 |
+
*
|
| 221 |
+
* @param array $request
|
| 222 |
+
*/
|
| 223 |
+
protected function _applyCountryWorkarounds(&$request)
|
| 224 |
+
{
|
| 225 |
+
if (isset($request['country']) && $request['country'] == 'PR') {
|
| 226 |
+
$request['country'] = 'US';
|
| 227 |
+
$request['state'] = 'PR';
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Cart.php
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* PayPal-specific model for shopping cart items and totals
|
| 5 |
+
* The main idea is to accommodate all possible totals into PayPal-compatible 4 totals and line items
|
| 6 |
+
*/
|
| 7 |
+
class Ebcomm_PaypalMx_Model_Cart
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* Totals that PayPal suppports when passing shopping cart
|
| 11 |
+
*
|
| 12 |
+
* @var string
|
| 13 |
+
*/
|
| 14 |
+
const TOTAL_SUBTOTAL = 'subtotal';
|
| 15 |
+
const TOTAL_DISCOUNT = 'discount';
|
| 16 |
+
const TOTAL_TAX = 'tax';
|
| 17 |
+
const TOTAL_SHIPPING = 'shipping';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Order or quote instance
|
| 21 |
+
*
|
| 22 |
+
* @var Mage_Sales_Model_Order
|
| 23 |
+
* @var Mage_Sales_Model_Quote
|
| 24 |
+
*/
|
| 25 |
+
protected $_salesEntity = null;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Rendered cart items
|
| 29 |
+
* Array of Varien_Objects
|
| 30 |
+
*
|
| 31 |
+
* @var array
|
| 32 |
+
*/
|
| 33 |
+
protected $_items = array();
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Rendered cart totals
|
| 37 |
+
* Associative array with the keys from constants above
|
| 38 |
+
*
|
| 39 |
+
* @var array
|
| 40 |
+
*/
|
| 41 |
+
protected $_totals = array();
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Set of optional descriptions for the item that may replace a total and composed of several amounts
|
| 45 |
+
* Array of strings
|
| 46 |
+
*
|
| 47 |
+
* @var array
|
| 48 |
+
*/
|
| 49 |
+
protected $_totalLineItemDescriptions = array();
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Lazy initialization indicator for rendering
|
| 53 |
+
*
|
| 54 |
+
* @var bool
|
| 55 |
+
*/
|
| 56 |
+
protected $_shouldRender = true;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Validation result for the rendered cart items
|
| 60 |
+
*
|
| 61 |
+
* @var bool
|
| 62 |
+
*/
|
| 63 |
+
protected $_areItemsValid = false;
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Validation result for the rendered totals
|
| 67 |
+
*
|
| 68 |
+
* @var bool
|
| 69 |
+
*/
|
| 70 |
+
protected $_areTotalsValid = false;
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Whether to render discount total as a line item
|
| 74 |
+
* Use case: WPP
|
| 75 |
+
*
|
| 76 |
+
* @var bool
|
| 77 |
+
*/
|
| 78 |
+
protected $_isDiscountAsItem = false;
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Whether to render shipping total as a line item
|
| 82 |
+
* Use case: WPS
|
| 83 |
+
*
|
| 84 |
+
* @var bool
|
| 85 |
+
*/
|
| 86 |
+
protected $_isShippingAsItem = false;
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Require instance of an order or a quote
|
| 90 |
+
*
|
| 91 |
+
* @param array $params
|
| 92 |
+
*/
|
| 93 |
+
public function __construct($params = array())
|
| 94 |
+
{
|
| 95 |
+
$salesEntity = array_shift($params);
|
| 96 |
+
if (is_object($salesEntity)
|
| 97 |
+
&& (($salesEntity instanceof Mage_Sales_Model_Order) || ($salesEntity instanceof Mage_Sales_Model_Quote))) {
|
| 98 |
+
$this->_salesEntity = $salesEntity;
|
| 99 |
+
} else {
|
| 100 |
+
throw new Exception('Invalid sales entity provided.');
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* Getter for the current sales entity
|
| 106 |
+
*
|
| 107 |
+
* @return Mage_Sales_Model_Order
|
| 108 |
+
* @return Mage_Sales_Model_Quote
|
| 109 |
+
*/
|
| 110 |
+
public function getSalesEntity()
|
| 111 |
+
{
|
| 112 |
+
return $this->_salesEntity;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Render and get line items
|
| 117 |
+
* By default returns false if the items are invalid
|
| 118 |
+
*
|
| 119 |
+
* @param bool $bypassValidation
|
| 120 |
+
* @return array|false
|
| 121 |
+
*/
|
| 122 |
+
public function getItems($bypassValidation = false)
|
| 123 |
+
{
|
| 124 |
+
$this->_render();
|
| 125 |
+
if (!$bypassValidation && !$this->_areItemsValid) {
|
| 126 |
+
return false;
|
| 127 |
+
}
|
| 128 |
+
return $this->_items;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Render and get totals
|
| 133 |
+
* If the totals are invalid for any reason, they will be merged into one amount (subtotal is utilized for it)
|
| 134 |
+
* An option to substract discount from the subtotal is available
|
| 135 |
+
*
|
| 136 |
+
* @param bool $mergeDiscount
|
| 137 |
+
* @return array
|
| 138 |
+
*/
|
| 139 |
+
public function getTotals($mergeDiscount = false)
|
| 140 |
+
{
|
| 141 |
+
$this->_render();
|
| 142 |
+
|
| 143 |
+
// cut down totals to one total if they are invalid
|
| 144 |
+
if (!$this->_areTotalsValid) {
|
| 145 |
+
$totals = array(self::TOTAL_SUBTOTAL =>
|
| 146 |
+
$this->_totals[self::TOTAL_SUBTOTAL] + $this->_totals[self::TOTAL_TAX]
|
| 147 |
+
);
|
| 148 |
+
if (!$this->_isShippingAsItem) {
|
| 149 |
+
$totals[self::TOTAL_SUBTOTAL] += $this->_totals[self::TOTAL_SHIPPING];
|
| 150 |
+
}
|
| 151 |
+
if (!$this->_isDiscountAsItem) {
|
| 152 |
+
$totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT];
|
| 153 |
+
}
|
| 154 |
+
return $totals;
|
| 155 |
+
} elseif ($mergeDiscount) {
|
| 156 |
+
$totals = $this->_totals;
|
| 157 |
+
unset($totals[self::TOTAL_DISCOUNT]);
|
| 158 |
+
if (!$this->_isDiscountAsItem) {
|
| 159 |
+
$totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT];
|
| 160 |
+
}
|
| 161 |
+
return $totals;
|
| 162 |
+
}
|
| 163 |
+
return $this->_totals;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Add a line item
|
| 168 |
+
*
|
| 169 |
+
* @param string $name
|
| 170 |
+
* @param numeric $qty
|
| 171 |
+
* @param float $amount
|
| 172 |
+
* @param string $identifier
|
| 173 |
+
* @return Varien_Object
|
| 174 |
+
*/
|
| 175 |
+
public function addItem($name, $qty, $amount, $identifier = null)
|
| 176 |
+
{
|
| 177 |
+
$this->_shouldRender = true;
|
| 178 |
+
$item = new Varien_Object(array(
|
| 179 |
+
'name' => $name,
|
| 180 |
+
'qty' => $qty,
|
| 181 |
+
'amount' => (float)$amount,
|
| 182 |
+
));
|
| 183 |
+
if ($identifier) {
|
| 184 |
+
$item->setData('id', $identifier);
|
| 185 |
+
}
|
| 186 |
+
$this->_items[] = $item;
|
| 187 |
+
return $item;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* Remove item from cart by identifier
|
| 192 |
+
*
|
| 193 |
+
* @param string $identifier
|
| 194 |
+
* @return bool
|
| 195 |
+
*/
|
| 196 |
+
public function removeItem($identifier)
|
| 197 |
+
{
|
| 198 |
+
foreach ($this->_items as $key => $item) {
|
| 199 |
+
if ($item->getId() == $identifier) {
|
| 200 |
+
unset($this->_items[$key]);
|
| 201 |
+
return true;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
return false;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* Compound the specified amount with the specified total
|
| 209 |
+
*
|
| 210 |
+
* @param string $code
|
| 211 |
+
* @param float $amount
|
| 212 |
+
* @param string $lineItemDescription
|
| 213 |
+
* @return Ebcomm_PaypalMx_Model_Cart
|
| 214 |
+
*/
|
| 215 |
+
public function updateTotal($code, $amount, $lineItemDescription = null)
|
| 216 |
+
{
|
| 217 |
+
$this->_shouldRender = true;
|
| 218 |
+
if (isset($this->_totals[$code])) {
|
| 219 |
+
$this->_totals[$code] += $amount;
|
| 220 |
+
if ($lineItemDescription) {
|
| 221 |
+
$this->_totalLineItemDescriptions[$code][] = $lineItemDescription;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
return $this;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Get/Set whether to render the discount total as a line item
|
| 229 |
+
*
|
| 230 |
+
* @param $setValue
|
| 231 |
+
* @return bool|Ebcomm_PaypalMx_Model_Cart
|
| 232 |
+
*/
|
| 233 |
+
public function isDiscountAsItem($setValue = null)
|
| 234 |
+
{
|
| 235 |
+
return $this->_totalAsItem('_isDiscountAsItem', $setValue);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* Get/Set whether to render the discount total as a line item
|
| 240 |
+
*
|
| 241 |
+
* @param $setValue
|
| 242 |
+
* @return bool|Ebcomm_PaypalMx_Model_Cart
|
| 243 |
+
*/
|
| 244 |
+
public function isShippingAsItem($setValue = null)
|
| 245 |
+
{
|
| 246 |
+
return $this->_totalAsItem('_isShippingAsItem', $setValue);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* (re)Render all items and totals
|
| 251 |
+
*/
|
| 252 |
+
protected function _render()
|
| 253 |
+
{
|
| 254 |
+
if (!$this->_shouldRender) {
|
| 255 |
+
return;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// regular items from the sales entity
|
| 259 |
+
$this->_items = array();
|
| 260 |
+
foreach ($this->_salesEntity->getAllItems() as $item) {
|
| 261 |
+
if (!$item->getParentItem()) {
|
| 262 |
+
$this->_addRegularItem($item);
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
end($this->_items);
|
| 266 |
+
$lastRegularItemKey = key($this->_items);
|
| 267 |
+
|
| 268 |
+
// regular totals
|
| 269 |
+
$shippingDescription = '';
|
| 270 |
+
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
|
| 271 |
+
$shippingDescription = $this->_salesEntity->getShippingDescription();
|
| 272 |
+
$this->_totals = array(
|
| 273 |
+
self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(),
|
| 274 |
+
self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(),
|
| 275 |
+
self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(),
|
| 276 |
+
self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount()),
|
| 277 |
+
);
|
| 278 |
+
$this->_applyHiddenTaxWorkaround($this->_salesEntity);
|
| 279 |
+
} else {
|
| 280 |
+
$address = $this->_salesEntity->getIsVirtual() ?
|
| 281 |
+
$this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress();
|
| 282 |
+
$shippingDescription = $address->getShippingDescription();
|
| 283 |
+
$this->_totals = array (
|
| 284 |
+
self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(),
|
| 285 |
+
self::TOTAL_TAX => $address->getBaseTaxAmount(),
|
| 286 |
+
self::TOTAL_SHIPPING => $address->getBaseShippingAmount(),
|
| 287 |
+
self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()),
|
| 288 |
+
);
|
| 289 |
+
$this->_applyHiddenTaxWorkaround($address);
|
| 290 |
+
}
|
| 291 |
+
$originalDiscount = $this->_totals[self::TOTAL_DISCOUNT];
|
| 292 |
+
|
| 293 |
+
// arbitrary items, total modifications
|
| 294 |
+
Mage::dispatchEvent('paypal_prepare_line_items', array('paypalmx_cart' => $this));
|
| 295 |
+
|
| 296 |
+
// distinguish original discount among the others
|
| 297 |
+
if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) {
|
| 298 |
+
$this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false));
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
// discount, shipping as items
|
| 302 |
+
if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) {
|
| 303 |
+
$this->addItem(Mage::helper('paypalmx')->__('Discount'), 1, -1.00 * $this->_totals[self::TOTAL_DISCOUNT],
|
| 304 |
+
$this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT)
|
| 305 |
+
);
|
| 306 |
+
}
|
| 307 |
+
$shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription);
|
| 308 |
+
if ($this->_isShippingAsItem && (float)$this->_totals[self::TOTAL_SHIPPING]) {
|
| 309 |
+
$this->addItem(Mage::helper('paypalmx')->__('Shipping'), 1, (float)$this->_totals[self::TOTAL_SHIPPING],
|
| 310 |
+
$shippingItemId
|
| 311 |
+
);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// compound non-regular items into subtotal
|
| 315 |
+
foreach ($this->_items as $key => $item) {
|
| 316 |
+
if ($key > $lastRegularItemKey && $item->getAmount() != 0) {
|
| 317 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount();
|
| 318 |
+
}
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
$this->_validate();
|
| 322 |
+
// if cart items are invalid, prepare cart for transfer without line items
|
| 323 |
+
if (!$this->_areItemsValid) {
|
| 324 |
+
$this->removeItem($shippingItemId);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
$this->_shouldRender = false;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* Merge multiple descriptions by a total code into a string
|
| 332 |
+
*
|
| 333 |
+
* @param string $code
|
| 334 |
+
* @param string $prepend
|
| 335 |
+
* @param string $append
|
| 336 |
+
* @param string $glue
|
| 337 |
+
* @return string
|
| 338 |
+
*/
|
| 339 |
+
protected function _renderTotalLineItemDescriptions($code, $prepend = '', $append = '', $glue = '; ')
|
| 340 |
+
{
|
| 341 |
+
$result = array();
|
| 342 |
+
if ($prepend) {
|
| 343 |
+
$result[] = $prepend;
|
| 344 |
+
}
|
| 345 |
+
if (isset($this->_totalLineItemDescriptions[$code])) {
|
| 346 |
+
$result = array_merge($this->_totalLineItemDescriptions[$code]);
|
| 347 |
+
}
|
| 348 |
+
if ($append) {
|
| 349 |
+
$result[] = $append;
|
| 350 |
+
}
|
| 351 |
+
return implode($glue, $result);
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* Check the line items and totals according to PayPal business logic limitations
|
| 356 |
+
*/
|
| 357 |
+
protected function _validate()
|
| 358 |
+
{
|
| 359 |
+
$this->_areItemsValid = false;
|
| 360 |
+
$this->_areTotalsValid = false;
|
| 361 |
+
|
| 362 |
+
$referenceAmount = $this->_salesEntity->getBaseGrandTotal();
|
| 363 |
+
|
| 364 |
+
$itemsSubtotal = 0;
|
| 365 |
+
foreach ($this->_items as $i) {
|
| 366 |
+
$itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount'];
|
| 367 |
+
}
|
| 368 |
+
$sum = $itemsSubtotal + $this->_totals[self::TOTAL_TAX];
|
| 369 |
+
if (!$this->_isShippingAsItem) {
|
| 370 |
+
$sum += $this->_totals[self::TOTAL_SHIPPING];
|
| 371 |
+
}
|
| 372 |
+
if (!$this->_isDiscountAsItem) {
|
| 373 |
+
$sum -= $this->_totals[self::TOTAL_DISCOUNT];
|
| 374 |
+
}
|
| 375 |
+
/**
|
| 376 |
+
* numbers are intentionally converted to strings because of possible comparison error
|
| 377 |
+
* see http://php.net/float
|
| 378 |
+
*/
|
| 379 |
+
// match sum of all the items and totals to the reference amount
|
| 380 |
+
if (sprintf('%.4F', $sum) == sprintf('%.4F', $referenceAmount)) {
|
| 381 |
+
$this->_areItemsValid = true;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// PayPal requires to have discount less than items subtotal
|
| 385 |
+
if (!$this->_isDiscountAsItem) {
|
| 386 |
+
$this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4);
|
| 387 |
+
} else {
|
| 388 |
+
$this->_areTotalsValid = $itemsSubtotal > 0.00001;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
$this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Add a usual line item with amount and qty
|
| 396 |
+
*
|
| 397 |
+
* @param Varien_Object $salesItem
|
| 398 |
+
* @return Varien_Object
|
| 399 |
+
*/
|
| 400 |
+
protected function _addRegularItem(Varien_Object $salesItem)
|
| 401 |
+
{
|
| 402 |
+
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
|
| 403 |
+
$qty = (int) $salesItem->getQtyOrdered();
|
| 404 |
+
$amount = (float) $salesItem->getBasePrice();
|
| 405 |
+
// TODO: nominal item for order
|
| 406 |
+
} else {
|
| 407 |
+
$qty = (int) $salesItem->getTotalQty();
|
| 408 |
+
$amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice();
|
| 409 |
+
}
|
| 410 |
+
// workaround in case if item subtotal precision is not compatible with PayPal (.2)
|
| 411 |
+
$subAggregatedLabel = '';
|
| 412 |
+
if ($amount - round($amount, 2)) {
|
| 413 |
+
$amount = $amount * $qty;
|
| 414 |
+
$subAggregatedLabel = ' x' . $qty;
|
| 415 |
+
$qty = 1;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
// aggregate item price if item qty * price does not match row total
|
| 419 |
+
if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
|
| 420 |
+
$amount = (float) $salesItem->getBaseRowTotal();
|
| 421 |
+
$subAggregatedLabel = ' x' . $qty;
|
| 422 |
+
$qty = 1;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/**
|
| 429 |
+
* Get/Set for the specified variable.
|
| 430 |
+
* If the value changes, the re-rendering is commenced
|
| 431 |
+
*
|
| 432 |
+
* @param string $var
|
| 433 |
+
* @param $setValue
|
| 434 |
+
* @return bool|Ebcomm_PaypalMx_Model_Cart
|
| 435 |
+
*/
|
| 436 |
+
private function _totalAsItem($var, $setValue = null)
|
| 437 |
+
{
|
| 438 |
+
if (null !== $setValue) {
|
| 439 |
+
if ($setValue != $this->$var) {
|
| 440 |
+
$this->_shouldRender = true;
|
| 441 |
+
}
|
| 442 |
+
$this->$var = $setValue;
|
| 443 |
+
return $this;
|
| 444 |
+
}
|
| 445 |
+
return $this->$var;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
/**
|
| 449 |
+
* Add "hidden" discount and shipping tax
|
| 450 |
+
*
|
| 451 |
+
* Go ahead, try to understand ]:->
|
| 452 |
+
*
|
| 453 |
+
* Tax settings for getting "discount tax":
|
| 454 |
+
* - Catalog Prices = Including Tax
|
| 455 |
+
* - Apply Customer Tax = After Discount
|
| 456 |
+
* - Apply Discount on Prices = Including Tax
|
| 457 |
+
*
|
| 458 |
+
* Test case for getting "hidden shipping tax":
|
| 459 |
+
* - Make sure shipping is taxable (set shipping tax class)
|
| 460 |
+
* - Catalog Prices = Including Tax
|
| 461 |
+
* - Shipping Prices = Including Tax
|
| 462 |
+
* - Apply Customer Tax = After Discount
|
| 463 |
+
* - Create a shopping cart price rule with % discount applied to the Shipping Amount
|
| 464 |
+
* - run shopping cart and estimate shipping
|
| 465 |
+
* - go to PayPal
|
| 466 |
+
*
|
| 467 |
+
* @param Mage_Core_Model_Abstract $salesEntity
|
| 468 |
+
*/
|
| 469 |
+
private function _applyHiddenTaxWorkaround($salesEntity)
|
| 470 |
+
{
|
| 471 |
+
$this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseHidd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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Config model that is aware of all Mage_Paypal payment methods
|
| 4 |
+
* Works with PayPal-specific system configuration
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_Config
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* PayPal Standard
|
| 10 |
+
* @var string
|
| 11 |
+
*/
|
| 12 |
+
const METHOD_PPMX = "ppmx";
|
| 13 |
+
const METHOD_PPMX_DEBITO = 'ppmx_debito2';
|
| 14 |
+
const METHOD_PPMX_MENSUALIDADES = 'ppmx_mensualidades2';
|
| 15 |
+
|
| 16 |
+
const METHOD_WPS = 'paypalmx_standard';
|
| 17 |
+
/**
|
| 18 |
+
* PayPal Website Payments Pro - Express Checkout
|
| 19 |
+
* @var string
|
| 20 |
+
*/
|
| 21 |
+
const METHOD_WPP_EXPRESS = 'paypalmx_express';
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* PayPal Website Payments Pro - Direct Payments
|
| 25 |
+
* @var string
|
| 26 |
+
*/
|
| 27 |
+
const METHOD_WPP_DIRECT = 'paypalmx_direct';
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Direct Payments (Payflow Edition)
|
| 31 |
+
* @var string
|
| 32 |
+
*/
|
| 33 |
+
const METHOD_WPP_PE_DIRECT = 'paypaluk_direct';
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Express Checkout (Payflow Edition)
|
| 37 |
+
* @var string
|
| 38 |
+
*/
|
| 39 |
+
const METHOD_WPP_PE_EXPRESS = 'paypaluk_express';
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Payflow Pro Gateway
|
| 43 |
+
* @var string
|
| 44 |
+
*/
|
| 45 |
+
const METHOD_PAYFLOWPRO = 'verisign';
|
| 46 |
+
|
| 47 |
+
const METHOD_PAYFLOWLINK = 'payflow_link';
|
| 48 |
+
const METHOD_PAYFLOWADVANCED = 'payflow_advanced';
|
| 49 |
+
|
| 50 |
+
const METHOD_HOSTEDPRO = 'hosted_pro';
|
| 51 |
+
|
| 52 |
+
const METHOD_BILLING_AGREEMENT = 'paypal_billing_agreement';
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Buttons and images
|
| 57 |
+
* @var string
|
| 58 |
+
*/
|
| 59 |
+
const EC_FLAVOR_DYNAMIC = 'dynamic';
|
| 60 |
+
const EC_FLAVOR_STATIC = 'static';
|
| 61 |
+
const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
|
| 62 |
+
const EC_BUTTON_TYPE_MARK = 'ecmark';
|
| 63 |
+
const PAYMENT_MARK_37x23 = '37x23';
|
| 64 |
+
const PAYMENT_MARK_50x34 = '50x34';
|
| 65 |
+
const PAYMENT_MARK_60x38 = '60x38';
|
| 66 |
+
const PAYMENT_MARK_180x113 = '180x113';
|
| 67 |
+
|
| 68 |
+
const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Payment actions
|
| 72 |
+
* @var string
|
| 73 |
+
*/
|
| 74 |
+
const PAYMENT_ACTION_SALE = 'Sale';
|
| 75 |
+
const PAYMENT_ACTION_ORDER = 'Order';
|
| 76 |
+
const PAYMENT_ACTION_AUTH = 'Authorization';
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Authorization amounts for Account Verification
|
| 80 |
+
*
|
| 81 |
+
* @deprecated since 1.6.2.0
|
| 82 |
+
* @var int
|
| 83 |
+
*/
|
| 84 |
+
const AUTHORIZATION_AMOUNT_ZERO = 0;
|
| 85 |
+
const AUTHORIZATION_AMOUNT_ONE = 1;
|
| 86 |
+
const AUTHORIZATION_AMOUNT_FULL = 2;
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Require Billing Address
|
| 90 |
+
* @var int
|
| 91 |
+
*/
|
| 92 |
+
const REQUIRE_BILLING_ADDRESS_NO = 0;
|
| 93 |
+
const REQUIRE_BILLING_ADDRESS_ALL = 1;
|
| 94 |
+
const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Fraud management actions
|
| 98 |
+
* @var string
|
| 99 |
+
*/
|
| 100 |
+
const FRAUD_ACTION_ACCEPT = 'Acept';
|
| 101 |
+
const FRAUD_ACTION_DENY = 'Deny';
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* Refund types
|
| 105 |
+
* @var string
|
| 106 |
+
*/
|
| 107 |
+
const REFUND_TYPE_FULL = 'Full';
|
| 108 |
+
const REFUND_TYPE_PARTIAL = 'Partial';
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* Express Checkout flows
|
| 112 |
+
* @var string
|
| 113 |
+
*/
|
| 114 |
+
const EC_SOLUTION_TYPE_SOLE = 'Sole';
|
| 115 |
+
const EC_SOLUTION_TYPE_MARK = 'Mark';
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* PPMX method type from config.xml
|
| 119 |
+
* @var int
|
| 120 |
+
*/
|
| 121 |
+
const PPMX_METHOD_MENS = 1;
|
| 122 |
+
const PPMX_METHOD_NORM = 2;
|
| 123 |
+
const PPMX_METHOD_DEB = 3;
|
| 124 |
+
/**
|
| 125 |
+
* Payment data transfer methods (Standard)
|
| 126 |
+
*
|
| 127 |
+
* @var string
|
| 128 |
+
*/
|
| 129 |
+
const WPS_TRANSPORT_IPN = 'ipn';
|
| 130 |
+
const WPS_TRANSPORT_PDT = 'pdt';
|
| 131 |
+
const WPS_TRANSPORT_IPN_PDT = 'ipn_n_pdt';
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Billing Agreement Signup
|
| 135 |
+
*
|
| 136 |
+
* @var string
|
| 137 |
+
*/
|
| 138 |
+
const EC_BA_SIGNUP_AUTO = 'auto';
|
| 139 |
+
const EC_BA_SIGNUP_ASK = 'ask';
|
| 140 |
+
const EC_BA_SIGNUP_NEVER = 'never';
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Default URL for centinel API (PayPal Direct)
|
| 144 |
+
*
|
| 145 |
+
* @var string
|
| 146 |
+
*/
|
| 147 |
+
public $centinelDefaultApiUrl = 'https://paypal.cardinalcommerce.com/maps/txns.asp';
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* Current payment method code
|
| 151 |
+
* @var string
|
| 152 |
+
*/
|
| 153 |
+
protected $_methodCode = null;
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Current store id
|
| 157 |
+
*
|
| 158 |
+
* @var int
|
| 159 |
+
*/
|
| 160 |
+
protected $_storeId = null;
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Instructions for generating proper BN code
|
| 164 |
+
*
|
| 165 |
+
* @var array
|
| 166 |
+
*/
|
| 167 |
+
protected $_buildNotationPPMap = array(
|
| 168 |
+
'paypalmx' => 'ppmx',
|
| 169 |
+
'paypalmx_standard' => 'WPS',
|
| 170 |
+
'paypalmx_express' => 'EC',
|
| 171 |
+
'paypalmx_direct' => 'DP',
|
| 172 |
+
'paypaluk_express' => 'EC',
|
| 173 |
+
'paypaluk_direct' => 'DP',
|
| 174 |
+
);
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Style system config map (Express Checkout)
|
| 178 |
+
*
|
| 179 |
+
* @var array
|
| 180 |
+
*/
|
| 181 |
+
protected $_ecStyleConfigMap = array(
|
| 182 |
+
'page_style' => 'page_style',
|
| 183 |
+
'paypalmx_hdrimg' => 'hdrimg',
|
| 184 |
+
'paypalmx_hdrbordercolor' => 'hdrbordercolor',
|
| 185 |
+
'paypalmx_hdrbackcolor' => 'hdrbackcolor',
|
| 186 |
+
'paypalmx_payflowcolor' => 'payflowcolor',
|
| 187 |
+
);
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* Currency codes supported by PayPal methods
|
| 191 |
+
*
|
| 192 |
+
* @var array
|
| 193 |
+
*/
|
| 194 |
+
protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN',
|
| 195 |
+
'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB');
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Merchant country supported by PayPal
|
| 199 |
+
*
|
| 200 |
+
* @var array
|
| 201 |
+
*/
|
| 202 |
+
protected $_supportedCountryCodes = array('MX');
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* Buyer country supported by PayPal
|
| 206 |
+
*
|
| 207 |
+
* @var array
|
| 208 |
+
*/
|
| 209 |
+
protected $_supportedBuyerCountryCodes = array('MX ');
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* Locale codes supported by misc images (marks, shortcuts etc)
|
| 213 |
+
*
|
| 214 |
+
* @var array
|
| 215 |
+
* @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK
|
| 216 |
+
*/
|
| 217 |
+
protected $_supportedImageLocales = array( 'es_ES',
|
| 218 |
+
);
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Set method and store id, if specified
|
| 222 |
+
*
|
| 223 |
+
* @param array $params
|
| 224 |
+
*/
|
| 225 |
+
public function __construct($params = array())
|
| 226 |
+
{
|
| 227 |
+
if ($params) {
|
| 228 |
+
$method = array_shift($params);
|
| 229 |
+
$this->setMethod($method);
|
| 230 |
+
if ($params) {
|
| 231 |
+
$storeId = array_shift($params);
|
| 232 |
+
$this->setStoreId($storeId);
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Method code setter
|
| 239 |
+
*
|
| 240 |
+
* @param string|Mage_Payment_Model_Method_Abstract $method
|
| 241 |
+
* @return Mage_Paypal_Model_Config
|
| 242 |
+
*/
|
| 243 |
+
public function setMethod($method)
|
| 244 |
+
{
|
| 245 |
+
if ($method instanceof Mage_Payment_Model_Method_Abstract) {
|
| 246 |
+
$this->_methodCode = $method->getCode();
|
| 247 |
+
} elseif (is_string($method)) {
|
| 248 |
+
$this->_methodCode = $method;
|
| 249 |
+
}
|
| 250 |
+
return $this;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Payment method instance code getter
|
| 255 |
+
*
|
| 256 |
+
* @return string
|
| 257 |
+
*/
|
| 258 |
+
public function getMethodCode()
|
| 259 |
+
{
|
| 260 |
+
return $this->_methodCode;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* Store ID setter
|
| 265 |
+
*
|
| 266 |
+
* @param int $storeId
|
| 267 |
+
* @return Mage_Paypal_Model_Config
|
| 268 |
+
*/
|
| 269 |
+
public function setStoreId($storeId)
|
| 270 |
+
{
|
| 271 |
+
$this->_storeId = (int)$storeId;
|
| 272 |
+
return $this;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Check whether method active in configuration and supported for merchant country or not
|
| 277 |
+
*
|
| 278 |
+
* @param string $method Method code
|
| 279 |
+
* @return bool
|
| 280 |
+
*/
|
| 281 |
+
public function isMethodActive($method)
|
| 282 |
+
{
|
| 283 |
+
if ($this->isMethodSupportedForCountry($method)
|
| 284 |
+
&& Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId)
|
| 285 |
+
) {
|
| 286 |
+
return true;
|
| 287 |
+
}
|
| 288 |
+
return false;
|
| 289 |
+
}
|
| 290 |
+
public function isContextAvailable($contextpos = null,$method = null){
|
| 291 |
+
if(!$contextpos){
|
| 292 |
+
return false;
|
| 293 |
+
}
|
| 294 |
+
if ($method === null) {
|
| 295 |
+
$method = $this->getMethodCode();
|
| 296 |
+
}
|
| 297 |
+
if (Mage::getStoreConfigFlag("payment/{$method}/{$contextpos}", $this->_storeId)) {
|
| 298 |
+
return true;
|
| 299 |
+
}
|
| 300 |
+
return false;
|
| 301 |
+
|
| 302 |
+
}
|
| 303 |
+
/**
|
| 304 |
+
* Check whether method available for checkout or not
|
| 305 |
+
* Logic based on merchant country, methods dependence
|
| 306 |
+
*
|
| 307 |
+
* @param string $method Method code
|
| 308 |
+
* @return bool
|
| 309 |
+
*/
|
| 310 |
+
public function isMethodAvailable($methodCode = null)
|
| 311 |
+
{
|
| 312 |
+
|
| 313 |
+
if ($methodCode === null) {
|
| 314 |
+
$methodCode = $this->getMethodCode();
|
| 315 |
+
}
|
| 316 |
+
/*
|
| 317 |
+
if(($methodCode == self::METHOD_PPMX_DEBITO || $methodCode == self::METHOD_PPMX_MENSUALIDADES) && !$this->isMethodActive(self::METHOD_PPMX)){
|
| 318 |
+
return false;
|
| 319 |
+
}*/
|
| 320 |
+
|
| 321 |
+
$result = true;
|
| 322 |
+
|
| 323 |
+
if (!$this->isMethodActive($methodCode)) {
|
| 324 |
+
$result = false;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
switch ($methodCode) {
|
| 328 |
+
case self::METHOD_PPMX:
|
| 329 |
+
break;
|
| 330 |
+
case self::METHOD_PPMX_DEBITO:
|
| 331 |
+
if ($this->isMethodActive(self::METHOD_PPMX)){
|
| 332 |
+
$result = false;
|
| 333 |
+
}
|
| 334 |
+
break;
|
| 335 |
+
case self::METHOD_PPMX_MENSUALIDADES:
|
| 336 |
+
if ($this->isMethodActive(self::METHOD_PPMX)){
|
| 337 |
+
$result = false;
|
| 338 |
+
}
|
| 339 |
+
break;
|
| 340 |
+
case self::METHOD_WPS:
|
| 341 |
+
if (!$this->businessAccount) {
|
| 342 |
+
$result = false;
|
| 343 |
+
break;
|
| 344 |
+
}
|
| 345 |
+
// check for direct payments dependence
|
| 346 |
+
if ($this->isMethodActive(self::METHOD_WPP_DIRECT)
|
| 347 |
+
|| $this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 348 |
+
$result = false;
|
| 349 |
+
}
|
| 350 |
+
break;
|
| 351 |
+
case self::METHOD_WPP_EXPRESS:
|
| 352 |
+
// check for direct payments dependence
|
| 353 |
+
if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 354 |
+
$result = false;
|
| 355 |
+
} elseif ($this->isMethodActive(self::METHOD_WPP_DIRECT)) {
|
| 356 |
+
$result = true;
|
| 357 |
+
}
|
| 358 |
+
break;
|
| 359 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 360 |
+
// check for direct payments dependence
|
| 361 |
+
if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 362 |
+
$result = true;
|
| 363 |
+
} elseif (!$this->isMethodActive(self::METHOD_WPP_PE_DIRECT)
|
| 364 |
+
&& !$this->isMethodActive(self::METHOD_PAYFLOWPRO)) {
|
| 365 |
+
$result = false;
|
| 366 |
+
}
|
| 367 |
+
break;
|
| 368 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 369 |
+
$result = $this->isWppApiAvailabe();
|
| 370 |
+
break;
|
| 371 |
+
case self::METHOD_WPP_DIRECT:
|
| 372 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 373 |
+
break;
|
| 374 |
+
}
|
| 375 |
+
return $result;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
/**
|
| 379 |
+
* Config field magic getter
|
| 380 |
+
* The specified key can be either in camelCase or under_score format
|
| 381 |
+
* Tries to map specified value according to set payment method code, into the configuration value
|
| 382 |
+
* Sets the values into public class parameters, to avoid redundant calls of this method
|
| 383 |
+
*
|
| 384 |
+
* @param string $key
|
| 385 |
+
* @return string|null
|
| 386 |
+
*/
|
| 387 |
+
public function __get($key)
|
| 388 |
+
{
|
| 389 |
+
$underscored = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $key));
|
| 390 |
+
$value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId);
|
| 391 |
+
$value = $this->_prepareValue($underscored, $value);
|
| 392 |
+
$this->$key = $value;
|
| 393 |
+
$this->$underscored = $value;
|
| 394 |
+
return $value;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
/**
|
| 398 |
+
* Perform additional config value preparation and return new value if needed
|
| 399 |
+
*
|
| 400 |
+
* @param string $key Underscored key
|
| 401 |
+
* @param string $value Old value
|
| 402 |
+
* @return string Modified value or old value
|
| 403 |
+
*/
|
| 404 |
+
protected function _prepareValue($key, $value)
|
| 405 |
+
{
|
| 406 |
+
// Always set payment action as "Sale" for Unilateral payments in EC
|
| 407 |
+
if ($key == 'payment_action'
|
| 408 |
+
&& $value != self::PAYMENT_ACTION_SALE
|
| 409 |
+
&& $this->shouldUseUnilateralPayments())
|
| 410 |
+
{
|
| 411 |
+
return self::PAYMENT_ACTION_SALE;
|
| 412 |
+
}
|
| 413 |
+
return $value;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* Return merchant country codes supported by PayPal
|
| 418 |
+
*
|
| 419 |
+
* @return array
|
| 420 |
+
*/
|
| 421 |
+
public function getSupportedMerchantCountryCodes()
|
| 422 |
+
{
|
| 423 |
+
return $this->_supportedCountryCodes;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
/**
|
| 427 |
+
* Return buyer country codes supported by PayPal
|
| 428 |
+
*
|
| 429 |
+
* @return array
|
| 430 |
+
*/
|
| 431 |
+
public function getSupportedBuyerCountryCodes()
|
| 432 |
+
{
|
| 433 |
+
return $this->_supportedBuyerCountryCodes;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
/**
|
| 437 |
+
* Return merchant country code, use default country if it not specified in General settings
|
| 438 |
+
*
|
| 439 |
+
* @return string
|
| 440 |
+
*/
|
| 441 |
+
public function getMerchantCountry()
|
| 442 |
+
{
|
| 443 |
+
$countryCode = Mage::getStoreConfig($this->_mapGeneralFieldset('merchant_country'), $this->_storeId);
|
| 444 |
+
if (!$countryCode) {
|
| 445 |
+
$countryCode = Mage::helper('core')->getDefaultCountry($this->_storeId);
|
| 446 |
+
}
|
| 447 |
+
return $countryCode;
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* Check whether method supported for specified country or not
|
| 452 |
+
* Use $_methodCode and merchant country by default
|
| 453 |
+
*
|
| 454 |
+
* @return bool
|
| 455 |
+
*/
|
| 456 |
+
public function isMethodSupportedForCountry($method = null, $countryCode = null)
|
| 457 |
+
{
|
| 458 |
+
if ($method === null) {
|
| 459 |
+
$method = $this->getMethodCode();
|
| 460 |
+
}
|
| 461 |
+
if ($countryCode === null) {
|
| 462 |
+
$countryCode = $this->getMerchantCountry();
|
| 463 |
+
}
|
| 464 |
+
$countryMethods = $this->getCountryMethods($countryCode);
|
| 465 |
+
if (in_array($method, $countryMethods)) {
|
| 466 |
+
return true;
|
| 467 |
+
}
|
| 468 |
+
return false;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
/**
|
| 472 |
+
* Return list of allowed methods for specified country iso code
|
| 473 |
+
*
|
| 474 |
+
* @param string $countryCode 2-letters iso code
|
| 475 |
+
* @return array
|
| 476 |
+
*/
|
| 477 |
+
public function getCountryMethods($countryCode = null)
|
| 478 |
+
{
|
| 479 |
+
$countryMethods = array(
|
| 480 |
+
'MX' => array(
|
| 481 |
+
self::METHOD_PPMX,
|
| 482 |
+
),
|
| 483 |
+
);
|
| 484 |
+
if ($countryCode === null) {
|
| 485 |
+
return $countryMethods;
|
| 486 |
+
}
|
| 487 |
+
return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods['other']; }
|
| 488 |
+
|
| 489 |
+
/**
|
| 490 |
+
* Get url for dispatching customer to express checkout start
|
| 491 |
+
*
|
| 492 |
+
* @param string $token
|
| 493 |
+
* @return string
|
| 494 |
+
*/
|
| 495 |
+
public function getExpressCheckoutStartUrl($token)
|
| 496 |
+
{
|
| 497 |
+
return $this->getPaypalUrl(array(
|
| 498 |
+
'cmd' => '_express-checkout',
|
| 499 |
+
'token' => $token,
|
| 500 |
+
));
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* Get url that allows to edit checkout details on paypal side
|
| 505 |
+
*
|
| 506 |
+
* @param $token
|
| 507 |
+
* @return string
|
| 508 |
+
*/
|
| 509 |
+
public function getExpressCheckoutEditUrl($token)
|
| 510 |
+
{
|
| 511 |
+
return $this->getPaypalUrl(array(
|
| 512 |
+
'cmd' => '_express-checkout',
|
| 513 |
+
'useraction' => 'continue',
|
| 514 |
+
'token' => $token,
|
| 515 |
+
));
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
/**
|
| 519 |
+
* Get url for additional actions that PayPal may require customer to do after placing the order.
|
| 520 |
+
* For instance, redirecting customer to bank for payment confirmation.
|
| 521 |
+
*
|
| 522 |
+
* @param string $token
|
| 523 |
+
* @return string
|
| 524 |
+
*/
|
| 525 |
+
public function getExpressCheckoutCompleteUrl($token)
|
| 526 |
+
{
|
| 527 |
+
return $this->getPaypalUrl(array(
|
| 528 |
+
'cmd' => '_complete-express-checkout',
|
| 529 |
+
'token' => $token,
|
| 530 |
+
));
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
/**
|
| 534 |
+
* Retrieve url for initialization of billing agreement
|
| 535 |
+
*
|
| 536 |
+
* @param string $token
|
| 537 |
+
* @return string
|
| 538 |
+
*/
|
| 539 |
+
public function getStartBillingAgreementUrl($token)
|
| 540 |
+
{
|
| 541 |
+
return $this->getPaypalUrl(array(
|
| 542 |
+
'cmd' => '_customer-billing-agreement',
|
| 543 |
+
'token' => $token,
|
| 544 |
+
));
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
/**
|
| 548 |
+
* PayPal web URL generic getter
|
| 549 |
+
*
|
| 550 |
+
* @param array $params
|
| 551 |
+
* @return string
|
| 552 |
+
*/
|
| 553 |
+
public function getPaypalUrl(array $params = array())
|
| 554 |
+
{
|
| 555 |
+
return sprintf('https://www.%spaypal.com/webscr%s',
|
| 556 |
+
$this->sandboxFlag ? 'sandbox.' : '',
|
| 557 |
+
$params ? '?' . http_build_query($params) : ''
|
| 558 |
+
);
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
/**
|
| 562 |
+
* Whether Express Checkout button should be rendered dynamically
|
| 563 |
+
*
|
| 564 |
+
* @return bool
|
| 565 |
+
*/
|
| 566 |
+
public function areButtonsDynamic()
|
| 567 |
+
{
|
| 568 |
+
return true;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
/**
|
| 572 |
+
* Express checkout shortcut pic URL getter
|
| 573 |
+
* PayPal will ignore "pal", if there is no total amount specified
|
| 574 |
+
*
|
| 575 |
+
* @param string $localeCode
|
| 576 |
+
* @param float $orderTotal
|
| 577 |
+
* @param string $pal encrypted summary about merchant
|
| 578 |
+
* @see Paypal_Model_Api_Nvp::callGetPalDetails()
|
| 579 |
+
*/
|
| 580 |
+
public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null)
|
| 581 |
+
{
|
| 582 |
+
if ($this->areButtonsDynamic()) {
|
| 583 |
+
return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal);
|
| 584 |
+
}
|
| 585 |
+
if ($this->buttonType === self::EC_BUTTON_TYPE_MARK) {
|
| 586 |
+
return $this->getPaymentMarkImageUrl($localeCode);
|
| 587 |
+
}
|
| 588 |
+
return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif',
|
| 589 |
+
$this->_getSupportedLocaleCode($localeCode));
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
/**
|
| 593 |
+
* Get PayPal "mark" image URL
|
| 594 |
+
* Supposed to be used on payment methods selection
|
| 595 |
+
* $staticSize is applicable for static images only
|
| 596 |
+
*
|
| 597 |
+
* @param string $localeCode
|
| 598 |
+
* @param float $orderTotal
|
| 599 |
+
* @param string $pal
|
| 600 |
+
* @param string $staticSize
|
| 601 |
+
*/
|
| 602 |
+
public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null)
|
| 603 |
+
{
|
| 604 |
+
/*
|
| 605 |
+
if ($this->areButtonsDynamic()) {
|
| 606 |
+
return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal);
|
| 607 |
+
}*/
|
| 608 |
+
|
| 609 |
+
if (null === $staticSize) {
|
| 610 |
+
$staticSize = $this->paymentMarkSize;
|
| 611 |
+
}
|
| 612 |
+
switch ($staticSize) {
|
| 613 |
+
case self::PAYMENT_MARK_37x23:
|
| 614 |
+
case self::PAYMENT_MARK_50x34:
|
| 615 |
+
case self::PAYMENT_MARK_60x38:
|
| 616 |
+
case self::PAYMENT_MARK_180x113:
|
| 617 |
+
break;
|
| 618 |
+
default:
|
| 619 |
+
$staticSize = self::PAYMENT_MARK_37x23;
|
| 620 |
+
}
|
| 621 |
+
return sprintf('https://www.paypal.com/%s/i/logo/PayPal_mark_%s.gif',
|
| 622 |
+
$this->_getSupportedLocaleCode($localeCode), $staticSize);
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
/**
|
| 626 |
+
* Get "What Is PayPal" localized URL
|
| 627 |
+
* Supposed to be used with "mark" as popup window
|
| 628 |
+
*
|
| 629 |
+
* @param Mage_Core_Model_Locale $locale
|
| 630 |
+
*/
|
| 631 |
+
public function getPaymentMarkWhatIsPaypalUrl(Mage_Core_Model_Locale $locale = null)
|
| 632 |
+
{
|
| 633 |
+
$countryCode = 'US';
|
| 634 |
+
if (null !== $locale) {
|
| 635 |
+
$shouldEmulate = (null !== $this->_storeId) && (Mage::app()->getStore()->getId() != $this->_storeId);
|
| 636 |
+
if ($shouldEmulate) {
|
| 637 |
+
$locale->emulate($this->_storeId);
|
| 638 |
+
}
|
| 639 |
+
$countryCode = $locale->getLocale()->getRegion();
|
| 640 |
+
if ($shouldEmulate) {
|
| 641 |
+
$locale->revert();
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
return sprintf('https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
|
| 645 |
+
strtolower($countryCode)
|
| 646 |
+
);
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
* Getter for Solution banner images
|
| 651 |
+
*
|
| 652 |
+
* @param string $localeCode
|
| 653 |
+
* @param bool $isVertical
|
| 654 |
+
* @param bool $isEcheck
|
| 655 |
+
*/
|
| 656 |
+
public function getSolutionImageUrl($localeCode, $isVertical = false, $isEcheck = false)
|
| 657 |
+
{
|
| 658 |
+
return sprintf('https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif',
|
| 659 |
+
$this->_getSupportedLocaleCode($localeCode),
|
| 660 |
+
$isVertical ? 'vertical' : 'horizontal', $isEcheck ? 'eCheck' : ''
|
| 661 |
+
);
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
/**
|
| 665 |
+
* Getter for Payment form logo images
|
| 666 |
+
*
|
| 667 |
+
* @param string $localeCode
|
| 668 |
+
*/
|
| 669 |
+
public function getPaymentFormLogoUrl($localeCode)
|
| 670 |
+
{
|
| 671 |
+
$locale = $this->_getSupportedLocaleCode($localeCode);
|
| 672 |
+
|
| 673 |
+
$imageType = 'logo';
|
| 674 |
+
$domain = 'paypal.com';
|
| 675 |
+
list (,$country) = explode('_', $locale);
|
| 676 |
+
$countryPrefix = $country . '/';
|
| 677 |
+
|
| 678 |
+
switch ($locale) {
|
| 679 |
+
case 'en_GB':
|
| 680 |
+
$imageName = 'horizontal_solution_PP';
|
| 681 |
+
$imageType = 'bnr';
|
| 682 |
+
$countryPrefix = '';
|
| 683 |
+
break;
|
| 684 |
+
case 'de_DE':
|
| 685 |
+
$imageName = 'lockbox_150x47';
|
| 686 |
+
break;
|
| 687 |
+
case 'fr_FR':
|
| 688 |
+
$imageName = 'bnr_horizontal_solution_PP_327wx80h';
|
| 689 |
+
$imageType = 'bnr';
|
| 690 |
+
$locale = 'en_US';
|
| 691 |
+
$domain = 'paypalobjects.com';
|
| 692 |
+
break;
|
| 693 |
+
case 'it_IT':
|
| 694 |
+
$imageName = 'bnr_horizontal_solution_PP_178wx80h';
|
| 695 |
+
$imageType = 'bnr';
|
| 696 |
+
$domain = 'paypalobjects.com';
|
| 697 |
+
break;
|
| 698 |
+
default:
|
| 699 |
+
$imageName='PayPal_mark_60x38';
|
| 700 |
+
$countryPrefix = '';
|
| 701 |
+
break;
|
| 702 |
+
}
|
| 703 |
+
return sprintf('https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName);
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
/**
|
| 707 |
+
* Return supported types for PayPal logo
|
| 708 |
+
*
|
| 709 |
+
* @return array
|
| 710 |
+
*/
|
| 711 |
+
public function getAdditionalOptionsLogoTypes()
|
| 712 |
+
{
|
| 713 |
+
return array(
|
| 714 |
+
'wePrefer_150x60' => Mage::helper('paypalmx')->__('We prefer PayPal (150 X 60)'),
|
| 715 |
+
'wePrefer_150x40' => Mage::helper('paypalmx')->__('We prefer PayPal (150 X 40)'),
|
| 716 |
+
'nowAccepting_150x60' => Mage::helper('paypalmx')->__('Now accepting PayPal (150 X 60)'),
|
| 717 |
+
'nowAccepting_150x40' => Mage::helper('paypalmx')->__('Now accepting PayPal (150 X 40)'),
|
| 718 |
+
'paymentsBy_150x60' => Mage::helper('paypalmx')->__('Payments by PayPal (150 X 60)'),
|
| 719 |
+
'paymentsBy_150x40' => Mage::helper('paypalmx')->__('Payments by PayPal (150 X 40)'),
|
| 720 |
+
'shopNowUsing_150x60' => Mage::helper('paypalmx')->__('Shop now using (150 X 60)'),
|
| 721 |
+
'shopNowUsing_150x40' => Mage::helper('paypalmx')->__('Shop now using (150 X 40)'),
|
| 722 |
+
);
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
/**
|
| 726 |
+
* Return PayPal logo URL with additional options
|
| 727 |
+
*
|
| 728 |
+
* @param string $localeCode Supported locale code
|
| 729 |
+
* @param string $type One of supported logo types
|
| 730 |
+
* @return string|bool Logo Image URL or false if logo disabled in configuration
|
| 731 |
+
*/
|
| 732 |
+
public function getAdditionalOptionsLogoUrl($localeCode, $type = false)
|
| 733 |
+
{
|
| 734 |
+
$configType = Mage::getStoreConfig($this->_mapGenericStyleFieldset('logo'), $this->_storeId);
|
| 735 |
+
if (!$configType) {
|
| 736 |
+
return false;
|
| 737 |
+
}
|
| 738 |
+
$type = $type ? $type : $configType;
|
| 739 |
+
$locale = $this->_getSupportedLocaleCode($localeCode);
|
| 740 |
+
$supportedTypes = array_keys($this->getAdditionalOptionsLogoTypes());
|
| 741 |
+
if (!in_array($type, $supportedTypes)) {
|
| 742 |
+
$type = self::DEFAULT_LOGO_TYPE;
|
| 743 |
+
}
|
| 744 |
+
return sprintf('https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale, $type);
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
/**
|
| 748 |
+
* BN code getter
|
| 749 |
+
*
|
| 750 |
+
* @param string $countryCode ISO 3166-1
|
| 751 |
+
*/
|
| 752 |
+
public function getBuildNotationCode($countryCode = null)
|
| 753 |
+
{
|
| 754 |
+
$product = 'WPP';
|
| 755 |
+
if ($this->_methodCode && isset($this->_buildNotationPPMap[$this->_methodCode])) {
|
| 756 |
+
$product = $this->_buildNotationPPMap[$this->_methodCode];
|
| 757 |
+
}
|
| 758 |
+
if (null === $countryCode) {
|
| 759 |
+
$countryCode = $this->_matchBnCountryCode($this->getMerchantCountry());
|
| 760 |
+
}
|
| 761 |
+
if ($countryCode) {
|
| 762 |
+
$countryCode = '_' . $countryCode;
|
| 763 |
+
}
|
| 764 |
+
return sprintf('Varien_Cart_%s%s', $product, $countryCode);
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
/**
|
| 768 |
+
* Express Checkout button "flavors" source getter
|
| 769 |
+
*
|
| 770 |
+
* @return array
|
| 771 |
+
*/
|
| 772 |
+
public function getExpressCheckoutButtonFlavors()
|
| 773 |
+
{
|
| 774 |
+
return array(
|
| 775 |
+
self::EC_FLAVOR_DYNAMIC => Mage::helper('paypalmx')->__('Dynamic'),
|
| 776 |
+
self::EC_FLAVOR_STATIC => Mage::helper('paypalmx')->__('Static'),
|
| 777 |
+
);
|
| 778 |
+
}
|
| 779 |
+
|
| 780 |
+
/**
|
| 781 |
+
* Express Checkout button types source getter
|
| 782 |
+
*
|
| 783 |
+
* @return array
|
| 784 |
+
*/
|
| 785 |
+
public function getExpressCheckoutButtonTypes()
|
| 786 |
+
{
|
| 787 |
+
return array(
|
| 788 |
+
self::EC_BUTTON_TYPE_SHORTCUT => Mage::helper('paypalmx')->__('Shortcut'),
|
| 789 |
+
self::EC_BUTTON_TYPE_MARK => Mage::helper('paypalmx')->__('Acceptance Mark Image'),
|
| 790 |
+
);
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
/**
|
| 794 |
+
* Payment actions source getter
|
| 795 |
+
*
|
| 796 |
+
* @return array
|
| 797 |
+
*/
|
| 798 |
+
public function getPaymentActions()
|
| 799 |
+
{
|
| 800 |
+
$paymentActions = array(
|
| 801 |
+
self::PAYMENT_ACTION_AUTH => Mage::helper('paypalmx')->__('Authorization'),
|
| 802 |
+
self::PAYMENT_ACTION_SALE => Mage::helper('paypalmx')->__('Sale')
|
| 803 |
+
);
|
| 804 |
+
if (!is_null($this->_methodCode) && ($this->_methodCode == self::METHOD_PPMX ||$this->_methodCode == self::METHOD_PPMX_DEBITO ||$this->_methodCode == self::METHOD_PPMX_MENSUALIDADES)) {
|
| 805 |
+
$paymentActions[self::PAYMENT_ACTION_ORDER] = Mage::helper('paypalmx')->__('Order');
|
| 806 |
+
}
|
| 807 |
+
return $paymentActions;
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
/**
|
| 811 |
+
* Require Billing Address source getter
|
| 812 |
+
*
|
| 813 |
+
* @return array
|
| 814 |
+
*/
|
| 815 |
+
public function getRequireBillingAddressOptions()
|
| 816 |
+
{
|
| 817 |
+
return array(
|
| 818 |
+
self::REQUIRE_BILLING_ADDRESS_ALL => Mage::helper('paypalmx')->__('Yes'),
|
| 819 |
+
self::REQUIRE_BILLING_ADDRESS_NO => Mage::helper('paypalmx')->__('No'),
|
| 820 |
+
self::REQUIRE_BILLING_ADDRESS_VIRTUAL => Mage::helper('paypalmx')->__('For Virtual Quotes Only'),
|
| 821 |
+
);
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
/**
|
| 825 |
+
* Mapper from PayPal-specific payment actions to Magento payment actions
|
| 826 |
+
*
|
| 827 |
+
* @return string|null
|
| 828 |
+
*/
|
| 829 |
+
public function getPaymentAction()
|
| 830 |
+
{
|
| 831 |
+
switch ($this->paymentAction) {
|
| 832 |
+
case self::PAYMENT_ACTION_AUTH:
|
| 833 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
| 834 |
+
case self::PAYMENT_ACTION_SALE:
|
| 835 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
| 836 |
+
case self::PAYMENT_ACTION_ORDER:
|
| 837 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
|
| 838 |
+
}
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
/**
|
| 842 |
+
* Returns array of possible Authorization Amounts for Account Verification
|
| 843 |
+
*
|
| 844 |
+
* @deprecated since 1.6.2.0
|
| 845 |
+
* @return array
|
| 846 |
+
*/
|
| 847 |
+
public function getAuthorizationAmounts()
|
| 848 |
+
{
|
| 849 |
+
return array();
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
/**
|
| 853 |
+
* Express Checkout "solution types" source getter
|
| 854 |
+
* "sole" = "Express Checkout for Auctions" - PayPal allows guest checkout
|
| 855 |
+
* "mark" = "Normal Express Checkout" - PayPal requires to checkout with PayPal buyer account only
|
| 856 |
+
*
|
| 857 |
+
* @return array
|
| 858 |
+
*/
|
| 859 |
+
public function getExpressCheckoutSolutionTypes()
|
| 860 |
+
{
|
| 861 |
+
return array(
|
| 862 |
+
self::EC_SOLUTION_TYPE_SOLE => Mage::helper('paypalmx')->__('Yes'),
|
| 863 |
+
self::EC_SOLUTION_TYPE_MARK => Mage::helper('paypalmx')->__('No'),
|
| 864 |
+
);
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
/**
|
| 868 |
+
* Retrieve express checkout billing agreement signup options
|
| 869 |
+
*
|
| 870 |
+
* @return array
|
| 871 |
+
*/
|
| 872 |
+
public function getExpressCheckoutBASignupOptions()
|
| 873 |
+
{
|
| 874 |
+
return array(
|
| 875 |
+
self::EC_BA_SIGNUP_AUTO => Mage::helper('paypalmx')->__('Auto'),
|
| 876 |
+
self::EC_BA_SIGNUP_ASK => Mage::helper('paypalmx')->__('Ask Customer'),
|
| 877 |
+
self::EC_BA_SIGNUP_NEVER => Mage::helper('paypalmx')->__('Never')
|
| 878 |
+
);
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
/**
|
| 882 |
+
* Whether to ask customer to create billing agreements
|
| 883 |
+
* Unilateral payments are incompatible with the billing agreements
|
| 884 |
+
*
|
| 885 |
+
* @return bool
|
| 886 |
+
*/
|
| 887 |
+
public function shouldAskToCreateBillingAgreement()
|
| 888 |
+
{
|
| 889 |
+
return ($this->allow_ba_signup === self::EC_BA_SIGNUP_ASK) && !$this->shouldUseUnilateralPayments();
|
| 890 |
+
}
|
| 891 |
+
|
| 892 |
+
/**
|
| 893 |
+
* Check whether only Unilateral payments (Accelerated Boarding) possible for Express method or not
|
| 894 |
+
*
|
| 895 |
+
* @return bool
|
| 896 |
+
*/
|
| 897 |
+
public function shouldUseUnilateralPayments()
|
| 898 |
+
{
|
| 899 |
+
return $this->business_account && !$this->isWppApiAvailabe();
|
| 900 |
+
}
|
| 901 |
+
|
| 902 |
+
/**
|
| 903 |
+
* Check whether WPP API credentials are available for this method
|
| 904 |
+
*
|
| 905 |
+
* @return bool
|
| 906 |
+
*/
|
| 907 |
+
public function isWppApiAvailabe()
|
| 908 |
+
{
|
| 909 |
+
return $this->api_username && $this->api_password && ($this->api_signature || $this->api_cert);
|
| 910 |
+
}
|
| 911 |
+
|
| 912 |
+
/**
|
| 913 |
+
* Payment data delivery methods getter for PayPal Standard
|
| 914 |
+
*
|
| 915 |
+
* @return array
|
| 916 |
+
*/
|
| 917 |
+
public function getWpsPaymentDeliveryMethods()
|
| 918 |
+
{
|
| 919 |
+
return array(
|
| 920 |
+
self::WPS_TRANSPORT_IPN => Mage::helper('adminhtml')->__('IPN (Instant Payment Notification) Only'),
|
| 921 |
+
// not supported yet:
|
| 922 |
+
// self::WPS_TRANSPORT_PDT => Mage::helper('adminhtml')->__('PDT (Payment Data Transfer) Only'),
|
| 923 |
+
// self::WPS_TRANSPORT_IPN_PDT => Mage::helper('adminhtml')->__('Both IPN and PDT'),
|
| 924 |
+
);
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
/**
|
| 928 |
+
* Return list of supported credit card types by Paypal Direct gateway
|
| 929 |
+
*
|
| 930 |
+
* @return array
|
| 931 |
+
*/
|
| 932 |
+
public function getWppCcTypesAsOptionArray()
|
| 933 |
+
{
|
| 934 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'SM', 'SO', 'DI'));
|
| 935 |
+
return $model->toOptionArray();
|
| 936 |
+
}
|
| 937 |
+
|
| 938 |
+
/**
|
| 939 |
+
* Return list of supported credit card types by Paypal Direct (Payflow Edition) gateway
|
| 940 |
+
*
|
| 941 |
+
* @return array
|
| 942 |
+
*/
|
| 943 |
+
public function getWppPeCcTypesAsOptionArray()
|
| 944 |
+
{
|
| 945 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('VI', 'MC', 'SM', 'SO', 'OT', 'AE'));
|
| 946 |
+
return $model->toOptionArray();
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
/**
|
| 950 |
+
* Return list of supported credit card types by Payflow Pro gateway
|
| 951 |
+
*
|
| 952 |
+
* @return array
|
| 953 |
+
*/
|
| 954 |
+
public function getPayflowproCcTypesAsOptionArray()
|
| 955 |
+
{
|
| 956 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'JCB', 'DI'));
|
| 957 |
+
return $model->toOptionArray();
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
/**
|
| 961 |
+
* Check whether the specified payment method is a CC-based one
|
| 962 |
+
*
|
| 963 |
+
* @param string $code
|
| 964 |
+
* @return bool
|
| 965 |
+
*/
|
| 966 |
+
public static function getIsCreditCardMethod($code)
|
| 967 |
+
{
|
| 968 |
+
switch ($code) {
|
| 969 |
+
case self::METHOD_WPP_DIRECT:
|
| 970 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 971 |
+
case self::METHOD_PAYFLOWPRO:
|
| 972 |
+
case self::METHOD_PAYFLOWLINK:
|
| 973 |
+
case self::METHOD_PAYFLOWADVANCED:
|
| 974 |
+
case self::METHOD_HOSTEDPRO:
|
| 975 |
+
return true;
|
| 976 |
+
}
|
| 977 |
+
return false;
|
| 978 |
+
}
|
| 979 |
+
|
| 980 |
+
/**
|
| 981 |
+
* Check whether specified currency code is supported
|
| 982 |
+
*
|
| 983 |
+
* @param string $code
|
| 984 |
+
* @return bool
|
| 985 |
+
*/
|
| 986 |
+
public function isCurrencyCodeSupported($code)
|
| 987 |
+
{
|
| 988 |
+
if (in_array($code, $this->_supportedCurrencyCodes)) {
|
| 989 |
+
return true;
|
| 990 |
+
}
|
| 991 |
+
if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') {
|
| 992 |
+
return true;
|
| 993 |
+
}
|
| 994 |
+
if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') {
|
| 995 |
+
return true;
|
| 996 |
+
}
|
| 997 |
+
return false;
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
/**
|
| 1001 |
+
* Export page style current settings to specified object
|
| 1002 |
+
*
|
| 1003 |
+
* @param Varien_Object $to
|
| 1004 |
+
*/
|
| 1005 |
+
public function exportExpressCheckoutStyleSettings(Varien_Object $to)
|
| 1006 |
+
{
|
| 1007 |
+
foreach ($this->_ecStyleConfigMap as $key => $exportKey) {
|
| 1008 |
+
if ($this->$key) {
|
| 1009 |
+
$to->setData($exportKey, $this->$key);
|
| 1010 |
+
}
|
| 1011 |
+
}
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
/**
|
| 1015 |
+
* Dynamic PayPal image URL getter
|
| 1016 |
+
* Also can render dynamic Acceptance Mark
|
| 1017 |
+
*
|
| 1018 |
+
* @param string $type
|
| 1019 |
+
* @param string $localeCode
|
| 1020 |
+
* @param float $orderTotal
|
| 1021 |
+
* @param string $pal
|
| 1022 |
+
*/
|
| 1023 |
+
protected function _getDynamicImageUrl($type, $localeCode, $orderTotal, $pal)
|
| 1024 |
+
{
|
| 1025 |
+
$params = array(
|
| 1026 |
+
'cmd' => '_dynamic-image',
|
| 1027 |
+
'buttontype' => $type,
|
| 1028 |
+
'locale' => $this->_getSupportedLocaleCode($localeCode),
|
| 1029 |
+
);
|
| 1030 |
+
if ($orderTotal) {
|
| 1031 |
+
$params['ordertotal'] = sprintf('%.2F', $orderTotal);
|
| 1032 |
+
if ($pal) {
|
| 1033 |
+
$params['pal'] = $pal;
|
| 1034 |
+
}
|
| 1035 |
+
}
|
| 1036 |
+
return sprintf('https://fpdbs%s.paypal.com/dynamicimageweb?%s',
|
| 1037 |
+
$this->sandboxFlag ? '.sandbox' : '', http_build_query($params)
|
| 1038 |
+
);
|
| 1039 |
+
}
|
| 1040 |
+
|
| 1041 |
+
/**
|
| 1042 |
+
* Check whether specified locale code is supported. Fallback to en_US
|
| 1043 |
+
*
|
| 1044 |
+
* @param string $localeCode
|
| 1045 |
+
* @return string
|
| 1046 |
+
*/
|
| 1047 |
+
protected function _getSupportedLocaleCode($localeCode = null)
|
| 1048 |
+
{
|
| 1049 |
+
if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
|
| 1050 |
+
return 'es_ES';
|
| 1051 |
+
}
|
| 1052 |
+
return $localeCode;
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
/**
|
| 1056 |
+
* Map any supported payment method into a config path by specified field name
|
| 1057 |
+
*
|
| 1058 |
+
* @param string $fieldName
|
| 1059 |
+
* @return string|null
|
| 1060 |
+
*/
|
| 1061 |
+
protected function _getSpecificConfigPath($fieldName)
|
| 1062 |
+
{
|
| 1063 |
+
$path = null;
|
| 1064 |
+
switch ($this->_methodCode) {
|
| 1065 |
+
case self::METHOD_PPMX_DEBITO:
|
| 1066 |
+
case self::METHOD_PPMX_MENSUALIDADES:
|
| 1067 |
+
case self::METHOD_PPMX:
|
| 1068 |
+
$path = $this->_mapExpressFieldset($fieldName);
|
| 1069 |
+
break;
|
| 1070 |
+
case self::METHOD_WPP_EXPRESS:
|
| 1071 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 1072 |
+
$path = $this->_mapExpressFieldset($fieldName);
|
| 1073 |
+
break;
|
| 1074 |
+
case self::METHOD_WPP_DIRECT:
|
| 1075 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 1076 |
+
$path = $this->_mapDirectFieldset($fieldName);
|
| 1077 |
+
break;
|
| 1078 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 1079 |
+
case self::METHOD_HOSTEDPRO:
|
| 1080 |
+
$path = $this->_mapMethodFieldset($fieldName);
|
| 1081 |
+
break;
|
| 1082 |
+
}
|
| 1083 |
+
|
| 1084 |
+
if ($path === null) {
|
| 1085 |
+
switch ($this->_methodCode) {
|
| 1086 |
+
case self::METHOD_WPP_EXPRESS:
|
| 1087 |
+
case self::METHOD_WPP_DIRECT:
|
| 1088 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 1089 |
+
case self::METHOD_HOSTEDPRO:
|
| 1090 |
+
case self::METHOD_PPMX_DEBITO:
|
| 1091 |
+
case self::METHOD_PPMX_MENSUALIDADES:
|
| 1092 |
+
case self::METHOD_PPMX:
|
| 1093 |
+
$path = $this->_mapWppFieldset($fieldName);
|
| 1094 |
+
break;
|
| 1095 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 1096 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 1097 |
+
$path = $this->_mapWpukFieldset($fieldName);
|
| 1098 |
+
break;
|
| 1099 |
+
}
|
| 1100 |
+
}
|
| 1101 |
+
|
| 1102 |
+
if ($path === null) {
|
| 1103 |
+
$path = $this->_mapGeneralFieldset($fieldName);
|
| 1104 |
+
}
|
| 1105 |
+
if ($path === null) {
|
| 1106 |
+
$path = $this->_mapGenericStyleFieldset($fieldName);
|
| 1107 |
+
}
|
| 1108 |
+
return $path;
|
| 1109 |
+
}
|
| 1110 |
+
|
| 1111 |
+
/**
|
| 1112 |
+
* Check wheter specified country code is supported by build notation codes for specific countries
|
| 1113 |
+
*
|
| 1114 |
+
* @param $code
|
| 1115 |
+
* @return string|null
|
| 1116 |
+
*/
|
| 1117 |
+
private function _matchBnCountryCode($code)
|
| 1118 |
+
{
|
| 1119 |
+
switch ($code) {
|
| 1120 |
+
// GB == UK
|
| 1121 |
+
case 'GB':
|
| 1122 |
+
return 'UK';
|
| 1123 |
+
// Australia, Austria, Belgium, Canada, China, France, Germany, Hong Kong, Italy
|
| 1124 |
+
case 'AU': case 'AT': case 'BE': case 'CA': case 'CN': case 'FR': case 'DE': case 'HK': case 'IT':
|
| 1125 |
+
// Japan, Mexico, Netherlands, Poland, Singapore, Spain, Switzerland, United Kingdom, United States
|
| 1126 |
+
case 'JP': case 'MX': case 'NL': case 'PL': case 'SG': case 'ES': case 'CH': case 'UK': case 'US':
|
| 1127 |
+
return $code;
|
| 1128 |
+
}
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
/**
|
| 1132 |
+
* Map PayPal Standard config fields
|
| 1133 |
+
*
|
| 1134 |
+
* @param string $fieldName
|
| 1135 |
+
* @return string|null
|
| 1136 |
+
*/
|
| 1137 |
+
protected function _mapStandardFieldset($fieldName)
|
| 1138 |
+
{
|
| 1139 |
+
switch ($fieldName)
|
| 1140 |
+
{
|
| 1141 |
+
case 'line_items_summary':
|
| 1142 |
+
case 'sandbox_flag':
|
| 1143 |
+
return 'payment/' . self::METHOD_PPMX . "/{$fieldName}";
|
| 1144 |
+
default:
|
| 1145 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1146 |
+
}
|
| 1147 |
+
}
|
| 1148 |
+
|
| 1149 |
+
/**
|
| 1150 |
+
* Map PayPal Express config fields
|
| 1151 |
+
*
|
| 1152 |
+
* @param string $fieldName
|
| 1153 |
+
* @return string|null
|
| 1154 |
+
*/
|
| 1155 |
+
protected function _mapExpressFieldset($fieldName)
|
| 1156 |
+
{
|
| 1157 |
+
switch ($fieldName)
|
| 1158 |
+
{
|
| 1159 |
+
|
| 1160 |
+
case 'transfer_shipping_options':
|
| 1161 |
+
case 'solution_type':
|
| 1162 |
+
case 'visible_on_shipping':
|
| 1163 |
+
case 'mensualidades':
|
| 1164 |
+
case 'require_billing_address':
|
| 1165 |
+
case 'authorization_honor_period':
|
| 1166 |
+
case 'order_valid_period':
|
| 1167 |
+
case 'child_authorization_number':
|
| 1168 |
+
case 'allow_ba_signup':
|
| 1169 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1170 |
+
default:
|
| 1171 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1172 |
+
}
|
| 1173 |
+
}
|
| 1174 |
+
|
| 1175 |
+
function getIsMensualidadesActive(){
|
| 1176 |
+
return Mage::getStoreConfig($this->_getSpecificConfigPath('mensualidades'));
|
| 1177 |
+
}
|
| 1178 |
+
function getnoposah(){
|
| 1179 |
+
return $this->__get('method_type');
|
| 1180 |
+
}
|
| 1181 |
+
/**
|
| 1182 |
+
* Map PayPal Direct config fields
|
| 1183 |
+
*
|
| 1184 |
+
* @param string $fieldName
|
| 1185 |
+
* @return string|null
|
| 1186 |
+
*/
|
| 1187 |
+
protected function _mapDirectFieldset($fieldName)
|
| 1188 |
+
{
|
| 1189 |
+
switch ($fieldName)
|
| 1190 |
+
{
|
| 1191 |
+
case 'useccv':
|
| 1192 |
+
case 'centinel':
|
| 1193 |
+
case 'centinel_is_mode_strict':
|
| 1194 |
+
case 'centinel_api_url':
|
| 1195 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1196 |
+
default:
|
| 1197 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1198 |
+
}
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
/**
|
| 1202 |
+
* Map PayPal Website Payments Pro common config fields
|
| 1203 |
+
*
|
| 1204 |
+
* @param string $fieldName
|
| 1205 |
+
* @return string|null
|
| 1206 |
+
*/
|
| 1207 |
+
protected function _mapWppFieldset($fieldName)
|
| 1208 |
+
{
|
| 1209 |
+
switch ($fieldName)
|
| 1210 |
+
{
|
| 1211 |
+
case 'api_authentication':
|
| 1212 |
+
case 'api_username':
|
| 1213 |
+
case 'api_password':
|
| 1214 |
+
case 'api_signature':
|
| 1215 |
+
case 'api_cert':
|
| 1216 |
+
case 'sandbox_flag':
|
| 1217 |
+
case 'use_proxy':
|
| 1218 |
+
case 'proxy_host':
|
| 1219 |
+
case 'proxy_port':
|
| 1220 |
+
case 'button_flavor':
|
| 1221 |
+
return "paypalmx/ppmx/{$fieldName}";
|
| 1222 |
+
default:
|
| 1223 |
+
return null;
|
| 1224 |
+
}
|
| 1225 |
+
}
|
| 1226 |
+
|
| 1227 |
+
/**
|
| 1228 |
+
* Map PayPal Website Payments Pro common config fields
|
| 1229 |
+
*
|
| 1230 |
+
* @param string $fieldName
|
| 1231 |
+
* @return string|null
|
| 1232 |
+
*/
|
| 1233 |
+
protected function _mapWpukFieldset($fieldName)
|
| 1234 |
+
{
|
| 1235 |
+
$pathPrefix = 'paypalmx/wpuk';
|
| 1236 |
+
// Use PUMP credentials from Verisign for EC when Direct Payments are unavailable
|
| 1237 |
+
if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS
|
| 1238 |
+
&& !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT)) {
|
| 1239 |
+
$pathPrefix = 'payment/verisign';
|
| 1240 |
+
}
|
| 1241 |
+
switch ($fieldName) {
|
| 1242 |
+
case 'partner':
|
| 1243 |
+
case 'user':
|
| 1244 |
+
case 'vendor':
|
| 1245 |
+
case 'pwd':
|
| 1246 |
+
case 'sandbox_flag':
|
| 1247 |
+
case 'use_proxy':
|
| 1248 |
+
case 'proxy_host':
|
| 1249 |
+
case 'proxy_port':
|
| 1250 |
+
return $pathPrefix . '/' . $fieldName;
|
| 1251 |
+
default:
|
| 1252 |
+
return null;
|
| 1253 |
+
}
|
| 1254 |
+
}
|
| 1255 |
+
|
| 1256 |
+
/**
|
| 1257 |
+
* Map PayPal common style config fields
|
| 1258 |
+
*
|
| 1259 |
+
* @param string $fieldName
|
| 1260 |
+
* @return string|null
|
| 1261 |
+
*/
|
| 1262 |
+
protected function _mapGenericStyleFieldset($fieldName)
|
| 1263 |
+
{
|
| 1264 |
+
switch ($fieldName) {
|
| 1265 |
+
case 'logo':
|
| 1266 |
+
case 'page_style':
|
| 1267 |
+
case 'paypal_hdrimg':
|
| 1268 |
+
case 'paypal_hdrbackcolor':
|
| 1269 |
+
case 'paypal_hdrbordercolor':
|
| 1270 |
+
case 'paypal_payflowcolor':
|
| 1271 |
+
return "paypalmx/style/{$fieldName}";
|
| 1272 |
+
default:
|
| 1273 |
+
return null;
|
| 1274 |
+
}
|
| 1275 |
+
}
|
| 1276 |
+
|
| 1277 |
+
/**
|
| 1278 |
+
* Map PayPal General Settings
|
| 1279 |
+
*
|
| 1280 |
+
* @param string $fieldName
|
| 1281 |
+
* @return string|null
|
| 1282 |
+
*/
|
| 1283 |
+
protected function _mapGeneralFieldset($fieldName)
|
| 1284 |
+
{
|
| 1285 |
+
switch ($fieldName)
|
| 1286 |
+
{
|
| 1287 |
+
case 'business_account':
|
| 1288 |
+
case 'merchant_country':
|
| 1289 |
+
return "paypalmx/general/{$fieldName}";
|
| 1290 |
+
default:
|
| 1291 |
+
return null;
|
| 1292 |
+
}
|
| 1293 |
+
}
|
| 1294 |
+
|
| 1295 |
+
/**
|
| 1296 |
+
* Map PayPal General Settings
|
| 1297 |
+
*
|
| 1298 |
+
* @param string $fieldName
|
| 1299 |
+
* @return string|null
|
| 1300 |
+
*/
|
| 1301 |
+
protected function _mapMethodFieldset($fieldName)
|
| 1302 |
+
{
|
| 1303 |
+
|
| 1304 |
+
if (!$this->_methodCode) {
|
| 1305 |
+
return null;
|
| 1306 |
+
}
|
| 1307 |
+
switch ($fieldName)
|
| 1308 |
+
{
|
| 1309 |
+
case 'sort_order':
|
| 1310 |
+
case 'active':
|
| 1311 |
+
case 'title':
|
| 1312 |
+
case 'payment_action':
|
| 1313 |
+
case 'allowspecific':
|
| 1314 |
+
case 'specificcountry':
|
| 1315 |
+
case 'line_items_enabled':
|
| 1316 |
+
case 'cctypes':
|
| 1317 |
+
case 'debug':
|
| 1318 |
+
case 'method_type':
|
| 1319 |
+
case 'verify_peer':
|
| 1320 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1321 |
+
default:
|
| 1322 |
+
return null;
|
| 1323 |
+
}
|
| 1324 |
+
}
|
| 1325 |
+
|
| 1326 |
+
/**
|
| 1327 |
+
* Payment API authentication methods source getter
|
| 1328 |
+
*
|
| 1329 |
+
* @return array
|
| 1330 |
+
*/
|
| 1331 |
+
public function getApiAuthenticationMethods()
|
| 1332 |
+
{
|
| 1333 |
+
return array(
|
| 1334 |
+
'0' => Mage::helper('paypalmx')->__('API Signature'),
|
| 1335 |
+
'1' => Mage::helper('paypalmx')->__('API Certificate')
|
| 1336 |
+
);
|
| 1337 |
+
}
|
| 1338 |
+
|
| 1339 |
+
/**
|
| 1340 |
+
* Api certificate getter
|
| 1341 |
+
*
|
| 1342 |
+
* @return string
|
| 1343 |
+
*/
|
| 1344 |
+
public function getApiCertificate()
|
| 1345 |
+
{
|
| 1346 |
+
$websiteId = Mage::app()->getStore($this->_storeId)->getWebsiteId();
|
| 1347 |
+
return Mage::getModel('paypalmx/cert')->loadByWebsite($websiteId, false)->getCertPath();
|
| 1348 |
+
}
|
| 1349 |
+
}
|
| 1350 |
+
|
app/code/community/Ebcomm/PaypalMx/Model/Debito2.php
ADDED
|
@@ -0,0 +1,685 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* PayPal Express Module
|
| 6 |
+
*/
|
| 7 |
+
class Ebcomm_PaypalMx_Model_Debito2 extends Mage_Payment_Model_Method_Abstract
|
| 8 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
| 9 |
+
{
|
| 10 |
+
protected $_code = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_DEBITO;
|
| 11 |
+
protected $_formBlockType = 'paypalmx/debito2_form';
|
| 12 |
+
protected $_infoBlockType = 'paypalmx/payment_info';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Website Payments Pro instance type
|
| 16 |
+
*
|
| 17 |
+
* @var $_proType string
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Availability options
|
| 22 |
+
*/
|
| 23 |
+
protected $_isGateway = false;
|
| 24 |
+
protected $_canOrder = true;
|
| 25 |
+
protected $_canAuthorize = true;
|
| 26 |
+
protected $_canCapture = true;
|
| 27 |
+
protected $_canCapturePartial = true;
|
| 28 |
+
protected $_canRefund = true;
|
| 29 |
+
protected $_canRefundInvoicePartial = true;
|
| 30 |
+
protected $_canVoid = true;
|
| 31 |
+
protected $_canUseInternal = false;
|
| 32 |
+
protected $_canUseCheckout = true;
|
| 33 |
+
protected $_canUseForMultishipping = false;
|
| 34 |
+
protected $_canFetchTransactionInfo = true;
|
| 35 |
+
protected $_canCreateBillingAgreement = true;
|
| 36 |
+
protected $_canReviewPayment = false;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Website Payments Pro instance
|
| 40 |
+
*
|
| 41 |
+
* @var Mage_Paypal_Model_Pro
|
| 42 |
+
*/
|
| 43 |
+
protected $_pro = null;
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Payment additional information key for payment action
|
| 47 |
+
* @var string
|
| 48 |
+
*/
|
| 49 |
+
protected $_isOrderPaymentActionKey = 'is_order_action';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Payment additional information key for number of used authorizations
|
| 53 |
+
* @var string
|
| 54 |
+
*/
|
| 55 |
+
protected $_authorizationCountKey = 'authorization_count';
|
| 56 |
+
|
| 57 |
+
public function __construct($params = array())
|
| 58 |
+
{
|
| 59 |
+
|
| 60 |
+
$proInstance = array_shift($params);
|
| 61 |
+
if ($proInstance && ($proInstance instanceof Ebcomm_PaypalMx_Model_Pro)) {
|
| 62 |
+
|
| 63 |
+
$this->_pro = $proInstance;
|
| 64 |
+
} else {
|
| 65 |
+
$this->_pro = Mage::getModel('paypalmx/pro');
|
| 66 |
+
}
|
| 67 |
+
$this->_pro->setMethod($this->_code);
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Store setter
|
| 73 |
+
* Also updates store ID in config object
|
| 74 |
+
*
|
| 75 |
+
* @param Mage_Core_Model_Store|int $store
|
| 76 |
+
*/
|
| 77 |
+
public function setStore($store)
|
| 78 |
+
{
|
| 79 |
+
$this->setData('store', $store);
|
| 80 |
+
if (null === $store) {
|
| 81 |
+
$store = Mage::app()->getStore()->getId();
|
| 82 |
+
}
|
| 83 |
+
$this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store);
|
| 84 |
+
return $this;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Can be used in regular checkout
|
| 89 |
+
*
|
| 90 |
+
* @return bool
|
| 91 |
+
*/
|
| 92 |
+
public function canUseCheckout()
|
| 93 |
+
{
|
| 94 |
+
if (Mage::getStoreConfigFlag('payment/hosted_pro/active')
|
| 95 |
+
&& !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec')
|
| 96 |
+
) {
|
| 97 |
+
return false;
|
| 98 |
+
}
|
| 99 |
+
return parent::canUseCheckout();
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Whether method is available for specified currency
|
| 104 |
+
*
|
| 105 |
+
* @param string $currencyCode
|
| 106 |
+
* @return bool
|
| 107 |
+
*/
|
| 108 |
+
public function canUseForCurrency($currencyCode)
|
| 109 |
+
{
|
| 110 |
+
return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Payment action getter compatible with payment model
|
| 115 |
+
*
|
| 116 |
+
* @see Mage_Sales_Model_Payment::place()
|
| 117 |
+
* @return string
|
| 118 |
+
*/
|
| 119 |
+
public function getConfigPaymentAction()
|
| 120 |
+
{
|
| 121 |
+
return $this->_pro->getConfig()->getPaymentAction();
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Check whether payment method can be used
|
| 126 |
+
* @param Mage_Sales_Model_Quote
|
| 127 |
+
* @return bool
|
| 128 |
+
*/
|
| 129 |
+
public function isAvailable($quote = null)
|
| 130 |
+
{
|
| 131 |
+
if ($this->_pro->getConfig()->isMethodAvailable(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX)) {
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
return false;
|
| 135 |
+
}
|
| 136 |
+
public function isContextAvailable($contextpos = null,$method = null)
|
| 137 |
+
{
|
| 138 |
+
if ($this->_pro->getConfig()->isContextAvailable($contextpos,$method)) {
|
| 139 |
+
return true;
|
| 140 |
+
}
|
| 141 |
+
return false;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Custom getter for payment configuration
|
| 146 |
+
*
|
| 147 |
+
* @param string $field
|
| 148 |
+
* @param int $storeId
|
| 149 |
+
* @return mixed
|
| 150 |
+
*/
|
| 151 |
+
public function getConfigData($field, $storeId = null)
|
| 152 |
+
{
|
| 153 |
+
return $this->_pro->getConfig()->$field;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Order payment
|
| 158 |
+
*
|
| 159 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 160 |
+
* @param float $amount
|
| 161 |
+
* @return Mage_Paypal_Model_Express
|
| 162 |
+
*/
|
| 163 |
+
public function order(Varien_Object $payment, $amount)
|
| 164 |
+
{
|
| 165 |
+
$this->_placeOrder($payment, $amount);
|
| 166 |
+
|
| 167 |
+
$payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
|
| 168 |
+
|
| 169 |
+
if ($payment->getIsFraudDetected()) {
|
| 170 |
+
return $this;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
$order = $payment->getOrder();
|
| 174 |
+
$orderTransactionId = $payment->getTransactionId();
|
| 175 |
+
|
| 176 |
+
$api = $this->_callDoAuthorize($amount, $payment, $payment->getTransactionId());
|
| 177 |
+
|
| 178 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
| 179 |
+
$status = true;
|
| 180 |
+
|
| 181 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 182 |
+
if ($payment->getIsTransactionPending()) {
|
| 183 |
+
$message = Mage::helper('paypalmx')->__('Ordering amount of %s is pending approval on gateway.', $formatedPrice);
|
| 184 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 185 |
+
} else {
|
| 186 |
+
$message = Mage::helper('paypalmx')->__('Ordered amount of %s.', $formatedPrice);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
|
| 190 |
+
|
| 191 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 192 |
+
|
| 193 |
+
if ($payment->getIsTransactionPending()) {
|
| 194 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 195 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 196 |
+
if ($payment->getIsFraudDetected()) {
|
| 197 |
+
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
|
| 198 |
+
}
|
| 199 |
+
} else {
|
| 200 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
$payment->resetTransactionAdditionalInfo();
|
| 204 |
+
|
| 205 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 206 |
+
$payment->setParentTransactionId($orderTransactionId);
|
| 207 |
+
|
| 208 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false,
|
| 209 |
+
$message
|
| 210 |
+
);
|
| 211 |
+
|
| 212 |
+
$order->setState($state, $status);
|
| 213 |
+
|
| 214 |
+
$payment->setSkipOrderProcessing(true);
|
| 215 |
+
return $this;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Authorize payment
|
| 220 |
+
*
|
| 221 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 222 |
+
* @param float $amount
|
| 223 |
+
* @return Mage_Paypal_Model_Express
|
| 224 |
+
*/
|
| 225 |
+
public function authorize(Varien_Object $payment, $amount)
|
| 226 |
+
{
|
| 227 |
+
return $this->_placeOrder($payment, $amount);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Void payment
|
| 232 |
+
*
|
| 233 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 234 |
+
* @return Mage_Paypal_Model_Express
|
| 235 |
+
*/
|
| 236 |
+
public function void(Varien_Object $payment)
|
| 237 |
+
{
|
| 238 |
+
//Switching to order transaction if needed
|
| 239 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)
|
| 240 |
+
&& !$payment->getVoidOnlyAuthorization()
|
| 241 |
+
) {
|
| 242 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 243 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 244 |
+
);
|
| 245 |
+
if ($orderTransaction) {
|
| 246 |
+
$payment->setParentTransactionId($orderTransaction->getTxnId());
|
| 247 |
+
$payment->setTransactionId($orderTransaction->getTxnId() . '-void');
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
$this->_pro->void($payment);
|
| 251 |
+
return $this;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Capture payment
|
| 256 |
+
*
|
| 257 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 258 |
+
* @param float $amount
|
| 259 |
+
* @return Mage_Paypal_Model_Express
|
| 260 |
+
*/
|
| 261 |
+
public function capture(Varien_Object $payment, $amount)
|
| 262 |
+
{
|
| 263 |
+
$authorizationTransaction = $payment->getAuthorizationTransaction();
|
| 264 |
+
$authorizationPeriod = abs(intval($this->getConfigData('authorization_honor_period')));
|
| 265 |
+
$maxAuthorizationNumber = abs(intval($this->getConfigData('child_authorization_number')));
|
| 266 |
+
$order = $payment->getOrder();
|
| 267 |
+
$isAuthorizationCreated = false;
|
| 268 |
+
|
| 269 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 270 |
+
$voided = false;
|
| 271 |
+
if (!$authorizationTransaction->getIsClosed()
|
| 272 |
+
&& $this->_isTransactionExpired($authorizationTransaction, $authorizationPeriod)
|
| 273 |
+
) {
|
| 274 |
+
//Save payment state and configure payment object for voiding
|
| 275 |
+
$isCaptureFinal = $payment->getShouldCloseParentTransaction();
|
| 276 |
+
$captureTrxId = $payment->getTransactionId();
|
| 277 |
+
$payment->setShouldCloseParentTransaction(false);
|
| 278 |
+
$payment->setParentTransactionId($authorizationTransaction->getTxnId());
|
| 279 |
+
$payment->unsTransactionId();
|
| 280 |
+
$payment->setVoidOnlyAuthorization(true);
|
| 281 |
+
$payment->void(new Varien_Object());
|
| 282 |
+
|
| 283 |
+
//Revert payment state after voiding
|
| 284 |
+
$payment->unsAuthorizationTransaction();
|
| 285 |
+
$payment->unsTransactionId();
|
| 286 |
+
$payment->setShouldCloseParentTransaction($isCaptureFinal);
|
| 287 |
+
$voided = true;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if ($authorizationTransaction->getIsClosed() || $voided) {
|
| 291 |
+
if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) {
|
| 292 |
+
Mage::throwException(Mage::helper('paypalmx')->__('The maximum number of child authorizations is reached.'));
|
| 293 |
+
}
|
| 294 |
+
$api = $this->_callDoAuthorize(
|
| 295 |
+
$amount,
|
| 296 |
+
$payment,
|
| 297 |
+
$authorizationTransaction->getParentTxnId()
|
| 298 |
+
);
|
| 299 |
+
|
| 300 |
+
//Adding authorization transaction
|
| 301 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 302 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 303 |
+
$payment->setParentTransactionId($authorizationTransaction->getParentTxnId());
|
| 304 |
+
$payment->setIsTransactionClosed(false);
|
| 305 |
+
|
| 306 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 307 |
+
|
| 308 |
+
if ($payment->getIsTransactionPending()) {
|
| 309 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 310 |
+
} else {
|
| 311 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null,
|
| 315 |
+
true, $message
|
| 316 |
+
);
|
| 317 |
+
|
| 318 |
+
$payment->setParentTransactionId($api->getTransactionId());
|
| 319 |
+
$isAuthorizationCreated = true;
|
| 320 |
+
}
|
| 321 |
+
//close order transaction if needed
|
| 322 |
+
if ($payment->getShouldCloseParentTransaction()) {
|
| 323 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 324 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 325 |
+
);
|
| 326 |
+
|
| 327 |
+
if ($orderTransaction) {
|
| 328 |
+
$orderTransaction->setIsClosed(true);
|
| 329 |
+
$order->addRelatedObject($orderTransaction);
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
if (false === $this->_pro->capture($payment, $amount)) {
|
| 335 |
+
$this->_placeOrder($payment, $amount);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
if ($isAuthorizationCreated && isset($transaction)) {
|
| 339 |
+
$transaction->setIsClosed(true);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
return $this;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
* Refund capture
|
| 347 |
+
*
|
| 348 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 349 |
+
* @param float $amount
|
| 350 |
+
* @return Mage_Paypal_Model_Express
|
| 351 |
+
*/
|
| 352 |
+
public function refund(Varien_Object $payment, $amount)
|
| 353 |
+
{
|
| 354 |
+
$this->_pro->refund($payment, $amount);
|
| 355 |
+
return $this;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Cancel payment
|
| 360 |
+
*
|
| 361 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 362 |
+
* @return Mage_Paypal_Model_Express
|
| 363 |
+
*/
|
| 364 |
+
public function cancel(Varien_Object $payment)
|
| 365 |
+
{
|
| 366 |
+
$this->void($payment);
|
| 367 |
+
|
| 368 |
+
return $this;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* Whether payment can be reviewed
|
| 373 |
+
*
|
| 374 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 375 |
+
* @return bool
|
| 376 |
+
*/
|
| 377 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 378 |
+
{
|
| 379 |
+
return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Attempt to accept a pending payment
|
| 384 |
+
*
|
| 385 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 386 |
+
* @return bool
|
| 387 |
+
*/
|
| 388 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
| 389 |
+
{
|
| 390 |
+
parent::acceptPayment($payment);
|
| 391 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_ACCEPT);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Attempt to deny a pending payment
|
| 396 |
+
*
|
| 397 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 398 |
+
* @return bool
|
| 399 |
+
*/
|
| 400 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
| 401 |
+
{
|
| 402 |
+
parent::denyPayment($payment);
|
| 403 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_DENY);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* Checkout redirect URL getter for onepage checkout (hardcode)
|
| 408 |
+
*
|
| 409 |
+
* @see Mage_Checkout_OnepageController::savePaymentAction()
|
| 410 |
+
* @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
|
| 411 |
+
* @return string
|
| 412 |
+
*/
|
| 413 |
+
public function getCheckoutRedirectUrl()
|
| 414 |
+
{
|
| 415 |
+
return Mage::getUrl('paypalmx/express/start');
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
/**
|
| 419 |
+
* Fetch transaction details info
|
| 420 |
+
*
|
| 421 |
+
* @param Mage_Payment_Model_Info $payment
|
| 422 |
+
* @param string $transactionId
|
| 423 |
+
* @return array
|
| 424 |
+
*/
|
| 425 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 426 |
+
{
|
| 427 |
+
return $this->_pro->fetchTransactionInfo($payment, $transactionId);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* Validate RP data
|
| 432 |
+
*
|
| 433 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 434 |
+
*/
|
| 435 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 436 |
+
{
|
| 437 |
+
return $this->_pro->validateRecurringProfile($profile);
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* Submit RP to the gateway
|
| 442 |
+
*
|
| 443 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 444 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 445 |
+
*/
|
| 446 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 447 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 448 |
+
) {
|
| 449 |
+
$token = $paymentInfo->
|
| 450 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 451 |
+
$profile->setToken($token);
|
| 452 |
+
$this->_pro->submitRecurringProfile($profile, $paymentInfo);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Fetch RP details
|
| 457 |
+
*
|
| 458 |
+
* @param string $referenceId
|
| 459 |
+
* @param Varien_Object $result
|
| 460 |
+
*/
|
| 461 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 462 |
+
{
|
| 463 |
+
return $this->_pro->getRecurringProfileDetails($referenceId, $result);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
/**
|
| 467 |
+
* Whether can get recurring profile details
|
| 468 |
+
*/
|
| 469 |
+
public function canGetRecurringProfileDetails()
|
| 470 |
+
{
|
| 471 |
+
return true;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* Update RP data
|
| 476 |
+
*
|
| 477 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 478 |
+
*/
|
| 479 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 480 |
+
{
|
| 481 |
+
return $this->_pro->updateRecurringProfile($profile);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* Manage status
|
| 486 |
+
*
|
| 487 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 488 |
+
*/
|
| 489 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 490 |
+
{
|
| 491 |
+
return $this->_pro->updateRecurringProfileStatus($profile);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/**
|
| 495 |
+
* Assign data to info model instance
|
| 496 |
+
*
|
| 497 |
+
* @param mixed $data
|
| 498 |
+
* @return Mage_Payment_Model_Info
|
| 499 |
+
*/
|
| 500 |
+
public function assignData($data)
|
| 501 |
+
{
|
| 502 |
+
$result = parent::assignData($data);
|
| 503 |
+
$key = Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
|
| 504 |
+
if (is_array($data)) {
|
| 505 |
+
$this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
|
| 506 |
+
}
|
| 507 |
+
elseif ($data instanceof Varien_Object) {
|
| 508 |
+
$this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
|
| 509 |
+
}
|
| 510 |
+
return $result;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
/**
|
| 514 |
+
* Place an order with authorization or capture action
|
| 515 |
+
*
|
| 516 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 517 |
+
* @param float $amount
|
| 518 |
+
* @return Mage_Paypal_Model_Express
|
| 519 |
+
*/
|
| 520 |
+
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
|
| 521 |
+
{
|
| 522 |
+
$order = $payment->getOrder();
|
| 523 |
+
|
| 524 |
+
// prepare api call
|
| 525 |
+
$token = $payment->getAdditionalInformation(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 526 |
+
$api = $this->_pro->getApi()
|
| 527 |
+
->setToken($token)
|
| 528 |
+
->setPayerId($payment->
|
| 529 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))
|
| 530 |
+
->setAmount($amount)
|
| 531 |
+
->setPaymentAction($this->_pro->getConfig()->paymentAction)
|
| 532 |
+
->setNotifyUrl(Mage::getUrl('paypalmx/ipn/'))
|
| 533 |
+
->setInvNum($order->getIncrementId()."MGT".date("YmdHis"))
|
| 534 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
| 535 |
+
->setPaypalCart(Mage::getModel('paypalmx/cart', array($order)))
|
| 536 |
+
->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)
|
| 537 |
+
;
|
| 538 |
+
if ($order->getIsVirtual()) {
|
| 539 |
+
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
|
| 540 |
+
} else {
|
| 541 |
+
$api->setAddress($order->getShippingAddress());
|
| 542 |
+
$api->setBillingAddress($order->getBillingAddress());
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
// call api and get details from it
|
| 546 |
+
$api->callDoExpressCheckoutPayment();
|
| 547 |
+
|
| 548 |
+
$this->_importToPayment($api, $payment);
|
| 549 |
+
return $this;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
* Import payment info to payment
|
| 554 |
+
*
|
| 555 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 556 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 557 |
+
*/
|
| 558 |
+
protected function _importToPayment($api, $payment)
|
| 559 |
+
{
|
| 560 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)
|
| 561 |
+
->setAdditionalInformation(Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT,
|
| 562 |
+
$api->getRedirectRequired()
|
| 563 |
+
);
|
| 564 |
+
|
| 565 |
+
if ($api->getBillingAgreementId()) {
|
| 566 |
+
$payment->setBillingAgreementData(array(
|
| 567 |
+
'billing_agreement_id' => $api->getBillingAgreementId(),
|
| 568 |
+
'method_code' => Ebcomm_PaypalMx_Model_Config::METHOD_BILLING_AGREEMENT
|
| 569 |
+
));
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 573 |
+
}
|
| 574 |
+
|
| 575 |
+
/**
|
| 576 |
+
* Check void availability
|
| 577 |
+
*
|
| 578 |
+
* @param Varien_Object $payment
|
| 579 |
+
* @return bool
|
| 580 |
+
*/
|
| 581 |
+
public function canVoid(Varien_Object $payment)
|
| 582 |
+
{
|
| 583 |
+
if ($payment instanceof Mage_Sales_Model_Order_Invoice
|
| 584 |
+
|| $payment instanceof Mage_Sales_Model_Order_Creditmemo
|
| 585 |
+
) {
|
| 586 |
+
return false;
|
| 587 |
+
}
|
| 588 |
+
$info = $this->getInfoInstance();
|
| 589 |
+
if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 590 |
+
$orderTransaction = $info->lookupTransaction(
|
| 591 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 592 |
+
);
|
| 593 |
+
if ($orderTransaction) {
|
| 594 |
+
$info->setParentTransactionId($orderTransaction->getTxnId());
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
return $this->_canVoid;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* Check capture availability
|
| 603 |
+
*
|
| 604 |
+
* @return bool
|
| 605 |
+
*/
|
| 606 |
+
public function canCapture()
|
| 607 |
+
{
|
| 608 |
+
$payment = $this->getInfoInstance();
|
| 609 |
+
$this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId());
|
| 610 |
+
|
| 611 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 612 |
+
$orderTransaction = $payment->lookupTransaction(false,
|
| 613 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 614 |
+
);
|
| 615 |
+
if ($orderTransaction->getIsClosed()) {
|
| 616 |
+
return false;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
$orderValidPeriod = abs(intval($this->getConfigData('order_valid_period')));
|
| 620 |
+
|
| 621 |
+
$dateCompass = new DateTime($orderTransaction->getCreatedAt());
|
| 622 |
+
$dateCompass->modify('+' . $orderValidPeriod . ' days');
|
| 623 |
+
$currentDate = new DateTime();
|
| 624 |
+
|
| 625 |
+
if ($currentDate > $dateCompass || $orderValidPeriod == 0) {
|
| 626 |
+
return false;
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
+
return $this->_canCapture;
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
/**
|
| 633 |
+
* Call DoAuthorize
|
| 634 |
+
*
|
| 635 |
+
* @param int $amount
|
| 636 |
+
* @param Varien_Object $payment
|
| 637 |
+
* @param string $parentTransactionId
|
| 638 |
+
* @return Mage_Paypal_Model_Api_Abstract
|
| 639 |
+
*/
|
| 640 |
+
protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
|
| 641 |
+
{
|
| 642 |
+
$api = $this->_pro->resetApi()->getApi()
|
| 643 |
+
->setAmount($amount)
|
| 644 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 645 |
+
->setTransactionId($parentTransactionId)
|
| 646 |
+
->callDoAuthorization();
|
| 647 |
+
|
| 648 |
+
$payment->setAdditionalInformation($this->_authorizationCountKey,
|
| 649 |
+
$payment->getAdditionalInformation($this->_authorizationCountKey) + 1
|
| 650 |
+
);
|
| 651 |
+
|
| 652 |
+
return $api;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* Check transaction for expiration in PST
|
| 657 |
+
*
|
| 658 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
| 659 |
+
* @param int $period
|
| 660 |
+
* @return boolean
|
| 661 |
+
*/
|
| 662 |
+
protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transaction $transaction, $period)
|
| 663 |
+
{
|
| 664 |
+
$period = intval($period);
|
| 665 |
+
if (0 == $period) {
|
| 666 |
+
return true;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
$transactionClosingDate = new DateTime($transaction->getCreatedAt(), new DateTimeZone('GMT'));
|
| 670 |
+
$transactionClosingDate->setTimezone(new DateTimeZone('US/Pacific'));
|
| 671 |
+
/**
|
| 672 |
+
* 11:49:00 PayPal transactions closing time
|
| 673 |
+
*/
|
| 674 |
+
$transactionClosingDate->setTime(11, 49, 00);
|
| 675 |
+
$transactionClosingDate->modify('+' . $period . ' days');
|
| 676 |
+
|
| 677 |
+
$currentTime = new DateTime(null, new DateTimeZone('US/Pacific'));
|
| 678 |
+
|
| 679 |
+
if ($currentTime > $transactionClosingDate) {
|
| 680 |
+
return true;
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
return false;
|
| 684 |
+
}
|
| 685 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Debito2/Checkout.php
ADDED
|
@@ -0,0 +1,967 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Debito2_Checkout
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cache ID prefix for "pal" lookup
|
| 6 |
+
* @var string
|
| 7 |
+
*/
|
| 8 |
+
const PAL_CACHE_ID = 'paypalmx_express_checkout_pal';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Keys for passthrough variables in sales/quote_payment and sales/order_payment
|
| 12 |
+
* Uses additional_information as storage
|
| 13 |
+
* @var string
|
| 14 |
+
*/
|
| 15 |
+
const PAYMENT_INFO_TRANSPORT_TOKEN = 'paypalmx_express_checkout_token';
|
| 16 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN = 'paypalmx_express_checkout_shipping_overriden';
|
| 17 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD = 'paypalmx_express_checkout_shipping_method';
|
| 18 |
+
const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypalmx_express_checkout_payer_id';
|
| 19 |
+
const PAYMENT_INFO_TRANSPORT_REDIRECT = 'paypalmx_express_checkout_redirect_required';
|
| 20 |
+
const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'paypalmx_ec_create_ba';
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @var Mage_Sales_Model_Quote
|
| 24 |
+
*/
|
| 25 |
+
protected $_quote = null;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Config instance
|
| 29 |
+
* @var Mage_Paypal_Model_Config
|
| 30 |
+
*/
|
| 31 |
+
protected $_config = null;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* API instance
|
| 35 |
+
* @var Mage_Paypal_Model_Api_Nvp
|
| 36 |
+
*/
|
| 37 |
+
protected $_api = null;
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Api Model Type
|
| 41 |
+
*
|
| 42 |
+
* @var string
|
| 43 |
+
*/
|
| 44 |
+
protected $_apiType = 'paypalmx/api_nvp';
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Payment method type
|
| 48 |
+
*
|
| 49 |
+
* @var unknown_type
|
| 50 |
+
*/
|
| 51 |
+
protected $_methodType = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_DEBITO;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* State helper variables
|
| 55 |
+
* @var string
|
| 56 |
+
*/
|
| 57 |
+
protected $_redirectUrl = '';
|
| 58 |
+
protected $_pendingPaymentMessage = '';
|
| 59 |
+
protected $_checkoutRedirectUrl = '';
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @var Mage_Customer_Model_Session
|
| 63 |
+
*/
|
| 64 |
+
protected $_customerSession;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Redirect urls supposed to be set to support giropay
|
| 68 |
+
*
|
| 69 |
+
* @var array
|
| 70 |
+
*/
|
| 71 |
+
protected $_giropayUrls = array();
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Create Billing Agreement flag
|
| 75 |
+
*
|
| 76 |
+
* @var bool
|
| 77 |
+
*/
|
| 78 |
+
protected $_isBARequested = false;
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Customer ID
|
| 82 |
+
*
|
| 83 |
+
* @var int
|
| 84 |
+
*/
|
| 85 |
+
protected $_customerId = null;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Recurring payment profiles
|
| 89 |
+
*
|
| 90 |
+
* @var array
|
| 91 |
+
*/
|
| 92 |
+
protected $_recurringPaymentProfiles = array();
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Billing agreement that might be created during order placing
|
| 96 |
+
*
|
| 97 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
| 98 |
+
*/
|
| 99 |
+
protected $_billingAgreement = null;
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Order
|
| 103 |
+
*
|
| 104 |
+
* @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
|
| 105 |
+
*/
|
| 106 |
+
protected $_order = null;
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Set quote and config instances
|
| 110 |
+
* @param array $params
|
| 111 |
+
*/
|
| 112 |
+
public function __construct($params = array())
|
| 113 |
+
{
|
| 114 |
+
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
| 115 |
+
$this->_quote = $params['quote'];
|
| 116 |
+
} else {
|
| 117 |
+
throw new Exception('Quote instance is required.');
|
| 118 |
+
}
|
| 119 |
+
if (isset($params['config']) && $params['config'] instanceof Ebcomm_PaypalMx_Model_Config) {
|
| 120 |
+
$this->_config = $params['config'];
|
| 121 |
+
} else {
|
| 122 |
+
throw new Exception('Config instance is required.');
|
| 123 |
+
}
|
| 124 |
+
$this->_customerSession = Mage::getSingleton('customer/session');
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Checkout with PayPal image URL getter
|
| 129 |
+
* Spares API calls of getting "pal" variable, by putting it into cache per store view
|
| 130 |
+
* @return string
|
| 131 |
+
*/
|
| 132 |
+
public function getCheckoutShortcutImageUrl()
|
| 133 |
+
{
|
| 134 |
+
// get "pal" thing from cache or lookup it via API
|
| 135 |
+
$pal = null;
|
| 136 |
+
if ($this->_config->areButtonsDynamic()) {
|
| 137 |
+
$cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId();
|
| 138 |
+
$pal = Mage::app()->loadCache($cacheId);
|
| 139 |
+
if (-1 == $pal) {
|
| 140 |
+
$pal = null;
|
| 141 |
+
} elseif (!$pal) {
|
| 142 |
+
$pal = null;
|
| 143 |
+
$this->_getApi();
|
| 144 |
+
try {
|
| 145 |
+
$this->_api->callGetPalDetails();
|
| 146 |
+
$pal = $this->_api->getPal();
|
| 147 |
+
Mage::app()->saveCache($pal, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 148 |
+
} catch (Exception $e) {
|
| 149 |
+
Mage::app()->saveCache(-1, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 150 |
+
Mage::logException($e);
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
return $this->_config->getExpressCheckoutShortcutImageUrl(
|
| 156 |
+
Mage::app()->getLocale()->getLocaleCode(),
|
| 157 |
+
$this->_quote->getBaseGrandTotal(),
|
| 158 |
+
$pal
|
| 159 |
+
);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Setter that enables giropay redirects flow
|
| 164 |
+
*
|
| 165 |
+
* @param string $successUrl - payment success result
|
| 166 |
+
* @param string $cancelUrl - payment cancellation result
|
| 167 |
+
* @param string $pendingUrl - pending payment result
|
| 168 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 169 |
+
*/
|
| 170 |
+
public function prepareGiropayUrls($successUrl, $cancelUrl, $pendingUrl)
|
| 171 |
+
{
|
| 172 |
+
$this->_giropayUrls = array($successUrl, $cancelUrl, $pendingUrl);
|
| 173 |
+
return $this;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Set create billing agreement flag
|
| 178 |
+
*
|
| 179 |
+
* @param bool $flag
|
| 180 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 181 |
+
*/
|
| 182 |
+
public function setIsBillingAgreementRequested($flag)
|
| 183 |
+
{
|
| 184 |
+
$this->_isBARequested = $flag;
|
| 185 |
+
return $this;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Setter for customer Id
|
| 190 |
+
*
|
| 191 |
+
* @param int $id
|
| 192 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 193 |
+
* @deprecated please use self::setCustomer
|
| 194 |
+
*/
|
| 195 |
+
public function setCustomerId($id)
|
| 196 |
+
{
|
| 197 |
+
$this->_customerId = $id;
|
| 198 |
+
return $this;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Setter for customer
|
| 203 |
+
*
|
| 204 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 205 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 206 |
+
*/
|
| 207 |
+
public function setCustomer($customer)
|
| 208 |
+
{
|
| 209 |
+
$this->_quote->assignCustomer($customer);
|
| 210 |
+
$this->_customerId = $customer->getId();
|
| 211 |
+
return $this;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* Setter for customer with billing and shipping address changing ability
|
| 216 |
+
*
|
| 217 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 218 |
+
* @param Mage_Sales_Model_Quote_Address $billingAddress
|
| 219 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 220 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 221 |
+
*/
|
| 222 |
+
public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null)
|
| 223 |
+
{
|
| 224 |
+
$this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress);
|
| 225 |
+
$this->_customerId = $customer->getId();
|
| 226 |
+
return $this;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Reserve order ID for specified quote and start checkout on PayPal
|
| 231 |
+
*
|
| 232 |
+
* @param string $returnUrl
|
| 233 |
+
* @param string $cancelUrl
|
| 234 |
+
* @return mixed
|
| 235 |
+
*/
|
| 236 |
+
public function start($returnUrl, $cancelUrl)
|
| 237 |
+
{
|
| 238 |
+
$this->_quote->collectTotals();
|
| 239 |
+
|
| 240 |
+
if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
|
| 241 |
+
Mage::throwException(Mage::helper('paypalmx')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$this->_quote->reserveOrderId()->save();
|
| 245 |
+
// prepare API
|
| 246 |
+
$this->_getApi();
|
| 247 |
+
$this->_api->setAmount($this->_quote->getBaseGrandTotal())
|
| 248 |
+
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
|
| 249 |
+
->setInvNum($this->_quote->getReservedOrderId()."MGT".date("YmdHis"))
|
| 250 |
+
->setReturnUrl($returnUrl)
|
| 251 |
+
->setCancelUrl($cancelUrl)
|
| 252 |
+
->setSolutionType($this->_config->solutionType)
|
| 253 |
+
->setPaymentAction($this->_config->paymentAction)
|
| 254 |
+
;
|
| 255 |
+
if ($this->_giropayUrls) {
|
| 256 |
+
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
|
| 257 |
+
$this->_api->addData(array(
|
| 258 |
+
'giropay_cancel_url' => $cancelUrl,
|
| 259 |
+
'giropay_success_url' => $successUrl,
|
| 260 |
+
'giropay_bank_txn_pending_url' => $pendingUrl,
|
| 261 |
+
));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
$this->_setBillingAgreementRequest();
|
| 265 |
+
|
| 266 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) {
|
| 267 |
+
$this->_api->setRequireBillingAddress(1);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// supress or export shipping address
|
| 271 |
+
if ($this->_quote->getIsVirtual()) {
|
| 272 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
|
| 273 |
+
$this->_api->setRequireBillingAddress(1);
|
| 274 |
+
}
|
| 275 |
+
$this->_api->setSuppressShipping(true);
|
| 276 |
+
} else {
|
| 277 |
+
$address = $this->_quote->getShippingAddress();
|
| 278 |
+
$isOverriden = 0;
|
| 279 |
+
if (true === $address->validate()) {
|
| 280 |
+
$isOverriden = 1;
|
| 281 |
+
$this->_api->setAddress($address);
|
| 282 |
+
}
|
| 283 |
+
$this->_quote->getPayment()->setAdditionalInformation(
|
| 284 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
|
| 285 |
+
);
|
| 286 |
+
$this->_quote->getPayment()->save();
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
// add line items
|
| 290 |
+
$paypalCart = Mage::getModel('paypalmx/cart', array($this->_quote));
|
| 291 |
+
$this->_api->setPaypalCart($paypalCart)
|
| 292 |
+
->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
|
| 293 |
+
;
|
| 294 |
+
|
| 295 |
+
// add shipping options if needed and line items are available
|
| 296 |
+
if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
|
| 297 |
+
if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
|
| 298 |
+
if ($options = $this->_prepareShippingOptions($address, true)) {
|
| 299 |
+
$this->_api->setShippingOptionsCallbackUrl(
|
| 300 |
+
Mage::getUrl('*/*/shippingOptionsCallback', array('quote_id' => $this->_quote->getId()))
|
| 301 |
+
)->setShippingOptions($options);
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// add recurring payment profiles information
|
| 307 |
+
if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
|
| 308 |
+
foreach ($profiles as $profile) {
|
| 309 |
+
$profile->setMethodCode(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX);
|
| 310 |
+
if (!$profile->isValid()) {
|
| 311 |
+
Mage::throwException($profile->getValidationErrors(true, true));
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
$this->_api->addRecurringPaymentProfiles($profiles);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
|
| 318 |
+
|
| 319 |
+
// call API and redirect with token
|
| 320 |
+
$this->_api->callSetExpressCheckout();
|
| 321 |
+
$token = $this->_api->getToken();
|
| 322 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
|
| 323 |
+
|
| 324 |
+
$this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 325 |
+
$this->_quote->getPayment()->save();
|
| 326 |
+
return $token;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
/**
|
| 330 |
+
* Update quote when returned from PayPal
|
| 331 |
+
* rewrite billing address by paypal
|
| 332 |
+
* save old billing address for new customer
|
| 333 |
+
* export shipping address in case address absence
|
| 334 |
+
*
|
| 335 |
+
* @param string $token
|
| 336 |
+
*/
|
| 337 |
+
public function returnFromPaypal($token)
|
| 338 |
+
{
|
| 339 |
+
$this->_getApi();
|
| 340 |
+
$this->_api->setToken($token)
|
| 341 |
+
->callGetExpressCheckoutDetails();
|
| 342 |
+
$quote = $this->_quote;
|
| 343 |
+
|
| 344 |
+
$this->_ignoreAddressValidation();
|
| 345 |
+
|
| 346 |
+
// import billing address
|
| 347 |
+
$billingAddress = $quote->getBillingAddress();
|
| 348 |
+
$exportedBillingAddress = $this->_api->getExportedBillingAddress();
|
| 349 |
+
$quote->setCustomerEmail($billingAddress->getEmail());
|
| 350 |
+
$quote->setCustomerPrefix($billingAddress->getPrefix());
|
| 351 |
+
$quote->setCustomerFirstname($billingAddress->getFirstname());
|
| 352 |
+
$quote->setCustomerMiddlename($billingAddress->getMiddlename());
|
| 353 |
+
$quote->setCustomerLastname($billingAddress->getLastname());
|
| 354 |
+
$quote->setCustomerSuffix($billingAddress->getSuffix());
|
| 355 |
+
$quote->setCustomerNote($exportedBillingAddress->getData('note'));
|
| 356 |
+
$this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
|
| 357 |
+
|
| 358 |
+
// import shipping address
|
| 359 |
+
$exportedShippingAddress = $this->_api->getExportedShippingAddress();
|
| 360 |
+
if (!$quote->getIsVirtual()) {
|
| 361 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 362 |
+
if ($shippingAddress) {
|
| 363 |
+
if ($exportedShippingAddress) {
|
| 364 |
+
$this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
|
| 365 |
+
$shippingAddress->setCollectShippingRates(true);
|
| 366 |
+
$shippingAddress->setSameAsBilling(0);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
// import shipping method
|
| 370 |
+
$code = '';
|
| 371 |
+
if ($this->_api->getShippingRateCode()) {
|
| 372 |
+
if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
|
| 373 |
+
// possible bug of double collecting rates :-/
|
| 374 |
+
$shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
$quote->getPayment()->setAdditionalInformation(
|
| 378 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD,
|
| 379 |
+
$code
|
| 380 |
+
);
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// import payment info
|
| 385 |
+
$payment = $quote->getPayment();
|
| 386 |
+
$payment->setMethod($this->_methodType);
|
| 387 |
+
Mage::getSingleton('paypalmx/info')->importToPayment($this->_api, $payment);
|
| 388 |
+
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())
|
| 389 |
+
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
|
| 390 |
+
;
|
| 391 |
+
$quote->collectTotals()->save();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Check whether order review has enough data to initialize
|
| 396 |
+
*
|
| 397 |
+
* @param $token
|
| 398 |
+
* @throws Mage_Core_Exception
|
| 399 |
+
*/
|
| 400 |
+
public function prepareOrderReview($token = null)
|
| 401 |
+
{
|
| 402 |
+
$payment = $this->_quote->getPayment();
|
| 403 |
+
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
|
| 404 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Payer is not identified.'));
|
| 405 |
+
}
|
| 406 |
+
$this->_quote->setMayEditShippingAddress(
|
| 407 |
+
1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN)
|
| 408 |
+
);
|
| 409 |
+
$this->_quote->setMayEditShippingMethod(
|
| 410 |
+
'' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
|
| 411 |
+
);
|
| 412 |
+
$this->_ignoreAddressValidation();
|
| 413 |
+
$this->_quote->collectTotals()->save();
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* Return callback response with shipping options
|
| 418 |
+
*
|
| 419 |
+
* @param array $request
|
| 420 |
+
* @return string
|
| 421 |
+
*/
|
| 422 |
+
public function getShippingOptionsCallbackResponse(array $request)
|
| 423 |
+
{
|
| 424 |
+
// prepare debug data
|
| 425 |
+
$logger = Mage::getModel('core/log_adapter', 'payment_' . $this->_methodType . '.log');
|
| 426 |
+
$debugData = array('request' => $request, 'response' => array());
|
| 427 |
+
|
| 428 |
+
try {
|
| 429 |
+
// obtain addresses
|
| 430 |
+
$this->_getApi();
|
| 431 |
+
$address = $this->_api->prepareShippingOptionsCallbackAddress($request);
|
| 432 |
+
$quoteAddress = $this->_quote->getShippingAddress();
|
| 433 |
+
|
| 434 |
+
// compare addresses, calculate shipping rates and prepare response
|
| 435 |
+
$options = array();
|
| 436 |
+
if ($address && $quoteAddress && !$this->_quote->getIsVirtual()) {
|
| 437 |
+
foreach ($address->getExportedKeys() as $key) {
|
| 438 |
+
$quoteAddress->setDataUsingMethod($key, $address->getData($key));
|
| 439 |
+
}
|
| 440 |
+
$quoteAddress->setCollectShippingRates(true)->collectTotals();
|
| 441 |
+
$options = $this->_prepareShippingOptions($quoteAddress, false, true);
|
| 442 |
+
}
|
| 443 |
+
$response = $this->_api->setShippingOptions($options)->formatShippingOptionsCallback();
|
| 444 |
+
|
| 445 |
+
// log request and response
|
| 446 |
+
$debugData['response'] = $response;
|
| 447 |
+
$logger->log($debugData);
|
| 448 |
+
return $response;
|
| 449 |
+
} catch (Exception $e) {
|
| 450 |
+
$logger->log($debugData);
|
| 451 |
+
throw $e;
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Set shipping method to quote, if needed
|
| 457 |
+
* @param string $methodCode
|
| 458 |
+
*/
|
| 459 |
+
public function updateShippingMethod($methodCode)
|
| 460 |
+
{
|
| 461 |
+
if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
|
| 462 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
| 463 |
+
$this->_ignoreAddressValidation();
|
| 464 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
| 465 |
+
$this->_quote->collectTotals();
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Update order data
|
| 472 |
+
*
|
| 473 |
+
* @param array $data
|
| 474 |
+
*/
|
| 475 |
+
public function updateOrder($data)
|
| 476 |
+
{
|
| 477 |
+
/** @var $checkout Mage_Checkout_Model_Type_Onepage */
|
| 478 |
+
$checkout = Mage::getModel('checkout/type_onepage');
|
| 479 |
+
|
| 480 |
+
$this->_quote->setTotalsCollectedFlag(true);
|
| 481 |
+
$checkout->setQuote($this->_quote);
|
| 482 |
+
if (isset($data['billing'])) {
|
| 483 |
+
if (isset($data['customer-email'])) {
|
| 484 |
+
$data['billing']['email'] = $data['customer-email'];
|
| 485 |
+
}
|
| 486 |
+
$checkout->saveBilling($data['billing'], 0);
|
| 487 |
+
}
|
| 488 |
+
if (!$this->_quote->getIsVirtual() && isset($data['shipping'])) {
|
| 489 |
+
$checkout->saveShipping($data['shipping'], 0);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
if (isset($data['shipping_method'])) {
|
| 493 |
+
$this->updateShippingMethod($data['shipping_method']);
|
| 494 |
+
}
|
| 495 |
+
$this->_quote->setTotalsCollectedFlag(false);
|
| 496 |
+
$this->_quote->collectTotals();
|
| 497 |
+
$this->_quote->setDataChanges(true);
|
| 498 |
+
$this->_quote->save();
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/**
|
| 502 |
+
* Place the order and recurring payment profiles when customer returned from paypal
|
| 503 |
+
* Until this moment all quote data must be valid
|
| 504 |
+
*
|
| 505 |
+
* @param string $token
|
| 506 |
+
* @param string $shippingMethodCode
|
| 507 |
+
*/
|
| 508 |
+
public function place($token, $shippingMethodCode = null)
|
| 509 |
+
{
|
| 510 |
+
if ($shippingMethodCode) {
|
| 511 |
+
$this->updateShippingMethod($shippingMethodCode);
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
$isNewCustomer = false;
|
| 515 |
+
switch ($this->getCheckoutMethod()) {
|
| 516 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
|
| 517 |
+
$this->_prepareGuestQuote();
|
| 518 |
+
break;
|
| 519 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
|
| 520 |
+
$this->_prepareNewCustomerQuote();
|
| 521 |
+
$isNewCustomer = true;
|
| 522 |
+
break;
|
| 523 |
+
default:
|
| 524 |
+
$this->_prepareCustomerQuote();
|
| 525 |
+
break;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
$this->_ignoreAddressValidation();
|
| 529 |
+
$this->_quote->collectTotals();
|
| 530 |
+
$service = Mage::getModel('sales/service_quote', $this->_quote);
|
| 531 |
+
$service->submitAll();
|
| 532 |
+
$this->_quote->save();
|
| 533 |
+
|
| 534 |
+
if ($isNewCustomer) {
|
| 535 |
+
try {
|
| 536 |
+
$this->_involveNewCustomer();
|
| 537 |
+
} catch (Exception $e) {
|
| 538 |
+
Mage::logException($e);
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
$this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
|
| 543 |
+
// TODO: send recurring profile emails
|
| 544 |
+
|
| 545 |
+
$order = $service->getOrder();
|
| 546 |
+
if (!$order) {
|
| 547 |
+
return;
|
| 548 |
+
}
|
| 549 |
+
$this->_billingAgreement = $order->getPayment()->getBillingAgreement();
|
| 550 |
+
|
| 551 |
+
// commence redirecting to finish payment, if paypal requires it
|
| 552 |
+
if ($order->getPayment()->getAdditionalInformation(
|
| 553 |
+
Ebcomm_PaypalMx_Model_Debito2_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT
|
| 554 |
+
)) {
|
| 555 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
switch ($order->getState()) {
|
| 559 |
+
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
|
| 560 |
+
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
| 561 |
+
// TODO
|
| 562 |
+
break;
|
| 563 |
+
// regular placement, when everything is ok
|
| 564 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
| 565 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
| 566 |
+
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
|
| 567 |
+
$order->sendNewOrderEmail();
|
| 568 |
+
break;
|
| 569 |
+
}
|
| 570 |
+
$this->_order = $order;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Make sure addresses will be saved without validation errors
|
| 575 |
+
*/
|
| 576 |
+
private function _ignoreAddressValidation()
|
| 577 |
+
{
|
| 578 |
+
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
| 579 |
+
if (!$this->_quote->getIsVirtual()) {
|
| 580 |
+
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
| 581 |
+
if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) {
|
| 582 |
+
$this->_quote->getBillingAddress()->setSameAsBilling(1);
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
/**
|
| 588 |
+
* Determine whether redirect somewhere specifically is required
|
| 589 |
+
*
|
| 590 |
+
* @return string
|
| 591 |
+
*/
|
| 592 |
+
public function getRedirectUrl()
|
| 593 |
+
{
|
| 594 |
+
return $this->_redirectUrl;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
/**
|
| 598 |
+
* Return recurring payment profiles
|
| 599 |
+
*
|
| 600 |
+
* @return array
|
| 601 |
+
*/
|
| 602 |
+
public function getRecurringPaymentProfiles()
|
| 603 |
+
{
|
| 604 |
+
return $this->_recurringPaymentProfiles;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/**
|
| 608 |
+
* Get created billing agreement
|
| 609 |
+
*
|
| 610 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
| 611 |
+
*/
|
| 612 |
+
public function getBillingAgreement()
|
| 613 |
+
{
|
| 614 |
+
return $this->_billingAgreement;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* Return order
|
| 619 |
+
*
|
| 620 |
+
* @return Mage_Sales_Model_Order
|
| 621 |
+
*/
|
| 622 |
+
public function getOrder()
|
| 623 |
+
{
|
| 624 |
+
return $this->_order;
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
/**
|
| 628 |
+
* Get checkout method
|
| 629 |
+
*
|
| 630 |
+
* @return string
|
| 631 |
+
*/
|
| 632 |
+
public function getCheckoutMethod()
|
| 633 |
+
{
|
| 634 |
+
if ($this->getCustomerSession()->isLoggedIn()) {
|
| 635 |
+
return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
| 636 |
+
}
|
| 637 |
+
if (!$this->_quote->getCheckoutMethod()) {
|
| 638 |
+
if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
|
| 639 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
| 640 |
+
} else {
|
| 641 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
return $this->_quote->getCheckoutMethod();
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
/**
|
| 648 |
+
* Sets address data from exported address
|
| 649 |
+
*
|
| 650 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 651 |
+
* @param array $exportedAddress
|
| 652 |
+
*/
|
| 653 |
+
protected function _setExportedAddressData($address, $exportedAddress)
|
| 654 |
+
{
|
| 655 |
+
foreach ($exportedAddress->getExportedKeys() as $key) {
|
| 656 |
+
$oldData = $address->getDataUsingMethod($key);
|
| 657 |
+
$isEmpty = null;
|
| 658 |
+
if (is_array($oldData)) {
|
| 659 |
+
foreach($oldData as $val) {
|
| 660 |
+
if(!empty($val)) {
|
| 661 |
+
$isEmpty = false;
|
| 662 |
+
break;
|
| 663 |
+
}
|
| 664 |
+
$isEmpty = true;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
if (empty($oldData) || $isEmpty === true) {
|
| 668 |
+
$address->setDataUsingMethod($key, $exportedAddress->getData($key));
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
/**
|
| 674 |
+
* Set create billing agreement flag to api call
|
| 675 |
+
*
|
| 676 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 677 |
+
*/
|
| 678 |
+
protected function _setBillingAgreementRequest()
|
| 679 |
+
{
|
| 680 |
+
if (!$this->_customerId || $this->_quote->hasNominalItems()) {
|
| 681 |
+
return $this;
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
$isRequested = $this->_isBARequested || $this->_quote->getPayment()
|
| 685 |
+
->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 686 |
+
|
| 687 |
+
if (!($this->_config->allow_ba_signup == Ebcomm_PaypalMx_Model_Config::EC_BA_SIGNUP_AUTO
|
| 688 |
+
|| $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
|
| 689 |
+
return $this;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
|
| 693 |
+
return $this;
|
| 694 |
+
}
|
| 695 |
+
$this->_api->setBillingType($this->_api->getBillingAgreementType());
|
| 696 |
+
return $this;
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
/**
|
| 700 |
+
* @return Mage_Paypal_Model_Api_Nvp
|
| 701 |
+
*/
|
| 702 |
+
protected function _getApi()
|
| 703 |
+
{
|
| 704 |
+
if (null === $this->_api) {
|
| 705 |
+
$this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
|
| 706 |
+
}
|
| 707 |
+
return $this->_api;
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/**
|
| 711 |
+
* Attempt to collect address shipping rates and return them for further usage in instant update API
|
| 712 |
+
* Returns empty array if it was impossible to obtain any shipping rate
|
| 713 |
+
* If there are shipping rates obtained, the method must return one of them as default.
|
| 714 |
+
*
|
| 715 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 716 |
+
* @param bool $mayReturnEmpty
|
| 717 |
+
* @return array|false
|
| 718 |
+
*/
|
| 719 |
+
protected function _prepareShippingOptions(
|
| 720 |
+
Mage_Sales_Model_Quote_Address $address,
|
| 721 |
+
$mayReturnEmpty = false, $calculateTax = false
|
| 722 |
+
) {
|
| 723 |
+
$options = array(); $i = 0; $iMin = false; $min = false;
|
| 724 |
+
$userSelectedOption = null;
|
| 725 |
+
|
| 726 |
+
foreach ($address->getGroupedAllShippingRates() as $group) {
|
| 727 |
+
foreach ($group as $rate) {
|
| 728 |
+
$amount = (float)$rate->getPrice();
|
| 729 |
+
if ($rate->getErrorMessage()) {
|
| 730 |
+
continue;
|
| 731 |
+
}
|
| 732 |
+
$isDefault = $address->getShippingMethod() === $rate->getCode();
|
| 733 |
+
$amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address);
|
| 734 |
+
$amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address);
|
| 735 |
+
|
| 736 |
+
$options[$i] = new Varien_Object(array(
|
| 737 |
+
'is_default' => $isDefault,
|
| 738 |
+
'name' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'),
|
| 739 |
+
'code' => $rate->getCode(),
|
| 740 |
+
'amount' => $amountExclTax,
|
| 741 |
+
));
|
| 742 |
+
if ($calculateTax) {
|
| 743 |
+
$options[$i]->setTaxAmount(
|
| 744 |
+
$amountInclTax - $amountExclTax
|
| 745 |
+
+ $address->getTaxAmount() - $address->getShippingTaxAmount()
|
| 746 |
+
);
|
| 747 |
+
}
|
| 748 |
+
if ($isDefault) {
|
| 749 |
+
$userSelectedOption = $options[$i];
|
| 750 |
+
}
|
| 751 |
+
if (false === $min || $amountInclTax < $min) {
|
| 752 |
+
$min = $amountInclTax;
|
| 753 |
+
$iMin = $i;
|
| 754 |
+
}
|
| 755 |
+
$i++;
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
if ($mayReturnEmpty && is_null($userSelectedOption)) {
|
| 760 |
+
$options[] = new Varien_Object(array(
|
| 761 |
+
'is_default' => true,
|
| 762 |
+
'name' => Mage::helper('paypalmx')->__('N/A'),
|
| 763 |
+
'code' => 'no_rate',
|
| 764 |
+
'amount' => 0.00,
|
| 765 |
+
));
|
| 766 |
+
if ($calculateTax) {
|
| 767 |
+
$options[$i]->setTaxAmount($address->getTaxAmount());
|
| 768 |
+
}
|
| 769 |
+
} elseif (is_null($userSelectedOption) && isset($options[$iMin])) {
|
| 770 |
+
$options[$iMin]->setIsDefault(true);
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
// Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
|
| 774 |
+
if (count($options) > 10) {
|
| 775 |
+
usort($options, array(get_class($this),'cmpShippingOptions'));
|
| 776 |
+
array_splice($options, 10);
|
| 777 |
+
// User selected option will be always included in options list
|
| 778 |
+
if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
|
| 779 |
+
$options[9] = $userSelectedOption;
|
| 780 |
+
}
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
return $options;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
/**
|
| 787 |
+
* Compare two shipping options based on their amounts
|
| 788 |
+
*
|
| 789 |
+
* This function is used as a callback comparison function in shipping options sorting process
|
| 790 |
+
* @see self::_prepareShippingOptions()
|
| 791 |
+
*
|
| 792 |
+
* @param Varien_Object $option1
|
| 793 |
+
* @param Varien_Object $option2
|
| 794 |
+
* @return integer
|
| 795 |
+
*/
|
| 796 |
+
protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2)
|
| 797 |
+
{
|
| 798 |
+
if ($option1->getAmount() == $option2->getAmount()) {
|
| 799 |
+
return 0;
|
| 800 |
+
}
|
| 801 |
+
return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
/**
|
| 805 |
+
* Try to find whether the code provided by PayPal corresponds to any of possible shipping rates
|
| 806 |
+
* This method was created only because PayPal has issues with returning the selected code.
|
| 807 |
+
* If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code
|
| 808 |
+
* before collecting shipping rates
|
| 809 |
+
*
|
| 810 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 811 |
+
* @param string $selectedCode
|
| 812 |
+
* @return string
|
| 813 |
+
*/
|
| 814 |
+
protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode)
|
| 815 |
+
{
|
| 816 |
+
$options = $this->_prepareShippingOptions($address, false);
|
| 817 |
+
foreach ($options as $option) {
|
| 818 |
+
if ($selectedCode === $option['code'] // the proper case as outlined in documentation
|
| 819 |
+
|| $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code
|
| 820 |
+
// workaround: PayPal may concatenate code and name, and return it instead of the code:
|
| 821 |
+
|| $selectedCode === "{$option['code']} {$option['name']}"
|
| 822 |
+
) {
|
| 823 |
+
return $option['code'];
|
| 824 |
+
}
|
| 825 |
+
}
|
| 826 |
+
return '';
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
/**
|
| 830 |
+
* Prepare quote for guest checkout order submit
|
| 831 |
+
*
|
| 832 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 833 |
+
*/
|
| 834 |
+
protected function _prepareGuestQuote()
|
| 835 |
+
{
|
| 836 |
+
$quote = $this->_quote;
|
| 837 |
+
$quote->setCustomerId(null)
|
| 838 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
|
| 839 |
+
->setCustomerIsGuest(true)
|
| 840 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
| 841 |
+
return $this;
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
/**
|
| 845 |
+
* Prepare quote for customer registration and customer order submit
|
| 846 |
+
* and restore magento customer data from quote
|
| 847 |
+
*
|
| 848 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 849 |
+
*/
|
| 850 |
+
protected function _prepareNewCustomerQuote()
|
| 851 |
+
{
|
| 852 |
+
$quote = $this->_quote;
|
| 853 |
+
$billing = $quote->getBillingAddress();
|
| 854 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 855 |
+
|
| 856 |
+
$customer = $quote->getCustomer();
|
| 857 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 858 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 859 |
+
$customer->addAddress($customerBilling);
|
| 860 |
+
$billing->setCustomerAddress($customerBilling);
|
| 861 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 862 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
| 863 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 864 |
+
$customer->addAddress($customerShipping);
|
| 865 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 866 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 867 |
+
} elseif ($shipping) {
|
| 868 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 869 |
+
}
|
| 870 |
+
/**
|
| 871 |
+
* @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
|
| 872 |
+
*/
|
| 873 |
+
if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
|
| 874 |
+
$billing->setCustomerDob($quote->getCustomerDob());
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
|
| 878 |
+
$billing->setCustomerTaxvat($quote->getCustomerTaxvat());
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
|
| 882 |
+
$billing->setCustomerGender($quote->getCustomerGender());
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
| 886 |
+
$customer->setEmail($quote->getCustomerEmail());
|
| 887 |
+
$customer->setPrefix($quote->getCustomerPrefix());
|
| 888 |
+
$customer->setFirstname($quote->getCustomerFirstname());
|
| 889 |
+
$customer->setMiddlename($quote->getCustomerMiddlename());
|
| 890 |
+
$customer->setLastname($quote->getCustomerLastname());
|
| 891 |
+
$customer->setSuffix($quote->getCustomerSuffix());
|
| 892 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
| 893 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
| 894 |
+
$customer->save();
|
| 895 |
+
$quote->setCustomer($customer);
|
| 896 |
+
|
| 897 |
+
return $this;
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
/**
|
| 901 |
+
* Prepare quote for customer order submit
|
| 902 |
+
*
|
| 903 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 904 |
+
*/
|
| 905 |
+
protected function _prepareCustomerQuote()
|
| 906 |
+
{
|
| 907 |
+
$quote = $this->_quote;
|
| 908 |
+
$billing = $quote->getBillingAddress();
|
| 909 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 910 |
+
|
| 911 |
+
$customer = $this->getCustomerSession()->getCustomer();
|
| 912 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
| 913 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 914 |
+
$customer->addAddress($customerBilling);
|
| 915 |
+
$billing->setCustomerAddress($customerBilling);
|
| 916 |
+
}
|
| 917 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
| 918 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
| 919 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 920 |
+
$customer->addAddress($customerShipping);
|
| 921 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
| 925 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 926 |
+
}
|
| 927 |
+
if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
|
| 928 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 929 |
+
} elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
| 930 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 931 |
+
}
|
| 932 |
+
$quote->setCustomer($customer);
|
| 933 |
+
|
| 934 |
+
return $this;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
/**
|
| 938 |
+
* Involve new customer to system
|
| 939 |
+
*
|
| 940 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 941 |
+
*/
|
| 942 |
+
protected function _involveNewCustomer()
|
| 943 |
+
{
|
| 944 |
+
$customer = $this->_quote->getCustomer();
|
| 945 |
+
if ($customer->isConfirmationRequired()) {
|
| 946 |
+
$customer->sendNewAccountEmail('confirmation');
|
| 947 |
+
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
| 948 |
+
$this->getCustomerSession()->addSuccess(
|
| 949 |
+
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
|
| 950 |
+
);
|
| 951 |
+
} else {
|
| 952 |
+
$customer->sendNewAccountEmail();
|
| 953 |
+
$this->getCustomerSession()->loginById($customer->getId());
|
| 954 |
+
}
|
| 955 |
+
return $this;
|
| 956 |
+
}
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Get customer session object
|
| 960 |
+
*
|
| 961 |
+
* @return Mage_Customer_Model_Session
|
| 962 |
+
*/
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* PayPal Express Module
|
| 6 |
+
*/
|
| 7 |
+
class Ebcomm_PaypalMx_Model_Express extends Mage_Payment_Model_Method_Abstract
|
| 8 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
| 9 |
+
{
|
| 10 |
+
protected $_code = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 11 |
+
protected $_formBlockType = 'paypalmx/express_form';
|
| 12 |
+
protected $_infoBlockType = 'paypalmx/payment_info';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Website Payments Pro instance type
|
| 16 |
+
*
|
| 17 |
+
* @var $_proType string
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Availability options
|
| 22 |
+
*/
|
| 23 |
+
protected $_isGateway = false;
|
| 24 |
+
protected $_canOrder = true;
|
| 25 |
+
protected $_canAuthorize = true;
|
| 26 |
+
protected $_canCapture = true;
|
| 27 |
+
protected $_canCapturePartial = true;
|
| 28 |
+
protected $_canRefund = true;
|
| 29 |
+
protected $_canRefundInvoicePartial = true;
|
| 30 |
+
protected $_canVoid = true;
|
| 31 |
+
protected $_canUseInternal = false;
|
| 32 |
+
protected $_canUseCheckout = true;
|
| 33 |
+
protected $_canUseForMultishipping = false;
|
| 34 |
+
protected $_canFetchTransactionInfo = true;
|
| 35 |
+
protected $_canCreateBillingAgreement = true;
|
| 36 |
+
protected $_canReviewPayment = false;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Website Payments Pro instance
|
| 40 |
+
*
|
| 41 |
+
* @var Mage_Paypal_Model_Pro
|
| 42 |
+
*/
|
| 43 |
+
protected $_pro = null;
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Payment additional information key for payment action
|
| 47 |
+
* @var string
|
| 48 |
+
*/
|
| 49 |
+
protected $_isOrderPaymentActionKey = 'is_order_action';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Payment additional information key for number of used authorizations
|
| 53 |
+
* @var string
|
| 54 |
+
*/
|
| 55 |
+
protected $_authorizationCountKey = 'authorization_count';
|
| 56 |
+
|
| 57 |
+
public function __construct($params = array())
|
| 58 |
+
{
|
| 59 |
+
|
| 60 |
+
$proInstance = array_shift($params);
|
| 61 |
+
if ($proInstance && ($proInstance instanceof Ebcomm_PaypalMx_Model_Pro)) {
|
| 62 |
+
|
| 63 |
+
$this->_pro = $proInstance;
|
| 64 |
+
} else {
|
| 65 |
+
$this->_pro = Mage::getModel('paypalmx/pro');
|
| 66 |
+
}
|
| 67 |
+
$this->_pro->setMethod($this->_code);
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Store setter
|
| 73 |
+
* Also updates store ID in config object
|
| 74 |
+
*
|
| 75 |
+
* @param Mage_Core_Model_Store|int $store
|
| 76 |
+
*/
|
| 77 |
+
public function setStore($store)
|
| 78 |
+
{
|
| 79 |
+
$this->setData('store', $store);
|
| 80 |
+
if (null === $store) {
|
| 81 |
+
$store = Mage::app()->getStore()->getId();
|
| 82 |
+
}
|
| 83 |
+
$this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store);
|
| 84 |
+
return $this;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Can be used in regular checkout
|
| 89 |
+
*
|
| 90 |
+
* @return bool
|
| 91 |
+
*/
|
| 92 |
+
public function canUseCheckout()
|
| 93 |
+
{
|
| 94 |
+
if (Mage::getStoreConfigFlag('payment/hosted_pro/active')
|
| 95 |
+
&& !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec')
|
| 96 |
+
) {
|
| 97 |
+
return false;
|
| 98 |
+
}
|
| 99 |
+
return parent::canUseCheckout();
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Whether method is available for specified currency
|
| 104 |
+
*
|
| 105 |
+
* @param string $currencyCode
|
| 106 |
+
* @return bool
|
| 107 |
+
*/
|
| 108 |
+
public function canUseForCurrency($currencyCode)
|
| 109 |
+
{
|
| 110 |
+
return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Payment action getter compatible with payment model
|
| 115 |
+
*
|
| 116 |
+
* @see Mage_Sales_Model_Payment::place()
|
| 117 |
+
* @return string
|
| 118 |
+
*/
|
| 119 |
+
public function getConfigPaymentAction()
|
| 120 |
+
{
|
| 121 |
+
return $this->_pro->getConfig()->getPaymentAction();
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Check whether payment method can be used
|
| 126 |
+
* @param Mage_Sales_Model_Quote
|
| 127 |
+
* @return bool
|
| 128 |
+
*/
|
| 129 |
+
public function isAvailable($quote = null)
|
| 130 |
+
{
|
| 131 |
+
if (/*parent::isAvailable($quote) && */$this->_pro->getConfig()->isMethodAvailable()) {
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
return false;
|
| 135 |
+
}
|
| 136 |
+
public function isContextAvailable($contextpos = null,$method = null)
|
| 137 |
+
{
|
| 138 |
+
if ($this->_pro->getConfig()->isContextAvailable($contextpos,$method)) {
|
| 139 |
+
return true;
|
| 140 |
+
}
|
| 141 |
+
return false;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Custom getter for payment configuration
|
| 146 |
+
*
|
| 147 |
+
* @param string $field
|
| 148 |
+
* @param int $storeId
|
| 149 |
+
* @return mixed
|
| 150 |
+
*/
|
| 151 |
+
public function getConfigData($field, $storeId = null)
|
| 152 |
+
{
|
| 153 |
+
return $this->_pro->getConfig()->$field;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Order payment
|
| 158 |
+
*
|
| 159 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 160 |
+
* @param float $amount
|
| 161 |
+
* @return Mage_Paypal_Model_Express
|
| 162 |
+
*/
|
| 163 |
+
public function order(Varien_Object $payment, $amount)
|
| 164 |
+
{
|
| 165 |
+
$this->_placeOrder($payment, $amount);
|
| 166 |
+
|
| 167 |
+
$payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
|
| 168 |
+
|
| 169 |
+
if ($payment->getIsFraudDetected()) {
|
| 170 |
+
return $this;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
$order = $payment->getOrder();
|
| 174 |
+
$orderTransactionId = $payment->getTransactionId();
|
| 175 |
+
|
| 176 |
+
$api = $this->_callDoAuthorize($amount, $payment, $payment->getTransactionId());
|
| 177 |
+
|
| 178 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
| 179 |
+
$status = true;
|
| 180 |
+
|
| 181 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 182 |
+
if ($payment->getIsTransactionPending()) {
|
| 183 |
+
$message = Mage::helper('paypalmx')->__('Ordering amount of %s is pending approval on gateway.', $formatedPrice);
|
| 184 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 185 |
+
} else {
|
| 186 |
+
$message = Mage::helper('paypalmx')->__('Ordered amount of %s.', $formatedPrice);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
|
| 190 |
+
|
| 191 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 192 |
+
|
| 193 |
+
if ($payment->getIsTransactionPending()) {
|
| 194 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 195 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 196 |
+
if ($payment->getIsFraudDetected()) {
|
| 197 |
+
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
|
| 198 |
+
}
|
| 199 |
+
} else {
|
| 200 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
$payment->resetTransactionAdditionalInfo();
|
| 204 |
+
|
| 205 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 206 |
+
$payment->setParentTransactionId($orderTransactionId);
|
| 207 |
+
|
| 208 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false,
|
| 209 |
+
$message
|
| 210 |
+
);
|
| 211 |
+
|
| 212 |
+
$order->setState($state, $status);
|
| 213 |
+
|
| 214 |
+
$payment->setSkipOrderProcessing(true);
|
| 215 |
+
return $this;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Authorize payment
|
| 220 |
+
*
|
| 221 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 222 |
+
* @param float $amount
|
| 223 |
+
* @return Mage_Paypal_Model_Express
|
| 224 |
+
*/
|
| 225 |
+
public function authorize(Varien_Object $payment, $amount)
|
| 226 |
+
{
|
| 227 |
+
return $this->_placeOrder($payment, $amount);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Void payment
|
| 232 |
+
*
|
| 233 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 234 |
+
* @return Mage_Paypal_Model_Express
|
| 235 |
+
*/
|
| 236 |
+
public function void(Varien_Object $payment)
|
| 237 |
+
{
|
| 238 |
+
//Switching to order transaction if needed
|
| 239 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)
|
| 240 |
+
&& !$payment->getVoidOnlyAuthorization()
|
| 241 |
+
) {
|
| 242 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 243 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 244 |
+
);
|
| 245 |
+
if ($orderTransaction) {
|
| 246 |
+
$payment->setParentTransactionId($orderTransaction->getTxnId());
|
| 247 |
+
$payment->setTransactionId($orderTransaction->getTxnId() . '-void');
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
$this->_pro->void($payment);
|
| 251 |
+
return $this;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Capture payment
|
| 256 |
+
*
|
| 257 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 258 |
+
* @param float $amount
|
| 259 |
+
* @return Mage_Paypal_Model_Express
|
| 260 |
+
*/
|
| 261 |
+
public function capture(Varien_Object $payment, $amount)
|
| 262 |
+
{
|
| 263 |
+
$authorizationTransaction = $payment->getAuthorizationTransaction();
|
| 264 |
+
$authorizationPeriod = abs(intval($this->getConfigData('authorization_honor_period')));
|
| 265 |
+
$maxAuthorizationNumber = abs(intval($this->getConfigData('child_authorization_number')));
|
| 266 |
+
$order = $payment->getOrder();
|
| 267 |
+
$isAuthorizationCreated = false;
|
| 268 |
+
|
| 269 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 270 |
+
$voided = false;
|
| 271 |
+
if (!$authorizationTransaction->getIsClosed()
|
| 272 |
+
&& $this->_isTransactionExpired($authorizationTransaction, $authorizationPeriod)
|
| 273 |
+
) {
|
| 274 |
+
//Save payment state and configure payment object for voiding
|
| 275 |
+
$isCaptureFinal = $payment->getShouldCloseParentTransaction();
|
| 276 |
+
$captureTrxId = $payment->getTransactionId();
|
| 277 |
+
$payment->setShouldCloseParentTransaction(false);
|
| 278 |
+
$payment->setParentTransactionId($authorizationTransaction->getTxnId());
|
| 279 |
+
$payment->unsTransactionId();
|
| 280 |
+
$payment->setVoidOnlyAuthorization(true);
|
| 281 |
+
$payment->void(new Varien_Object());
|
| 282 |
+
|
| 283 |
+
//Revert payment state after voiding
|
| 284 |
+
$payment->unsAuthorizationTransaction();
|
| 285 |
+
$payment->unsTransactionId();
|
| 286 |
+
$payment->setShouldCloseParentTransaction($isCaptureFinal);
|
| 287 |
+
$voided = true;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if ($authorizationTransaction->getIsClosed() || $voided) {
|
| 291 |
+
if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) {
|
| 292 |
+
Mage::throwException(Mage::helper('paypalmx')->__('The maximum number of child authorizations is reached.'));
|
| 293 |
+
}
|
| 294 |
+
$api = $this->_callDoAuthorize(
|
| 295 |
+
$amount,
|
| 296 |
+
$payment,
|
| 297 |
+
$authorizationTransaction->getParentTxnId()
|
| 298 |
+
);
|
| 299 |
+
|
| 300 |
+
//Adding authorization transaction
|
| 301 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 302 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 303 |
+
$payment->setParentTransactionId($authorizationTransaction->getParentTxnId());
|
| 304 |
+
$payment->setIsTransactionClosed(false);
|
| 305 |
+
|
| 306 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 307 |
+
|
| 308 |
+
if ($payment->getIsTransactionPending()) {
|
| 309 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 310 |
+
} else {
|
| 311 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null,
|
| 315 |
+
true, $message
|
| 316 |
+
);
|
| 317 |
+
|
| 318 |
+
$payment->setParentTransactionId($api->getTransactionId());
|
| 319 |
+
$isAuthorizationCreated = true;
|
| 320 |
+
}
|
| 321 |
+
//close order transaction if needed
|
| 322 |
+
if ($payment->getShouldCloseParentTransaction()) {
|
| 323 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 324 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 325 |
+
);
|
| 326 |
+
|
| 327 |
+
if ($orderTransaction) {
|
| 328 |
+
$orderTransaction->setIsClosed(true);
|
| 329 |
+
$order->addRelatedObject($orderTransaction);
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
if (false === $this->_pro->capture($payment, $amount)) {
|
| 335 |
+
$this->_placeOrder($payment, $amount);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
if ($isAuthorizationCreated && isset($transaction)) {
|
| 339 |
+
$transaction->setIsClosed(true);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
return $this;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
* Refund capture
|
| 347 |
+
*
|
| 348 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 349 |
+
* @param float $amount
|
| 350 |
+
* @return Mage_Paypal_Model_Express
|
| 351 |
+
*/
|
| 352 |
+
public function refund(Varien_Object $payment, $amount)
|
| 353 |
+
{
|
| 354 |
+
$this->_pro->refund($payment, $amount);
|
| 355 |
+
return $this;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Cancel payment
|
| 360 |
+
*
|
| 361 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 362 |
+
* @return Mage_Paypal_Model_Express
|
| 363 |
+
*/
|
| 364 |
+
public function cancel(Varien_Object $payment)
|
| 365 |
+
{
|
| 366 |
+
$this->void($payment);
|
| 367 |
+
|
| 368 |
+
return $this;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* Whether payment can be reviewed
|
| 373 |
+
*
|
| 374 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 375 |
+
* @return bool
|
| 376 |
+
*/
|
| 377 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 378 |
+
{
|
| 379 |
+
return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Attempt to accept a pending payment
|
| 384 |
+
*
|
| 385 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 386 |
+
* @return bool
|
| 387 |
+
*/
|
| 388 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
| 389 |
+
{
|
| 390 |
+
parent::acceptPayment($payment);
|
| 391 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_ACCEPT);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Attempt to deny a pending payment
|
| 396 |
+
*
|
| 397 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 398 |
+
* @return bool
|
| 399 |
+
*/
|
| 400 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
| 401 |
+
{
|
| 402 |
+
parent::denyPayment($payment);
|
| 403 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_DENY);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* Checkout redirect URL getter for onepage checkout (hardcode)
|
| 408 |
+
*
|
| 409 |
+
* @see Mage_Checkout_OnepageController::savePaymentAction()
|
| 410 |
+
* @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
|
| 411 |
+
* @return string
|
| 412 |
+
*/
|
| 413 |
+
public function getCheckoutRedirectUrl()
|
| 414 |
+
{
|
| 415 |
+
return Mage::getUrl('paypalmx/express/start');
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
/**
|
| 419 |
+
* Fetch transaction details info
|
| 420 |
+
*
|
| 421 |
+
* @param Mage_Payment_Model_Info $payment
|
| 422 |
+
* @param string $transactionId
|
| 423 |
+
* @return array
|
| 424 |
+
*/
|
| 425 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 426 |
+
{
|
| 427 |
+
return $this->_pro->fetchTransactionInfo($payment, $transactionId);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* Validate RP data
|
| 432 |
+
*
|
| 433 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 434 |
+
*/
|
| 435 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 436 |
+
{
|
| 437 |
+
return $this->_pro->validateRecurringProfile($profile);
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* Submit RP to the gateway
|
| 442 |
+
*
|
| 443 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 444 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 445 |
+
*/
|
| 446 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 447 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 448 |
+
) {
|
| 449 |
+
$token = $paymentInfo->
|
| 450 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 451 |
+
$profile->setToken($token);
|
| 452 |
+
$this->_pro->submitRecurringProfile($profile, $paymentInfo);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Fetch RP details
|
| 457 |
+
*
|
| 458 |
+
* @param string $referenceId
|
| 459 |
+
* @param Varien_Object $result
|
| 460 |
+
*/
|
| 461 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 462 |
+
{
|
| 463 |
+
return $this->_pro->getRecurringProfileDetails($referenceId, $result);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
/**
|
| 467 |
+
* Whether can get recurring profile details
|
| 468 |
+
*/
|
| 469 |
+
public function canGetRecurringProfileDetails()
|
| 470 |
+
{
|
| 471 |
+
return true;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* Update RP data
|
| 476 |
+
*
|
| 477 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 478 |
+
*/
|
| 479 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 480 |
+
{
|
| 481 |
+
return $this->_pro->updateRecurringProfile($profile);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* Manage status
|
| 486 |
+
*
|
| 487 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 488 |
+
*/
|
| 489 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 490 |
+
{
|
| 491 |
+
return $this->_pro->updateRecurringProfileStatus($profile);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/**
|
| 495 |
+
* Assign data to info model instance
|
| 496 |
+
*
|
| 497 |
+
* @param mixed $data
|
| 498 |
+
* @return Mage_Payment_Model_Info
|
| 499 |
+
*/
|
| 500 |
+
public function assignData($data)
|
| 501 |
+
{
|
| 502 |
+
$result = parent::assignData($data);
|
| 503 |
+
$key = Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
|
| 504 |
+
if (is_array($data)) {
|
| 505 |
+
$this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
|
| 506 |
+
}
|
| 507 |
+
elseif ($data instanceof Varien_Object) {
|
| 508 |
+
$this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
|
| 509 |
+
}
|
| 510 |
+
return $result;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
/**
|
| 514 |
+
* Place an order with authorization or capture action
|
| 515 |
+
*
|
| 516 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 517 |
+
* @param float $amount
|
| 518 |
+
* @return Mage_Paypal_Model_Express
|
| 519 |
+
*/
|
| 520 |
+
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
|
| 521 |
+
{
|
| 522 |
+
$order = $payment->getOrder();
|
| 523 |
+
|
| 524 |
+
// prepare api call
|
| 525 |
+
$token = $payment->getAdditionalInformation(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 526 |
+
$api = $this->_pro->getApi()
|
| 527 |
+
->setToken($token)
|
| 528 |
+
->setPayerId($payment->
|
| 529 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))
|
| 530 |
+
->setAmount($amount)
|
| 531 |
+
->setPaymentAction($this->_pro->getConfig()->paymentAction)
|
| 532 |
+
->setNotifyUrl(Mage::getUrl('paypalmx/ipn/'))
|
| 533 |
+
->setInvNum($order->getIncrementId()."MGT".date("YmdHis"))
|
| 534 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
| 535 |
+
->setPaypalCart(Mage::getModel('paypalmx/cart', array($order)))
|
| 536 |
+
->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)
|
| 537 |
+
;
|
| 538 |
+
if ($order->getIsVirtual()) {
|
| 539 |
+
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
|
| 540 |
+
} else {
|
| 541 |
+
$api->setAddress($order->getShippingAddress());
|
| 542 |
+
$api->setBillingAddress($order->getBillingAddress());
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
// call api and get details from it
|
| 546 |
+
$api->callDoExpressCheckoutPayment();
|
| 547 |
+
|
| 548 |
+
$this->_importToPayment($api, $payment);
|
| 549 |
+
return $this;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
* Import payment info to payment
|
| 554 |
+
*
|
| 555 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 556 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 557 |
+
*/
|
| 558 |
+
protected function _importToPayment($api, $payment)
|
| 559 |
+
{
|
| 560 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)
|
| 561 |
+
->setAdditionalInformation(Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT,
|
| 562 |
+
$api->getRedirectRequired()
|
| 563 |
+
);
|
| 564 |
+
|
| 565 |
+
if ($api->getBillingAgreementId()) {
|
| 566 |
+
$payment->setBillingAgreementData(array(
|
| 567 |
+
'billing_agreement_id' => $api->getBillingAgreementId(),
|
| 568 |
+
'method_code' => Ebcomm_PaypalMx_Model_Config::METHOD_BILLING_AGREEMENT
|
| 569 |
+
));
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 573 |
+
}
|
| 574 |
+
|
| 575 |
+
/**
|
| 576 |
+
* Check void availability
|
| 577 |
+
*
|
| 578 |
+
* @param Varien_Object $payment
|
| 579 |
+
* @return bool
|
| 580 |
+
*/
|
| 581 |
+
public function canVoid(Varien_Object $payment)
|
| 582 |
+
{
|
| 583 |
+
if ($payment instanceof Mage_Sales_Model_Order_Invoice
|
| 584 |
+
|| $payment instanceof Mage_Sales_Model_Order_Creditmemo
|
| 585 |
+
) {
|
| 586 |
+
return false;
|
| 587 |
+
}
|
| 588 |
+
$info = $this->getInfoInstance();
|
| 589 |
+
if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 590 |
+
$orderTransaction = $info->lookupTransaction(
|
| 591 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 592 |
+
);
|
| 593 |
+
if ($orderTransaction) {
|
| 594 |
+
$info->setParentTransactionId($orderTransaction->getTxnId());
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
return $this->_canVoid;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* Check capture availability
|
| 603 |
+
*
|
| 604 |
+
* @return bool
|
| 605 |
+
*/
|
| 606 |
+
public function canCapture()
|
| 607 |
+
{
|
| 608 |
+
$payment = $this->getInfoInstance();
|
| 609 |
+
$this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId());
|
| 610 |
+
|
| 611 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 612 |
+
$orderTransaction = $payment->lookupTransaction(false,
|
| 613 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 614 |
+
);
|
| 615 |
+
if ($orderTransaction->getIsClosed()) {
|
| 616 |
+
return false;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
$orderValidPeriod = abs(intval($this->getConfigData('order_valid_period')));
|
| 620 |
+
|
| 621 |
+
$dateCompass = new DateTime($orderTransaction->getCreatedAt());
|
| 622 |
+
$dateCompass->modify('+' . $orderValidPeriod . ' days');
|
| 623 |
+
$currentDate = new DateTime();
|
| 624 |
+
|
| 625 |
+
if ($currentDate > $dateCompass || $orderValidPeriod == 0) {
|
| 626 |
+
return false;
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
+
return $this->_canCapture;
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
/**
|
| 633 |
+
* Call DoAuthorize
|
| 634 |
+
*
|
| 635 |
+
* @param int $amount
|
| 636 |
+
* @param Varien_Object $payment
|
| 637 |
+
* @param string $parentTransactionId
|
| 638 |
+
* @return Mage_Paypal_Model_Api_Abstract
|
| 639 |
+
*/
|
| 640 |
+
protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
|
| 641 |
+
{
|
| 642 |
+
$api = $this->_pro->resetApi()->getApi()
|
| 643 |
+
->setAmount($amount)
|
| 644 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 645 |
+
->setTransactionId($parentTransactionId)
|
| 646 |
+
->callDoAuthorization();
|
| 647 |
+
|
| 648 |
+
$payment->setAdditionalInformation($this->_authorizationCountKey,
|
| 649 |
+
$payment->getAdditionalInformation($this->_authorizationCountKey) + 1
|
| 650 |
+
);
|
| 651 |
+
|
| 652 |
+
return $api;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* Check transaction for expiration in PST
|
| 657 |
+
*
|
| 658 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
| 659 |
+
* @param int $period
|
| 660 |
+
* @return boolean
|
| 661 |
+
*/
|
| 662 |
+
protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transaction $transaction, $period)
|
| 663 |
+
{
|
| 664 |
+
$period = intval($period);
|
| 665 |
+
if (0 == $period) {
|
| 666 |
+
return true;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
$transactionClosingDate = new DateTime($transaction->getCreatedAt(), new DateTimeZone('GMT'));
|
| 670 |
+
$transactionClosingDate->setTimezone(new DateTimeZone('US/Pacific'));
|
| 671 |
+
/**
|
| 672 |
+
* 11:49:00 PayPal transactions closing time
|
| 673 |
+
*/
|
| 674 |
+
$transactionClosingDate->setTime(11, 49, 00);
|
| 675 |
+
$transactionClosingDate->modify('+' . $period . ' days');
|
| 676 |
+
|
| 677 |
+
$currentTime = new DateTime(null, new DateTimeZone('US/Pacific'));
|
| 678 |
+
|
| 679 |
+
if ($currentTime > $transactionClosingDate) {
|
| 680 |
+
return true;
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
return false;
|
| 684 |
+
}
|
| 685 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Express/Checkout.php
ADDED
|
@@ -0,0 +1,967 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Express_Checkout
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cache ID prefix for "pal" lookup
|
| 6 |
+
* @var string
|
| 7 |
+
*/
|
| 8 |
+
const PAL_CACHE_ID = 'paypalmx_express_checkout_pal';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Keys for passthrough variables in sales/quote_payment and sales/order_payment
|
| 12 |
+
* Uses additional_information as storage
|
| 13 |
+
* @var string
|
| 14 |
+
*/
|
| 15 |
+
const PAYMENT_INFO_TRANSPORT_TOKEN = 'paypalmx_express_checkout_token';
|
| 16 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN = 'paypalmx_express_checkout_shipping_overriden';
|
| 17 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD = 'paypalmx_express_checkout_shipping_method';
|
| 18 |
+
const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypalmx_express_checkout_payer_id';
|
| 19 |
+
const PAYMENT_INFO_TRANSPORT_REDIRECT = 'paypalmx_express_checkout_redirect_required';
|
| 20 |
+
const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'paypalmx_ec_create_ba';
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @var Mage_Sales_Model_Quote
|
| 24 |
+
*/
|
| 25 |
+
protected $_quote = null;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Config instance
|
| 29 |
+
* @var Mage_Paypal_Model_Config
|
| 30 |
+
*/
|
| 31 |
+
protected $_config = null;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* API instance
|
| 35 |
+
* @var Mage_Paypal_Model_Api_Nvp
|
| 36 |
+
*/
|
| 37 |
+
protected $_api = null;
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Api Model Type
|
| 41 |
+
*
|
| 42 |
+
* @var string
|
| 43 |
+
*/
|
| 44 |
+
protected $_apiType = 'paypalmx/api_nvp';
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Payment method type
|
| 48 |
+
*
|
| 49 |
+
* @var unknown_type
|
| 50 |
+
*/
|
| 51 |
+
protected $_methodType = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* State helper variables
|
| 55 |
+
* @var string
|
| 56 |
+
*/
|
| 57 |
+
protected $_redirectUrl = '';
|
| 58 |
+
protected $_pendingPaymentMessage = '';
|
| 59 |
+
protected $_checkoutRedirectUrl = '';
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @var Mage_Customer_Model_Session
|
| 63 |
+
*/
|
| 64 |
+
protected $_customerSession;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Redirect urls supposed to be set to support giropay
|
| 68 |
+
*
|
| 69 |
+
* @var array
|
| 70 |
+
*/
|
| 71 |
+
protected $_giropayUrls = array();
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Create Billing Agreement flag
|
| 75 |
+
*
|
| 76 |
+
* @var bool
|
| 77 |
+
*/
|
| 78 |
+
protected $_isBARequested = false;
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Customer ID
|
| 82 |
+
*
|
| 83 |
+
* @var int
|
| 84 |
+
*/
|
| 85 |
+
protected $_customerId = null;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Recurring payment profiles
|
| 89 |
+
*
|
| 90 |
+
* @var array
|
| 91 |
+
*/
|
| 92 |
+
protected $_recurringPaymentProfiles = array();
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Billing agreement that might be created during order placing
|
| 96 |
+
*
|
| 97 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
| 98 |
+
*/
|
| 99 |
+
protected $_billingAgreement = null;
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Order
|
| 103 |
+
*
|
| 104 |
+
* @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
|
| 105 |
+
*/
|
| 106 |
+
protected $_order = null;
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Set quote and config instances
|
| 110 |
+
* @param array $params
|
| 111 |
+
*/
|
| 112 |
+
public function __construct($params = array())
|
| 113 |
+
{
|
| 114 |
+
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
| 115 |
+
$this->_quote = $params['quote'];
|
| 116 |
+
} else {
|
| 117 |
+
throw new Exception('Quote instance is required.');
|
| 118 |
+
}
|
| 119 |
+
if (isset($params['config']) && $params['config'] instanceof Ebcomm_PaypalMx_Model_Config) {
|
| 120 |
+
$this->_config = $params['config'];
|
| 121 |
+
} else {
|
| 122 |
+
throw new Exception('Config instance is required.');
|
| 123 |
+
}
|
| 124 |
+
$this->_customerSession = Mage::getSingleton('customer/session');
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Checkout with PayPal image URL getter
|
| 129 |
+
* Spares API calls of getting "pal" variable, by putting it into cache per store view
|
| 130 |
+
* @return string
|
| 131 |
+
*/
|
| 132 |
+
public function getCheckoutShortcutImageUrl()
|
| 133 |
+
{
|
| 134 |
+
// get "pal" thing from cache or lookup it via API
|
| 135 |
+
$pal = null;
|
| 136 |
+
if ($this->_config->areButtonsDynamic()) {
|
| 137 |
+
$cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId();
|
| 138 |
+
$pal = Mage::app()->loadCache($cacheId);
|
| 139 |
+
if (-1 == $pal) {
|
| 140 |
+
$pal = null;
|
| 141 |
+
} elseif (!$pal) {
|
| 142 |
+
$pal = null;
|
| 143 |
+
$this->_getApi();
|
| 144 |
+
try {
|
| 145 |
+
$this->_api->callGetPalDetails();
|
| 146 |
+
$pal = $this->_api->getPal();
|
| 147 |
+
Mage::app()->saveCache($pal, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 148 |
+
} catch (Exception $e) {
|
| 149 |
+
Mage::app()->saveCache(-1, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 150 |
+
Mage::logException($e);
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
return $this->_config->getExpressCheckoutShortcutImageUrl(
|
| 156 |
+
Mage::app()->getLocale()->getLocaleCode(),
|
| 157 |
+
$this->_quote->getBaseGrandTotal(),
|
| 158 |
+
$pal
|
| 159 |
+
);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Setter that enables giropay redirects flow
|
| 164 |
+
*
|
| 165 |
+
* @param string $successUrl - payment success result
|
| 166 |
+
* @param string $cancelUrl - payment cancellation result
|
| 167 |
+
* @param string $pendingUrl - pending payment result
|
| 168 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 169 |
+
*/
|
| 170 |
+
public function prepareGiropayUrls($successUrl, $cancelUrl, $pendingUrl)
|
| 171 |
+
{
|
| 172 |
+
$this->_giropayUrls = array($successUrl, $cancelUrl, $pendingUrl);
|
| 173 |
+
return $this;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Set create billing agreement flag
|
| 178 |
+
*
|
| 179 |
+
* @param bool $flag
|
| 180 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 181 |
+
*/
|
| 182 |
+
public function setIsBillingAgreementRequested($flag)
|
| 183 |
+
{
|
| 184 |
+
$this->_isBARequested = $flag;
|
| 185 |
+
return $this;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Setter for customer Id
|
| 190 |
+
*
|
| 191 |
+
* @param int $id
|
| 192 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 193 |
+
* @deprecated please use self::setCustomer
|
| 194 |
+
*/
|
| 195 |
+
public function setCustomerId($id)
|
| 196 |
+
{
|
| 197 |
+
$this->_customerId = $id;
|
| 198 |
+
return $this;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Setter for customer
|
| 203 |
+
*
|
| 204 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 205 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 206 |
+
*/
|
| 207 |
+
public function setCustomer($customer)
|
| 208 |
+
{
|
| 209 |
+
$this->_quote->assignCustomer($customer);
|
| 210 |
+
$this->_customerId = $customer->getId();
|
| 211 |
+
return $this;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* Setter for customer with billing and shipping address changing ability
|
| 216 |
+
*
|
| 217 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 218 |
+
* @param Mage_Sales_Model_Quote_Address $billingAddress
|
| 219 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 220 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 221 |
+
*/
|
| 222 |
+
public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null)
|
| 223 |
+
{
|
| 224 |
+
$this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress);
|
| 225 |
+
$this->_customerId = $customer->getId();
|
| 226 |
+
return $this;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Reserve order ID for specified quote and start checkout on PayPal
|
| 231 |
+
*
|
| 232 |
+
* @param string $returnUrl
|
| 233 |
+
* @param string $cancelUrl
|
| 234 |
+
* @return mixed
|
| 235 |
+
*/
|
| 236 |
+
public function start($returnUrl, $cancelUrl)
|
| 237 |
+
{
|
| 238 |
+
$this->_quote->collectTotals();
|
| 239 |
+
|
| 240 |
+
if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
|
| 241 |
+
Mage::throwException(Mage::helper('paypalmx')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$this->_quote->reserveOrderId()->save();
|
| 245 |
+
// prepare API
|
| 246 |
+
$this->_getApi();
|
| 247 |
+
$this->_api->setAmount($this->_quote->getBaseGrandTotal())
|
| 248 |
+
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
|
| 249 |
+
->setInvNum($this->_quote->getReservedOrderId()."MGT".date("YmdHis"))
|
| 250 |
+
->setReturnUrl($returnUrl)
|
| 251 |
+
->setCancelUrl($cancelUrl)
|
| 252 |
+
->setSolutionType($this->_config->solutionType)
|
| 253 |
+
->setPaymentAction($this->_config->paymentAction)
|
| 254 |
+
;
|
| 255 |
+
if ($this->_giropayUrls) {
|
| 256 |
+
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
|
| 257 |
+
$this->_api->addData(array(
|
| 258 |
+
'giropay_cancel_url' => $cancelUrl,
|
| 259 |
+
'giropay_success_url' => $successUrl,
|
| 260 |
+
'giropay_bank_txn_pending_url' => $pendingUrl,
|
| 261 |
+
));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
$this->_setBillingAgreementRequest();
|
| 265 |
+
|
| 266 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) {
|
| 267 |
+
$this->_api->setRequireBillingAddress(1);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// supress or export shipping address
|
| 271 |
+
if ($this->_quote->getIsVirtual()) {
|
| 272 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
|
| 273 |
+
$this->_api->setRequireBillingAddress(1);
|
| 274 |
+
}
|
| 275 |
+
$this->_api->setSuppressShipping(true);
|
| 276 |
+
} else {
|
| 277 |
+
$address = $this->_quote->getShippingAddress();
|
| 278 |
+
$isOverriden = 0;
|
| 279 |
+
if (true === $address->validate()) {
|
| 280 |
+
$isOverriden = 1;
|
| 281 |
+
$this->_api->setAddress($address);
|
| 282 |
+
}
|
| 283 |
+
$this->_quote->getPayment()->setAdditionalInformation(
|
| 284 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
|
| 285 |
+
);
|
| 286 |
+
$this->_quote->getPayment()->save();
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
// add line items
|
| 290 |
+
$paypalCart = Mage::getModel('paypalmx/cart', array($this->_quote));
|
| 291 |
+
$this->_api->setPaypalCart($paypalCart)
|
| 292 |
+
->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
|
| 293 |
+
;
|
| 294 |
+
|
| 295 |
+
// add shipping options if needed and line items are available
|
| 296 |
+
if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
|
| 297 |
+
if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
|
| 298 |
+
if ($options = $this->_prepareShippingOptions($address, true)) {
|
| 299 |
+
$this->_api->setShippingOptionsCallbackUrl(
|
| 300 |
+
Mage::getUrl('*/*/shippingOptionsCallback', array('quote_id' => $this->_quote->getId()))
|
| 301 |
+
)->setShippingOptions($options);
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// add recurring payment profiles information
|
| 307 |
+
if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
|
| 308 |
+
foreach ($profiles as $profile) {
|
| 309 |
+
$profile->setMethodCode(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX);
|
| 310 |
+
if (!$profile->isValid()) {
|
| 311 |
+
Mage::throwException($profile->getValidationErrors(true, true));
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
$this->_api->addRecurringPaymentProfiles($profiles);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
|
| 318 |
+
|
| 319 |
+
// call API and redirect with token
|
| 320 |
+
$this->_api->callSetExpressCheckout();
|
| 321 |
+
$token = $this->_api->getToken();
|
| 322 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
|
| 323 |
+
|
| 324 |
+
$this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 325 |
+
$this->_quote->getPayment()->save();
|
| 326 |
+
return $token;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
/**
|
| 330 |
+
* Update quote when returned from PayPal
|
| 331 |
+
* rewrite billing address by paypal
|
| 332 |
+
* save old billing address for new customer
|
| 333 |
+
* export shipping address in case address absence
|
| 334 |
+
*
|
| 335 |
+
* @param string $token
|
| 336 |
+
*/
|
| 337 |
+
public function returnFromPaypal($token)
|
| 338 |
+
{
|
| 339 |
+
$this->_getApi();
|
| 340 |
+
$this->_api->setToken($token)
|
| 341 |
+
->callGetExpressCheckoutDetails();
|
| 342 |
+
$quote = $this->_quote;
|
| 343 |
+
|
| 344 |
+
$this->_ignoreAddressValidation();
|
| 345 |
+
|
| 346 |
+
// import billing address
|
| 347 |
+
$billingAddress = $quote->getBillingAddress();
|
| 348 |
+
$exportedBillingAddress = $this->_api->getExportedBillingAddress();
|
| 349 |
+
$quote->setCustomerEmail($billingAddress->getEmail());
|
| 350 |
+
$quote->setCustomerPrefix($billingAddress->getPrefix());
|
| 351 |
+
$quote->setCustomerFirstname($billingAddress->getFirstname());
|
| 352 |
+
$quote->setCustomerMiddlename($billingAddress->getMiddlename());
|
| 353 |
+
$quote->setCustomerLastname($billingAddress->getLastname());
|
| 354 |
+
$quote->setCustomerSuffix($billingAddress->getSuffix());
|
| 355 |
+
$quote->setCustomerNote($exportedBillingAddress->getData('note'));
|
| 356 |
+
$this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
|
| 357 |
+
|
| 358 |
+
// import shipping address
|
| 359 |
+
$exportedShippingAddress = $this->_api->getExportedShippingAddress();
|
| 360 |
+
if (!$quote->getIsVirtual()) {
|
| 361 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 362 |
+
if ($shippingAddress) {
|
| 363 |
+
if ($exportedShippingAddress) {
|
| 364 |
+
$this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
|
| 365 |
+
$shippingAddress->setCollectShippingRates(true);
|
| 366 |
+
$shippingAddress->setSameAsBilling(0);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
// import shipping method
|
| 370 |
+
$code = '';
|
| 371 |
+
if ($this->_api->getShippingRateCode()) {
|
| 372 |
+
if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
|
| 373 |
+
// possible bug of double collecting rates :-/
|
| 374 |
+
$shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
$quote->getPayment()->setAdditionalInformation(
|
| 378 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD,
|
| 379 |
+
$code
|
| 380 |
+
);
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// import payment info
|
| 385 |
+
$payment = $quote->getPayment();
|
| 386 |
+
$payment->setMethod($this->_methodType);
|
| 387 |
+
Mage::getSingleton('paypalmx/info')->importToPayment($this->_api, $payment);
|
| 388 |
+
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())
|
| 389 |
+
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
|
| 390 |
+
;
|
| 391 |
+
$quote->collectTotals()->save();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Check whether order review has enough data to initialize
|
| 396 |
+
*
|
| 397 |
+
* @param $token
|
| 398 |
+
* @throws Mage_Core_Exception
|
| 399 |
+
*/
|
| 400 |
+
public function prepareOrderReview($token = null)
|
| 401 |
+
{
|
| 402 |
+
$payment = $this->_quote->getPayment();
|
| 403 |
+
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
|
| 404 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Payer is not identified.'));
|
| 405 |
+
}
|
| 406 |
+
$this->_quote->setMayEditShippingAddress(
|
| 407 |
+
1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN)
|
| 408 |
+
);
|
| 409 |
+
$this->_quote->setMayEditShippingMethod(
|
| 410 |
+
'' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
|
| 411 |
+
);
|
| 412 |
+
$this->_ignoreAddressValidation();
|
| 413 |
+
$this->_quote->collectTotals()->save();
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* Return callback response with shipping options
|
| 418 |
+
*
|
| 419 |
+
* @param array $request
|
| 420 |
+
* @return string
|
| 421 |
+
*/
|
| 422 |
+
public function getShippingOptionsCallbackResponse(array $request)
|
| 423 |
+
{
|
| 424 |
+
// prepare debug data
|
| 425 |
+
$logger = Mage::getModel('core/log_adapter', 'payment_' . $this->_methodType . '.log');
|
| 426 |
+
$debugData = array('request' => $request, 'response' => array());
|
| 427 |
+
|
| 428 |
+
try {
|
| 429 |
+
// obtain addresses
|
| 430 |
+
$this->_getApi();
|
| 431 |
+
$address = $this->_api->prepareShippingOptionsCallbackAddress($request);
|
| 432 |
+
$quoteAddress = $this->_quote->getShippingAddress();
|
| 433 |
+
|
| 434 |
+
// compare addresses, calculate shipping rates and prepare response
|
| 435 |
+
$options = array();
|
| 436 |
+
if ($address && $quoteAddress && !$this->_quote->getIsVirtual()) {
|
| 437 |
+
foreach ($address->getExportedKeys() as $key) {
|
| 438 |
+
$quoteAddress->setDataUsingMethod($key, $address->getData($key));
|
| 439 |
+
}
|
| 440 |
+
$quoteAddress->setCollectShippingRates(true)->collectTotals();
|
| 441 |
+
$options = $this->_prepareShippingOptions($quoteAddress, false, true);
|
| 442 |
+
}
|
| 443 |
+
$response = $this->_api->setShippingOptions($options)->formatShippingOptionsCallback();
|
| 444 |
+
|
| 445 |
+
// log request and response
|
| 446 |
+
$debugData['response'] = $response;
|
| 447 |
+
$logger->log($debugData);
|
| 448 |
+
return $response;
|
| 449 |
+
} catch (Exception $e) {
|
| 450 |
+
$logger->log($debugData);
|
| 451 |
+
throw $e;
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Set shipping method to quote, if needed
|
| 457 |
+
* @param string $methodCode
|
| 458 |
+
*/
|
| 459 |
+
public function updateShippingMethod($methodCode)
|
| 460 |
+
{
|
| 461 |
+
if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
|
| 462 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
| 463 |
+
$this->_ignoreAddressValidation();
|
| 464 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
| 465 |
+
$this->_quote->collectTotals();
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Update order data
|
| 472 |
+
*
|
| 473 |
+
* @param array $data
|
| 474 |
+
*/
|
| 475 |
+
public function updateOrder($data)
|
| 476 |
+
{
|
| 477 |
+
/** @var $checkout Mage_Checkout_Model_Type_Onepage */
|
| 478 |
+
$checkout = Mage::getModel('checkout/type_onepage');
|
| 479 |
+
|
| 480 |
+
$this->_quote->setTotalsCollectedFlag(true);
|
| 481 |
+
$checkout->setQuote($this->_quote);
|
| 482 |
+
if (isset($data['billing'])) {
|
| 483 |
+
if (isset($data['customer-email'])) {
|
| 484 |
+
$data['billing']['email'] = $data['customer-email'];
|
| 485 |
+
}
|
| 486 |
+
$checkout->saveBilling($data['billing'], 0);
|
| 487 |
+
}
|
| 488 |
+
if (!$this->_quote->getIsVirtual() && isset($data['shipping'])) {
|
| 489 |
+
$checkout->saveShipping($data['shipping'], 0);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
if (isset($data['shipping_method'])) {
|
| 493 |
+
$this->updateShippingMethod($data['shipping_method']);
|
| 494 |
+
}
|
| 495 |
+
$this->_quote->setTotalsCollectedFlag(false);
|
| 496 |
+
$this->_quote->collectTotals();
|
| 497 |
+
$this->_quote->setDataChanges(true);
|
| 498 |
+
$this->_quote->save();
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/**
|
| 502 |
+
* Place the order and recurring payment profiles when customer returned from paypal
|
| 503 |
+
* Until this moment all quote data must be valid
|
| 504 |
+
*
|
| 505 |
+
* @param string $token
|
| 506 |
+
* @param string $shippingMethodCode
|
| 507 |
+
*/
|
| 508 |
+
public function place($token, $shippingMethodCode = null)
|
| 509 |
+
{
|
| 510 |
+
if ($shippingMethodCode) {
|
| 511 |
+
$this->updateShippingMethod($shippingMethodCode);
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
$isNewCustomer = false;
|
| 515 |
+
switch ($this->getCheckoutMethod()) {
|
| 516 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
|
| 517 |
+
$this->_prepareGuestQuote();
|
| 518 |
+
break;
|
| 519 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
|
| 520 |
+
$this->_prepareNewCustomerQuote();
|
| 521 |
+
$isNewCustomer = true;
|
| 522 |
+
break;
|
| 523 |
+
default:
|
| 524 |
+
$this->_prepareCustomerQuote();
|
| 525 |
+
break;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
$this->_ignoreAddressValidation();
|
| 529 |
+
$this->_quote->collectTotals();
|
| 530 |
+
$service = Mage::getModel('sales/service_quote', $this->_quote);
|
| 531 |
+
$service->submitAll();
|
| 532 |
+
$this->_quote->save();
|
| 533 |
+
|
| 534 |
+
if ($isNewCustomer) {
|
| 535 |
+
try {
|
| 536 |
+
$this->_involveNewCustomer();
|
| 537 |
+
} catch (Exception $e) {
|
| 538 |
+
Mage::logException($e);
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
$this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
|
| 543 |
+
// TODO: send recurring profile emails
|
| 544 |
+
|
| 545 |
+
$order = $service->getOrder();
|
| 546 |
+
if (!$order) {
|
| 547 |
+
return;
|
| 548 |
+
}
|
| 549 |
+
$this->_billingAgreement = $order->getPayment()->getBillingAgreement();
|
| 550 |
+
|
| 551 |
+
// commence redirecting to finish payment, if paypal requires it
|
| 552 |
+
if ($order->getPayment()->getAdditionalInformation(
|
| 553 |
+
Ebcomm_PaypalMx_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT
|
| 554 |
+
)) {
|
| 555 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
switch ($order->getState()) {
|
| 559 |
+
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
|
| 560 |
+
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
| 561 |
+
// TODO
|
| 562 |
+
break;
|
| 563 |
+
// regular placement, when everything is ok
|
| 564 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
| 565 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
| 566 |
+
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
|
| 567 |
+
$order->sendNewOrderEmail();
|
| 568 |
+
break;
|
| 569 |
+
}
|
| 570 |
+
$this->_order = $order;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Make sure addresses will be saved without validation errors
|
| 575 |
+
*/
|
| 576 |
+
private function _ignoreAddressValidation()
|
| 577 |
+
{
|
| 578 |
+
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
| 579 |
+
if (!$this->_quote->getIsVirtual()) {
|
| 580 |
+
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
| 581 |
+
if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) {
|
| 582 |
+
$this->_quote->getBillingAddress()->setSameAsBilling(1);
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
/**
|
| 588 |
+
* Determine whether redirect somewhere specifically is required
|
| 589 |
+
*
|
| 590 |
+
* @return string
|
| 591 |
+
*/
|
| 592 |
+
public function getRedirectUrl()
|
| 593 |
+
{
|
| 594 |
+
return $this->_redirectUrl;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
/**
|
| 598 |
+
* Return recurring payment profiles
|
| 599 |
+
*
|
| 600 |
+
* @return array
|
| 601 |
+
*/
|
| 602 |
+
public function getRecurringPaymentProfiles()
|
| 603 |
+
{
|
| 604 |
+
return $this->_recurringPaymentProfiles;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/**
|
| 608 |
+
* Get created billing agreement
|
| 609 |
+
*
|
| 610 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
| 611 |
+
*/
|
| 612 |
+
public function getBillingAgreement()
|
| 613 |
+
{
|
| 614 |
+
return $this->_billingAgreement;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* Return order
|
| 619 |
+
*
|
| 620 |
+
* @return Mage_Sales_Model_Order
|
| 621 |
+
*/
|
| 622 |
+
public function getOrder()
|
| 623 |
+
{
|
| 624 |
+
return $this->_order;
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
/**
|
| 628 |
+
* Get checkout method
|
| 629 |
+
*
|
| 630 |
+
* @return string
|
| 631 |
+
*/
|
| 632 |
+
public function getCheckoutMethod()
|
| 633 |
+
{
|
| 634 |
+
if ($this->getCustomerSession()->isLoggedIn()) {
|
| 635 |
+
return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
| 636 |
+
}
|
| 637 |
+
if (!$this->_quote->getCheckoutMethod()) {
|
| 638 |
+
if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
|
| 639 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
| 640 |
+
} else {
|
| 641 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
return $this->_quote->getCheckoutMethod();
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
/**
|
| 648 |
+
* Sets address data from exported address
|
| 649 |
+
*
|
| 650 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 651 |
+
* @param array $exportedAddress
|
| 652 |
+
*/
|
| 653 |
+
protected function _setExportedAddressData($address, $exportedAddress)
|
| 654 |
+
{
|
| 655 |
+
foreach ($exportedAddress->getExportedKeys() as $key) {
|
| 656 |
+
$oldData = $address->getDataUsingMethod($key);
|
| 657 |
+
$isEmpty = null;
|
| 658 |
+
if (is_array($oldData)) {
|
| 659 |
+
foreach($oldData as $val) {
|
| 660 |
+
if(!empty($val)) {
|
| 661 |
+
$isEmpty = false;
|
| 662 |
+
break;
|
| 663 |
+
}
|
| 664 |
+
$isEmpty = true;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
if (empty($oldData) || $isEmpty === true) {
|
| 668 |
+
$address->setDataUsingMethod($key, $exportedAddress->getData($key));
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
/**
|
| 674 |
+
* Set create billing agreement flag to api call
|
| 675 |
+
*
|
| 676 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 677 |
+
*/
|
| 678 |
+
protected function _setBillingAgreementRequest()
|
| 679 |
+
{
|
| 680 |
+
if (!$this->_customerId || $this->_quote->hasNominalItems()) {
|
| 681 |
+
return $this;
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
$isRequested = $this->_isBARequested || $this->_quote->getPayment()
|
| 685 |
+
->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 686 |
+
|
| 687 |
+
if (!($this->_config->allow_ba_signup == Ebcomm_PaypalMx_Model_Config::EC_BA_SIGNUP_AUTO
|
| 688 |
+
|| $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
|
| 689 |
+
return $this;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
|
| 693 |
+
return $this;
|
| 694 |
+
}
|
| 695 |
+
$this->_api->setBillingType($this->_api->getBillingAgreementType());
|
| 696 |
+
return $this;
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
/**
|
| 700 |
+
* @return Mage_Paypal_Model_Api_Nvp
|
| 701 |
+
*/
|
| 702 |
+
protected function _getApi()
|
| 703 |
+
{
|
| 704 |
+
if (null === $this->_api) {
|
| 705 |
+
$this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
|
| 706 |
+
}
|
| 707 |
+
return $this->_api;
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/**
|
| 711 |
+
* Attempt to collect address shipping rates and return them for further usage in instant update API
|
| 712 |
+
* Returns empty array if it was impossible to obtain any shipping rate
|
| 713 |
+
* If there are shipping rates obtained, the method must return one of them as default.
|
| 714 |
+
*
|
| 715 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 716 |
+
* @param bool $mayReturnEmpty
|
| 717 |
+
* @return array|false
|
| 718 |
+
*/
|
| 719 |
+
protected function _prepareShippingOptions(
|
| 720 |
+
Mage_Sales_Model_Quote_Address $address,
|
| 721 |
+
$mayReturnEmpty = false, $calculateTax = false
|
| 722 |
+
) {
|
| 723 |
+
$options = array(); $i = 0; $iMin = false; $min = false;
|
| 724 |
+
$userSelectedOption = null;
|
| 725 |
+
|
| 726 |
+
foreach ($address->getGroupedAllShippingRates() as $group) {
|
| 727 |
+
foreach ($group as $rate) {
|
| 728 |
+
$amount = (float)$rate->getPrice();
|
| 729 |
+
if ($rate->getErrorMessage()) {
|
| 730 |
+
continue;
|
| 731 |
+
}
|
| 732 |
+
$isDefault = $address->getShippingMethod() === $rate->getCode();
|
| 733 |
+
$amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address);
|
| 734 |
+
$amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address);
|
| 735 |
+
|
| 736 |
+
$options[$i] = new Varien_Object(array(
|
| 737 |
+
'is_default' => $isDefault,
|
| 738 |
+
'name' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'),
|
| 739 |
+
'code' => $rate->getCode(),
|
| 740 |
+
'amount' => $amountExclTax,
|
| 741 |
+
));
|
| 742 |
+
if ($calculateTax) {
|
| 743 |
+
$options[$i]->setTaxAmount(
|
| 744 |
+
$amountInclTax - $amountExclTax
|
| 745 |
+
+ $address->getTaxAmount() - $address->getShippingTaxAmount()
|
| 746 |
+
);
|
| 747 |
+
}
|
| 748 |
+
if ($isDefault) {
|
| 749 |
+
$userSelectedOption = $options[$i];
|
| 750 |
+
}
|
| 751 |
+
if (false === $min || $amountInclTax < $min) {
|
| 752 |
+
$min = $amountInclTax;
|
| 753 |
+
$iMin = $i;
|
| 754 |
+
}
|
| 755 |
+
$i++;
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
if ($mayReturnEmpty && is_null($userSelectedOption)) {
|
| 760 |
+
$options[] = new Varien_Object(array(
|
| 761 |
+
'is_default' => true,
|
| 762 |
+
'name' => Mage::helper('paypalmx')->__('N/A'),
|
| 763 |
+
'code' => 'no_rate',
|
| 764 |
+
'amount' => 0.00,
|
| 765 |
+
));
|
| 766 |
+
if ($calculateTax) {
|
| 767 |
+
$options[$i]->setTaxAmount($address->getTaxAmount());
|
| 768 |
+
}
|
| 769 |
+
} elseif (is_null($userSelectedOption) && isset($options[$iMin])) {
|
| 770 |
+
$options[$iMin]->setIsDefault(true);
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
// Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
|
| 774 |
+
if (count($options) > 10) {
|
| 775 |
+
usort($options, array(get_class($this),'cmpShippingOptions'));
|
| 776 |
+
array_splice($options, 10);
|
| 777 |
+
// User selected option will be always included in options list
|
| 778 |
+
if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
|
| 779 |
+
$options[9] = $userSelectedOption;
|
| 780 |
+
}
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
return $options;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
/**
|
| 787 |
+
* Compare two shipping options based on their amounts
|
| 788 |
+
*
|
| 789 |
+
* This function is used as a callback comparison function in shipping options sorting process
|
| 790 |
+
* @see self::_prepareShippingOptions()
|
| 791 |
+
*
|
| 792 |
+
* @param Varien_Object $option1
|
| 793 |
+
* @param Varien_Object $option2
|
| 794 |
+
* @return integer
|
| 795 |
+
*/
|
| 796 |
+
protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2)
|
| 797 |
+
{
|
| 798 |
+
if ($option1->getAmount() == $option2->getAmount()) {
|
| 799 |
+
return 0;
|
| 800 |
+
}
|
| 801 |
+
return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
/**
|
| 805 |
+
* Try to find whether the code provided by PayPal corresponds to any of possible shipping rates
|
| 806 |
+
* This method was created only because PayPal has issues with returning the selected code.
|
| 807 |
+
* If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code
|
| 808 |
+
* before collecting shipping rates
|
| 809 |
+
*
|
| 810 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 811 |
+
* @param string $selectedCode
|
| 812 |
+
* @return string
|
| 813 |
+
*/
|
| 814 |
+
protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode)
|
| 815 |
+
{
|
| 816 |
+
$options = $this->_prepareShippingOptions($address, false);
|
| 817 |
+
foreach ($options as $option) {
|
| 818 |
+
if ($selectedCode === $option['code'] // the proper case as outlined in documentation
|
| 819 |
+
|| $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code
|
| 820 |
+
// workaround: PayPal may concatenate code and name, and return it instead of the code:
|
| 821 |
+
|| $selectedCode === "{$option['code']} {$option['name']}"
|
| 822 |
+
) {
|
| 823 |
+
return $option['code'];
|
| 824 |
+
}
|
| 825 |
+
}
|
| 826 |
+
return '';
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
/**
|
| 830 |
+
* Prepare quote for guest checkout order submit
|
| 831 |
+
*
|
| 832 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 833 |
+
*/
|
| 834 |
+
protected function _prepareGuestQuote()
|
| 835 |
+
{
|
| 836 |
+
$quote = $this->_quote;
|
| 837 |
+
$quote->setCustomerId(null)
|
| 838 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
|
| 839 |
+
->setCustomerIsGuest(true)
|
| 840 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
| 841 |
+
return $this;
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
/**
|
| 845 |
+
* Prepare quote for customer registration and customer order submit
|
| 846 |
+
* and restore magento customer data from quote
|
| 847 |
+
*
|
| 848 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 849 |
+
*/
|
| 850 |
+
protected function _prepareNewCustomerQuote()
|
| 851 |
+
{
|
| 852 |
+
$quote = $this->_quote;
|
| 853 |
+
$billing = $quote->getBillingAddress();
|
| 854 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 855 |
+
|
| 856 |
+
$customer = $quote->getCustomer();
|
| 857 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 858 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 859 |
+
$customer->addAddress($customerBilling);
|
| 860 |
+
$billing->setCustomerAddress($customerBilling);
|
| 861 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 862 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
| 863 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 864 |
+
$customer->addAddress($customerShipping);
|
| 865 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 866 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 867 |
+
} elseif ($shipping) {
|
| 868 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 869 |
+
}
|
| 870 |
+
/**
|
| 871 |
+
* @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
|
| 872 |
+
*/
|
| 873 |
+
if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
|
| 874 |
+
$billing->setCustomerDob($quote->getCustomerDob());
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
|
| 878 |
+
$billing->setCustomerTaxvat($quote->getCustomerTaxvat());
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
|
| 882 |
+
$billing->setCustomerGender($quote->getCustomerGender());
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
| 886 |
+
$customer->setEmail($quote->getCustomerEmail());
|
| 887 |
+
$customer->setPrefix($quote->getCustomerPrefix());
|
| 888 |
+
$customer->setFirstname($quote->getCustomerFirstname());
|
| 889 |
+
$customer->setMiddlename($quote->getCustomerMiddlename());
|
| 890 |
+
$customer->setLastname($quote->getCustomerLastname());
|
| 891 |
+
$customer->setSuffix($quote->getCustomerSuffix());
|
| 892 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
| 893 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
| 894 |
+
$customer->save();
|
| 895 |
+
$quote->setCustomer($customer);
|
| 896 |
+
|
| 897 |
+
return $this;
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
/**
|
| 901 |
+
* Prepare quote for customer order submit
|
| 902 |
+
*
|
| 903 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 904 |
+
*/
|
| 905 |
+
protected function _prepareCustomerQuote()
|
| 906 |
+
{
|
| 907 |
+
$quote = $this->_quote;
|
| 908 |
+
$billing = $quote->getBillingAddress();
|
| 909 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 910 |
+
|
| 911 |
+
$customer = $this->getCustomerSession()->getCustomer();
|
| 912 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
| 913 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 914 |
+
$customer->addAddress($customerBilling);
|
| 915 |
+
$billing->setCustomerAddress($customerBilling);
|
| 916 |
+
}
|
| 917 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
| 918 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
| 919 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 920 |
+
$customer->addAddress($customerShipping);
|
| 921 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
| 925 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 926 |
+
}
|
| 927 |
+
if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
|
| 928 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 929 |
+
} elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
| 930 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 931 |
+
}
|
| 932 |
+
$quote->setCustomer($customer);
|
| 933 |
+
|
| 934 |
+
return $this;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
/**
|
| 938 |
+
* Involve new customer to system
|
| 939 |
+
*
|
| 940 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 941 |
+
*/
|
| 942 |
+
protected function _involveNewCustomer()
|
| 943 |
+
{
|
| 944 |
+
$customer = $this->_quote->getCustomer();
|
| 945 |
+
if ($customer->isConfirmationRequired()) {
|
| 946 |
+
$customer->sendNewAccountEmail('confirmation');
|
| 947 |
+
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
| 948 |
+
$this->getCustomerSession()->addSuccess(
|
| 949 |
+
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
|
| 950 |
+
);
|
| 951 |
+
} else {
|
| 952 |
+
$customer->sendNewAccountEmail();
|
| 953 |
+
$this->getCustomerSession()->loginById($customer->getId());
|
| 954 |
+
}
|
| 955 |
+
return $this;
|
| 956 |
+
}
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Get customer session object
|
| 960 |
+
*
|
| 961 |
+
* @return Mage_Customer_Model_Session
|
| 962 |
+
*/
|
| 963 |
+
public function getCustomerSession()
|
| 964 |
+
{
|
| 965 |
+
return $this->_customerSession;
|
| 966 |
+
}
|
| 967 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Info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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Info
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cross-models public exchange keys
|
| 6 |
+
*
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
const PAYER_ID = 'payer_id';
|
| 10 |
+
const PAYER_EMAIL = 'email';
|
| 11 |
+
const PAYER_STATUS = 'payer_status';
|
| 12 |
+
const ADDRESS_ID = 'address_id';
|
| 13 |
+
const ADDRESS_STATUS = 'address_status';
|
| 14 |
+
const PROTECTION_EL = 'protection_eligibility';
|
| 15 |
+
const FRAUD_FILTERS = 'collected_fraud_filters';
|
| 16 |
+
const CORRELATION_ID = 'correlation_id';
|
| 17 |
+
const AVS_CODE = 'avs_result';
|
| 18 |
+
const CVV2_MATCH = 'cvv2_check_result';
|
| 19 |
+
const CENTINEL_VPAS = 'centinel_vpas_result';
|
| 20 |
+
const CENTINEL_ECI = 'centinel_eci_result';
|
| 21 |
+
|
| 22 |
+
// Next two fields are required for Brazil
|
| 23 |
+
const BUYER_TAX_ID = 'buyer_tax_id';
|
| 24 |
+
const BUYER_TAX_ID_TYPE = 'buyer_tax_id_type';
|
| 25 |
+
|
| 26 |
+
const PAYMENT_STATUS = 'payment_status';
|
| 27 |
+
const PENDING_REASON = 'pending_reason';
|
| 28 |
+
const IS_FRAUD = 'is_fraud_detected';
|
| 29 |
+
const PAYMENT_STATUS_GLOBAL = 'paypal_payment_status';
|
| 30 |
+
const PENDING_REASON_GLOBAL = 'paypal_pending_reason';
|
| 31 |
+
const IS_FRAUD_GLOBAL = 'paypal_is_fraud_detected';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Possible buyer's tax id types (Brazil only)
|
| 35 |
+
*/
|
| 36 |
+
const BUYER_TAX_ID_TYPE_CPF = 'BR_CPF';
|
| 37 |
+
const BUYER_TAX_ID_TYPE_CNPJ = 'BR_CNPJ';
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* All payment information map
|
| 41 |
+
*
|
| 42 |
+
* @var array
|
| 43 |
+
*/
|
| 44 |
+
protected $_paymentMap = array(
|
| 45 |
+
self::PAYER_ID => 'paypal_payer_id',
|
| 46 |
+
self::PAYER_EMAIL => 'paypal_payer_email',
|
| 47 |
+
self::PAYER_STATUS => 'paypal_payer_status',
|
| 48 |
+
self::PAYMENT_STATUS_GLOBAL => 'paypal_payment_status',
|
| 49 |
+
self::PENDING_REASON_GLOBAL => 'paypal_pending_reason',
|
| 50 |
+
self::ADDRESS_ID => 'paypal_address_id',
|
| 51 |
+
self::ADDRESS_STATUS => 'paypal_address_status',
|
| 52 |
+
self::PROTECTION_EL => 'paypal_protection_eligibility',
|
| 53 |
+
self::FRAUD_FILTERS => 'paypal_fraud_filters',
|
| 54 |
+
self::CORRELATION_ID => 'paypal_correlation_id',
|
| 55 |
+
self::AVS_CODE => 'paypal_avs_code',
|
| 56 |
+
self::CVV2_MATCH => 'paypal_cvv2_match',
|
| 57 |
+
self::CENTINEL_VPAS => self::CENTINEL_VPAS,
|
| 58 |
+
self::CENTINEL_ECI => self::CENTINEL_ECI,
|
| 59 |
+
self::BUYER_TAX_ID => self::BUYER_TAX_ID,
|
| 60 |
+
self::BUYER_TAX_ID_TYPE => self::BUYER_TAX_ID_TYPE,
|
| 61 |
+
);
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* System information map
|
| 65 |
+
*
|
| 66 |
+
* @var array
|
| 67 |
+
*/
|
| 68 |
+
protected $_systemMap = array(
|
| 69 |
+
self::PAYMENT_STATUS => self::PAYMENT_STATUS_GLOBAL,
|
| 70 |
+
self::PENDING_REASON => self::PENDING_REASON_GLOBAL,
|
| 71 |
+
self::IS_FRAUD => self::IS_FRAUD_GLOBAL,
|
| 72 |
+
);
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* PayPal payment status possible values
|
| 76 |
+
*
|
| 77 |
+
* @var string
|
| 78 |
+
*/
|
| 79 |
+
const PAYMENTSTATUS_NONE = 'none';
|
| 80 |
+
const PAYMENTSTATUS_COMPLETED = 'completed';
|
| 81 |
+
const PAYMENTSTATUS_DENIED = 'denied';
|
| 82 |
+
const PAYMENTSTATUS_EXPIRED = 'expired';
|
| 83 |
+
const PAYMENTSTATUS_FAILED = 'failed';
|
| 84 |
+
const PAYMENTSTATUS_INPROGRESS = 'in_progress';
|
| 85 |
+
const PAYMENTSTATUS_PENDING = 'pending';
|
| 86 |
+
const PAYMENTSTATUS_REFUNDED = 'refunded';
|
| 87 |
+
const PAYMENTSTATUS_REFUNDEDPART = 'partially_refunded';
|
| 88 |
+
const PAYMENTSTATUS_REVERSED = 'reversed';
|
| 89 |
+
const PAYMENTSTATUS_UNREVERSED = 'canceled_reversal';
|
| 90 |
+
const PAYMENTSTATUS_PROCESSED = 'processed';
|
| 91 |
+
const PAYMENTSTATUS_VOIDED = 'voided';
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Map of payment information available to customer
|
| 95 |
+
*
|
| 96 |
+
* @var array
|
| 97 |
+
*/
|
| 98 |
+
protected $_paymentPublicMap = array(
|
| 99 |
+
'paypal_payer_email',
|
| 100 |
+
self::BUYER_TAX_ID,
|
| 101 |
+
self::BUYER_TAX_ID_TYPE
|
| 102 |
+
);
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* Rendered payment map cache
|
| 106 |
+
*
|
| 107 |
+
* @var array
|
| 108 |
+
*/
|
| 109 |
+
protected $_paymentMapFull = array();
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* All available payment info getter
|
| 113 |
+
*
|
| 114 |
+
* @param Mage_Payment_Model_Info $payment
|
| 115 |
+
* @param bool $labelValuesOnly
|
| 116 |
+
* @return array
|
| 117 |
+
*/
|
| 118 |
+
public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 119 |
+
{
|
| 120 |
+
// collect paypal-specific info
|
| 121 |
+
$result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
|
| 122 |
+
|
| 123 |
+
// add last_trans_id
|
| 124 |
+
$label = Mage::helper('paypalmx')->__('Last Transaction ID');
|
| 125 |
+
$value = $payment->getLastTransId();
|
| 126 |
+
if ($labelValuesOnly) {
|
| 127 |
+
$result[$label] = $value;
|
| 128 |
+
} else {
|
| 129 |
+
$result['last_trans_id'] = array('label' => $label, 'value' => $value);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
return $result;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Public payment info getter
|
| 137 |
+
*
|
| 138 |
+
* @param Mage_Payment_Model_Info $payment
|
| 139 |
+
* @param bool $labelValuesOnly
|
| 140 |
+
* @return array
|
| 141 |
+
*/
|
| 142 |
+
public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 143 |
+
{
|
| 144 |
+
return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Grab data from source and map it into payment
|
| 149 |
+
*
|
| 150 |
+
* @param array|Varien_Object|callback $from
|
| 151 |
+
* @param Mage_Payment_Model_Info $payment
|
| 152 |
+
*/
|
| 153 |
+
public function importToPayment($from, Mage_Payment_Model_Info $payment)
|
| 154 |
+
{
|
| 155 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 156 |
+
if (is_object($from)) {
|
| 157 |
+
$from = array($from, 'getDataUsingMethod');
|
| 158 |
+
}
|
| 159 |
+
Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Grab data from payment and map it into target
|
| 164 |
+
*
|
| 165 |
+
* @param Mage_Payment_Model_Info $payment
|
| 166 |
+
* @param array|Varien_Object|callback $to
|
| 167 |
+
* @param array $map
|
| 168 |
+
* @return array|Varien_Object
|
| 169 |
+
*/
|
| 170 |
+
public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, array $map = null)
|
| 171 |
+
{
|
| 172 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 173 |
+
Varien_Object_Mapper::accumulateByMap(array($payment, 'getAdditionalInformation'), $to,
|
| 174 |
+
$map ? $map : array_flip($fullMap)
|
| 175 |
+
);
|
| 176 |
+
return $to;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Check whether the payment is in review state
|
| 181 |
+
*
|
| 182 |
+
* @param Mage_Payment_Model_Info $payment
|
| 183 |
+
* @return bool
|
| 184 |
+
*/
|
| 185 |
+
public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
|
| 186 |
+
{
|
| 187 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 188 |
+
if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
|
| 189 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 190 |
+
return !in_array($pendingReason, array('authorization', 'order'));
|
| 191 |
+
}
|
| 192 |
+
return false;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Check whether fraud order review detected and can be reviewed
|
| 197 |
+
*
|
| 198 |
+
* @param Mage_Payment_Model_Info $payment
|
| 199 |
+
* @return bool
|
| 200 |
+
*/
|
| 201 |
+
public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
|
| 202 |
+
{
|
| 203 |
+
return self::isPaymentReviewRequired($payment)
|
| 204 |
+
&& 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* Check whether the payment is completed
|
| 209 |
+
*
|
| 210 |
+
* @param Mage_Payment_Model_Info $payment
|
| 211 |
+
* @return bool
|
| 212 |
+
*/
|
| 213 |
+
public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
|
| 214 |
+
{
|
| 215 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 216 |
+
return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/**
|
| 220 |
+
* Check whether the payment was processed successfully
|
| 221 |
+
*
|
| 222 |
+
* @param Mage_Payment_Model_Info $payment
|
| 223 |
+
* @return bool
|
| 224 |
+
*/
|
| 225 |
+
public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
|
| 226 |
+
{
|
| 227 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 228 |
+
if (in_array($paymentStatus, array(
|
| 229 |
+
self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
|
| 230 |
+
self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
|
| 231 |
+
))) {
|
| 232 |
+
return true;
|
| 233 |
+
}
|
| 234 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 235 |
+
return self::PAYMENTSTATUS_PENDING === $paymentStatus
|
| 236 |
+
&& in_array($pendingReason, array('authorization', 'order'));
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/**
|
| 240 |
+
* Check whether the payment was processed unsuccessfully or failed
|
| 241 |
+
*
|
| 242 |
+
* @param Mage_Payment_Model_Info $payment
|
| 243 |
+
* @return bool
|
| 244 |
+
*/
|
| 245 |
+
public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
|
| 246 |
+
{
|
| 247 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 248 |
+
return in_array($paymentStatus, array(
|
| 249 |
+
self::PAYMENTSTATUS_DENIED, self::PAYMENTSTATUS_EXPIRED, self::PAYMENTSTATUS_FAILED,
|
| 250 |
+
self::PAYMENTSTATUS_REVERSED, self::PAYMENTSTATUS_VOIDED,
|
| 251 |
+
));
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Explain pending payment reason code
|
| 256 |
+
*
|
| 257 |
+
* @param string $code
|
| 258 |
+
* @return string
|
| 259 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
|
| 260 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails
|
| 261 |
+
*/
|
| 262 |
+
public static function explainPendingReason($code)
|
| 263 |
+
{
|
| 264 |
+
switch ($code) {
|
| 265 |
+
case 'address':
|
| 266 |
+
return Mage::helper('paypalmx')->__('Customer did not include a confirmed address.');
|
| 267 |
+
case 'authorization':
|
| 268 |
+
case 'order':
|
| 269 |
+
return Mage::helper('paypalmx')->__('The payment is authorized but not settled.');
|
| 270 |
+
case 'echeck':
|
| 271 |
+
return Mage::helper('paypalmx')->__('The payment eCheck is not yet cleared.');
|
| 272 |
+
case 'intl':
|
| 273 |
+
return Mage::helper('paypalmx')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.');
|
| 274 |
+
case 'multi-currency': // break is intentionally omitted
|
| 275 |
+
case 'multi_currency': // break is intentionally omitted
|
| 276 |
+
case 'multicurrency':
|
| 277 |
+
return Mage::helper('paypalmx')->__('The payment curency does not match any of the merchant\'s balances currency.');
|
| 278 |
+
case 'paymentreview':
|
| 279 |
+
return Mage::helper('paypalmx')->__('The payment is pending while it is being reviewed by PayPal for risk.');
|
| 280 |
+
case 'unilateral':
|
| 281 |
+
return Mage::helper('paypalmx')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
|
| 282 |
+
case 'verify':
|
| 283 |
+
return Mage::helper('paypalmx')->__('The merchant account is not yet verified.');
|
| 284 |
+
case 'upgrade':
|
| 285 |
+
return Mage::helper('paypalmx')->__('The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.');
|
| 286 |
+
case 'none': // break is intentionally omitted
|
| 287 |
+
case 'other': // break is intentionally omitted
|
| 288 |
+
default:
|
| 289 |
+
return Mage::helper('paypalmx')->__('Unknown reason. Please contact PayPal customer service.');
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
/**
|
| 294 |
+
* Explain the refund or chargeback reason code
|
| 295 |
+
*
|
| 296 |
+
* @param $code
|
| 297 |
+
* @return string
|
| 298 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
|
| 299 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails
|
| 300 |
+
*/
|
| 301 |
+
public static function explainReasonCode($code)
|
| 302 |
+
{
|
| 303 |
+
switch ($code) {
|
| 304 |
+
case 'chargeback':
|
| 305 |
+
return Mage::helper('paypalmx')->__('Chargeback by customer.');
|
| 306 |
+
case 'guarantee':
|
| 307 |
+
return Mage::helper('paypalmx')->__('Customer triggered a money-back guarantee.');
|
| 308 |
+
case 'buyer-complaint':
|
| 309 |
+
return Mage::helper('paypalmx')->__('Customer complaint.');
|
| 310 |
+
case 'refund':
|
| 311 |
+
return Mage::helper('paypalmx')->__('Refund issued by merchant.');
|
| 312 |
+
case 'adjustment_reversal':
|
| 313 |
+
return Mage::helper('paypalmx')->__('Reversal of an adjustment.');
|
| 314 |
+
case 'chargeback_reimbursement':
|
| 315 |
+
return Mage::helper('paypalmx')->__('Reimbursement for a chargeback.');
|
| 316 |
+
case 'chargeback_settlement':
|
| 317 |
+
return Mage::helper('paypalmx')->__('Settlement of a chargeback.');
|
| 318 |
+
case 'none': // break is intentionally omitted
|
| 319 |
+
case 'other':
|
| 320 |
+
default:
|
| 321 |
+
return Mage::helper('paypalmx')->__('Unknown reason. Please contact PayPal customer service.');
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
* Whether a reversal/refund can be disputed with PayPal
|
| 327 |
+
*
|
| 328 |
+
* @param string $code
|
| 329 |
+
* @return bool;
|
| 330 |
+
*/
|
| 331 |
+
public static function isReversalDisputable($code)
|
| 332 |
+
{
|
| 333 |
+
switch ($code) {
|
| 334 |
+
case 'none':
|
| 335 |
+
case 'other':
|
| 336 |
+
case 'chargeback':
|
| 337 |
+
case 'buyer-complaint':
|
| 338 |
+
case 'adjustment_reversal':
|
| 339 |
+
return true;
|
| 340 |
+
case 'guarantee':
|
| 341 |
+
case 'refund':
|
| 342 |
+
case 'chargeback_reimbursement':
|
| 343 |
+
case 'chargeback_settlement':
|
| 344 |
+
default:
|
| 345 |
+
return false;
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* Render info item
|
| 351 |
+
*
|
| 352 |
+
* @param array $keys
|
| 353 |
+
* @param Mage_Payment_Model_Info $payment
|
| 354 |
+
* @param bool $labelValuesOnly
|
| 355 |
+
*/
|
| 356 |
+
protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
|
| 357 |
+
{
|
| 358 |
+
$result = array();
|
| 359 |
+
foreach ($keys as $key) {
|
| 360 |
+
if (!isset($this->_paymentMapFull[$key])) {
|
| 361 |
+
$this->_paymentMapFull[$key] = array();
|
| 362 |
+
}
|
| 363 |
+
if (!isset($this->_paymentMapFull[$key]['label'])) {
|
| 364 |
+
if (!$payment->hasAdditionalInformation($key)) {
|
| 365 |
+
$this->_paymentMapFull[$key]['label'] = false;
|
| 366 |
+
$this->_paymentMapFull[$key]['value'] = false;
|
| 367 |
+
} else {
|
| 368 |
+
$value = $payment->getAdditionalInformation($key);
|
| 369 |
+
$this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
|
| 370 |
+
$this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
if (!empty($this->_paymentMapFull[$key]['value'])) {
|
| 374 |
+
if ($labelValuesOnly) {
|
| 375 |
+
$result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
|
| 376 |
+
} else {
|
| 377 |
+
$result[$key] = $this->_paymentMapFull[$key];
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
return $result;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
/**
|
| 385 |
+
* Render info item labels
|
| 386 |
+
*
|
| 387 |
+
* @param string $key
|
| 388 |
+
*/
|
| 389 |
+
protected function _getLabel($key)
|
| 390 |
+
{
|
| 391 |
+
switch ($key) {
|
| 392 |
+
case 'paypal_payer_id':
|
| 393 |
+
return Mage::helper('paypalmx')->__('Payer ID');
|
| 394 |
+
case 'paypal_payer_email':
|
| 395 |
+
return Mage::helper('paypalmx')->__('Payer Email');
|
| 396 |
+
case 'paypal_payer_status':
|
| 397 |
+
return Mage::helper('paypalmx')->__('Payer Status');
|
| 398 |
+
case 'paypal_address_id':
|
| 399 |
+
return Mage::helper('paypalmx')->__('Payer Address ID');
|
| 400 |
+
case 'paypal_address_status':
|
| 401 |
+
return Mage::helper('paypalmx')->__('Payer Address Status');
|
| 402 |
+
case 'paypal_payment_status':
|
| 403 |
+
return Mage::helper('paypalmx')->__('Payment Status');
|
| 404 |
+
case 'paypal_pending_reason':
|
| 405 |
+
return Mage::helper('paypalmx')->__('Pending Reason');
|
| 406 |
+
case 'paypal_protection_eligibility':
|
| 407 |
+
return Mage::helper('paypalmx')->__('Merchant Protection Eligibility');
|
| 408 |
+
case 'paypal_fraud_filters':
|
| 409 |
+
return Mage::helper('paypalmx')->__('Triggered Fraud Filters');
|
| 410 |
+
case 'paypal_correlation_id':
|
| 411 |
+
return Mage::helper('paypalmx')->__('Last Correlation ID');
|
| 412 |
+
case 'paypal_avs_code':
|
| 413 |
+
return Mage::helper('paypalmx')->__('Address Verification System Response');
|
| 414 |
+
case 'paypal_cvv2_match':
|
| 415 |
+
return Mage::helper('paypalmx')->__('CVV2 Check Result by PayPal');
|
| 416 |
+
case self::BUYER_TAX_ID :
|
| 417 |
+
return Mage::helper('paypalmx')->__('Buyer\'s Tax ID');
|
| 418 |
+
case self::BUYER_TAX_ID_TYPE :
|
| 419 |
+
return Mage::helper('paypalmx')->__('Buyer\'s Tax ID Type');
|
| 420 |
+
case self::CENTINEL_VPAS:
|
| 421 |
+
return Mage::helper('paypalmx')->__('PayPal/Centinel Visa Payer Authentication Service Result');
|
| 422 |
+
case self::CENTINEL_ECI:
|
| 423 |
+
return Mage::helper('paypalmx')->__('PayPal/Centinel Electronic Commerce Indicator');
|
| 424 |
+
}
|
| 425 |
+
return '';
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/**
|
| 429 |
+
* Apply a filter upon value getting
|
| 430 |
+
*
|
| 431 |
+
* @param string $value
|
| 432 |
+
* @param string $key
|
| 433 |
+
* @return string
|
| 434 |
+
*/
|
| 435 |
+
protected function _getValue($value, $key)
|
| 436 |
+
{
|
| 437 |
+
$label = '';
|
| 438 |
+
switch ($key) {
|
| 439 |
+
case 'paypal_avs_code':
|
| 440 |
+
$label = $this->_getAvsLabel($value);
|
| 441 |
+
break;
|
| 442 |
+
case 'paypal_cvv2_match':
|
| 443 |
+
$label = $this->_getCvv2Label($value);
|
| 444 |
+
break;
|
| 445 |
+
case self::CENTINEL_VPAS:
|
| 446 |
+
$label = $this->_getCentinelVpasLabel($value);
|
| 447 |
+
break;
|
| 448 |
+
case self::CENTINEL_ECI:
|
| 449 |
+
$label = $this->_getCentinelEciLabel($value);
|
| 450 |
+
break;
|
| 451 |
+
case self::BUYER_TAX_ID_TYPE :
|
| 452 |
+
$value = $this->_getBuyerIdTypeValue($value);
|
| 453 |
+
default:
|
| 454 |
+
return $value;
|
| 455 |
+
}
|
| 456 |
+
return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label);
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
/**
|
| 460 |
+
* Attempt to convert AVS check result code into label
|
| 461 |
+
*
|
| 462 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes
|
| 463 |
+
* @param string $value
|
| 464 |
+
* @return string
|
| 465 |
+
*/
|
| 466 |
+
protected function _getAvsLabel($value)
|
| 467 |
+
{
|
| 468 |
+
switch ($value) {
|
| 469 |
+
// Visa, MasterCard, Discover and American Express
|
| 470 |
+
case 'A':
|
| 471 |
+
case 'YN':
|
| 472 |
+
return Mage::helper('paypalmx')->__('Matched Address only (no ZIP)');
|
| 473 |
+
case 'B': // international "A"
|
| 474 |
+
return Mage::helper('paypalmx')->__('Matched Address only (no ZIP). International');
|
| 475 |
+
case 'N':
|
| 476 |
+
return Mage::helper('paypalmx')->__('No Details matched');
|
| 477 |
+
case 'C': // international "N"
|
| 478 |
+
return Mage::helper('paypalmx')->__('No Details matched. International');
|
| 479 |
+
case 'X':
|
| 480 |
+
return Mage::helper('paypalmx')->__('Exact Match. Address and nine-digit ZIP code');
|
| 481 |
+
case 'D': // international "X"
|
| 482 |
+
return Mage::helper('paypalmx')->__('Exact Match. Address and Postal Code. International');
|
| 483 |
+
case 'F': // UK-specific "X"
|
| 484 |
+
return Mage::helper('paypalmx')->__('Exact Match. Address and Postal Code. UK-specific');
|
| 485 |
+
case 'E':
|
| 486 |
+
return Mage::helper('paypalmx')->__('N/A. Not allowed for MOTO (Internet/Phone) transactions');
|
| 487 |
+
case 'G':
|
| 488 |
+
return Mage::helper('paypalmx')->__('N/A. Global Unavailable');
|
| 489 |
+
case 'I':
|
| 490 |
+
return Mage::helper('paypalmx')->__('N/A. International Unavailable');
|
| 491 |
+
case 'Z':
|
| 492 |
+
case 'NY':
|
| 493 |
+
return Mage::helper('paypalmx')->__('Matched five-digit ZIP only (no Address)');
|
| 494 |
+
case 'P': // international "Z"
|
| 495 |
+
case 'NY':
|
| 496 |
+
return Mage::helper('paypalmx')->__('Matched Postal Code only (no Address)');
|
| 497 |
+
case 'R':
|
| 498 |
+
return Mage::helper('paypalmx')->__('N/A. Retry');
|
| 499 |
+
case 'S':
|
| 500 |
+
return Mage::helper('paypalmx')->__('N/A. Service not Supported');
|
| 501 |
+
case 'U':
|
| 502 |
+
return Mage::helper('paypalmx')->__('N/A. Unavailable');
|
| 503 |
+
case 'W':
|
| 504 |
+
return Mage::helper('paypalmx')->__('Matched whole nine-didgit ZIP (no Address)');
|
| 505 |
+
case 'Y':
|
| 506 |
+
return Mage::helper('paypalmx')->__('Yes. Matched Address and five-didgit ZIP');
|
| 507 |
+
// Maestro and Solo
|
| 508 |
+
case '0':
|
| 509 |
+
return Mage::helper('paypalmx')->__('All the address information matched');
|
| 510 |
+
case '1':
|
| 511 |
+
return Mage::helper('paypalmx')->__('None of the address information matched');
|
| 512 |
+
case '2':
|
| 513 |
+
return Mage::helper('paypalmx')->__('Part of the address information matched');
|
| 514 |
+
case '3':
|
| 515 |
+
return Mage::helper('paypalmx')->__('N/A. The merchant did not provide AVS information');
|
| 516 |
+
case '4':
|
| 517 |
+
return Mage::helper('paypalmx')->__('N/A. Address not checked, or acquirer had no response. Service not available');
|
| 518 |
+
default:
|
| 519 |
+
return $value;
|
| 520 |
+
}
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
/**
|
| 524 |
+
* Attempt to convert CVV2 check result code into label
|
| 525 |
+
*
|
| 526 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes
|
| 527 |
+
* @param string $value
|
| 528 |
+
* @return string
|
| 529 |
+
*/
|
| 530 |
+
protected function _getCvv2Label($value)
|
| 531 |
+
{
|
| 532 |
+
switch ($value) {
|
| 533 |
+
// Visa, MasterCard, Discover and American Express
|
| 534 |
+
case 'M':
|
| 535 |
+
return Mage::helper('paypalmx')->__('Matched (CVV2CSC)');
|
| 536 |
+
case 'N':
|
| 537 |
+
return Mage::helper('paypalmx')->__('No match');
|
| 538 |
+
case 'P':
|
| 539 |
+
return Mage::helper('paypalmx')->__('N/A. Not processed');
|
| 540 |
+
case 'S':
|
| 541 |
+
return Mage::helper('paypalmx')->__('N/A. Service not supported');
|
| 542 |
+
case 'U':
|
| 543 |
+
return Mage::helper('paypalmx')->__('N/A. Service not available');
|
| 544 |
+
case 'X':
|
| 545 |
+
return Mage::helper('paypalmx')->__('N/A. No response');
|
| 546 |
+
// Maestro and Solo
|
| 547 |
+
case '0':
|
| 548 |
+
return Mage::helper('paypalmx')->__('Matched (CVV2)');
|
| 549 |
+
case '1':
|
| 550 |
+
return Mage::helper('paypalmx')->__('No match');
|
| 551 |
+
case '2':
|
| 552 |
+
return Mage::helper('paypalmx')->__('N/A. The merchant has not implemented CVV2 code handling');
|
| 553 |
+
case '3':
|
| 554 |
+
return Mage::helper('paypalmx')->__('N/A. Merchant has indicated that CVV2 is not present on card');
|
| 555 |
+
case '4':
|
| 556 |
+
return Mage::helper('paypalmx')->__('N/A. Service not available');
|
| 557 |
+
default:
|
| 558 |
+
return $value;
|
| 559 |
+
}
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
/**
|
| 563 |
+
* Attempt to convert centinel VPAS result into label
|
| 564 |
+
*
|
| 565 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment
|
| 566 |
+
* @param string $value
|
| 567 |
+
* @return string
|
| 568 |
+
*/
|
| 569 |
+
private function _getCentinelVpasLabel($value)
|
| 570 |
+
{
|
| 571 |
+
switch ($value) {
|
| 572 |
+
case '2':
|
| 573 |
+
case 'D':
|
| 574 |
+
return Mage::helper('paypalmx')->__('Authenticated, Good Result');
|
| 575 |
+
case '1':
|
| 576 |
+
return Mage::helper('paypalmx')->__('Authenticated, Bad Result');
|
| 577 |
+
case '3':
|
| 578 |
+
case '6':
|
| 579 |
+
case '8':
|
| 580 |
+
case 'A':
|
| 581 |
+
case 'C':
|
| 582 |
+
return Mage::helper('paypalmx')->__('Attempted Authentication, Good Result');
|
| 583 |
+
case '4':
|
| 584 |
+
case '7':
|
| 585 |
+
case '9':
|
| 586 |
+
return Mage::helper('paypalmx')->__('Attempted Authentication, Bad Result');
|
| 587 |
+
case '':
|
| 588 |
+
case '0':
|
| 589 |
+
case 'B':
|
| 590 |
+
return Mage::helper('paypalmx')->__('No Liability Shift');
|
| 591 |
+
default:
|
| 592 |
+
return $value;
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
/**
|
| 597 |
+
* Attempt to convert centinel ECI result into label
|
| 598 |
+
*
|
| 599 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment
|
| 600 |
+
* @param string $value
|
| 601 |
+
* @return string
|
| 602 |
+
*/
|
| 603 |
+
private function _getCentinelEciLabel($value)
|
| 604 |
+
{
|
| 605 |
+
switch ($value) {
|
| 606 |
+
case '01':
|
| 607 |
+
case '07':
|
| 608 |
+
return Mage::helper('paypalmx')->__('Merchant Liability');
|
| 609 |
+
case '02':
|
| 610 |
+
case '05':
|
| 611 |
+
case '06':
|
| 612 |
+
return Mage::helper('paypalmx')->__('Issuer Liability');
|
| 613 |
+
default:
|
| 614 |
+
return $value;
|
| 615 |
+
}
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
/**
|
| 619 |
+
* Retrieve buyer id type value based on code received from PayPal (Brazil only)
|
| 620 |
+
*
|
| 621 |
+
* @param string $code
|
| 622 |
+
* @return string
|
| 623 |
+
*/
|
| 624 |
+
protected function _getBuyerIdTypeValue($code)
|
| 625 |
+
{
|
| 626 |
+
$value = '';
|
| 627 |
+
switch ($code) {
|
| 628 |
+
case self::BUYER_TAX_ID_TYPE_CNPJ :
|
| 629 |
+
$value = Mage::helper('paypalmx')->__('CNPJ');
|
| 630 |
+
break;
|
| 631 |
+
case self::BUYER_TAX_ID_TYPE_CPF :
|
| 632 |
+
$value = Mage::helper('paypalmx')->__('CPF');
|
| 633 |
+
break;
|
| 634 |
+
}
|
| 635 |
+
return $value;
|
| 636 |
+
}
|
| 637 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Mensualidades2.php
ADDED
|
@@ -0,0 +1,685 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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Pal Express Module
|
| 6 |
+
*/
|
| 7 |
+
class Ebcomm_PaypalMx_Model_Mensualidades2 extends Mage_Payment_Model_Method_Abstract
|
| 8 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
| 9 |
+
{
|
| 10 |
+
protected $_code = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_MENSUALIDADES;
|
| 11 |
+
protected $_formBlockType = 'paypalmx/mensualidades2_form';
|
| 12 |
+
protected $_infoBlockType = 'paypalmx/payment_info';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Website Payments Pro instance type
|
| 16 |
+
*
|
| 17 |
+
* @var $_proType string
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Availability options
|
| 22 |
+
*/
|
| 23 |
+
protected $_isGateway = false;
|
| 24 |
+
protected $_canOrder = true;
|
| 25 |
+
protected $_canAuthorize = true;
|
| 26 |
+
protected $_canCapture = true;
|
| 27 |
+
protected $_canCapturePartial = true;
|
| 28 |
+
protected $_canRefund = true;
|
| 29 |
+
protected $_canRefundInvoicePartial = true;
|
| 30 |
+
protected $_canVoid = true;
|
| 31 |
+
protected $_canUseInternal = false;
|
| 32 |
+
protected $_canUseCheckout = true;
|
| 33 |
+
protected $_canUseForMultishipping = false;
|
| 34 |
+
protected $_canFetchTransactionInfo = true;
|
| 35 |
+
protected $_canCreateBillingAgreement = true;
|
| 36 |
+
protected $_canReviewPayment = false;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Website Payments Pro instance
|
| 40 |
+
*
|
| 41 |
+
* @var Mage_Paypal_Model_Pro
|
| 42 |
+
*/
|
| 43 |
+
protected $_pro = null;
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Payment additional information key for payment action
|
| 47 |
+
* @var string
|
| 48 |
+
*/
|
| 49 |
+
protected $_isOrderPaymentActionKey = 'is_order_action';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Payment additional information key for number of used authorizations
|
| 53 |
+
* @var string
|
| 54 |
+
*/
|
| 55 |
+
protected $_authorizationCountKey = 'authorization_count';
|
| 56 |
+
|
| 57 |
+
public function __construct($params = array())
|
| 58 |
+
{
|
| 59 |
+
|
| 60 |
+
$proInstance = array_shift($params);
|
| 61 |
+
if ($proInstance && ($proInstance instanceof Ebcomm_PaypalMx_Model_Pro)) {
|
| 62 |
+
|
| 63 |
+
$this->_pro = $proInstance;
|
| 64 |
+
} else {
|
| 65 |
+
$this->_pro = Mage::getModel('paypalmx/pro');
|
| 66 |
+
}
|
| 67 |
+
$this->_pro->setMethod($this->_code);
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Store setter
|
| 73 |
+
* Also updates store ID in config object
|
| 74 |
+
*
|
| 75 |
+
* @param Mage_Core_Model_Store|int $store
|
| 76 |
+
*/
|
| 77 |
+
public function setStore($store)
|
| 78 |
+
{
|
| 79 |
+
$this->setData('store', $store);
|
| 80 |
+
if (null === $store) {
|
| 81 |
+
$store = Mage::app()->getStore()->getId();
|
| 82 |
+
}
|
| 83 |
+
$this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store);
|
| 84 |
+
return $this;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Can be used in regular checkout
|
| 89 |
+
*
|
| 90 |
+
* @return bool
|
| 91 |
+
*/
|
| 92 |
+
public function canUseCheckout()
|
| 93 |
+
{
|
| 94 |
+
if (Mage::getStoreConfigFlag('payment/hosted_pro/active')
|
| 95 |
+
&& !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec')
|
| 96 |
+
) {
|
| 97 |
+
return false;
|
| 98 |
+
}
|
| 99 |
+
return parent::canUseCheckout();
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Whether method is available for specified currency
|
| 104 |
+
*
|
| 105 |
+
* @param string $currencyCode
|
| 106 |
+
* @return bool
|
| 107 |
+
*/
|
| 108 |
+
public function canUseForCurrency($currencyCode)
|
| 109 |
+
{
|
| 110 |
+
return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Payment action getter compatible with payment model
|
| 115 |
+
*
|
| 116 |
+
* @see Mage_Sales_Model_Payment::place()
|
| 117 |
+
* @return string
|
| 118 |
+
*/
|
| 119 |
+
public function getConfigPaymentAction()
|
| 120 |
+
{
|
| 121 |
+
return $this->_pro->getConfig()->getPaymentAction();
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Check whether payment method can be used
|
| 126 |
+
* @param Mage_Sales_Model_Quote
|
| 127 |
+
* @return bool
|
| 128 |
+
*/
|
| 129 |
+
public function isAvailable($quote = null)
|
| 130 |
+
{
|
| 131 |
+
if ($this->_pro->getConfig()->isMethodAvailable(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX) && $this->_pro->getConfig()->getIsMensualidadesActive()) {
|
| 132 |
+
return true;
|
| 133 |
+
}
|
| 134 |
+
return false;
|
| 135 |
+
}
|
| 136 |
+
public function isContextAvailable($contextpos = null,$method = null)
|
| 137 |
+
{
|
| 138 |
+
if ($this->_pro->getConfig()->isContextAvailable($contextpos,$method)) {
|
| 139 |
+
return true;
|
| 140 |
+
}
|
| 141 |
+
return false;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Custom getter for payment configuration
|
| 146 |
+
*
|
| 147 |
+
* @param string $field
|
| 148 |
+
* @param int $storeId
|
| 149 |
+
* @return mixed
|
| 150 |
+
*/
|
| 151 |
+
public function getConfigData($field, $storeId = null)
|
| 152 |
+
{
|
| 153 |
+
return $this->_pro->getConfig()->$field;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Order payment
|
| 158 |
+
*
|
| 159 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 160 |
+
* @param float $amount
|
| 161 |
+
* @return Mage_Paypal_Model_Express
|
| 162 |
+
*/
|
| 163 |
+
public function order(Varien_Object $payment, $amount)
|
| 164 |
+
{
|
| 165 |
+
$this->_placeOrder($payment, $amount);
|
| 166 |
+
|
| 167 |
+
$payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
|
| 168 |
+
|
| 169 |
+
if ($payment->getIsFraudDetected()) {
|
| 170 |
+
return $this;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
$order = $payment->getOrder();
|
| 174 |
+
$orderTransactionId = $payment->getTransactionId();
|
| 175 |
+
|
| 176 |
+
$api = $this->_callDoAuthorize($amount, $payment, $payment->getTransactionId());
|
| 177 |
+
|
| 178 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
| 179 |
+
$status = true;
|
| 180 |
+
|
| 181 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 182 |
+
if ($payment->getIsTransactionPending()) {
|
| 183 |
+
$message = Mage::helper('paypalmx')->__('Ordering amount of %s is pending approval on gateway.', $formatedPrice);
|
| 184 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 185 |
+
} else {
|
| 186 |
+
$message = Mage::helper('paypalmx')->__('Ordered amount of %s.', $formatedPrice);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
|
| 190 |
+
|
| 191 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 192 |
+
|
| 193 |
+
if ($payment->getIsTransactionPending()) {
|
| 194 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 195 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 196 |
+
if ($payment->getIsFraudDetected()) {
|
| 197 |
+
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
|
| 198 |
+
}
|
| 199 |
+
} else {
|
| 200 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
$payment->resetTransactionAdditionalInfo();
|
| 204 |
+
|
| 205 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 206 |
+
$payment->setParentTransactionId($orderTransactionId);
|
| 207 |
+
|
| 208 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false,
|
| 209 |
+
$message
|
| 210 |
+
);
|
| 211 |
+
|
| 212 |
+
$order->setState($state, $status);
|
| 213 |
+
|
| 214 |
+
$payment->setSkipOrderProcessing(true);
|
| 215 |
+
return $this;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Authorize payment
|
| 220 |
+
*
|
| 221 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 222 |
+
* @param float $amount
|
| 223 |
+
* @return Mage_Paypal_Model_Express
|
| 224 |
+
*/
|
| 225 |
+
public function authorize(Varien_Object $payment, $amount)
|
| 226 |
+
{
|
| 227 |
+
return $this->_placeOrder($payment, $amount);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Void payment
|
| 232 |
+
*
|
| 233 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 234 |
+
* @return Mage_Paypal_Model_Express
|
| 235 |
+
*/
|
| 236 |
+
public function void(Varien_Object $payment)
|
| 237 |
+
{
|
| 238 |
+
//Switching to order transaction if needed
|
| 239 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)
|
| 240 |
+
&& !$payment->getVoidOnlyAuthorization()
|
| 241 |
+
) {
|
| 242 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 243 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 244 |
+
);
|
| 245 |
+
if ($orderTransaction) {
|
| 246 |
+
$payment->setParentTransactionId($orderTransaction->getTxnId());
|
| 247 |
+
$payment->setTransactionId($orderTransaction->getTxnId() . '-void');
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
$this->_pro->void($payment);
|
| 251 |
+
return $this;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Capture payment
|
| 256 |
+
*
|
| 257 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 258 |
+
* @param float $amount
|
| 259 |
+
* @return Mage_Paypal_Model_Express
|
| 260 |
+
*/
|
| 261 |
+
public function capture(Varien_Object $payment, $amount)
|
| 262 |
+
{
|
| 263 |
+
$authorizationTransaction = $payment->getAuthorizationTransaction();
|
| 264 |
+
$authorizationPeriod = abs(intval($this->getConfigData('authorization_honor_period')));
|
| 265 |
+
$maxAuthorizationNumber = abs(intval($this->getConfigData('child_authorization_number')));
|
| 266 |
+
$order = $payment->getOrder();
|
| 267 |
+
$isAuthorizationCreated = false;
|
| 268 |
+
|
| 269 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 270 |
+
$voided = false;
|
| 271 |
+
if (!$authorizationTransaction->getIsClosed()
|
| 272 |
+
&& $this->_isTransactionExpired($authorizationTransaction, $authorizationPeriod)
|
| 273 |
+
) {
|
| 274 |
+
//Save payment state and configure payment object for voiding
|
| 275 |
+
$isCaptureFinal = $payment->getShouldCloseParentTransaction();
|
| 276 |
+
$captureTrxId = $payment->getTransactionId();
|
| 277 |
+
$payment->setShouldCloseParentTransaction(false);
|
| 278 |
+
$payment->setParentTransactionId($authorizationTransaction->getTxnId());
|
| 279 |
+
$payment->unsTransactionId();
|
| 280 |
+
$payment->setVoidOnlyAuthorization(true);
|
| 281 |
+
$payment->void(new Varien_Object());
|
| 282 |
+
|
| 283 |
+
//Revert payment state after voiding
|
| 284 |
+
$payment->unsAuthorizationTransaction();
|
| 285 |
+
$payment->unsTransactionId();
|
| 286 |
+
$payment->setShouldCloseParentTransaction($isCaptureFinal);
|
| 287 |
+
$voided = true;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if ($authorizationTransaction->getIsClosed() || $voided) {
|
| 291 |
+
if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) {
|
| 292 |
+
Mage::throwException(Mage::helper('paypalmx')->__('The maximum number of child authorizations is reached.'));
|
| 293 |
+
}
|
| 294 |
+
$api = $this->_callDoAuthorize(
|
| 295 |
+
$amount,
|
| 296 |
+
$payment,
|
| 297 |
+
$authorizationTransaction->getParentTxnId()
|
| 298 |
+
);
|
| 299 |
+
|
| 300 |
+
//Adding authorization transaction
|
| 301 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 302 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 303 |
+
$payment->setParentTransactionId($authorizationTransaction->getParentTxnId());
|
| 304 |
+
$payment->setIsTransactionClosed(false);
|
| 305 |
+
|
| 306 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 307 |
+
|
| 308 |
+
if ($payment->getIsTransactionPending()) {
|
| 309 |
+
$message = Mage::helper('paypalmx')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 310 |
+
} else {
|
| 311 |
+
$message = Mage::helper('paypalmx')->__('Authorized amount of %s.', $formatedPrice);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null,
|
| 315 |
+
true, $message
|
| 316 |
+
);
|
| 317 |
+
|
| 318 |
+
$payment->setParentTransactionId($api->getTransactionId());
|
| 319 |
+
$isAuthorizationCreated = true;
|
| 320 |
+
}
|
| 321 |
+
//close order transaction if needed
|
| 322 |
+
if ($payment->getShouldCloseParentTransaction()) {
|
| 323 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 324 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 325 |
+
);
|
| 326 |
+
|
| 327 |
+
if ($orderTransaction) {
|
| 328 |
+
$orderTransaction->setIsClosed(true);
|
| 329 |
+
$order->addRelatedObject($orderTransaction);
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
if (false === $this->_pro->capture($payment, $amount)) {
|
| 335 |
+
$this->_placeOrder($payment, $amount);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
if ($isAuthorizationCreated && isset($transaction)) {
|
| 339 |
+
$transaction->setIsClosed(true);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
return $this;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
* Refund capture
|
| 347 |
+
*
|
| 348 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 349 |
+
* @param float $amount
|
| 350 |
+
* @return Mage_Paypal_Model_Express
|
| 351 |
+
*/
|
| 352 |
+
public function refund(Varien_Object $payment, $amount)
|
| 353 |
+
{
|
| 354 |
+
$this->_pro->refund($payment, $amount);
|
| 355 |
+
return $this;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Cancel payment
|
| 360 |
+
*
|
| 361 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 362 |
+
* @return Mage_Paypal_Model_Express
|
| 363 |
+
*/
|
| 364 |
+
public function cancel(Varien_Object $payment)
|
| 365 |
+
{
|
| 366 |
+
$this->void($payment);
|
| 367 |
+
|
| 368 |
+
return $this;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* Whether payment can be reviewed
|
| 373 |
+
*
|
| 374 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 375 |
+
* @return bool
|
| 376 |
+
*/
|
| 377 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 378 |
+
{
|
| 379 |
+
return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Attempt to accept a pending payment
|
| 384 |
+
*
|
| 385 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 386 |
+
* @return bool
|
| 387 |
+
*/
|
| 388 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
| 389 |
+
{
|
| 390 |
+
parent::acceptPayment($payment);
|
| 391 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_ACCEPT);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Attempt to deny a pending payment
|
| 396 |
+
*
|
| 397 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 398 |
+
* @return bool
|
| 399 |
+
*/
|
| 400 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
| 401 |
+
{
|
| 402 |
+
parent::denyPayment($payment);
|
| 403 |
+
return $this->_pro->reviewPayment($payment, Ebcomm_PaypalMx_Model_Pro::PAYMENT_REVIEW_DENY);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* Checkout redirect URL getter for onepage checkout (hardcode)
|
| 408 |
+
*
|
| 409 |
+
* @see Mage_Checkout_OnepageController::savePaymentAction()
|
| 410 |
+
* @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
|
| 411 |
+
* @return string
|
| 412 |
+
*/
|
| 413 |
+
public function getCheckoutRedirectUrl()
|
| 414 |
+
{
|
| 415 |
+
return Mage::getUrl('paypalmx/express/start');
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
/**
|
| 419 |
+
* Fetch transaction details info
|
| 420 |
+
*
|
| 421 |
+
* @param Mage_Payment_Model_Info $payment
|
| 422 |
+
* @param string $transactionId
|
| 423 |
+
* @return array
|
| 424 |
+
*/
|
| 425 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 426 |
+
{
|
| 427 |
+
return $this->_pro->fetchTransactionInfo($payment, $transactionId);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* Validate RP data
|
| 432 |
+
*
|
| 433 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 434 |
+
*/
|
| 435 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 436 |
+
{
|
| 437 |
+
return $this->_pro->validateRecurringProfile($profile);
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* Submit RP to the gateway
|
| 442 |
+
*
|
| 443 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 444 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 445 |
+
*/
|
| 446 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 447 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 448 |
+
) {
|
| 449 |
+
$token = $paymentInfo->
|
| 450 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 451 |
+
$profile->setToken($token);
|
| 452 |
+
$this->_pro->submitRecurringProfile($profile, $paymentInfo);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Fetch RP details
|
| 457 |
+
*
|
| 458 |
+
* @param string $referenceId
|
| 459 |
+
* @param Varien_Object $result
|
| 460 |
+
*/
|
| 461 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 462 |
+
{
|
| 463 |
+
return $this->_pro->getRecurringProfileDetails($referenceId, $result);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
/**
|
| 467 |
+
* Whether can get recurring profile details
|
| 468 |
+
*/
|
| 469 |
+
public function canGetRecurringProfileDetails()
|
| 470 |
+
{
|
| 471 |
+
return true;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* Update RP data
|
| 476 |
+
*
|
| 477 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 478 |
+
*/
|
| 479 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 480 |
+
{
|
| 481 |
+
return $this->_pro->updateRecurringProfile($profile);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* Manage status
|
| 486 |
+
*
|
| 487 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 488 |
+
*/
|
| 489 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 490 |
+
{
|
| 491 |
+
return $this->_pro->updateRecurringProfileStatus($profile);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/**
|
| 495 |
+
* Assign data to info model instance
|
| 496 |
+
*
|
| 497 |
+
* @param mixed $data
|
| 498 |
+
* @return Mage_Payment_Model_Info
|
| 499 |
+
*/
|
| 500 |
+
public function assignData($data)
|
| 501 |
+
{
|
| 502 |
+
$result = parent::assignData($data);
|
| 503 |
+
$key = Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
|
| 504 |
+
if (is_array($data)) {
|
| 505 |
+
$this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
|
| 506 |
+
}
|
| 507 |
+
elseif ($data instanceof Varien_Object) {
|
| 508 |
+
$this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
|
| 509 |
+
}
|
| 510 |
+
return $result;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
/**
|
| 514 |
+
* Place an order with authorization or capture action
|
| 515 |
+
*
|
| 516 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 517 |
+
* @param float $amount
|
| 518 |
+
* @return Mage_Paypal_Model_Express
|
| 519 |
+
*/
|
| 520 |
+
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
|
| 521 |
+
{
|
| 522 |
+
$order = $payment->getOrder();
|
| 523 |
+
|
| 524 |
+
// prepare api call
|
| 525 |
+
$token = $payment->getAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 526 |
+
$api = $this->_pro->getApi()
|
| 527 |
+
->setToken($token)
|
| 528 |
+
->setPayerId($payment->
|
| 529 |
+
getAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))
|
| 530 |
+
->setAmount($amount)
|
| 531 |
+
->setPaymentAction($this->_pro->getConfig()->paymentAction)
|
| 532 |
+
->setNotifyUrl(Mage::getUrl('paypalmx/ipn/'))
|
| 533 |
+
->setInvNum($order->getIncrementId()."MGT".date("YmdHis"))
|
| 534 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
| 535 |
+
->setPaypalCart(Mage::getModel('paypalmx/cart', array($order)))
|
| 536 |
+
->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)
|
| 537 |
+
;
|
| 538 |
+
if ($order->getIsVirtual()) {
|
| 539 |
+
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
|
| 540 |
+
} else {
|
| 541 |
+
$api->setAddress($order->getShippingAddress());
|
| 542 |
+
$api->setBillingAddress($order->getBillingAddress());
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
// call api and get details from it
|
| 546 |
+
$api->callDoExpressCheckoutPayment();
|
| 547 |
+
|
| 548 |
+
$this->_importToPayment($api, $payment);
|
| 549 |
+
return $this;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
* Import payment info to payment
|
| 554 |
+
*
|
| 555 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 556 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 557 |
+
*/
|
| 558 |
+
protected function _importToPayment($api, $payment)
|
| 559 |
+
{
|
| 560 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)
|
| 561 |
+
->setAdditionalInformation(Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT,
|
| 562 |
+
$api->getRedirectRequired()
|
| 563 |
+
);
|
| 564 |
+
|
| 565 |
+
if ($api->getBillingAgreementId()) {
|
| 566 |
+
$payment->setBillingAgreementData(array(
|
| 567 |
+
'billing_agreement_id' => $api->getBillingAgreementId(),
|
| 568 |
+
'method_code' => Ebcomm_PaypalMx_Model_Config::METHOD_BILLING_AGREEMENT
|
| 569 |
+
));
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 573 |
+
}
|
| 574 |
+
|
| 575 |
+
/**
|
| 576 |
+
* Check void availability
|
| 577 |
+
*
|
| 578 |
+
* @param Varien_Object $payment
|
| 579 |
+
* @return bool
|
| 580 |
+
*/
|
| 581 |
+
public function canVoid(Varien_Object $payment)
|
| 582 |
+
{
|
| 583 |
+
if ($payment instanceof Mage_Sales_Model_Order_Invoice
|
| 584 |
+
|| $payment instanceof Mage_Sales_Model_Order_Creditmemo
|
| 585 |
+
) {
|
| 586 |
+
return false;
|
| 587 |
+
}
|
| 588 |
+
$info = $this->getInfoInstance();
|
| 589 |
+
if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 590 |
+
$orderTransaction = $info->lookupTransaction(
|
| 591 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 592 |
+
);
|
| 593 |
+
if ($orderTransaction) {
|
| 594 |
+
$info->setParentTransactionId($orderTransaction->getTxnId());
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
return $this->_canVoid;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* Check capture availability
|
| 603 |
+
*
|
| 604 |
+
* @return bool
|
| 605 |
+
*/
|
| 606 |
+
public function canCapture()
|
| 607 |
+
{
|
| 608 |
+
$payment = $this->getInfoInstance();
|
| 609 |
+
$this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId());
|
| 610 |
+
|
| 611 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 612 |
+
$orderTransaction = $payment->lookupTransaction(false,
|
| 613 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 614 |
+
);
|
| 615 |
+
if ($orderTransaction->getIsClosed()) {
|
| 616 |
+
return false;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
$orderValidPeriod = abs(intval($this->getConfigData('order_valid_period')));
|
| 620 |
+
|
| 621 |
+
$dateCompass = new DateTime($orderTransaction->getCreatedAt());
|
| 622 |
+
$dateCompass->modify('+' . $orderValidPeriod . ' days');
|
| 623 |
+
$currentDate = new DateTime();
|
| 624 |
+
|
| 625 |
+
if ($currentDate > $dateCompass || $orderValidPeriod == 0) {
|
| 626 |
+
return false;
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
+
return $this->_canCapture;
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
/**
|
| 633 |
+
* Call DoAuthorize
|
| 634 |
+
*
|
| 635 |
+
* @param int $amount
|
| 636 |
+
* @param Varien_Object $payment
|
| 637 |
+
* @param string $parentTransactionId
|
| 638 |
+
* @return Mage_Paypal_Model_Api_Abstract
|
| 639 |
+
*/
|
| 640 |
+
protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
|
| 641 |
+
{
|
| 642 |
+
$api = $this->_pro->resetApi()->getApi()
|
| 643 |
+
->setAmount($amount)
|
| 644 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 645 |
+
->setTransactionId($parentTransactionId)
|
| 646 |
+
->callDoAuthorization();
|
| 647 |
+
|
| 648 |
+
$payment->setAdditionalInformation($this->_authorizationCountKey,
|
| 649 |
+
$payment->getAdditionalInformation($this->_authorizationCountKey) + 1
|
| 650 |
+
);
|
| 651 |
+
|
| 652 |
+
return $api;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* Check transaction for expiration in PST
|
| 657 |
+
*
|
| 658 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
| 659 |
+
* @param int $period
|
| 660 |
+
* @return boolean
|
| 661 |
+
*/
|
| 662 |
+
protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transaction $transaction, $period)
|
| 663 |
+
{
|
| 664 |
+
$period = intval($period);
|
| 665 |
+
if (0 == $period) {
|
| 666 |
+
return true;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
$transactionClosingDate = new DateTime($transaction->getCreatedAt(), new DateTimeZone('GMT'));
|
| 670 |
+
$transactionClosingDate->setTimezone(new DateTimeZone('US/Pacific'));
|
| 671 |
+
/**
|
| 672 |
+
* 11:49:00 PayPal transactions closing time
|
| 673 |
+
*/
|
| 674 |
+
$transactionClosingDate->setTime(11, 49, 00);
|
| 675 |
+
$transactionClosingDate->modify('+' . $period . ' days');
|
| 676 |
+
|
| 677 |
+
$currentTime = new DateTime(null, new DateTimeZone('US/Pacific'));
|
| 678 |
+
|
| 679 |
+
if ($currentTime > $transactionClosingDate) {
|
| 680 |
+
return true;
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
return false;
|
| 684 |
+
}
|
| 685 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Mensualidades2/Checkout.php
ADDED
|
@@ -0,0 +1,967 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Mensualidades2_Checkout
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cache ID prefix for "pal" lookup
|
| 6 |
+
* @var string
|
| 7 |
+
*/
|
| 8 |
+
const PAL_CACHE_ID = 'paypalmx_express_checkout_pal';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Keys for passthrough variables in sales/quote_payment and sales/order_payment
|
| 12 |
+
* Uses additional_information as storage
|
| 13 |
+
* @var string
|
| 14 |
+
*/
|
| 15 |
+
const PAYMENT_INFO_TRANSPORT_TOKEN = 'paypalmx_express_checkout_token';
|
| 16 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN = 'paypalmx_express_checkout_shipping_overriden';
|
| 17 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD = 'paypalmx_express_checkout_shipping_method';
|
| 18 |
+
const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypalmx_express_checkout_payer_id';
|
| 19 |
+
const PAYMENT_INFO_TRANSPORT_REDIRECT = 'paypalmx_express_checkout_redirect_required';
|
| 20 |
+
const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'paypalmx_ec_create_ba';
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @var Mage_Sales_Model_Quote
|
| 24 |
+
*/
|
| 25 |
+
protected $_quote = null;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Config instance
|
| 29 |
+
* @var Mage_Paypal_Model_Config
|
| 30 |
+
*/
|
| 31 |
+
protected $_config = null;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* API instance
|
| 35 |
+
* @var Mage_Paypal_Model_Api_Nvp
|
| 36 |
+
*/
|
| 37 |
+
protected $_api = null;
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Api Model Type
|
| 41 |
+
*
|
| 42 |
+
* @var string
|
| 43 |
+
*/
|
| 44 |
+
protected $_apiType = 'paypalmx/api_nvp';
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Payment method type
|
| 48 |
+
*
|
| 49 |
+
* @var unknown_type
|
| 50 |
+
*/
|
| 51 |
+
protected $_methodType = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX_MENSUALIDADES;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* State helper variables
|
| 55 |
+
* @var string
|
| 56 |
+
*/
|
| 57 |
+
protected $_redirectUrl = '';
|
| 58 |
+
protected $_pendingPaymentMessage = '';
|
| 59 |
+
protected $_checkoutRedirectUrl = '';
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @var Mage_Customer_Model_Session
|
| 63 |
+
*/
|
| 64 |
+
protected $_customerSession;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Redirect urls supposed to be set to support giropay
|
| 68 |
+
*
|
| 69 |
+
* @var array
|
| 70 |
+
*/
|
| 71 |
+
protected $_giropayUrls = array();
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Create Billing Agreement flag
|
| 75 |
+
*
|
| 76 |
+
* @var bool
|
| 77 |
+
*/
|
| 78 |
+
protected $_isBARequested = false;
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Customer ID
|
| 82 |
+
*
|
| 83 |
+
* @var int
|
| 84 |
+
*/
|
| 85 |
+
protected $_customerId = null;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Recurring payment profiles
|
| 89 |
+
*
|
| 90 |
+
* @var array
|
| 91 |
+
*/
|
| 92 |
+
protected $_recurringPaymentProfiles = array();
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Billing agreement that might be created during order placing
|
| 96 |
+
*
|
| 97 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
| 98 |
+
*/
|
| 99 |
+
protected $_billingAgreement = null;
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Order
|
| 103 |
+
*
|
| 104 |
+
* @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
|
| 105 |
+
*/
|
| 106 |
+
protected $_order = null;
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Set quote and config instances
|
| 110 |
+
* @param array $params
|
| 111 |
+
*/
|
| 112 |
+
public function __construct($params = array())
|
| 113 |
+
{
|
| 114 |
+
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
| 115 |
+
$this->_quote = $params['quote'];
|
| 116 |
+
} else {
|
| 117 |
+
throw new Exception('Quote instance is required.');
|
| 118 |
+
}
|
| 119 |
+
if (isset($params['config']) && $params['config'] instanceof Ebcomm_PaypalMx_Model_Config) {
|
| 120 |
+
$this->_config = $params['config'];
|
| 121 |
+
} else {
|
| 122 |
+
throw new Exception('Config instance is required.');
|
| 123 |
+
}
|
| 124 |
+
$this->_customerSession = Mage::getSingleton('customer/session');
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Checkout with PayPal image URL getter
|
| 129 |
+
* Spares API calls of getting "pal" variable, by putting it into cache per store view
|
| 130 |
+
* @return string
|
| 131 |
+
*/
|
| 132 |
+
public function getCheckoutShortcutImageUrl()
|
| 133 |
+
{
|
| 134 |
+
// get "pal" thing from cache or lookup it via API
|
| 135 |
+
$pal = null;
|
| 136 |
+
if ($this->_config->areButtonsDynamic()) {
|
| 137 |
+
$cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId();
|
| 138 |
+
$pal = Mage::app()->loadCache($cacheId);
|
| 139 |
+
if (-1 == $pal) {
|
| 140 |
+
$pal = null;
|
| 141 |
+
} elseif (!$pal) {
|
| 142 |
+
$pal = null;
|
| 143 |
+
$this->_getApi();
|
| 144 |
+
try {
|
| 145 |
+
$this->_api->callGetPalDetails();
|
| 146 |
+
$pal = $this->_api->getPal();
|
| 147 |
+
Mage::app()->saveCache($pal, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 148 |
+
} catch (Exception $e) {
|
| 149 |
+
Mage::app()->saveCache(-1, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
|
| 150 |
+
Mage::logException($e);
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
return $this->_config->getExpressCheckoutShortcutImageUrl(
|
| 156 |
+
Mage::app()->getLocale()->getLocaleCode(),
|
| 157 |
+
$this->_quote->getBaseGrandTotal(),
|
| 158 |
+
$pal
|
| 159 |
+
);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Setter that enables giropay redirects flow
|
| 164 |
+
*
|
| 165 |
+
* @param string $successUrl - payment success result
|
| 166 |
+
* @param string $cancelUrl - payment cancellation result
|
| 167 |
+
* @param string $pendingUrl - pending payment result
|
| 168 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 169 |
+
*/
|
| 170 |
+
public function prepareGiropayUrls($successUrl, $cancelUrl, $pendingUrl)
|
| 171 |
+
{
|
| 172 |
+
$this->_giropayUrls = array($successUrl, $cancelUrl, $pendingUrl);
|
| 173 |
+
return $this;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Set create billing agreement flag
|
| 178 |
+
*
|
| 179 |
+
* @param bool $flag
|
| 180 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 181 |
+
*/
|
| 182 |
+
public function setIsBillingAgreementRequested($flag)
|
| 183 |
+
{
|
| 184 |
+
$this->_isBARequested = $flag;
|
| 185 |
+
return $this;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Setter for customer Id
|
| 190 |
+
*
|
| 191 |
+
* @param int $id
|
| 192 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 193 |
+
* @deprecated please use self::setCustomer
|
| 194 |
+
*/
|
| 195 |
+
public function setCustomerId($id)
|
| 196 |
+
{
|
| 197 |
+
$this->_customerId = $id;
|
| 198 |
+
return $this;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Setter for customer
|
| 203 |
+
*
|
| 204 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 205 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 206 |
+
*/
|
| 207 |
+
public function setCustomer($customer)
|
| 208 |
+
{
|
| 209 |
+
$this->_quote->assignCustomer($customer);
|
| 210 |
+
$this->_customerId = $customer->getId();
|
| 211 |
+
return $this;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* Setter for customer with billing and shipping address changing ability
|
| 216 |
+
*
|
| 217 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 218 |
+
* @param Mage_Sales_Model_Quote_Address $billingAddress
|
| 219 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
| 220 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 221 |
+
*/
|
| 222 |
+
public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null)
|
| 223 |
+
{
|
| 224 |
+
$this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress);
|
| 225 |
+
$this->_customerId = $customer->getId();
|
| 226 |
+
return $this;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Reserve order ID for specified quote and start checkout on PayPal
|
| 231 |
+
*
|
| 232 |
+
* @param string $returnUrl
|
| 233 |
+
* @param string $cancelUrl
|
| 234 |
+
* @return mixed
|
| 235 |
+
*/
|
| 236 |
+
public function start($returnUrl, $cancelUrl)
|
| 237 |
+
{
|
| 238 |
+
$this->_quote->collectTotals();
|
| 239 |
+
|
| 240 |
+
if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
|
| 241 |
+
Mage::throwException(Mage::helper('paypalmx')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$this->_quote->reserveOrderId()->save();
|
| 245 |
+
// prepare API
|
| 246 |
+
$this->_getApi();
|
| 247 |
+
$this->_api->setAmount($this->_quote->getBaseGrandTotal())
|
| 248 |
+
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
|
| 249 |
+
->setInvNum($this->_quote->getReservedOrderId()."MGT".date("YmdHis"))
|
| 250 |
+
->setReturnUrl($returnUrl)
|
| 251 |
+
->setCancelUrl($cancelUrl)
|
| 252 |
+
->setSolutionType($this->_config->solutionType)
|
| 253 |
+
->setPaymentAction($this->_config->paymentAction)
|
| 254 |
+
;
|
| 255 |
+
if ($this->_giropayUrls) {
|
| 256 |
+
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
|
| 257 |
+
$this->_api->addData(array(
|
| 258 |
+
'giropay_cancel_url' => $cancelUrl,
|
| 259 |
+
'giropay_success_url' => $successUrl,
|
| 260 |
+
'giropay_bank_txn_pending_url' => $pendingUrl,
|
| 261 |
+
));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
$this->_setBillingAgreementRequest();
|
| 265 |
+
|
| 266 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) {
|
| 267 |
+
$this->_api->setRequireBillingAddress(1);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// supress or export shipping address
|
| 271 |
+
if ($this->_quote->getIsVirtual()) {
|
| 272 |
+
if ($this->_config->requireBillingAddress == Ebcomm_PaypalMx_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
|
| 273 |
+
$this->_api->setRequireBillingAddress(1);
|
| 274 |
+
}
|
| 275 |
+
$this->_api->setSuppressShipping(true);
|
| 276 |
+
} else {
|
| 277 |
+
$address = $this->_quote->getShippingAddress();
|
| 278 |
+
$isOverriden = 0;
|
| 279 |
+
if (true === $address->validate()) {
|
| 280 |
+
$isOverriden = 1;
|
| 281 |
+
$this->_api->setAddress($address);
|
| 282 |
+
}
|
| 283 |
+
$this->_quote->getPayment()->setAdditionalInformation(
|
| 284 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
|
| 285 |
+
);
|
| 286 |
+
$this->_quote->getPayment()->save();
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
// add line items
|
| 290 |
+
$paypalCart = Mage::getModel('paypalmx/cart', array($this->_quote));
|
| 291 |
+
$this->_api->setPaypalCart($paypalCart)
|
| 292 |
+
->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
|
| 293 |
+
;
|
| 294 |
+
|
| 295 |
+
// add shipping options if needed and line items are available
|
| 296 |
+
if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
|
| 297 |
+
if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
|
| 298 |
+
if ($options = $this->_prepareShippingOptions($address, true)) {
|
| 299 |
+
$this->_api->setShippingOptionsCallbackUrl(
|
| 300 |
+
Mage::getUrl('*/*/shippingOptionsCallback', array('quote_id' => $this->_quote->getId()))
|
| 301 |
+
)->setShippingOptions($options);
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// add recurring payment profiles information
|
| 307 |
+
if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
|
| 308 |
+
foreach ($profiles as $profile) {
|
| 309 |
+
$profile->setMethodCode(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX);
|
| 310 |
+
if (!$profile->isValid()) {
|
| 311 |
+
Mage::throwException($profile->getValidationErrors(true, true));
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
$this->_api->addRecurringPaymentProfiles($profiles);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
|
| 318 |
+
|
| 319 |
+
// call API and redirect with token
|
| 320 |
+
$this->_api->callSetExpressCheckout();
|
| 321 |
+
$token = $this->_api->getToken();
|
| 322 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
|
| 323 |
+
|
| 324 |
+
$this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 325 |
+
$this->_quote->getPayment()->save();
|
| 326 |
+
return $token;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
/**
|
| 330 |
+
* Update quote when returned from PayPal
|
| 331 |
+
* rewrite billing address by paypal
|
| 332 |
+
* save old billing address for new customer
|
| 333 |
+
* export shipping address in case address absence
|
| 334 |
+
*
|
| 335 |
+
* @param string $token
|
| 336 |
+
*/
|
| 337 |
+
public function returnFromPaypal($token)
|
| 338 |
+
{
|
| 339 |
+
$this->_getApi();
|
| 340 |
+
$this->_api->setToken($token)
|
| 341 |
+
->callGetExpressCheckoutDetails();
|
| 342 |
+
$quote = $this->_quote;
|
| 343 |
+
|
| 344 |
+
$this->_ignoreAddressValidation();
|
| 345 |
+
|
| 346 |
+
// import billing address
|
| 347 |
+
$billingAddress = $quote->getBillingAddress();
|
| 348 |
+
$exportedBillingAddress = $this->_api->getExportedBillingAddress();
|
| 349 |
+
$quote->setCustomerEmail($billingAddress->getEmail());
|
| 350 |
+
$quote->setCustomerPrefix($billingAddress->getPrefix());
|
| 351 |
+
$quote->setCustomerFirstname($billingAddress->getFirstname());
|
| 352 |
+
$quote->setCustomerMiddlename($billingAddress->getMiddlename());
|
| 353 |
+
$quote->setCustomerLastname($billingAddress->getLastname());
|
| 354 |
+
$quote->setCustomerSuffix($billingAddress->getSuffix());
|
| 355 |
+
$quote->setCustomerNote($exportedBillingAddress->getData('note'));
|
| 356 |
+
$this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
|
| 357 |
+
|
| 358 |
+
// import shipping address
|
| 359 |
+
$exportedShippingAddress = $this->_api->getExportedShippingAddress();
|
| 360 |
+
if (!$quote->getIsVirtual()) {
|
| 361 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 362 |
+
if ($shippingAddress) {
|
| 363 |
+
if ($exportedShippingAddress) {
|
| 364 |
+
$this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
|
| 365 |
+
$shippingAddress->setCollectShippingRates(true);
|
| 366 |
+
$shippingAddress->setSameAsBilling(0);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
// import shipping method
|
| 370 |
+
$code = '';
|
| 371 |
+
if ($this->_api->getShippingRateCode()) {
|
| 372 |
+
if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
|
| 373 |
+
// possible bug of double collecting rates :-/
|
| 374 |
+
$shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
$quote->getPayment()->setAdditionalInformation(
|
| 378 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD,
|
| 379 |
+
$code
|
| 380 |
+
);
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// import payment info
|
| 385 |
+
$payment = $quote->getPayment();
|
| 386 |
+
$payment->setMethod($this->_methodType);
|
| 387 |
+
Mage::getSingleton('paypalmx/info')->importToPayment($this->_api, $payment);
|
| 388 |
+
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())
|
| 389 |
+
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
|
| 390 |
+
;
|
| 391 |
+
$quote->collectTotals()->save();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/**
|
| 395 |
+
* Check whether order review has enough data to initialize
|
| 396 |
+
*
|
| 397 |
+
* @param $token
|
| 398 |
+
* @throws Mage_Core_Exception
|
| 399 |
+
*/
|
| 400 |
+
public function prepareOrderReview($token = null)
|
| 401 |
+
{
|
| 402 |
+
$payment = $this->_quote->getPayment();
|
| 403 |
+
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
|
| 404 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Payer is not identified.'));
|
| 405 |
+
}
|
| 406 |
+
$this->_quote->setMayEditShippingAddress(
|
| 407 |
+
1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN)
|
| 408 |
+
);
|
| 409 |
+
$this->_quote->setMayEditShippingMethod(
|
| 410 |
+
'' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
|
| 411 |
+
);
|
| 412 |
+
$this->_ignoreAddressValidation();
|
| 413 |
+
$this->_quote->collectTotals()->save();
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* Return callback response with shipping options
|
| 418 |
+
*
|
| 419 |
+
* @param array $request
|
| 420 |
+
* @return string
|
| 421 |
+
*/
|
| 422 |
+
public function getShippingOptionsCallbackResponse(array $request)
|
| 423 |
+
{
|
| 424 |
+
// prepare debug data
|
| 425 |
+
$logger = Mage::getModel('core/log_adapter', 'payment_' . $this->_methodType . '.log');
|
| 426 |
+
$debugData = array('request' => $request, 'response' => array());
|
| 427 |
+
|
| 428 |
+
try {
|
| 429 |
+
// obtain addresses
|
| 430 |
+
$this->_getApi();
|
| 431 |
+
$address = $this->_api->prepareShippingOptionsCallbackAddress($request);
|
| 432 |
+
$quoteAddress = $this->_quote->getShippingAddress();
|
| 433 |
+
|
| 434 |
+
// compare addresses, calculate shipping rates and prepare response
|
| 435 |
+
$options = array();
|
| 436 |
+
if ($address && $quoteAddress && !$this->_quote->getIsVirtual()) {
|
| 437 |
+
foreach ($address->getExportedKeys() as $key) {
|
| 438 |
+
$quoteAddress->setDataUsingMethod($key, $address->getData($key));
|
| 439 |
+
}
|
| 440 |
+
$quoteAddress->setCollectShippingRates(true)->collectTotals();
|
| 441 |
+
$options = $this->_prepareShippingOptions($quoteAddress, false, true);
|
| 442 |
+
}
|
| 443 |
+
$response = $this->_api->setShippingOptions($options)->formatShippingOptionsCallback();
|
| 444 |
+
|
| 445 |
+
// log request and response
|
| 446 |
+
$debugData['response'] = $response;
|
| 447 |
+
$logger->log($debugData);
|
| 448 |
+
return $response;
|
| 449 |
+
} catch (Exception $e) {
|
| 450 |
+
$logger->log($debugData);
|
| 451 |
+
throw $e;
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Set shipping method to quote, if needed
|
| 457 |
+
* @param string $methodCode
|
| 458 |
+
*/
|
| 459 |
+
public function updateShippingMethod($methodCode)
|
| 460 |
+
{
|
| 461 |
+
if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
|
| 462 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
| 463 |
+
$this->_ignoreAddressValidation();
|
| 464 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
| 465 |
+
$this->_quote->collectTotals();
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Update order data
|
| 472 |
+
*
|
| 473 |
+
* @param array $data
|
| 474 |
+
*/
|
| 475 |
+
public function updateOrder($data)
|
| 476 |
+
{
|
| 477 |
+
/** @var $checkout Mage_Checkout_Model_Type_Onepage */
|
| 478 |
+
$checkout = Mage::getModel('checkout/type_onepage');
|
| 479 |
+
|
| 480 |
+
$this->_quote->setTotalsCollectedFlag(true);
|
| 481 |
+
$checkout->setQuote($this->_quote);
|
| 482 |
+
if (isset($data['billing'])) {
|
| 483 |
+
if (isset($data['customer-email'])) {
|
| 484 |
+
$data['billing']['email'] = $data['customer-email'];
|
| 485 |
+
}
|
| 486 |
+
$checkout->saveBilling($data['billing'], 0);
|
| 487 |
+
}
|
| 488 |
+
if (!$this->_quote->getIsVirtual() && isset($data['shipping'])) {
|
| 489 |
+
$checkout->saveShipping($data['shipping'], 0);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
if (isset($data['shipping_method'])) {
|
| 493 |
+
$this->updateShippingMethod($data['shipping_method']);
|
| 494 |
+
}
|
| 495 |
+
$this->_quote->setTotalsCollectedFlag(false);
|
| 496 |
+
$this->_quote->collectTotals();
|
| 497 |
+
$this->_quote->setDataChanges(true);
|
| 498 |
+
$this->_quote->save();
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/**
|
| 502 |
+
* Place the order and recurring payment profiles when customer returned from paypal
|
| 503 |
+
* Until this moment all quote data must be valid
|
| 504 |
+
*
|
| 505 |
+
* @param string $token
|
| 506 |
+
* @param string $shippingMethodCode
|
| 507 |
+
*/
|
| 508 |
+
public function place($token, $shippingMethodCode = null)
|
| 509 |
+
{
|
| 510 |
+
if ($shippingMethodCode) {
|
| 511 |
+
$this->updateShippingMethod($shippingMethodCode);
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
$isNewCustomer = false;
|
| 515 |
+
switch ($this->getCheckoutMethod()) {
|
| 516 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
|
| 517 |
+
$this->_prepareGuestQuote();
|
| 518 |
+
break;
|
| 519 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
|
| 520 |
+
$this->_prepareNewCustomerQuote();
|
| 521 |
+
$isNewCustomer = true;
|
| 522 |
+
break;
|
| 523 |
+
default:
|
| 524 |
+
$this->_prepareCustomerQuote();
|
| 525 |
+
break;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
$this->_ignoreAddressValidation();
|
| 529 |
+
$this->_quote->collectTotals();
|
| 530 |
+
$service = Mage::getModel('sales/service_quote', $this->_quote);
|
| 531 |
+
$service->submitAll();
|
| 532 |
+
$this->_quote->save();
|
| 533 |
+
|
| 534 |
+
if ($isNewCustomer) {
|
| 535 |
+
try {
|
| 536 |
+
$this->_involveNewCustomer();
|
| 537 |
+
} catch (Exception $e) {
|
| 538 |
+
Mage::logException($e);
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
$this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
|
| 543 |
+
// TODO: send recurring profile emails
|
| 544 |
+
|
| 545 |
+
$order = $service->getOrder();
|
| 546 |
+
if (!$order) {
|
| 547 |
+
return;
|
| 548 |
+
}
|
| 549 |
+
$this->_billingAgreement = $order->getPayment()->getBillingAgreement();
|
| 550 |
+
|
| 551 |
+
// commence redirecting to finish payment, if paypal requires it
|
| 552 |
+
if ($order->getPayment()->getAdditionalInformation(
|
| 553 |
+
Ebcomm_PaypalMx_Model_Mensualidades2_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT
|
| 554 |
+
)) {
|
| 555 |
+
$this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
switch ($order->getState()) {
|
| 559 |
+
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
|
| 560 |
+
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
| 561 |
+
// TODO
|
| 562 |
+
break;
|
| 563 |
+
// regular placement, when everything is ok
|
| 564 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
| 565 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
| 566 |
+
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
|
| 567 |
+
$order->sendNewOrderEmail();
|
| 568 |
+
break;
|
| 569 |
+
}
|
| 570 |
+
$this->_order = $order;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Make sure addresses will be saved without validation errors
|
| 575 |
+
*/
|
| 576 |
+
private function _ignoreAddressValidation()
|
| 577 |
+
{
|
| 578 |
+
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
| 579 |
+
if (!$this->_quote->getIsVirtual()) {
|
| 580 |
+
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
| 581 |
+
if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) {
|
| 582 |
+
$this->_quote->getBillingAddress()->setSameAsBilling(1);
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
/**
|
| 588 |
+
* Determine whether redirect somewhere specifically is required
|
| 589 |
+
*
|
| 590 |
+
* @return string
|
| 591 |
+
*/
|
| 592 |
+
public function getRedirectUrl()
|
| 593 |
+
{
|
| 594 |
+
return $this->_redirectUrl;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
/**
|
| 598 |
+
* Return recurring payment profiles
|
| 599 |
+
*
|
| 600 |
+
* @return array
|
| 601 |
+
*/
|
| 602 |
+
public function getRecurringPaymentProfiles()
|
| 603 |
+
{
|
| 604 |
+
return $this->_recurringPaymentProfiles;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/**
|
| 608 |
+
* Get created billing agreement
|
| 609 |
+
*
|
| 610 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
| 611 |
+
*/
|
| 612 |
+
public function getBillingAgreement()
|
| 613 |
+
{
|
| 614 |
+
return $this->_billingAgreement;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* Return order
|
| 619 |
+
*
|
| 620 |
+
* @return Mage_Sales_Model_Order
|
| 621 |
+
*/
|
| 622 |
+
public function getOrder()
|
| 623 |
+
{
|
| 624 |
+
return $this->_order;
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
/**
|
| 628 |
+
* Get checkout method
|
| 629 |
+
*
|
| 630 |
+
* @return string
|
| 631 |
+
*/
|
| 632 |
+
public function getCheckoutMethod()
|
| 633 |
+
{
|
| 634 |
+
if ($this->getCustomerSession()->isLoggedIn()) {
|
| 635 |
+
return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
| 636 |
+
}
|
| 637 |
+
if (!$this->_quote->getCheckoutMethod()) {
|
| 638 |
+
if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
|
| 639 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
| 640 |
+
} else {
|
| 641 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
return $this->_quote->getCheckoutMethod();
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
/**
|
| 648 |
+
* Sets address data from exported address
|
| 649 |
+
*
|
| 650 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 651 |
+
* @param array $exportedAddress
|
| 652 |
+
*/
|
| 653 |
+
protected function _setExportedAddressData($address, $exportedAddress)
|
| 654 |
+
{
|
| 655 |
+
foreach ($exportedAddress->getExportedKeys() as $key) {
|
| 656 |
+
$oldData = $address->getDataUsingMethod($key);
|
| 657 |
+
$isEmpty = null;
|
| 658 |
+
if (is_array($oldData)) {
|
| 659 |
+
foreach($oldData as $val) {
|
| 660 |
+
if(!empty($val)) {
|
| 661 |
+
$isEmpty = false;
|
| 662 |
+
break;
|
| 663 |
+
}
|
| 664 |
+
$isEmpty = true;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
if (empty($oldData) || $isEmpty === true) {
|
| 668 |
+
$address->setDataUsingMethod($key, $exportedAddress->getData($key));
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
/**
|
| 674 |
+
* Set create billing agreement flag to api call
|
| 675 |
+
*
|
| 676 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 677 |
+
*/
|
| 678 |
+
protected function _setBillingAgreementRequest()
|
| 679 |
+
{
|
| 680 |
+
if (!$this->_customerId || $this->_quote->hasNominalItems()) {
|
| 681 |
+
return $this;
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
$isRequested = $this->_isBARequested || $this->_quote->getPayment()
|
| 685 |
+
->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
|
| 686 |
+
|
| 687 |
+
if (!($this->_config->allow_ba_signup == Ebcomm_PaypalMx_Model_Config::EC_BA_SIGNUP_AUTO
|
| 688 |
+
|| $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
|
| 689 |
+
return $this;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
|
| 693 |
+
return $this;
|
| 694 |
+
}
|
| 695 |
+
$this->_api->setBillingType($this->_api->getBillingAgreementType());
|
| 696 |
+
return $this;
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
/**
|
| 700 |
+
* @return Mage_Paypal_Model_Api_Nvp
|
| 701 |
+
*/
|
| 702 |
+
protected function _getApi()
|
| 703 |
+
{
|
| 704 |
+
if (null === $this->_api) {
|
| 705 |
+
$this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
|
| 706 |
+
}
|
| 707 |
+
return $this->_api;
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/**
|
| 711 |
+
* Attempt to collect address shipping rates and return them for further usage in instant update API
|
| 712 |
+
* Returns empty array if it was impossible to obtain any shipping rate
|
| 713 |
+
* If there are shipping rates obtained, the method must return one of them as default.
|
| 714 |
+
*
|
| 715 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 716 |
+
* @param bool $mayReturnEmpty
|
| 717 |
+
* @return array|false
|
| 718 |
+
*/
|
| 719 |
+
protected function _prepareShippingOptions(
|
| 720 |
+
Mage_Sales_Model_Quote_Address $address,
|
| 721 |
+
$mayReturnEmpty = false, $calculateTax = false
|
| 722 |
+
) {
|
| 723 |
+
$options = array(); $i = 0; $iMin = false; $min = false;
|
| 724 |
+
$userSelectedOption = null;
|
| 725 |
+
|
| 726 |
+
foreach ($address->getGroupedAllShippingRates() as $group) {
|
| 727 |
+
foreach ($group as $rate) {
|
| 728 |
+
$amount = (float)$rate->getPrice();
|
| 729 |
+
if ($rate->getErrorMessage()) {
|
| 730 |
+
continue;
|
| 731 |
+
}
|
| 732 |
+
$isDefault = $address->getShippingMethod() === $rate->getCode();
|
| 733 |
+
$amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address);
|
| 734 |
+
$amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address);
|
| 735 |
+
|
| 736 |
+
$options[$i] = new Varien_Object(array(
|
| 737 |
+
'is_default' => $isDefault,
|
| 738 |
+
'name' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'),
|
| 739 |
+
'code' => $rate->getCode(),
|
| 740 |
+
'amount' => $amountExclTax,
|
| 741 |
+
));
|
| 742 |
+
if ($calculateTax) {
|
| 743 |
+
$options[$i]->setTaxAmount(
|
| 744 |
+
$amountInclTax - $amountExclTax
|
| 745 |
+
+ $address->getTaxAmount() - $address->getShippingTaxAmount()
|
| 746 |
+
);
|
| 747 |
+
}
|
| 748 |
+
if ($isDefault) {
|
| 749 |
+
$userSelectedOption = $options[$i];
|
| 750 |
+
}
|
| 751 |
+
if (false === $min || $amountInclTax < $min) {
|
| 752 |
+
$min = $amountInclTax;
|
| 753 |
+
$iMin = $i;
|
| 754 |
+
}
|
| 755 |
+
$i++;
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
if ($mayReturnEmpty && is_null($userSelectedOption)) {
|
| 760 |
+
$options[] = new Varien_Object(array(
|
| 761 |
+
'is_default' => true,
|
| 762 |
+
'name' => Mage::helper('paypalmx')->__('N/A'),
|
| 763 |
+
'code' => 'no_rate',
|
| 764 |
+
'amount' => 0.00,
|
| 765 |
+
));
|
| 766 |
+
if ($calculateTax) {
|
| 767 |
+
$options[$i]->setTaxAmount($address->getTaxAmount());
|
| 768 |
+
}
|
| 769 |
+
} elseif (is_null($userSelectedOption) && isset($options[$iMin])) {
|
| 770 |
+
$options[$iMin]->setIsDefault(true);
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
// Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
|
| 774 |
+
if (count($options) > 10) {
|
| 775 |
+
usort($options, array(get_class($this),'cmpShippingOptions'));
|
| 776 |
+
array_splice($options, 10);
|
| 777 |
+
// User selected option will be always included in options list
|
| 778 |
+
if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
|
| 779 |
+
$options[9] = $userSelectedOption;
|
| 780 |
+
}
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
return $options;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
/**
|
| 787 |
+
* Compare two shipping options based on their amounts
|
| 788 |
+
*
|
| 789 |
+
* This function is used as a callback comparison function in shipping options sorting process
|
| 790 |
+
* @see self::_prepareShippingOptions()
|
| 791 |
+
*
|
| 792 |
+
* @param Varien_Object $option1
|
| 793 |
+
* @param Varien_Object $option2
|
| 794 |
+
* @return integer
|
| 795 |
+
*/
|
| 796 |
+
protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2)
|
| 797 |
+
{
|
| 798 |
+
if ($option1->getAmount() == $option2->getAmount()) {
|
| 799 |
+
return 0;
|
| 800 |
+
}
|
| 801 |
+
return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
/**
|
| 805 |
+
* Try to find whether the code provided by PayPal corresponds to any of possible shipping rates
|
| 806 |
+
* This method was created only because PayPal has issues with returning the selected code.
|
| 807 |
+
* If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code
|
| 808 |
+
* before collecting shipping rates
|
| 809 |
+
*
|
| 810 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 811 |
+
* @param string $selectedCode
|
| 812 |
+
* @return string
|
| 813 |
+
*/
|
| 814 |
+
protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode)
|
| 815 |
+
{
|
| 816 |
+
$options = $this->_prepareShippingOptions($address, false);
|
| 817 |
+
foreach ($options as $option) {
|
| 818 |
+
if ($selectedCode === $option['code'] // the proper case as outlined in documentation
|
| 819 |
+
|| $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code
|
| 820 |
+
// workaround: PayPal may concatenate code and name, and return it instead of the code:
|
| 821 |
+
|| $selectedCode === "{$option['code']} {$option['name']}"
|
| 822 |
+
) {
|
| 823 |
+
return $option['code'];
|
| 824 |
+
}
|
| 825 |
+
}
|
| 826 |
+
return '';
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
/**
|
| 830 |
+
* Prepare quote for guest checkout order submit
|
| 831 |
+
*
|
| 832 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 833 |
+
*/
|
| 834 |
+
protected function _prepareGuestQuote()
|
| 835 |
+
{
|
| 836 |
+
$quote = $this->_quote;
|
| 837 |
+
$quote->setCustomerId(null)
|
| 838 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
|
| 839 |
+
->setCustomerIsGuest(true)
|
| 840 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
| 841 |
+
return $this;
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
/**
|
| 845 |
+
* Prepare quote for customer registration and customer order submit
|
| 846 |
+
* and restore magento customer data from quote
|
| 847 |
+
*
|
| 848 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 849 |
+
*/
|
| 850 |
+
protected function _prepareNewCustomerQuote()
|
| 851 |
+
{
|
| 852 |
+
$quote = $this->_quote;
|
| 853 |
+
$billing = $quote->getBillingAddress();
|
| 854 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 855 |
+
|
| 856 |
+
$customer = $quote->getCustomer();
|
| 857 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 858 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 859 |
+
$customer->addAddress($customerBilling);
|
| 860 |
+
$billing->setCustomerAddress($customerBilling);
|
| 861 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 862 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
| 863 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 864 |
+
$customer->addAddress($customerShipping);
|
| 865 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 866 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 867 |
+
} elseif ($shipping) {
|
| 868 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 869 |
+
}
|
| 870 |
+
/**
|
| 871 |
+
* @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
|
| 872 |
+
*/
|
| 873 |
+
if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
|
| 874 |
+
$billing->setCustomerDob($quote->getCustomerDob());
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
|
| 878 |
+
$billing->setCustomerTaxvat($quote->getCustomerTaxvat());
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
|
| 882 |
+
$billing->setCustomerGender($quote->getCustomerGender());
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
| 886 |
+
$customer->setEmail($quote->getCustomerEmail());
|
| 887 |
+
$customer->setPrefix($quote->getCustomerPrefix());
|
| 888 |
+
$customer->setFirstname($quote->getCustomerFirstname());
|
| 889 |
+
$customer->setMiddlename($quote->getCustomerMiddlename());
|
| 890 |
+
$customer->setLastname($quote->getCustomerLastname());
|
| 891 |
+
$customer->setSuffix($quote->getCustomerSuffix());
|
| 892 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
| 893 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
| 894 |
+
$customer->save();
|
| 895 |
+
$quote->setCustomer($customer);
|
| 896 |
+
|
| 897 |
+
return $this;
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
/**
|
| 901 |
+
* Prepare quote for customer order submit
|
| 902 |
+
*
|
| 903 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 904 |
+
*/
|
| 905 |
+
protected function _prepareCustomerQuote()
|
| 906 |
+
{
|
| 907 |
+
$quote = $this->_quote;
|
| 908 |
+
$billing = $quote->getBillingAddress();
|
| 909 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 910 |
+
|
| 911 |
+
$customer = $this->getCustomerSession()->getCustomer();
|
| 912 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
| 913 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 914 |
+
$customer->addAddress($customerBilling);
|
| 915 |
+
$billing->setCustomerAddress($customerBilling);
|
| 916 |
+
}
|
| 917 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
| 918 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
| 919 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 920 |
+
$customer->addAddress($customerShipping);
|
| 921 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
| 925 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 926 |
+
}
|
| 927 |
+
if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
|
| 928 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 929 |
+
} elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
| 930 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 931 |
+
}
|
| 932 |
+
$quote->setCustomer($customer);
|
| 933 |
+
|
| 934 |
+
return $this;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
/**
|
| 938 |
+
* Involve new customer to system
|
| 939 |
+
*
|
| 940 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 941 |
+
*/
|
| 942 |
+
protected function _involveNewCustomer()
|
| 943 |
+
{
|
| 944 |
+
$customer = $this->_quote->getCustomer();
|
| 945 |
+
if ($customer->isConfirmationRequired()) {
|
| 946 |
+
$customer->sendNewAccountEmail('confirmation');
|
| 947 |
+
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
| 948 |
+
$this->getCustomerSession()->addSuccess(
|
| 949 |
+
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
|
| 950 |
+
);
|
| 951 |
+
} else {
|
| 952 |
+
$customer->sendNewAccountEmail();
|
| 953 |
+
$this->getCustomerSession()->loginById($customer->getId());
|
| 954 |
+
}
|
| 955 |
+
return $this;
|
| 956 |
+
}
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Get customer session object
|
| 960 |
+
*
|
| 961 |
+
* @return Mage_Customer_Model_Session
|
| 962 |
+
*/
|
| 963 |
+
public function getCustomerSession()
|
| 964 |
+
{
|
| 965 |
+
return $this->_customerSession;
|
| 966 |
+
}
|
| 967 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Pro.php
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* PayPal Website Payments Pro implementation for payment method instaces
|
| 4 |
+
* This model was created because right now PayPal Direct and PayPal Express payment methods cannot have same abstract
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_Pro
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Possible payment review actions (for FMF only)
|
| 10 |
+
*
|
| 11 |
+
* @var string
|
| 12 |
+
*/
|
| 13 |
+
const PAYMENT_REVIEW_ACCEPT = 'accept';
|
| 14 |
+
const PAYMENT_REVIEW_DENY = 'deny';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Config instance
|
| 18 |
+
*
|
| 19 |
+
* @var Mage_Paypal_Model_Config
|
| 20 |
+
*/
|
| 21 |
+
protected $_config = null;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* API instance
|
| 25 |
+
*
|
| 26 |
+
* @var Mage_Paypal_Model_Api_Nvp
|
| 27 |
+
*/
|
| 28 |
+
protected $_api = null;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* PayPal info object
|
| 32 |
+
*
|
| 33 |
+
* @var Mage_Paypal_Model_Info
|
| 34 |
+
*/
|
| 35 |
+
protected $_infoInstance = null;
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* API model type
|
| 39 |
+
*
|
| 40 |
+
* @var string
|
| 41 |
+
*/
|
| 42 |
+
protected $_apiType = 'paypalmx/api_nvp';
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Config model type
|
| 46 |
+
*
|
| 47 |
+
* @var string
|
| 48 |
+
*/
|
| 49 |
+
protected $_configType = 'paypalmx/config';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Payment method code setter. Also instantiates/updates config
|
| 53 |
+
*
|
| 54 |
+
* @param string $code
|
| 55 |
+
* @param int|null $storeId
|
| 56 |
+
*/
|
| 57 |
+
public function setMethod($code, $storeId = null)
|
| 58 |
+
{
|
| 59 |
+
if (null === $this->_config) {
|
| 60 |
+
$params = array($code);
|
| 61 |
+
if (null !== $storeId) {
|
| 62 |
+
$params[] = $storeId;
|
| 63 |
+
}
|
| 64 |
+
$this->_config = Mage::getModel($this->_configType, $params);
|
| 65 |
+
} else {
|
| 66 |
+
$this->_config->setMethod($code);
|
| 67 |
+
if (null !== $storeId) {
|
| 68 |
+
$this->_config->setStoreId($storeId);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
return $this;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Config instance setter
|
| 76 |
+
*
|
| 77 |
+
* @param Mage_Paypal_Model_Config $instace
|
| 78 |
+
* @param int $storeId
|
| 79 |
+
*/
|
| 80 |
+
public function setConfig(Ebcomm_PaypalMx_Model_Config $instace, $storeId = null)
|
| 81 |
+
{
|
| 82 |
+
$this->_config = $instace;
|
| 83 |
+
if (null !== $storeId) {
|
| 84 |
+
$this->_config->setStoreId($storeId);
|
| 85 |
+
}
|
| 86 |
+
return $this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Config instance getter
|
| 91 |
+
*
|
| 92 |
+
* @return Mage_Paypal_Model_Config
|
| 93 |
+
*/
|
| 94 |
+
public function getConfig()
|
| 95 |
+
{
|
| 96 |
+
return $this->_config;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* API instance getter
|
| 101 |
+
* Sets current store id to current config instance and passes it to API
|
| 102 |
+
*
|
| 103 |
+
* @return Mage_Paypal_Model_Api_Nvp
|
| 104 |
+
*/
|
| 105 |
+
public function getApi()
|
| 106 |
+
{
|
| 107 |
+
if (null === $this->_api) {
|
| 108 |
+
$this->_api = Mage::getModel($this->_apiType);
|
| 109 |
+
}
|
| 110 |
+
$this->_api->setConfigObject($this->_config);
|
| 111 |
+
return $this->_api;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* Destroy existing NVP Api object
|
| 116 |
+
*
|
| 117 |
+
* @return Mage_Paypal_Model_Pro
|
| 118 |
+
*/
|
| 119 |
+
public function resetApi()
|
| 120 |
+
{
|
| 121 |
+
$this->_api = null;
|
| 122 |
+
|
| 123 |
+
return $this;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Instantiate and return info model
|
| 128 |
+
*
|
| 129 |
+
* @return Mage_Paypal_Model_Info
|
| 130 |
+
*/
|
| 131 |
+
public function getInfo()
|
| 132 |
+
{
|
| 133 |
+
if (null === $this->_infoInstance) {
|
| 134 |
+
$this->_infoInstance = Mage::getModel('paypalmx/info');
|
| 135 |
+
}
|
| 136 |
+
return $this->_infoInstance;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Transfer transaction/payment information from API instance to order payment
|
| 141 |
+
*
|
| 142 |
+
* @param Mage_Paypal_Model_Api_Abstract $from
|
| 143 |
+
* @param Mage_Payment_Model_Info $to
|
| 144 |
+
* @return Mage_Paypal_Model_Pro
|
| 145 |
+
*/
|
| 146 |
+
public function importPaymentInfo(Varien_Object $from, Mage_Payment_Model_Info $to)
|
| 147 |
+
{
|
| 148 |
+
// update PayPal-specific payment information in the payment object
|
| 149 |
+
$this->getInfo()->importToPayment($from, $to);
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* Detect payment review and/or frauds
|
| 153 |
+
* PayPal pro API returns fraud results only in the payment call response
|
| 154 |
+
*/
|
| 155 |
+
if ($from->getDataUsingMethod(Ebcomm_PaypalMx_Model_Info::IS_FRAUD)) {
|
| 156 |
+
$to->setIsTransactionPending(true);
|
| 157 |
+
$to->setIsFraudDetected(true);
|
| 158 |
+
} elseif ($this->getInfo()->isPaymentReviewRequired($to)) {
|
| 159 |
+
$to->setIsTransactionPending(true);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// give generic info about transaction state
|
| 163 |
+
if ($this->getInfo()->isPaymentSuccessful($to)) {
|
| 164 |
+
$to->setIsTransactionApproved(true);
|
| 165 |
+
} elseif ($this->getInfo()->isPaymentFailed($to)) {
|
| 166 |
+
$to->setIsTransactionDenied(true);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
return $this;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Void transaction
|
| 174 |
+
*
|
| 175 |
+
* @param Varien_Object $payment
|
| 176 |
+
*/
|
| 177 |
+
public function void(Varien_Object $payment)
|
| 178 |
+
{
|
| 179 |
+
if ($authTransactionId = $this->_getParentTransactionId($payment)) {
|
| 180 |
+
$api = $this->getApi();
|
| 181 |
+
$api->setPayment($payment)->setAuthorizationId($authTransactionId)->callDoVoid();
|
| 182 |
+
$this->importPaymentInfo($api, $payment);
|
| 183 |
+
} else {
|
| 184 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Authorization transaction is required to void.'));
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Attempt to capture payment
|
| 190 |
+
* Will return false if the payment is not supposed to be captured
|
| 191 |
+
*
|
| 192 |
+
* @param Varien_Object $payment
|
| 193 |
+
* @param float $amount
|
| 194 |
+
* @return false|null
|
| 195 |
+
*/
|
| 196 |
+
public function capture(Varien_Object $payment, $amount)
|
| 197 |
+
{
|
| 198 |
+
$authTransactionId = $this->_getParentTransactionId($payment);
|
| 199 |
+
if (!$authTransactionId) {
|
| 200 |
+
return false;
|
| 201 |
+
}
|
| 202 |
+
$api = $this->getApi()
|
| 203 |
+
->setAuthorizationId($authTransactionId)
|
| 204 |
+
->setIsCaptureComplete($payment->getShouldCloseParentTransaction())
|
| 205 |
+
->setAmount($amount)
|
| 206 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 207 |
+
->setInvNum($payment->getOrder()->getIncrementId()."MGT")
|
| 208 |
+
// TODO: pass 'NOTE' to API
|
| 209 |
+
;
|
| 210 |
+
|
| 211 |
+
$api->callDoCapture();
|
| 212 |
+
$this->_importCaptureResultToPayment($api, $payment);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* Refund a capture transaction
|
| 217 |
+
*
|
| 218 |
+
* @param Varien_Object $payment
|
| 219 |
+
* @param float $amount
|
| 220 |
+
*/
|
| 221 |
+
public function refund(Varien_Object $payment, $amount)
|
| 222 |
+
{
|
| 223 |
+
$captureTxnId = $this->_getParentTransactionId($payment);
|
| 224 |
+
if ($captureTxnId) {
|
| 225 |
+
$api = $this->getApi();
|
| 226 |
+
$order = $payment->getOrder();
|
| 227 |
+
$api->setPayment($payment)
|
| 228 |
+
->setTransactionId($captureTxnId)
|
| 229 |
+
->setAmount($amount)
|
| 230 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
| 231 |
+
;
|
| 232 |
+
$canRefundMore = $payment->getCreditmemo()->getInvoice()->canRefund();
|
| 233 |
+
$isFullRefund = !$canRefundMore
|
| 234 |
+
&& (0 == ((float)$order->getBaseTotalOnlineRefunded() + (float)$order->getBaseTotalOfflineRefunded()));
|
| 235 |
+
$api->setRefundType($isFullRefund ? Ebcomm_PaypalMx_Model_Config::REFUND_TYPE_FULL
|
| 236 |
+
: Ebcomm_PaypalMx_Model_Config::REFUND_TYPE_PARTIAL
|
| 237 |
+
);
|
| 238 |
+
$api->callRefundTransaction();
|
| 239 |
+
$this->_importRefundResultToPayment($api, $payment, $canRefundMore);
|
| 240 |
+
} else {
|
| 241 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Impossible to issue a refund transaction because the capture transaction does not exist.'));
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
/**
|
| 246 |
+
* Cancel payment
|
| 247 |
+
*
|
| 248 |
+
* @param Varien_Object $payment
|
| 249 |
+
*/
|
| 250 |
+
public function cancel(Varien_Object $payment)
|
| 251 |
+
{
|
| 252 |
+
if (!$payment->getOrder()->getInvoiceCollection()->count()) {
|
| 253 |
+
$this->void($payment);
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
/**
|
| 258 |
+
*
|
| 259 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 260 |
+
* @return bool
|
| 261 |
+
*/
|
| 262 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 263 |
+
{
|
| 264 |
+
return Ebcomm_PaypalMx_Model_Info::isPaymentReviewRequired($payment);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* Perform the payment review
|
| 269 |
+
*
|
| 270 |
+
* @param Mage_Payment_Model_Info $payment
|
| 271 |
+
* @param string $action
|
| 272 |
+
* @return bool
|
| 273 |
+
*/
|
| 274 |
+
public function reviewPayment(Mage_Payment_Model_Info $payment, $action)
|
| 275 |
+
{
|
| 276 |
+
$api = $this->getApi()->setTransactionId($payment->getLastTransId());
|
| 277 |
+
|
| 278 |
+
// check whether the review is still needed
|
| 279 |
+
$api->callGetTransactionDetails();
|
| 280 |
+
$this->importPaymentInfo($api, $payment);
|
| 281 |
+
if (!$this->getInfo()->isPaymentReviewRequired($payment)) {
|
| 282 |
+
return false;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
// perform the review action
|
| 286 |
+
$api->setAction($action)->callManagePendingTransactionStatus();
|
| 287 |
+
$api->callGetTransactionDetails();
|
| 288 |
+
$this->importPaymentInfo($api, $payment);
|
| 289 |
+
return true;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
/**
|
| 293 |
+
* Fetch transaction details info
|
| 294 |
+
*
|
| 295 |
+
* @param Mage_Payment_Model_Info $payment
|
| 296 |
+
* @param string $transactionId
|
| 297 |
+
* @return array
|
| 298 |
+
*/
|
| 299 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 300 |
+
{
|
| 301 |
+
$api = $this->getApi()
|
| 302 |
+
->setTransactionId($transactionId)
|
| 303 |
+
->setRawResponseNeeded(true);
|
| 304 |
+
$api->callGetTransactionDetails();
|
| 305 |
+
$this->importPaymentInfo($api, $payment);
|
| 306 |
+
$data = $api->getRawSuccessResponseData();
|
| 307 |
+
return ($data) ? $data : array();
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
* Validate RP data
|
| 312 |
+
*
|
| 313 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 314 |
+
* @throws Mage_Core_Exception
|
| 315 |
+
*/
|
| 316 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 317 |
+
{
|
| 318 |
+
$errors = array();
|
| 319 |
+
if (strlen($profile->getSubscriberName()) > 32) { // up to 32 single-byte chars
|
| 320 |
+
$errors[] = Mage::helper('paypalmx')->__('Subscriber name is too long.');
|
| 321 |
+
}
|
| 322 |
+
$refId = $profile->getInternalReferenceId(); // up to 127 single-byte alphanumeric
|
| 323 |
+
if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $refId)
|
| 324 |
+
$errors[] = Mage::helper('paypalmx')->__('Merchant reference ID format is not supported.');
|
| 325 |
+
}
|
| 326 |
+
$scheduleDescr = $profile->getScheduleDescription(); // up to 127 single-byte alphanumeric
|
| 327 |
+
if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $scheduleDescr)
|
| 328 |
+
$errors[] = Mage::helper('paypalmx')->__('Schedule description is too long.');
|
| 329 |
+
}
|
| 330 |
+
if ($errors) {
|
| 331 |
+
Mage::throwException(implode(' ', $errors));
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* Submit RP to the gateway
|
| 337 |
+
*
|
| 338 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 339 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 340 |
+
* @throws Mage_Core_Exception
|
| 341 |
+
*/
|
| 342 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 343 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 344 |
+
) {
|
| 345 |
+
$api = $this->getApi();
|
| 346 |
+
Varien_Object_Mapper::accumulateByMap($profile, $api, array(
|
| 347 |
+
'token', // EC fields
|
| 348 |
+
// TODO: DP fields
|
| 349 |
+
// profile fields
|
| 350 |
+
'subscriber_name', 'start_datetime', 'internal_reference_id', 'schedule_description',
|
| 351 |
+
'suspension_threshold', 'bill_failed_later', 'period_unit', 'period_frequency', 'period_max_cycles',
|
| 352 |
+
'billing_amount' => 'amount', 'trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles',
|
| 353 |
+
'trial_billing_amount', 'currency_code', 'shipping_amount', 'tax_amount', 'init_amount', 'init_may_fail',
|
| 354 |
+
));
|
| 355 |
+
$api->callCreateRecurringPaymentsProfile();
|
| 356 |
+
$profile->setReferenceId($api->getRecurringProfileId());
|
| 357 |
+
if ($api->getIsProfileActive()) {
|
| 358 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
| 359 |
+
} elseif ($api->getIsProfilePending()) {
|
| 360 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING);
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
/**
|
| 365 |
+
* Fetch RP details
|
| 366 |
+
*
|
| 367 |
+
* @param string $referenceId
|
| 368 |
+
* @param Varien_Object $result
|
| 369 |
+
*/
|
| 370 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 371 |
+
{
|
| 372 |
+
$api = $this->getApi();
|
| 373 |
+
$api->setRecurringProfileId($referenceId)
|
| 374 |
+
->callGetRecurringPaymentsProfileDetails($result)
|
| 375 |
+
;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
/**
|
| 379 |
+
* Update RP data
|
| 380 |
+
*
|
| 381 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 382 |
+
*/
|
| 383 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 384 |
+
{
|
| 385 |
+
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
/**
|
| 389 |
+
* Manage status
|
| 390 |
+
*
|
| 391 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 392 |
+
*/
|
| 393 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 394 |
+
{
|
| 395 |
+
$api = $this->getApi();
|
| 396 |
+
$action = null;
|
| 397 |
+
switch ($profile->getNewState()) {
|
| 398 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED: $action = 'cancel'; break;
|
| 399 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED: $action = 'suspend'; break;
|
| 400 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE: $action = 'activate'; break;
|
| 401 |
+
}
|
| 402 |
+
$state = $profile->getState();
|
| 403 |
+
$api->setRecurringProfileId($profile->getReferenceId())
|
| 404 |
+
->setIsAlreadyCanceled($state == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED)
|
| 405 |
+
->setIsAlreadySuspended($state == Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED)
|
| 406 |
+
->setIsAlreadyActive($state == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE)
|
| 407 |
+
->setAction($action)
|
| 408 |
+
->callManageRecurringPaymentsProfileStatus()
|
| 409 |
+
;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
* Import capture results to payment
|
| 414 |
+
*
|
| 415 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 416 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 417 |
+
*/
|
| 418 |
+
protected function _importCaptureResultToPayment($api, $payment)
|
| 419 |
+
{
|
| 420 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(false);
|
| 421 |
+
$this->importPaymentInfo($api, $payment);
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
/**
|
| 425 |
+
* Import refund results to payment
|
| 426 |
+
*
|
| 427 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 428 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 429 |
+
* @param bool $canRefundMore
|
| 430 |
+
*/
|
| 431 |
+
protected function _importRefundResultToPayment($api, $payment, $canRefundMore)
|
| 432 |
+
{
|
| 433 |
+
$payment->setTransactionId($api->getRefundTransactionId())
|
| 434 |
+
->setIsTransactionClosed(1) // refund initiated by merchant
|
| 435 |
+
->setShouldCloseParentTransaction(!$canRefundMore)
|
| 436 |
+
;
|
| 437 |
+
$this->importPaymentInfo($api, $payment);
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* Parent transaction id getter
|
| 442 |
+
*
|
| 443 |
+
* @param Varien_Object $payment
|
| 444 |
+
* @return string
|
| 445 |
+
*/
|
| 446 |
+
protected function _getParentTransactionId(Varien_Object $payment)
|
| 447 |
+
{
|
| 448 |
+
return $payment->getParentTransactionId();
|
| 449 |
+
}
|
| 450 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Report/Settlement.php
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Settlement extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Default PayPal SFTP host
|
| 6 |
+
* @var string
|
| 7 |
+
*/
|
| 8 |
+
const REPORTS_HOSTNAME = "reports.paypal.com";
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Default PayPal SFTP host for sandbox mode
|
| 12 |
+
* @var string
|
| 13 |
+
*/
|
| 14 |
+
const SANDBOX_REPORTS_HOSTNAME = "reports.sandbox.paypal.com";
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* PayPal SFTP path
|
| 18 |
+
* @var string
|
| 19 |
+
*/
|
| 20 |
+
const REPORTS_PATH = "/ppreports/outgoing";
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Original charset of old report files
|
| 24 |
+
* @var string
|
| 25 |
+
*/
|
| 26 |
+
const FILES_IN_CHARSET = "UTF-16";
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Target charset of report files to be parsed
|
| 30 |
+
* @var string
|
| 31 |
+
*/
|
| 32 |
+
const FILES_OUT_CHARSET = "UTF-8";
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Reports rows storage
|
| 36 |
+
* @var array
|
| 37 |
+
*/
|
| 38 |
+
protected $_rows = array();
|
| 39 |
+
|
| 40 |
+
protected $_csvColumns = array(
|
| 41 |
+
'old' => array(
|
| 42 |
+
'section_columns' => array(
|
| 43 |
+
'' => 0,
|
| 44 |
+
'IDdeTransacción' => 1,
|
| 45 |
+
'IDdelafactura' => 2,
|
| 46 |
+
'IdentificacióndeReferenciaPayPal' => 3,
|
| 47 |
+
'TipodeIdentificacióndeReferencia PayPal' => 4,
|
| 48 |
+
'CódigodeEventodeTransacción' => 5,
|
| 49 |
+
'FechadeIniciodeTransacción' => 6,
|
| 50 |
+
'FechadeFinalizacióndeTransacción' => 7,
|
| 51 |
+
'TransacciónconTarjetadeDébitooCrédito' => 8,
|
| 52 |
+
'ImporteBrutodeTransacción' => 9,
|
| 53 |
+
'DivisadeTransacciónBruta' => 10,
|
| 54 |
+
'ComisióndeTarjetadeDébitooCrédito' => 11,
|
| 55 |
+
'ImportedelaComisión' => 12,
|
| 56 |
+
'ComisióndeDivisa' => 13,
|
| 57 |
+
'CampoPersonalizado' => 14,
|
| 58 |
+
'Identificacióndelconsumidor' => 15,
|
| 59 |
+
),
|
| 60 |
+
'rowmap' => array(
|
| 61 |
+
'IDdeTransacción' => 'transaction_id',
|
| 62 |
+
'IDdelafactura' => 'invoice_id',
|
| 63 |
+
'IdentificacióndeReferenciaPayPal' => 'paypal_reference_id',
|
| 64 |
+
'TipodeIdentificacióndeReferenciaPayPal' => 'paypal_reference_id_type',
|
| 65 |
+
'CódigodeEventodeTransacción' => 'transaction_event_code',
|
| 66 |
+
'FechadeIniciodeTransacción' => 'transaction_initiation_date',
|
| 67 |
+
'FechadeFinalizacióndeTransacción' => 'transaction_completion_date',
|
| 68 |
+
'TransacciónconTarjetadeDébitooCrédito' => 'transaction_debit_or_credit',
|
| 69 |
+
'ImporteBrutodeTransacción' => 'gross_transaction_amount',
|
| 70 |
+
'DivisadeTransacciónBruta' => 'gross_transaction_currency',
|
| 71 |
+
'ComisióndeTarjetadeDébitooCrédito' => 'fee_debit_or_credit',
|
| 72 |
+
'ImportedelaComisión' => 'fee_amount',
|
| 73 |
+
'ComisióndeDivisa' => 'fee_currency',
|
| 74 |
+
'CampoPersonalizado' => 'custom_field',
|
| 75 |
+
'Identificacióndelconsumidor' => 'consumer_id',
|
| 76 |
+
)
|
| 77 |
+
/*
|
| 78 |
+
'section_columns' => array(
|
| 79 |
+
'' => 0,
|
| 80 |
+
'TransactionID' => 1,
|
| 81 |
+
'InvoiceID' => 2,
|
| 82 |
+
'PayPalReferenceID' => 3,
|
| 83 |
+
'PayPalReferenceIDType' => 4,
|
| 84 |
+
'TransactionEventCode' => 5,
|
| 85 |
+
'TransactionInitiationDate' => 6,
|
| 86 |
+
'TransactionCompletionDate' => 7,
|
| 87 |
+
'TransactionDebitOrCredit' => 8,
|
| 88 |
+
'GrossTransactionAmount' => 9,
|
| 89 |
+
'GrossTransactionCurrency' => 10,
|
| 90 |
+
'FeeDebitOrCredit' => 11,
|
| 91 |
+
'FeeAmount' => 12,
|
| 92 |
+
'FeeCurrency' => 13,
|
| 93 |
+
'CustomField' => 14,
|
| 94 |
+
'ConsumerID' => 15
|
| 95 |
+
),
|
| 96 |
+
'rowmap' => array(
|
| 97 |
+
'TransactionID' => 'transaction_id',
|
| 98 |
+
'InvoiceID' => 'invoice_id',
|
| 99 |
+
'PayPalReferenceID' => 'paypal_reference_id',
|
| 100 |
+
'PayPalReferenceIDType' => 'paypal_reference_id_type',
|
| 101 |
+
'TransactionEventCode' => 'transaction_event_code',
|
| 102 |
+
'TransactionInitiationDate' => 'transaction_initiation_date',
|
| 103 |
+
'TransactionCompletionDate' => 'transaction_completion_date',
|
| 104 |
+
'TransactionDebitOrCredit' => 'transaction_debit_or_credit',
|
| 105 |
+
'GrossTransactionAmount' => 'gross_transaction_amount',
|
| 106 |
+
'GrossTransactionCurrency' => 'gross_transaction_currency',
|
| 107 |
+
'FeeDebitOrCredit' => 'fee_debit_or_credit',
|
| 108 |
+
'FeeAmount' => 'fee_amount',
|
| 109 |
+
'FeeCurrency' => 'fee_currency',
|
| 110 |
+
'CustomField' => 'custom_field',
|
| 111 |
+
'ConsumerID' => 'consumer_id'
|
| 112 |
+
)*/
|
| 113 |
+
),
|
| 114 |
+
'new' => array(
|
| 115 |
+
'section_columns' => array(
|
| 116 |
+
'' => 0,
|
| 117 |
+
'Identificación de transacción' => 1,
|
| 118 |
+
'Identificación de la factura' => 2,
|
| 119 |
+
'Identificación de referencia de PayPal' => 3,
|
| 120 |
+
'Tipo de Identificación de referencia PayPal' => 4,
|
| 121 |
+
'Código de evento de la transacción' => 5,
|
| 122 |
+
'Fecha de Inicio de Transacción' => 6,
|
| 123 |
+
'Fecha de Finalización de Transacción' => 7,
|
| 124 |
+
'Transacción con Tarjeta de Débitoo Crédito' => 8,
|
| 125 |
+
'Importe Bruto de Transacción' => 9,
|
| 126 |
+
'Divisa de Transacción Bruta' => 10,
|
| 127 |
+
'Comisión de Tarjeta de Débito o Crédito' => 11,
|
| 128 |
+
'Importe de la Comisión' => 12,
|
| 129 |
+
'Comisión de Divisa' => 13,
|
| 130 |
+
'Campo Personalizado' => 14,
|
| 131 |
+
'Identificación del consumidor' => 15,
|
| 132 |
+
'Identificación de seguimiento del pago' => 16
|
| 133 |
+
),/*
|
| 134 |
+
'section_columns' => array(
|
| 135 |
+
|
| 136 |
+
'' => 0,
|
| 137 |
+
'Transaction ID' => 1,
|
| 138 |
+
'Invoice ID' => 2,
|
| 139 |
+
'PayPal Reference ID' => 3,
|
| 140 |
+
'PayPal Reference ID Type' => 4,
|
| 141 |
+
'Transaction Event Code' => 5,
|
| 142 |
+
'Transaction Initiation Date' => 6,
|
| 143 |
+
'Transaction Completion Date' => 7,
|
| 144 |
+
'Transaction Debit or Credit' => 8,
|
| 145 |
+
'Gross Transaction Amount' => 9,
|
| 146 |
+
'Gross Transaction Currency' => 10,
|
| 147 |
+
'Fee Debit or Credit' => 11,
|
| 148 |
+
'Fee Amount' => 12,
|
| 149 |
+
'Fee Currency' => 13,
|
| 150 |
+
'Custom Field' => 14,
|
| 151 |
+
'Consumer ID' => 15,
|
| 152 |
+
'Payment Tracking ID' => 16
|
| 153 |
+
),/*
|
| 154 |
+
'rowmap' => array(
|
| 155 |
+
'Transaction ID' => 'transaction_id',
|
| 156 |
+
'Invoice ID' => 'invoice_id',
|
| 157 |
+
'PayPal Reference ID' => 'paypal_reference_id',
|
| 158 |
+
'PayPal Reference ID Type' => 'paypal_reference_id_type',
|
| 159 |
+
'Transaction Event Code' => 'transaction_event_code',
|
| 160 |
+
'Transaction Initiation Date' => 'transaction_initiation_date',
|
| 161 |
+
'Transaction Completion Date' => 'transaction_completion_date',
|
| 162 |
+
'Transaction Debit or Credit' => 'transaction_debit_or_credit',
|
| 163 |
+
'Gross Transaction Amount' => 'gross_transaction_amount',
|
| 164 |
+
'Gross Transaction Currency' => 'gross_transaction_currency',
|
| 165 |
+
'Fee Debit or Credit' => 'fee_debit_or_credit',
|
| 166 |
+
'Fee Amount' => 'fee_amount',
|
| 167 |
+
'Fee Currency' => 'fee_currency',
|
| 168 |
+
'Custom Field' => 'custom_field',
|
| 169 |
+
'Consumer ID' => 'consumer_id',
|
| 170 |
+
'Payment Tracking ID' => 'payment_tracking_id'
|
| 171 |
+
)*/
|
| 172 |
+
'rowmap' => array(
|
| 173 |
+
'Identificación de transacción' => 'transaction_id',
|
| 174 |
+
'Identificación de recibo PayPal' => 'invoice_id',
|
| 175 |
+
'Identificación de referencia de PayPal' => 'paypal_reference_id',
|
| 176 |
+
'Tipo de Identificación de referencia de PayPal' => 'paypal_reference_id_type',
|
| 177 |
+
'Código de evento de la transacción' => 'transaction_event_code',
|
| 178 |
+
'Fecha de inicio de la transacción' => 'transaction_initiation_date',
|
| 179 |
+
'Fecha de finalización de la transacción' => 'transaction_completion_date',
|
| 180 |
+
'Transacción con tarjeta de débito o crédito' => 'transaction_debit_or_credit',
|
| 181 |
+
'Importe bruto de la transacción' => 'gross_transaction_amount',
|
| 182 |
+
'Divisa de la transacción bruta' => 'gross_transaction_currency',
|
| 183 |
+
'Comisión de la tarjeta de débito o crédito' => 'fee_debit_or_credit',
|
| 184 |
+
'Importe de la comisión' => 'fee_amount',
|
| 185 |
+
'Divisa de comisión' => 'fee_currency',
|
| 186 |
+
'Campo personalizado' => 'custom_field',
|
| 187 |
+
'Identificación del consumidor' => 'consumer_id',
|
| 188 |
+
'Identificación de seguimiento del pago' => 'payment_tracking_id'
|
| 189 |
+
)
|
| 190 |
+
)
|
| 191 |
+
);
|
| 192 |
+
/**
|
| 193 |
+
* Initialize resource model
|
| 194 |
+
*/
|
| 195 |
+
protected function _construct()
|
| 196 |
+
{
|
| 197 |
+
$this->_init('paypalmx/report_settlement');
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Stop saving process if file with same report date, account ID and last modified date was already ferched
|
| 202 |
+
*
|
| 203 |
+
* @return Mage_Core_Model_Abstract
|
| 204 |
+
*/
|
| 205 |
+
protected function _beforeSave()
|
| 206 |
+
{
|
| 207 |
+
$this->_dataSaveAllowed = true;
|
| 208 |
+
if ($this->getId()) {
|
| 209 |
+
if ($this->getLastModified() == $this->getReportLastModified()) {
|
| 210 |
+
$this->_dataSaveAllowed = false;
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
$this->setLastModified($this->getReportLastModified());
|
| 214 |
+
return parent::_beforeSave();
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Goes to specified host/path and fetches reports from there.
|
| 219 |
+
* Save reports to database.
|
| 220 |
+
*
|
| 221 |
+
* @param array $config SFTP credentials
|
| 222 |
+
* @return int Number of report rows that were fetched and saved successfully
|
| 223 |
+
*/
|
| 224 |
+
public function fetchAndSave($config)
|
| 225 |
+
{
|
| 226 |
+
$connection = new Varien_Io_Sftp();
|
| 227 |
+
$connection->open(array(
|
| 228 |
+
'host' => $config['hostname'],
|
| 229 |
+
'username' => $config['username'],
|
| 230 |
+
'password' => $config['password']
|
| 231 |
+
));
|
| 232 |
+
$connection->cd($config['path']);
|
| 233 |
+
$fetched = 0;
|
| 234 |
+
$listing = $this->_filterReportsList($connection->rawls());
|
| 235 |
+
foreach ($listing as $filename => $attributes) {
|
| 236 |
+
$localCsv = tempnam(Mage::getConfig()->getOptions()->getTmpDir(), 'PayPal_STL');
|
| 237 |
+
if ($connection->read($filename, $localCsv)) {
|
| 238 |
+
if (!is_writable($localCsv)) {
|
| 239 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Cannot create target file for reading reports.'));
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
$encoded = file_get_contents($localCsv);
|
| 243 |
+
$csvFormat = 'new';
|
| 244 |
+
if (self::FILES_OUT_CHARSET != mb_detect_encoding(($encoded))) {
|
| 245 |
+
$decoded = @iconv(self::FILES_IN_CHARSET, self::FILES_OUT_CHARSET.'//IGNORE', $encoded);
|
| 246 |
+
file_put_contents($localCsv, $decoded);
|
| 247 |
+
$csvFormat = 'old';
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
// Set last modified date, this value will be overwritten during parsing
|
| 251 |
+
if (isset($attributes['mtime'])) {
|
| 252 |
+
$lastModified = new Zend_Date($attributes['mtime']);
|
| 253 |
+
$this->setReportLastModified($lastModified->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
$this->setReportDate($this->_fileNameToDate($filename))
|
| 257 |
+
->setFilename($filename)
|
| 258 |
+
->parseCsv($localCsv, $csvFormat);
|
| 259 |
+
|
| 260 |
+
if ($this->getAccountId()) {
|
| 261 |
+
$this->save();
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
if ($this->_dataSaveAllowed) {
|
| 265 |
+
$fetched += count($this->_rows);
|
| 266 |
+
}
|
| 267 |
+
// clean object and remove parsed file
|
| 268 |
+
$this->unsetData();
|
| 269 |
+
unlink($localCsv);
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
return $fetched;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Parse CSV file and collect report rows
|
| 277 |
+
*
|
| 278 |
+
* @param string $localCsv Path to CSV file
|
| 279 |
+
* @param string $format CSV format(column names)
|
| 280 |
+
* @return Mage_Paypal_Model_Report_Settlement
|
| 281 |
+
*/
|
| 282 |
+
public function parseCsv($localCsv, $format = 'new')
|
| 283 |
+
{
|
| 284 |
+
$this->_rows = array();
|
| 285 |
+
|
| 286 |
+
$sectionColumns = $this->_csvColumns[$format]['section_columns'];
|
| 287 |
+
$rowMap = $this->_csvColumns[$format]['rowmap'];
|
| 288 |
+
|
| 289 |
+
$flippedSectionColumns = array_flip($sectionColumns);
|
| 290 |
+
$fp = fopen($localCsv, 'r');
|
| 291 |
+
while($line = fgetcsv($fp)) {
|
| 292 |
+
if (empty($line)) { // The line was empty, so skip it.
|
| 293 |
+
continue;
|
| 294 |
+
}
|
| 295 |
+
$lineType = $line[0];
|
| 296 |
+
switch($lineType) {
|
| 297 |
+
case 'RH': // Report header.
|
| 298 |
+
$lastModified = new Zend_Date($line[1]);
|
| 299 |
+
$this->setReportLastModified($lastModified->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
| 300 |
+
//$this->setAccountId($columns[2]); -- probably we'll just take that from the section header...
|
| 301 |
+
break;
|
| 302 |
+
case 'FH': // File header.
|
| 303 |
+
// Nothing interesting here, move along
|
| 304 |
+
break;
|
| 305 |
+
case 'SH': // Section header.
|
| 306 |
+
$this->setAccountId($line[3]);
|
| 307 |
+
$this->loadByAccountAndDate();
|
| 308 |
+
break;
|
| 309 |
+
case 'CH': // Section columns.
|
| 310 |
+
// In case ever the column order is changed, we will have the items recorded properly
|
| 311 |
+
// anyway. We have named, not numbered columns.
|
| 312 |
+
for ($i = 1; $i < count($line); $i++) {
|
| 313 |
+
$sectionColumns[$line[$i]] = $i;
|
| 314 |
+
}
|
| 315 |
+
$flippedSectionColumns = array_flip($sectionColumns);
|
| 316 |
+
break;
|
| 317 |
+
case 'SB': // Section body.
|
| 318 |
+
$bodyItem = array();
|
| 319 |
+
for($i = 1; $i < count($line); $i++) {
|
| 320 |
+
$bodyItem[$rowMap[$flippedSectionColumns[$i]]] = $line[$i];
|
| 321 |
+
|
| 322 |
+
}
|
| 323 |
+
$this->_rows[] = $bodyItem;
|
| 324 |
+
break;
|
| 325 |
+
case 'SC': // Section records count.
|
| 326 |
+
case 'RC': // Report records count.
|
| 327 |
+
case 'SF': // Section footer.
|
| 328 |
+
case 'FF': // File footer.
|
| 329 |
+
case 'RF': // Report footer.
|
| 330 |
+
// Nothing to see here, move along
|
| 331 |
+
break;
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
return $this;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
/**
|
| 338 |
+
* Load report by unique key (accoutn + report date)
|
| 339 |
+
*
|
| 340 |
+
* @return Mage_Paypal_Model_Report_Settlement
|
| 341 |
+
*/
|
| 342 |
+
public function loadByAccountAndDate()
|
| 343 |
+
{
|
| 344 |
+
$this->getResource()->loadByAccountAndDate($this, $this->getAccountId(), $this->getReportDate());
|
| 345 |
+
return $this;
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
/**
|
| 349 |
+
* Return collected rows for further processing.
|
| 350 |
+
*
|
| 351 |
+
* @return array
|
| 352 |
+
*/
|
| 353 |
+
public function getRows()
|
| 354 |
+
{
|
| 355 |
+
return $this->_rows;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Return name for row column
|
| 360 |
+
*
|
| 361 |
+
* @param string $field Field name in row model
|
| 362 |
+
* @return string
|
| 363 |
+
*/
|
| 364 |
+
public function getFieldLabel($field)
|
| 365 |
+
{
|
| 366 |
+
switch ($field) {
|
| 367 |
+
case 'report_date':
|
| 368 |
+
return Mage::helper('paypalmx')->__('Fecha de reporte');
|
| 369 |
+
case 'account_id':
|
| 370 |
+
return Mage::helper('paypalmx')->__('Cuenta del comerciante');
|
| 371 |
+
case 'transaction_id':
|
| 372 |
+
return Mage::helper('paypalmx')->__('ID de transacción');
|
| 373 |
+
case 'invoice_id':
|
| 374 |
+
return Mage::helper('paypalmx')->__('ID de factura');
|
| 375 |
+
case 'paypal_reference_id':
|
| 376 |
+
return Mage::helper('paypalmx')->__('ID de referencia para PayPal');
|
| 377 |
+
case 'paypal_reference_id_type':
|
| 378 |
+
return Mage::helper('paypalmx')->__('Referencia al tipo de ID de PayPal');
|
| 379 |
+
case 'transaction_event_code':
|
| 380 |
+
return Mage::helper('paypalmx')->__('Codigo de evento');
|
| 381 |
+
case 'transaction_event':
|
| 382 |
+
return Mage::helper('paypalmx')->__('Evento');
|
| 383 |
+
case 'transaction_initiation_date':
|
| 384 |
+
return Mage::helper('paypalmx')->__('Fecha de incio');
|
| 385 |
+
case 'transaction_completion_date':
|
| 386 |
+
return Mage::helper('paypalmx')->__('Fecha de termino');
|
| 387 |
+
case 'transaction_debit_or_credit':
|
| 388 |
+
return Mage::helper('paypalmx')->__('Débito o Crédito');
|
| 389 |
+
case 'gross_transaction_amount':
|
| 390 |
+
return Mage::helper('paypalmx')->__('Monto bruto');
|
| 391 |
+
/*case 'fee_debit_or_credit':
|
| 392 |
+
return Mage::helper('paypalmx')->__('Cuota por Débito o Crédito');*/
|
| 393 |
+
case 'fee_amount':
|
| 394 |
+
return Mage::helper('paypalmx')->__('Monto de cuota');
|
| 395 |
+
case 'custom_field':
|
| 396 |
+
return Mage::helper('paypalmx')->__('Personalizado');
|
| 397 |
+
default:
|
| 398 |
+
return $field;
|
| 399 |
+
}
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
* Iterate through website configurations and collect all SFTP configurations
|
| 404 |
+
* Filter config values if necessary
|
| 405 |
+
*
|
| 406 |
+
* @param bool $automaticMode Whether to skip settings with disabled Automatic Fetching or not
|
| 407 |
+
* @return array
|
| 408 |
+
*/
|
| 409 |
+
public function getSftpCredentials($automaticMode = false)
|
| 410 |
+
{
|
| 411 |
+
$configs = array();
|
| 412 |
+
$uniques = array();
|
| 413 |
+
foreach(Mage::app()->getStores() as $store) {
|
| 414 |
+
/*@var $store Mage_Core_Model_Store */
|
| 415 |
+
$active = (bool)$store->getConfig('paypalmx/fetch_reports/active');
|
| 416 |
+
if (!$active && $automaticMode) {
|
| 417 |
+
continue;
|
| 418 |
+
}
|
| 419 |
+
$cfg = array(
|
| 420 |
+
'hostname' => $store->getConfig('paypalmx/fetch_reports/ftp_ip'),
|
| 421 |
+
'path' => $store->getConfig('paypalmx/fetch_reports/ftp_path'),
|
| 422 |
+
'username' => $store->getConfig('paypalmx/fetch_reports/ftp_login'),
|
| 423 |
+
'password' => $store->getConfig('paypalmx/fetch_reports/ftp_password'),
|
| 424 |
+
'sandbox' => $store->getConfig('paypalmx/fetch_reports/ftp_sandbox'),
|
| 425 |
+
);
|
| 426 |
+
if (empty($cfg['username']) || empty($cfg['password'])) {
|
| 427 |
+
continue;
|
| 428 |
+
}
|
| 429 |
+
if (empty($cfg['hostname']) || $cfg['sandbox']) {
|
| 430 |
+
$cfg['hostname'] = $cfg['sandbox'] ? self::SANDBOX_REPORTS_HOSTNAME : self::REPORTS_HOSTNAME;
|
| 431 |
+
}
|
| 432 |
+
if (empty($cfg['path']) || $cfg['sandbox']) {
|
| 433 |
+
$cfg['path'] = self::REPORTS_PATH;
|
| 434 |
+
}
|
| 435 |
+
// avoid duplicates
|
| 436 |
+
if (in_array(serialize($cfg), $uniques)) {
|
| 437 |
+
continue;
|
| 438 |
+
}
|
| 439 |
+
$uniques[] = serialize($cfg);
|
| 440 |
+
$configs[] = $cfg;
|
| 441 |
+
}
|
| 442 |
+
return $configs;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* Converts a filename to date of report.
|
| 447 |
+
*
|
| 448 |
+
* @param string $filename
|
| 449 |
+
* @return string
|
| 450 |
+
*/
|
| 451 |
+
protected function _fileNameToDate($filename)
|
| 452 |
+
{
|
| 453 |
+
// Currently filenames look like STL-YYYYMMDD, so that is what we care about.
|
| 454 |
+
$dateSnippet = substr(basename($filename), 4, 8);
|
| 455 |
+
$result = substr($dateSnippet, 0, 4).'-'.substr($dateSnippet, 4, 2).'-'.substr($dateSnippet, 6, 2);
|
| 456 |
+
return $result;
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
/**
|
| 460 |
+
* Filter SFTP file list by filename format
|
| 461 |
+
*
|
| 462 |
+
* @param array $list List of files as per $connection->rawls()
|
| 463 |
+
* @return array Trimmed down list of files
|
| 464 |
+
*/
|
| 465 |
+
protected function _filterReportsList($list)
|
| 466 |
+
{
|
| 467 |
+
$result = array();
|
| 468 |
+
$pattern = '/^STL-(\d{8,8})\.(\d{2,2})\.(.{3,3})\.CSV$/';
|
| 469 |
+
foreach ($list as $filename => $data) {
|
| 470 |
+
if (preg_match($pattern, $filename)) {
|
| 471 |
+
$result[$filename] = $data;
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
return $result;
|
| 475 |
+
}
|
| 476 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Report/Settlement/Row.php
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Report_Settlement_Row extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Assoc array event code => label
|
| 6 |
+
*
|
| 7 |
+
* @var array
|
| 8 |
+
*/
|
| 9 |
+
protected static $_eventList = array();
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Casted amount keys registry
|
| 13 |
+
*
|
| 14 |
+
* @var array
|
| 15 |
+
*/
|
| 16 |
+
protected $_castedAmounts = array();
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Initialize resource model
|
| 20 |
+
*/
|
| 21 |
+
protected function _construct()
|
| 22 |
+
{
|
| 23 |
+
$this->_init('paypal/report_settlement_row');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Return description of Reference ID Type
|
| 28 |
+
* If no code specified, return full list of codes with their description
|
| 29 |
+
*
|
| 30 |
+
* @param string code
|
| 31 |
+
* @return string|array
|
| 32 |
+
*/
|
| 33 |
+
public function getReferenceType($code = null)
|
| 34 |
+
{
|
| 35 |
+
$types = array(
|
| 36 |
+
'TXN' => Mage::helper('paypalmx')->__('Transaction ID'),
|
| 37 |
+
'ODR' => Mage::helper('paypalmx')->__('Order ID'),
|
| 38 |
+
'SUB' => Mage::helper('paypalmx')->__('Subscription ID'),
|
| 39 |
+
'PAP' => Mage::helper('paypalmx')->__('Preapproved Payment ID')
|
| 40 |
+
);
|
| 41 |
+
if($code === null) {
|
| 42 |
+
asort($types);
|
| 43 |
+
return $types;
|
| 44 |
+
}
|
| 45 |
+
if (isset($types[$code])) {
|
| 46 |
+
return $types[$code];
|
| 47 |
+
}
|
| 48 |
+
return $code;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Get native description for transaction code
|
| 53 |
+
*
|
| 54 |
+
* @param string code
|
| 55 |
+
* @return string
|
| 56 |
+
*/
|
| 57 |
+
public function getTransactionEvent($code)
|
| 58 |
+
{
|
| 59 |
+
$this->_generateEventLabels();
|
| 60 |
+
if (isset(self::$_eventList[$code])) {
|
| 61 |
+
return self::$_eventList[$code];
|
| 62 |
+
}
|
| 63 |
+
return $code;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Get full list of codes with their description
|
| 68 |
+
*
|
| 69 |
+
* @return &array
|
| 70 |
+
*/
|
| 71 |
+
public function &getTransactionEvents()
|
| 72 |
+
{
|
| 73 |
+
$this->_generateEventLabels();
|
| 74 |
+
return self::$_eventList;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Return description of "Debit or Credit" value
|
| 79 |
+
* If no code specified, return full list of codes with their description
|
| 80 |
+
*
|
| 81 |
+
* @param string code
|
| 82 |
+
* @return string|array
|
| 83 |
+
*/
|
| 84 |
+
public function getDebitCreditText($code = null)
|
| 85 |
+
{
|
| 86 |
+
$options = array(
|
| 87 |
+
'CR' => Mage::helper('paypalmx')->__('Credit'),
|
| 88 |
+
'DR' => Mage::helper('paypalmx')->__('Debit'),
|
| 89 |
+
);
|
| 90 |
+
if($code === null) {
|
| 91 |
+
return $options;
|
| 92 |
+
}
|
| 93 |
+
if (isset($options[$code])) {
|
| 94 |
+
return $options[$code];
|
| 95 |
+
}
|
| 96 |
+
return $code;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Invoke casting some amounts
|
| 101 |
+
*
|
| 102 |
+
* @param mixed $key
|
| 103 |
+
* @param mixed $index
|
| 104 |
+
* @return mixed
|
| 105 |
+
*/
|
| 106 |
+
public function getData($key = '', $index = null)
|
| 107 |
+
{
|
| 108 |
+
$this->_castAmount('fee_amount', 'fee_debit_or_credit');
|
| 109 |
+
$this->_castAmount('gross_transaction_amount', 'transaction_debit_or_credit');
|
| 110 |
+
return parent::getData($key, $index);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Cast amounts of the specified keys
|
| 115 |
+
*
|
| 116 |
+
* PayPal settlement reports contain amounts in cents, hence the values need to be divided by 100
|
| 117 |
+
* Also if the "credit" value is detected, it will be casted to negative amount
|
| 118 |
+
*
|
| 119 |
+
* @param string $key
|
| 120 |
+
* @param string $creditKey
|
| 121 |
+
*/
|
| 122 |
+
public function _castAmount($key, $creditKey)
|
| 123 |
+
{
|
| 124 |
+
if (isset($this->_castedAmounts[$key]) || !isset($this->_data[$key]) || !isset($this->_data[$creditKey])) {
|
| 125 |
+
return;
|
| 126 |
+
}
|
| 127 |
+
if (empty($this->_data[$key])) {
|
| 128 |
+
return;
|
| 129 |
+
}
|
| 130 |
+
$amount = $this->_data[$key] / 100;
|
| 131 |
+
if ('CR' === $this->_data[$creditKey]) {
|
| 132 |
+
$amount = -1 * $amount;
|
| 133 |
+
}
|
| 134 |
+
$this->_data[$key] = $amount;
|
| 135 |
+
$this->_castedAmounts[$key] = true;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Fill/translate and sort all event codes/labels
|
| 140 |
+
*/
|
| 141 |
+
protected function _generateEventLabels()
|
| 142 |
+
{
|
| 143 |
+
if (!self::$_eventList) {
|
| 144 |
+
self::$_eventList = array(
|
| 145 |
+
'T0000' => Mage::helper('paypalmx')->__('General: Recibir pagos de de tipo no perteneciente a la categoria T00xx'),
|
| 146 |
+
'T0001' => Mage::helper('paypalmx')->__('Pagos masivos'),
|
| 147 |
+
'T0002' => Mage::helper('paypalmx')->__('Pagos subscritos, tambien pagos enviados y recibidos'),
|
| 148 |
+
'T0003' => Mage::helper('paypalmx')->__('Pagos previamente aprovados (BillUser API), ya sean enviados o recividos'),
|
| 149 |
+
'T0004' => Mage::helper('paypalmx')->__('eBay Auction Payment'),
|
| 150 |
+
'T0005' => Mage::helper('paypalmx')->__('Pagos Directos del API'),
|
| 151 |
+
'T0006' => Mage::helper('paypalmx')->__('Express Checkout APIs'),
|
| 152 |
+
'T0007' => Mage::helper('paypalmx')->__('Pagos regulares de la tienda'),
|
| 153 |
+
'T0008' => Mage::helper('paypalmx')->__('Pagos de envio ya sea USPS o UPS'),
|
| 154 |
+
'T0009' => Mage::helper('paypalmx')->__('Pagos de certificados de regalo: compra de un certificado de regalo'),
|
| 155 |
+
'T0010' => Mage::helper('paypalmx')->__('Auction Payment other than through eBay'),
|
| 156 |
+
'T0011' => Mage::helper('paypalmx')->__('Pago echos desde un telefono (echos por via telefonica)'),
|
| 157 |
+
'T0012' => Mage::helper('paypalmx')->__('Pagos por terminal virtual'),
|
| 158 |
+
'T0100' => Mage::helper('paypalmx')->__('General: sin cuota de pago, no perteneciente a la categoria T01xx'),
|
| 159 |
+
'T0101' => Mage::helper('paypalmx')->__('Cuota: Web Site Payments Pro Account Monthly'),
|
| 160 |
+
'T0102' => Mage::helper('paypalmx')->__('Cuota: Retiro foraneo de ACH'),
|
| 161 |
+
'T0103' => Mage::helper('paypalmx')->__('Cuota: Retiro de WorldLink Check'),
|
| 162 |
+
'T0104' => Mage::helper('paypalmx')->__('Cuota: solicitud de pagos masivos'),
|
| 163 |
+
'T0200' => Mage::helper('paypalmx')->__('General de conversion de moneda'),
|
| 164 |
+
'T0201' => Mage::helper('paypalmx')->__('Conversion de moneda usado por el usuario'),
|
| 165 |
+
'T0202' => Mage::helper('paypalmx')->__('Conversion de moneda requerido para cubrir el balance negativo'),
|
| 166 |
+
'T0300' => Mage::helper('paypalmx')->__('Fundacion general de la cuenta PayPal'),
|
| 167 |
+
'T0301' => Mage::helper('paypalmx')->__('Ayudante del balance PayPal funcion de la cuenta PayPal'),
|
| 168 |
+
'T0302' => Mage::helper('paypalmx')->__('ACH Fundacion para recuperacion de fondos del balance de la cuenta.'),
|
| 169 |
+
'T0303' => Mage::helper('paypalmx')->__('Fundacion EFT (Banco aleman)'),
|
| 170 |
+
'T0400' => Mage::helper('paypalmx')->__('Retiro general de la cuenta de Paypal'),
|
| 171 |
+
'T0401' => Mage::helper('paypalmx')->__('Limpiado Automático'),
|
| 172 |
+
'T0500' => Mage::helper('paypalmx')->__('General: Uso de la cuenta Paypal para comprar asi como para recibir pagos'),
|
| 173 |
+
'T0501' => Mage::helper('paypalmx')->__('Transaccion de Paypal tarjeto de debito virtual'),
|
| 174 |
+
'T0502' => Mage::helper('paypalmx')->__('Retiros de la tarjeta de debito PayPal del cajero automatico'),
|
| 175 |
+
'T0503' => Mage::helper('paypalmx')->__('Tranascciones escodndidas de la tarjeta de debito Virtual de PayPal'),
|
| 176 |
+
'T0504' => Mage::helper('paypalmx')->__('Avanzado Tarjeta de debito de PayPal'),
|
| 177 |
+
'T0600' => Mage::helper('paypalmx')->__('General: retiro de la cuenta de PayPalt'),
|
| 178 |
+
'T0700' => Mage::helper('paypalmx')->__('General (Compras con una tarjeta de credito)'),
|
| 179 |
+
'T0701' => Mage::helper('paypalmx')->__('Balance Negativo'),
|
| 180 |
+
'T0800' => Mage::helper('paypalmx')->__('General: bonus del tipo no perteneciente a las otras T08xx categories'),
|
| 181 |
+
'T0801' => Mage::helper('paypalmx')->__('Tarjeta de debito regreso de dinero'),
|
| 182 |
+
'T0802' => Mage::helper('paypalmx')->__('Bonus a referencias del comerciante'),
|
| 183 |
+
'T0803' => Mage::helper('paypalmx')->__('Bonus del ayudante'),
|
| 184 |
+
'T0804' => Mage::helper('paypalmx')->__('Bonus del seguro al comprador PayPal'),
|
| 185 |
+
'T0805' => Mage::helper('paypalmx')->__('Bonus de proteccion de PayPal'),
|
| 186 |
+
'T0806' => Mage::helper('paypalmx')->__('Bonus por primer uso de ACH'),
|
| 187 |
+
'T0900' => Mage::helper('paypalmx')->__('Redención General'),
|
| 188 |
+
'T0901' => Mage::helper('paypalmx')->__('Certificado de regalo de Redención'),
|
| 189 |
+
'T0902' => Mage::helper('paypalmx')->__('Points Incentive Redemption'),
|
| 190 |
+
'T0903' => Mage::helper('paypalmx')->__('Cupon de Redención'),
|
| 191 |
+
'T0904' => Mage::helper('paypalmx')->__('Reward Voucher Redemption'),
|
| 192 |
+
'T1000' => Mage::helper('paypalmx')->__('General. Product no longer supported'),
|
| 193 |
+
'T1100' => Mage::helper('paypalmx')->__('General: reversal of a type not belonging to the other T11xx categories'),
|
| 194 |
+
'T1101' => Mage::helper('paypalmx')->__('ACH Withdrawal'),
|
| 195 |
+
'T1102' => Mage::helper('paypalmx')->__('Debit Card Transaction'),
|
| 196 |
+
'T1103' => Mage::helper('paypalmx')->__('Reversal of Points Usage'),
|
| 197 |
+
'T1104' => Mage::helper('paypalmx')->__('ACH Deposit (Reversal)'),
|
| 198 |
+
'T1105' => Mage::helper('paypalmx')->__('Reversal of General Account Hold'),
|
| 199 |
+
'T1106' => Mage::helper('paypalmx')->__('Account-to-Account Payment, initiated by PayPal'),
|
| 200 |
+
'T1107' => Mage::helper('paypalmx')->__('Payment Refund initiated by merchant'),
|
| 201 |
+
'T1108' => Mage::helper('paypalmx')->__('Fee Reversal'),
|
| 202 |
+
'T1110' => Mage::helper('paypalmx')->__('Hold for Dispute Investigation'),
|
| 203 |
+
'T1111' => Mage::helper('paypalmx')->__('Reversal of hold for Dispute Investigation'),
|
| 204 |
+
'T1200' => Mage::helper('paypalmx')->__('General: adjustment of a type not belonging to the other T12xx categories'),
|
| 205 |
+
'T1201' => Mage::helper('paypalmx')->__('Chargeback'),
|
| 206 |
+
'T1202' => Mage::helper('paypalmx')->__('Reversal'),
|
| 207 |
+
'T1203' => Mage::helper('paypalmx')->__('Charge-off'),
|
| 208 |
+
'T1204' => Mage::helper('paypalmx')->__('Incentive'),
|
| 209 |
+
'T1205' => Mage::helper('paypalmx')->__('Reimbursement of Chargeback'),
|
| 210 |
+
'T1300' => Mage::helper('paypalmx')->__('General (Authorization)'),
|
| 211 |
+
'T1301' => Mage::helper('paypalmx')->__('Reauthorization'),
|
| 212 |
+
'T1302' => Mage::helper('paypalmx')->__('Void'),
|
| 213 |
+
'T1400' => Mage::helper('paypalmx')->__('General (Dividend)'),
|
| 214 |
+
'T1500' => Mage::helper('paypalmx')->__('General: temporary hold of a type not belonging to the other T15xx categories'),
|
| 215 |
+
'T1501' => Mage::helper('paypalmx')->__('Open Authorization'),
|
| 216 |
+
'T1502' => Mage::helper('paypalmx')->__('ACH Deposit (Hold for Dispute or Other Investigation)'),
|
| 217 |
+
'T1503' => Mage::helper('paypalmx')->__('Available Balance'),
|
| 218 |
+
'T1600' => Mage::helper('paypalmx')->__('Funding'),
|
| 219 |
+
'T1700' => Mage::helper('paypalmx')->__('General: Withdrawal to Non-Bank Entity'),
|
| 220 |
+
'T1701' => Mage::helper('paypalmx')->__('WorldLink Withdrawal'),
|
| 221 |
+
'T1800' => Mage::helper('paypalmx')->__('Buyer Credit Payment'),
|
| 222 |
+
'T1900' => Mage::helper('paypalmx')->__('General Adjustment without businessrelated event'),
|
| 223 |
+
'T2000' => Mage::helper('paypalmx')->__('General (Funds Transfer from PayPal Account to Another)'),
|
| 224 |
+
'T2001' => Mage::helper('paypalmx')->__('Settlement Consolidation'),
|
| 225 |
+
'T9900' => Mage::helper('paypalmx')->__('General: event not yet categorized'),
|
| 226 |
+
);
|
| 227 |
+
asort(self::$_eventList);
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Cert.php
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* PayPal resource model for certificate based authentication
|
| 30 |
+
*
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Model_Resource_Cert extends Mage_Core_Model_Resource_Db_Abstract
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Initialize connection
|
| 39 |
+
*/
|
| 40 |
+
protected function _construct()
|
| 41 |
+
{
|
| 42 |
+
$this->_init('paypal/cert', 'cert_id');
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Set date of last update
|
| 47 |
+
*
|
| 48 |
+
* @param Mage_Core_Model_Abstract $object
|
| 49 |
+
* @return Mage_Core_Model_Resource_Db_Abstract
|
| 50 |
+
*/
|
| 51 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object)
|
| 52 |
+
{
|
| 53 |
+
$object->setUpdatedAt($this->formatDate(Mage::getSingleton('core/date')->gmtDate()));
|
| 54 |
+
return parent::_beforeSave($object);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Load model by website id
|
| 59 |
+
*
|
| 60 |
+
* @param Mage_Paypal_Model_Cert $object
|
| 61 |
+
* @param bool $strictLoad
|
| 62 |
+
* @return Mage_Paypal_Model_Cert
|
| 63 |
+
*/
|
| 64 |
+
public function loadByWebsite($object, $strictLoad = true)
|
| 65 |
+
{
|
| 66 |
+
$adapter = $this->_getReadAdapter();
|
| 67 |
+
$select = $adapter->select()->from(array('main_table' => $this->getMainTable()));
|
| 68 |
+
|
| 69 |
+
if ($strictLoad) {
|
| 70 |
+
$select->where('main_table.website_id =?', $object->getWebsiteId());
|
| 71 |
+
} else {
|
| 72 |
+
$select->where('main_table.website_id IN(0, ?)', $object->getWebsiteId())
|
| 73 |
+
->order('main_table.website_id DESC')
|
| 74 |
+
->limit(1);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
$data = $adapter->fetchRow($select);
|
| 78 |
+
if ($data) {
|
| 79 |
+
$object->setData($data);
|
| 80 |
+
}
|
| 81 |
+
return $object;
|
| 82 |
+
}
|
| 83 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Payment/Transaction.php
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal transaction resource model
|
| 29 |
+
*
|
| 30 |
+
* @deprecated since 1.6.2.0
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Model_Resource_Payment_Transaction extends Mage_Core_Model_Resource_Db_Abstract
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Serializeable field: additional_information
|
| 39 |
+
*
|
| 40 |
+
* @var array
|
| 41 |
+
*/
|
| 42 |
+
protected $_serializableFields = array(
|
| 43 |
+
'additional_information' => array(null, array())
|
| 44 |
+
);
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Initialize main table and the primary key field name
|
| 48 |
+
*
|
| 49 |
+
*/
|
| 50 |
+
protected function _construct()
|
| 51 |
+
{
|
| 52 |
+
$this->_init('paypal/payment_transaction', 'transaction_id');
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Load the transaction object by specified txn_id
|
| 57 |
+
*
|
| 58 |
+
* @param Mage_Paypal_Model_Payment_Transaction $transaction
|
| 59 |
+
* @param string $txnId
|
| 60 |
+
*/
|
| 61 |
+
public function loadObjectByTxnId(Mage_Paypal_Model_Payment_Transaction $transaction, $txnId)
|
| 62 |
+
{
|
| 63 |
+
$select = $this->_getLoadByUniqueKeySelect($txnId);
|
| 64 |
+
$data = $this->_getWriteAdapter()->fetchRow($select);
|
| 65 |
+
$transaction->setData($data);
|
| 66 |
+
$this->unserializeFields($transaction);
|
| 67 |
+
$this->_afterLoad($transaction);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Serialize additional information, if any
|
| 72 |
+
*
|
| 73 |
+
* @throws Mage_Core_Exception
|
| 74 |
+
*
|
| 75 |
+
* @param Mage_Core_Model_Abstract $transaction
|
| 76 |
+
* @return Mage_Paypal_Model_Resource_Payment_Transaction
|
| 77 |
+
*/
|
| 78 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $transaction)
|
| 79 |
+
{
|
| 80 |
+
$txnId = $transaction->getData('txn_id');
|
| 81 |
+
$idFieldName = $this->getIdFieldName();
|
| 82 |
+
|
| 83 |
+
// make sure unique key won't cause trouble
|
| 84 |
+
if ($transaction->isFailsafe()) {
|
| 85 |
+
$autoincrementId = (int)$this->_lookupByTxnId($txnId, $idFieldName);
|
| 86 |
+
if ($autoincrementId) {
|
| 87 |
+
$transaction->setData($idFieldName, $autoincrementId)->isObjectNew(false);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
return parent::_beforeSave($transaction);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Load cell/row by specified unique key parts
|
| 96 |
+
*
|
| 97 |
+
* @param string $txnId
|
| 98 |
+
* @param mixed (array|string|object) $columns
|
| 99 |
+
* @param bool $isRow
|
| 100 |
+
* @return mixed (array|string)
|
| 101 |
+
*/
|
| 102 |
+
private function _lookupByTxnId($txnId, $columns, $isRow = false)
|
| 103 |
+
{
|
| 104 |
+
$select = $this->_getLoadByUniqueKeySelect($txnId, $columns);
|
| 105 |
+
if ($isRow) {
|
| 106 |
+
return $this->_getWriteAdapter()->fetchRow($select);
|
| 107 |
+
}
|
| 108 |
+
return $this->_getWriteAdapter()->fetchOne($select);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* Get select object for loading transaction by the unique key of order_id, payment_id, txn_id
|
| 113 |
+
*
|
| 114 |
+
* @param string $txnId
|
| 115 |
+
* @param string|array|Zend_Db_Expr $columns
|
| 116 |
+
* @return Varien_Db_Select
|
| 117 |
+
*/
|
| 118 |
+
private function _getLoadByUniqueKeySelect($txnId, $columns = '*')
|
| 119 |
+
{
|
| 120 |
+
return $this->_getWriteAdapter()->select()
|
| 121 |
+
->from($this->getMainTable(), $columns)
|
| 122 |
+
->where('txn_id = ?', $txnId);
|
| 123 |
+
}
|
| 124 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Payment/Transaction/Collection.php
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Payment transactions collection
|
| 29 |
+
*
|
| 30 |
+
* @deprecated since 1.6.2.0
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Model_Resource_Payment_Transaction_Collection
|
| 36 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
| 37 |
+
{
|
| 38 |
+
/**
|
| 39 |
+
* Created Before filter
|
| 40 |
+
*
|
| 41 |
+
* @var string
|
| 42 |
+
*/
|
| 43 |
+
protected $_createdBefore = "";
|
| 44 |
+
/**
|
| 45 |
+
* Initialize collection items factory class
|
| 46 |
+
*/
|
| 47 |
+
protected function _construct()
|
| 48 |
+
{
|
| 49 |
+
$this->_init('paypal/payment_transaction');
|
| 50 |
+
parent::_construct();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* CreatedAt filter setter
|
| 55 |
+
*
|
| 56 |
+
* @param string $date
|
| 57 |
+
* @return Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection
|
| 58 |
+
*/
|
| 59 |
+
public function addCreatedBeforeFilter($date)
|
| 60 |
+
{
|
| 61 |
+
$this->_createdBefore = $date;
|
| 62 |
+
return $this;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Prepare filters
|
| 67 |
+
*
|
| 68 |
+
* @return Mage_Paypal_Model_Resource_Payment_Transaction_Collection
|
| 69 |
+
*/
|
| 70 |
+
protected function _beforeLoad()
|
| 71 |
+
{
|
| 72 |
+
parent::_beforeLoad();
|
| 73 |
+
|
| 74 |
+
if ($this->isLoaded()) {
|
| 75 |
+
return $this;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// filters
|
| 79 |
+
if ($this->_createdBefore) {
|
| 80 |
+
$this->getSelect()->where('main_table.created_at < ?', $this->_createdBefore);
|
| 81 |
+
}
|
| 82 |
+
return $this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Unserialize additional_information in each item
|
| 87 |
+
*
|
| 88 |
+
* @return Mage_Paypal_Model_Resource_Payment_Transaction_Collection
|
| 89 |
+
*/
|
| 90 |
+
protected function _afterLoad()
|
| 91 |
+
{
|
| 92 |
+
foreach ($this->_items as $item) {
|
| 93 |
+
$this->getResource()->unserializeFields($item);
|
| 94 |
+
}
|
| 95 |
+
return parent::_afterLoad();
|
| 96 |
+
}
|
| 97 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement.php
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Resource_Report_Settlement extends Mage_Core_Model_Resource_Db_Abstract
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Table name
|
| 6 |
+
*
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
protected $_rowsTable;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Init main table
|
| 13 |
+
*
|
| 14 |
+
*/
|
| 15 |
+
protected function _construct()
|
| 16 |
+
{
|
| 17 |
+
$this->_init('paypal/settlement_report', 'report_id');
|
| 18 |
+
$this->_rowsTable = $this->getTable('paypal/settlement_report_row');
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Save report rows collected in settlement model
|
| 23 |
+
*
|
| 24 |
+
* @param Mage_Paypal_Model_Report_Settlement $object
|
| 25 |
+
* @return Mage_Paypal_Model_Resource_Report_Settlement
|
| 26 |
+
*/
|
| 27 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
| 28 |
+
{
|
| 29 |
+
$rows = $object->getRows();
|
| 30 |
+
if (is_array($rows)) {
|
| 31 |
+
$adapter = $this->_getWriteAdapter();
|
| 32 |
+
$reportId = (int)$object->getId();
|
| 33 |
+
try {
|
| 34 |
+
$adapter->beginTransaction();
|
| 35 |
+
if ($reportId) {
|
| 36 |
+
$adapter->delete($this->_rowsTable, array('report_id = ?' => $reportId));
|
| 37 |
+
}
|
| 38 |
+
/** @var $date Mage_Core_Model_Date */
|
| 39 |
+
$date = Mage::getSingleton('core/date');
|
| 40 |
+
|
| 41 |
+
foreach ($rows as $key => $row) {
|
| 42 |
+
/*
|
| 43 |
+
* Converting dates
|
| 44 |
+
*/
|
| 45 |
+
$completionDate = new Zend_Date($rows[$key]['transaction_completion_date']);
|
| 46 |
+
$rows[$key]['transaction_completion_date'] = $date->date(null, $completionDate->getTimestamp());
|
| 47 |
+
$initiationDate = new Zend_Date($rows[$key]['transaction_initiation_date']);
|
| 48 |
+
$rows[$key]['transaction_initiation_date'] = $date->date(null, $initiationDate->getTimestamp());
|
| 49 |
+
/*
|
| 50 |
+
* Converting numeric
|
| 51 |
+
*/
|
| 52 |
+
$rows[$key]['fee_amount'] = (float)$rows[$key]['fee_amount'];
|
| 53 |
+
/*
|
| 54 |
+
* Setting reportId
|
| 55 |
+
*/
|
| 56 |
+
$rows[$key]['report_id'] = $reportId;
|
| 57 |
+
}
|
| 58 |
+
if (!empty($rows)) {
|
| 59 |
+
$adapter->insertMultiple($this->_rowsTable, $rows);
|
| 60 |
+
}
|
| 61 |
+
$adapter->commit();
|
| 62 |
+
} catch (Exception $e) {
|
| 63 |
+
$adapter->rollback();
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
return $this;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Check if report with same account and report date already fetched
|
| 72 |
+
*
|
| 73 |
+
* @param Mage_Paypal_Model_Report_Settlement $report
|
| 74 |
+
* @param string $accountId
|
| 75 |
+
* @param string $reportDate
|
| 76 |
+
* @return Mage_Paypal_Model_Resource_Report_Settlement
|
| 77 |
+
*/
|
| 78 |
+
public function loadByAccountAndDate(Ebcomm_PaypalMx_Model_Report_Settlement $report, $accountId, $reportDate)
|
| 79 |
+
{
|
| 80 |
+
$adapter = $this->_getReadAdapter();
|
| 81 |
+
$select = $adapter->select()
|
| 82 |
+
->from($this->getMainTable())
|
| 83 |
+
->where('account_id = :account_id')
|
| 84 |
+
->where('report_date = :report_date');
|
| 85 |
+
|
| 86 |
+
$data = $adapter->fetchRow($select, array(':account_id' => $accountId, ':report_date' => $reportDate));
|
| 87 |
+
if ($data) {
|
| 88 |
+
$report->addData($data);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
return $this;
|
| 92 |
+
}
|
| 93 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement/Row.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Resource_Report_Settlement_Row extends Mage_Core_Model_Resource_Db_Abstract
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Resource model initialization.
|
| 6 |
+
* Set main entity table name and primary key field name.
|
| 7 |
+
*/
|
| 8 |
+
protected function _construct()
|
| 9 |
+
{
|
| 10 |
+
$this->_init('paypal/settlement_report_row', 'row_id');
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Report/Settlement/Row/Collection.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_Resource_Report_Settlement_Row_Collection
|
| 3 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Resource initializing
|
| 7 |
+
*
|
| 8 |
+
*/
|
| 9 |
+
protected function _construct()
|
| 10 |
+
{
|
| 11 |
+
$this->_init('paypalmx/report_settlement_row');
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Join reports info table
|
| 16 |
+
*
|
| 17 |
+
* @return Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection
|
| 18 |
+
*/
|
| 19 |
+
protected function _initSelect()
|
| 20 |
+
{
|
| 21 |
+
parent::_initSelect();
|
| 22 |
+
$this->getSelect()
|
| 23 |
+
->join(
|
| 24 |
+
array('report' => $this->getTable('paypal/settlement_report')),
|
| 25 |
+
'report.report_id = main_table.report_id',
|
| 26 |
+
array('report.account_id', 'report.report_date')
|
| 27 |
+
);
|
| 28 |
+
return $this;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Filter items collection by account ID
|
| 33 |
+
*
|
| 34 |
+
* @param string $accountId
|
| 35 |
+
* @return Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection
|
| 36 |
+
*/
|
| 37 |
+
public function addAccountFilter($accountId)
|
| 38 |
+
{
|
| 39 |
+
$this->getSelect()->where('report.account_id = ?', $accountId);
|
| 40 |
+
return $this;
|
| 41 |
+
}
|
| 42 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Resource/Setup.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* PayPal Setup Resource class
|
| 30 |
+
*
|
| 31 |
+
* @category Mage
|
| 32 |
+
* @package Mage_Paypal
|
| 33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
+
*/
|
| 35 |
+
class Mage_Paypal_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup
|
| 36 |
+
{
|
| 37 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/Session.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* Paypal transaction session namespace
|
| 6 |
+
*
|
| 7 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 8 |
+
*/
|
| 9 |
+
class Ebcomm_PaypalMx_Model_Session extends Mage_Core_Model_Session_Abstract
|
| 10 |
+
{
|
| 11 |
+
public function __construct()
|
| 12 |
+
{
|
| 13 |
+
$this->init('paypalmx');
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/Cert.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Model_System_Config_Backend_Cert extends Mage_Core_Model_Config_Data
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Process additional data before save config
|
| 7 |
+
*
|
| 8 |
+
* @return Mage_Paypal_Model_System_Config_Backend_Cert
|
| 9 |
+
*/
|
| 10 |
+
protected function _beforeSave()
|
| 11 |
+
{
|
| 12 |
+
$value = $this->getValue();
|
| 13 |
+
if (is_array($value) && !empty($value['delete'])) {
|
| 14 |
+
$this->setValue('');
|
| 15 |
+
Mage::getModel('paypalmx/cert')->loadByWebsite($this->getScopeId())->delete();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
if (!isset($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'])) {
|
| 19 |
+
return $this;
|
| 20 |
+
}
|
| 21 |
+
$tmpPath = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
|
| 22 |
+
if ($tmpPath && file_exists($tmpPath)) {
|
| 23 |
+
if (!filesize($tmpPath)) {
|
| 24 |
+
Mage::throwException(Mage::helper('paypalmx')->__('El certificado paypal esta vacio..'));
|
| 25 |
+
}
|
| 26 |
+
$this->setValue($_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value']);
|
| 27 |
+
$content = Mage::helper('core')->encrypt(file_get_contents($tmpPath));
|
| 28 |
+
Mage::getModel('paypalmx/cert')->loadByWebsite($this->getScopeId())
|
| 29 |
+
->setContent($content)
|
| 30 |
+
->save();
|
| 31 |
+
}
|
| 32 |
+
return $this;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Process object after delete data
|
| 37 |
+
*
|
| 38 |
+
* @return Mage_Paypal_Model_System_Config_Backend_Cert
|
| 39 |
+
*/
|
| 40 |
+
protected function _afterDelete()
|
| 41 |
+
{
|
| 42 |
+
Mage::getModel('paypalmx/cert')->loadByWebsite($this->getScopeId())->delete();
|
| 43 |
+
return $this;
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/Cron.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Model_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data
|
| 4 |
+
{
|
| 5 |
+
const CRON_STRING_PATH = 'crontab/jobs/paypal_fetch_settlement_reports/schedule/cron_expr';
|
| 6 |
+
const CRON_MODEL_PATH_INTERVAL = 'paypalmx/fetch_reports/schedule';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Cron settings after save
|
| 10 |
+
* @return void
|
| 11 |
+
*/
|
| 12 |
+
protected function _afterSave()
|
| 13 |
+
{
|
| 14 |
+
$cronExprString = '';
|
| 15 |
+
$time = explode(',', Mage::getModel('core/config_data')->load('paypalmx/fetch_reports/time', 'path')->getValue());
|
| 16 |
+
if (Mage::getModel('core/config_data')->load('paypalmx/fetch_reports/active', 'path')->getValue()) {
|
| 17 |
+
$interval = Mage::getModel('core/config_data')->load(self::CRON_MODEL_PATH_INTERVAL, 'path')->getValue();
|
| 18 |
+
$cronExprString = "{$time[1]} {$time[0]} */{$interval} * *";
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
Mage::getModel('core/config_data')
|
| 22 |
+
->load(self::CRON_STRING_PATH, 'path')
|
| 23 |
+
->setValue($cronExprString)
|
| 24 |
+
->setPath(self::CRON_STRING_PATH)
|
| 25 |
+
->save();
|
| 26 |
+
|
| 27 |
+
return parent::_afterSave();
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Backend/MerchantCountry.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_System_Config_Backend_MerchantCountry extends Mage_Core_Model_Config_Data
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Config path to default country
|
| 6 |
+
* @deprecated since 1.4.1.0
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
const XML_PATH_COUNTRY_DEFAULT = 'general/country/default';
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Substitute empty value with Default country.
|
| 13 |
+
*/
|
| 14 |
+
protected function _afterLoad()
|
| 15 |
+
{
|
| 16 |
+
$value = (string)$this->getValue();
|
| 17 |
+
if (empty($value)) {
|
| 18 |
+
if ($this->getWebsite()) {
|
| 19 |
+
$defaultCountry = Mage::app()->getWebsite($this->getWebsite())
|
| 20 |
+
->getConfig(Mage_Core_Helper_Data::XML_PATH_DEFAULT_COUNTRY);
|
| 21 |
+
} else {
|
| 22 |
+
$defaultCountry = Mage::helper('core')->getDefaultCountry($this->getStore());
|
| 23 |
+
}
|
| 24 |
+
$this->setValue($defaultCountry);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/AuthorizationAmounts.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_AuthorizationAmounts
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Options getter
|
| 7 |
+
*
|
| 8 |
+
* @return array
|
| 9 |
+
*/
|
| 10 |
+
public function toOptionArray()
|
| 11 |
+
{
|
| 12 |
+
return array();
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/BuyerCountry.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Source model for buyer countries supported by PayPal
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_BuyerCountry
|
| 7 |
+
{
|
| 8 |
+
public function toOptionArray($isMultiselect = false)
|
| 9 |
+
{
|
| 10 |
+
$supported = Mage::getModel('paypalmx/config')->getSupportedBuyerCountryCodes();
|
| 11 |
+
$options = Mage::getResourceModel('directory/country_collection')
|
| 12 |
+
->addCountryCodeFilter($supported, 'iso2')
|
| 13 |
+
->loadData()
|
| 14 |
+
->toOptionArray($isMultiselect ? false : Mage::helper('adminhtml')->__('--Please Select--'));
|
| 15 |
+
|
| 16 |
+
return $options;
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/FetchingSchedule.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Source model for available settlement report fetching intervals
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_FetchingSchedule
|
| 7 |
+
{
|
| 8 |
+
public function toOptionArray()
|
| 9 |
+
{
|
| 10 |
+
return array (
|
| 11 |
+
1 => Mage::helper('paypalmx')->__("Diario"),
|
| 12 |
+
3 => Mage::helper('paypalmx')->__("Cada 3 dias"),
|
| 13 |
+
7 => Mage::helper('paypalmx')->__("Cada 7 dias"),
|
| 14 |
+
10 => Mage::helper('paypalmx')->__("Cada 10 dias"),
|
| 15 |
+
14 => Mage::helper('paypalmx')->__("Cada 14 dias"),
|
| 16 |
+
30 => Mage::helper('paypalmx')->__("Cada 30 dias"),
|
| 17 |
+
40 => Mage::helper('paypalmx')->__("Cada 40 dias"),
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/Logo.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Source model for available logo types
|
| 4 |
+
*/
|
| 5 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_Logo
|
| 6 |
+
{
|
| 7 |
+
public function toOptionArray()
|
| 8 |
+
{
|
| 9 |
+
$result = array('' => Mage::helper('paypalmx')->__('No Logo'));
|
| 10 |
+
$result += Mage::getModel('paypalmx/config')->getAdditionalOptionsLogoTypes();
|
| 11 |
+
return $result;
|
| 12 |
+
}
|
| 13 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/MerchantCountry.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Source model for merchant countries supported by PayPal
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_MerchantCountry
|
| 7 |
+
{
|
| 8 |
+
public function toOptionArray($isMultiselect = false)
|
| 9 |
+
{
|
| 10 |
+
$supported = Mage::getModel('paypalmx/config')->getSupportedMerchantCountryCodes();
|
| 11 |
+
$options = Mage::getResourceModel('directory/country_collection')
|
| 12 |
+
->addCountryCodeFilter($supported, 'iso2')
|
| 13 |
+
->loadData()
|
| 14 |
+
->toOptionArray($isMultiselect ? false : Mage::helper('adminhtml')->__('--Please Select--'));
|
| 15 |
+
|
| 16 |
+
return $options;
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/PaymentActions.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_PaymentActions
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Options getter
|
| 6 |
+
*
|
| 7 |
+
* @return array
|
| 8 |
+
*/
|
| 9 |
+
public function toOptionArray()
|
| 10 |
+
{
|
| 11 |
+
$configModel = Mage::getModel('paypalmx/config');
|
| 12 |
+
return $configModel->getPaymentActions();
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/PaymentActions/Express.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Source model for available paypal express payment actions
|
| 4 |
+
*/
|
| 5 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_PaymentActions_Express
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Options getter
|
| 9 |
+
*
|
| 10 |
+
* @return array
|
| 11 |
+
*/
|
| 12 |
+
public function toOptionArray()
|
| 13 |
+
{
|
| 14 |
+
$configModel = Mage::getModel('paypalmx/config');
|
| 15 |
+
$configModel->setMethod(Ebcomm_PaypalMx_Model_Config::METHOD_PPMX);
|
| 16 |
+
return $configModel->getPaymentActions();
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/RequireBillingAddress.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Source model for Require Billing Address
|
| 4 |
+
*/
|
| 5 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_RequireBillingAddress
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Options getter
|
| 9 |
+
*
|
| 10 |
+
* @return array
|
| 11 |
+
*/
|
| 12 |
+
public function toOptionArray()
|
| 13 |
+
{
|
| 14 |
+
/** @var $configModel Mage_Paypal_Model_Config */
|
| 15 |
+
$configModel = Mage::getModel('paypalmx/config');
|
| 16 |
+
return $configModel->getRequireBillingAddressOptions();
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/Ebcomm/PaypalMx/Model/System/Config/Source/UrlMethod.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Source model for url method: GET/POST
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_Model_System_Config_Source_UrlMethod
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Options getter
|
| 10 |
+
*
|
| 11 |
+
* @return array
|
| 12 |
+
*/
|
| 13 |
+
public function toOptionArray()
|
| 14 |
+
{
|
| 15 |
+
return array(
|
| 16 |
+
array('value' => 'GET', 'label' => 'GET'),
|
| 17 |
+
array('value' => 'POST', 'label' => 'POST'),
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
+
}
|
app/code/community/Ebcomm/PaypalMx/controllers/Adminhtml/Paypal/ReportssController.php
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ebcomm_PaypalMx_Adminhtml_Paypal_ReportssController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Grid action
|
| 7 |
+
*/
|
| 8 |
+
public function indexAction()
|
| 9 |
+
{
|
| 10 |
+
$this->_initAction()
|
| 11 |
+
->_addContent($this->getLayout()->createBlock('paypalmx/adminhtml_settlement_report'))
|
| 12 |
+
->renderLayout();
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Ajax callback for grid actions
|
| 17 |
+
*/
|
| 18 |
+
public function gridAction()
|
| 19 |
+
{
|
| 20 |
+
$this->loadLayout();
|
| 21 |
+
$this->getResponse()->setBody(
|
| 22 |
+
$this->getLayout()->createBlock('paypalmx/adminhtml_settlement_report_grid')->toHtml()
|
| 23 |
+
);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* View transaction details action
|
| 28 |
+
*/
|
| 29 |
+
public function detailsAction()
|
| 30 |
+
{
|
| 31 |
+
$rowId = $this->getRequest()->getParam('id');
|
| 32 |
+
$row = Mage::getModel('paypalmx/report_settlement_row')->load($rowId);
|
| 33 |
+
if (!$row->getId()) {
|
| 34 |
+
$this->_redirect('*/*/');
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
Mage::register('current_transaction', $row);
|
| 38 |
+
$this->_initAction()
|
| 39 |
+
->_title($this->__('View Transaction'))
|
| 40 |
+
->_addContent($this->getLayout()->createBlock('paypalmx/adminhtml_settlement_details', 'settlementDetails'))
|
| 41 |
+
->renderLayout();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Forced fetch reports action
|
| 46 |
+
*/
|
| 47 |
+
public function fetchAction()
|
| 48 |
+
{
|
| 49 |
+
try {
|
| 50 |
+
$reports = Mage::getModel('paypalmx/report_settlement');
|
| 51 |
+
/* @var $reports Mage_Paypal_Model_Report_Settlement */
|
| 52 |
+
$credentials = $reports->getSftpCredentials();
|
| 53 |
+
if (empty($credentials)) {
|
| 54 |
+
Mage::throwException(Mage::helper('paypalmx')->__('Nada que buscar porque no se encuentra la configuracion apropiada.'));
|
| 55 |
+
}
|
| 56 |
+
foreach ($credentials as $config) {
|
| 57 |
+
try {
|
| 58 |
+
$fetched = $reports->fetchAndSave($config);
|
| 59 |
+
$this->_getSession()->addSuccess(
|
| 60 |
+
Mage::helper('paypalmx')->__("Se encontraron %s reportes de '%s@%s'.", $fetched, $config['username'], $config['hostname'])
|
| 61 |
+
);
|
| 62 |
+
} catch (Exception $e) {
|
| 63 |
+
$this->_getSession()->addError(
|
| 64 |
+
Mage::helper('paypalmx')->__("No se encontraron reportes de '%s@%s'.", $config['username'], $config['hostname'])
|
| 65 |
+
);
|
| 66 |
+
Mage::logException($e);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
} catch (Mage_Core_Exception $e) {
|
| 70 |
+
$this->_getSession()->addError($e->getMessage());
|
| 71 |
+
} catch (Exception $e) {
|
| 72 |
+
Mage::logException($e);
|
| 73 |
+
}
|
| 74 |
+
$this->_redirect('*/*/index');
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Initialize titles, navigation
|
| 79 |
+
* @return Mage_Paypal_Adminhtml_Paypal_ReportsController
|
| 80 |
+
*/
|
| 81 |
+
protected function _initAction()
|
| 82 |
+
{
|
| 83 |
+
$this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Reportes de Solución PayPal México'));
|
| 84 |
+
$this->loadLayout()
|
| 85 |
+
->_setActiveMenu('report/sales')
|
| 86 |
+
->_addBreadcrumb(Mage::helper('paypalmx')->__('Reports'), Mage::helper('paypalmx')->__('Reports'))
|
| 87 |
+
->_addBreadcrumb(Mage::helper('paypalmx')->__('Sales'), Mage::helper('paypalmx')->__('Sales'))
|
| 88 |
+
->_addBreadcrumb(Mage::helper('paypalmx')->__('PayPal Settlement Reports'), Mage::helper('paypalmx')->__('PayPal Settlement Reports'));
|
| 89 |
+
return $this;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* ACL check
|
| 94 |
+
* @return bool
|
| 95 |
+
*/
|
| 96 |
+
protected function _isAllowed()
|
| 97 |
+
{
|
| 98 |
+
switch ($this->getRequest()->getActionName()) {
|
| 99 |
+
case 'index':
|
| 100 |
+
case 'details':
|
| 101 |
+
return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/view');
|
| 102 |
+
break;
|
| 103 |
+
case 'fetch':
|
| 104 |
+
return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/fetch');
|
| 105 |
+
break;
|
| 106 |
+
default:
|
| 107 |
+
return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports');
|
| 108 |
+
break;
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
app/code/community/Ebcomm/PaypalMx/controllers/ExpressController.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Express Checkout Controller
|
| 5 |
+
*/
|
| 6 |
+
class Ebcomm_PaypalMx_ExpressController extends Ebcomm_PaypalMx_Controller_Express_Abstract
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Config mode type
|
| 10 |
+
*
|
| 11 |
+
* @var string
|
| 12 |
+
*/
|
| 13 |
+
protected $_configType = 'paypalmx/config';
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Config method type
|
| 17 |
+
*
|
| 18 |
+
* @var string
|
| 19 |
+
*/
|
| 20 |
+
protected $_configMethod = Ebcomm_PaypalMx_Model_Config::METHOD_PPMX;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Checkout mode type
|
| 24 |
+
*
|
| 25 |
+
* @var string
|
| 26 |
+
*/
|
| 27 |
+
protected $_checkoutType = 'paypalmx/express_checkout';
|
| 28 |
+
}
|
app/code/community/Ebcomm/PaypalMx/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<menu>
|
| 4 |
+
<report>
|
| 5 |
+
<children>
|
| 6 |
+
<salesroot translate="title">
|
| 7 |
+
<children>
|
| 8 |
+
<paypalmx_settlement_reports translate="title">
|
| 9 |
+
<title>Reportes de Solución PayPal México</title>
|
| 10 |
+
<action>adminhtml/paypal_reportss</action>
|
| 11 |
+
<sort_order>100</sort_order>
|
| 12 |
+
</paypalmx_settlement_reports>
|
| 13 |
+
</children>
|
| 14 |
+
</salesroot>
|
| 15 |
+
</children>
|
| 16 |
+
</report>
|
| 17 |
+
</menu>
|
| 18 |
+
<acl>
|
| 19 |
+
<resources>
|
| 20 |
+
<admin>
|
| 21 |
+
<children>
|
| 22 |
+
<system>
|
| 23 |
+
<children>
|
| 24 |
+
<config>
|
| 25 |
+
<children>
|
| 26 |
+
<paypalmx>
|
| 27 |
+
<title>Seccion de PayPal Mexico</title>
|
| 28 |
+
</paypalmx>
|
| 29 |
+
</children>
|
| 30 |
+
</config>
|
| 31 |
+
</children>
|
| 32 |
+
</system>
|
| 33 |
+
<report>
|
| 34 |
+
<children>
|
| 35 |
+
<salesroot>
|
| 36 |
+
<children>
|
| 37 |
+
<paypalmx_settlement_reports translate="title">
|
| 38 |
+
<title>Reportes de Solución PayPal México</title>
|
| 39 |
+
<children>
|
| 40 |
+
<view translate="title">
|
| 41 |
+
<title>View</title>
|
| 42 |
+
</view>
|
| 43 |
+
<fetch translate="title">
|
| 44 |
+
<title>Fetch</title>
|
| 45 |
+
</fetch>
|
| 46 |
+
</children>
|
| 47 |
+
</paypalmx_settlement_reports>
|
| 48 |
+
</children>
|
| 49 |
+
</salesroot>
|
| 50 |
+
</children>
|
| 51 |
+
</report>
|
| 52 |
+
</children>
|
| 53 |
+
</admin>
|
| 54 |
+
</resources>
|
| 55 |
+
</acl>
|
| 56 |
+
</config>
|
app/code/community/Ebcomm/PaypalMx/etc/config.xml
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Ebcomm_PaypalMx>
|
| 5 |
+
<version>1.0.2</version>
|
| 6 |
+
</Ebcomm_PaypalMx>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<paypalmx>
|
| 11 |
+
<class>Ebcomm_PaypalMx_Model</class>
|
| 12 |
+
<resourceModel>paypalmx_resource</resourceModel>
|
| 13 |
+
</paypalmx>
|
| 14 |
+
<paypalmx_resource>
|
| 15 |
+
<class>Ebcomm_PaypalMx_Model_Resource</class>
|
| 16 |
+
<deprecatedNode>paypalmx_mysql4</deprecatedNode>
|
| 17 |
+
<entities>
|
| 18 |
+
<api_debug>
|
| 19 |
+
<table>paypalmx_api_debug</table>
|
| 20 |
+
</api_debug>
|
| 21 |
+
<cert>
|
| 22 |
+
<table>paypalmx_cert</table>
|
| 23 |
+
</cert>
|
| 24 |
+
<payment_transaction>
|
| 25 |
+
<table>paypalmx_payment_transaction</table>
|
| 26 |
+
</payment_transaction>
|
| 27 |
+
</entities>
|
| 28 |
+
</paypalmx_resource>
|
| 29 |
+
</models>
|
| 30 |
+
<helpers>
|
| 31 |
+
<paypalmx>
|
| 32 |
+
<class>Ebcomm_PaypalMx_Helper</class>
|
| 33 |
+
</paypalmx>
|
| 34 |
+
</helpers>
|
| 35 |
+
<blocks>
|
| 36 |
+
<paypalmx>
|
| 37 |
+
<class>Ebcomm_PaypalMx_Block</class>
|
| 38 |
+
</paypalmx>
|
| 39 |
+
</blocks>
|
| 40 |
+
</global>
|
| 41 |
+
<frontend>
|
| 42 |
+
<translate>
|
| 43 |
+
<modules>
|
| 44 |
+
<Ebcomm_PaypalMx>
|
| 45 |
+
<files>
|
| 46 |
+
<default>Ebcomm_PaypalMx.csv</default>
|
| 47 |
+
</files>
|
| 48 |
+
</Ebcomm_PaypalMx>
|
| 49 |
+
</modules>
|
| 50 |
+
</translate>
|
| 51 |
+
<secure_url>
|
| 52 |
+
<paypal_mexico>/paypalmx/express</paypal_mexico>
|
| 53 |
+
</secure_url>
|
| 54 |
+
<routers>
|
| 55 |
+
<paypalmx>
|
| 56 |
+
<use>standard</use>
|
| 57 |
+
<args>
|
| 58 |
+
<module>Ebcomm_PaypalMx</module>
|
| 59 |
+
<frontName>paypalmx</frontName>
|
| 60 |
+
</args>
|
| 61 |
+
</paypalmx>
|
| 62 |
+
</routers>
|
| 63 |
+
<layout>
|
| 64 |
+
<updates>
|
| 65 |
+
<paypalmx>
|
| 66 |
+
<file>paypalmx.xml</file>
|
| 67 |
+
</paypalmx>
|
| 68 |
+
</updates>
|
| 69 |
+
</layout>
|
| 70 |
+
<secure_url>
|
| 71 |
+
<paypalmexico_callbackshippingoptions>paypalmx/express/callbackshippingoptions
|
| 72 |
+
</paypalmexico_callbackshippingoptions>
|
| 73 |
+
</secure_url>
|
| 74 |
+
<events>
|
| 75 |
+
<checkout_submit_all_after>
|
| 76 |
+
<observers>
|
| 77 |
+
SHORTCUT_popup <hss_save_order_after_submit_mx>
|
| 78 |
+
<class>paypalmx/observer</class>
|
| 79 |
+
<method>saveOrderAfterSubmit</method>
|
| 80 |
+
</hss_save_order_after_submit_mx>
|
| 81 |
+
</observers>
|
| 82 |
+
</checkout_submit_all_after>
|
| 83 |
+
<controller_action_postdispatch_checkout_onepage_saveOrder>
|
| 84 |
+
<observers>
|
| 85 |
+
<hss_save_order_onepage_mx>
|
| 86 |
+
<class>paypalmx/observer</class>
|
| 87 |
+
<method>setResponseAfterSaveOrder</method>
|
| 88 |
+
</hss_save_order_onepage_mx>
|
| 89 |
+
</observers>
|
| 90 |
+
</controller_action_postdispatch_checkout_onepage_saveOrder>
|
| 91 |
+
</events>
|
| 92 |
+
</frontend>
|
| 93 |
+
<adminhtml>
|
| 94 |
+
<translate>
|
| 95 |
+
<modules>
|
| 96 |
+
<Ebcomm_PaypalMx>
|
| 97 |
+
<files>
|
| 98 |
+
<default>Ebcomm_PaypalMx.csv</default>
|
| 99 |
+
</files>
|
| 100 |
+
</Ebcomm_PaypalMx>
|
| 101 |
+
</modules>
|
| 102 |
+
</translate>
|
| 103 |
+
<events>
|
| 104 |
+
<adminhtml_init_system_config>
|
| 105 |
+
<observers>
|
| 106 |
+
<paypalmx>
|
| 107 |
+
<class>paypalmx/observer</class>
|
| 108 |
+
<method>loadCountryDependentSolutionsConfig</method>
|
| 109 |
+
</paypalmx>
|
| 110 |
+
</observers>
|
| 111 |
+
</adminhtml_init_system_config>
|
| 112 |
+
</events>
|
| 113 |
+
</adminhtml>
|
| 114 |
+
<default>
|
| 115 |
+
<paypalmx>
|
| 116 |
+
<fetch_reports>
|
| 117 |
+
<ftp_login backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 118 |
+
<ftp_password backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 119 |
+
<schedule>1</schedule>
|
| 120 |
+
<time>00,00,00</time>
|
| 121 |
+
</fetch_reports>
|
| 122 |
+
<style>
|
| 123 |
+
<paypal_hdrimg>https://dl.dropboxusercontent.com/u/105978444/Banner-CO-Amex-750x90_VF.png</paypal_hdrimg>
|
| 124 |
+
</style>
|
| 125 |
+
</paypalmx>
|
| 126 |
+
<payment>
|
| 127 |
+
<ppmx>
|
| 128 |
+
<model>paypalmx/express</model>
|
| 129 |
+
<title>PayPal</title>
|
| 130 |
+
<payment_action>Sale</payment_action>
|
| 131 |
+
<solution_type>Mark</solution_type>
|
| 132 |
+
<method_type>2</method_type>
|
| 133 |
+
<sort_order>0</sort_order>
|
| 134 |
+
<line_items_enabled>1</line_items_enabled>
|
| 135 |
+
<visible_on_shipping>1</visible_on_shipping>
|
| 136 |
+
<allow_ba_signup>never</allow_ba_signup>
|
| 137 |
+
<group>paypalmx</group>
|
| 138 |
+
<authorization_honor_period>3</authorization_honor_period>
|
| 139 |
+
<order_valid_period>29</order_valid_period>
|
| 140 |
+
<child_authorization_number>1</child_authorization_number>
|
| 141 |
+
<verify_peer>1</verify_peer>
|
| 142 |
+
</ppmx>
|
| 143 |
+
<ppmx_debito2>
|
| 144 |
+
<model>paypalmx/debito2</model>
|
| 145 |
+
<title>PayPal Debito</title>
|
| 146 |
+
<payment_action>Sale</payment_action>
|
| 147 |
+
<solution_type>Mark</solution_type>
|
| 148 |
+
<method_type>3</method_type>
|
| 149 |
+
<sort_order>0</sort_order>
|
| 150 |
+
<line_items_enabled>1</line_items_enabled>
|
| 151 |
+
<allow_ba_signup>never</allow_ba_signup>
|
| 152 |
+
<group>paypalmx</group>
|
| 153 |
+
<authorization_honor_period>3</authorization_honor_period>
|
| 154 |
+
<order_valid_period>29</order_valid_period>
|
| 155 |
+
<child_authorization_number>1</child_authorization_number>
|
| 156 |
+
<verify_peer>1</verify_peer>
|
| 157 |
+
</ppmx_debito2>
|
| 158 |
+
<ppmx_mensualidades2>
|
| 159 |
+
<model>paypalmx/mensualidades2</model>
|
| 160 |
+
<title>PayPal Mensualidades</title>
|
| 161 |
+
<payment_action>Sale</payment_action>
|
| 162 |
+
<solution_type>Mark</solution_type>
|
| 163 |
+
<method_type>1</method_type>
|
| 164 |
+
<sort_order>0</sort_order>
|
| 165 |
+
<line_items_enabled>1</line_items_enabled>
|
| 166 |
+
<allow_ba_signup>never</allow_ba_signup>
|
| 167 |
+
<group>paypalmx</group>
|
| 168 |
+
<authorization_honor_period>3</authorization_honor_period>
|
| 169 |
+
<order_valid_period>29</order_valid_period>
|
| 170 |
+
<child_authorization_number>1</child_authorization_number>
|
| 171 |
+
<verify_peer>1</verify_peer>
|
| 172 |
+
</ppmx_mensualidades2>
|
| 173 |
+
</payment>
|
| 174 |
+
|
| 175 |
+
</default>
|
| 176 |
+
<crontab>
|
| 177 |
+
<jobs>
|
| 178 |
+
<paypalmx_fetch_settlement_reports>
|
| 179 |
+
<run>
|
| 180 |
+
<model>paypalmx/observer::fetchReports</model>
|
| 181 |
+
</run>
|
| 182 |
+
</paypalmx_fetch_settlement_reports>
|
| 183 |
+
</jobs>
|
| 184 |
+
</crontab>
|
| 185 |
+
<admin>
|
| 186 |
+
<routers>
|
| 187 |
+
<adminhtml>
|
| 188 |
+
<args>
|
| 189 |
+
<modules>
|
| 190 |
+
<Ebcomm_PaypalMx before="Mage_Adminhtml">Ebcomm_PaypalMx_Adminhtml</Ebcomm_PaypalMx>
|
| 191 |
+
</modules>
|
| 192 |
+
</args>
|
| 193 |
+
</adminhtml>
|
| 194 |
+
</routers>
|
| 195 |
+
</admin>
|
| 196 |
+
</config>
|
app/code/community/Ebcomm/PaypalMx/etc/system.xml
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
<payment>
|
| 6 |
+
<groups>
|
| 7 |
+
<pmxx translate="label comment paypal_title" module="paypalmx">
|
| 8 |
+
<label>PayPal <![CDATA[México (México)]]></label>
|
| 9 |
+
<sort_order>10</sort_order>
|
| 10 |
+
<expanded>1</expanded>
|
| 11 |
+
<show_in_default>1</show_in_default>
|
| 12 |
+
<show_in_website>1</show_in_website>
|
| 13 |
+
<show_in_store>1</show_in_store>
|
| 14 |
+
<frontend_class>complex</frontend_class>
|
| 15 |
+
<frontend_model>paypalmx/adminhtml_system_config_fieldset_group</frontend_model>
|
| 16 |
+
<comment>Agrega otro m<![CDATA[é]]>todo de pago a tus soluciones actuales o selecciónalo independientemente. <![CDATA[<a href="https://www.paypal.com/mx/webapps/mpp/home" target="_blank">Ayuda</a> <script> document.observe("dom:loaded", function() { Fieldset.toggleCollapse('payment_paypal_payment_solutions');});</script>]]></comment>
|
| 17 |
+
<paypal_title>Select a Payment Solution</paypal_title>
|
| 18 |
+
<fields/>
|
| 19 |
+
</pmxx>
|
| 20 |
+
<paypal_payments>
|
| 21 |
+
|
| 22 |
+
<ppmxx type="group" translate="label comment">
|
| 23 |
+
<label>PayPal <![CDATA[México (México)]]></label>
|
| 24 |
+
<frontend_type>text</frontend_type>
|
| 25 |
+
<show_in_default>1</show_in_default>
|
| 26 |
+
<show_in_website>1</show_in_website>
|
| 27 |
+
<show_in_store>1</show_in_store>
|
| 28 |
+
<sort_order>10</sort_order>
|
| 29 |
+
<group>pmxx</group>
|
| 30 |
+
<frontend_model>paypalmx/adminhtml_system_config_fieldset_payment</frontend_model>
|
| 31 |
+
<frontend_class>ppmx-method</frontend_class>
|
| 32 |
+
<include>1</include>
|
| 33 |
+
<comment><![CDATA[Especialmente construido para vendedores en México. Acepta pagos con Débito, Crédito y ofrezca mensualidades </br>
|
| 34 |
+
<div id="paypalmx-module" style="padding:15px 0 0 35px;">
|
| 35 |
+
<span><h4 style="color:#576f8e;">Tarjetas de crédito y débito</h4></span>
|
| 36 |
+
Con PayPal puede aceptar las principales tarjetas de crédito y débito. PayPal le facilita también aceptar pagos en 25 divisas de 190 países.</br></br>
|
| 37 |
+
<span><h4 style="color:#576f8e;">Ofrezca mensualidades</h4></span>
|
| 38 |
+
Brinde a sus clientes la oportunidad de pagarle en mensualidades con tarjetas de crédito Bancomer, Banamex, HSBC, Santander y Banorte.</br>
|
| 39 |
+
Esto activará la tercera opción de pago (botón de mensualidades). Se explicará cómo el usuario activará mensualidades en su cuenta de PayPal
|
| 40 |
+
</br></br><span><h4 style="color:#576f8e;">Express Checkout Shortcut</h4></span>
|
| 41 |
+
Brinde a sus usuarios la mejor experiencia de compra con Express Checkout Shortcut. Al implementarlo, los compradores podrán terminar su transacción en pocos clics.
|
| 42 |
+
<br>
|
| 43 |
+
</div>
|
| 44 |
+
]]></comment>
|
| 45 |
+
<activity_path>payment/ppmx/active</activity_path>
|
| 46 |
+
<learn_more_link>https://www.paypal.com/mx/webapps/mpp/home</learn_more_link>
|
| 47 |
+
<fields>
|
| 48 |
+
<ppmx_required type="group" translate="label">
|
| 49 |
+
<label>Configuración de Paypal Requerida</label>
|
| 50 |
+
<frontend_type>text</frontend_type>
|
| 51 |
+
<show_in_default>1</show_in_default>
|
| 52 |
+
<show_in_website>1</show_in_website>
|
| 53 |
+
<sort_order>10</sort_order>
|
| 54 |
+
<frontend_model>paypalmx/adminhtml_system_config_fieldset_expanded</frontend_model>
|
| 55 |
+
<fields>
|
| 56 |
+
<ppmx_required_express_checkout type="group" translate="label">
|
| 57 |
+
<label>Express Checkout</label>
|
| 58 |
+
<frontend_type>text</frontend_type>
|
| 59 |
+
<show_in_default>1</show_in_default>
|
| 60 |
+
<show_in_website>1</show_in_website>
|
| 61 |
+
<frontend_model>paypalmx/adminhtml_system_config_fieldset_expanded</frontend_model>
|
| 62 |
+
<sort_order>10</sort_order>
|
| 63 |
+
<fields>
|
| 64 |
+
<business_account translate="label comment tooltip">
|
| 65 |
+
<label>Email asociado con PayPal Merchant Account</label>
|
| 66 |
+
<comment><![CDATA[<a style="cursor:pointer" onclick="javascript:window.open('https://www.paypal.com/mx/webapps/mpp/referral/paypal-business-account2?partner_id=88FPTPUV43C3A','ppmx','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=1100, height=650');"> Empieza a recibir pagos con PayPal</a>]]></comment>
|
| 67 |
+
<tooltip>No tienes cuenta de Paypal? Simplemente agrega tu correo.</tooltip>
|
| 68 |
+
<config_path>paypalmx/general/business_account</config_path>
|
| 69 |
+
<show_in_default>1</show_in_default>
|
| 70 |
+
<show_in_website>1</show_in_website>
|
| 71 |
+
<sort_order>10</sort_order>
|
| 72 |
+
<validate>validate-email</validate>
|
| 73 |
+
<shared>1</shared>
|
| 74 |
+
</business_account>
|
| 75 |
+
<api_authentication translate="label">
|
| 76 |
+
<label>M<![CDATA[é]]>todo de autentificación de la API</label>
|
| 77 |
+
<config_path>paypalmx/ppmx/api_authentication</config_path>
|
| 78 |
+
<frontend_type>select</frontend_type>
|
| 79 |
+
<source_model>paypalmx/config::getApiAuthenticationMethods</source_model>
|
| 80 |
+
<sort_order>20</sort_order>
|
| 81 |
+
<show_in_default>1</show_in_default>
|
| 82 |
+
<show_in_website>1</show_in_website>
|
| 83 |
+
<shared>1</shared>
|
| 84 |
+
</api_authentication>
|
| 85 |
+
<api_username translate="label">
|
| 86 |
+
<label>Usuario de la API</label>
|
| 87 |
+
<config_path>paypalmx/ppmx/api_username</config_path>
|
| 88 |
+
<sort_order>30</sort_order>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<shared>1</shared>
|
| 92 |
+
</api_username>
|
| 93 |
+
<api_password translate="label">
|
| 94 |
+
<label>Contraseña de la API</label>
|
| 95 |
+
<config_path>paypalmx/ppmx/api_password</config_path>
|
| 96 |
+
<sort_order>40</sort_order>
|
| 97 |
+
<show_in_default>1</show_in_default>
|
| 98 |
+
<show_in_website>1</show_in_website>
|
| 99 |
+
<shared>1</shared>
|
| 100 |
+
</api_password>
|
| 101 |
+
<api_signature translate="label">
|
| 102 |
+
<label>Firma de la API</label>
|
| 103 |
+
<config_path>paypalmx/ppmx/api_signature</config_path>
|
| 104 |
+
<sort_order>50</sort_order>
|
| 105 |
+
<show_in_default>1</show_in_default>
|
| 106 |
+
<show_in_website>1</show_in_website>
|
| 107 |
+
<depends><api_authentication>0</api_authentication></depends>
|
| 108 |
+
<shared>1</shared>
|
| 109 |
+
</api_signature>
|
| 110 |
+
<api_cert translate="label">
|
| 111 |
+
<label>Certificado de la API</label>
|
| 112 |
+
<config_path>paypalmx/ppmx/api_cert</config_path>
|
| 113 |
+
<frontend_type>file</frontend_type>
|
| 114 |
+
<backend_model>paypalmx/system_config_backend_cert</backend_model>
|
| 115 |
+
<sort_order>60</sort_order>
|
| 116 |
+
<show_in_default>1</show_in_default>
|
| 117 |
+
<show_in_website>1</show_in_website>
|
| 118 |
+
<depends><api_authentication>1</api_authentication></depends>
|
| 119 |
+
<shared>1</shared>
|
| 120 |
+
</api_cert>
|
| 121 |
+
<api_wizard translate="button_label sandbox_button_label">
|
| 122 |
+
<label></label>
|
| 123 |
+
<button_label>Obtener Credenciales de PayPal de Producción</button_label>
|
| 124 |
+
<button_url><![CDATA[https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run]]></button_url>
|
| 125 |
+
<sandbox_button_label>Obtener Credenciales del ambiente de Pruebas de PayPal (Sandbox)</sandbox_button_label>
|
| 126 |
+
<sandbox_button_url><![CDATA[https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run]]></sandbox_button_url>
|
| 127 |
+
<frontend_model>paypalmx/adminhtml_system_config_apiWizard</frontend_model>
|
| 128 |
+
<sort_order>70</sort_order>
|
| 129 |
+
<show_in_default>1</show_in_default>
|
| 130 |
+
<show_in_website>1</show_in_website>
|
| 131 |
+
</api_wizard>
|
| 132 |
+
<sandbox_flag translate="label">
|
| 133 |
+
<label>Modo Sandbox</label>
|
| 134 |
+
<config_path>paypalmx/ppmx/sandbox_flag</config_path>
|
| 135 |
+
<frontend_type>select</frontend_type>
|
| 136 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 137 |
+
<sort_order>80</sort_order>
|
| 138 |
+
<show_in_default>1</show_in_default>
|
| 139 |
+
<show_in_website>1</show_in_website>
|
| 140 |
+
<shared>1</shared>
|
| 141 |
+
</sandbox_flag>
|
| 142 |
+
<use_proxy translate="label">
|
| 143 |
+
<label>API Utiliza Proxy</label>
|
| 144 |
+
<config_path>paypalmx/ppmx/use_proxy</config_path>
|
| 145 |
+
<frontend_type>select</frontend_type>
|
| 146 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 147 |
+
<sort_order>90</sort_order>
|
| 148 |
+
<show_in_default>1</show_in_default>
|
| 149 |
+
<show_in_website>1</show_in_website>
|
| 150 |
+
<shared>1</shared>
|
| 151 |
+
</use_proxy>
|
| 152 |
+
<proxy_host translate="label">
|
| 153 |
+
<label>Host del Proxy</label>
|
| 154 |
+
<config_path>paypalmx/ppmx/proxy_host</config_path>
|
| 155 |
+
<frontend_type>text</frontend_type>
|
| 156 |
+
<sort_order>100</sort_order>
|
| 157 |
+
<show_in_default>1</show_in_default>
|
| 158 |
+
<show_in_website>1</show_in_website>
|
| 159 |
+
<depends><use_proxy>1</use_proxy></depends>
|
| 160 |
+
<shared>1</shared>
|
| 161 |
+
</proxy_host>
|
| 162 |
+
<proxy_port translate="label">
|
| 163 |
+
<label>Puerto del Proxy</label>
|
| 164 |
+
<config_path>paypalmx/ppmx/proxy_port</config_path>
|
| 165 |
+
<frontend_type>text</frontend_type>
|
| 166 |
+
<sort_order>110</sort_order>
|
| 167 |
+
<show_in_default>1</show_in_default>
|
| 168 |
+
<show_in_website>1</show_in_website>
|
| 169 |
+
<depends><use_proxy>1</use_proxy></depends>
|
| 170 |
+
<shared>1</shared>
|
| 171 |
+
</proxy_port>
|
| 172 |
+
</fields>
|
| 173 |
+
</ppmx_required_express_checkout>
|
| 174 |
+
<enable_ppmx translate="label">
|
| 175 |
+
<label>Habilitar esta solución</label>
|
| 176 |
+
<config_path>payment/ppmx/active</config_path>
|
| 177 |
+
<frontend_type>select</frontend_type>
|
| 178 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 179 |
+
<sort_order>20</sort_order>
|
| 180 |
+
<show_in_default>1</show_in_default>
|
| 181 |
+
<show_in_website>1</show_in_website>
|
| 182 |
+
<shared>1</shared>
|
| 183 |
+
<requires>ppmx_required_express_checkout</requires>
|
| 184 |
+
<frontend_class>paypal-enabler paypal-ec-enabler</frontend_class>
|
| 185 |
+
</enable_ppmx>
|
| 186 |
+
</fields>
|
| 187 |
+
</ppmx_required>
|
| 188 |
+
<settings_ec_mxx type="group" translate="label">
|
| 189 |
+
<label>Configuración básica - PayPal Express Checkout</label>
|
| 190 |
+
<frontend_type>text</frontend_type>
|
| 191 |
+
<show_in_default>1</show_in_default>
|
| 192 |
+
<show_in_website>1</show_in_website >
|
| 193 |
+
<show_in_store>1</show_in_store>
|
| 194 |
+
<frontend_model>paypalmx/adminhtml_system_config_fieldset_expanded</frontend_model>
|
| 195 |
+
<sort_order>20</sort_order>
|
| 196 |
+
<fields>
|
| 197 |
+
<sort_order translate="label">
|
| 198 |
+
<label>Orden de acomodo</label>
|
| 199 |
+
<config_path>payment/ppmx/sort_order</config_path>
|
| 200 |
+
<frontend_type>text</frontend_type>
|
| 201 |
+
<tooltip>Establezca el orden en el que desea mostrar la opción del sistema de pago electrónico. El más bajo es desplegado primero</tooltip>
|
| 202 |
+
<sort_order>20</sort_order>
|
| 203 |
+
<show_in_default>1</show_in_default>
|
| 204 |
+
<show_in_website>1</show_in_website>
|
| 205 |
+
<show_in_store>1</show_in_store>
|
| 206 |
+
<frontend_class>validate-number</frontend_class>
|
| 207 |
+
<shared>1</shared>
|
| 208 |
+
</sort_order>
|
| 209 |
+
<payment_action translate="label">
|
| 210 |
+
<label>Acción de Pago</label>
|
| 211 |
+
<comment><![CDATA[“Sale” hará que la venta termine en línea y de forma directa.
|
| 212 |
+
Para utilizar Authorización y Captura por favor refiérase
|
| 213 |
+
<a style="cursor:pointer" onclick="javascript:window.open('https://cms.paypal.com/es/cgi-bin/?cmd=_render-content&content_ID=developer/howto_admin_authcapture','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=800, height=650');"> aquí.</a>]]>
|
| 214 |
+
</comment>
|
| 215 |
+
<config_path>payment/ppmx/payment_action</config_path>
|
| 216 |
+
<frontend_type>select</frontend_type>
|
| 217 |
+
<source_model>paypal/system_config_source_paymentActions_express</source_model>
|
| 218 |
+
<sort_order>30</sort_order>
|
| 219 |
+
<show_in_default>1</show_in_default>
|
| 220 |
+
<show_in_website>1</show_in_website>
|
| 221 |
+
<shared>1</shared>
|
| 222 |
+
</payment_action>
|
| 223 |
+
<visible_on_shipping translate="label">
|
| 224 |
+
<label>Shortcut en el m<![CDATA[é]]>todo de envío</label>
|
| 225 |
+
<config_path>payment/ppmx/visible_on_shipping</config_path>
|
| 226 |
+
<frontend_type>select</frontend_type>
|
| 227 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 228 |
+
<sort_order>35</sort_order>
|
| 229 |
+
<show_in_default>1</show_in_default>
|
| 230 |
+
<show_in_website>1</show_in_website>
|
| 231 |
+
<show_in_store>1</show_in_store>
|
| 232 |
+
<shared>1</shared>
|
| 233 |
+
</visible_on_shipping>
|
| 234 |
+
<activar_mensualidad translate="label">
|
| 235 |
+
<label>Activar pago a mensualidades</label>
|
| 236 |
+
<comment>¿Cómo activar mensualidades? <![CDATA[<a style="cursor:pointer" onclick="javascript:window.open('https://www.paypal.com/mx/webapps/mpp/installments','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=800, height=650');"
|
| 237 |
+
>(Info.)</a>]]> No muestre mensualidades aquí hasta que las haya habilitado en su cuenta PayPal.</comment>
|
| 238 |
+
<config_path>payment/ppmx_mensualidades2/mensualidades</config_path>
|
| 239 |
+
<frontend_type>select</frontend_type>
|
| 240 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 241 |
+
<sort_order>40</sort_order>
|
| 242 |
+
<show_in_default>1</show_in_default>
|
| 243 |
+
<show_in_website>1</show_in_website>
|
| 244 |
+
<show_in_store>1</show_in_store>
|
| 245 |
+
<shared>1</shared>
|
| 246 |
+
</activar_mensualidad>
|
| 247 |
+
<authorization_honor_period translate="label comment">
|
| 248 |
+
<label>Periodo de autorizacion de Honor (días)</label>
|
| 249 |
+
<comment>Especifica que Periodo de autorizacion de honor se tiene en la cuenta de PayPal. Debe reflejar la configuración en Paypal.</comment>
|
| 250 |
+
<config_path>payment/ppmx/authorization_honor_period</config_path>
|
| 251 |
+
<frontend_type>text</frontend_type>
|
| 252 |
+
<sort_order>50</sort_order>
|
| 253 |
+
<show_in_default>1</show_in_default>
|
| 254 |
+
<show_in_website>1</show_in_website>
|
| 255 |
+
<shared>1</shared>
|
| 256 |
+
<depends><payment_action>Order</payment_action></depends>
|
| 257 |
+
</authorization_honor_period>
|
| 258 |
+
<order_valid_period translate="label comment">
|
| 259 |
+
<label>Periodo de valides de orden (días)</label>
|
| 260 |
+
<comment>Especifica el periodo de validez de la orden configurada en la cuenta de PayPal merchant. Debe reflejar la configuración en Paypal.</comment>
|
| 261 |
+
<config_path>payment/ppmx/order_valid_period</config_path>
|
| 262 |
+
<frontend_type>text</frontend_type>
|
| 263 |
+
<sort_order>60</sort_order>
|
| 264 |
+
<show_in_default>1</show_in_default>
|
| 265 |
+
<show_in_website>1</show_in_website>
|
| 266 |
+
<shared>1</shared>
|
| 267 |
+
<depends><payment_action>Order</payment_action></depends>
|
| 268 |
+
</order_valid_period>
|
| 269 |
+
<child_authorization_number translate="label comment">
|
| 270 |
+
<label>Numero de autorizaciones hijas</label>
|
| 271 |
+
<comment>El numero default de tu cuenta PayPal es 1. Para hacer multiples autorizaciones porfavor contactar a PayPal para solicitar un incremento.</comment>
|
| 272 |
+
<config_path>payment/ppmx/child_authorization_number</config_path>
|
| 273 |
+
<frontend_type>text</frontend_type>
|
| 274 |
+
<sort_order>70</sort_order>
|
| 275 |
+
<show_in_default>1</show_in_default>
|
| 276 |
+
<show_in_website>1</show_in_website>
|
| 277 |
+
<shared>1</shared>
|
| 278 |
+
<depends><payment_action>Order</payment_action></depends>
|
| 279 |
+
</child_authorization_number>
|
| 280 |
+
|
| 281 |
+
<settings_ec_advanced_mxx type="group" translate="label">
|
| 282 |
+
<label>Configuración Avanzada</label>
|
| 283 |
+
<frontend_class>config-advanced</frontend_class>
|
| 284 |
+
<frontend_type>text</frontend_type>
|
| 285 |
+
<show_in_default>1</show_in_default>
|
| 286 |
+
<show_in_website>1</show_in_website>
|
| 287 |
+
<show_in_store>1</show_in_store>
|
| 288 |
+
<sort_order>80</sort_order>
|
| 289 |
+
<fields>
|
| 290 |
+
<allowspecific translate="label">
|
| 291 |
+
<label>Permitir pagos de</label>
|
| 292 |
+
<config_path>payment/ppmx/allowspecific</config_path>
|
| 293 |
+
<frontend_type>select</frontend_type>
|
| 294 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 295 |
+
<sort_order>10</sort_order>
|
| 296 |
+
<show_in_default>1</show_in_default>
|
| 297 |
+
<show_in_website>1</show_in_website>
|
| 298 |
+
<shared>1</shared>
|
| 299 |
+
</allowspecific>
|
| 300 |
+
<specificcountry translate="label">
|
| 301 |
+
<label>Paises que aplican el tipo de pago</label>
|
| 302 |
+
<config_path>payment/ppmx/specificcountry</config_path>
|
| 303 |
+
<frontend_type>multiselect</frontend_type>
|
| 304 |
+
<source_model>paypal/system_config_source_buyerCountry</source_model>
|
| 305 |
+
<sort_order>20</sort_order>
|
| 306 |
+
<show_in_default>1</show_in_default>
|
| 307 |
+
<show_in_website>1</show_in_website>
|
| 308 |
+
<depends><allowspecific>1</allowspecific></depends>
|
| 309 |
+
<shared>1</shared>
|
| 310 |
+
</specificcountry>
|
| 311 |
+
<debug translate="label">
|
| 312 |
+
<label>Modo Debug</label>
|
| 313 |
+
<config_path>payment/ppmx/debug</config_path>
|
| 314 |
+
<frontend_type>select</frontend_type>
|
| 315 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 316 |
+
<sort_order>30</sort_order>
|
| 317 |
+
<show_in_default>1</show_in_default>
|
| 318 |
+
<show_in_website>1</show_in_website>
|
| 319 |
+
<shared>1</shared>
|
| 320 |
+
</debug>
|
| 321 |
+
<verify_peer translate="label">
|
| 322 |
+
<label>Habilitar Certificación SSL</label>
|
| 323 |
+
<config_path>payment/ppmx/verify_peer</config_path>
|
| 324 |
+
<frontend_type>select</frontend_type>
|
| 325 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 326 |
+
<sort_order>35</sort_order>
|
| 327 |
+
<show_in_default>1</show_in_default>
|
| 328 |
+
<show_in_website>1</show_in_website>
|
| 329 |
+
<shared>1</shared>
|
| 330 |
+
</verify_peer>
|
| 331 |
+
<express_checkout_settlement_report_xx type="group" translate="label">
|
| 332 |
+
<label>Configuración del Reporte de Solución</label>
|
| 333 |
+
<frontend_type>text</frontend_type>
|
| 334 |
+
<show_in_default>1</show_in_default>
|
| 335 |
+
<show_in_website>1</show_in_website>
|
| 336 |
+
<sort_order>110</sort_order>
|
| 337 |
+
<fields>
|
| 338 |
+
<heading_sftp translate="label">
|
| 339 |
+
<label>Credenciales SFTP</label>
|
| 340 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 341 |
+
<sort_order>10</sort_order>
|
| 342 |
+
<show_in_default>1</show_in_default>
|
| 343 |
+
<show_in_website>1</show_in_website>
|
| 344 |
+
</heading_sftp>
|
| 345 |
+
<settlement_reports_ftp_login translate="label">
|
| 346 |
+
<label>Usuario</label>
|
| 347 |
+
<config_path>paypalmx/fetch_reports/ftp_login</config_path>
|
| 348 |
+
<frontend_type>obscure</frontend_type>
|
| 349 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 350 |
+
<sort_order>20</sort_order>
|
| 351 |
+
<show_in_default>1</show_in_default>
|
| 352 |
+
<show_in_website>1</show_in_website>
|
| 353 |
+
<shared>1</shared>
|
| 354 |
+
</settlement_reports_ftp_login>
|
| 355 |
+
<settlement_reports_ftp_password translate="label">
|
| 356 |
+
<label>Contraseña</label>
|
| 357 |
+
<config_path>paypalmx/fetch_reports/ftp_password</config_path>
|
| 358 |
+
<frontend_type>obscure</frontend_type>
|
| 359 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 360 |
+
<sort_order>30</sort_order>
|
| 361 |
+
<show_in_default>1</show_in_default>
|
| 362 |
+
<show_in_website>1</show_in_website>
|
| 363 |
+
<shared>1</shared>
|
| 364 |
+
</settlement_reports_ftp_password>
|
| 365 |
+
<settlement_reports_ftp_sandbox translate="label">
|
| 366 |
+
<label>Modo Sandbox</label>
|
| 367 |
+
<config_path>paypalmx/fetch_reports/ftp_sandbox</config_path>
|
| 368 |
+
<frontend_type>select</frontend_type>
|
| 369 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 370 |
+
<sort_order>40</sort_order>
|
| 371 |
+
<show_in_default>1</show_in_default>
|
| 372 |
+
<show_in_website>1</show_in_website>
|
| 373 |
+
<shared>1</shared>
|
| 374 |
+
</settlement_reports_ftp_sandbox>
|
| 375 |
+
<settlement_reports_ftp_ip translate="label comment tooltip">
|
| 376 |
+
<label>Nombre del Servidor Personalizado o Dirección IP</label>
|
| 377 |
+
<comment>Por defecto es "reports.paypal.com".</comment>
|
| 378 |
+
<tooltip>Use ":" para especificar el puerto, Por Ejemplo: "test.example.com:5224".</tooltip>
|
| 379 |
+
<config_path>paypalmx/fetch_reports/ftp_ip</config_path>
|
| 380 |
+
<frontend_type>text</frontend_type>
|
| 381 |
+
<sort_order>50</sort_order>
|
| 382 |
+
<show_in_default>1</show_in_default>
|
| 383 |
+
<show_in_website>1</show_in_website>
|
| 384 |
+
<depends><settlement_reports_ftp_sandbox>0</settlement_reports_ftp_sandbox></depends>
|
| 385 |
+
<shared>1</shared>
|
| 386 |
+
</settlement_reports_ftp_ip>
|
| 387 |
+
<settlement_reports_ftp_path translate="label comeent">
|
| 388 |
+
<label>Directorio Personalizado</label>
|
| 389 |
+
<comment>Por defecto es "/ppreports/outgoing".</comment>
|
| 390 |
+
<config_path>paypalmx/fetch_reports/ftp_path</config_path>
|
| 391 |
+
<frontend_type>text</frontend_type>
|
| 392 |
+
<sort_order>60</sort_order>
|
| 393 |
+
<show_in_default>1</show_in_default>
|
| 394 |
+
<show_in_website>1</show_in_website>
|
| 395 |
+
<depends><settlement_reports_ftp_sandbox>0</settlement_reports_ftp_sandbox></depends>
|
| 396 |
+
<shared>1</shared>
|
| 397 |
+
</settlement_reports_ftp_path>
|
| 398 |
+
</fields>
|
| 399 |
+
</express_checkout_settlement_report_xx>
|
| 400 |
+
<express_checkout_frontend_mxx type="group" translate="label">
|
| 401 |
+
<label>Configuración de la página de pagos de PayPal.</label>
|
| 402 |
+
<frontend_type>text</frontend_type>
|
| 403 |
+
<show_in_default>1</show_in_default>
|
| 404 |
+
<show_in_website>1</show_in_website>
|
| 405 |
+
<show_in_store>1</show_in_store>
|
| 406 |
+
<sort_order>120</sort_order>
|
| 407 |
+
<fields>
|
| 408 |
+
<paypal_pages translate="label">
|
| 409 |
+
<label>Estilo de la Página PayPal Merchant</label>
|
| 410 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 411 |
+
<sort_order>20</sort_order>
|
| 412 |
+
<show_in_default>1</show_in_default>
|
| 413 |
+
<show_in_website>1</show_in_website>
|
| 414 |
+
<show_in_store>1</show_in_store>
|
| 415 |
+
<shared>1</shared>
|
| 416 |
+
</paypal_pages>
|
| 417 |
+
<paypal_hdrimg translate='label tooltip'>
|
| 418 |
+
<label>URL de la Imagen de tu Encabezado</label>
|
| 419 |
+
<comment>PayPal rechazará la transacción si se excede el máximo permitido de 127 caracteres en la URL.</comment>
|
| 420 |
+
<config_path>paypalmx/style/paypal_hdrimg</config_path>
|
| 421 |
+
<tooltip><![CDATA[ Ingrese la url para el banner de la empresa (750px de ancho con 90px de alto). Se recomienda que el banner resida en un servidor seguro (<strong style="color:red">SSL</strong>). De lo contrario, en algunos exploradores mostrarán advertencias de que existen elementos no seguros en la página.]]></tooltip>
|
| 422 |
+
<sort_order>40</sort_order>
|
| 423 |
+
<show_in_default>1</show_in_default>
|
| 424 |
+
<show_in_website>1</show_in_website>
|
| 425 |
+
<show_in_store>1</show_in_store>
|
| 426 |
+
<shared>1</shared>
|
| 427 |
+
</paypal_hdrimg>
|
| 428 |
+
<paypal_payflowcolor translate="label tooltip">
|
| 429 |
+
<label>Color de fondo de la página</label>
|
| 430 |
+
<config_path>paypalmx/style/paypal_payflowcolor</config_path>
|
| 431 |
+
<tooltip><![CDATA[El color de gradiente en formato hexadecimal a aplicar al carrito de compras de PayPal.]]></tooltip>
|
| 432 |
+
<sort_order>70</sort_order>
|
| 433 |
+
<show_in_default>1</show_in_default>
|
| 434 |
+
<show_in_website>1</show_in_website>
|
| 435 |
+
<show_in_store>1</show_in_store>
|
| 436 |
+
<shared>1</shared>
|
| 437 |
+
</paypal_payflowcolor>
|
| 438 |
+
</fields>
|
| 439 |
+
</express_checkout_frontend_mxx>
|
| 440 |
+
</fields>
|
| 441 |
+
</settings_ec_advanced_mxx>
|
| 442 |
+
</fields>
|
| 443 |
+
</settings_ec_mxx>
|
| 444 |
+
</fields>
|
| 445 |
+
</ppmxx></paypal_payments>
|
| 446 |
+
</groups>
|
| 447 |
+
</payment>
|
| 448 |
+
</sections>
|
| 449 |
+
</config>
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/install-1.6.0.0.php
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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E.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/** @var $installer Mage_Paypal_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Prepare database for install
|
| 32 |
+
*/
|
| 33 |
+
$installer->startSetup();
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Create table 'paypal/settlement_report'
|
| 37 |
+
*/
|
| 38 |
+
$table = $installer->getConnection()
|
| 39 |
+
->newTable($installer->getTable('paypal/settlement_report'))
|
| 40 |
+
->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 41 |
+
'identity' => true,
|
| 42 |
+
'unsigned' => true,
|
| 43 |
+
'nullable' => false,
|
| 44 |
+
'primary' => true,
|
| 45 |
+
), 'Report Id')
|
| 46 |
+
->addColumn('report_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 47 |
+
), 'Report Date')
|
| 48 |
+
->addColumn('account_id', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
|
| 49 |
+
), 'Account Id')
|
| 50 |
+
->addColumn('filename', Varien_Db_Ddl_Table::TYPE_TEXT, 24, array(
|
| 51 |
+
), 'Filename')
|
| 52 |
+
->addColumn('last_modified', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 53 |
+
), 'Last Modified')
|
| 54 |
+
->addIndex($installer->getIdxName('paypal/settlement_report', array('report_date', 'account_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
| 55 |
+
array('report_date', 'account_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
| 56 |
+
->setComment('Paypal Settlement Report Table');
|
| 57 |
+
$installer->getConnection()->createTable($table);
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Create table 'paypal/settlement_report_row'
|
| 61 |
+
*/
|
| 62 |
+
$table = $installer->getConnection()
|
| 63 |
+
->newTable($installer->getTable('paypal/settlement_report_row'))
|
| 64 |
+
->addColumn('row_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 65 |
+
'identity' => true,
|
| 66 |
+
'unsigned' => true,
|
| 67 |
+
'nullable' => false,
|
| 68 |
+
'primary' => true,
|
| 69 |
+
), 'Row Id')
|
| 70 |
+
->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 71 |
+
'unsigned' => true,
|
| 72 |
+
'nullable' => false,
|
| 73 |
+
), 'Report Id')
|
| 74 |
+
->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, array(
|
| 75 |
+
), 'Transaction Id')
|
| 76 |
+
->addColumn('invoice_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, array(
|
| 77 |
+
), 'Invoice Id')
|
| 78 |
+
->addColumn('paypal_reference_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, array(
|
| 79 |
+
), 'Paypal Reference Id')
|
| 80 |
+
->addColumn('paypal_reference_id_type', Varien_Db_Ddl_Table::TYPE_TEXT, 3, array(
|
| 81 |
+
), 'Paypal Reference Id Type')
|
| 82 |
+
->addColumn('transaction_event_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array(
|
| 83 |
+
), 'Transaction Event Code')
|
| 84 |
+
->addColumn('transaction_initiation_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 85 |
+
), 'Transaction Initiation Date')
|
| 86 |
+
->addColumn('transaction_completion_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 87 |
+
), 'Transaction Completion Date')
|
| 88 |
+
->addColumn('transaction_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, array(
|
| 89 |
+
'nullable' => false,
|
| 90 |
+
'default' => 'CR',
|
| 91 |
+
), 'Transaction Debit Or Credit')
|
| 92 |
+
->addColumn('gross_transaction_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', array(
|
| 93 |
+
'nullable' => false,
|
| 94 |
+
'default' => '0.000000',
|
| 95 |
+
), 'Gross Transaction Amount')
|
| 96 |
+
->addColumn('gross_transaction_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, array(
|
| 97 |
+
'default' => '',
|
| 98 |
+
), 'Gross Transaction Currency')
|
| 99 |
+
->addColumn('fee_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, array(
|
| 100 |
+
), 'Fee Debit Or Credit')
|
| 101 |
+
->addColumn('fee_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', array(
|
| 102 |
+
'nullable' => false,
|
| 103 |
+
'default' => '0.000000',
|
| 104 |
+
), 'Fee Amount')
|
| 105 |
+
->addColumn('fee_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, array(
|
| 106 |
+
), 'Fee Currency')
|
| 107 |
+
->addColumn('custom_field', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 108 |
+
), 'Custom Field')
|
| 109 |
+
->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, array(
|
| 110 |
+
), 'Consumer Id')
|
| 111 |
+
->addIndex($installer->getIdxName('paypal/settlement_report_row', array('report_id')),
|
| 112 |
+
array('report_id'))
|
| 113 |
+
->addForeignKey($installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'),
|
| 114 |
+
'report_id', $installer->getTable('paypal/settlement_report'), 'report_id',
|
| 115 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
| 116 |
+
->setComment('Paypal Settlement Report Row Table');
|
| 117 |
+
$installer->getConnection()->createTable($table);
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* Create table 'paypal/cert'
|
| 121 |
+
*/
|
| 122 |
+
$table = $installer->getConnection()
|
| 123 |
+
->newTable($installer->getTable('paypal/cert'))
|
| 124 |
+
->addColumn('cert_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
| 125 |
+
'identity' => true,
|
| 126 |
+
'unsigned' => true,
|
| 127 |
+
'nullable' => false,
|
| 128 |
+
'primary' => true,
|
| 129 |
+
), 'Cert Id')
|
| 130 |
+
->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
| 131 |
+
'unsigned' => true,
|
| 132 |
+
'nullable' => false,
|
| 133 |
+
'default' => '0'
|
| 134 |
+
), 'Website Id')
|
| 135 |
+
->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '64K', array(
|
| 136 |
+
), 'Content')
|
| 137 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 138 |
+
), 'Updated At')
|
| 139 |
+
->addIndex($installer->getIdxName('paypal/cert', array('website_id')),
|
| 140 |
+
array('website_id'))
|
| 141 |
+
->addForeignKey($installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'),
|
| 142 |
+
'website_id', $installer->getTable('core/website'), 'website_id',
|
| 143 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
| 144 |
+
->setComment('Paypal Certificate Table');
|
| 145 |
+
$installer->getConnection()->createTable($table);
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Add paypal attributes to the:
|
| 149 |
+
* - sales/flat_quote_payment_item table
|
| 150 |
+
* - sales/flat_order table
|
| 151 |
+
*/
|
| 152 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_id', array());
|
| 153 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_status', array());
|
| 154 |
+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', array());
|
| 155 |
+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', array('type' => 'int', 'visible' => false, 'default' => 0));
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* Prepare database after install
|
| 159 |
+
*/
|
| 160 |
+
$installer->endSetup();
|
| 161 |
+
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-install-0.7.0.php
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
$installer = $this;
|
| 29 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 30 |
+
|
| 31 |
+
$installer->startSetup();
|
| 32 |
+
|
| 33 |
+
$installer->run("
|
| 34 |
+
|
| 35 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('paypal_api_debug')}`;
|
| 36 |
+
CREATE TABLE `{$this->getTable('paypal_api_debug')}` (
|
| 37 |
+
`debug_id` int(10) unsigned NOT NULL auto_increment,
|
| 38 |
+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
| 39 |
+
`request_body` text,
|
| 40 |
+
`response_body` text,
|
| 41 |
+
PRIMARY KEY (`debug_id`),
|
| 42 |
+
KEY `debug_at` (`debug_at`)
|
| 43 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 44 |
+
|
| 45 |
+
");
|
| 46 |
+
|
| 47 |
+
$installer->endSetup();
|
| 48 |
+
|
| 49 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_id', array());
|
| 50 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_status', array());
|
| 51 |
+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', array());
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-install-1.4.0.0.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
$installer = $this;
|
| 29 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 30 |
+
|
| 31 |
+
$installer->startSetup();
|
| 32 |
+
|
| 33 |
+
$installer->run("
|
| 34 |
+
CREATE TABLE `{$this->getTable('paypal_api_debug')}` (
|
| 35 |
+
`debug_id` int(10) unsigned NOT NULL auto_increment,
|
| 36 |
+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
| 37 |
+
`request_body` text,
|
| 38 |
+
`response_body` text,
|
| 39 |
+
PRIMARY KEY (`debug_id`),
|
| 40 |
+
KEY `debug_at` (`debug_at`)
|
| 41 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
| 42 |
+
|
| 43 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_id', array());
|
| 44 |
+
$installer->addAttribute('quote_payment', 'paypal_payer_status', array());
|
| 45 |
+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', array());
|
| 46 |
+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', array('type'=>'int', 'visible' => false, 'default' => 0));
|
| 47 |
+
|
| 48 |
+
$installer->endSetup();
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
$installer = $this;
|
| 27 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 28 |
+
$installer->startSetup();
|
| 29 |
+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', array('type'=>'int', 'visible' => false, 'default' => 0));
|
| 30 |
+
$installer->endSetup();
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
$installer = $this;
|
| 27 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 28 |
+
$installer->startSetup();
|
| 29 |
+
|
| 30 |
+
$installer->addAttribute('order_payment', 'cc_secure_verify', array());
|
| 31 |
+
|
| 32 |
+
// move paypal style settings to new paths
|
| 33 |
+
foreach (array(
|
| 34 |
+
'paypal/wpp/page_style' => 'paypal/style/page_style',
|
| 35 |
+
'paypal/wps/logo_url' => 'paypal/style/logo_url',
|
| 36 |
+
) as $from => $to) {
|
| 37 |
+
$installer->run("
|
| 38 |
+
UPDATE {$installer->getTable('core/config_data')} SET `path` = '{$to}'
|
| 39 |
+
WHERE `path` = '{$from}'
|
| 40 |
+
");
|
| 41 |
+
}
|
| 42 |
+
$installer->endSetup();
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
$installer = $this;
|
| 29 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 30 |
+
|
| 31 |
+
$installer->startSetup();
|
| 32 |
+
|
| 33 |
+
$installer->run("
|
| 34 |
+
|
| 35 |
+
CREATE TABLE `{$installer->getTable('paypal_settlement_report')}` (
|
| 36 |
+
`report_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
| 37 |
+
`report_date` date NOT NULL,
|
| 38 |
+
`account_id` varchar(64) NOT NULL,
|
| 39 |
+
`filename` varchar(24) NOT NULL,
|
| 40 |
+
`last_modified` datetime NOT NULL,
|
| 41 |
+
PRIMARY KEY (`report_id`),
|
| 42 |
+
UNIQUE KEY `UNQ_REPORT_DATE_ACCOUNT` (`report_date`,`account_id`)
|
| 43 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 44 |
+
|
| 45 |
+
CREATE TABLE `{$installer->getTable('paypal_settlement_report_row')}` (
|
| 46 |
+
`row_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
| 47 |
+
`report_id` int(10) unsigned NOT NULL,
|
| 48 |
+
`transaction_id` varchar(19) NOT NULL,
|
| 49 |
+
`invoice_id` varchar(127) DEFAULT NULL,
|
| 50 |
+
`paypal_reference_id` varchar(19) NOT NULL,
|
| 51 |
+
`paypal_reference_id_type` enum('ODR','TXN','SUB','PAP','') NOT NULL,
|
| 52 |
+
`transaction_event_code` char(5) NOT NULL DEFAULT '',
|
| 53 |
+
`transaction_initiation_date` datetime DEFAULT NULL,
|
| 54 |
+
`transaction_completion_date` datetime DEFAULT NULL,
|
| 55 |
+
`transaction_debit_or_credit` enum('CR','DR') NOT NULL DEFAULT 'CR',
|
| 56 |
+
`gross_transaction_amount` decimal(20,6) NOT NULL DEFAULT '0.000000',
|
| 57 |
+
`gross_transaction_currency` char(3) NOT NULL DEFAULT '',
|
| 58 |
+
`fee_debit_or_credit` enum('CR','DR') NOT NULL,
|
| 59 |
+
`fee_amount` decimal(20,6) NOT NULL DEFAULT '0.000000',
|
| 60 |
+
`fee_currency` char(3) NOT NULL,
|
| 61 |
+
`custom_field` varchar(255) DEFAULT NULL,
|
| 62 |
+
`consumer_id` varchar(127) NOT NULL DEFAULT '',
|
| 63 |
+
PRIMARY KEY (`row_id`),
|
| 64 |
+
KEY `IDX_REPORT_ID` (`report_id`)
|
| 65 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 66 |
+
|
| 67 |
+
ALTER TABLE `{$installer->getTable('paypal_settlement_report_row')}`
|
| 68 |
+
ADD CONSTRAINT `FK_PAYPAL_SETTLEMENT_ROW_REPORT` FOREIGN KEY (`report_id`) REFERENCES `{$installer->getTable('paypal_settlement_report')}` (`report_id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
| 69 |
+
|
| 70 |
+
");
|
| 71 |
+
|
| 72 |
+
$installer->endSetup();
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/* @var $installer Mage_Paypal_Model_Mysql4_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
$installer->run("
|
| 31 |
+
CREATE TABLE `{$installer->getTable('paypal/cert')}` (
|
| 32 |
+
`cert_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 33 |
+
`website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
|
| 34 |
+
`content` MEDIUMBLOB NOT NULL,
|
| 35 |
+
`updated_at` datetime default NULL,
|
| 36 |
+
PRIMARY KEY (`cert_id`),
|
| 37 |
+
KEY `IDX_PAYPAL_CERT_WEBSITE` (`website_id`)
|
| 38 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 39 |
+
");
|
| 40 |
+
|
| 41 |
+
$installer->getConnection()->addConstraint(
|
| 42 |
+
'FK_PAYPAL_CERT_WEBSITE',
|
| 43 |
+
$this->getTable('paypal/cert'),
|
| 44 |
+
'website_id',
|
| 45 |
+
$this->getTable('core/website'),
|
| 46 |
+
'website_id'
|
| 47 |
+
);
|
app/code/community/Ebc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that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
$installer->startSetup();
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Drop foreign keys
|
| 33 |
+
*/
|
| 34 |
+
$installer->getConnection()->dropForeignKey(
|
| 35 |
+
$installer->getTable('paypal/cert'),
|
| 36 |
+
'FK_PAYPAL_CERT_WEBSITE'
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
$installer->getConnection()->dropForeignKey(
|
| 40 |
+
$installer->getTable('paypal/settlement_report_row'),
|
| 41 |
+
'FK_PAYPAL_SETTLEMENT_ROW_REPORT'
|
| 42 |
+
);
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Drop indexes
|
| 47 |
+
*/
|
| 48 |
+
$installer->getConnection()->dropIndex(
|
| 49 |
+
$installer->getTable('paypal/cert'),
|
| 50 |
+
'IDX_PAYPAL_CERT_WEBSITE'
|
| 51 |
+
);
|
| 52 |
+
|
| 53 |
+
$installer->getConnection()->dropIndex(
|
| 54 |
+
$installer->getTable('paypal/settlement_report'),
|
| 55 |
+
'UNQ_REPORT_DATE_ACCOUNT'
|
| 56 |
+
);
|
| 57 |
+
|
| 58 |
+
$installer->getConnection()->dropIndex(
|
| 59 |
+
$installer->getTable('paypal/settlement_report_row'),
|
| 60 |
+
'IDX_REPORT_ID'
|
| 61 |
+
);
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Change columns
|
| 66 |
+
*/
|
| 67 |
+
$tables = array(
|
| 68 |
+
$installer->getTable('paypal/settlement_report') => array(
|
| 69 |
+
'columns' => array(
|
| 70 |
+
'report_id' => array(
|
| 71 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 72 |
+
'identity' => true,
|
| 73 |
+
'unsigned' => true,
|
| 74 |
+
'nullable' => false,
|
| 75 |
+
'primary' => true,
|
| 76 |
+
'comment' => 'Report Id'
|
| 77 |
+
),
|
| 78 |
+
'report_date' => array(
|
| 79 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
| 80 |
+
'comment' => 'Report Date'
|
| 81 |
+
),
|
| 82 |
+
'account_id' => array(
|
| 83 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 84 |
+
'length' => 64,
|
| 85 |
+
'comment' => 'Account Id'
|
| 86 |
+
),
|
| 87 |
+
'filename' => array(
|
| 88 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 89 |
+
'length' => 24,
|
| 90 |
+
'comment' => 'Filename'
|
| 91 |
+
),
|
| 92 |
+
'last_modified' => array(
|
| 93 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
| 94 |
+
'comment' => 'Last Modified'
|
| 95 |
+
)
|
| 96 |
+
),
|
| 97 |
+
'comment' => 'Paypal Settlement Report Table'
|
| 98 |
+
),
|
| 99 |
+
$installer->getTable('paypal/settlement_report_row') => array(
|
| 100 |
+
'columns' => array(
|
| 101 |
+
'row_id' => array(
|
| 102 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 103 |
+
'identity' => true,
|
| 104 |
+
'unsigned' => true,
|
| 105 |
+
'nullable' => false,
|
| 106 |
+
'primary' => true,
|
| 107 |
+
'comment' => 'Row Id'
|
| 108 |
+
),
|
| 109 |
+
'report_id' => array(
|
| 110 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 111 |
+
'unsigned' => true,
|
| 112 |
+
'nullable' => false,
|
| 113 |
+
'comment' => 'Report Id'
|
| 114 |
+
),
|
| 115 |
+
'transaction_id' => array(
|
| 116 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 117 |
+
'length' => 19,
|
| 118 |
+
'comment' => 'Transaction Id'
|
| 119 |
+
),
|
| 120 |
+
'invoice_id' => array(
|
| 121 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 122 |
+
'length' => 127,
|
| 123 |
+
'comment' => 'Invoice Id'
|
| 124 |
+
),
|
| 125 |
+
'paypal_reference_id' => array(
|
| 126 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 127 |
+
'length' => 19,
|
| 128 |
+
'comment' => 'Paypal Reference Id'
|
| 129 |
+
),
|
| 130 |
+
'paypal_reference_id_type' => array(
|
| 131 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 132 |
+
'length' => 3,
|
| 133 |
+
'comment' => 'Paypal Reference Id Type'
|
| 134 |
+
),
|
| 135 |
+
'transaction_event_code' => array(
|
| 136 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 137 |
+
'length' => 5,
|
| 138 |
+
'comment' => 'Transaction Event Code'
|
| 139 |
+
),
|
| 140 |
+
'transaction_initiation_date' => array(
|
| 141 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
| 142 |
+
'comment' => 'Transaction Initiation Date'
|
| 143 |
+
),
|
| 144 |
+
'transaction_completion_date' => array(
|
| 145 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
| 146 |
+
'comment' => 'Transaction Completion Date'
|
| 147 |
+
),
|
| 148 |
+
'transaction_debit_or_credit' => array(
|
| 149 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 150 |
+
'length' => 2,
|
| 151 |
+
'nullable' => false,
|
| 152 |
+
'default' => 'CR',
|
| 153 |
+
'comment' => 'Transaction Debit Or Credit'
|
| 154 |
+
),
|
| 155 |
+
'gross_transaction_amount' => array(
|
| 156 |
+
'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL,
|
| 157 |
+
'scale' => 6,
|
| 158 |
+
'precision' => 20,
|
| 159 |
+
'nullable' => false,
|
| 160 |
+
'default' => '0.000000',
|
| 161 |
+
'comment' => 'Gross Transaction Amount'
|
| 162 |
+
),
|
| 163 |
+
'gross_transaction_currency' => array(
|
| 164 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 165 |
+
'length' => 3,
|
| 166 |
+
'default' => '',
|
| 167 |
+
'comment' => 'Gross Transaction Currency'
|
| 168 |
+
),
|
| 169 |
+
'fee_debit_or_credit' => array(
|
| 170 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 171 |
+
'length' => 2,
|
| 172 |
+
'comment' => 'Fee Debit Or Credit'
|
| 173 |
+
),
|
| 174 |
+
'fee_amount' => array(
|
| 175 |
+
'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL,
|
| 176 |
+
'scale' => 6,
|
| 177 |
+
'precision' => 20,
|
| 178 |
+
'nullable' => false,
|
| 179 |
+
'default' => '0.000000',
|
| 180 |
+
'comment' => 'Fee Amount'
|
| 181 |
+
),
|
| 182 |
+
'fee_currency' => array(
|
| 183 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 184 |
+
'length' => 3,
|
| 185 |
+
'comment' => 'Fee Currency'
|
| 186 |
+
),
|
| 187 |
+
'custom_field' => array(
|
| 188 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 189 |
+
'length' => 255,
|
| 190 |
+
'comment' => 'Custom Field'
|
| 191 |
+
),
|
| 192 |
+
'consumer_id' => array(
|
| 193 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 194 |
+
'length' => 127,
|
| 195 |
+
'comment' => 'Consumer Id'
|
| 196 |
+
)
|
| 197 |
+
),
|
| 198 |
+
'comment' => 'Paypal Settlement Report Row Table'
|
| 199 |
+
),
|
| 200 |
+
$installer->getTable('paypal/cert') => array(
|
| 201 |
+
'columns' => array(
|
| 202 |
+
'cert_id' => array(
|
| 203 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
| 204 |
+
'identity' => true,
|
| 205 |
+
'unsigned' => true,
|
| 206 |
+
'nullable' => false,
|
| 207 |
+
'primary' => true,
|
| 208 |
+
'comment' => 'Cert Id'
|
| 209 |
+
),
|
| 210 |
+
'website_id' => array(
|
| 211 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
| 212 |
+
'unsigned' => true,
|
| 213 |
+
'nullable' => false,
|
| 214 |
+
'default' => '0',
|
| 215 |
+
'comment' => 'Website Id'
|
| 216 |
+
),
|
| 217 |
+
'content' => array(
|
| 218 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 219 |
+
'length' => '64K',
|
| 220 |
+
'comment' => 'Content'
|
| 221 |
+
),
|
| 222 |
+
'updated_at' => array(
|
| 223 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
| 224 |
+
'comment' => 'Updated At'
|
| 225 |
+
)
|
| 226 |
+
),
|
| 227 |
+
'comment' => 'Paypal Certificate Table'
|
| 228 |
+
),
|
| 229 |
+
$installer->getTable('sales/quote_payment') => array(
|
| 230 |
+
'columns' => array(
|
| 231 |
+
'paypal_payer_id' => array(
|
| 232 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 233 |
+
'length' => 255,
|
| 234 |
+
'comment' => 'Paypal Payer Id'
|
| 235 |
+
),
|
| 236 |
+
'paypal_payer_status' => array(
|
| 237 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 238 |
+
'length' => 255,
|
| 239 |
+
'comment' => 'Paypal Payer Status'
|
| 240 |
+
),
|
| 241 |
+
'paypal_correlation_id' => array(
|
| 242 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 243 |
+
'length' => 255,
|
| 244 |
+
'comment' => 'Paypal Correlation Id'
|
| 245 |
+
)
|
| 246 |
+
)
|
| 247 |
+
),
|
| 248 |
+
$installer->getTable('sales/order') => array(
|
| 249 |
+
'columns' => array(
|
| 250 |
+
'paypal_ipn_customer_notified' => array(
|
| 251 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 252 |
+
'comment' => 'Paypal Ipn Customer Notified'
|
| 253 |
+
)
|
| 254 |
+
)
|
| 255 |
+
)
|
| 256 |
+
);
|
| 257 |
+
|
| 258 |
+
$installer->getConnection()->modifyTables($tables);
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* Add indexes
|
| 263 |
+
*/
|
| 264 |
+
$installer->getConnection()->addIndex(
|
| 265 |
+
$installer->getTable('paypal/cert'),
|
| 266 |
+
$installer->getIdxName('paypal/cert', array('website_id')),
|
| 267 |
+
array('website_id')
|
| 268 |
+
);
|
| 269 |
+
|
| 270 |
+
$installer->getConnection()->addIndex(
|
| 271 |
+
$installer->getTable('paypal/settlement_report'),
|
| 272 |
+
$installer->getIdxName(
|
| 273 |
+
'paypal/settlement_report',
|
| 274 |
+
array('report_date', 'account_id'),
|
| 275 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
| 276 |
+
),
|
| 277 |
+
array('report_date', 'account_id'),
|
| 278 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
| 279 |
+
);
|
| 280 |
+
|
| 281 |
+
$installer->getConnection()->addIndex(
|
| 282 |
+
$installer->getTable('paypal/settlement_report_row'),
|
| 283 |
+
$installer->getIdxName('paypal/settlement_report_row', array('report_id')),
|
| 284 |
+
array('report_id')
|
| 285 |
+
);
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* Add foreign keys
|
| 290 |
+
*/
|
| 291 |
+
$installer->getConnection()->addForeignKey(
|
| 292 |
+
$installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'),
|
| 293 |
+
$installer->getTable('paypal/settlement_report_row'),
|
| 294 |
+
'report_id',
|
| 295 |
+
$installer->getTable('paypal/settlement_report'),
|
| 296 |
+
'report_id'
|
| 297 |
+
);
|
| 298 |
+
|
| 299 |
+
$installer->getConnection()->addForeignKey(
|
| 300 |
+
$installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'),
|
| 301 |
+
$installer->getTable('paypal/cert'),
|
| 302 |
+
'website_id',
|
| 303 |
+
$installer->getTable('core/website'),
|
| 304 |
+
'website_id'
|
| 305 |
+
);
|
| 306 |
+
|
| 307 |
+
$installer->endSetup();
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/** @var $installer Mage_Paypal_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Create table 'paypal/payment_transaction'
|
| 32 |
+
*/
|
| 33 |
+
$table = $installer->getConnection()
|
| 34 |
+
->newTable($installer->getTable('paypal/payment_transaction'))
|
| 35 |
+
->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 36 |
+
'identity' => true,
|
| 37 |
+
'unsigned' => true,
|
| 38 |
+
'nullable' => false,
|
| 39 |
+
'primary' => true,
|
| 40 |
+
), 'Entity Id')
|
| 41 |
+
->addColumn('txn_id', Varien_Db_Ddl_Table::TYPE_TEXT, 100, array(
|
| 42 |
+
), 'Txn Id')
|
| 43 |
+
->addColumn('additional_information', Varien_Db_Ddl_Table::TYPE_BLOB, '64K', array(
|
| 44 |
+
), 'Additional Information')
|
| 45 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 46 |
+
), 'Created At')
|
| 47 |
+
->addIndex(
|
| 48 |
+
$installer->getIdxName(
|
| 49 |
+
'paypal/payment_transaction',
|
| 50 |
+
array('txn_id'),
|
| 51 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
| 52 |
+
),
|
| 53 |
+
array('txn_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
| 54 |
+
->setComment('PayPal Payflow Link Payment Transaction');
|
| 55 |
+
$installer->getConnection()->createTable($table);
|
app/code/community/Ebcomm/PaypalMx/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/** @var $installer Mage_Paypal_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
$installer->getConnection()
|
| 31 |
+
->addColumn($installer->getTable('paypal/settlement_report_row'), 'payment_tracking_id', array(
|
| 32 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 33 |
+
'comment' => 'Payment Tracking ID',
|
| 34 |
+
'length' => '255'
|
| 35 |
+
));
|
app/design/adminhtml/default/default/template/paypalmx/system/config/api_wizard.phtml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @see Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard
|
| 4 |
+
*/
|
| 5 |
+
?>
|
| 6 |
+
<div class="pp-buttons-container">
|
| 7 |
+
<button onclick="javascript:window.open('<?php echo $this->getButtonUrl()?>', 'apiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=380, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
|
| 8 |
+
<span><span><span><?php echo $this->escapeHtml($this->getButtonLabel()); ?></span></span></span>
|
| 9 |
+
</button>
|
| 10 |
+
<button onclick="javascript:window.open('<?php echo $this->getSandboxButtonUrl()?>', 'apiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=380, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getSandboxHtmlId() ?>">
|
| 11 |
+
<span><span><span><?php echo $this->escapeHtml($this->getSandboxButtonLabel()); ?></span></span></span>
|
| 12 |
+
</button>
|
| 13 |
+
</div>
|
app/design/adminhtml/default/default/template/paypalmx/system/config/fieldset/global.phtml
ADDED
|
@@ -0,0 +1,600 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package default_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<?php
|
| 28 |
+
/**
|
| 29 |
+
* @see Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global
|
| 30 |
+
* @deprecated since 1.7.0.1
|
| 31 |
+
*/
|
| 32 |
+
?>
|
| 33 |
+
<table class="paypal-selection" id="paypal_checkout" cellspacing="0">
|
| 34 |
+
<col width="75%" />
|
| 35 |
+
<col width="25%" />
|
| 36 |
+
<thead>
|
| 37 |
+
<tr>
|
| 38 |
+
<th><?php echo $this->escapeHtml($this->getFieldsetLabel()) ?></th>
|
| 39 |
+
<th class="paypal-selection-info"><a href="<?php echo $this->escapeHtml($this->getFieldsetHelpUrl()) ?>"><?php echo Mage::helper('paypal')->__('Help')?></a></th>
|
| 40 |
+
</tr>
|
| 41 |
+
</thead>
|
| 42 |
+
<tbody>
|
| 43 |
+
<?php foreach($this->getElements() as $htmlId => $element): ?>
|
| 44 |
+
<tr>
|
| 45 |
+
<?php if ($this->getIsElementSimplified($element)):?>
|
| 46 |
+
<td colspan="2" class="paypal-selection-simplified">
|
| 47 |
+
<?php if ($this->hasInheritElement($element)): ?>
|
| 48 |
+
<div><?php echo $this->getInheritElementHtml($element) ?><?php echo $this->getInheritElementLabelHtml($element) ?></div>
|
| 49 |
+
<?php endif;?>
|
| 50 |
+
<label for="<?php echo $htmlId?>"><?php echo $this->getElementHtml($element) ?><strong><?php echo $this->getElementLabelTextHtml($element)?></strong> – <?php echo $this->escapeHtml($this->getElementComment($element))?></label>
|
| 51 |
+
</td>
|
| 52 |
+
<?php else:?>
|
| 53 |
+
<td>
|
| 54 |
+
<?php if ($this->hasInheritElement($element)): ?>
|
| 55 |
+
<div><?php echo $this->getInheritElementHtml($element) ?><?php echo $this->getInheritElementLabelHtml($element) ?></div>
|
| 56 |
+
<?php endif;?>
|
| 57 |
+
<label for="<?php echo $htmlId?>"><?php echo $this->getElementHtml($element) ?><strong><?php echo $this->getElementLabelTextHtml($element)?></strong> – <?php echo $this->getElementComment($element)?></label>
|
| 58 |
+
</td>
|
| 59 |
+
<td class="paypal-selection-info">
|
| 60 |
+
<?php if ($url = $this->getElementOriginalData($element, 'demo_url')):?>
|
| 61 |
+
<a id="<?php echo $element->getHtmlId()?>_demo_url" href="<?php echo $this->escapeHtml($url) ?>"><?php echo Mage::helper('paypal')->__('View Demo')?></a> |
|
| 62 |
+
<?php endif;?>
|
| 63 |
+
<?php if ($url = $this->getElementOriginalData($element, 'more_url')):?>
|
| 64 |
+
<a id="<?php echo $element->getHtmlId()?>_more_url" href="<?php echo $this->escapeHtml($url) ?>"><?php echo Mage::helper('paypal')->__('Learn More')?></a>
|
| 65 |
+
<?php endif;?>
|
| 66 |
+
</td>
|
| 67 |
+
<?php endif;?>
|
| 68 |
+
</tr>
|
| 69 |
+
<?php endforeach;?>
|
| 70 |
+
</tbody>
|
| 71 |
+
</table>
|
| 72 |
+
|
| 73 |
+
<script type="text/javascript">
|
| 74 |
+
|
| 75 |
+
Event.observe(window, 'load', function() {
|
| 76 |
+
var pConfig = new PaypalConfig;
|
| 77 |
+
Element.observe('paypal_account_business_account', 'change', pConfig.trackBusinessAccount.bind(pConfig));
|
| 78 |
+
Element.observe('paypal_account_merchant_country', 'change', pConfig.trackMerchantCountry.bind(pConfig));
|
| 79 |
+
Element.observe('paypal_global_wpp', 'click', pConfig.trackWpp.bind(pConfig));
|
| 80 |
+
Element.observe('paypal_global_wpp_pe', 'click', pConfig.trackWppPe.bind(pConfig));
|
| 81 |
+
Element.observe('paypal_global_payflow_link', 'click', pConfig.trackWppPl.bind(pConfig));
|
| 82 |
+
Element.observe('paypal_global_payflow_advanced', 'click', pConfig.trackWppPa.bind(pConfig));
|
| 83 |
+
Element.observe('paypal_global_hosted_pro', 'click', pConfig.trackHss.bind(pConfig));
|
| 84 |
+
Element.observe('paypal_global_verisign', 'click', pConfig.trackPayflowpro.bind(pConfig));
|
| 85 |
+
['ec','wps','ecpe'].each(function(m) {
|
| 86 |
+
Element.observe(pConfig.getMethodSwitcher(m).id, 'click', pConfig.trackMethod.bind(pConfig, m));
|
| 87 |
+
});
|
| 88 |
+
pConfig.fastMode = true;
|
| 89 |
+
pConfig.trackMerchantCountry();
|
| 90 |
+
pConfig.trackBusinessAccount();
|
| 91 |
+
pConfig.trackWpp();
|
| 92 |
+
pConfig.trackWppPl();
|
| 93 |
+
pConfig.trackWppPa();
|
| 94 |
+
pConfig.trackWppPe();
|
| 95 |
+
pConfig.trackWps();
|
| 96 |
+
pConfig.trackHss();
|
| 97 |
+
['ec','wps','ecpe'].each(function(m) {
|
| 98 |
+
pConfig.trackMethod(m);
|
| 99 |
+
});
|
| 100 |
+
pConfig.trackPayflowpro();
|
| 101 |
+
pConfig.fastMode = false;
|
| 102 |
+
pConfig.destruct();
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
PaypalConfig = Class.create();
|
| 106 |
+
PaypalConfig.prototype = {
|
| 107 |
+
initialize: function(){
|
| 108 |
+
this.methods = $H({
|
| 109 |
+
ec: $H({
|
| 110 |
+
switcher: 'express',
|
| 111 |
+
fieldset: 'express',
|
| 112 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 113 |
+
$this->getElement('paypal_global_express'));
|
| 114 |
+
?>)
|
| 115 |
+
}),
|
| 116 |
+
wps: $H({
|
| 117 |
+
switcher: 'wps',
|
| 118 |
+
fieldset: 'wps',
|
| 119 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 120 |
+
$this->getElement('paypal_global_wps'));
|
| 121 |
+
?>)
|
| 122 |
+
}),
|
| 123 |
+
wpp: $H({
|
| 124 |
+
switcher: 'wpp',
|
| 125 |
+
fieldset: 'wpp',
|
| 126 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 127 |
+
$this->getElement('paypal_global_wpp'));
|
| 128 |
+
?>)
|
| 129 |
+
}),
|
| 130 |
+
wpppe: $H({
|
| 131 |
+
switcher: 'wpp_pe',
|
| 132 |
+
fieldset: 'wpp_pe',
|
| 133 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 134 |
+
$this->getElement('paypal_global_wpp_pe'));
|
| 135 |
+
?>)
|
| 136 |
+
}),
|
| 137 |
+
wpppl: $H({
|
| 138 |
+
switcher: 'payflow_link',
|
| 139 |
+
fieldset: 'payflow_link',
|
| 140 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 141 |
+
$this->getElement('paypal_global_payflow_link'));
|
| 142 |
+
?>)
|
| 143 |
+
}),
|
| 144 |
+
wpppa: $H({
|
| 145 |
+
switcher: 'payflow_advanced',
|
| 146 |
+
fieldset: 'payflow_advanced',
|
| 147 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 148 |
+
$this->getElement('paypal_global_payflow_advanced'));
|
| 149 |
+
?>)
|
| 150 |
+
}),
|
| 151 |
+
ecpe: $H({
|
| 152 |
+
switcher: 'express_pe',
|
| 153 |
+
fieldset: 'express_pe',
|
| 154 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 155 |
+
$this->getElement('paypal_global_express_pe'));
|
| 156 |
+
?>)
|
| 157 |
+
}),
|
| 158 |
+
payflowpro: $H({
|
| 159 |
+
switcher: 'verisign',
|
| 160 |
+
fieldset: 'verisign',
|
| 161 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 162 |
+
$this->getElement('paypal_global_verisign'));
|
| 163 |
+
?>)
|
| 164 |
+
}),
|
| 165 |
+
hosted_pro: $H({
|
| 166 |
+
switcher: 'hosted_pro',
|
| 167 |
+
fieldset: 'hosted_pro',
|
| 168 |
+
backendConfig : $H(<?php echo $this->getElementBackendConfig(
|
| 169 |
+
$this->getElement('paypal_global_hosted_pro'));
|
| 170 |
+
?>)
|
| 171 |
+
})
|
| 172 |
+
});
|
| 173 |
+
this.disabledMethods = [];
|
| 174 |
+
},
|
| 175 |
+
|
| 176 |
+
getMethods: function()
|
| 177 |
+
{
|
| 178 |
+
return this.methods;
|
| 179 |
+
},
|
| 180 |
+
|
| 181 |
+
getMethod: function(method)
|
| 182 |
+
{
|
| 183 |
+
return this.methods.get(method);
|
| 184 |
+
},
|
| 185 |
+
|
| 186 |
+
isDisabled: function(method)
|
| 187 |
+
{
|
| 188 |
+
return this.disabledMethods.indexOf(method) != -1;
|
| 189 |
+
},
|
| 190 |
+
|
| 191 |
+
isHidden: function(method)
|
| 192 |
+
{
|
| 193 |
+
if (this.getMethod(method).get('hidden')) {
|
| 194 |
+
return true;
|
| 195 |
+
}
|
| 196 |
+
return false;
|
| 197 |
+
},
|
| 198 |
+
|
| 199 |
+
getMethodFieldset: function(method)
|
| 200 |
+
{
|
| 201 |
+
var fieldsetId = 'paypal_' + this.getMethod(method).get('fieldset');
|
| 202 |
+
return $(fieldsetId);
|
| 203 |
+
},
|
| 204 |
+
|
| 205 |
+
getMethodFieldsetHeadingLink: function(fieldset)
|
| 206 |
+
{
|
| 207 |
+
var heading = fieldset.previous('div');
|
| 208 |
+
return heading.down('a');
|
| 209 |
+
},
|
| 210 |
+
|
| 211 |
+
getMethodSwitcher: function(method)
|
| 212 |
+
{
|
| 213 |
+
var switcherId = 'paypal_global_' + this.getMethod(method).get('switcher');
|
| 214 |
+
return $(switcherId);
|
| 215 |
+
},
|
| 216 |
+
|
| 217 |
+
getMethodSwitcherValue: function(method)
|
| 218 |
+
{
|
| 219 |
+
var switcherValueId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_value';
|
| 220 |
+
return $(switcherValueId);
|
| 221 |
+
},
|
| 222 |
+
|
| 223 |
+
getMethodSwitcherLabelText: function(method)
|
| 224 |
+
{
|
| 225 |
+
var switcherValueId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_label_text';
|
| 226 |
+
return $(switcherValueId);
|
| 227 |
+
},
|
| 228 |
+
|
| 229 |
+
getMethodLinkDemoUrl: function(method)
|
| 230 |
+
{
|
| 231 |
+
return $('paypal_global_' + this.getMethod(method).get('switcher') + '_demo_url');
|
| 232 |
+
},
|
| 233 |
+
|
| 234 |
+
getMethodLinkMoreUrl: function(method)
|
| 235 |
+
{
|
| 236 |
+
return $('paypal_global_' + this.getMethod(method).get('switcher') + '_more_url');
|
| 237 |
+
},
|
| 238 |
+
|
| 239 |
+
getMethodSwitcherInherit: function(method)
|
| 240 |
+
{
|
| 241 |
+
var inheritId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_inherit';
|
| 242 |
+
return $(inheritId);
|
| 243 |
+
},
|
| 244 |
+
|
| 245 |
+
markMethodAsReadonly: function(method, readonly)
|
| 246 |
+
{
|
| 247 |
+
if (readonly == undefined) {
|
| 248 |
+
readonly = true;
|
| 249 |
+
}
|
| 250 |
+
if (this.isDisabled(method) && !readonly || this.isHidden(method)) {
|
| 251 |
+
return;
|
| 252 |
+
}
|
| 253 |
+
if (this.fastMode) {
|
| 254 |
+
this.getMethod(method).set('readonly', readonly);
|
| 255 |
+
return;
|
| 256 |
+
}
|
| 257 |
+
var inherit = this.getMethodSwitcherInherit(method);
|
| 258 |
+
if (inherit != undefined) {
|
| 259 |
+
inherit.disabled = readonly;
|
| 260 |
+
if (!inherit.disabled && inherit.checked) {
|
| 261 |
+
readonly = true;
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
this.getMethodSwitcherValue(method).value = this.getMethodSwitcher(method).checked ? '1' : '0';
|
| 265 |
+
this.getMethodSwitcher(method).disabled = readonly;
|
| 266 |
+
},
|
| 267 |
+
|
| 268 |
+
enableMethod: function(method, readonly)
|
| 269 |
+
{
|
| 270 |
+
if (this.isDisabled(method) || this.isHidden(method)) {
|
| 271 |
+
return;
|
| 272 |
+
}
|
| 273 |
+
readonly = (readonly == undefined ? false : readonly);
|
| 274 |
+
if (this.fastMode) {
|
| 275 |
+
this.getMethod(method).set('disabled', false);
|
| 276 |
+
this.getMethod(method).set('readonly', readonly);
|
| 277 |
+
return;
|
| 278 |
+
}
|
| 279 |
+
this.getMethodSwitcher(method).checked = true;
|
| 280 |
+
this.markMethodAsReadonly(method, readonly);
|
| 281 |
+
this.toggleFieldset(this.getMethodFieldset(method), this.getMethodSwitcher(method));
|
| 282 |
+
},
|
| 283 |
+
|
| 284 |
+
disableMethod: function(method, readonly)
|
| 285 |
+
{
|
| 286 |
+
if (this.isHidden(method)) {
|
| 287 |
+
return;
|
| 288 |
+
}
|
| 289 |
+
readonly = (readonly == undefined ? true : readonly);
|
| 290 |
+
if (this.fastMode) {
|
| 291 |
+
this.getMethod(method).set('disabled', true);
|
| 292 |
+
this.getMethod(method).set('readonly', readonly);
|
| 293 |
+
return;
|
| 294 |
+
}
|
| 295 |
+
this.getMethodSwitcher(method).checked = false;
|
| 296 |
+
this.markMethodAsReadonly(method, readonly);
|
| 297 |
+
this.toggleFieldset(this.getMethodFieldset(method), this.getMethodSwitcher(method));
|
| 298 |
+
},
|
| 299 |
+
|
| 300 |
+
toggleMethodVisibility: function(method, isHidden)
|
| 301 |
+
{
|
| 302 |
+
var selection = this.getMethodSwitcher(method).up('tr');
|
| 303 |
+
var fieldset = this.getMethodFieldset(method);
|
| 304 |
+
var fieldsetHead = fieldset.previous('div');
|
| 305 |
+
[selection, fieldset, fieldsetHead].each(function(e) {
|
| 306 |
+
isHidden ? e.hide() : e.show();
|
| 307 |
+
});
|
| 308 |
+
// do not show fieldset for turned off methods
|
| 309 |
+
if (!isHidden && !this.getMethodSwitcher(method).checked) {
|
| 310 |
+
fieldset.hide();
|
| 311 |
+
}
|
| 312 |
+
this.getMethod(method).set('hidden', isHidden);
|
| 313 |
+
},
|
| 314 |
+
|
| 315 |
+
hideMethod: function(method)
|
| 316 |
+
{
|
| 317 |
+
this.toggleMethodVisibility(method, true);
|
| 318 |
+
},
|
| 319 |
+
|
| 320 |
+
showMethod: function(method)
|
| 321 |
+
{
|
| 322 |
+
this.toggleMethodVisibility(method, false);
|
| 323 |
+
},
|
| 324 |
+
|
| 325 |
+
trackMethod: function(method)
|
| 326 |
+
{
|
| 327 |
+
var switcher = this.getMethodSwitcher(method);
|
| 328 |
+
if (!switcher.checked && this.fastMode || !this.fastMode) {
|
| 329 |
+
this.toggleFieldset(this.getMethodFieldset(method), switcher);
|
| 330 |
+
}
|
| 331 |
+
this.getMethodSwitcherValue(method).value = switcher.checked ? '1' : '0';
|
| 332 |
+
},
|
| 333 |
+
|
| 334 |
+
trackMerchantCountry: function()
|
| 335 |
+
{
|
| 336 |
+
this.disabledMethods = [];
|
| 337 |
+
this.getMethods().keys().each(function(methodKey) {
|
| 338 |
+
this.applyMethodConfig(methodKey);
|
| 339 |
+
}.bind(this));
|
| 340 |
+
|
| 341 |
+
this.trackBusinessAccount();
|
| 342 |
+
this.trackWpp();
|
| 343 |
+
this.trackWppPe();
|
| 344 |
+
this.trackWps();
|
| 345 |
+
},
|
| 346 |
+
|
| 347 |
+
applyMethodConfig: function(methodKey)
|
| 348 |
+
{
|
| 349 |
+
var country = $('paypal_account_merchant_country').value;
|
| 350 |
+
var config = this.getMethod(methodKey).get('backendConfig');
|
| 351 |
+
if (!config) {
|
| 352 |
+
return false;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
var isMethodEnable = false;
|
| 356 |
+
var enableForCountries = config.get('enable_for_countries');
|
| 357 |
+
var disableForCountries = config.get('disable_for_countries');
|
| 358 |
+
var labels = config.get('labels');
|
| 359 |
+
|
| 360 |
+
if (enableForCountries
|
| 361 |
+
&& (enableForCountries.indexOf(country) > -1 || enableForCountries.indexOf('all') > -1)) {
|
| 362 |
+
isMethodEnable = true;
|
| 363 |
+
}
|
| 364 |
+
if (disableForCountries
|
| 365 |
+
&& (disableForCountries.indexOf(country) > -1 || disableForCountries.indexOf('all') > -1)) {
|
| 366 |
+
isMethodEnable = false;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
if (isMethodEnable) {
|
| 370 |
+
this.showMethod(methodKey);
|
| 371 |
+
this.markMethodAsReadonly(methodKey, false);
|
| 372 |
+
} else {
|
| 373 |
+
this.disableMethod(methodKey);
|
| 374 |
+
this.disabledMethods.push(methodKey);
|
| 375 |
+
this.hideMethod(methodKey);
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
if (labels) {
|
| 379 |
+
var switcherLabelElement = this.getMethodSwitcherLabelText(methodKey);
|
| 380 |
+
var fieldsetLabelElement = this.getMethodFieldsetHeadingLink(this.getMethodFieldset(methodKey));
|
| 381 |
+
if (!labels['default']) {
|
| 382 |
+
labels['default'] = {
|
| 383 |
+
switcher: switcherLabelElement.innerHTML,
|
| 384 |
+
fieldset: fieldsetLabelElement.innerHTML
|
| 385 |
+
};
|
| 386 |
+
}
|
| 387 |
+
var labelConfig = labels[country];
|
| 388 |
+
if (!labelConfig) {
|
| 389 |
+
labelConfig = labels['default'];
|
| 390 |
+
}
|
| 391 |
+
switcherLabelElement.update(labelConfig['switcher']);
|
| 392 |
+
fieldsetLabelElement.update(labelConfig['fieldset']);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
var urls = config.get('urls');
|
| 396 |
+
if (urls) {
|
| 397 |
+
var linkMoreUrl = this.getMethodLinkMoreUrl(methodKey);
|
| 398 |
+
if (linkMoreUrl) {
|
| 399 |
+
if (!urls['more_url']) {
|
| 400 |
+
urls['more_url'] = linkMoreUrl.readAttribute('href');
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
var moreUrl = urls[country];
|
| 404 |
+
if (!moreUrl && urls['more_url']) {
|
| 405 |
+
var moreUrl = {
|
| 406 |
+
more_url: urls['more_url']
|
| 407 |
+
};
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
linkMoreUrl.writeAttribute('href', moreUrl['more_url']);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
var linkDemoUrl = this.getMethodLinkDemoUrl(methodKey);
|
| 414 |
+
if (linkDemoUrl) {
|
| 415 |
+
if (!urls['demo_url']) {
|
| 416 |
+
urls['demo_url'] = linkDemoUrl.readAttribute('href');
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
var demoUrl = urls[country];
|
| 420 |
+
if (!demoUrl && urls['demo_url']) {
|
| 421 |
+
var demoUrl = {
|
| 422 |
+
demo_url: urls['demo_url']
|
| 423 |
+
};
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
linkDemoUrl.writeAttribute('href', demoUrl['demo_url']);
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
},
|
| 430 |
+
|
| 431 |
+
trackBusinessAccount: function()
|
| 432 |
+
{
|
| 433 |
+
var elem = $('paypal_account_business_account');
|
| 434 |
+
if (!Validation.validate(elem) || !elem.value) {
|
| 435 |
+
this.disableMethod('wps', true);
|
| 436 |
+
this.disableMethod('ec', true);
|
| 437 |
+
this.disabledMethods.push('wps','ec');
|
| 438 |
+
} else {
|
| 439 |
+
this.disabledMethods = this.disabledMethods.without('wps','ec');
|
| 440 |
+
this.markMethodAsReadonly('wps',false);
|
| 441 |
+
this.markMethodAsReadonly('ec',false);
|
| 442 |
+
}
|
| 443 |
+
},
|
| 444 |
+
|
| 445 |
+
trackWpp: function()
|
| 446 |
+
{
|
| 447 |
+
var enabled = this.getMethodSwitcher('wpp').checked;
|
| 448 |
+
var wpppeEnabled = this.getMethodSwitcher('wpppe').checked;
|
| 449 |
+
|
| 450 |
+
if (enabled) {
|
| 451 |
+
this.enableMethod('wpp',false);
|
| 452 |
+
if (!wpppeEnabled) {
|
| 453 |
+
this.enableMethod('ec',true);
|
| 454 |
+
}
|
| 455 |
+
} else {
|
| 456 |
+
this.disableMethod('wpp',false);
|
| 457 |
+
if (!wpppeEnabled) {
|
| 458 |
+
this.markMethodAsReadonly('ec',false);
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
this.trackWps();
|
| 462 |
+
},
|
| 463 |
+
|
| 464 |
+
trackWppPe: function()
|
| 465 |
+
{
|
| 466 |
+
this.trackMethod('wpppe');
|
| 467 |
+
this.trackEcpe();
|
| 468 |
+
this.trackWps();
|
| 469 |
+
},
|
| 470 |
+
|
| 471 |
+
trackWppPl: function()
|
| 472 |
+
{
|
| 473 |
+
this.trackMethod('wpppl');
|
| 474 |
+
},
|
| 475 |
+
|
| 476 |
+
trackWppPa: function()
|
| 477 |
+
{
|
| 478 |
+
this.trackMethod('wpppa');
|
| 479 |
+
},
|
| 480 |
+
|
| 481 |
+
trackHss: function()
|
| 482 |
+
{
|
| 483 |
+
this.trackMethod('hosted_pro');
|
| 484 |
+
},
|
| 485 |
+
|
| 486 |
+
trackPayflowpro: function()
|
| 487 |
+
{
|
| 488 |
+
this.trackMethod('payflowpro');
|
| 489 |
+
this.trackEcpe();
|
| 490 |
+
},
|
| 491 |
+
|
| 492 |
+
trackEcpe: function()
|
| 493 |
+
{
|
| 494 |
+
var wpppeEnabled = this.getMethodSwitcher('wpppe').checked;
|
| 495 |
+
if (wpppeEnabled) {
|
| 496 |
+
// Do not enable ecpe based on wpppe state on page load
|
| 497 |
+
if (!this.fastMode) {
|
| 498 |
+
this.enableMethod('ecpe',true);
|
| 499 |
+
} else {
|
| 500 |
+
this.markMethodAsReadonly('ecpe', true);
|
| 501 |
+
}
|
| 502 |
+
this.disableMethod('ec',true);
|
| 503 |
+
return;
|
| 504 |
+
} else {
|
| 505 |
+
if (!this.getMethodSwitcher('wpp').checked) {
|
| 506 |
+
this.markMethodAsReadonly('ec', false);
|
| 507 |
+
} else {
|
| 508 |
+
this.enableMethod('ec',true);
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
var disabled = !wpppeEnabled && !this.getMethodSwitcher('payflowpro').checked;
|
| 512 |
+
if (disabled) {
|
| 513 |
+
this.disableMethod('ecpe', true);
|
| 514 |
+
} else {
|
| 515 |
+
this.markMethodAsReadonly('ecpe', false);
|
| 516 |
+
}
|
| 517 |
+
},
|
| 518 |
+
|
| 519 |
+
trackWps: function()
|
| 520 |
+
{
|
| 521 |
+
var disabled = this.getMethodSwitcher('wpp').checked || this.getMethodSwitcher('wpppe').checked;
|
| 522 |
+
if (disabled) {
|
| 523 |
+
this.disableMethod('wps', true);
|
| 524 |
+
} else {
|
| 525 |
+
this.markMethodAsReadonly('wps',false);
|
| 526 |
+
}
|
| 527 |
+
},
|
| 528 |
+
|
| 529 |
+
enableRow: function(rowId)
|
| 530 |
+
{
|
| 531 |
+
$(rowId).select('input','select').each(function(e) {
|
| 532 |
+
e.disabled = false;
|
| 533 |
+
});
|
| 534 |
+
$(rowId).show();
|
| 535 |
+
},
|
| 536 |
+
|
| 537 |
+
disableRow: function(rowId)
|
| 538 |
+
{
|
| 539 |
+
$(rowId).select('input','select').each(function(e) {
|
| 540 |
+
e.disabled = true;
|
| 541 |
+
});
|
| 542 |
+
$(rowId).hide();
|
| 543 |
+
},
|
| 544 |
+
|
| 545 |
+
toggleFieldset: function(fieldset, checkbox)
|
| 546 |
+
{
|
| 547 |
+
var isHidden = !checkbox.checked;
|
| 548 |
+
this.toggleValueElements(checkbox, fieldset, isHidden);
|
| 549 |
+
isHidden ? fieldset.hide() : fieldset.show();
|
| 550 |
+
var heading = fieldset.previous('div');
|
| 551 |
+
var headingLink = this.getMethodFieldsetHeadingLink(fieldset);
|
| 552 |
+
isHidden ? heading.addClassName('disabled') : heading.removeClassName('disabled');
|
| 553 |
+
if (isHidden) {
|
| 554 |
+
headingLink.oldHref = headingLink.href;
|
| 555 |
+
headingLink.oldOnclick = headingLink.onclick;
|
| 556 |
+
headingLink.onclick = "return false;";
|
| 557 |
+
headingLink.href = "javascript:void(0)";
|
| 558 |
+
} else {
|
| 559 |
+
if (headingLink.oldOnclick && headingLink.oldHref) {
|
| 560 |
+
headingLink.onclick = headingLink.oldOnclick;
|
| 561 |
+
headingLink.href = headingLink.oldHref;
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
},
|
| 565 |
+
|
| 566 |
+
toggleValueElements: function(checkbox, container, checked)
|
| 567 |
+
{
|
| 568 |
+
var isDisabled = (checked != undefined ? checked : $(checkbox).checked);
|
| 569 |
+
var elemInherit, currIsDisabled;
|
| 570 |
+
$(container).select('select', 'input', 'textarea', 'button').each (function(elem) {
|
| 571 |
+
// avoid inherit checkbox functionality rewrite
|
| 572 |
+
currIsDisabled = isDisabled;
|
| 573 |
+
if (!currIsDisabled) {
|
| 574 |
+
elemInherit = $(elem.id + '_inherit');
|
| 575 |
+
if (elemInherit != undefined && elemInherit.checked) {
|
| 576 |
+
currIsDisabled = true;
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
elem.disabled=currIsDisabled;
|
| 580 |
+
if (currIsDisabled) {
|
| 581 |
+
elem.addClassName('disabled');
|
| 582 |
+
} else {
|
| 583 |
+
elem.removeClassName('disabled');
|
| 584 |
+
}
|
| 585 |
+
});
|
| 586 |
+
},
|
| 587 |
+
|
| 588 |
+
destruct: function()
|
| 589 |
+
{
|
| 590 |
+
this.getMethods().each(function(method) {
|
| 591 |
+
if (method.value.get('disabled') != undefined) {
|
| 592 |
+
method.value.get('disabled') ? this.disableMethod(method.key) : this.enableMethod(method.key);
|
| 593 |
+
}
|
| 594 |
+
if (method.value.get('readonly') != undefined) {
|
| 595 |
+
this.markMethodAsReadonly(method.key, method.value.get('readonly'));
|
| 596 |
+
}
|
| 597 |
+
}.bind(this));
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
</script>
|
app/design/adminhtml/default/default/template/paypalmx/system/config/fieldset/store.phtml
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package default_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<?php
|
| 28 |
+
/**
|
| 29 |
+
* @see Mage_Paypal_Block_System_Config_Fieldset_Store
|
| 30 |
+
*/
|
| 31 |
+
?>
|
| 32 |
+
<script type="text/javascript">
|
| 33 |
+
|
| 34 |
+
Event.observe(window, 'load', function () {
|
| 35 |
+
var pConfigDisabler = new PaypalConfigDisabler;
|
| 36 |
+
var disabledMethods = <?php echo Mage::helper('core')->jsonEncode($this->getPaypalDisabledMethods()); ?>;
|
| 37 |
+
pConfigDisabler.disableMethods(disabledMethods);
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
PaypalConfigDisabler = Class.create();
|
| 41 |
+
PaypalConfigDisabler.prototype = {
|
| 42 |
+
initialize: function () {
|
| 43 |
+
this.methods = $H({
|
| 44 |
+
express: $H({fieldset: 'express'}),
|
| 45 |
+
wps: $H({fieldset: 'wps'}),
|
| 46 |
+
wpp: $H({fieldset: 'wpp'}),
|
| 47 |
+
wpppe: $H({fieldset: 'wpp_pe'}),
|
| 48 |
+
expresspe: $H({fieldset: 'express_pe'}),
|
| 49 |
+
verisign: $H({fieldset: 'verisign'}),
|
| 50 |
+
wpppl: $H({fieldset: 'payflow_link'}),
|
| 51 |
+
hosted_pro: $H({fieldset: 'hosted_pro'})
|
| 52 |
+
});
|
| 53 |
+
},
|
| 54 |
+
|
| 55 |
+
getMethods: function ()
|
| 56 |
+
{
|
| 57 |
+
return this.methods;
|
| 58 |
+
},
|
| 59 |
+
|
| 60 |
+
getMethod: function (method)
|
| 61 |
+
{
|
| 62 |
+
return this.methods.get(method);
|
| 63 |
+
},
|
| 64 |
+
|
| 65 |
+
getMethodFieldset: function (method)
|
| 66 |
+
{
|
| 67 |
+
var fieldsetId = 'paypal_' + this.getMethod(method).get('fieldset');
|
| 68 |
+
return $(fieldsetId);
|
| 69 |
+
},
|
| 70 |
+
|
| 71 |
+
disableMethod: function (method)
|
| 72 |
+
{
|
| 73 |
+
this.hideFieldset(this.getMethodFieldset(method));
|
| 74 |
+
},
|
| 75 |
+
|
| 76 |
+
disableMethods: function (methods)
|
| 77 |
+
{
|
| 78 |
+
for(var methodId in methods) {
|
| 79 |
+
this.disableMethod(methodId);
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
|
| 83 |
+
hideFieldset: function (fieldset)
|
| 84 |
+
{
|
| 85 |
+
this.disableValueElements(fieldset);
|
| 86 |
+
fieldset.hide();
|
| 87 |
+
var heading = fieldset.previous('div');
|
| 88 |
+
var headingLink = heading.down('a');
|
| 89 |
+
heading.addClassName('disabled');
|
| 90 |
+
headingLink.onclick = "return false;";
|
| 91 |
+
headingLink.href = "javascript:void(0)";
|
| 92 |
+
},
|
| 93 |
+
|
| 94 |
+
disableValueElements: function (container)
|
| 95 |
+
{
|
| 96 |
+
$(container).select('select', 'input', 'textarea', 'button').each(function (elem) {
|
| 97 |
+
elem.addClassName('disabled');
|
| 98 |
+
});
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
</script>
|
app/design/adminhtml/default/default/template/paypalmx/system/config/payflowlink/advanced.phtml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package default_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/*
|
| 28 |
+
* @var $this Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<div class="payflow-settings-notice">
|
| 32 |
+
<strong class="important-label"><?php echo $this->__('Important: ') ?></strong>
|
| 33 |
+
<?php echo $this->__('To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.'); ?>
|
| 34 |
+
<?php echo $this->__('Once you log into your PayPal Advanced account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below') ?>
|
| 35 |
+
<ul class="options-list">
|
| 36 |
+
<li><strong>AVS:</strong> No</li>
|
| 37 |
+
<li><strong>CSC:</strong> No</li>
|
| 38 |
+
<li><strong>Enable Secure Token:</strong> Yes</li>
|
| 39 |
+
</ul>
|
| 40 |
+
</div>
|
app/design/adminhtml/default/default/template/paypalmx/system/config/payflowlink/info.phtml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package default_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<?php
|
| 28 |
+
/**
|
| 29 |
+
* @see Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info
|
| 30 |
+
*/
|
| 31 |
+
?>
|
| 32 |
+
<div class="payflow-settings-notice">
|
| 33 |
+
<strong class="important-label"><?php echo $this->__('Important: ') ?></strong>
|
| 34 |
+
<?php echo $this->__('To use PayPal Payflow Link, you must configure your PayPal Payflow Link account on the PayPal website.'); ?>
|
| 35 |
+
<?php echo $this->__('Once you log into your PayPal Payflow Link account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below') ?>
|
| 36 |
+
<ul class="options-list">
|
| 37 |
+
<li><strong>AVS:</strong> No</li>
|
| 38 |
+
<li><strong>CSC:</strong> No</li>
|
| 39 |
+
<li><strong>Enable Secure Token:</strong> Yes</li>
|
| 40 |
+
</ul>
|
| 41 |
+
</div>
|
app/design/frontend/base/default/layout/paypalmx.xml
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0"><!--
|
| 3 |
+
<checkout_cart_index>
|
| 4 |
+
<reference name="checkout.cart.top_methods">
|
| 5 |
+
<block type="paypalmx/express_shortcut" name="checkout.cart.methods.paypalmx_express.top" before="-" template="paypalmx/express/shortcut.phtml">
|
| 6 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 7 |
+
<action method="setIsInCart"><value>1</value></action>
|
| 8 |
+
</block>
|
| 9 |
+
</reference>
|
| 10 |
+
<reference name="checkout.cart.methods">
|
| 11 |
+
<block type="paypalmx/express_shortcut" name="checkout.cart.methods.paypalmx_express.bottom" before="-" template="paypalmx/express/shortcut.phtml">
|
| 12 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 13 |
+
<action method="setIsInCart"><value>1</value></action>
|
| 14 |
+
</block>
|
| 15 |
+
</reference>
|
| 16 |
+
<update handle="SHORTCUT_popup" />
|
| 17 |
+
</checkout_cart_index>
|
| 18 |
+
|
| 19 |
+
<checkout_onepage_shippingmethod>
|
| 20 |
+
<reference name="root">
|
| 21 |
+
<block type="paypalmx/express_shortcut" name="checkout.onepage.shipping.method.available.paypalmx_express.top" before="-" template="paypalmx/express/shortcut.phtml">
|
| 22 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 23 |
+
</block>
|
| 24 |
+
</reference>
|
| 25 |
+
<update handle="SHORTCUT_popup" />
|
| 26 |
+
</checkout_onepage_shippingmethod>
|
| 27 |
+
|
| 28 |
+
<checkout_onepage_additional>
|
| 29 |
+
<reference name="root">
|
| 30 |
+
<action method="setTemplate">
|
| 31 |
+
<template>paypalmx/express/shortcut.phtml</template>
|
| 32 |
+
</action>
|
| 33 |
+
</reference>
|
| 34 |
+
<update handle="SHORTCUT_popup" />
|
| 35 |
+
</checkout_onepage_additional>
|
| 36 |
+
-->
|
| 37 |
+
<checkout_onepage_index>
|
| 38 |
+
<reference name="content">
|
| 39 |
+
<block type="paypalmx/express_shortcut" name="checkout.onepage.shipping.method.available.paypalmx_express.top" before="-" template="paypalmx/express/shortcut.phtml">
|
| 40 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 41 |
+
</block>
|
| 42 |
+
</reference>
|
| 43 |
+
<update handle="SHORTCUT_popup" />
|
| 44 |
+
</checkout_onepage_index>
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
<paypalmx_express_review translate="label">
|
| 48 |
+
<label>PayPal Express Order Review Form</label>
|
| 49 |
+
<remove name="right"/>
|
| 50 |
+
<remove name="left"/>
|
| 51 |
+
|
| 52 |
+
<reference name="root">
|
| 53 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
| 54 |
+
</reference>
|
| 55 |
+
<reference name="content">
|
| 56 |
+
<block type="paypalmx/express_review" name="paypalmx.express.review" template="paypalmx/express/review.phtml">
|
| 57 |
+
<block type="paypalmx/express_review_billing" name="express.review.billing" as="billing" template="paypalmx/express/review/address.phtml"/>
|
| 58 |
+
<block type="paypalmx/express_review_shipping" name="express.review.shipping" as="shipping" template="paypalmx/express/review/address.phtml"/>
|
| 59 |
+
<block type="paypalmx/express_review" name="express.review.shipping.method" as="shipping_method" template="paypalmx/express/review/shipping/method.phtml"/>
|
| 60 |
+
<block type="paypalmx/express_review_details" name="paypalmx.express.review.details" as="details" template="paypalmx/express/review/details.phtml">
|
| 61 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 62 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 63 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 64 |
+
<block type="checkout/cart_totals" name="paypalmx.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
| 65 |
+
</block>
|
| 66 |
+
<block type="checkout/agreements" name="paypalmx.express.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
| 67 |
+
</block>
|
| 68 |
+
</reference>
|
| 69 |
+
<reference name="head">
|
| 70 |
+
<action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action>
|
| 71 |
+
</reference>
|
| 72 |
+
<block type="core/text_list" name="additional.product.info" />
|
| 73 |
+
</paypalmx_express_review>
|
| 74 |
+
|
| 75 |
+
<paypalmx_express_review_details>
|
| 76 |
+
<block type="paypalmx/express_review_details" name="root" output="toHtml" template="paypalmx/express/review/details.phtml">
|
| 77 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 78 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 79 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 80 |
+
<block type="checkout/cart_totals" name="paypalmx.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
| 81 |
+
</block>
|
| 82 |
+
</paypalmx_express_review_details>
|
| 83 |
+
<!--
|
| 84 |
+
Available logo types can be assigned with action="setLogoType":
|
| 85 |
+
- wePrefer_150x60
|
| 86 |
+
- wePrefer_150x40
|
| 87 |
+
- nowAccepting_150x60
|
| 88 |
+
- nowAccepting_150x40
|
| 89 |
+
- paymentsBy_150x60
|
| 90 |
+
- paymentsBy_150x40
|
| 91 |
+
- shopNowUsing_150x60
|
| 92 |
+
- shopNowUsing_150x40
|
| 93 |
+
|
| 94 |
+
<catalog_product_view>
|
| 95 |
+
<reference name="product.info.addtocart">
|
| 96 |
+
<block type="page/html_wrapper" name="product.info.addtocart.paypalmx.wrapper" translate="label">
|
| 97 |
+
<label>PayPal Express Checkout Shortcut Wrapper</label>
|
| 98 |
+
<block type="paypalmx/express_shortcut" name="product.info.addtocart.paypalmx" template="paypalmx/express/shortcut.phtml">
|
| 99 |
+
<action method="setIsInCatalogProduct"><value>1</value></action>
|
| 100 |
+
</block>
|
| 101 |
+
</block>
|
| 102 |
+
</reference>
|
| 103 |
+
<update handle="SHORTCUT_popup" />
|
| 104 |
+
<reference name="right">
|
| 105 |
+
<block type="paypalmx/logo" name="paypalmx.partner.right.logo" template="paypalmx/partner/logo.phtml">
|
| 106 |
+
action method="setLogoType"><value>wePrefer_150x60</value></action
|
| 107 |
+
</block>
|
| 108 |
+
</reference>
|
| 109 |
+
</catalog_product_view>
|
| 110 |
+
|
| 111 |
+
<catalog_category_default>
|
| 112 |
+
<update handle="SHORTCUT_popup" />
|
| 113 |
+
<reference name="right">
|
| 114 |
+
<block type="paypalmx/logo" name="paypalmx.partner.right.logo" template="paypalmx/partner/logo.phtml"/>
|
| 115 |
+
</reference>
|
| 116 |
+
</catalog_category_default>
|
| 117 |
+
|
| 118 |
+
<catalog_category_layered>
|
| 119 |
+
<update handle="SHORTCUT_popup" />
|
| 120 |
+
<reference name="right">
|
| 121 |
+
<block type="paypalmx/logo" name="paypalmx.partner.right.logo" template="paypalmx/partner/logo.phtml"/>
|
| 122 |
+
</reference>
|
| 123 |
+
</catalog_category_layered>
|
| 124 |
+
-->
|
| 125 |
+
<catalog_product_compare_index>
|
| 126 |
+
<update handle="SHORTCUT_popup" />
|
| 127 |
+
</catalog_product_compare_index>
|
| 128 |
+
|
| 129 |
+
<catalogsearch_result_index>
|
| 130 |
+
<update handle="SHORTCUT_popup" />
|
| 131 |
+
</catalogsearch_result_index>
|
| 132 |
+
|
| 133 |
+
<catalogsearch_advanced_result>
|
| 134 |
+
<update handle="SHORTCUT_popup" />
|
| 135 |
+
</catalogsearch_advanced_result>
|
| 136 |
+
|
| 137 |
+
<tag_product_list>
|
| 138 |
+
<update handle="SHORTCUT_popup" />
|
| 139 |
+
</tag_product_list>
|
| 140 |
+
<tag_customer_view>
|
| 141 |
+
<update handle="SHORTCUT_popup" />
|
| 142 |
+
</tag_customer_view>
|
| 143 |
+
|
| 144 |
+
<wishlist_index_index>
|
| 145 |
+
<update handle="SHORTCUT_popup" />
|
| 146 |
+
</wishlist_index_index>
|
| 147 |
+
<review_product_list>
|
| 148 |
+
<update handle="SHORTCUT_popup" />
|
| 149 |
+
</review_product_list>
|
| 150 |
+
|
| 151 |
+
<checkout_onepage_success>
|
| 152 |
+
<update handle="SHORTCUT_popup" />
|
| 153 |
+
</checkout_onepage_success>
|
| 154 |
+
<checkout_onepage_failure>
|
| 155 |
+
<update handle="SHORTCUT_popup" />
|
| 156 |
+
</checkout_onepage_failure>
|
| 157 |
+
<!--
|
| 158 |
+
<default>
|
| 159 |
+
<reference name="topCart.extra_actions">
|
| 160 |
+
<block type="paypalmx/express_shortcut" name="paypalmx.partner.top_cart.shortcut" template="paypalmx/express/shortcut.phtml"/>
|
| 161 |
+
</reference>
|
| 162 |
+
<reference name="cart_sidebar.extra_actions">
|
| 163 |
+
<block type="paypalmx/express_shortcut" name="paypalmx.partner.cart_sidebar.shortcut" template="paypalmx/express/shortcut.phtml">
|
| 164 |
+
<action method="setIsInCatalogProduct"><value>1</value></action>
|
| 165 |
+
</block>
|
| 166 |
+
</reference>
|
| 167 |
+
</default>
|
| 168 |
+
-->
|
| 169 |
+
<checkout_onepage_review>
|
| 170 |
+
<reference name="checkout.onepage.review.info.items.after">
|
| 171 |
+
<block type="paypalmx/iframe" name="paypalmx.iframe" />
|
| 172 |
+
</reference>
|
| 173 |
+
<reference name="checkout.onepage.review.button">
|
| 174 |
+
<action method="setTemplate"><template helper="paypalmx/hss/getReviewButtonTemplate"><name>paypalmx/hss/review/button.phtml</name><block>checkout.onepage.review.button</block></template></action>
|
| 175 |
+
</reference>
|
| 176 |
+
</checkout_onepage_review>
|
| 177 |
+
|
| 178 |
+
<paypalmx_payflow_link_iframe>
|
| 179 |
+
<block type="paypalmx/payflow_link_iframe" name="payflow.link.iframe" template="paypalmx/payflowlink/form.phtml" />
|
| 180 |
+
</paypalmx_payflow_link_iframe>
|
| 181 |
+
|
| 182 |
+
<paypalmx_payflow_advanced_iframe>
|
| 183 |
+
<block type="paypalmx/payflow_advanced_iframe" name="payflow.advanced.iframe" template="paypalmx/payflowadvanced/form.phtml" />
|
| 184 |
+
</paypalmx_payflow_advanced_iframe>
|
| 185 |
+
|
| 186 |
+
<paypalmx_hosted_pro_iframe>
|
| 187 |
+
<block type="paypalmx/hosted_pro_iframe" name="hosted.pro.iframe" template="paypalmx/hss/form.phtml"/>
|
| 188 |
+
</paypalmx_hosted_pro_iframe>
|
| 189 |
+
<!-- -->
|
| 190 |
+
<SHORTCUT_popup>
|
| 191 |
+
<reference name="product.tooltip">
|
| 192 |
+
<block type="page/html_wrapper" name="product.info.addtocart.paypalmx.wrapper" translate="label">
|
| 193 |
+
<block type="paypalmx/express_shortcut" name="product.info.addtocart.paypalmx" template="paypalmx/express/shortcut.phtml">
|
| 194 |
+
<action method="setIsInCatalogProduct"><value>1</value></action>
|
| 195 |
+
<action method="setShowOrPosition"><value>after</value></action>
|
| 196 |
+
</block>
|
| 197 |
+
</block>
|
| 198 |
+
</reference>
|
| 199 |
+
</SHORTCUT_popup>
|
| 200 |
+
-->
|
| 201 |
+
</layout>
|
app/design/frontend/base/default/template/paypalmx/express/review.phtml
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script
|
| 2 |
+
src="http://code.jquery.com/jquery-1.9.1.js"></script>
|
| 3 |
+
<script type="text/javascript">
|
| 4 |
+
|
| 5 |
+
$j = jQuery.noConflict();
|
| 6 |
+
$j( document ).ready(function() {
|
| 7 |
+
$j("#review_button").trigger("click");
|
| 8 |
+
});
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
</script>
|
| 12 |
+
<style type="text/css">
|
| 13 |
+
#backgr {
|
| 14 |
+
background-color: #EFEFEF;
|
| 15 |
+
display: inline;
|
| 16 |
+
bottom: 0;
|
| 17 |
+
height: 100%;
|
| 18 |
+
left: 0;
|
| 19 |
+
position: fixed;
|
| 20 |
+
right: 0;
|
| 21 |
+
top: 0;
|
| 22 |
+
width: 100%;
|
| 23 |
+
z-index: 980;
|
| 24 |
+
}
|
| 25 |
+
#ppmx_popup {
|
| 26 |
+
z-index: 1001;
|
| 27 |
+
display: inline;
|
| 28 |
+
width: 400px;
|
| 29 |
+
height: 300px;
|
| 30 |
+
position: fixed;
|
| 31 |
+
top: 50%;
|
| 32 |
+
left: 50%;
|
| 33 |
+
margin: -200px 0 0 -200px;
|
| 34 |
+
line-height: normal;
|
| 35 |
+
background: #fefefe; /* Old browsers */
|
| 36 |
+
background: -moz-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 37 |
+
/* FF3.6+ */
|
| 38 |
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fefefe),
|
| 39 |
+
color-stop(100%, #f1f2f4)); /* Chrome,Safari4+ */
|
| 40 |
+
background: -webkit-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 41 |
+
/* Chrome10+,Safari5.1+ */
|
| 42 |
+
background: -o-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 43 |
+
/* Opera 11.10+ */
|
| 44 |
+
background: -ms-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 45 |
+
/* IE10+ */
|
| 46 |
+
background: linear-gradient(to bottom, #fefefe 0%, #f1f2f4 100%);
|
| 47 |
+
/* W3C */
|
| 48 |
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fefefe',
|
| 49 |
+
endColorstr='#f1f2f4', GradientType=0); /* IE6-9 */
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
#ppmx_popup .ppmx_logo {
|
| 53 |
+
float: right;
|
| 54 |
+
margin: 10px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
#ppmx_popup .ppmx_content {
|
| 58 |
+
margin-top: 80px;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
#ppmx_popup .ppmx_loader {
|
| 62 |
+
display: block;
|
| 63 |
+
margin: 20px 0 0 0px;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
#ppmx_popup .ppmx_loader div {
|
| 67 |
+
color: #0071BB;
|
| 68 |
+
font-size: 10px;
|
| 69 |
+
text-align: center;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
#ppmx_popup .ppmx_loader img {
|
| 73 |
+
position: relative;
|
| 74 |
+
left: 50%;
|
| 75 |
+
margin: 0 0 15px -105px;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
#ppmx_popup .ppmx_title {
|
| 79 |
+
font-size: 25px;
|
| 80 |
+
color: #0F4073;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
#ppmx_popup .ppmx_box {
|
| 84 |
+
margin: 0 10px 0 0;
|
| 85 |
+
float: left;
|
| 86 |
+
width: 50px;
|
| 87 |
+
height: 100px;
|
| 88 |
+
background: #0079C0;
|
| 89 |
+
-webkit-border-top-right-radius: 6px;
|
| 90 |
+
-webkit-border-bottom-right-radius: 6px;
|
| 91 |
+
-moz-border-radius-topright: 6px;
|
| 92 |
+
-moz-border-radius-bottomright: 6px;
|
| 93 |
+
border-top-right-radius: 6px;
|
| 94 |
+
border-bottom-right-radius: 6px;
|
| 95 |
+
}
|
| 96 |
+
</style>
|
| 97 |
+
<div id="backgr"></div>
|
| 98 |
+
<div id='ppmx_popup'>
|
| 99 |
+
<img style="width: 125px; height: 44px"
|
| 100 |
+
src="<?php echo $this->getSkinUrl('images/paypalmx/bdg_compra_segura_pp_.PNG'); ?>"
|
| 101 |
+
class='ppmx_logo'>
|
| 102 |
+
<div class='ppmx_content'>
|
| 103 |
+
<div class='ppmx_box'></div>
|
| 104 |
+
<span class='ppmx_title'>Espere mientras procesamos su pago.</span></br>
|
| 105 |
+
<div class='ppmx_loader'>
|
| 106 |
+
<img alt="" src="<?php echo $this->getSkinUrl('images/paypalmx/paypalmx_loader.gif');?>" style = "height: 100px; width: 100px;">
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
<?php
|
| 111 |
+
$billingBlock = $this->getChild('billing')->setFieldNamePrefix('billing')->setHideEmailAddress(true);
|
| 112 |
+
$shippingAddress = $this->getShippingAddress();
|
| 113 |
+
?>
|
| 114 |
+
<div class="page-title">
|
| 115 |
+
<h1><?php echo $this->__('Review Order') ?></h1>
|
| 116 |
+
</div>
|
| 117 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
| 118 |
+
<script type="text/javascript">
|
| 119 |
+
//<![CDATA[
|
| 120 |
+
var countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?>
|
| 121 |
+
//]]>
|
| 122 |
+
</script>
|
| 123 |
+
<h2 class="sub-title">
|
| 124 |
+
Please confirm your addresses
|
| 125 |
+
</h2>
|
| 126 |
+
<div class="paypal-review-order">
|
| 127 |
+
<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>">
|
| 128 |
+
<?php if(!$billingBlock->isCustomerLoggedIn()): ?>
|
| 129 |
+
<div class="info-set col2-set">
|
| 130 |
+
<h2 class="legend"><?php echo $this->__('Customer Information') ?></h2>
|
| 131 |
+
<ul class="form-list form-list-narrow">
|
| 132 |
+
<li id="customer-info-form" class="address-form">
|
| 133 |
+
<div class="field">
|
| 134 |
+
<label for="customer:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
| 135 |
+
<div class="input-box">
|
| 136 |
+
<input type="text" name="customer-email" id="customer:email" value="<?php echo $this->escapeHtml($billingBlock->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</li>
|
| 140 |
+
</ul>
|
| 141 |
+
</div>
|
| 142 |
+
<?php endif ?>
|
| 143 |
+
<div class="info-set col2-set">
|
| 144 |
+
<div class="col-1" id="billing-address">
|
| 145 |
+
<h2 class="legend"><?php echo $this->__('Billing Address') ?></h2>
|
| 146 |
+
<?php if ($shippingAddress): ?>
|
| 147 |
+
<?php echo $billingBlock->setShowAsShippingCheckbox(true)->toHtml(); ?>
|
| 148 |
+
<?php else: ?>
|
| 149 |
+
<?php echo $billingBlock->toHtml(); ?>
|
| 150 |
+
<?php endif; ?>
|
| 151 |
+
</div>
|
| 152 |
+
<?php if ($shippingAddress): ?>
|
| 153 |
+
<div class="col-2" id="shipping-address">
|
| 154 |
+
<h2 class="legend"><?php echo $this->__('Shipping Address') ?></h2>
|
| 155 |
+
<?php echo $this->getChild('shipping')->setFieldNamePrefix('shipping')->setHideEmailAddress(true)->toHtml(); ?>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
|
| 159 |
+
<div class="info-set col2-set">
|
| 160 |
+
<div class="col-2">
|
| 161 |
+
<div class="box paypal-shipping-method">
|
| 162 |
+
<div class="box-title">
|
| 163 |
+
<h3><?php echo $this->__('Shipping Method') ?></h3>
|
| 164 |
+
</div>
|
| 165 |
+
<div class="box-content">
|
| 166 |
+
<?php echo $this->getChild('shipping_method')->toHtml(); ?>
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
<?php endif; ?>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<div class="info-set">
|
| 174 |
+
<h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2>
|
| 175 |
+
<div id="details-reload">
|
| 176 |
+
<?php echo $this->getChildHtml('details') ?>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
<?php echo $this->getChildHtml('agreements'); ?>
|
| 180 |
+
<div class="buttons-set buttons-set-order" id="review-buttons-container">
|
| 181 |
+
<button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
|
| 182 |
+
<button type="button" id="review_submit" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
|
| 183 |
+
<button type="button" id="update_order" class="button btn-checkout"><span><span><?php echo $this->__('Update Order Data') ?></span></span></button>
|
| 184 |
+
<span class="please-wait" id="review-please-wait" style="display:none;">
|
| 185 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
|
| 186 |
+
</span>
|
| 187 |
+
</div>
|
| 188 |
+
</form>
|
| 189 |
+
</div>
|
| 190 |
+
<script type="text/javascript">
|
| 191 |
+
//<![CDATA[
|
| 192 |
+
// submit buttons are not needed when submitting with ajax
|
| 193 |
+
$('review_submit').hide();
|
| 194 |
+
if ($('update_shipping_method_submit')) {
|
| 195 |
+
$('update_shipping_method_submit').hide();
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
<?php if ($this->getUseAjax()):?>
|
| 199 |
+
OrderReviewController.prototype._submitOrder = function() {
|
| 200 |
+
if (this._canSubmitOrder) {
|
| 201 |
+
if (this._pleaseWait) {
|
| 202 |
+
this._pleaseWait.show();
|
| 203 |
+
}
|
| 204 |
+
new Ajax.Request(this.form.action, {
|
| 205 |
+
parameters: {isAjax: 1, method: 'POST'},
|
| 206 |
+
onSuccess: function(transport) {
|
| 207 |
+
try{
|
| 208 |
+
response = eval('(' + transport.responseText + ')');
|
| 209 |
+
} catch (e) {
|
| 210 |
+
response = {};
|
| 211 |
+
}
|
| 212 |
+
if (response.redirect) {
|
| 213 |
+
setLocation(response.redirect);
|
| 214 |
+
return;
|
| 215 |
+
}
|
| 216 |
+
if (response.success) {
|
| 217 |
+
setLocation('<?php echo $this->getSuccessUrl()?>');
|
| 218 |
+
return;
|
| 219 |
+
} else {
|
| 220 |
+
var msg = response.error_messages;
|
| 221 |
+
if (typeof(msg)=='object') {
|
| 222 |
+
msg = msg.join("\n");
|
| 223 |
+
}
|
| 224 |
+
if (msg) {
|
| 225 |
+
$('review-please-wait').hide();
|
| 226 |
+
alert(msg);
|
| 227 |
+
return;
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
$('review-please-wait').hide();
|
| 231 |
+
alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>');
|
| 232 |
+
return;
|
| 233 |
+
},
|
| 234 |
+
onFailure: function(){
|
| 235 |
+
alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>');
|
| 236 |
+
$('review-please-wait').hide();
|
| 237 |
+
}
|
| 238 |
+
});
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
<?php endif ?>
|
| 242 |
+
PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'),
|
| 243 |
+
'shipping_method', null, 'details-reload'
|
| 244 |
+
);
|
| 245 |
+
PayPalExpressAjax.addPleaseWait($('review-please-wait'));
|
| 246 |
+
PayPalExpressAjax.setShippingAddressContainer($('shipping-address'));
|
| 247 |
+
PayPalExpressAjax.setShippingMethodContainer('shipping-method-container');
|
| 248 |
+
PayPalExpressAjax.shippingMethodsUpdateUrl = '<?php echo $this->escapeHtml($this->getUpdateShippingMethodsUrl()) ?>';
|
| 249 |
+
PayPalExpressAjax.setUpdateButton($('update_order'),'<?php echo $this->escapeHtml($this->getUpdateOrderSubmitUrl()) ?>','details-reload');
|
| 250 |
+
if ($('billing:as_shipping')) {
|
| 251 |
+
PayPalExpressAjax.setCopyElement($('billing:as_shipping'));
|
| 252 |
+
}
|
| 253 |
+
//]]>
|
| 254 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/express/review/address.phtml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<?php $prefix = $this->getFieldNamePrefix();?>
|
| 28 |
+
<fieldset>
|
| 29 |
+
<ul class="form-list form-list-narrow">
|
| 30 |
+
<li id="<?php echo $prefix ?>-address-form" class="address-form">
|
| 31 |
+
<fieldset>
|
| 32 |
+
<input type="hidden" name="<?php echo $prefix ?>[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id" />
|
| 33 |
+
<ul>
|
| 34 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li>
|
| 35 |
+
<li class="fields">
|
| 36 |
+
<div class="field">
|
| 37 |
+
<label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
|
| 38 |
+
<div class="input-box">
|
| 39 |
+
<input type="text" id="<?php echo $prefix ?>:company" name="<?php echo $prefix ?>[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
| 40 |
+
</div>
|
| 41 |
+
</div>
|
| 42 |
+
<?php if(!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
|
| 43 |
+
<div class="field">
|
| 44 |
+
<label for="<?php echo $prefix ?>:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
| 45 |
+
<div class="input-box">
|
| 46 |
+
<input type="text" name="<?php echo $prefix ?>[email]" id="<?php echo $prefix ?>:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
<?php endif; ?>
|
| 50 |
+
</li>
|
| 51 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
| 52 |
+
<li class="wide">
|
| 53 |
+
<label for="<?php echo $prefix ?>:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
| 54 |
+
<div class="input-box">
|
| 55 |
+
<input type="text" title="<?php echo $this->__('Street Address') ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
| 56 |
+
</div>
|
| 57 |
+
</li>
|
| 58 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
| 59 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
| 60 |
+
<li class="add-field">
|
| 61 |
+
<div class="input-box">
|
| 62 |
+
<input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street<?php echo $_i?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
| 63 |
+
</div>
|
| 64 |
+
</li>
|
| 65 |
+
<?php endfor; ?>
|
| 66 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
| 67 |
+
<li class="wide">
|
| 68 |
+
<label for="<?php echo $prefix ?>:vat_id"><?php echo $this->__('VAT Number') ?></label>
|
| 69 |
+
<div class="input-box">
|
| 70 |
+
<input type="text" id="<?php echo $prefix ?>:vat_id" name="<?php echo $prefix ?>[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
|
| 71 |
+
</div>
|
| 72 |
+
</li>
|
| 73 |
+
<?php endif; ?>
|
| 74 |
+
<li class="fields">
|
| 75 |
+
<div class="field">
|
| 76 |
+
<label for="<?php echo $prefix ?>:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
| 77 |
+
<div class="input-box">
|
| 78 |
+
<input type="text" title="<?php echo $this->__('City') ?>" name="<?php echo $prefix ?>[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="<?php echo $prefix ?>:city" />
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
<div class="field">
|
| 82 |
+
<label for="<?php echo $prefix ?>:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
| 83 |
+
<div class="input-box">
|
| 84 |
+
<select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
|
| 85 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
| 86 |
+
</select>
|
| 87 |
+
<script type="text/javascript">
|
| 88 |
+
//<![CDATA[
|
| 89 |
+
$('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
| 90 |
+
//]]>
|
| 91 |
+
</script>
|
| 92 |
+
<input type="text" id="<?php echo $prefix ?>:region" name="<?php echo $prefix ?>[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
</li>
|
| 96 |
+
<li class="fields">
|
| 97 |
+
<div class="field">
|
| 98 |
+
<label for="<?php echo $prefix ?>:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
| 99 |
+
<div class="input-box">
|
| 100 |
+
<input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="field">
|
| 104 |
+
<label for="<?php echo $prefix ?>:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
| 105 |
+
<div class="input-box">
|
| 106 |
+
<?php echo $this->getCountryHtmlSelect($prefix) ?>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
</li>
|
| 110 |
+
<li class="fields">
|
| 111 |
+
<div class="field">
|
| 112 |
+
<label for="<?php echo $prefix ?>:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
| 113 |
+
<div class="input-box">
|
| 114 |
+
<input type="text" name="<?php echo $prefix ?>[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="<?php echo $prefix ?>:telephone" />
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
<div class="field">
|
| 118 |
+
<label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
|
| 119 |
+
<div class="input-box">
|
| 120 |
+
<input type="text" name="<?php echo $prefix ?>[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="<?php echo $prefix ?>:fax" />
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</li>
|
| 124 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
| 125 |
+
<?php if ($this->getShowAsShippingCheckbox()): ?>
|
| 126 |
+
<li class="control">
|
| 127 |
+
<div class="field">
|
| 128 |
+
<div class="input-box">
|
| 129 |
+
<input type="checkbox" name="<?php echo $prefix ?>[as_shipping]" class="checkbox" value="1" title="<?php echo $this->__('Same as shipping') ?>" id="<?php echo $prefix ?>:as_shipping" <?php if ($this->getAddress()->getSameAsBilling()):?>checked="checked"<?php endif;?>/>
|
| 130 |
+
</div>
|
| 131 |
+
<label for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
|
| 132 |
+
</div>
|
| 133 |
+
</li>
|
| 134 |
+
<?php endif; ?>
|
| 135 |
+
</ul>
|
| 136 |
+
</fieldset>
|
| 137 |
+
</li>
|
| 138 |
+
</ul>
|
| 139 |
+
</fieldset>
|
| 140 |
+
<script type="text/javascript">
|
| 141 |
+
//<![CDATA[
|
| 142 |
+
var <?php echo $prefix ?>RegionUpdater = new RegionUpdater('<?php echo $prefix ?>:country_id', '<?php echo $prefix ?>:region', '<?php echo $prefix ?>:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, '<?php echo $prefix ?>:postcode');
|
| 143 |
+
<?php echo $prefix ?>RegionUpdater.update();
|
| 144 |
+
//]]>
|
| 145 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/express/review/details.phtml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Express_Review_Details
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<table id="details-table" class="data-table">
|
| 32 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
|
| 33 |
+
<col />
|
| 34 |
+
<col width="1" />
|
| 35 |
+
<col width="1" />
|
| 36 |
+
<col width="1" />
|
| 37 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
| 38 |
+
<col width="1" />
|
| 39 |
+
<col width="1" />
|
| 40 |
+
<?php endif; ?>
|
| 41 |
+
<thead>
|
| 42 |
+
<tr>
|
| 43 |
+
<th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
|
| 44 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
|
| 45 |
+
<th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
| 46 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
|
| 47 |
+
</tr>
|
| 48 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
| 49 |
+
<tr>
|
| 50 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
| 51 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
| 52 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
| 53 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
| 54 |
+
</tr>
|
| 55 |
+
<?php endif; ?>
|
| 56 |
+
</thead>
|
| 57 |
+
<?php echo $this->getChildHtml('totals'); ?>
|
| 58 |
+
<tbody>
|
| 59 |
+
<?php foreach($this->getItems() as $_item): ?>
|
| 60 |
+
<?php echo $this->getItemHtml($_item) ?>
|
| 61 |
+
<?php endforeach ?>
|
| 62 |
+
</tbody>
|
| 63 |
+
</table>
|
| 64 |
+
<script type="text/javascript">decorateTable('details-table');</script>
|
app/design/frontend/base/default/template/paypalmx/express/review/shipping/method.phtml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
/** @var $this Mage_Paypal_Block_Express_Review */
|
| 27 |
+
?>
|
| 28 |
+
<fieldset id="shipping-method-container">
|
| 29 |
+
<?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
|
| 30 |
+
<?php if ($groups = $this->getShippingRateGroups()):?>
|
| 31 |
+
<?php $currentRate = $this->getCurrentShippingRate(); ?>
|
| 32 |
+
<select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
|
| 33 |
+
<?php if (!$currentRate):?>
|
| 34 |
+
<option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
|
| 35 |
+
<?php endif;?>
|
| 36 |
+
<?php foreach ($groups as $code => $rates):?>
|
| 37 |
+
<optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
|
| 38 |
+
<?php foreach ($rates as $rate):?>
|
| 39 |
+
<option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
|
| 40 |
+
<?php echo $this->renderShippingRateOption($rate)?>
|
| 41 |
+
</option>
|
| 42 |
+
<?php endforeach;?>
|
| 43 |
+
</optgroup>
|
| 44 |
+
<?php endforeach;?>
|
| 45 |
+
</select>
|
| 46 |
+
<?php else: ?>
|
| 47 |
+
<p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
|
| 48 |
+
<?php endif;?>
|
| 49 |
+
<?php else: ?>
|
| 50 |
+
<p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p>
|
| 51 |
+
<?php endif; ?>
|
| 52 |
+
</fieldset>
|
| 53 |
+
<div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div>
|
app/design/frontend/base/default/template/paypalmx/express/shortcut.phtml
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|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 5 |
+
?>
|
| 6 |
+
<style type="text/css">
|
| 7 |
+
#btnscppmx{
|
| 8 |
+
display: none;
|
| 9 |
+
}
|
| 10 |
+
#backgr {
|
| 11 |
+
display: none;
|
| 12 |
+
background-color: #EFEFEF;
|
| 13 |
+
bottom: 0;
|
| 14 |
+
height: 100%;
|
| 15 |
+
left: 0;
|
| 16 |
+
opacity: 0.5;
|
| 17 |
+
position: fixed;
|
| 18 |
+
right: 0;
|
| 19 |
+
top: 0;
|
| 20 |
+
width: 100%;
|
| 21 |
+
z-index: 980;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
#ppmx_popup {
|
| 25 |
+
z-index: 1001;
|
| 26 |
+
display: none;
|
| 27 |
+
width: 400px;
|
| 28 |
+
height: 300px;
|
| 29 |
+
position: fixed;
|
| 30 |
+
top: 50%;
|
| 31 |
+
left: 50%;
|
| 32 |
+
margin: -200px 0 0 -200px;
|
| 33 |
+
line-height: normal;
|
| 34 |
+
background: #fefefe; /* Old browsers */
|
| 35 |
+
background: -moz-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 36 |
+
/* FF3.6+ */
|
| 37 |
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fefefe),
|
| 38 |
+
color-stop(100%, #f1f2f4)); /* Chrome,Safari4+ */
|
| 39 |
+
background: -webkit-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 40 |
+
/* Chrome10+,Safari5.1+ */
|
| 41 |
+
background: -o-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 42 |
+
/* Opera 11.10+ */
|
| 43 |
+
background: -ms-linear-gradient(top, #fefefe 0%, #f1f2f4 100%);
|
| 44 |
+
/* IE10+ */
|
| 45 |
+
background: linear-gradient(to bottom, #fefefe 0%, #f1f2f4 100%);
|
| 46 |
+
/* W3C */
|
| 47 |
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fefefe',
|
| 48 |
+
endColorstr='#f1f2f4', GradientType=0); /* IE6-9 */
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
#ppmx_popup .ppmx_logo {
|
| 52 |
+
float: right;
|
| 53 |
+
margin: 10px;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
#ppmx_popup .ppmx_content {
|
| 57 |
+
margin-top: 80px;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
#ppmx_popup .ppmx_loader {
|
| 61 |
+
display: block;
|
| 62 |
+
margin: 20px 0 0 0px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
#ppmx_popup .ppmx_loader div {
|
| 66 |
+
color: #0071BB;
|
| 67 |
+
font-size: 10px;
|
| 68 |
+
text-align: center;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
#ppmx_popup .ppmx_loader img {
|
| 72 |
+
position: relative;
|
| 73 |
+
left: 50%;
|
| 74 |
+
margin: 0 0 15px -85px;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
#ppmx_popup .ppmx_title {
|
| 78 |
+
font-size: 25px;
|
| 79 |
+
color: #0F4073;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
#ppmx_popup .ppmx_box {
|
| 83 |
+
margin: 0 10px 0 0;
|
| 84 |
+
float: left;
|
| 85 |
+
width: 50px;
|
| 86 |
+
height: 100px;
|
| 87 |
+
background: #0079C0;
|
| 88 |
+
-webkit-border-top-right-radius: 6px;
|
| 89 |
+
-webkit-border-bottom-right-radius: 6px;
|
| 90 |
+
-moz-border-radius-topright: 6px;
|
| 91 |
+
-moz-border-radius-bottomright: 6px;
|
| 92 |
+
border-top-right-radius: 6px;
|
| 93 |
+
border-bottom-right-radius: 6px;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
#tooltip {
|
| 97 |
+
margin: 0 0 0 150px;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
#tooltip:hover #nopos {
|
| 101 |
+
display: inline;
|
| 102 |
+
position: absolute;
|
| 103 |
+
color: #1182C5;
|
| 104 |
+
border: 1px solid #1182C5;
|
| 105 |
+
background: #FFFFFF;
|
| 106 |
+
text-align: left;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
#nopos {
|
| 110 |
+
z-index: 10;
|
| 111 |
+
display: none;
|
| 112 |
+
padding: 14px 20px;
|
| 113 |
+
margin: 35px 0 0 -200px;
|
| 114 |
+
width: 235px;
|
| 115 |
+
line-height: 16px;
|
| 116 |
+
font-size: 10px;
|
| 117 |
+
border-radius: 4px;
|
| 118 |
+
-moz-border-radius: 4px;
|
| 119 |
+
-webkit-border-radius: 4px;
|
| 120 |
+
-moz-box-shadow: 0px 0px 20px 5px #CCC;
|
| 121 |
+
-webkit-box-shadow: 0px 0px 20px 5px #CCC;
|
| 122 |
+
box-shadow: 0px 0px 20px 5px #CCC;
|
| 123 |
+
display: none;
|
| 124 |
+
background-color: #000000;
|
| 125 |
+
-webkit-transition: opacity 0.2s ease;
|
| 126 |
+
-moz-transition: opacity 0.2s ease;
|
| 127 |
+
-o-transition: opacity 0.2s ease;
|
| 128 |
+
}
|
| 129 |
+
</style>
|
| 130 |
+
|
| 131 |
+
<script type="text/javascript">
|
| 132 |
+
|
| 133 |
+
var PpmxShippingMethod = Class.create();
|
| 134 |
+
PpmxShippingMethod.prototype = {
|
| 135 |
+
initialize: function(form, saveUrl){
|
| 136 |
+
this.form = form;
|
| 137 |
+
if ($(this.form)) {
|
| 138 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
| 139 |
+
}
|
| 140 |
+
this.saveUrl = saveUrl;
|
| 141 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
| 142 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
| 143 |
+
|
| 144 |
+
},
|
| 145 |
+
save: function(){
|
| 146 |
+
|
| 147 |
+
if (checkout.loadWaiting!=false) return;
|
| 148 |
+
if (true) {
|
| 149 |
+
checkout.setLoadWaiting('shipping-method');
|
| 150 |
+
var request = new Ajax.Request(
|
| 151 |
+
this.saveUrl,
|
| 152 |
+
{
|
| 153 |
+
method:'post',
|
| 154 |
+
onComplete: this.onComplete,
|
| 155 |
+
onSuccess: this.onSave,
|
| 156 |
+
onFailure: this.failppmx,
|
| 157 |
+
parameters: Form.serialize(this.form)
|
| 158 |
+
}
|
| 159 |
+
);
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
failppmx: function(){
|
| 163 |
+
takeoffppmxloading();
|
| 164 |
+
checkout.ajaxFailure.bind(checkout);
|
| 165 |
+
},
|
| 166 |
+
resetLoadWaiting: function(transport){
|
| 167 |
+
checkout.setLoadWaiting(false);
|
| 168 |
+
},
|
| 169 |
+
|
| 170 |
+
nextStep: function(transport){
|
| 171 |
+
if (transport && transport.responseText){
|
| 172 |
+
try{
|
| 173 |
+
response = eval('(' + transport.responseText + ')');
|
| 174 |
+
}
|
| 175 |
+
catch (e) {
|
| 176 |
+
response = {};
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
if (response.error) {
|
| 181 |
+
alert(response.message);
|
| 182 |
+
return false;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
if (response.update_section) {
|
| 186 |
+
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
|
| 187 |
+
}
|
| 188 |
+
payment.initWhatIsCvvListeners();
|
| 189 |
+
if (response.goto_section) {
|
| 190 |
+
//checkout.gotoSection(response.goto_section);
|
| 191 |
+
checkout.reloadProgressBlock();
|
| 192 |
+
|
| 193 |
+
this.ppmxRedirectPayment();
|
| 194 |
+
return;
|
| 195 |
+
}
|
| 196 |
+
if (response.payment_methods_html) {
|
| 197 |
+
$('checkout-payment-method-load').update(response.payment_methods_html);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
checkout.setShippingMethod();
|
| 201 |
+
|
| 202 |
+
this.ppmxRedirectPayment();
|
| 203 |
+
},
|
| 204 |
+
|
| 205 |
+
ppmxRedirectPayment: function() {
|
| 206 |
+
setTimeout(function () {
|
| 207 |
+
window.location = "<?php echo $this->getCheckoutUrl()?>";
|
| 208 |
+
}, 2000);
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
ppmxshippingMethod = new PpmxShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
|
| 213 |
+
|
| 214 |
+
</script>
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
|
| 218 |
+
|
| 219 |
+
<script type="text/javascript">
|
| 220 |
+
$j = jQuery.noConflict();
|
| 221 |
+
|
| 222 |
+
function onclickshortcutppmx(){
|
| 223 |
+
entro = false;
|
| 224 |
+
methodSelected = false;
|
| 225 |
+
$j('#co-shipping-method-form :input:radio').each(function (i){
|
| 226 |
+
entro = true;
|
| 227 |
+
if(this.checked){
|
| 228 |
+
methodSelected = true;
|
| 229 |
+
return;
|
| 230 |
+
}
|
| 231 |
+
});;
|
| 232 |
+
if(entro && !methodSelected){
|
| 233 |
+
alert("Seleccione una forma de envío.");
|
| 234 |
+
return;
|
| 235 |
+
}
|
| 236 |
+
showbtnppmx();
|
| 237 |
+
ppmxshippingMethod.save();
|
| 238 |
+
//$j.when($j("#shipping-method-buttons-container :button").trigger("click")).done(window.location = "<?php echo $this->getCheckoutUrl()?>");
|
| 239 |
+
}
|
| 240 |
+
$j( document ).ready(function() {
|
| 241 |
+
$j('#payment-buttons-container :input').click(function() {
|
| 242 |
+
onclickpaymentppmx();
|
| 243 |
+
});
|
| 244 |
+
$j('#btnscppmx').prependTo('#shipping-method-buttons-container');
|
| 245 |
+
$j('#btnscppmx').css("display", "inline-block");
|
| 246 |
+
});
|
| 247 |
+
function sortPPMX(){
|
| 248 |
+
$j( '#p_method_ppmx' ).parent().after($j('#p_method_ppmx_debito2').parent());
|
| 249 |
+
$j( '#p_method_ppmx_debito2').parent().after($j('#p_method_ppmx_mensualidades2').parent());
|
| 250 |
+
if(!validateifselectedppmx()) {
|
| 251 |
+
$j('#p_method_ppmx').attr('checked','checked');
|
| 252 |
+
payment.switchMethod('ppmx');
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
function validateifselectedppmx(){
|
| 256 |
+
var val = false;
|
| 257 |
+
$j('#co-payment-form :input:radio').each(function (i){
|
| 258 |
+
if((this.value=="ppmx"||this.value=="ppmx_debito2"|| this.value=="ppmx_mensualidades2") && this.checked){
|
| 259 |
+
val = true;
|
| 260 |
+
}
|
| 261 |
+
});;
|
| 262 |
+
return val;
|
| 263 |
+
};
|
| 264 |
+
function onclickpaymentppmx(){
|
| 265 |
+
if(validateifselectedppmx()){
|
| 266 |
+
showbtnppmx();
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
function takeoffppmxloading(){
|
| 270 |
+
$j('#backgr').css("display", "none");
|
| 271 |
+
$j('#ppmx_popup').css("display", "none");
|
| 272 |
+
}
|
| 273 |
+
function showbtnppmx(){
|
| 274 |
+
$j('#backgr').css("display", "inline");
|
| 275 |
+
$j('#ppmx_popup').css("display", "inline");
|
| 276 |
+
}
|
| 277 |
+
</script>
|
| 278 |
+
<div id="backgr"></div>
|
| 279 |
+
<div id='ppmx_popup'>
|
| 280 |
+
<img style="width: 125px; height: 44px"
|
| 281 |
+
src="<?php echo $this->getSkinUrl('images/paypalmx/bdg_compra_segura_pp_.PNG'); ?>"
|
| 282 |
+
class='ppmx_logo'>
|
| 283 |
+
<div class='ppmx_content'>
|
| 284 |
+
<div class='ppmx_box'></div>
|
| 285 |
+
<span class='ppmx_title'>Lo estamos redirigiendo a los servidores
|
| 286 |
+
seguros</span></br>
|
| 287 |
+
<div class='ppmx_loader'>
|
| 288 |
+
<img alt=""
|
| 289 |
+
src="<?php echo $this->getSkinUrl('images/paypalmx/paypalmx_loader.gif');?>">
|
| 290 |
+
<div>Usted puede pagar con tarjetas de crédito y débito</div>
|
| 291 |
+
</div>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
<?php if($this->prueba()){ $shortcutHtmlId = $this->getShortcutHtmlId(); ?>
|
| 295 |
+
<span id="btnscppmx" onClick="onclickshortcutppmx()">
|
| 296 |
+
<p class="paypal-logo">
|
| 297 |
+
<?php if ($this->isOrPositionBefore()): ?>
|
| 298 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?> </span>
|
| 299 |
+
<?php endif; ?>
|
| 300 |
+
|
| 301 |
+
<a id="<?php echo $shortcutHtmlId ?>"><img
|
| 302 |
+
src="<?php echo $this->getImageUrl()?>"
|
| 303 |
+
alt="<?php echo Mage::helper('paypalmx')->__('Pague con PayPal');?>"
|
| 304 |
+
title="<?php echo Mage::helper('paypalmx')->__('Pague con PayPal');?>" />
|
| 305 |
+
</a>
|
| 306 |
+
<?php if ($this->isOrPositionAfter()): ?>
|
| 307 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?> </span>
|
| 308 |
+
<?php endif; ?>
|
| 309 |
+
<?php if ($this->getConfirmationUrl() || $this->getIsInCatalogProduct()): ?>
|
| 310 |
+
<?php if ($this->getIsInCatalogProduct()): ?>
|
| 311 |
+
<input type="hidden" id="pp_checkout_url" name="return_url" value="" />
|
| 312 |
+
<?php endif; ?>
|
| 313 |
+
<script type="text/javascript">
|
| 314 |
+
//<![CDATA[
|
| 315 |
+
Event.observe('<?php echo $shortcutHtmlId ?>', 'click', function(event) {
|
| 316 |
+
<?php if ($this->getConfirmationUrl()): ?>
|
| 317 |
+
if (confirm('<?php echo Mage::helper('core')->jsQuoteEscape($this->getConfirmationMessage())?>')) {
|
| 318 |
+
this.href = '<?php echo $this->getConfirmationUrl() ?>';
|
| 319 |
+
}
|
| 320 |
+
<?php endif; ?>
|
| 321 |
+
<?php if ($this->getIsInCatalogProduct()): ?>
|
| 322 |
+
$('pp_checkout_url').value = this.href;
|
| 323 |
+
productAddToCartForm.submit(this);
|
| 324 |
+
event.stop();
|
| 325 |
+
<?php endif; ?>
|
| 326 |
+
});
|
| 327 |
+
//]]>
|
| 328 |
+
</script>
|
| 329 |
+
<?php endif;?>
|
| 330 |
+
</p>
|
| 331 |
+
</span>
|
| 332 |
+
<?php } ?>
|
app/design/frontend/base/default/template/paypalmx/hss/form.phtml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Payflow_Link_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head></head>
|
| 33 |
+
<body>
|
| 34 |
+
<form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>">
|
| 35 |
+
<input type="hidden" name="SECURETOKEN" value="<?php echo $this->getSecureToken(); ?>" />
|
| 36 |
+
<input type="hidden" name="SECURETOKENID" value="<?php echo $this->getSecureTokenId(); ?>" />
|
| 37 |
+
<input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>" />
|
| 38 |
+
</form>
|
| 39 |
+
<script type="text/javascript">
|
| 40 |
+
//<![CDATA[
|
| 41 |
+
document.getElementById('token_form').submit();
|
| 42 |
+
//]]>
|
| 43 |
+
</script>
|
| 44 |
+
</body>
|
| 45 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/hss/iframe.phtml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
?>
|
| 28 |
+
<div id="iframe-warning" class="warning-message">
|
| 29 |
+
<?php echo $this->__('Please do not refresh the page until you complete payment.') ?>
|
| 30 |
+
</div>
|
| 31 |
+
<iframe id="hss-iframe" style="display:none;" scrolling="no" frameborder="0" border="0" src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="570"></iframe>
|
| 32 |
+
<script type="text/javascript">
|
| 33 |
+
//<![CDATA[
|
| 34 |
+
var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section');
|
| 35 |
+
headers.each(function(header) {
|
| 36 |
+
header.removeClassName('allow');
|
| 37 |
+
});
|
| 38 |
+
$('hss-iframe').observe('load', function(){
|
| 39 |
+
$('hss-iframe').show();
|
| 40 |
+
$('iframe-warning').show();
|
| 41 |
+
checkout.loadWaiting = 'review';
|
| 42 |
+
checkout.setLoadWaiting(false);
|
| 43 |
+
if (checkout.accordion.currentSection == 'opc-review') {
|
| 44 |
+
$('checkout-review-submit').hide();
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
//]]>
|
| 48 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/hss/info.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Payflow_Link_Info
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list">
|
| 32 |
+
<li>
|
| 33 |
+
<?php echo $this->__('You will be required to enter your payment details after you place an order.') ?>
|
| 34 |
+
</li>
|
| 35 |
+
</ul>
|
app/design/frontend/base/default/template/paypalmx/hss/js.phtml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<div id="checkout-paypaliframe-load" class="authentication"></div>
|
| 32 |
+
<script type="text/javascript">
|
| 33 |
+
//<![CDATA[
|
| 34 |
+
Review.prototype.save = function() {
|
| 35 |
+
if (checkout.loadWaiting!=false) return;
|
| 36 |
+
checkout.setLoadWaiting('review');
|
| 37 |
+
var params = Form.serialize(payment.form);
|
| 38 |
+
if (this.agreementsForm) {
|
| 39 |
+
params += '&'+Form.serialize(this.agreementsForm);
|
| 40 |
+
}
|
| 41 |
+
params.save = true;
|
| 42 |
+
var request = new Ajax.Request(
|
| 43 |
+
this.saveUrl,
|
| 44 |
+
{
|
| 45 |
+
method:'post',
|
| 46 |
+
parameters:params,
|
| 47 |
+
onComplete: function(transport) {
|
| 48 |
+
if (transport && transport.responseText) {
|
| 49 |
+
try{
|
| 50 |
+
response = eval('(' + transport.responseText + ')');
|
| 51 |
+
}
|
| 52 |
+
catch (e) {
|
| 53 |
+
response = {};
|
| 54 |
+
}
|
| 55 |
+
if (response.error_messages) {
|
| 56 |
+
checkout.setLoadWaiting(false);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
onSuccess: this.onSave,
|
| 61 |
+
onFailure: checkout.ajaxFailure.bind(checkout)
|
| 62 |
+
}
|
| 63 |
+
);
|
| 64 |
+
}
|
| 65 |
+
//]]>
|
| 66 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/hss/redirect.phtml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head>
|
| 33 |
+
<script type="text/javascript">
|
| 34 |
+
//<![CDATA[
|
| 35 |
+
if (window.top == window.self) {
|
| 36 |
+
window.location = "<?php echo $this->getUrl('checkout/cart') ?>";
|
| 37 |
+
}
|
| 38 |
+
<?php if ($this->getGotoSection()): ?>
|
| 39 |
+
for (var s = 0; s < window.top.checkout.steps.length; s++) {
|
| 40 |
+
if (window.top.checkout.steps[s] == '<?php echo $this->getGotoSection() ?>') {
|
| 41 |
+
break;
|
| 42 |
+
}
|
| 43 |
+
if (window.top.document.getElementById('opc-' + window.top.checkout.steps[s])) {
|
| 44 |
+
window.top.document.getElementById('opc-' + window.top.checkout.steps[s]).addClassName('allow');
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
window.top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>");
|
| 48 |
+
window.top.document.getElementById('checkout-review-submit').show();
|
| 49 |
+
window.top.document.getElementById('iframe-warning').hide();
|
| 50 |
+
<?php if ($this->getErrorMsg()): ?>
|
| 51 |
+
alert('<?php echo $this->getErrorMsg() ?>');
|
| 52 |
+
<?php endif; ?>
|
| 53 |
+
<?php elseif ($this->getGotoSuccessPage()) : ?>
|
| 54 |
+
window.top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>";
|
| 55 |
+
<?php else : ?>
|
| 56 |
+
window.top.location="<?php echo $this->getUrl('checkout/cart') ?>";
|
| 57 |
+
<?php endif; ?>
|
| 58 |
+
//]]>
|
| 59 |
+
</script>
|
| 60 |
+
</head>
|
| 61 |
+
<body></body>
|
| 62 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/hss/review/button.phtml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<button type="submit" title="<?php echo $this->__('Continue') ?>" class="button btn-checkout" onclick="review.save();"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
app/design/frontend/base/default/template/paypalmx/partner/logo.phtml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
?>
|
| 3 |
+
<?php
|
| 4 |
+
/**
|
| 5 |
+
* @see Mage_Paypal_Block_Logo
|
| 6 |
+
*/
|
| 7 |
+
?>
|
| 8 |
+
<div class="paypal-logo">
|
| 9 |
+
<a href="#" title="<?php echo Mage::helper('paypalmx')->__('Additional Options') ?>" onclick="javascript:window.open('<?php echo $this->getAboutPaypalPageUrl() ?>','paypalmx','width=600,height=350,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;"><img src="<?php echo $this->escapeHtml($this->getLogoImageUrl()) ?>" alt="<?php echo Mage::helper('paypalmx')->__('Additional Options') ?>" title="<?php echo Mage::helper('paypalmx')->__('Additional Options') ?>" /></a>
|
| 10 |
+
</div>
|
app/design/frontend/base/default/template/paypalmx/payflowadvanced/form.phtml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var $this Mage_Paypal_Block_Payflow_Advanced_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head></head>
|
| 33 |
+
<body>
|
| 34 |
+
<form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>">
|
| 35 |
+
<input type="hidden" name="SECURETOKEN" value="<?php echo $this->getSecureToken(); ?>" />
|
| 36 |
+
<input type="hidden" name="SECURETOKENID" value="<?php echo $this->getSecureTokenId(); ?>" />
|
| 37 |
+
<input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>" />
|
| 38 |
+
</form>
|
| 39 |
+
<script type="text/javascript">
|
| 40 |
+
//<![CDATA[
|
| 41 |
+
document.getElementById('token_form').submit();
|
| 42 |
+
//]]>
|
| 43 |
+
</script>
|
| 44 |
+
</body>
|
| 45 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/payflowadvanced/iframe.phtml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
/** @var $this Mage_Paypal_Block_Payflow_Advanced_Form */
|
| 27 |
+
?>
|
| 28 |
+
<div id="iframe-warning" class="warning-message">
|
| 29 |
+
<?php echo $this->__('Please do not refresh the page until you complete payment.') ?>
|
| 30 |
+
</div>
|
| 31 |
+
<iframe id="payflow-advanced-iframe" style="display:none;" scrolling="no" frameborder="0" border="0" src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="570"></iframe>
|
| 32 |
+
<script type="text/javascript">
|
| 33 |
+
//<![CDATA[
|
| 34 |
+
var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section');
|
| 35 |
+
headers.each(function(header) {
|
| 36 |
+
header.removeClassName('allow');
|
| 37 |
+
});
|
| 38 |
+
$('payflow-advanced-iframe').observe('load', function(){
|
| 39 |
+
$('payflow-advanced-iframe').show();
|
| 40 |
+
$('iframe-warning').show();
|
| 41 |
+
checkout.loadWaiting = 'review';
|
| 42 |
+
checkout.setLoadWaiting(false);
|
| 43 |
+
if (checkout.accordion.currentSection == 'opc-review') {
|
| 44 |
+
$('checkout-review-submit').hide();
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
//]]>
|
| 48 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/payflowadvanced/info.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var $this Mage_Paypal_Block_Payflow_Advanced_Form
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list">
|
| 32 |
+
<li>
|
| 33 |
+
<?php echo $this->__('You will be required to enter your payment details after you place an order.') ?>
|
| 34 |
+
</li>
|
| 35 |
+
</ul>
|
app/design/frontend/base/default/template/paypalmx/payflowadvanced/redirect.phtml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var $this Mage_Paypal_Block_Payflow_Advanced_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head>
|
| 33 |
+
<script type="text/javascript">
|
| 34 |
+
//<![CDATA[
|
| 35 |
+
if (window.top == window.self) {
|
| 36 |
+
window.location = "<?php echo $this->getUrl('checkout/cart') ?>";
|
| 37 |
+
}
|
| 38 |
+
var window_top = window.top;
|
| 39 |
+
<?php if ($this->getGotoSection()): ?>
|
| 40 |
+
var checkout_steps;
|
| 41 |
+
|
| 42 |
+
try{
|
| 43 |
+
checkout_steps = window.top.checkout.steps
|
| 44 |
+
}catch(e){
|
| 45 |
+
window_top.location="<?php echo $this->getUrl('checkout/cart') ?>";
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
for (var s = 0; s < checkout_steps.length; s++) {
|
| 49 |
+
if (checkout_steps[s] == '<?php echo $this->getGotoSection() ?>') {
|
| 50 |
+
break;
|
| 51 |
+
}
|
| 52 |
+
if (window_top.document.getElementById('opc-' + checkout_steps[s])) {
|
| 53 |
+
window_top.document.getElementById('opc-' + checkout_steps[s]).addClassName('allow');
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
window_top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>");
|
| 57 |
+
window_top.document.getElementById('checkout-review-submit').show();
|
| 58 |
+
window_top.document.getElementById('iframe-warning').hide();
|
| 59 |
+
<?php if ($this->getErrorMsg()): ?>
|
| 60 |
+
alert('<?php echo $this->getErrorMsg() ?>');
|
| 61 |
+
<?php endif; ?>
|
| 62 |
+
<?php elseif ($this->getGotoSuccessPage()) : ?>
|
| 63 |
+
window_top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>";
|
| 64 |
+
<?php else : ?>
|
| 65 |
+
window_top.location="<?php echo $this->getUrl('checkout/cart') ?>";
|
| 66 |
+
<?php endif; ?>
|
| 67 |
+
//]]>
|
| 68 |
+
</script>
|
| 69 |
+
</head>
|
| 70 |
+
<body></body>
|
| 71 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/payflowlink/form.phtml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Payflow_Link_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head></head>
|
| 33 |
+
<body>
|
| 34 |
+
<form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>">
|
| 35 |
+
<input type="hidden" name="SECURETOKEN" value="<?php echo $this->getSecureToken(); ?>" />
|
| 36 |
+
<input type="hidden" name="SECURETOKENID" value="<?php echo $this->getSecureTokenId(); ?>" />
|
| 37 |
+
<input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>" />
|
| 38 |
+
</form>
|
| 39 |
+
<script type="text/javascript">
|
| 40 |
+
//<![CDATA[
|
| 41 |
+
document.getElementById('token_form').submit();
|
| 42 |
+
//]]>
|
| 43 |
+
</script>
|
| 44 |
+
</body>
|
| 45 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/payflowlink/iframe.phtml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
/** @var $this Mage_Paypal_Block_Payflow_Link_Form */
|
| 27 |
+
?>
|
| 28 |
+
<div id="iframe-warning" class="warning-message">
|
| 29 |
+
<?php echo $this->__('Please do not refresh the page until you complete payment.') ?>
|
| 30 |
+
</div>
|
| 31 |
+
<iframe id="payflow-link-iframe" style="display:none;" scrolling="no" frameborder="0" border="0" src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="570"></iframe>
|
| 32 |
+
<script type="text/javascript">
|
| 33 |
+
//<![CDATA[
|
| 34 |
+
var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section');
|
| 35 |
+
headers.each(function(header) {
|
| 36 |
+
header.removeClassName('allow');
|
| 37 |
+
});
|
| 38 |
+
$('payflow-link-iframe').observe('load', function(){
|
| 39 |
+
$('payflow-link-iframe').show();
|
| 40 |
+
$('iframe-warning').show();
|
| 41 |
+
checkout.loadWaiting = 'review';
|
| 42 |
+
checkout.setLoadWaiting(false);
|
| 43 |
+
if (checkout.accordion.currentSection == 'opc-review') {
|
| 44 |
+
$('checkout-review-submit').hide();
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
//]]>
|
| 48 |
+
</script>
|
app/design/frontend/base/default/template/paypalmx/payflowlink/info.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var $this Mage_Paypal_Block_Payflow_Link_Form
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list">
|
| 32 |
+
<li>
|
| 33 |
+
<?php echo $this->__('You will be required to enter your payment details after you place an order.') ?>
|
| 34 |
+
</li>
|
| 35 |
+
</ul>
|
app/design/frontend/base/default/template/paypalmx/payflowlink/redirect.phtml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var $this Mage_Paypal_Block_Payflow_Link_Iframe
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<html>
|
| 32 |
+
<head>
|
| 33 |
+
<script type="text/javascript">
|
| 34 |
+
//<![CDATA[
|
| 35 |
+
if (window.top == window.self) {
|
| 36 |
+
window.location = "<?php echo $this->getUrl('checkout/cart') ?>";
|
| 37 |
+
}
|
| 38 |
+
var window_top = window.top;
|
| 39 |
+
<?php if ($this->getGotoSection()): ?>
|
| 40 |
+
var checkout_steps;
|
| 41 |
+
|
| 42 |
+
try{
|
| 43 |
+
checkout_steps = window.top.checkout.steps
|
| 44 |
+
}catch(e){
|
| 45 |
+
window_top.location="<?php echo $this->getUrl('checkout/cart') ?>";
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
for (var s = 0; s < checkout_steps.length; s++) {
|
| 49 |
+
if (checkout_steps[s] == '<?php echo $this->getGotoSection() ?>') {
|
| 50 |
+
break;
|
| 51 |
+
}
|
| 52 |
+
if (window_top.document.getElementById('opc-' + checkout_steps[s])) {
|
| 53 |
+
window_top.document.getElementById('opc-' + checkout_steps[s]).addClassName('allow');
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
window_top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>");
|
| 57 |
+
window_top.document.getElementById('checkout-review-submit').show();
|
| 58 |
+
window_top.document.getElementById('iframe-warning').hide();
|
| 59 |
+
<?php if ($this->getErrorMsg()): ?>
|
| 60 |
+
alert('<?php echo $this->getErrorMsg() ?>');
|
| 61 |
+
<?php endif; ?>
|
| 62 |
+
<?php elseif ($this->getGotoSuccessPage()) : ?>
|
| 63 |
+
window_top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>";
|
| 64 |
+
<?php else : ?>
|
| 65 |
+
window_top.location="<?php echo $this->getUrl('checkout/cart') ?>";
|
| 66 |
+
<?php endif; ?>
|
| 67 |
+
//]]>
|
| 68 |
+
</script>
|
| 69 |
+
</head>
|
| 70 |
+
<body></body>
|
| 71 |
+
</html>
|
app/design/frontend/base/default/template/paypalmx/payment/mark.phtml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Note: This mark is a requirement of PayPal
|
| 4 |
+
* @see Mage_Paypal_Block_Standard_Form
|
| 5 |
+
*/
|
| 6 |
+
/*
|
| 7 |
+
<!-- PayPal Logo -->
|
| 8 |
+
<img src="<?php echo $this->escapeHtml($this->getPaymentAcceptanceMarkSrc())?>" alt="<?php echo Mage::helper('paypalmx')->__('Acceptance Mark') ?>" class="v-middle" />
|
| 9 |
+
<a href="<?php echo $this->getPaymentAcceptanceMarkHref()?>" onclick="javascript:window.open('<?php echo $this->getPaymentAcceptanceMarkHref()?>','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=400, height=350'); return false;"><?php echo Mage::helper('paypalmx')->__('¿Qué es PayPal?') ?></a>
|
| 10 |
+
<!-- PayPal Logo -->
|
| 11 |
+
*/
|
| 12 |
+
?>
|
| 13 |
+
<!-- PayPal Logo -->
|
| 14 |
+
<img <?php if ($this->getNoPosAH() == 2) { ?>style="width:105px;height:35px;"<?php }?> id="imagemx" src="<?php
|
| 15 |
+
switch ($this->getNoPosAH()){
|
| 16 |
+
case "1":
|
| 17 |
+
echo $this->getSkinUrl('images/paypalmx/accpmark_mensualidades_SP.PNG');
|
| 18 |
+
break;
|
| 19 |
+
case "2":
|
| 20 |
+
echo $this->getSkinUrl('images/paypalmx/accpmark_visa_mc_SP.PNG');
|
| 21 |
+
break;
|
| 22 |
+
case "3":
|
| 23 |
+
echo $this->getSkinUrl('images/paypalmx/accpmark_tarjdeb_SP.PNG');
|
| 24 |
+
break;
|
| 25 |
+
}
|
| 26 |
+
?>" alt="<?php echo Mage::helper('paypalmx')->__('Acceptance Mark') ?>" class="v-middle" />
|
| 27 |
+
<?php if($this->getNoPosAH() == 2){?><span id="tooltip"><a> <?php echo Mage::helper('paypalmx')->__('¿Qué es PayPal?') ?></a><span id="nopos">
|
| 28 |
+
<ul>
|
| 29 |
+
<li>·Es un medio de pago fácil, rápido y seguro.</li>
|
| 30 |
+
<li>·Puede hacer pagos con tarjeta de crédito y débito.</li>
|
| 31 |
+
<li>·Registre en PayPal sus datos financieros una sola vez. No necesitará proporcionarlos en compras posteriores.</li>
|
| 32 |
+
<li>·Más de 100 millones de personas en el mundo utilizan PayPal.</li>
|
| 33 |
+
<li>·PayPal protege su información; No compartimos sus datos financieros.</li>
|
| 34 |
+
</ul>
|
| 35 |
+
</span></span> <?php }?>
|
| 36 |
+
<script >
|
| 37 |
+
sortPPMX();
|
| 38 |
+
</script>
|
| 39 |
+
<!-- PayPal Logo -->
|
app/design/frontend/base/default/template/paypalmx/payment/redirect.phtml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<?php
|
| 3 |
+
/**
|
| 4 |
+
* @see Mage_PayPal_Block_Express_Form
|
| 5 |
+
* @see Mage_PayPal_Block_Standard_Form
|
| 6 |
+
*/
|
| 7 |
+
?>
|
| 8 |
+
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
|
| 9 |
+
<li class="form-alt"><?php echo $this->getRedirectMessage() ?></li>
|
| 10 |
+
<?php if ($code = $this->getCreateBACode()): ?>
|
| 11 |
+
<li class="form-alt">
|
| 12 |
+
<label for="<?php echo $code ?>"><input type="checkbox" id="<?php echo $code ?>" value="1" name="payment[<?php echo $code ?>]" class="checkbox" />
|
| 13 |
+
<?php echo $this->__('Sign a billing agreement to streamline further purchases with PayPal.') ?></label>
|
| 14 |
+
</li>
|
| 15 |
+
<?php endif; ?>
|
| 16 |
+
</ul>
|
app/etc/modules/Ebcomm_PaypalMx.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Ebcomm_PaypalMx>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<version>1.0.0</version>
|
| 8 |
+
</Ebcomm_PaypalMx>
|
| 9 |
+
</modules>
|
| 10 |
+
</config>
|
app/locale/es_ES/Ebcomm_PaypalMx.csv
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"-OR-","-O-"
|
| 2 |
+
"2-pixel perimeter around the header space.","Perímetro de 2 píxeles alrededor del espacio de cabera."
|
| 3 |
+
"3D Secure","3D Seguro"
|
| 4 |
+
"3D Secure Card Validation","Validación segura 3D de tarjeta"
|
| 5 |
+
"3D Secure validation is required for Maestro cards. Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Para tarjetas Maestro se requiere validación 3D Secure. Para aceptar tarjetas American Express se requiere un acuerdo adicional. Obtenga más información en <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>."
|
| 6 |
+
"<a href=""http://www.magentocommerce.com/paypal"">Start accepting payments via PayPal!</a>","<a href=""http://www.magentocommerce.com/paypal"">¡Empiece a aceptar pagos a través de PayPal!</a>"
|
| 7 |
+
"A value is required for live mode. Refer to your CardinalCommerce agreement.","Se necesita un valor para el modo en vivo. Consulte el acuerdo de comercio cardinal."
|
| 8 |
+
"ACH Deposit (Hold for Dispute or Other Investigation)","Depósito ACH (En Espera por Conflicto u Otra Investigación)"
|
| 9 |
+
"ACH Deposit (Reversal)","Depósito ACH (Revocación)"
|
| 10 |
+
"ACH Funding for Funds Recovery from Account Balance","Financiación ACH para Recuperación de Fondos desde el Balance de Cuenta"
|
| 11 |
+
"ACH Withdrawal","Retirada ACH"
|
| 12 |
+
"API Authentication Methods","Métodos de autenticación API"
|
| 13 |
+
"API Certificate","Certificdo API"
|
| 14 |
+
"API Password","Contraseña API"
|
| 15 |
+
"API Signature","Firma API"
|
| 16 |
+
"API Username","Nombre de Usuario API"
|
| 17 |
+
"API Uses Proxy","Proxy de Usos API"
|
| 18 |
+
"API/Integration","Api/Integración"
|
| 19 |
+
"API/Integration Settings","Api/Configuración de Integración"
|
| 20 |
+
"Ability for buyer to purchase without PayPal account.","Capacidad del comprador para comprar sin cuenta PayPal."
|
| 21 |
+
"Accept PayPal payments in your shopping cart. PayPal will process your credit card payments through the Payflow Pro Gateway.","Aceptar pagos PayPal en tu carro de la compra. PayPal procesará tus pagos de tarjeta de crédito a través del Gateway Payflow Pro"
|
| 22 |
+
"Accept payments with a PCI-compliant checkout that keeps customers on your site. Includes a merchant account from PayPal.","Aceptar pagos conformes a la norma PCI de verificación que mantiene a los clientes en tu sitio web. Incluye una cuenta comercial de PayPal."
|
| 23 |
+
"Accept payments with a PCI-compliant checkout that keeps customers on your site. For use with your own merchant account.","Aceptar pagos conformes a la norma PCI de verificación que mantiene a los clientes en tu sitio web. Para usarlo con tu propia cuenta comercial."
|
| 24 |
+
"Accept payments without customers leaving your website. Many popular web-hosting services and shopping carts come with the Payflow payment gateways built in, so they are easy to set up.","Aceptar pagos sin que los clientes abandonen tu página web. Muchos servicios populares de web-hosting y carros de la compra vienen con los gateways de pago Payflow incluidos, de manera que sean fáciles de configurar."
|
| 25 |
+
"Acceptance Mark","Señal de Aceptación"
|
| 26 |
+
"Acceptance Mark Image","Imagen de Señal de Aceptación"
|
| 27 |
+
"Account-to-Account Payment, initiated by PayPal","Pago Cuenta-a-Cuenta, iniciado por PayPal"
|
| 28 |
+
"Add an Express Checkout button to your existing shopping cart for quick and easy credit card payments. PayPal handles all payment processing.","Añadir un botón de Pago Express a tu carro de la compra ya existente para pagos con tarjeta de crédito rápidos y sencillos. PayPal gestiona todo el proceso de pago."
|
| 29 |
+
"Additional Options","Opciones Adicionales"
|
| 30 |
+
"Address","Dirección"
|
| 31 |
+
"Address Verification System Response","Respuesta del Sistema de Verificación de Dirección"
|
| 32 |
+
"All the address information matched","Coincide toda la información de dirección"
|
| 33 |
+
"Allow in Billing Agreement Wizard","Permitir el Asistente de Acuerdo de Facturación"
|
| 34 |
+
"Allowable values: ""paypal"", ""primary"" (default), your_custom_value (a custom payment page style from your merchant account profile).","Valores admitidos: ""paypal"", ""primary"" (por defecto), su_valor_customizado (estílo de página de pago customizado de su perfil de cuenta comercial)."
|
| 35 |
+
"Allowed Credit Card Types","Tipos de Tarjetas de Crédito Permitidos"
|
| 36 |
+
"Also affects mini-shopping cart.","También afecta al mini-carro de la compra."
|
| 37 |
+
"Ask Customer","Preguntar al Cliente"
|
| 38 |
+
"Attempted Authentication, Bad Result","Intento de Autenticación, Resultado Incorrecto"
|
| 39 |
+
"Attempted Authentication, Good Result","Intento de Autenticación, Resultado Correcto"
|
| 40 |
+
"Auction Payment other than through eBay","Pago por Subasta diferente de eBay"
|
| 41 |
+
"Authenticated, Bad Result","Autenticación, Resultado Incorrecto"
|
| 42 |
+
"Authenticated, Good Result","Autenticación, Resultado Correcto"
|
| 43 |
+
"Authorization","Autorización"
|
| 44 |
+
"Authorization Honor Period (days)","Período de autorización (días)"
|
| 45 |
+
"Authorization expired.","Autorización caducada."
|
| 46 |
+
"Authorization transaction is required to void.","Para anular se requiere la transacción de autorización."
|
| 47 |
+
"Authorization was voided by merchant.","El vendedor ha anulado la autorización."
|
| 48 |
+
"Authorized amount of %s.","Cantidad autorizada de %s."
|
| 49 |
+
"Authorizing amount of %s is pending approval on gateway.","La cantidad autorizada de %s está a la espera de ser aprobada en la pasarela de pago."
|
| 50 |
+
"Auto","Auto"
|
| 51 |
+
"AutoSweep","AutoBarrido"
|
| 52 |
+
"Available Balance","Balance Disponible"
|
| 53 |
+
"Balance Manager Account Bonus","Bono de Cuenta de Gestor de Balance"
|
| 54 |
+
"Billing Address","Dirección de facturación"
|
| 55 |
+
"Billing Agreement Signup ","Firma de Acuerdo de Facturación"
|
| 56 |
+
"Bonus for first ACH Use","Bono por el primer Uso de ACH"
|
| 57 |
+
"Buyer Credit Payment","Pago de Crédito de Comprador"
|
| 58 |
+
"Buyer\'s Tax ID","Número de identificación social del contribuyente del comprador\es"
|
| 59 |
+
"Buyer\'s Tax ID Type","Tipo de número de identificación social del contribuyente del comprador\es"
|
| 60 |
+
"By default it is ""reports.paypal.com"".","Por defecto es ""reports.paypal.com""."
|
| 61 |
+
"CNPJ","CNPJ"
|
| 62 |
+
"CPF","CPF"
|
| 63 |
+
"CVV2 Check Result by PayPal","Resultado de Comprobación CVV2 por PayPal"
|
| 64 |
+
"Can not send new order email.","No se puede enviar correo-e de nuevo encargo."
|
| 65 |
+
"Cannot create target file for reading reports.","No se puede crear el archivo destino para leer informes."
|
| 66 |
+
"Centinel API URL","URL de Api Centinela"
|
| 67 |
+
"Centinel Custom API URL","Centinel API URL customizado"
|
| 68 |
+
"Charge-off","Cancelar"
|
| 69 |
+
"Chargeback","Facturar"
|
| 70 |
+
"Chargeback by customer.","Facturación por cliente."
|
| 71 |
+
"Checkout with PayPal","Pago con PayPal"
|
| 72 |
+
"City","Ciudad"
|
| 73 |
+
"Click here if you are not redirected within 10 seconds...","Haz clic aquí si no se te redirige a la página web en 10 segundos..."
|
| 74 |
+
"Company","Empresa"
|
| 75 |
+
"Completion Date","Fecha de Finalización"
|
| 76 |
+
"Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?","Conectándose al servidor SFTP de PayPal para recuperar nuevos informes.¿Estás seguro de querer continuar?"
|
| 77 |
+
"Countries Payment Applicable From","Formulario Aplicable de Pago por Países"
|
| 78 |
+
"Country","País"
|
| 79 |
+
"Coupon Redemption","Reembolso de Cupón"
|
| 80 |
+
"Credit","Crédito"
|
| 81 |
+
"Credit Card Settings","Configuración de la Tarjeta de Crédito"
|
| 82 |
+
"Currency Conversion required to cover negative balance","Se requiere una Conversión de Divisas para cubrir el saldo negativo"
|
| 83 |
+
"Custom","Personalizado"
|
| 84 |
+
"Custom Endpoint Hostname or IP-Address","Dirección IP o nombre de Host de destino personalizado"
|
| 85 |
+
"Custom Path","Camino personalizado"
|
| 86 |
+
"Customer Information","Información del cliente"
|
| 87 |
+
"Customer complaint.","Queja del cliente:"
|
| 88 |
+
"Customer did not include a confirmed address.","El cliente no incluyó una dirección confirmada."
|
| 89 |
+
"Customer failed to pay.","El cliente no pagó."
|
| 90 |
+
"Customer triggered a money-back guarantee.","El cliente hizo uso de una garantía de devolución."
|
| 91 |
+
"Customer used non-confirmed address.","El cliente usó una dirección no confirmada."
|
| 92 |
+
"Daily","Diario"
|
| 93 |
+
"Debit","Débito"
|
| 94 |
+
"Debit Card Cash Back","Retirada de efectivo de tarjeta de débito"
|
| 95 |
+
"Debit Card Transaction","Transacción con tarjeta de débito"
|
| 96 |
+
"Debit or Credit","Débito o Crédito"
|
| 97 |
+
"Debug Mode","Modo Depuración"
|
| 98 |
+
"Direct Payment API","API de pago directo"
|
| 99 |
+
"Discount","Descuento"
|
| 100 |
+
"Display Express Checkout in the Payment Information step","Mostrar Pago exprés en la pantalla de información del Pago"
|
| 101 |
+
"Displays on catalog pages and homepage.","Impresiones en páginas de catálogo y sitio web."
|
| 102 |
+
"Don't have a PayPal account? Simply enter your email address.","No dispone de una cuenta PayPal? Introduzca su dirección de email."
|
| 103 |
+
"Don’t have a PayPal merchant account? You can still accept credit card payments through the Payflow Pro Gateway.","No dispone de una cuenta de comerciante de Paypal? Puede aceptar pagos mediante tarjeta de crédito a través del procesador de pagos Payflow Pro"
|
| 104 |
+
"Dynamic","Dinámico"
|
| 105 |
+
"EFT Funding (German banking)","Transacción EFT (Bancos alemanes)"
|
| 106 |
+
"Edit Shopping Cart","Editar Carrito de la Compra"
|
| 107 |
+
"Email Address","Dirección de correo electrónico"
|
| 108 |
+
"Email Associated with PayPal Merchant Account","Email asociado con la cuenta de comerciante de Paypal"
|
| 109 |
+
"Enable Automatic Fetching","Habilitar acceso automático"
|
| 110 |
+
"Enable PayPal Guest Checkout","Habilitar Checkout de Invitado Paypal"
|
| 111 |
+
"Enabled","Habilitado"
|
| 112 |
+
"Event","Evento"
|
| 113 |
+
"Event Code","Código de Evento"
|
| 114 |
+
"Every 10 days","Cada 10 días"
|
| 115 |
+
"Every 14 days","Cada 14 días"
|
| 116 |
+
"Every 3 days","Cada 3 días"
|
| 117 |
+
"Every 30 days","Cada 30 días"
|
| 118 |
+
"Every 40 days","Cada 40 días"
|
| 119 |
+
"Every 7 days","Cada 7 días"
|
| 120 |
+
"Exact Match. Address and Postal Code. International","Coincidencia exacta. Dirección y Código Postal. Internacional"
|
| 121 |
+
"Exact Match. Address and Postal Code. UK-specific","Coincidencia exacta. Dirección y Código Postal. Específico para Reino Unido"
|
| 122 |
+
"Exact Match. Address and nine-digit ZIP code","Coincidencia exacta. Dirección y código ZIP de 9 dígitos"
|
| 123 |
+
"Explanation: %s.","Explicación: %s."
|
| 124 |
+
"Express Checkout","Paso por Caja Express"
|
| 125 |
+
"Express Checkout (Payflow Edition) Settings","Ajustes de Paso por Caja Express (edición de Payflow)"
|
| 126 |
+
"Express Checkout APIs","APIs de Paso por Caja Express"
|
| 127 |
+
"Express Checkout Settings","Ajustes de Paso por Caja Express"
|
| 128 |
+
"Express Checkout and Order have been canceled.","El Pedido y la Salida Express se han cancelado."
|
| 129 |
+
"Express Checkout has been canceled.","La Salida Express se ha cancelado."
|
| 130 |
+
"Failed to fetch reports from '%s@%s'.","No se consiguió obtener los registros de '%s@%s'."
|
| 131 |
+
"Fax","Fax"
|
| 132 |
+
"Fee Amount","Importe de la Comisión"
|
| 133 |
+
"Fee Debit or Credit","Comisión Débito o Crédito"
|
| 134 |
+
"Fee Reversal","Retroceso de Comisiones"
|
| 135 |
+
"Fee: Foreign ACH Withdrawal","Comisión: Retirada ACH en el extranjero"
|
| 136 |
+
"Fee: Mass Pay Request","Comisión: Solicitud de Pago Masivo"
|
| 137 |
+
"Fee: Web Site Payments Pro Account Monthly","Comisión: cuenta Web Site Payments Pro mensual"
|
| 138 |
+
"Fee: WorldLink Check Withdrawal","Comisión: Retirada mediante cheque WorldLink"
|
| 139 |
+
"Fetch","Capturar"
|
| 140 |
+
"Fetch Updates","Nuevos resultados obtenidos"
|
| 141 |
+
"Fetched %s report rows from '%s@%s'.","Se obtuvieron %s filas de informe de '%s@%s'."
|
| 142 |
+
"For Virtual Quotes Only","Solo para presupuestos en línea"
|
| 143 |
+
"Frontend Experience Settings","Ajustes de la Experiencia con Fachada"
|
| 144 |
+
"Funding","Fondos"
|
| 145 |
+
"General (Authorization)","General (Autorización)"
|
| 146 |
+
"General (Dividend)","General (Dividendo)"
|
| 147 |
+
"General (Funds Transfer from PayPal Account to Another)","General (Transferencia de Fondos desde una Cuenta Paypal a Otra Cuenta)"
|
| 148 |
+
"General (Purchase with a credit card)","General (Compra con una tarjeta de crédito)"
|
| 149 |
+
"General Adjustment without businessrelated event","Ajuste General sin ningún acontecimiento relacionado con el negocio"
|
| 150 |
+
"General Currency Conversion","Conversión de Divisa General"
|
| 151 |
+
"General Funding of PayPal Account ","Fondos Generales de la Cuenta de PayPal"
|
| 152 |
+
"General Redemption","Amortización General"
|
| 153 |
+
"General Withdrawal from PayPal Account","Retirada de fondos General desde la Cuenta de PayPal"
|
| 154 |
+
"General. Product no longer supported","General. Este producto ya no está admitido"
|
| 155 |
+
"General: Use of PayPal account for purchasing as well as receiving payments","General: Uso de la cuenta PayPal tanto para comprar como para recibir pagos"
|
| 156 |
+
"General: Withdrawal from PayPal Account","General: Retirada de fondos desde la Cuenta de PayPal"
|
| 157 |
+
"General: Withdrawal to Non-Bank Entity","General: Retirada de fondos a una Entidad No Bancaria"
|
| 158 |
+
"General: adjustment of a type not belonging to the other T12xx categories","General: ajuste de una clase no perteneciente a las otras T12xx categorías"
|
| 159 |
+
"General: bonus of a type not belonging to the other T08xx categories","General: bonificación de una clase no perteneciente a las otras T08xx categorías"
|
| 160 |
+
"General: event not yet categorized","General: suceso no catalogado aún"
|
| 161 |
+
"General: non-payment fee of a type not belonging to the other T01xx categories","General: tarifa de impago de una clase no perteneciente a las otras T01xx categorías"
|
| 162 |
+
"General: received payment of a type not belonging to the other T00xx categories","General: pago recibido de una clase no perteneciente a las otras T00xx categorías"
|
| 163 |
+
"General: reversal of a type not belonging to the other T11xx categories","General: revocación de una clase no perteneciente a las otras T01xx categorías"
|
| 164 |
+
"General: temporary hold of a type not belonging to the other T15xx categories","General: cargo temporal de una clase no perteneciente a las otras T15xx categorías"
|
| 165 |
+
"Get Credentials from PayPal","Consiga sus Credenciales de PayPal"
|
| 166 |
+
"Gift Certificate Payment: purchase of Gift Certificate","Pago de Cheque Regalo: compra de Cheque Regalo"
|
| 167 |
+
"Gift Certificate Redemption","Canjear Cheque Regalo"
|
| 168 |
+
"Gross Amount","Total Bruto"
|
| 169 |
+
"Header Background Color","Color del Fondo de la Cabecera"
|
| 170 |
+
"Header Border Color","Color del Borde de la Cabecera"
|
| 171 |
+
"Header Image URL","URL de la Imagen de la Cabecera"
|
| 172 |
+
"Help","Ayuda"
|
| 173 |
+
"Hidden Virtual PayPal Debit Card Transaction","Transacción Oculta de Tarjeta Virtual de Débito PayPal"
|
| 174 |
+
"Hold for Dispute Investigation","Manténgase a la Espera de la Investigación sobre la Disputa"
|
| 175 |
+
"IPN ""%s"".","""%s"" IPN."
|
| 176 |
+
"IPN verification ""%s"".","""%s"" de verificación de IPN."
|
| 177 |
+
"If empty, a default value will be used. Custom URL may be provided by CardinalCommerce agreement.","Se utilizará un valor por defecto si se deja en blanco. Podrá proporcionarse una URL por encargo según acuerdo con Cardinal Commerce."
|
| 178 |
+
"If not specified, Default Country from General Config will be used","Si no se especifica, use el país por defecto de la configuración general."
|
| 179 |
+
"If this option is enabled, customer can change shipping address and shipping method on PayPal website. In live mode works via HTTPS protocol only.","Si se activa esta opción, el cliente podrá cambiar la dirección y el método de envío desde el sitio de Internet de PayPal. La modalidad en vivo funciona sólo a través de protocolo HTTPS."
|
| 180 |
+
"Impossible to issue a refund transaction because the capture transaction does not exist.","No es posible facilitar una transacción de reembolso porque no existe la transacción de captura."
|
| 181 |
+
"Incentive","Incentivo"
|
| 182 |
+
"Initiation Date","Fecha de Inicio"
|
| 183 |
+
"Integral Evolution","Evolución integral"
|
| 184 |
+
"Integral Evolution Settings","Ajustes de evolución integral"
|
| 185 |
+
"Invoice ID","Identificación de la Factura"
|
| 186 |
+
"Issuer Liability","Responsabilidad del Emisor"
|
| 187 |
+
"It is recommended to set this value to ""Debit or Credit Card"" per store views.","Se recomienda fijar este valor en ""Tarjeta de débito o crédito"" por vistas de tienda."
|
| 188 |
+
"It is recommended to set this value to ""PayPal"" per store views.","Se recomienda fijar este valor en ""PayPal"" por vistas de tienda."
|
| 189 |
+
"Items in Your Shopping Cart","Artículos en Su Carro de la Compra"
|
| 190 |
+
"Last Correlation ID","Última Identificación de Correlación"
|
| 191 |
+
"Last Transaction ID","Última Identificación de Transacción"
|
| 192 |
+
"Learn More","Saber más"
|
| 193 |
+
"Login","Entrar"
|
| 194 |
+
"Looking for PayPal? We have our own tab to the left under Sales.","¿Busca PayPal? Tenemos nuestra propia etiqueta a la izquierda, debajo de Ventas."
|
| 195 |
+
"Mass Pay Payment","Pago Agrupado"
|
| 196 |
+
"Matched (CVV2)","Emparejado (CVV2)"
|
| 197 |
+
"Matched (CVV2CSC)","CVV2CSC coincidentes."
|
| 198 |
+
"Matched Address only (no ZIP)","Sólo dirección correspondiente (no CP)"
|
| 199 |
+
"Matched Address only (no ZIP). International","Sólo Encaja la Dirección (no el Código Postal). Internacional"
|
| 200 |
+
"Matched Postal Code only (no Address)","Sólo Encaja el Código Postal (no la Dirección)"
|
| 201 |
+
"Matched five-digit ZIP only (no Address)","Sólo Encaja el Código Postal de cinco dígitos (no la Dirección)"
|
| 202 |
+
"Matched whole nine-didgit ZIP (no Address)","Sólo Encaja el Código Postal de nueve dígitos (no la Dirección)"
|
| 203 |
+
"Merchant Account","Cuenta del comerciante"
|
| 204 |
+
"Merchant Country","País de envío"
|
| 205 |
+
"Merchant Liability","Responsabilidad del comerciante"
|
| 206 |
+
"Merchant Protection Eligibility","Requisitos de protección de mercado"
|
| 207 |
+
"Merchant Referral Bonus","Bonificación de referencia del comerciante"
|
| 208 |
+
"Merchant account doesn\'t have a withdrawal mechanism. Merchant must manually accept or deny this payment from your Account Overview.","La cuenta del envío no tiene una opción de retirada de dinero. El recipiente debe aceptar o rechazar manualmente este pago de su resumen de cuentas."
|
| 209 |
+
"Merchant account is not verified.","La cuenta del comerciante no ha sido verificada."
|
| 210 |
+
"Merchant denied this pending payment.","El comerciante denegó este pago pendiente."
|
| 211 |
+
"Merchant holds a non-U.S. account and does not have a withdrawal mechanism.","El comerciante no posee una cuenta de EEUU ni tampoco un mecanismo de retirada de dinero."
|
| 212 |
+
"Merchant must upgrade account to Business or Premier status.","El comerciante debe actualizar su cuenta a la opción Business o Premier."
|
| 213 |
+
"Merchant reference ID format is not supported.","El formato de la Id. de referencia del comerciante no es compatible."
|
| 214 |
+
"Merchants need to apply to PayPal for enabling billing agreements feature. Do not enable this option until PayPal confirms that billing agreements are enabled for your merchant account.","Los comerciantes necesitan registrarse en Paypal para activar la opción de acuerdos de facturación. No active esta opción hasta que Paypal confirme que los acuerdos de facturación han sido activados para su cuenta de comerciante."
|
| 215 |
+
"Mobile Payment (made via a mobile phone)","Pago móvil (realizado vía teléfono móvil)"
|
| 216 |
+
"Multi-currency issue. Merchant must manually accept or deny this payment from PayPal Account Overview.","Problema de monedas múltiples. El comerciante debe aceptar o denegar manualmente este pago a través de la opción Vista general de la cuenta de Paypal."
|
| 217 |
+
"N/A","N/A"
|
| 218 |
+
"N/A. Address not checked, or acquirer had no response. Service not available","No disponible. No se ha comprobado la dirección o el usuario no obtuvo respuesta. Servicio no disponible."
|
| 219 |
+
"N/A. Global Unavailable","No disponible. Global no disponible."
|
| 220 |
+
"N/A. International Unavailable","No disponible. Internacional no disponible."
|
| 221 |
+
"N/A. Merchant has indicated that CVV2 is not present on card","No disponible. El comerciante ha notificado que su tarjeta no tiene CVV2."
|
| 222 |
+
"N/A. No response","No disponible. Sin respuesta."
|
| 223 |
+
"N/A. Not allowed for MOTO (Internet/Phone) transactions","N/A. No disponible para transacciones MOTO (Internet/móvil)"
|
| 224 |
+
"N/A. Not processed","No disponible. No procesado."
|
| 225 |
+
"N/A. Retry","No disponible. Vuelva a intentar."
|
| 226 |
+
"N/A. Service not Supported","N/A. Servicio no disponible."
|
| 227 |
+
"N/A. Service not available","No disponible. Servicio no disponible."
|
| 228 |
+
"N/A. Service not supported","N/A. Servicio no operativo"
|
| 229 |
+
"N/A. The merchant did not provide AVS information","N/A. El comerciante no ha proporcionado la información AVS"
|
| 230 |
+
"N/A. The merchant has not implemented CVV2 code handling","No disponible. El comerciante no ha implementado la gestión del código CVV2."
|
| 231 |
+
"N/A. Unavailable","No disponible. No disponible."
|
| 232 |
+
"Negative Balance","No disponible. Saldo negativo"
|
| 233 |
+
"Never","Nunca"
|
| 234 |
+
"No","No"
|
| 235 |
+
"No Details matched","No ha habido coincidencias"
|
| 236 |
+
"No Details matched. International","Los detalles no coinciden. Internacional"
|
| 237 |
+
"No Liability Shift","No hay cambios de responsabilidad"
|
| 238 |
+
"No Logo","Sin logotipo"
|
| 239 |
+
"No match","No ha habido coincidencias"
|
| 240 |
+
"None of the address information matched","Ninguna información de la dirección coincide"
|
| 241 |
+
"Note: %s","Nota: %s"
|
| 242 |
+
"Nothing to fetch because of an empty configuration.","No hay resultados debido a un vacío en la configuración."
|
| 243 |
+
"Notice that PayPal can handle up to 10 shipping options. That is why Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.","Tenga en cuenta que PayPal puede gestionar hasta 10 opciones de envío. Por eso Magento solamente transferirá las primeras 10 opciones de envío más baratas si hay mas de 10 opciones disponibles."
|
| 244 |
+
"Notified customer about creditmemo #%s.","Cliente informado de la nota de abono #%s."
|
| 245 |
+
"Notified customer about invoice #%s.","Cliente informado de la factura #%s."
|
| 246 |
+
"Now accepting PayPal (150 X 40)","Se acepta PayPal (150 X 40)"
|
| 247 |
+
"Now accepting PayPal (150 X 60)","Ahora se acepta Paypal (150 X 60)"
|
| 248 |
+
"Number of Child Authorizations","Número de autorizaciones infantiles"
|
| 249 |
+
"Open Authorization","Abrir la autorización"
|
| 250 |
+
"Order","Encargar"
|
| 251 |
+
"Order ID","ID de Pedido"
|
| 252 |
+
"Order Valid Period (days)","Período válido del pedido (días)"
|
| 253 |
+
"Ordered amount of %s.","Cantidad pedida de %s."
|
| 254 |
+
"Ordering amount of %s is pending approval on gateway.","El pedido de la cantidad de %s está pendiente de aprobación en el portal."
|
| 255 |
+
"Page Background Color","Color del fondo de página"
|
| 256 |
+
"Page Style","Estilo de página"
|
| 257 |
+
"Part of the address information matched","Parte de la información de la dirección coincidió"
|
| 258 |
+
"Partner","Socio"
|
| 259 |
+
"Pasarela integral","Pasarela integral"
|
| 260 |
+
"Pasarela integral Settings","Ajustes de Pasarela integral"
|
| 261 |
+
"Password","Contraseña"
|
| 262 |
+
"Pay Now","Pagar ahora"
|
| 263 |
+
"PayPal","PayPal"
|
| 264 |
+
"PayPal Balance Manager function of PayPal account","Función del Gestor de saldo de PayPal de la cuenta de PayPal"
|
| 265 |
+
"PayPal Buyer Warranty Bonus","Bonificación de garantía del comprador en PayPal"
|
| 266 |
+
"PayPal Debit Card Cash Advance","Adelanto de efectivo de una tarjeta de débito en PayPal"
|
| 267 |
+
"PayPal Debit Card Withdrawal from ATM","Retiro de dinero de tarjeta de débido de PayPal desde un cajero automático"
|
| 268 |
+
"PayPal Express Checkout Shortcut Wrapper","Acceso directo al check-out exprés de PayPal"
|
| 269 |
+
"PayPal Express Checkout Token does not exist.","El símbolo para la Salida Express con Paypal no existe."
|
| 270 |
+
"PayPal Express Order Review Form","Formulario de revisión de compra por PayPal Express"
|
| 271 |
+
"PayPal Fee Information","Información de tarifa de PayPal"
|
| 272 |
+
"PayPal Merchant Pages Style","Estilo de la página de la tienda en PayPal"
|
| 273 |
+
"PayPal Payments Advanced","Pagos Avanzados de PayPal"
|
| 274 |
+
"PayPal Pro","PayPal Pro"
|
| 275 |
+
"PayPal Pro Settings","Ajustes de PayPal Pro"
|
| 276 |
+
"PayPal Product Logo","Logotipo del producto en PayPal"
|
| 277 |
+
"PayPal Protection Bonus","Bono de protección de PayPal"
|
| 278 |
+
"PayPal Reference ID","Id. de referencia de PayPal"
|
| 279 |
+
"PayPal Reference ID Type","Tipo de Id. de referencia de PayPal"
|
| 280 |
+
"PayPal Settlement Reports","Informes de liquidación de PayPal"
|
| 281 |
+
"PayPal certificate does not exist.","Certificado PayPal no existe."
|
| 282 |
+
"PayPal certificate file is empty.","Archivo de certificado PayPal está vacío."
|
| 283 |
+
"PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.","PayPal no admite el proceso de pedidos con importe cero. Para finalizar su compra, continúe con el proceso de caja estándar."
|
| 284 |
+
"PayPal gateway has rejected request. %s","La puerta de enlace de PayPal ha rechazado la solicitud. %s"
|
| 285 |
+
"PayPal processes all of your orders, and you get paid.","PayPal procesa todos sus pedidos y le paga a usted."
|
| 286 |
+
"PayPal response hasn't required fields.","La respuesta de PayPal no tiene campos obligatorios."
|
| 287 |
+
"PayPal retains reports for 45 days.","PayPal almacena los informes durante 45 días."
|
| 288 |
+
"PayPal/Centinel Electronic Commerce Indicator","Indicador de comercio electrónico de PayPal/Centinel"
|
| 289 |
+
"PayPal/Centinel Visa Payer Authentication Service Result","Resultado del servicio de autenticación del pagador con Visa a través de PayPal/Centinel"
|
| 290 |
+
"Payer Address ID","Id. de dirección del pagador"
|
| 291 |
+
"Payer Address Status","Estado de la dirección del comprador"
|
| 292 |
+
"Payer Email","Correo electrónico del pagador"
|
| 293 |
+
"Payer ID","Id. del pagador"
|
| 294 |
+
"Payer Status","Situación del comprador"
|
| 295 |
+
"Payer is not identified.","El pagador no se ha identificado."
|
| 296 |
+
"Payflow Link (for USA and Canada)","Vínculo de Flujo de Pago (para EE. UU. y Canadá)"
|
| 297 |
+
"Payflow Link Settings","Configuración del Vínculo de Flujo de Pago"
|
| 298 |
+
"Payflow Pro Gateway","Pasarela Payflow Pro"
|
| 299 |
+
"Payflow Pro Settings","Ajustes de la Pasarela Payflow Pro"
|
| 300 |
+
"Payment Action","Acción de Pago"
|
| 301 |
+
"Payment Applicable From","Pago Aplicable Desde"
|
| 302 |
+
"Payment Refund initiated by merchant","Reembolso de Pago iniciado por el comerciante"
|
| 303 |
+
"Payment has been declined. Please try again.","El pago ha sido rechazado. Vuelva a intentarlo."
|
| 304 |
+
"Payment is being reviewed by PayPal for risk.","El pago está siendo revisado por PayPal por si hubiera algún riesgo."
|
| 305 |
+
"Payment transactions disallow storing objects.","Las operaciones de pago no permiten almacenar objetos."
|
| 306 |
+
"Payment was made to an email address that is not yet registered or confirmed.","El pago se ha realizado a una dirección electrónica que todavía no ha sido registrada o confirmada."
|
| 307 |
+
"Payments by PayPal (150 X 40)","Pagos por PayPal (150 X 40)"
|
| 308 |
+
"Payments by PayPal (150 X 60)","Pagos por PayPal (150 X 60)"
|
| 309 |
+
"Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Pagos mediante tarjetas + protección de vendedor - <strong style=""color:red"">Contacte con PayPal antes de su activación</strong>"
|
| 310 |
+
"Paypal Billing Agreement Settings","Ajustes del Acuerdo de Facturación de PayPal"
|
| 311 |
+
"Pending PayPal","Pendiente de pago en PayPal"
|
| 312 |
+
"Place Order","Hacer pedido"
|
| 313 |
+
"Please agree to all the terms and conditions before placing the order.","Por favor, acepta todos los términos y condiciones antes de realizar el pedido."
|
| 314 |
+
"Please contact PayPal Customer Service.","Por favor, póngase en contacto con el Servicio de Atención al Cliente de PayPal."
|
| 315 |
+
"Please do not refresh the page until you complete payment.","No actualice la página hasta que complete el pago."
|
| 316 |
+
"Please select a shipping method...","Por favor, elija un método de envío..."
|
| 317 |
+
"Please select region, state or province","Por favor seleccione región, estado o provincia"
|
| 318 |
+
"Please update order data to get shipping methods and rates","Por favor, actualice los datos del pedido para obtener métodos de envío y tarifas"
|
| 319 |
+
"Points Incentive Redemption","Puntos de incentivo por cancelación"
|
| 320 |
+
"Postage Payment to either USPS or UPS","Pago de los Gastos de Envío bien a USPS o a UPS"
|
| 321 |
+
"Preapproved Payment (BillUser API), either sent or received","Pagos previamente aprobados (BillUser API) enviados o recibidos"
|
| 322 |
+
"Preapproved Payment ID","Identificación del Pago Pre-autorizado"
|
| 323 |
+
"Price","Precio"
|
| 324 |
+
"Process credit cards directly on your website with PayPal’s all-in-one online payment processing solution.","Tramite las tarjetas de crédito directamente en su sitio de Internet con la solución de tramitación de pago a distancia todo-en-uno de PayPal."
|
| 325 |
+
"Product Name","Nombre de Producto"
|
| 326 |
+
"Proxy Host","Servidor Proxy"
|
| 327 |
+
"Proxy Port","Puerto proxy"
|
| 328 |
+
"Qty","Cantidad"
|
| 329 |
+
"Reauthorization","Reautorización"
|
| 330 |
+
"Reference Information","Información de Referencia"
|
| 331 |
+
"Refund issued by merchant.","Reembolso emitido por el comerciante."
|
| 332 |
+
"Reimbursement for a chargeback.","Devolución o reembolso."
|
| 333 |
+
"Reimbursement of Chargeback","Reembolso de una transacción devuelta"
|
| 334 |
+
"Report Date","Fecha del informe"
|
| 335 |
+
"Reports","Informes"
|
| 336 |
+
"Requested %s and configured %s merchant emails do not match.","Las direcciones del comerciante solicitada %s y configurada %s no se corresponden."
|
| 337 |
+
"Require CVV Entry","Requiere el código de seguridad de la tarjeta"
|
| 338 |
+
"Require Customer's Billing Address","Exija la dirección de facturación del cliente"
|
| 339 |
+
"Reversal","Inversión"
|
| 340 |
+
"Reversal of General Account Hold","Revocación de Cargo General en Cuenta"
|
| 341 |
+
"Reversal of Points Usage","Inversión de los puntos de utilización"
|
| 342 |
+
"Reversal of an adjustment.","Revocación de un ajuste."
|
| 343 |
+
"Reversal of hold for Dispute Investigation","Reposición por la investigación de la disputa"
|
| 344 |
+
"Review Order","Revise su pedido"
|
| 345 |
+
"Reward Voucher Redemption","Realizar canje de vales"
|
| 346 |
+
"SFTP Credentials","Credenciales SFTP"
|
| 347 |
+
"Sale","Venta"
|
| 348 |
+
"Sales","Ventas"
|
| 349 |
+
"Same as shipping","Igual que el envío"
|
| 350 |
+
"Sandbox Credentials","Credenciales de Supervisión"
|
| 351 |
+
"Sandbox Mode","Modo de prueba"
|
| 352 |
+
"Schedule","Programa"
|
| 353 |
+
"Schedule description is too long.","La descripción de designaciones es demasiado larga."
|
| 354 |
+
"Scheduled Fetching","Compra programada"
|
| 355 |
+
"Select a PayPal Solution","Selecciones una solución PayPal"
|
| 356 |
+
"Server Error. Please try again.","Error del servidor. Por favor, inténtelo de nuevo."
|
| 357 |
+
"Settlement Consolidation","Consolidación del Acuerdo"
|
| 358 |
+
"Settlement Report Settings","Ajustes del informe de liquidación"
|
| 359 |
+
"Settlement of a chargeback.","Liquidación de una transacción devuelta."
|
| 360 |
+
"Severe 3D Secure Card Validation","Validación estricta de tarjeta segura en 3D"
|
| 361 |
+
"Severe Validation Removes Chargeback Liability on Merchant","La Validación Severe Suprime la Responsabilidad de Cancelación de Cargo del Comerciante"
|
| 362 |
+
"Severe validation removes chargeback liability on merchant.","La validación estricta exime al comerciante de responsabilidad en caso de devoluciones de cargos"
|
| 363 |
+
"Shipping","Transporte"
|
| 364 |
+
"Shipping Address","Dirección de Envío"
|
| 365 |
+
"Shipping Method","Método de envío"
|
| 366 |
+
"Shop now using (150 X 40)","Compre ahora usando (150 X 40)"
|
| 367 |
+
"Shop now using (150 X 60)","Compre ahora utilizando (150 X 60)"
|
| 368 |
+
"Shortcut","Acceso directo"
|
| 369 |
+
"Shortcut Buttons Flavor","Tipo de Botones de Atajo"
|
| 370 |
+
"Shortcut on Product View","Atajo para Vista de Producto"
|
| 371 |
+
"Shortcut on Shopping Cart","Atajo en el carro de la compra"
|
| 372 |
+
"Sign a billing agreement to streamline further purchases with PayPal.","Firma un acuerdo de facturación para agilizar futuras compras con PayPal."
|
| 373 |
+
"Solo","Solo"
|
| 374 |
+
"Sorry, no quotes are available for this order at this time.","Lamentamos informarle que en este momento no hay cotizaciones disponibles para este pedido."
|
| 375 |
+
"Sort Order","Orden de selección"
|
| 376 |
+
"Specifies what the Authorization Honor Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.","Especifica cuál es el período de autorización de la cuenta de PayPal del comerciante. Tiene que ser igual a la configuración de PayPal."
|
| 377 |
+
"Specifies what the Order Valid Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.","Especifica cuál es el período de validez del pedido de la cuenta de PayPal del comerciante. Tiene que ser igual a la configuración de PayPal."
|
| 378 |
+
"State/Province","Estado/Provincia"
|
| 379 |
+
"Static","Estático"
|
| 380 |
+
"Street Address","Dirección postal"
|
| 381 |
+
"Street Address %s","Calle %s"
|
| 382 |
+
"Submitting order information...","Enviando la información del pedido..."
|
| 383 |
+
"Subscriber name is too long.","El nombre de suscriptor es demasiado largo."
|
| 384 |
+
"Subscription ID","ID de Suscripción."
|
| 385 |
+
"Subscription Payment, either payment sent or payment received","Pago de suscripción, bien sea pago enviado o recibido."
|
| 386 |
+
"Subtotal","Subtotal"
|
| 387 |
+
"Summary Text for Aggregated Cart","Texto de Resumen para el Carro Añadido"
|
| 388 |
+
"Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","La admisión de tarjetas American Express requiere de un acuerdo adicional. Consulte los requisitios en <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>."
|
| 389 |
+
"Switch/Maestro","Cambiar/Maestro"
|
| 390 |
+
"Telephone","Teléfono"
|
| 391 |
+
"Test Mode","Modo de prueba"
|
| 392 |
+
"The background color for the checkout page around the header and payment form.","El color de fondo de la página de reembolso de la cabecera y formulario de pago."
|
| 393 |
+
"The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Color de fondo para la cabecera de la página de pago. Código ASCII de color hexadecimal HTML de seis caracteres sin diferencias mayúsculas o minúsculas."
|
| 394 |
+
"The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","El número de autorizaciones infantiles por defecto de su cuenta de PayPal es 1. Para tener autorizaciones múltiples, póngase en contacto con PayPal para solicitar un aumento."
|
| 395 |
+
"The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","Imagen en la parte superior izquierda de la página de pago. El tamaño máximo es 750x90 píxeles. Se recomienda encarecidamente el uso de <strong style=""color:red"">https</strong>."
|
| 396 |
+
"The maximum number of child authorizations is reached.","Se ha alcanzado el número máximo de autorizaciones infantiles."
|
| 397 |
+
"The merchant account is not yet verified.","Todavía no se ha verificado la cuenta de vendedor."
|
| 398 |
+
"The payment curency does not match any of the merchant\'s balances currency.","La moneda de pago no coincide con ninguna de las monedas de saldo del vendedor."
|
| 399 |
+
"The payment eCheck is not yet cleared.","Todavía no se ha limpiado el eCheck de pago."
|
| 400 |
+
"The payment is authorized but not settled.","El pago se ha autorizado, pero no se ha realizado."
|
| 401 |
+
"The payment is pending because it was made to an email address that is not yet registered or confirmed.","El pago está pendiente porque se ha realizado a una dirección de mail que todavía no se ha registrado o confirmado."
|
| 402 |
+
"The payment is pending while it is being reviewed by PayPal for risk.","El pago está pendiente, PayPal lo está revisando para asegurarse."
|
| 403 |
+
"The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","El pago se ha realizado mediante tarjeta de crédito. Para recibir los fondos el vendedor tiene que actualizar la cuenta a estado Business o Premier."
|
| 404 |
+
"There was an error processing your order. Please contact us or try again later.","Se produjo un error en el proceso de su pedido. Contacte con nosotros o inténtelo más tarde."
|
| 405 |
+
"This feature needs be enabled first for the merchant account through PayPal technical support.","Esta característica necesita primero ser activada para la cuenta comercial a través del soporte técnico de PayPal."
|
| 406 |
+
"This operation requires an existing transaction object.","Esta operación requiere de una transacción ya existente."
|
| 407 |
+
"Time of Day","Hora del Día"
|
| 408 |
+
"Title","Título"
|
| 409 |
+
"Transaction ID","Número de identificación de la transacción"
|
| 410 |
+
"Transaction ID must not be empty.","El número identificativo de la transacción debe completarse."
|
| 411 |
+
"Transaction Information","Información de Transacción"
|
| 412 |
+
"Transfer Cart Line Items","Transferir la línea de los artículos en el carrito"
|
| 413 |
+
"Transfer Shipping Options","Transferir las opciones de envío"
|
| 414 |
+
"Triggered Fraud Filters","Filtros de Fraude Desencadenados"
|
| 415 |
+
"Unable to cancel Express Checkout.","No se ha podido cancelar la Salida Express."
|
| 416 |
+
"Unable to change status. Current status is not correspond to real status.","No se puede cambiar el estado. El estado actual no se corresponde con el estado real."
|
| 417 |
+
"Unable to communicate with the PayPal gateway.","No ha sido posible comunicarse con el gateway de PayPal."
|
| 418 |
+
"Unable to initialize Express Checkout review.","No se ha podido iniciar la revisión de Salida Express."
|
| 419 |
+
"Unable to initialize Express Checkout.","No ha sido posible inicializar el Pago Express."
|
| 420 |
+
"Unable to place the order.","No se puede efectuar el pedido."
|
| 421 |
+
"Unable to process Express Checkout approval.","No se ha podido procesar la aprobación de Salida Express."
|
| 422 |
+
"Unable to start Express Checkout.","No se ha podido iniciar la Salida Express."
|
| 423 |
+
"Unable to update Order data.","No es posible actualizar la información del pedido."
|
| 424 |
+
"Unable to update shipping method.","No se ha podido actualizar el método de envío."
|
| 425 |
+
"Unknown Error. Please try again later.","Error desconocido. Por favor inténtalo más tarde."
|
| 426 |
+
"Unknown reason. Please contact PayPal customer service.","Razones desconocidas. Por favor, contacte el servicio de atención al cliente de PayPal."
|
| 427 |
+
"Update Order Data","Actualizar información del pedido"
|
| 428 |
+
"Use Proxy","Utilizar Proxy"
|
| 429 |
+
"Use colon to specify port. For example: ""test.example.com:5224"".","Utilice dos puntos para especificar el puerto. Por ejemplo: ""prueba.ejemplo.com:5224""."
|
| 430 |
+
"User","Usuario"
|
| 431 |
+
"User-initiated Currency Conversion","Conversión de moneda iniciada por el usuario"
|
| 432 |
+
"Uses store frontend name by default.","De forma predeterminada utiliza el nombre de la tienda de interfaz de usuario"
|
| 433 |
+
"VAT Number","Número de IVA"
|
| 434 |
+
"Vendor","Vendedor"
|
| 435 |
+
"Vendor / Merchant Login","Inicio de sesión para proveedores / comerciantes"
|
| 436 |
+
"View","Ver"
|
| 437 |
+
"View Demo","Vea la demostración"
|
| 438 |
+
"View PayPal solutions.","Ver soluciones de PayPal"
|
| 439 |
+
"View Transaction","Ver transacción"
|
| 440 |
+
"View Transaction Details","Ver Detalles de la Transacción"
|
| 441 |
+
"Virtual PayPal Debit Card Transaction","Transacción de Tarjeta de Débito de PayPal Virtual"
|
| 442 |
+
"Virtual Terminal Payment","Pago Terminal virtual"
|
| 443 |
+
"Void","Nulo"
|
| 444 |
+
"Waiting until Customer\'s eCheck will be cleared.","En espera hasta que se produzca la compensación del Cheque Electrónico del Cliente"
|
| 445 |
+
"We prefer PayPal (150 X 40)","Preferimos PayPal (150 X 40)"
|
| 446 |
+
"We prefer PayPal (150 X 60)","Preferimos PayPal (150 X 60)"
|
| 447 |
+
"Website Payments Plus","Pagos Web Plus"
|
| 448 |
+
"Website Payments Plus Settings","Configuración de Pagos Web Plus"
|
| 449 |
+
"Website Payments Pro","Website Payments Pro"
|
| 450 |
+
"Website Payments Pro (Payflow Edition) Settings","Configuración de Website Payments Pro (Payflow Edition)"
|
| 451 |
+
"Website Payments Pro Hosted Solution","Solución Hospedada de Pagos Web Pro"
|
| 452 |
+
"Website Payments Pro Hosted Solution Settings","Configuración de Solución Hospedada de Pagos Web Pro"
|
| 453 |
+
"Website Payments Pro Payflow Edition (includes Express Checkout)","Website Payments Pro Payflow Edition (incluye Pago Express)"
|
| 454 |
+
"Website Payments Pro Settings","Configuración de Website Payments Pro"
|
| 455 |
+
"Website Payments Standard","Pago Estándar en el Sitio Web"
|
| 456 |
+
"Website Payments Standard Payment","Pago estándar de la página web"
|
| 457 |
+
"Website Payments Standard Settings","Configuración de Pago Estándar en el Sitio Web"
|
| 458 |
+
"What is PayPal?","¿Qué es PayPal?"
|
| 459 |
+
"Whether to create a billing agreement, if there are no active billing agreements available.","Opción de creación de un contrato de facturación, si no hay contratos de facturación activos disponibles."
|
| 460 |
+
"Will appear as a payment option only for customers who have at least one active billing agreement.","Aparecerá como una opción de pago solamente para clientes que tengan al menos un contrato de facturación activo."
|
| 461 |
+
"WorldLink Withdrawal","Retirada de Fondos WorldLink"
|
| 462 |
+
"Would you like to sign a billing agreement to streamline further purchases with PayPal?","¿Le gustaría firmar un contrato de facturación para agilizar sus futuras compras con PayPal?"
|
| 463 |
+
"Wrong Order ID (%s) specified.","Se especificó un Identificador de Pedido Erróneo (%s)."
|
| 464 |
+
"Wrong PayPal Express Checkout Token specified.","Símbolo especificado de Salida Express con Paypal incorrecto."
|
| 465 |
+
"Yes","Sí"
|
| 466 |
+
"Yes. Matched Address and five-didgit ZIP","Sí. La Dirección y el Código Postal de cinco dígitos coinciden."
|
| 467 |
+
"You cannot void a verification transaction","No se puede anular una operación de comprobación"
|
| 468 |
+
"You will be redirected to the PayPal website in a few seconds.","Volverá a la página web de Paypal en unos segundos."
|
| 469 |
+
"You will be redirected to the PayPal website when you place an order.","Cuando realice el pedido se le devolverá a la página PayPal."
|
| 470 |
+
"You will be redirected to the PayPal website.","Se le redirigirá al sitio web de PayPal."
|
| 471 |
+
"You will be required to enter your payment details after you place an order.","Se le solicitará que introduzca los detalles del pago tras realizar el pedido."
|
| 472 |
+
"Zip/Postal Code","Código postal"
|
| 473 |
+
"chargeback reimbursed","Devolución del cargo reembolsada"
|
| 474 |
+
"chargeback settled","Devolución del cargo liquidada"
|
| 475 |
+
"customer complaint","reclamación de cliente"
|
| 476 |
+
"customer triggered a chargeback","El cliente ha solicitado un reembolso"
|
| 477 |
+
"customer triggered money-back guarantee","el cliente activó una garantía de devolución del dinero"
|
| 478 |
+
"eBay Auction Payment","Pago de Subasta de eBay"
|
| 479 |
+
"merchant refunded payment","el comerciante ha reembolsado el pago"
|
| 480 |
+
"no reason","No existen razones"
|
| 481 |
+
"reversal of an adjustment","revocación de un ajuste"
|
| 482 |
+
"unknown reason","Razones desconocidas"
|
| 483 |
+
"Payment Status","Estado del Pago"
|
| 484 |
+
"Pending Reason","Razones Pendiente"
|
| 485 |
+
"Payment Information","Información del Pago"
|
| 486 |
+
"Order Date","Fecha del Pedido"
|
| 487 |
+
"The order was placed using %s","El pedido fue realizado utilizando %s"
|
app/locale/es_MX/Ebcomm_PaypalMx.csv
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"-OR-","-O-"
|
| 2 |
+
"2-pixel perimeter around the header space.","Perímetro de 2 píxeles alrededor del espacio de cabera."
|
| 3 |
+
"3D Secure","3D Seguro"
|
| 4 |
+
"3D Secure Card Validation","Validación segura 3D de tarjeta"
|
| 5 |
+
"3D Secure validation is required for Maestro cards. Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Para tarjetas Maestro se requiere validación 3D Secure. Para aceptar tarjetas American Express se requiere un acuerdo adicional. Obtenga más información en <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>."
|
| 6 |
+
"<a href=""http://www.magentocommerce.com/paypal"">Start accepting payments via PayPal!</a>","<a href=""http://www.magentocommerce.com/paypal"">¡Empiece a aceptar pagos a través de PayPal!</a>"
|
| 7 |
+
"A value is required for live mode. Refer to your CardinalCommerce agreement.","Se necesita un valor para el modo en vivo. Consulte el acuerdo de comercio cardinal."
|
| 8 |
+
"ACH Deposit (Hold for Dispute or Other Investigation)","Depósito ACH (En Espera por Conflicto u Otra Investigación)"
|
| 9 |
+
"ACH Deposit (Reversal)","Depósito ACH (Revocación)"
|
| 10 |
+
"ACH Funding for Funds Recovery from Account Balance","Financiación ACH para Recuperación de Fondos desde el Balance de Cuenta"
|
| 11 |
+
"ACH Withdrawal","Retirada ACH"
|
| 12 |
+
"API Authentication Methods","Métodos de autenticación API"
|
| 13 |
+
"API Certificate","Certificdo API"
|
| 14 |
+
"API Password","Contraseña API"
|
| 15 |
+
"API Signature","Firma API"
|
| 16 |
+
"API Username","Nombre de Usuario API"
|
| 17 |
+
"API Uses Proxy","Proxy de Usos API"
|
| 18 |
+
"API/Integration","Api/Integración"
|
| 19 |
+
"API/Integration Settings","Api/Configuración de Integración"
|
| 20 |
+
"Ability for buyer to purchase without PayPal account.","Capacidad del comprador para comprar sin cuenta PayPal."
|
| 21 |
+
"Accept PayPal payments in your shopping cart. PayPal will process your credit card payments through the Payflow Pro Gateway.","Aceptar pagos PayPal en tu carro de la compra. PayPal procesará tus pagos de tarjeta de crédito a través del Gateway Payflow Pro"
|
| 22 |
+
"Accept payments with a PCI-compliant checkout that keeps customers on your site. Includes a merchant account from PayPal.","Aceptar pagos conformes a la norma PCI de verificación que mantiene a los clientes en tu sitio web. Incluye una cuenta comercial de PayPal."
|
| 23 |
+
"Accept payments with a PCI-compliant checkout that keeps customers on your site. For use with your own merchant account.","Aceptar pagos conformes a la norma PCI de verificación que mantiene a los clientes en tu sitio web. Para usarlo con tu propia cuenta comercial."
|
| 24 |
+
"Accept payments without customers leaving your website. Many popular web-hosting services and shopping carts come with the Payflow payment gateways built in, so they are easy to set up.","Aceptar pagos sin que los clientes abandonen tu página web. Muchos servicios populares de web-hosting y carros de la compra vienen con los gateways de pago Payflow incluidos, de manera que sean fáciles de configurar."
|
| 25 |
+
"Acceptance Mark","Señal de Aceptación"
|
| 26 |
+
"Acceptance Mark Image","Imagen de Señal de Aceptación"
|
| 27 |
+
"Account-to-Account Payment, initiated by PayPal","Pago Cuenta-a-Cuenta, iniciado por PayPal"
|
| 28 |
+
"Add an Express Checkout button to your existing shopping cart for quick and easy credit card payments. PayPal handles all payment processing.","Añadir un botón de Pago Express a tu carro de la compra ya existente para pagos con tarjeta de crédito rápidos y sencillos. PayPal gestiona todo el proceso de pago."
|
| 29 |
+
"Additional Options","Opciones Adicionales"
|
| 30 |
+
"Address","Dirección"
|
| 31 |
+
"Address Verification System Response","Respuesta del Sistema de Verificación de Dirección"
|
| 32 |
+
"All the address information matched","Coincide toda la información de dirección"
|
| 33 |
+
"Allow in Billing Agreement Wizard","Permitir el Asistente de Acuerdo de Facturación"
|
| 34 |
+
"Allowable values: ""paypal"", ""primary"" (default), your_custom_value (a custom payment page style from your merchant account profile).","Valores admitidos: ""paypal"", ""primary"" (por defecto), su_valor_customizado (estílo de página de pago customizado de su perfil de cuenta comercial)."
|
| 35 |
+
"Allowed Credit Card Types","Tipos de Tarjetas de Crédito Permitidos"
|
| 36 |
+
"Also affects mini-shopping cart.","También afecta al mini-carro de la compra."
|
| 37 |
+
"Ask Customer","Preguntar al Cliente"
|
| 38 |
+
"Attempted Authentication, Bad Result","Intento de Autenticación, Resultado Incorrecto"
|
| 39 |
+
"Attempted Authentication, Good Result","Intento de Autenticación, Resultado Correcto"
|
| 40 |
+
"Auction Payment other than through eBay","Pago por Subasta diferente de eBay"
|
| 41 |
+
"Authenticated, Bad Result","Autenticación, Resultado Incorrecto"
|
| 42 |
+
"Authenticated, Good Result","Autenticación, Resultado Correcto"
|
| 43 |
+
"Authorization","Autorización"
|
| 44 |
+
"Authorization Honor Period (days)","Período de autorización (días)"
|
| 45 |
+
"Authorization expired.","Autorización caducada."
|
| 46 |
+
"Authorization transaction is required to void.","Para anular se requiere la transacción de autorización."
|
| 47 |
+
"Authorization was voided by merchant.","El vendedor ha anulado la autorización."
|
| 48 |
+
"Authorized amount of %s.","Cantidad autorizada de %s."
|
| 49 |
+
"Authorizing amount of %s is pending approval on gateway.","La cantidad autorizada de %s está a la espera de ser aprobada en la pasarela de pago."
|
| 50 |
+
"Auto","Auto"
|
| 51 |
+
"AutoSweep","AutoBarrido"
|
| 52 |
+
"Available Balance","Balance Disponible"
|
| 53 |
+
"Balance Manager Account Bonus","Bono de Cuenta de Gestor de Balance"
|
| 54 |
+
"Billing Address","Dirección de facturación"
|
| 55 |
+
"Billing Agreement Signup ","Firma de Acuerdo de Facturación"
|
| 56 |
+
"Bonus for first ACH Use","Bono por el primer Uso de ACH"
|
| 57 |
+
"Buyer Credit Payment","Pago de Crédito de Comprador"
|
| 58 |
+
"Buyer\'s Tax ID","Número de identificación social del contribuyente del comprador\es"
|
| 59 |
+
"Buyer\'s Tax ID Type","Tipo de número de identificación social del contribuyente del comprador\es"
|
| 60 |
+
"By default it is ""reports.paypal.com"".","Por defecto es ""reports.paypal.com""."
|
| 61 |
+
"CNPJ","CNPJ"
|
| 62 |
+
"CPF","CPF"
|
| 63 |
+
"CVV2 Check Result by PayPal","Resultado de Comprobación CVV2 por PayPal"
|
| 64 |
+
"Can not send new order email.","No se puede enviar correo-e de nuevo encargo."
|
| 65 |
+
"Cannot create target file for reading reports.","No se puede crear el archivo destino para leer informes."
|
| 66 |
+
"Centinel API URL","URL de Api Centinela"
|
| 67 |
+
"Centinel Custom API URL","Centinel API URL customizado"
|
| 68 |
+
"Charge-off","Cancelar"
|
| 69 |
+
"Chargeback","Facturar"
|
| 70 |
+
"Chargeback by customer.","Facturación por cliente."
|
| 71 |
+
"Checkout with PayPal","Pago con PayPal"
|
| 72 |
+
"City","Ciudad"
|
| 73 |
+
"Click here if you are not redirected within 10 seconds...","Haz clic aquí si no se te redirige a la página web en 10 segundos..."
|
| 74 |
+
"Company","Empresa"
|
| 75 |
+
"Completion Date","Fecha de Finalización"
|
| 76 |
+
"Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?","Conectándose al servidor SFTP de PayPal para recuperar nuevos informes.¿Estás seguro de querer continuar?"
|
| 77 |
+
"Countries Payment Applicable From","Formulario Aplicable de Pago por Países"
|
| 78 |
+
"Country","País"
|
| 79 |
+
"Coupon Redemption","Reembolso de Cupón"
|
| 80 |
+
"Credit","Crédito"
|
| 81 |
+
"Credit Card Settings","Configuración de la Tarjeta de Crédito"
|
| 82 |
+
"Currency Conversion required to cover negative balance","Se requiere una Conversión de Divisas para cubrir el saldo negativo"
|
| 83 |
+
"Custom","Personalizado"
|
| 84 |
+
"Custom Endpoint Hostname or IP-Address","Dirección IP o nombre de Host de destino personalizado"
|
| 85 |
+
"Custom Path","Camino personalizado"
|
| 86 |
+
"Customer Information","Información del cliente"
|
| 87 |
+
"Customer complaint.","Queja del cliente:"
|
| 88 |
+
"Customer did not include a confirmed address.","El cliente no incluyó una dirección confirmada."
|
| 89 |
+
"Customer failed to pay.","El cliente no pagó."
|
| 90 |
+
"Customer triggered a money-back guarantee.","El cliente hizo uso de una garantía de devolución."
|
| 91 |
+
"Customer used non-confirmed address.","El cliente usó una dirección no confirmada."
|
| 92 |
+
"Daily","Diario"
|
| 93 |
+
"Debit","Débito"
|
| 94 |
+
"Debit Card Cash Back","Retirada de efectivo de tarjeta de débito"
|
| 95 |
+
"Debit Card Transaction","Transacción con tarjeta de débito"
|
| 96 |
+
"Debit or Credit","Débito o Crédito"
|
| 97 |
+
"Debug Mode","Modo Depuración"
|
| 98 |
+
"Direct Payment API","API de pago directo"
|
| 99 |
+
"Discount","Descuento"
|
| 100 |
+
"Display Express Checkout in the Payment Information step","Mostrar Pago exprés en la pantalla de información del Pago"
|
| 101 |
+
"Displays on catalog pages and homepage.","Impresiones en páginas de catálogo y sitio web."
|
| 102 |
+
"Don't have a PayPal account? Simply enter your email address.","No dispone de una cuenta PayPal? Introduzca su dirección de email."
|
| 103 |
+
"Don’t have a PayPal merchant account? You can still accept credit card payments through the Payflow Pro Gateway.","No dispone de una cuenta de comerciante de Paypal? Puede aceptar pagos mediante tarjeta de crédito a través del procesador de pagos Payflow Pro"
|
| 104 |
+
"Dynamic","Dinámico"
|
| 105 |
+
"EFT Funding (German banking)","Transacción EFT (Bancos alemanes)"
|
| 106 |
+
"Edit Shopping Cart","Editar Carrito de la Compra"
|
| 107 |
+
"Email Address","Dirección de correo electrónico"
|
| 108 |
+
"Email Associated with PayPal Merchant Account","Email asociado con la cuenta de comerciante de Paypal"
|
| 109 |
+
"Enable Automatic Fetching","Habilitar acceso automático"
|
| 110 |
+
"Enable PayPal Guest Checkout","Habilitar Checkout de Invitado Paypal"
|
| 111 |
+
"Enabled","Habilitado"
|
| 112 |
+
"Event","Evento"
|
| 113 |
+
"Event Code","Código de Evento"
|
| 114 |
+
"Every 10 days","Cada 10 días"
|
| 115 |
+
"Every 14 days","Cada 14 días"
|
| 116 |
+
"Every 3 days","Cada 3 días"
|
| 117 |
+
"Every 30 days","Cada 30 días"
|
| 118 |
+
"Every 40 days","Cada 40 días"
|
| 119 |
+
"Every 7 days","Cada 7 días"
|
| 120 |
+
"Exact Match. Address and Postal Code. International","Coincidencia exacta. Dirección y Código Postal. Internacional"
|
| 121 |
+
"Exact Match. Address and Postal Code. UK-specific","Coincidencia exacta. Dirección y Código Postal. Específico para Reino Unido"
|
| 122 |
+
"Exact Match. Address and nine-digit ZIP code","Coincidencia exacta. Dirección y código ZIP de 9 dígitos"
|
| 123 |
+
"Explanation: %s.","Explicación: %s."
|
| 124 |
+
"Express Checkout","Paso por Caja Express"
|
| 125 |
+
"Express Checkout (Payflow Edition) Settings","Ajustes de Paso por Caja Express (edición de Payflow)"
|
| 126 |
+
"Express Checkout APIs","APIs de Paso por Caja Express"
|
| 127 |
+
"Express Checkout Settings","Ajustes de Paso por Caja Express"
|
| 128 |
+
"Express Checkout and Order have been canceled.","El Pedido y la Salida Express se han cancelado."
|
| 129 |
+
"Express Checkout has been canceled.","La Salida Express se ha cancelado."
|
| 130 |
+
"Failed to fetch reports from '%s@%s'.","No se consiguió obtener los registros de '%s@%s'."
|
| 131 |
+
"Fax","Fax"
|
| 132 |
+
"Fee Amount","Importe de la Comisión"
|
| 133 |
+
"Fee Debit or Credit","Comisión Débito o Crédito"
|
| 134 |
+
"Fee Reversal","Retroceso de Comisiones"
|
| 135 |
+
"Fee: Foreign ACH Withdrawal","Comisión: Retirada ACH en el extranjero"
|
| 136 |
+
"Fee: Mass Pay Request","Comisión: Solicitud de Pago Masivo"
|
| 137 |
+
"Fee: Web Site Payments Pro Account Monthly","Comisión: cuenta Web Site Payments Pro mensual"
|
| 138 |
+
"Fee: WorldLink Check Withdrawal","Comisión: Retirada mediante cheque WorldLink"
|
| 139 |
+
"Fetch","Capturar"
|
| 140 |
+
"Fetch Updates","Nuevos resultados obtenidos"
|
| 141 |
+
"Fetched %s report rows from '%s@%s'.","Se obtuvieron %s filas de informe de '%s@%s'."
|
| 142 |
+
"For Virtual Quotes Only","Solo para presupuestos en línea"
|
| 143 |
+
"Frontend Experience Settings","Ajustes de la Experiencia con Fachada"
|
| 144 |
+
"Funding","Fondos"
|
| 145 |
+
"General (Authorization)","General (Autorización)"
|
| 146 |
+
"General (Dividend)","General (Dividendo)"
|
| 147 |
+
"General (Funds Transfer from PayPal Account to Another)","General (Transferencia de Fondos desde una Cuenta Paypal a Otra Cuenta)"
|
| 148 |
+
"General (Purchase with a credit card)","General (Compra con una tarjeta de crédito)"
|
| 149 |
+
"General Adjustment without businessrelated event","Ajuste General sin ningún acontecimiento relacionado con el negocio"
|
| 150 |
+
"General Currency Conversion","Conversión de Divisa General"
|
| 151 |
+
"General Funding of PayPal Account ","Fondos Generales de la Cuenta de PayPal"
|
| 152 |
+
"General Redemption","Amortización General"
|
| 153 |
+
"General Withdrawal from PayPal Account","Retirada de fondos General desde la Cuenta de PayPal"
|
| 154 |
+
"General. Product no longer supported","General. Este producto ya no está admitido"
|
| 155 |
+
"General: Use of PayPal account for purchasing as well as receiving payments","General: Uso de la cuenta PayPal tanto para comprar como para recibir pagos"
|
| 156 |
+
"General: Withdrawal from PayPal Account","General: Retirada de fondos desde la Cuenta de PayPal"
|
| 157 |
+
"General: Withdrawal to Non-Bank Entity","General: Retirada de fondos a una Entidad No Bancaria"
|
| 158 |
+
"General: adjustment of a type not belonging to the other T12xx categories","General: ajuste de una clase no perteneciente a las otras T12xx categorías"
|
| 159 |
+
"General: bonus of a type not belonging to the other T08xx categories","General: bonificación de una clase no perteneciente a las otras T08xx categorías"
|
| 160 |
+
"General: event not yet categorized","General: suceso no catalogado aún"
|
| 161 |
+
"General: non-payment fee of a type not belonging to the other T01xx categories","General: tarifa de impago de una clase no perteneciente a las otras T01xx categorías"
|
| 162 |
+
"General: received payment of a type not belonging to the other T00xx categories","General: pago recibido de una clase no perteneciente a las otras T00xx categorías"
|
| 163 |
+
"General: reversal of a type not belonging to the other T11xx categories","General: revocación de una clase no perteneciente a las otras T01xx categorías"
|
| 164 |
+
"General: temporary hold of a type not belonging to the other T15xx categories","General: cargo temporal de una clase no perteneciente a las otras T15xx categorías"
|
| 165 |
+
"Get Credentials from PayPal","Consiga sus Credenciales de PayPal"
|
| 166 |
+
"Gift Certificate Payment: purchase of Gift Certificate","Pago de Cheque Regalo: compra de Cheque Regalo"
|
| 167 |
+
"Gift Certificate Redemption","Canjear Cheque Regalo"
|
| 168 |
+
"Gross Amount","Total Bruto"
|
| 169 |
+
"Header Background Color","Color del Fondo de la Cabecera"
|
| 170 |
+
"Header Border Color","Color del Borde de la Cabecera"
|
| 171 |
+
"Header Image URL","URL de la Imagen de la Cabecera"
|
| 172 |
+
"Help","Ayuda"
|
| 173 |
+
"Hidden Virtual PayPal Debit Card Transaction","Transacción Oculta de Tarjeta Virtual de Débito PayPal"
|
| 174 |
+
"Hold for Dispute Investigation","Manténgase a la Espera de la Investigación sobre la Disputa"
|
| 175 |
+
"IPN ""%s"".","""%s"" IPN."
|
| 176 |
+
"IPN verification ""%s"".","""%s"" de verificación de IPN."
|
| 177 |
+
"If empty, a default value will be used. Custom URL may be provided by CardinalCommerce agreement.","Se utilizará un valor por defecto si se deja en blanco. Podrá proporcionarse una URL por encargo según acuerdo con Cardinal Commerce."
|
| 178 |
+
"If not specified, Default Country from General Config will be used","Si no se especifica, use el país por defecto de la configuración general."
|
| 179 |
+
"If this option is enabled, customer can change shipping address and shipping method on PayPal website. In live mode works via HTTPS protocol only.","Si se activa esta opción, el cliente podrá cambiar la dirección y el método de envío desde el sitio de Internet de PayPal. La modalidad en vivo funciona sólo a través de protocolo HTTPS."
|
| 180 |
+
"Impossible to issue a refund transaction because the capture transaction does not exist.","No es posible facilitar una transacción de reembolso porque no existe la transacción de captura."
|
| 181 |
+
"Incentive","Incentivo"
|
| 182 |
+
"Initiation Date","Fecha de Inicio"
|
| 183 |
+
"Integral Evolution","Evolución integral"
|
| 184 |
+
"Integral Evolution Settings","Ajustes de evolución integral"
|
| 185 |
+
"Invoice ID","Identificación de la Factura"
|
| 186 |
+
"Issuer Liability","Responsabilidad del Emisor"
|
| 187 |
+
"It is recommended to set this value to ""Debit or Credit Card"" per store views.","Se recomienda fijar este valor en ""Tarjeta de débito o crédito"" por vistas de tienda."
|
| 188 |
+
"It is recommended to set this value to ""PayPal"" per store views.","Se recomienda fijar este valor en ""PayPal"" por vistas de tienda."
|
| 189 |
+
"Items in Your Shopping Cart","Artículos en Su Carro de la Compra"
|
| 190 |
+
"Last Correlation ID","Última Identificación de Correlación"
|
| 191 |
+
"Last Transaction ID","Última Identificación de Transacción"
|
| 192 |
+
"Learn More","Saber más"
|
| 193 |
+
"Login","Entrar"
|
| 194 |
+
"Looking for PayPal? We have our own tab to the left under Sales.","¿Busca PayPal? Tenemos nuestra propia etiqueta a la izquierda, debajo de Ventas."
|
| 195 |
+
"Mass Pay Payment","Pago Agrupado"
|
| 196 |
+
"Matched (CVV2)","Emparejado (CVV2)"
|
| 197 |
+
"Matched (CVV2CSC)","CVV2CSC coincidentes."
|
| 198 |
+
"Matched Address only (no ZIP)","Sólo dirección correspondiente (no CP)"
|
| 199 |
+
"Matched Address only (no ZIP). International","Sólo Encaja la Dirección (no el Código Postal). Internacional"
|
| 200 |
+
"Matched Postal Code only (no Address)","Sólo Encaja el Código Postal (no la Dirección)"
|
| 201 |
+
"Matched five-digit ZIP only (no Address)","Sólo Encaja el Código Postal de cinco dígitos (no la Dirección)"
|
| 202 |
+
"Matched whole nine-didgit ZIP (no Address)","Sólo Encaja el Código Postal de nueve dígitos (no la Dirección)"
|
| 203 |
+
"Merchant Account","Cuenta del comerciante"
|
| 204 |
+
"Merchant Country","País de envío"
|
| 205 |
+
"Merchant Liability","Responsabilidad del comerciante"
|
| 206 |
+
"Merchant Protection Eligibility","Requisitos de protección de mercado"
|
| 207 |
+
"Merchant Referral Bonus","Bonificación de referencia del comerciante"
|
| 208 |
+
"Merchant account doesn\'t have a withdrawal mechanism. Merchant must manually accept or deny this payment from your Account Overview.","La cuenta del envío no tiene una opción de retirada de dinero. El recipiente debe aceptar o rechazar manualmente este pago de su resumen de cuentas."
|
| 209 |
+
"Merchant account is not verified.","La cuenta del comerciante no ha sido verificada."
|
| 210 |
+
"Merchant denied this pending payment.","El comerciante denegó este pago pendiente."
|
| 211 |
+
"Merchant holds a non-U.S. account and does not have a withdrawal mechanism.","El comerciante no posee una cuenta de EEUU ni tampoco un mecanismo de retirada de dinero."
|
| 212 |
+
"Merchant must upgrade account to Business or Premier status.","El comerciante debe actualizar su cuenta a la opción Business o Premier."
|
| 213 |
+
"Merchant reference ID format is not supported.","El formato de la Id. de referencia del comerciante no es compatible."
|
| 214 |
+
"Merchants need to apply to PayPal for enabling billing agreements feature. Do not enable this option until PayPal confirms that billing agreements are enabled for your merchant account.","Los comerciantes necesitan registrarse en Paypal para activar la opción de acuerdos de facturación. No active esta opción hasta que Paypal confirme que los acuerdos de facturación han sido activados para su cuenta de comerciante."
|
| 215 |
+
"Mobile Payment (made via a mobile phone)","Pago móvil (realizado vía teléfono móvil)"
|
| 216 |
+
"Multi-currency issue. Merchant must manually accept or deny this payment from PayPal Account Overview.","Problema de monedas múltiples. El comerciante debe aceptar o denegar manualmente este pago a través de la opción Vista general de la cuenta de Paypal."
|
| 217 |
+
"N/A","N/A"
|
| 218 |
+
"N/A. Address not checked, or acquirer had no response. Service not available","No disponible. No se ha comprobado la dirección o el usuario no obtuvo respuesta. Servicio no disponible."
|
| 219 |
+
"N/A. Global Unavailable","No disponible. Global no disponible."
|
| 220 |
+
"N/A. International Unavailable","No disponible. Internacional no disponible."
|
| 221 |
+
"N/A. Merchant has indicated that CVV2 is not present on card","No disponible. El comerciante ha notificado que su tarjeta no tiene CVV2."
|
| 222 |
+
"N/A. No response","No disponible. Sin respuesta."
|
| 223 |
+
"N/A. Not allowed for MOTO (Internet/Phone) transactions","N/A. No disponible para transacciones MOTO (Internet/móvil)"
|
| 224 |
+
"N/A. Not processed","No disponible. No procesado."
|
| 225 |
+
"N/A. Retry","No disponible. Vuelva a intentar."
|
| 226 |
+
"N/A. Service not Supported","N/A. Servicio no disponible."
|
| 227 |
+
"N/A. Service not available","No disponible. Servicio no disponible."
|
| 228 |
+
"N/A. Service not supported","N/A. Servicio no operativo"
|
| 229 |
+
"N/A. The merchant did not provide AVS information","N/A. El comerciante no ha proporcionado la información AVS"
|
| 230 |
+
"N/A. The merchant has not implemented CVV2 code handling","No disponible. El comerciante no ha implementado la gestión del código CVV2."
|
| 231 |
+
"N/A. Unavailable","No disponible. No disponible."
|
| 232 |
+
"Negative Balance","No disponible. Saldo negativo"
|
| 233 |
+
"Never","Nunca"
|
| 234 |
+
"No","No"
|
| 235 |
+
"No Details matched","No ha habido coincidencias"
|
| 236 |
+
"No Details matched. International","Los detalles no coinciden. Internacional"
|
| 237 |
+
"No Liability Shift","No hay cambios de responsabilidad"
|
| 238 |
+
"No Logo","Sin logotipo"
|
| 239 |
+
"No match","No ha habido coincidencias"
|
| 240 |
+
"None of the address information matched","Ninguna información de la dirección coincide"
|
| 241 |
+
"Note: %s","Nota: %s"
|
| 242 |
+
"Nothing to fetch because of an empty configuration.","No hay resultados debido a un vacío en la configuración."
|
| 243 |
+
"Notice that PayPal can handle up to 10 shipping options. That is why Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.","Tenga en cuenta que PayPal puede gestionar hasta 10 opciones de envío. Por eso Magento solamente transferirá las primeras 10 opciones de envío más baratas si hay mas de 10 opciones disponibles."
|
| 244 |
+
"Notified customer about creditmemo #%s.","Cliente informado de la nota de abono #%s."
|
| 245 |
+
"Notified customer about invoice #%s.","Cliente informado de la factura #%s."
|
| 246 |
+
"Now accepting PayPal (150 X 40)","Se acepta PayPal (150 X 40)"
|
| 247 |
+
"Now accepting PayPal (150 X 60)","Ahora se acepta Paypal (150 X 60)"
|
| 248 |
+
"Number of Child Authorizations","Número de autorizaciones infantiles"
|
| 249 |
+
"Open Authorization","Abrir la autorización"
|
| 250 |
+
"Order","Encargar"
|
| 251 |
+
"Order ID","ID de Pedido"
|
| 252 |
+
"Order Valid Period (days)","Período válido del pedido (días)"
|
| 253 |
+
"Ordered amount of %s.","Cantidad pedida de %s."
|
| 254 |
+
"Ordering amount of %s is pending approval on gateway.","El pedido de la cantidad de %s está pendiente de aprobación en el portal."
|
| 255 |
+
"Page Background Color","Color del fondo de página"
|
| 256 |
+
"Page Style","Estilo de página"
|
| 257 |
+
"Part of the address information matched","Parte de la información de la dirección coincidió"
|
| 258 |
+
"Partner","Socio"
|
| 259 |
+
"Pasarela integral","Pasarela integral"
|
| 260 |
+
"Pasarela integral Settings","Ajustes de Pasarela integral"
|
| 261 |
+
"Password","Contraseña"
|
| 262 |
+
"Pay Now","Pagar ahora"
|
| 263 |
+
"PayPal","PayPal"
|
| 264 |
+
"PayPal Balance Manager function of PayPal account","Función del Gestor de saldo de PayPal de la cuenta de PayPal"
|
| 265 |
+
"PayPal Buyer Warranty Bonus","Bonificación de garantía del comprador en PayPal"
|
| 266 |
+
"PayPal Debit Card Cash Advance","Adelanto de efectivo de una tarjeta de débito en PayPal"
|
| 267 |
+
"PayPal Debit Card Withdrawal from ATM","Retiro de dinero de tarjeta de débido de PayPal desde un cajero automático"
|
| 268 |
+
"PayPal Express Checkout Shortcut Wrapper","Acceso directo al check-out exprés de PayPal"
|
| 269 |
+
"PayPal Express Checkout Token does not exist.","El símbolo para la Salida Express con Paypal no existe."
|
| 270 |
+
"PayPal Express Order Review Form","Formulario de revisión de compra por PayPal Express"
|
| 271 |
+
"PayPal Fee Information","Información de tarifa de PayPal"
|
| 272 |
+
"PayPal Merchant Pages Style","Estilo de la página de la tienda en PayPal"
|
| 273 |
+
"PayPal Payments Advanced","Pagos Avanzados de PayPal"
|
| 274 |
+
"PayPal Pro","PayPal Pro"
|
| 275 |
+
"PayPal Pro Settings","Ajustes de PayPal Pro"
|
| 276 |
+
"PayPal Product Logo","Logotipo del producto en PayPal"
|
| 277 |
+
"PayPal Protection Bonus","Bono de protección de PayPal"
|
| 278 |
+
"PayPal Reference ID","Id. de referencia de PayPal"
|
| 279 |
+
"PayPal Reference ID Type","Tipo de Id. de referencia de PayPal"
|
| 280 |
+
"PayPal Settlement Reports","Informes de liquidación de PayPal"
|
| 281 |
+
"PayPal certificate does not exist.","Certificado PayPal no existe."
|
| 282 |
+
"PayPal certificate file is empty.","Archivo de certificado PayPal está vacío."
|
| 283 |
+
"PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.","PayPal no admite el proceso de pedidos con importe cero. Para finalizar su compra, continúe con el proceso de caja estándar."
|
| 284 |
+
"PayPal gateway has rejected request. %s","La puerta de enlace de PayPal ha rechazado la solicitud. %s"
|
| 285 |
+
"PayPal processes all of your orders, and you get paid.","PayPal procesa todos sus pedidos y le paga a usted."
|
| 286 |
+
"PayPal response hasn't required fields.","La respuesta de PayPal no tiene campos obligatorios."
|
| 287 |
+
"PayPal retains reports for 45 days.","PayPal almacena los informes durante 45 días."
|
| 288 |
+
"PayPal/Centinel Electronic Commerce Indicator","Indicador de comercio electrónico de PayPal/Centinel"
|
| 289 |
+
"PayPal/Centinel Visa Payer Authentication Service Result","Resultado del servicio de autenticación del pagador con Visa a través de PayPal/Centinel"
|
| 290 |
+
"Payer Address ID","Id. de dirección del pagador"
|
| 291 |
+
"Payer Address Status","Estado de la dirección del comprador"
|
| 292 |
+
"Payer Email","Correo electrónico del pagador"
|
| 293 |
+
"Payer ID","Id. del pagador"
|
| 294 |
+
"Payer Status","Situación del comprador"
|
| 295 |
+
"Payer is not identified.","El pagador no se ha identificado."
|
| 296 |
+
"Payflow Link (for USA and Canada)","Vínculo de Flujo de Pago (para EE. UU. y Canadá)"
|
| 297 |
+
"Payflow Link Settings","Configuración del Vínculo de Flujo de Pago"
|
| 298 |
+
"Payflow Pro Gateway","Pasarela Payflow Pro"
|
| 299 |
+
"Payflow Pro Settings","Ajustes de la Pasarela Payflow Pro"
|
| 300 |
+
"Payment Action","Acción de Pago"
|
| 301 |
+
"Payment Applicable From","Pago Aplicable Desde"
|
| 302 |
+
"Payment Refund initiated by merchant","Reembolso de Pago iniciado por el comerciante"
|
| 303 |
+
"Payment has been declined. Please try again.","El pago ha sido rechazado. Vuelva a intentarlo."
|
| 304 |
+
"Payment is being reviewed by PayPal for risk.","El pago está siendo revisado por PayPal por si hubiera algún riesgo."
|
| 305 |
+
"Payment transactions disallow storing objects.","Las operaciones de pago no permiten almacenar objetos."
|
| 306 |
+
"Payment was made to an email address that is not yet registered or confirmed.","El pago se ha realizado a una dirección electrónica que todavía no ha sido registrada o confirmada."
|
| 307 |
+
"Payments by PayPal (150 X 40)","Pagos por PayPal (150 X 40)"
|
| 308 |
+
"Payments by PayPal (150 X 60)","Pagos por PayPal (150 X 60)"
|
| 309 |
+
"Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Pagos mediante tarjetas + protección de vendedor - <strong style=""color:red"">Contacte con PayPal antes de su activación</strong>"
|
| 310 |
+
"Paypal Billing Agreement Settings","Ajustes del Acuerdo de Facturación de PayPal"
|
| 311 |
+
"Pending PayPal","Pendiente de pago en PayPal"
|
| 312 |
+
"Place Order","Hacer pedido"
|
| 313 |
+
"Please agree to all the terms and conditions before placing the order.","Por favor, acepta todos los términos y condiciones antes de realizar el pedido."
|
| 314 |
+
"Please contact PayPal Customer Service.","Por favor, póngase en contacto con el Servicio de Atención al Cliente de PayPal."
|
| 315 |
+
"Please do not refresh the page until you complete payment.","No actualice la página hasta que complete el pago."
|
| 316 |
+
"Please select a shipping method...","Por favor, elija un método de envío..."
|
| 317 |
+
"Please select region, state or province","Por favor seleccione región, estado o provincia"
|
| 318 |
+
"Please update order data to get shipping methods and rates","Por favor, actualice los datos del pedido para obtener métodos de envío y tarifas"
|
| 319 |
+
"Points Incentive Redemption","Puntos de incentivo por cancelación"
|
| 320 |
+
"Postage Payment to either USPS or UPS","Pago de los Gastos de Envío bien a USPS o a UPS"
|
| 321 |
+
"Preapproved Payment (BillUser API), either sent or received","Pagos previamente aprobados (BillUser API) enviados o recibidos"
|
| 322 |
+
"Preapproved Payment ID","Identificación del Pago Pre-autorizado"
|
| 323 |
+
"Price","Precio"
|
| 324 |
+
"Process credit cards directly on your website with PayPal’s all-in-one online payment processing solution.","Tramite las tarjetas de crédito directamente en su sitio de Internet con la solución de tramitación de pago a distancia todo-en-uno de PayPal."
|
| 325 |
+
"Product Name","Nombre de Producto"
|
| 326 |
+
"Proxy Host","Servidor Proxy"
|
| 327 |
+
"Proxy Port","Puerto proxy"
|
| 328 |
+
"Qty","Cantidad"
|
| 329 |
+
"Reauthorization","Reautorización"
|
| 330 |
+
"Reference Information","Información de Referencia"
|
| 331 |
+
"Refund issued by merchant.","Reembolso emitido por el comerciante."
|
| 332 |
+
"Reimbursement for a chargeback.","Devolución o reembolso."
|
| 333 |
+
"Reimbursement of Chargeback","Reembolso de una transacción devuelta"
|
| 334 |
+
"Report Date","Fecha del informe"
|
| 335 |
+
"Reports","Informes"
|
| 336 |
+
"Requested %s and configured %s merchant emails do not match.","Las direcciones del comerciante solicitada %s y configurada %s no se corresponden."
|
| 337 |
+
"Require CVV Entry","Requiere el código de seguridad de la tarjeta"
|
| 338 |
+
"Require Customer's Billing Address","Exija la dirección de facturación del cliente"
|
| 339 |
+
"Reversal","Inversión"
|
| 340 |
+
"Reversal of General Account Hold","Revocación de Cargo General en Cuenta"
|
| 341 |
+
"Reversal of Points Usage","Inversión de los puntos de utilización"
|
| 342 |
+
"Reversal of an adjustment.","Revocación de un ajuste."
|
| 343 |
+
"Reversal of hold for Dispute Investigation","Reposición por la investigación de la disputa"
|
| 344 |
+
"Review Order","Revise su pedido"
|
| 345 |
+
"Reward Voucher Redemption","Realizar canje de vales"
|
| 346 |
+
"SFTP Credentials","Credenciales SFTP"
|
| 347 |
+
"Sale","Venta"
|
| 348 |
+
"Sales","Ventas"
|
| 349 |
+
"Same as shipping","Igual que el envío"
|
| 350 |
+
"Sandbox Credentials","Credenciales de Supervisión"
|
| 351 |
+
"Sandbox Mode","Modo de prueba"
|
| 352 |
+
"Schedule","Programa"
|
| 353 |
+
"Schedule description is too long.","La descripción de designaciones es demasiado larga."
|
| 354 |
+
"Scheduled Fetching","Compra programada"
|
| 355 |
+
"Select a PayPal Solution","Selecciones una solución PayPal"
|
| 356 |
+
"Server Error. Please try again.","Error del servidor. Por favor, inténtelo de nuevo."
|
| 357 |
+
"Settlement Consolidation","Consolidación del Acuerdo"
|
| 358 |
+
"Settlement Report Settings","Ajustes del informe de liquidación"
|
| 359 |
+
"Settlement of a chargeback.","Liquidación de una transacción devuelta."
|
| 360 |
+
"Severe 3D Secure Card Validation","Validación estricta de tarjeta segura en 3D"
|
| 361 |
+
"Severe Validation Removes Chargeback Liability on Merchant","La Validación Severe Suprime la Responsabilidad de Cancelación de Cargo del Comerciante"
|
| 362 |
+
"Severe validation removes chargeback liability on merchant.","La validación estricta exime al comerciante de responsabilidad en caso de devoluciones de cargos"
|
| 363 |
+
"Shipping","Transporte"
|
| 364 |
+
"Shipping Address","Dirección de Envío"
|
| 365 |
+
"Shipping Method","Método de envío"
|
| 366 |
+
"Shop now using (150 X 40)","Compre ahora usando (150 X 40)"
|
| 367 |
+
"Shop now using (150 X 60)","Compre ahora utilizando (150 X 60)"
|
| 368 |
+
"Shortcut","Acceso directo"
|
| 369 |
+
"Shortcut Buttons Flavor","Tipo de Botones de Atajo"
|
| 370 |
+
"Shortcut on Product View","Atajo para Vista de Producto"
|
| 371 |
+
"Shortcut on Shopping Cart","Atajo en el carro de la compra"
|
| 372 |
+
"Sign a billing agreement to streamline further purchases with PayPal.","Firma un acuerdo de facturación para agilizar futuras compras con PayPal."
|
| 373 |
+
"Solo","Solo"
|
| 374 |
+
"Sorry, no quotes are available for this order at this time.","Lamentamos informarle que en este momento no hay cotizaciones disponibles para este pedido."
|
| 375 |
+
"Sort Order","Orden de selección"
|
| 376 |
+
"Specifies what the Authorization Honor Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.","Especifica cuál es el período de autorización de la cuenta de PayPal del comerciante. Tiene que ser igual a la configuración de PayPal."
|
| 377 |
+
"Specifies what the Order Valid Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.","Especifica cuál es el período de validez del pedido de la cuenta de PayPal del comerciante. Tiene que ser igual a la configuración de PayPal."
|
| 378 |
+
"State/Province","Estado/Provincia"
|
| 379 |
+
"Static","Estático"
|
| 380 |
+
"Street Address","Dirección postal"
|
| 381 |
+
"Street Address %s","Calle %s"
|
| 382 |
+
"Submitting order information...","Enviando la información del pedido..."
|
| 383 |
+
"Subscriber name is too long.","El nombre de suscriptor es demasiado largo."
|
| 384 |
+
"Subscription ID","ID de Suscripción."
|
| 385 |
+
"Subscription Payment, either payment sent or payment received","Pago de suscripción, bien sea pago enviado o recibido."
|
| 386 |
+
"Subtotal","Subtotal"
|
| 387 |
+
"Summary Text for Aggregated Cart","Texto de Resumen para el Carro Añadido"
|
| 388 |
+
"Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","La admisión de tarjetas American Express requiere de un acuerdo adicional. Consulte los requisitios en <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>."
|
| 389 |
+
"Switch/Maestro","Cambiar/Maestro"
|
| 390 |
+
"Telephone","Teléfono"
|
| 391 |
+
"Test Mode","Modo de prueba"
|
| 392 |
+
"The background color for the checkout page around the header and payment form.","El color de fondo de la página de reembolso de la cabecera y formulario de pago."
|
| 393 |
+
"The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Color de fondo para la cabecera de la página de pago. Código ASCII de color hexadecimal HTML de seis caracteres sin diferencias mayúsculas o minúsculas."
|
| 394 |
+
"The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","El número de autorizaciones infantiles por defecto de su cuenta de PayPal es 1. Para tener autorizaciones múltiples, póngase en contacto con PayPal para solicitar un aumento."
|
| 395 |
+
"The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","Imagen en la parte superior izquierda de la página de pago. El tamaño máximo es 750x90 píxeles. Se recomienda encarecidamente el uso de <strong style=""color:red"">https</strong>."
|
| 396 |
+
"The maximum number of child authorizations is reached.","Se ha alcanzado el número máximo de autorizaciones infantiles."
|
| 397 |
+
"The merchant account is not yet verified.","Todavía no se ha verificado la cuenta de vendedor."
|
| 398 |
+
"The payment curency does not match any of the merchant\'s balances currency.","La moneda de pago no coincide con ninguna de las monedas de saldo del vendedor."
|
| 399 |
+
"The payment eCheck is not yet cleared.","Todavía no se ha limpiado el eCheck de pago."
|
| 400 |
+
"The payment is authorized but not settled.","El pago se ha autorizado, pero no se ha realizado."
|
| 401 |
+
"The payment is pending because it was made to an email address that is not yet registered or confirmed.","El pago está pendiente porque se ha realizado a una dirección de mail que todavía no se ha registrado o confirmado."
|
| 402 |
+
"The payment is pending while it is being reviewed by PayPal for risk.","El pago está pendiente, PayPal lo está revisando para asegurarse."
|
| 403 |
+
"The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","El pago se ha realizado mediante tarjeta de crédito. Para recibir los fondos el vendedor tiene que actualizar la cuenta a estado Business o Premier."
|
| 404 |
+
"There was an error processing your order. Please contact us or try again later.","Se produjo un error en el proceso de su pedido. Contacte con nosotros o inténtelo más tarde."
|
| 405 |
+
"This feature needs be enabled first for the merchant account through PayPal technical support.","Esta característica necesita primero ser activada para la cuenta comercial a través del soporte técnico de PayPal."
|
| 406 |
+
"This operation requires an existing transaction object.","Esta operación requiere de una transacción ya existente."
|
| 407 |
+
"Time of Day","Hora del Día"
|
| 408 |
+
"Title","Título"
|
| 409 |
+
"Transaction ID","Número de identificación de la transacción"
|
| 410 |
+
"Transaction ID must not be empty.","El número identificativo de la transacción debe completarse."
|
| 411 |
+
"Transaction Information","Información de Transacción"
|
| 412 |
+
"Transfer Cart Line Items","Transferir la línea de los artículos en el carrito"
|
| 413 |
+
"Transfer Shipping Options","Transferir las opciones de envío"
|
| 414 |
+
"Triggered Fraud Filters","Filtros de Fraude Desencadenados"
|
| 415 |
+
"Unable to cancel Express Checkout.","No se ha podido cancelar la Salida Express."
|
| 416 |
+
"Unable to change status. Current status is not correspond to real status.","No se puede cambiar el estado. El estado actual no se corresponde con el estado real."
|
| 417 |
+
"Unable to communicate with the PayPal gateway.","No ha sido posible comunicarse con el gateway de PayPal."
|
| 418 |
+
"Unable to initialize Express Checkout review.","No se ha podido iniciar la revisión de Salida Express."
|
| 419 |
+
"Unable to initialize Express Checkout.","No ha sido posible inicializar el Pago Express."
|
| 420 |
+
"Unable to place the order.","No se puede efectuar el pedido."
|
| 421 |
+
"Unable to process Express Checkout approval.","No se ha podido procesar la aprobación de Salida Express."
|
| 422 |
+
"Unable to start Express Checkout.","No se ha podido iniciar la Salida Express."
|
| 423 |
+
"Unable to update Order data.","No es posible actualizar la información del pedido."
|
| 424 |
+
"Unable to update shipping method.","No se ha podido actualizar el método de envío."
|
| 425 |
+
"Unknown Error. Please try again later.","Error desconocido. Por favor inténtalo más tarde."
|
| 426 |
+
"Unknown reason. Please contact PayPal customer service.","Razones desconocidas. Por favor, contacte el servicio de atención al cliente de PayPal."
|
| 427 |
+
"Update Order Data","Actualizar información del pedido"
|
| 428 |
+
"Use Proxy","Utilizar Proxy"
|
| 429 |
+
"Use colon to specify port. For example: ""test.example.com:5224"".","Utilice dos puntos para especificar el puerto. Por ejemplo: ""prueba.ejemplo.com:5224""."
|
| 430 |
+
"User","Usuario"
|
| 431 |
+
"User-initiated Currency Conversion","Conversión de moneda iniciada por el usuario"
|
| 432 |
+
"Uses store frontend name by default.","De forma predeterminada utiliza el nombre de la tienda de interfaz de usuario"
|
| 433 |
+
"VAT Number","Número de IVA"
|
| 434 |
+
"Vendor","Vendedor"
|
| 435 |
+
"Vendor / Merchant Login","Inicio de sesión para proveedores / comerciantes"
|
| 436 |
+
"View","Ver"
|
| 437 |
+
"View Demo","Vea la demostración"
|
| 438 |
+
"View PayPal solutions.","Ver soluciones de PayPal"
|
| 439 |
+
"View Transaction","Ver transacción"
|
| 440 |
+
"View Transaction Details","Ver Detalles de la Transacción"
|
| 441 |
+
"Virtual PayPal Debit Card Transaction","Transacción de Tarjeta de Débito de PayPal Virtual"
|
| 442 |
+
"Virtual Terminal Payment","Pago Terminal virtual"
|
| 443 |
+
"Void","Nulo"
|
| 444 |
+
"Waiting until Customer\'s eCheck will be cleared.","En espera hasta que se produzca la compensación del Cheque Electrónico del Cliente"
|
| 445 |
+
"We prefer PayPal (150 X 40)","Preferimos PayPal (150 X 40)"
|
| 446 |
+
"We prefer PayPal (150 X 60)","Preferimos PayPal (150 X 60)"
|
| 447 |
+
"Website Payments Plus","Pagos Web Plus"
|
| 448 |
+
"Website Payments Plus Settings","Configuración de Pagos Web Plus"
|
| 449 |
+
"Website Payments Pro","Website Payments Pro"
|
| 450 |
+
"Website Payments Pro (Payflow Edition) Settings","Configuración de Website Payments Pro (Payflow Edition)"
|
| 451 |
+
"Website Payments Pro Hosted Solution","Solución Hospedada de Pagos Web Pro"
|
| 452 |
+
"Website Payments Pro Hosted Solution Settings","Configuración de Solución Hospedada de Pagos Web Pro"
|
| 453 |
+
"Website Payments Pro Payflow Edition (includes Express Checkout)","Website Payments Pro Payflow Edition (incluye Pago Express)"
|
| 454 |
+
"Website Payments Pro Settings","Configuración de Website Payments Pro"
|
| 455 |
+
"Website Payments Standard","Pago Estándar en el Sitio Web"
|
| 456 |
+
"Website Payments Standard Payment","Pago estándar de la página web"
|
| 457 |
+
"Website Payments Standard Settings","Configuración de Pago Estándar en el Sitio Web"
|
| 458 |
+
"What is PayPal?","¿Qué es PayPal?"
|
| 459 |
+
"Whether to create a billing agreement, if there are no active billing agreements available.","Opción de creación de un contrato de facturación, si no hay contratos de facturación activos disponibles."
|
| 460 |
+
"Will appear as a payment option only for customers who have at least one active billing agreement.","Aparecerá como una opción de pago solamente para clientes que tengan al menos un contrato de facturación activo."
|
| 461 |
+
"WorldLink Withdrawal","Retirada de Fondos WorldLink"
|
| 462 |
+
"Would you like to sign a billing agreement to streamline further purchases with PayPal?","¿Le gustaría firmar un contrato de facturación para agilizar sus futuras compras con PayPal?"
|
| 463 |
+
"Wrong Order ID (%s) specified.","Se especificó un Identificador de Pedido Erróneo (%s)."
|
| 464 |
+
"Wrong PayPal Express Checkout Token specified.","Símbolo especificado de Salida Express con Paypal incorrecto."
|
| 465 |
+
"Yes","Sí"
|
| 466 |
+
"Yes. Matched Address and five-didgit ZIP","Sí. La Dirección y el Código Postal de cinco dígitos coinciden."
|
| 467 |
+
"You cannot void a verification transaction","No se puede anular una operación de comprobación"
|
| 468 |
+
"You will be redirected to the PayPal website in a few seconds.","Volverá a la página web de Paypal en unos segundos."
|
| 469 |
+
"You will be redirected to the PayPal website when you place an order.","Cuando realice el pedido se le devolverá a la página PayPal."
|
| 470 |
+
"You will be redirected to the PayPal website.","Se le redirigirá al sitio web de PayPal."
|
| 471 |
+
"You will be required to enter your payment details after you place an order.","Se le solicitará que introduzca los detalles del pago tras realizar el pedido."
|
| 472 |
+
"Zip/Postal Code","Código postal"
|
| 473 |
+
"chargeback reimbursed","Devolución del cargo reembolsada"
|
| 474 |
+
"chargeback settled","Devolución del cargo liquidada"
|
| 475 |
+
"customer complaint","reclamación de cliente"
|
| 476 |
+
"customer triggered a chargeback","El cliente ha solicitado un reembolso"
|
| 477 |
+
"customer triggered money-back guarantee","el cliente activó una garantía de devolución del dinero"
|
| 478 |
+
"eBay Auction Payment","Pago de Subasta de eBay"
|
| 479 |
+
"merchant refunded payment","el comerciante ha reembolsado el pago"
|
| 480 |
+
"no reason","No existen razones"
|
| 481 |
+
"reversal of an adjustment","revocación de un ajuste"
|
| 482 |
+
"unknown reason","Razones desconocidas"
|
| 483 |
+
"Payment Status","Estado del Pago"
|
| 484 |
+
"Pending Reason","Razones Pendiente"
|
| 485 |
+
"Payment Information","Información del Pago"
|
| 486 |
+
"Order Date","Fecha del Pedido"
|
| 487 |
+
"The order was placed using %s","El pedido fue realizado utilizando %s"
|
package.xml
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>magento_community_Ebcomm_PaypalMx</name>
|
| 4 |
+
<version>1.0.2</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>PayPal es la forma más fácil, rápida y segura de enviar y recibir pagos en línea. Los comercios
|
| 10 |
+

|
| 11 |
+
en México que habilitan PayPal como forma de pago pueden aceptar pagos en línea con las 
|
| 12 |
+

|
| 13 |
+
principales tarjetas de crédito y débito y con el saldo de las cuentas PayPal. Este módulo, diseñado 
|
| 14 |
+

|
| 15 |
+
por el equipo de PayPal México, está optimizado especialmente para comercios mexicanos y 
|
| 16 |
+

|
| 17 |
+
cuenta con los ajustes necesarios para comunicar de la mejor manera las diferentes alternativas 
|
| 18 |
+

|
| 19 |
+
de pago con PayPal y ayudar a maximizar la conversión. También pueden ofrecer a sus clientes 
|
| 20 |
+

|
| 21 |
+
pagos en mensualidades. La integración es sencilla, sin cargos por apertura ni comisiones 
|
| 22 |
+

|
| 23 |
+
mensuales.
|
| 24 |
+

|
| 25 |
+
Los comercios que integran las soluciones de PayPal cuentan con una serie de funcionalidades 
|
| 26 |
+

|
| 27 |
+
que les ayudarán a impulsar sus ventas de comercio electrónico.</summary>
|
| 28 |
+
<description>Funcionalidades
|
| 29 |
+

|
| 30 |
+
Aceptación de pagos con tarjetas: Con PayPal, los comercios pueden aceptar pagos en línea con 
|
| 31 |
+

|
| 32 |
+
tarjetas de crédito VISA, MasterCard y American Express, y con tarjetas de débito emitidas por 
|
| 33 |
+

|
| 34 |
+
BBVA Bancomer, Banamex, Banorte, HSBC y Santander.
|
| 35 |
+

|
| 36 |
+
Planes de mensualidades: PayPal brinda a los comercios la opción de ofrecer a sus clientes planes 
|
| 37 |
+

|
| 38 |
+
de pago en mensualidades desde 3, 6, 9 y hasta 12 meses con Visa y MasterCard. Para ofrecer 
|
| 39 |
+

|
| 40 |
+
mensualidades, primero debe de estar activada la opción dentro de tu cuenta PayPal. Más 
|
| 41 |
+

|
| 42 |
+
información (https://www.paypal.com/mx/webapps/mpp/installments)
|
| 43 |
+

|
| 44 |
+
Seguridad y Protección: Los comercios que integran las soluciones de PayPal están protegidos 
|
| 45 |
+

|
| 46 |
+
por modelos de prevención de fraudes, líderes en la industria. Además, la Política de Protección 
|
| 47 |
+

|
| 48 |
+
al Vendedor de PayPal los protege contra reclamaciones del comprador y devoluciones de cargo. 
|
| 49 |
+

|
| 50 |
+
Alcance internacional: PayPal cuenta con más 137 millones de usuarios en 193 países y permite 
|
| 51 |
+

|
| 52 |
+
hacer transacciones en 26 divisas, incluyendo el dólar y el euro.
|
| 53 |
+

|
| 54 |
+
Solución líder
|
| 55 |
+

|
| 56 |
+
Pagos Exprés: Es una de las soluciones líderes de PayPal, la cual proporciona una experiencia de 
|
| 57 |
+

|
| 58 |
+
pago rápida, fácil y confiable. Entre sus características destacan:
|
| 59 |
+

|
| 60 |
+
• Ha sido integrada previamente por más 100 carritos de compra preferidos a nivel global.
|
| 61 |
+

|
| 62 |
+
• Puede integrarse fácilmente a través de las API de PayPal.
|
| 63 |
+

|
| 64 |
+
• Ha sido optimizada para pagos móviles; puede integrarla fácilmente en sitios móviles y en 
|
| 65 |
+

|
| 66 |
+
• Facilita la venta en línea de contenido digital.
|
| 67 |
+

|
| 68 |
+
• Ofrece herramientas para generar reportes en línea y llevar mejor el control de las ventas.
|
| 69 |
+

|
| 70 |
+
• Cuenta con medios de validación avanzados para brindar seguridad al comprador y al 
|
| 71 |
+

|
| 72 |
+
• Se integra a la perfección con los sistemas de back-office y back-end a la perfección.</description>
|
| 73 |
+
<notes>Este módulo es Compatible con las versiones de Magento: 1.8.0.0, 1.7.0.1 y 1.7.0.2</notes>
|
| 74 |
+
<authors><author><name>Ebcomm</name><user>Ebcomm</user><email>soporte@ebcomm.mx</email></author></authors>
|
| 75 |
+
<date>2014-02-05</date>
|
| 76 |
+
<time>19:14:28</time>
|
| 77 |
+
<contents><target name="magecommunity"><dir name="Ebcomm"><dir name="PaypalMx"><dir name="Block"><dir name="Adminhtml"><dir name="Settlement"><dir name="Details"><file name="Form.php" hash="b4cd66af4231bb4ba9bca8d75cc913c2"/></dir><file name="Details.php" hash="c721bb4e2f17fa2a805f4de2f2289888"/><dir name="Report"><file name="Grid.php" hash="776efd4bd4d87e16df77cf92db18cf0e"/></dir><file name="Report.php" hash="8850ee51b7773debbb58d14c65437ece"/></dir><dir name="System"><dir name="Config"><file name="ApiWizard.php" hash="80e5ae8798ab6bab3c81ee5cf376d5c2"/><dir name="Field"><file name="Country.php" hash="87db0dbbe10b34d2de7864b1d03a0b88"/><file name="Hidden.php" hash="40b17e389a0aee746592d8f4e1624979"/></dir><dir name="Fieldset"><file name="Expanded.php" hash="099556f3e484638c9facd35604ec7225"/><file name="Global.php" hash="94559f302e2fd22734e32423a279fe14"/><file name="Group.php" hash="7171fda706718a838710733b3105fa65"/><file name="Hint.php" hash="bf7ba7e966d4a223fb7e5f4180111bbe"/><file name="Location.php" hash="7ea802ee66868fb8a32f596593b07426"/><file name="Payment.php" hash="a751fd1ff644462985bf35f03444df89"/><file name="Store.php" hash="22d54bea1a5c0306828013584c5668af"/></dir><dir name="Payflowlink"><file name="Advanced.php" hash="5dd3ca0839dc4ccd2b2a61768fb519d1"/><file name="Info.php" hash="22882a71b671aa7364e52b46c83a8242"/></dir></dir></dir></dir><dir name="Debito"><file name="Form.php" hash="fa3ee77484ecaa5999f0acdf97959b6f"/><dir name="Review"><file name="Billing.php" hash="4d7f23048b18b1b8ad3317773f4f1e40"/><file name="Details.php" hash="15d86be5b2afa3023c78e33fb63d0857"/><file name="Shipping.php" hash="2b4223451ad0215b3a036bbe6c62debd"/></dir><file name="Review.php" hash="c6966f89d147619f604893d625e75dad"/></dir><dir name="Debito2"><file name="Form.php" hash="d85b3704a56cb3b285dd032845cba513"/><dir name="Review"><file name="Billing.php" hash="e2bc5486e487b391526a4305c73189a2"/><file name="Details.php" hash="446c6f3aa23ba5fccd834191d4816870"/><file name="Shipping.php" hash="5f4c83a6de3f9eacbe82879655ea97de"/></dir><file name="Review.php" hash="d5beca27a2dfd637404f6c3de88dc2f5"/><file name="Shortcut.php" hash="9201b9ce21345d4063011b72505cc230"/></dir><dir name="Express"><file name="Form.php" hash="7d043afe5a31007d4825b459c7f89190"/><dir name="Review"><file name="Billing.php" hash="4d7f23048b18b1b8ad3317773f4f1e40"/><file name="Details.php" hash="15d86be5b2afa3023c78e33fb63d0857"/><file name="Shipping.php" hash="2b4223451ad0215b3a036bbe6c62debd"/></dir><file name="Review.php" hash="7abd308b3b9aea48b69331bb2a7e5b2c"/><file name="Shortcut.php" hash="f19e8f442446a73e2d5fef93bd47c374"/></dir><dir name="Hosted"><dir name="Pro"><file name="Form.php" hash="ce858564fcd9897787bc37653b4888cb"/><file name="Iframe.php" hash="fc2d5870d207bb7205754298908c7a62"/><file name="Info.php" hash="c1aa1a0a39e0bebc0c2bac41f1761350"/></dir></dir><file name="Iframe.php" hash="578b47d39e498419be4e6c83b089f235"/><file name="Logo.php" hash="60aa0464029a82d100b6c0f7bd20e460"/><dir name="Mensualidades"><file name="Form.php" hash="3cf8338a8e89081449b2ac51f8f780ff"/><dir name="Review"><file name="Billing.php" hash="4d7f23048b18b1b8ad3317773f4f1e40"/><file name="Details.php" hash="15d86be5b2afa3023c78e33fb63d0857"/><file name="Shipping.php" hash="2b4223451ad0215b3a036bbe6c62debd"/></dir><file name="Review.php" hash="33cadd7774a17a29239f6d8722b8f57b"/></dir><dir name="Mensualidades2"><file name="Form.php" hash="3f5d31397e8eb63f5226d094a6d47331"/><dir name="Review"><file name="Billing.php" hash="6b5d7fa2eeb2518c295e56b8b2e9bf1e"/><file name="Details.php" hash="04fbfc8d7f54a0e06414c042b0670718"/><file name="Shipping.php" hash="5f4c83a6de3f9eacbe82879655ea97de"/></dir><file name="Review.php" hash="da02b2f12f8662c38388672dbf76fa14"/><file name="Shortcut.php" hash="289dc02f278629a2dc0cefba518cf172"/></dir><dir name="Payflow"><dir name="Advanced"><file name="Form.php" hash="927010606fe5fced1403d6ef58d3c270"/><file name="Iframe.php" hash="27d0fc56829f2c75b293df2e5e4650ab"/><file name="Info.php" hash="42d47a2b51ce4776f969ea5c72fd255e"/><file name="Review.php" hash="2714529f5662538bf847f0ed2e66bd41"/></dir><dir name="Link"><file name="Form.php" hash="f778d0aeee9c7b39931c0c135ae92003"/><file name="Iframe.php" hash="3c089c9890fc32657dc9fcaf126b9528"/><file name="Info.php" hash="420577d8a045b35691b7477915a147b3"/><file name="Review.php" hash="8f786f27ab15e61ddaaec8da98ac9c35"/></dir></dir><dir name="Payment"><file name="Info.php" hash="2cd023036a62048968e932dad6796b66"/></dir><dir name="Standard"><file name="Form.php" hash="f3ad173d8ba39b04dff8e2370eda5fa2"/><file name="Redirect.php" hash="542276cef580745aedca25069183d391"/></dir></dir><dir name="Controller"><dir name="Express"><file name="Abstract.php" hash="ea133b7e8507dd763f0816dd40c9cb4d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="db302f1b6a260a8c782f02dd12ee478d"/><file name="Hss.php" hash="e2df964d50fd85baf9703cf913da8977"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="08923700aba3c615280c4504a1ce81ad"/><file name="Nvp.php" hash="ef24fccac541c0da88093fdf686288e3"/><file name="Standard.php" hash="b96bf939bfa415b12388955077080bfc"/></dir><file name="Cart.php" hash="3b864c26f735143475b2f0615333d893"/><file name="Config.php" hash="9c72fc35fcd1747a980b26f92e04f862"/><dir name="Debito2"><file name="Checkout.php" hash="a903481cacf3c1adb87e7c56cc2084a0"/></dir><file name="Debito2.php" hash="b65a1e2f39d588dc70fa1bf688c23a7f"/><dir name="Express"><file name="Checkout.php" hash="c882c7a145cb3801c8222f4efd935a62"/></dir><file name="Express.php" hash="c60d7452da8b7bbf9d9ecee9fa81d037"/><file name="Info.php" hash="520ad9cbdd7dd4fa8d07dd9005d87d22"/><dir name="Mensualidades2"><file name="Checkout.php" hash="31a5a6fa6e664ef188da7723b7b7b1fc"/></dir><file name="Mensualidades2.php" hash="4bf49b042828316deb7e2715dc89b9d3"/><file name="Pro.php" hash="de3a2f57cf5a002b4f9d586cad26c2e8"/><dir name="Report"><dir name="Settlement"><file name="Row.php" hash="3f592ab9955c8d6a0de4fd6f62261bdd"/></dir><file name="Settlement.php" hash="2691c26ef9cf5d8c3975142a0b586954"/></dir><dir name="Resource"><file name="Cert.php" hash="64f2ff21ad23f68923602d867be75f95"/><dir name="Payment"><dir name="Transaction"><file name="Collection.php" hash="cbf6b54fe1a27fcd7244c6812b7dfcc5"/></dir><file name="Transaction.php" hash="55ba2006e21cdbd346eac74fe9539d2b"/></dir><dir name="Report"><dir name="Settlement"><dir name="Row"><file name="Collection.php" hash="8ece691160ad67e9e978579d2115002e"/></dir><file name="Row.php" hash="1eeaca503f403f134aab6d4dcb10f6ff"/></dir><file name="Settlement.php" hash="5b33161db3930ac991e2085c65ba771c"/></dir><file name="Setup.php" hash="7b15a771edebf6c6537cf178a666723b"/></dir><file name="Session.php" hash="ab58cd4c8d5d4e2859c666c27f956828"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cert.php" hash="8ffbb08021ca8a4ce58803d65e3bd735"/><file name="Cron.php" hash="a12543a814ef2ef2e24fe198e5f5700e"/><file name="MerchantCountry.php" hash="5bece6129577d833bdb86f52562af327"/></dir><dir name="Source"><file name="AuthorizationAmounts.php" hash="c7bc73f81cba80fa18980e49943eeae6"/><file name="BuyerCountry.php" hash="ee6578ea63adb780e1984e14103c40b1"/><file name="FetchingSchedule.php" hash="ae16dad27d4612b8c1e06600891ac801"/><file name="Logo.php" hash="b27ffbe0531bccc37c35f24d3cfd5377"/><file name="MerchantCountry.php" hash="3bb1fd8d8724df3b1b8e6ca850f8f4ff"/><dir name="PaymentActions"><file name="Express.php" hash="ac1a4ec817571dc2cfec035e588f296d"/></dir><file name="PaymentActions.php" hash="658d1257015b76f4b20726cbc2f65381"/><file name="RequireBillingAddress.php" hash="beb69ae978a1ad00aa7bc153ce1faf54"/><file name="UrlMethod.php" hash="3537462618e67f6ed30f149a83ab3978"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Paypal"><file name="ReportssController.php" hash="be81a61a7a8c1c641040479a2a1f311f"/></dir></dir><file name="ExpressController.php" hash="5cdf754a2f6d50c06724a9e2b46419d0"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2d1d1903c172a3cc49144d932922472e"/><file name="config.xml" hash="031d0ec75c5bbb044b58d222313b80f5"/><file name="system.xml" hash="2c1f7631ec4cc39f594ff79d697adc35"/></dir><dir name="sql"><dir name="paypal_setup"><file name="install-1.6.0.0.php" hash="b2469041739bf8e14fd0966400a22c07"/><file name="mysql4-install-0.7.0.php" hash="25fcdc3e2c1c6269aaa418be249b2d9f"/><file name="mysql4-install-1.4.0.0.php" hash="f42c5ef6ac5567f2d1f6f4c15263ea74"/><file name="mysql4-upgrade-0.7.1-0.7.2.php" hash="d6a61cfed1b9816441d043dd880e8238"/><file name="mysql4-upgrade-0.7.2-0.7.3.php" hash="1716deec69cbf7fa949558a76fa43fd1"/><file name="mysql4-upgrade-1.4.0.0-1.4.0.1.php" hash="e624edb8630883dd02b4b51662dc331b"/><file name="mysql4-upgrade-1.4.0.1-1.4.0.2.php" hash="38089d012488add3dfebb8257561f113"/><file name="mysql4-upgrade-1.5.9.9-1.6.0.0.php" hash="97953cf10dad2b87ed38a3e16fa10ca5"/><file name="upgrade-1.6.0.0-1.6.0.1.php" hash="145024349ddf84b2beab0f5f0f6d64a2"/><file name="upgrade-1.6.0.1-1.6.0.2.php" hash="370588e330f0a311fbd543cb31a182bb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="paypalmx"><dir name="system"><dir name="config"><file name="api_wizard.phtml" hash="6a5528fd5e0f05894b304bef308f5393"/><dir name="fieldset"><file name="global.phtml" hash="9782420769b39409c72b4248dc8bf9f3"/><file name="store.phtml" hash="f05eed8334cc4d25b3f767e330763cf4"/></dir><dir name="payflowlink"><file name="advanced.phtml" hash="50928244065ad54cc7e2ec921dd3f261"/><file name="info.phtml" hash="5db2cff1d753f822a72ab07bdee9c4a8"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="paypalmx.xml" hash="61434c3d35ecca74433f0cd511498c10"/></dir><dir name="template"><dir name="paypalmx"><dir name="express"><dir name="review"><file name="address.phtml" hash="f274e591956f2277608bebf62fa2b6b9"/><file name="details.phtml" hash="f3a7b01960a0a1ffbce627de81ddbaa5"/><dir name="shipping"><file name="method.phtml" hash="b3d255b8567f88996b2ed7cc36895a6e"/></dir></dir><file name="review.phtml" hash="10ae000f9eecf74e86c07a7986d4e779"/><file name="shortcut.phtml" hash="568ec5a867f3ef2e2c8cb88d643f1bdd"/></dir><dir name="hss"><file name="form.phtml" hash="7988a2afc2f851631223b2db66e1b064"/><file name="iframe.phtml" hash="dbb2b3fbf4ffa17b9e7fac30d996bf3f"/><file name="info.phtml" hash="0422558db314c49361ffa4e1486673b4"/><file name="js.phtml" hash="7810505ae3dc5caa48626edd367d869f"/><file name="redirect.phtml" hash="92aa527ff49a49557f991f417ba2e3f6"/><dir name="review"><file name="button.phtml" hash="d5c300ad6bd5149ae148424232cc431c"/></dir></dir><dir name="partner"><file name="logo.phtml" hash="fcf0a1f4b3aa08f892033b0b26c048e5"/></dir><dir name="payflowadvanced"><file name="form.phtml" hash="0cef01090768f89bb2dfaab4201750e4"/><file name="iframe.phtml" hash="a0a93a9784d09df119315e7f5947d11d"/><file name="info.phtml" hash="3c3d3115a34158ee1045924ad06fa5f6"/><file name="redirect.phtml" hash="2d22773588722699eb4b0943e496bbf0"/></dir><dir name="payflowlink"><file name="form.phtml" hash="7988a2afc2f851631223b2db66e1b064"/><file name="iframe.phtml" hash="990fd582d1a47def3453299a6abc8fc3"/><file name="info.phtml" hash="ef8a052347e035d9fdc3d8bea9859807"/><file name="redirect.phtml" hash="87b87bcb189c2e49f1f129086eea55ec"/></dir><dir name="payment"><file name="mark.phtml" hash="7b071019bbb5377a4585c6f3a7f4cab6"/><file name="redirect.phtml" hash="e584eba7a6af84e86294499edddf00cb"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ebcomm_PaypalMx.xml" hash="e4af926547cdd1a4b281bb51c262c0b7"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="paypalmx"><file name="accpmark_mensualidades_SP.PNG" hash="eeec91559b0b8bc76fdc3d47fd5042bf"/><file name="accpmark_tarjdeb_SP.PNG" hash="dc4acb3d846c91817b477c7650730830"/><file name="accpmark_visa_mc_SP.PNG" hash="25fc6f60251c81a594feb4ae9c4cc829"/><file name="logo-paypal.png" hash="d032551b47e48dced277c4fa344ac7f6"/><file name="pp-alt.png" hash="c262d332b342a2f4063cd82a61d11107"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="paypalmx"><file name="accpmark_mensualidades_SP.PNG" hash="eeec91559b0b8bc76fdc3d47fd5042bf"/><file name="accpmark_tarjdeb_SP.PNG" hash="dc4acb3d846c91817b477c7650730830"/><file name="accpmark_visa_mc_SP.PNG" hash="25fc6f60251c81a594feb4ae9c4cc829"/><file name="bdg_compra_segura_pp_.PNG" hash="99f16d5431768683b5bca61e8494ce4a"/><file name="logo-paypal.png" hash="d032551b47e48dced277c4fa344ac7f6"/><file name="paypalmx_loader.gif" hash="7f0d7ae2a20ebfc33b3f967d91047684"/><file name="pp-alt.png" hash="c262d332b342a2f4063cd82a61d11107"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="es_ES"><file name="Ebcomm_PaypalMx.csv" hash="11ef4a4cf25d117699e61eac6bc13b78"/></dir><dir name="es_MX"><file name="Ebcomm_PaypalMx.csv" hash="11ef4a4cf25d117699e61eac6bc13b78"/></dir></target></contents>
|
| 78 |
+
<compatible/>
|
| 79 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 80 |
+
</package>
|
skin/adminhtml/default/default/images/paypalmx/accpmark_mensualidades_SP.PNG
ADDED
|
Binary file
|
skin/adminhtml/default/default/images/paypalmx/accpmark_tarjdeb_SP.PNG
ADDED
|
Binary file
|
skin/adminhtml/default/default/images/paypalmx/accpmark_visa_mc_SP.PNG
ADDED
|
Binary file
|
skin/adminhtml/default/default/images/paypalmx/logo-paypal.png
ADDED
|
Binary file
|
skin/adminhtml/default/default/images/paypalmx/pp-alt.png
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/accpmark_mensualidades_SP.PNG
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/accpmark_tarjdeb_SP.PNG
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/accpmark_visa_mc_SP.PNG
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/bdg_compra_segura_pp_.PNG
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/logo-paypal.png
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/paypalmx_loader.gif
ADDED
|
Binary file
|
skin/frontend/base/default/images/paypalmx/pp-alt.png
ADDED
|
Binary file
|
