Version Notes
Released at Revision 16623
Download this release
Release Info
Developer | Magento Core Team |
Extension | Official_Computop_Payment_Modul |
Version | 1.0.0.16623 |
Comparing to | |
See all releases |
Version 1.0.0.16623
- DEPLOYED_REVISION +2 -0
- app/code/community/Dotsource/Computop/Block/Adminhtml/Block/Sales/Order/Grid.php +130 -0
- app/code/community/Dotsource/Computop/Block/Adminhtml/Notification/Secureurl.php +76 -0
- app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View.php +69 -0
- app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View/Tab/Action.php +281 -0
- app/code/community/Dotsource/Computop/Block/Checkout/Iframe.php +15 -0
- app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review.php +195 -0
- app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review/Details.php +41 -0
- app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Shortcut.php +85 -0
- app/code/community/Dotsource/Computop/Block/Config/Form/Abstract.php +265 -0
- app/code/community/Dotsource/Computop/Block/Config/Form/Merchant.php +76 -0
- app/code/community/Dotsource/Computop/Block/Config/Form/Renderer/Select.php +166 -0
- app/code/community/Dotsource/Computop/Block/Form/Abstract.php +93 -0
- app/code/community/Dotsource/Computop/Block/Form/Cc.php +193 -0
- app/code/community/Dotsource/Computop/Block/Form/Directpay.php +44 -0
- app/code/community/Dotsource/Computop/Block/Form/Eft.php +143 -0
- app/code/community/Dotsource/Computop/Block/Form/Giropay.php +44 -0
- app/code/community/Dotsource/Computop/Block/Form/Ideal.php +24 -0
- app/code/community/Dotsource/Computop/Block/Form/Mpass.php +25 -0
- app/code/community/Dotsource/Computop/Block/Form/Paypalexpress.php +39 -0
- app/code/community/Dotsource/Computop/Block/Form/Paypalstandard.php +48 -0
- app/code/community/Dotsource/Computop/Block/Info/Cc.php +90 -0
- app/code/community/Dotsource/Computop/Block/Info/Directpay.php +25 -0
- app/code/community/Dotsource/Computop/Block/Info/Eft.php +35 -0
- app/code/community/Dotsource/Computop/Block/Info/Giropay.php +25 -0
- app/code/community/Dotsource/Computop/Block/Info/Ideal.php +25 -0
- app/code/community/Dotsource/Computop/Block/Info/Mpass.php +28 -0
- app/code/community/Dotsource/Computop/Block/Info/Paypalstandard.php +25 -0
- app/code/community/Dotsource/Computop/Block/Widget/Grid/Column/Renderer/Zerofill.php +40 -0
- app/code/community/Dotsource/Computop/Controller/Callback.php +143 -0
- app/code/community/Dotsource/Computop/Controller/Computopcallback.php +334 -0
- app/code/community/Dotsource/Computop/Controller/Expresscallback.php +528 -0
- app/code/community/Dotsource/Computop/Helper/Config.php +345 -0
- app/code/community/Dotsource/Computop/Helper/Converter.php +298 -0
- app/code/community/Dotsource/Computop/Helper/Data.php +636 -0
- app/code/community/Dotsource/Computop/Helper/Feature.php +50 -0
- app/code/community/Dotsource/Computop/Helper/Payment.php +454 -0
- app/code/community/Dotsource/Computop/Helper/Paypal/Config.php +87 -0
- app/code/community/Dotsource/Computop/Model/Action.php +114 -0
- app/code/community/Dotsource/Computop/Model/Cancelprocess.php +584 -0
- app/code/community/Dotsource/Computop/Model/Connection.php +187 -0
- app/code/community/Dotsource/Computop/Model/Encryption.php +166 -0
- app/code/community/Dotsource/Computop/Model/Error/Handler/Abstract.php +57 -0
- app/code/community/Dotsource/Computop/Model/Error/Handler/Exception.php +32 -0
- app/code/community/Dotsource/Computop/Model/Error/Handler/Message.php +321 -0
- app/code/community/Dotsource/Computop/Model/Error/Handler/Session.php +64 -0
- app/code/community/Dotsource/Computop/Model/Error/Handler/Translate.php +62 -0
- app/code/community/Dotsource/Computop/Model/Error/Manager.php +267 -0
- app/code/community/Dotsource/Computop/Model/Error/Observer.php +102 -0
- app/code/community/Dotsource/Computop/Model/Exception.php +17 -0
- app/code/community/Dotsource/Computop/Model/Mysql4/Action.php +19 -0
- app/code/community/Dotsource/Computop/Model/Mysql4/Action/Collection.php +20 -0
- app/code/community/Dotsource/Computop/Model/Mysql4/Setup.php +116 -0
- app/code/community/Dotsource/Computop/Model/Mysql4/Transaction.php +46 -0
- app/code/community/Dotsource/Computop/Model/Mysql4/Transaction/Collection.php +20 -0
- app/code/community/Dotsource/Computop/Model/Observer.php +176 -0
- app/code/community/Dotsource/Computop/Model/Observer/Session.php +39 -0
- app/code/community/Dotsource/Computop/Model/Payment/Abstract.php +982 -0
- app/code/community/Dotsource/Computop/Model/Payment/Cc.php +122 -0
- app/code/community/Dotsource/Computop/Model/Payment/Directpay.php +61 -0
- app/code/community/Dotsource/Computop/Model/Payment/Eft.php +177 -0
- app/code/community/Dotsource/Computop/Model/Payment/Giropay.php +115 -0
- app/code/community/Dotsource/Computop/Model/Payment/Ideal.php +46 -0
- app/code/community/Dotsource/Computop/Model/Payment/Mpass.php +57 -0
- app/code/community/Dotsource/Computop/Model/Payment/Paypalexpress.php +216 -0
- app/code/community/Dotsource/Computop/Model/Payment/Paypalstandard.php +54 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Authorize.php +138 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Capture/New.php +61 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Capture.php +38 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Refund.php +41 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Reverse.php +42 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Directpay/Authorize.php +65 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Eft/Authorize.php +98 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Authorize.php +96 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Check.php +54 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Ideal/Authorize.php +46 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Mpass/Authorize.php +102 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Paypal/Authorize.php +131 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Paypalexpress/Authorize.php +114 -0
- app/code/community/Dotsource/Computop/Model/Payment/Request/Request.php +835 -0
- app/code/community/Dotsource/Computop/Model/Payment/Response/Giropay/Check.php +32 -0
- app/code/community/Dotsource/Computop/Model/Payment/Response/Response.php +205 -0
- app/code/community/Dotsource/Computop/Model/Rewrite/Sales/Order/Payment.php +86 -0
- app/code/community/Dotsource/Computop/Model/Session.php +91 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Backend/Orderdesc.php +37 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Backend/Serialized/Merchant.php +54 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Abstract.php +26 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedcountriesAction.php +38 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedipzonesAction.php +38 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Baseurl.php +33 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Countryiso3.php +44 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Logos.php +81 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Modus.php +35 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Paymentaction.php +41 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Paypalpaymentaction.php +37 -0
- app/code/community/Dotsource/Computop/Model/System/Config/Source/Txtype.php +34 -0
- app/code/community/Dotsource/Computop/Model/Transaction.php +99 -0
- app/code/community/Dotsource/Computop/Object.php +349 -0
- app/code/community/Dotsource/Computop/controllers/Adminhtml/ActionController.php +52 -0
- app/code/community/Dotsource/Computop/controllers/Adminhtml/MassactionController.php +238 -0
- app/code/community/Dotsource/Computop/controllers/Callback/CcController.php +62 -0
- app/code/community/Dotsource/Computop/controllers/Callback/DirectpayController.php +23 -0
- app/code/community/Dotsource/Computop/controllers/Callback/GiropayController.php +23 -0
- app/code/community/Dotsource/Computop/controllers/Callback/IdealController.php +23 -0
- app/code/community/Dotsource/Computop/controllers/Callback/MpassController.php +27 -0
- app/code/community/Dotsource/Computop/controllers/Callback/PaypalController.php +28 -0
- app/code/community/Dotsource/Computop/controllers/Callback/PaypalexpressController.php +80 -0
- app/code/community/Dotsource/Computop/controllers/IframeController.php +127 -0
- app/code/community/Dotsource/Computop/controllers/IndexController.php +77 -0
- app/code/community/Dotsource/Computop/etc/adminhtml.xml +23 -0
- app/code/community/Dotsource/Computop/etc/config.xml +303 -0
- app/code/community/Dotsource/Computop/etc/errors.xml +254 -0
- app/code/community/Dotsource/Computop/etc/system.xml +776 -0
- app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-install-1.4.0.1.1.php +56 -0
- app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.0.1.1-1.4.1.1.2.php +83 -0
- app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.2-1.4.1.1.3.php +8 -0
- app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.3-1.4.1.1.4.php +8 -0
- app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.4-1.4.1.1.5.php +8 -0
- app/code/community/Dotsource/Dsrevision/Block/Adminhtml/System/Revision.php +60 -0
- app/code/community/Dotsource/Dsrevision/etc/config.xml +25 -0
- app/code/community/Dotsource/Dsrevision/etc/system.xml +38 -0
- app/code/community/Mage/Sales/Model/Order/Payment-1.4.0.X.php +964 -0
- app/code/community/Mage/Sales/Model/Order/Payment-1.4.1.X.php +1294 -0
- app/code/community/Mage/Sales/Model/Order/Payment.php +10 -0
- app/design/adminhtml/default/default/layout/computop.xml +58 -0
- app/design/adminhtml/default/default/template/computop/config/form/field/form.phtml +178 -0
- app/design/adminhtml/default/default/template/computop/depends/allallowedcountries.phtml +120 -0
- app/design/adminhtml/default/default/template/computop/depends/ipzones.phtml +114 -0
- app/design/adminhtml/default/default/template/computop/form/eft.phtml +32 -0
- app/design/adminhtml/default/default/template/computop/info/callback.phtml +25 -0
- app/design/adminhtml/default/default/template/computop/notification/secureurl.phtml +18 -0
- app/design/frontend/base/default/layout/computop.xml +55 -0
- app/design/frontend/base/default/template/computop/checkout/iframe.phtml +21 -0
- app/design/frontend/base/default/template/computop/checkout/paypal/review.phtml +130 -0
- app/design/frontend/base/default/template/computop/checkout/paypal/review/details.phtml +52 -0
- app/design/frontend/base/default/template/computop/checkout/paypal/shortcut.phtml +20 -0
- app/design/frontend/base/default/template/computop/form/cc.phtml +19 -0
- app/design/frontend/base/default/template/computop/form/directpay.phtml +35 -0
- app/design/frontend/base/default/template/computop/form/eft.phtml +32 -0
- app/design/frontend/base/default/template/computop/form/giropay.phtml +35 -0
- app/design/frontend/base/default/template/computop/form/ideal.phtml +19 -0
- app/design/frontend/base/default/template/computop/form/mpass.phtml +21 -0
- app/design/frontend/base/default/template/computop/form/paypalstandard.phtml +16 -0
- app/design/frontend/base/default/template/computop/info/callback.phtml +27 -0
- app/etc/modules/Dotsource_Computop.xml +16 -0
- app/etc/modules/Dotsource_Dsrevision.xml +20 -0
- app/locale/de_DE/Dotsource_Computop.csv +189 -0
- package.xml +27 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_american_express.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_cartebleue.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_dankort.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_jcb.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_maestro.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_mastercard.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_mastercard_secure_code.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_verified_by_visa.png +0 -0
- skin/frontend/base/default/images/computop/computop_cc/computop_visa.png +0 -0
- skin/frontend/base/default/images/computop/computop_directpay.gif +0 -0
- skin/frontend/base/default/images/computop/computop_eft.gif +0 -0
- skin/frontend/base/default/images/computop/computop_giropay.gif +0 -0
- skin/frontend/base/default/images/computop/computop_ideal.gif +0 -0
- skin/frontend/base/default/images/computop/computop_mpass.gif +0 -0
- skin/frontend/base/default/images/computop/computop_o2.gif +0 -0
- skin/frontend/base/default/images/computop/computop_paypal.gif +0 -0
- skin/frontend/base/default/images/computop/computop_vodafone.gif +0 -0
DEPLOYED_REVISION
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
Date: 2010-09-01 16:45
|
2 |
+
Revision: 16623
|
app/code/community/Dotsource/Computop/Block/Adminhtml/Block/Sales/Order/Grid.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Block_Adminhtml_Block_Sales_Order_Grid
|
11 |
+
extends Mage_Adminhtml_Block_Sales_Order_Grid
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Extends the order grid cols.
|
16 |
+
*/
|
17 |
+
protected function _prepareColumns()
|
18 |
+
{
|
19 |
+
//Only need for magento version < 1.4.1.0
|
20 |
+
if ($this->_getHelper()->getFeatureHelper()->hasGridTables()) {
|
21 |
+
return parent::_prepareColumns();
|
22 |
+
}
|
23 |
+
|
24 |
+
//Add the computop RefNr
|
25 |
+
$this->addColumnAfter('computop_transaction_id',
|
26 |
+
array(
|
27 |
+
'header' => 'CT RefNr',
|
28 |
+
'title' => 'Computop Reference Number',
|
29 |
+
'index' => 'computop_transaction_id',
|
30 |
+
'type' => 'text',
|
31 |
+
'width' => '65px',
|
32 |
+
'renderer' => 'computop/widget_grid_column_renderer_zerofill',
|
33 |
+
'filter_condition_callback' => array($this, '_filterComputopTransactionId')
|
34 |
+
),
|
35 |
+
'real_order_id'
|
36 |
+
);
|
37 |
+
|
38 |
+
//Add the magentodefault cols
|
39 |
+
return parent::_prepareColumns();
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Extends the collection with the computop_transaction_id attribute from the
|
45 |
+
* order payment entity.
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection()
|
48 |
+
{
|
49 |
+
//Only need for magento version < 1.4.1.0
|
50 |
+
if ($this->_getHelper()->getFeatureHelper()->hasGridTables()) {
|
51 |
+
return parent::_prepareCollection();
|
52 |
+
}
|
53 |
+
|
54 |
+
//Default magento logic
|
55 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
56 |
+
->addAttributeToSelect('*')
|
57 |
+
->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
|
58 |
+
->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
|
59 |
+
->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
|
60 |
+
->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
|
61 |
+
->addExpressionAttributeToSelect('billing_name',
|
62 |
+
'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
|
63 |
+
array('billing_firstname', 'billing_lastname'))
|
64 |
+
->addExpressionAttributeToSelect('shipping_name',
|
65 |
+
'CONCAT({{shipping_firstname}}, IFNULL(CONCAT(\' \', {{shipping_lastname}}), \'\'))',
|
66 |
+
array('shipping_firstname', 'shipping_lastname'));
|
67 |
+
|
68 |
+
|
69 |
+
//Join the EAV attribute
|
70 |
+
$attributeModel = Mage::getModel('eav/config');
|
71 |
+
$refNrAttribute = $attributeModel->getAttribute('order_payment', 'computop_transaction_id');
|
72 |
+
|
73 |
+
$collection->getSelect()
|
74 |
+
->joinLeft( //Join the payment entity id
|
75 |
+
array('payment' => $collection->getTable('sales/order_entity')),
|
76 |
+
'e.entity_id=payment.parent_id AND payment.entity_type_id=' . $refNrAttribute->getEntityTypeId(),
|
77 |
+
null
|
78 |
+
)
|
79 |
+
->joinLeft( //Join the computop transaction id
|
80 |
+
array('ct_refnr' => $refNrAttribute->getBackendTable()),
|
81 |
+
'payment.entity_id=ct_refnr.entity_id AND ct_refnr.attribute_id=' . $refNrAttribute->getId(),
|
82 |
+
array('computop_transaction_id' => 'ct_refnr.value')
|
83 |
+
);
|
84 |
+
|
85 |
+
//Add the sort order
|
86 |
+
switch($this->getParam($this->getVarNameSort())) {
|
87 |
+
case 'computop_transaction_id':
|
88 |
+
$sortOrder = trim(strtoupper($this->getParam($this->getVarNameDir())));
|
89 |
+
|
90 |
+
if (Zend_Db_Select::SQL_DESC == $sortOrder) {
|
91 |
+
$sortOrder = Zend_Db_Select::SQL_DESC;
|
92 |
+
} else {
|
93 |
+
$sortOrder = Zend_Db_Select::SQL_ASC;
|
94 |
+
}
|
95 |
+
|
96 |
+
$collection->getSelect()->order("ct_refnr.value $sortOrder");
|
97 |
+
break;
|
98 |
+
}
|
99 |
+
|
100 |
+
$this->setCollection($collection);
|
101 |
+
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Filter callback for computop_transaction_id.
|
107 |
+
*
|
108 |
+
* @param unknown_type $collection
|
109 |
+
* @param unknown_type $column
|
110 |
+
*/
|
111 |
+
protected function _filterComputopTransactionId($collection, $column)
|
112 |
+
{
|
113 |
+
if (!$value = $column->getFilter()->getValue()) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
$collection->getSelect()->where('ct_refnr.value = ?', $value);
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Return the computop helper.
|
123 |
+
*
|
124 |
+
* @return Dotsource_Computop_Helper_Data
|
125 |
+
*/
|
126 |
+
protected function _getHelper()
|
127 |
+
{
|
128 |
+
return Mage::helper('computop');
|
129 |
+
}
|
130 |
+
}
|
app/code/community/Dotsource/Computop/Block/Adminhtml/Notification/Secureurl.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Block_Adminhtml_Notification_Secureurl
|
11 |
+
extends Mage_Adminhtml_Block_Notification_Baseurl
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Mage_Adminhtml_Block_Notification_Baseurl::getConfigUrl()
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getConfigUrl()
|
20 |
+
{
|
21 |
+
//Holds the route to the setting
|
22 |
+
$route = 'adminhtml/system_config/edit';
|
23 |
+
$param = array('section' => 'web');
|
24 |
+
|
25 |
+
//check for default settings
|
26 |
+
$defaultSecureUrl = (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
|
27 |
+
|
28 |
+
if (!$this->_getHelper()->isHttpsUrl($defaultSecureUrl)) {
|
29 |
+
return $this->getUrl($route, $param);
|
30 |
+
}
|
31 |
+
|
32 |
+
//Find all secure urls for checking the https
|
33 |
+
/* @var $dataCollection Mage_Core_Model_Mysql4_Config_Data_Collection */
|
34 |
+
$dataCollection = Mage::getResourceModel('core/config_data_collection')
|
35 |
+
->addFieldToFilter('path', array('eq' => Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL));
|
36 |
+
|
37 |
+
//Add filter for start with https
|
38 |
+
$dataCollection
|
39 |
+
->getSelect()
|
40 |
+
->where(new Zend_Db_Expr("LOWER(main_table.value) NOT LIKE ?"), 'https://%')
|
41 |
+
->limit(1);
|
42 |
+
|
43 |
+
//Check for the right section
|
44 |
+
foreach ($dataCollection as $data) {
|
45 |
+
//Check if the given url is an https url
|
46 |
+
if ($this->_getHelper()->isHttpsUrl($data->getValue())) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
|
50 |
+
//Build the right url
|
51 |
+
switch ($data->getScope()) {
|
52 |
+
case 'default' :
|
53 |
+
return $this->getUrl($route, $param);
|
54 |
+
case 'stores' :
|
55 |
+
$param['store'] = Mage::app()->getStore($data->getScopeId())->getCode();
|
56 |
+
return $this->getUrl($route, $param);
|
57 |
+
case 'websites' :
|
58 |
+
$param['website'] = Mage::app()->getWebsite($data->getScopeId())->getCode();
|
59 |
+
return $this->getUrl($route, $param);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
return "";
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Return the computop helper.
|
69 |
+
*
|
70 |
+
* @return Dotsource_Computop_Helper_Data
|
71 |
+
*/
|
72 |
+
protected function _getHelper()
|
73 |
+
{
|
74 |
+
return Mage::helper('computop');
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Block_Adminhtml_Sales_Order_View
|
11 |
+
extends Mage_Adminhtml_Block_Sales_Order_View
|
12 |
+
{
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
parent::__construct();
|
17 |
+
|
18 |
+
//Only need for computop payment
|
19 |
+
if (!$this->getOrder()->getPayment()->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
+
//Refresh the onclick message
|
24 |
+
if ($this->_hasButton('order_cancel')) {
|
25 |
+
$message = Mage::helper('computop')->__(
|
26 |
+
'Are you sure you want to cancel this order and refund an amount of %s?',
|
27 |
+
$this->getOrder()->getPayment()->getMethodInstance()->getCancelAmount($this->getOrder(), true)
|
28 |
+
);
|
29 |
+
|
30 |
+
$this->_updateButton('order_cancel', 'onclick', 'deleteConfirm(\''.$message.'\', \'' . $this->getCancelUrl() . '\')');
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Return true if the given button already exists.
|
37 |
+
*
|
38 |
+
* @param string $id
|
39 |
+
* @return boolean
|
40 |
+
*/
|
41 |
+
protected function _hasButton($id)
|
42 |
+
{
|
43 |
+
foreach ($this->_buttons as $level => $buttons) {
|
44 |
+
if (isset($buttons[$id])) {
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Return the button data from the given button id.
|
55 |
+
*
|
56 |
+
* @param string $id
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
protected function _getButtonData($id)
|
60 |
+
{
|
61 |
+
foreach ($this->_buttons as $level => $buttons) {
|
62 |
+
if (isset($buttons[$id])) {
|
63 |
+
return $buttons[$id];
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
return array();
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View/Tab/Action.php
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 05.05.2010 14:44:15
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Order Shipments grid
|
16 |
+
*
|
17 |
+
* @category Mage
|
18 |
+
* @package Mage_Adminhtml
|
19 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
20 |
+
*/
|
21 |
+
class Dotsource_Computop_Block_Adminhtml_Sales_Order_View_Tab_Action
|
22 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
23 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
24 |
+
{
|
25 |
+
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->setId('computop_action');
|
30 |
+
$this->setDefaultSort('created_at');
|
31 |
+
$this->setDefaultDir('desc');
|
32 |
+
$this->setUseAjax(true);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Prepares the collection to be sholwn in the computop action grid.
|
38 |
+
*
|
39 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
40 |
+
*/
|
41 |
+
protected function _prepareCollection()
|
42 |
+
{
|
43 |
+
/* @var $collection Dotsource_Computop_Model_Mysql4_Action_Collection */
|
44 |
+
$collection = Mage::getResourceModel('computop/action_collection');
|
45 |
+
$collection
|
46 |
+
->addFieldToFilter(
|
47 |
+
'transaction_id',
|
48 |
+
$this->_getComputopTransactionId()
|
49 |
+
);
|
50 |
+
|
51 |
+
$this->setCollection($collection);
|
52 |
+
return parent::_prepareCollection();
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Override for format the transaction number.
|
58 |
+
*
|
59 |
+
* @return unknown
|
60 |
+
*/
|
61 |
+
protected function _afterLoadCollection()
|
62 |
+
{
|
63 |
+
//Format the as transaction_id as transaction_code
|
64 |
+
foreach ($this->getCollection() as $item) {
|
65 |
+
$item->setData(
|
66 |
+
'transaction_code',
|
67 |
+
sprintf("%09s", $this->_getHelper()->getConverter()->formatAsTransactionCode(
|
68 |
+
$item->getData('transaction_id')
|
69 |
+
))
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
//Process parent action
|
74 |
+
parent::_afterLoadCollection();
|
75 |
+
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Prepares the backend grid that shows the computop transactions
|
82 |
+
* of the current order.
|
83 |
+
*
|
84 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
85 |
+
*/
|
86 |
+
protected function _prepareColumns()
|
87 |
+
{
|
88 |
+
$this->addColumn(
|
89 |
+
'transaction_code',
|
90 |
+
array(
|
91 |
+
'header' => Mage::helper('computop')->__('RefNr'),
|
92 |
+
'index' => 'transaction_code',
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
$this->addColumn(
|
97 |
+
'request_payid',
|
98 |
+
array(
|
99 |
+
'header' => Mage::helper('computop')->__('Request PayID'),
|
100 |
+
'index' => 'request_payid',
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
$this->addColumn(
|
105 |
+
'response_payid',
|
106 |
+
array(
|
107 |
+
'header' => Mage::helper('computop')->__('Response PayID'),
|
108 |
+
'index' => 'response_payid',
|
109 |
+
)
|
110 |
+
);
|
111 |
+
|
112 |
+
$this->addColumn(
|
113 |
+
'action',
|
114 |
+
array(
|
115 |
+
'header' => Mage::helper('computop')->__('Action'),
|
116 |
+
'index' => 'action',
|
117 |
+
)
|
118 |
+
);
|
119 |
+
|
120 |
+
$this->addColumn(
|
121 |
+
'created_at',
|
122 |
+
array(
|
123 |
+
'header' => Mage::helper('computop')->__('Created At'),
|
124 |
+
'index' => 'created_at',
|
125 |
+
'type' => 'datetime'
|
126 |
+
)
|
127 |
+
);
|
128 |
+
|
129 |
+
$this->addColumn(
|
130 |
+
'error_description',
|
131 |
+
array(
|
132 |
+
'header' => Mage::helper('computop')->__('Description'),
|
133 |
+
'index' => 'error_description',
|
134 |
+
'frame_callback' => array($this, 'decorateErrorDescription')
|
135 |
+
)
|
136 |
+
);
|
137 |
+
|
138 |
+
$this->addColumn(
|
139 |
+
'error_code',
|
140 |
+
array(
|
141 |
+
'header' => Mage::helper('computop')->__('Error Code'),
|
142 |
+
'index' => 'error_code',
|
143 |
+
'width' => '50px',
|
144 |
+
)
|
145 |
+
);
|
146 |
+
|
147 |
+
$this->addColumn(
|
148 |
+
'error',
|
149 |
+
array(
|
150 |
+
'header' => Mage::helper('computop')->__('Successful'),
|
151 |
+
'index' => 'error',
|
152 |
+
'type' => 'options',
|
153 |
+
'options' => array(
|
154 |
+
1 => $this->__('No'),
|
155 |
+
0 => $this->__('Yes')
|
156 |
+
),
|
157 |
+
'frame_callback' => array($this, 'decorateError')
|
158 |
+
)
|
159 |
+
);
|
160 |
+
|
161 |
+
return parent::_prepareColumns();
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Decorate error column values
|
167 |
+
*
|
168 |
+
* @param string $value
|
169 |
+
* @param Dotsource_Computop_Model_Action $row
|
170 |
+
* @param Mage_Adminhtml_Block_Widget_GridColumn $column
|
171 |
+
* @param boolean $isExport
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
public function decorateError($value, $row, $column, $isExport)
|
175 |
+
{
|
176 |
+
if (isset($this->_invalidatedTypes[$row->getId()])) {
|
177 |
+
$cell = '<span class="grid-severity-minor"><span>'.$this->__('Invalidated').'</span></span>';
|
178 |
+
} else {
|
179 |
+
if ($row->getError()) {
|
180 |
+
$cell = '<span class="grid-severity-critical"><span>'.$value.'</span></span>';
|
181 |
+
} else {
|
182 |
+
$cell = '<span class="grid-severity-notice"><span>'.$value.'</span></span>';
|
183 |
+
}
|
184 |
+
}
|
185 |
+
return $cell;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Truncates the content of the error_description column.
|
191 |
+
*
|
192 |
+
* @param string $value
|
193 |
+
* @param Dotsource_Computop_Model_Action $row
|
194 |
+
* @param Mage_Adminhtml_Block_Widget_GridColumn $column
|
195 |
+
* @param boolean $isExport
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
+
public function decorateErrorDescription($value, $row, $column, $isExport)
|
199 |
+
{
|
200 |
+
$noNeed = '';
|
201 |
+
return Mage::helper('core/string')->truncate($value, 255, '...', $noNeed, false);
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Retreives teh grid url that is used for resorting and searching
|
207 |
+
* in the action grid.
|
208 |
+
*
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function getGridUrl()
|
212 |
+
{
|
213 |
+
return $this->getUrl('computop/adminhtml_action/grid', array('_current' => true));
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Retrieves the label for the tab in the sales view.
|
219 |
+
*
|
220 |
+
* @return string
|
221 |
+
*/
|
222 |
+
public function getTabLabel()
|
223 |
+
{
|
224 |
+
return Mage::helper('computop')->__('Computop Transaction');
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Retrieves the title for the tab in the sales view.
|
230 |
+
*
|
231 |
+
* @return string
|
232 |
+
*/
|
233 |
+
public function getTabTitle()
|
234 |
+
{
|
235 |
+
return Mage::helper('computop')->__('Computop Transaction');
|
236 |
+
}
|
237 |
+
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Indicates if it's possilbe to show the tab.
|
241 |
+
*
|
242 |
+
* @return boolean
|
243 |
+
*/
|
244 |
+
public function canShowTab()
|
245 |
+
{
|
246 |
+
return true;
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Indicates if the tab should be hidden.
|
252 |
+
*
|
253 |
+
* @return boolean
|
254 |
+
*/
|
255 |
+
public function isHidden()
|
256 |
+
{
|
257 |
+
return false;
|
258 |
+
}
|
259 |
+
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Retrieves the transaction id of the computop transaction.
|
263 |
+
*
|
264 |
+
* @return integer
|
265 |
+
*/
|
266 |
+
protected function _getComputopTransactionId()
|
267 |
+
{
|
268 |
+
return (int)Mage::registry('current_order')->getPayment()->getComputopTransactionId();
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Return the computop helper.
|
274 |
+
*
|
275 |
+
* @return Dotsource_Computop_Helper_Data
|
276 |
+
*/
|
277 |
+
protected function _getHelper()
|
278 |
+
{
|
279 |
+
return Mage::helper('computop');
|
280 |
+
}
|
281 |
+
}
|
app/code/community/Dotsource/Computop/Block/Checkout/Iframe.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Checkout_Iframe
|
12 |
+
extends Mage_Core_Block_Template
|
13 |
+
{
|
14 |
+
|
15 |
+
}
|
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 18.05.2010 10:27:46
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Checkout_Paypal_Review
|
15 |
+
extends Mage_Core_Block_Template
|
16 |
+
{
|
17 |
+
/**
|
18 |
+
* Holds the current processed quote.
|
19 |
+
*
|
20 |
+
* @var Mage_Sales_Model_Quote
|
21 |
+
*/
|
22 |
+
protected $_quote;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Paypal action prefix.
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
protected $_paypalActionPrefix = 'paypal';
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Holds the address based on the shipping address.
|
33 |
+
*
|
34 |
+
* @var Mage_Sales_Model_Quote_Address
|
35 |
+
*/
|
36 |
+
protected $_address;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Holds the shippingsrates as array.
|
40 |
+
*
|
41 |
+
* @var array
|
42 |
+
*/
|
43 |
+
protected $_rates;
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Set quote for internal use.
|
48 |
+
*
|
49 |
+
* @param Mage_Sales_Model_Quote $quote
|
50 |
+
* @return Dotsource_Computop_Block_Checkout_Paypal_Review
|
51 |
+
*/
|
52 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
53 |
+
{
|
54 |
+
$this->_quote = $quote;
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Retrieves the billing address of the current quote.
|
61 |
+
*
|
62 |
+
* @return Mage_Sales_Model_Quote_Address|false
|
63 |
+
*/
|
64 |
+
public function getBillingAddress()
|
65 |
+
{
|
66 |
+
return $this->_quote->getBillingAddress();
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Retrieves the shipping address of the current quote.
|
72 |
+
*
|
73 |
+
* @return Mage_Sales_Model_Quote_Address|false
|
74 |
+
*/
|
75 |
+
public function getShippingAddress()
|
76 |
+
{
|
77 |
+
if ($this->_quote->getIsVirtual()) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
return $this->_quote->getShippingAddress();
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Return address base on quote shipping address
|
86 |
+
*
|
87 |
+
* @return Mage_Sales_Quote_Address
|
88 |
+
*/
|
89 |
+
public function getAddress()
|
90 |
+
{
|
91 |
+
if (null === $this->_address) {
|
92 |
+
$this->_address = $this->_quote->getShippingAddress();
|
93 |
+
}
|
94 |
+
return $this->_address;
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Retrieves the shipping rates.
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function getShippingRates()
|
104 |
+
{
|
105 |
+
if (null === $this->_rates) {
|
106 |
+
$this->_rates = (array)$this->getAddress()->getGroupedAllShippingRates();
|
107 |
+
}
|
108 |
+
return $this->_rates;
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Retrieves carrier name from config, base on carrier code
|
114 |
+
*
|
115 |
+
* @param $carrierCode string
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
public function getCarrierName($carrierCode)
|
119 |
+
{
|
120 |
+
if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) {
|
121 |
+
return $name;
|
122 |
+
}
|
123 |
+
return $carrierCode;
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
/**
|
128 |
+
* get shipping method
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
*/
|
132 |
+
public function getAddressShippingMethod()
|
133 |
+
{
|
134 |
+
return $this->getAddress()->getShippingMethod();
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Retrieves the formated shipping price.
|
140 |
+
*
|
141 |
+
* @param float $price
|
142 |
+
* @param boolean $flag
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function getShippingPrice($price, $flag)
|
147 |
+
{
|
148 |
+
return $this->formatPrice($this->helper('tax')->getShippingPrice($price, $flag, $this->getAddress()));
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Format price base on store convert price method.
|
154 |
+
*
|
155 |
+
* @param float $price
|
156 |
+
* @return string
|
157 |
+
*/
|
158 |
+
public function formatPrice($price)
|
159 |
+
{
|
160 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Indicates if the quote is virtual.
|
166 |
+
*
|
167 |
+
* @return boolean
|
168 |
+
*/
|
169 |
+
public function isVirtual()
|
170 |
+
{
|
171 |
+
return (bool)$this->_quote->getIsVirtual();
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Retrieves the url to the saveShippingMethodAction.
|
177 |
+
*
|
178 |
+
* @return string
|
179 |
+
*/
|
180 |
+
public function getSaveShippingMethodUrl()
|
181 |
+
{
|
182 |
+
return $this->getUrl('computop/callback_paypalexpress/saveShippingMethod');
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Retrieves the url to the saveShippingMethodAction.
|
188 |
+
*
|
189 |
+
* @return string
|
190 |
+
*/
|
191 |
+
public function getPlaceOrderUrl()
|
192 |
+
{
|
193 |
+
return $this->getUrl('computop/callback_paypalexpress/placeOrder');
|
194 |
+
}
|
195 |
+
}
|
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review/Details.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 18.05.2010 14:31:10
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Checkout_Paypal_Review_Details
|
15 |
+
extends Mage_Checkout_Block_Cart_Totals
|
16 |
+
{
|
17 |
+
protected $_address;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Return review shipping address
|
21 |
+
*
|
22 |
+
* @return Mage_Sales_Model_Order_Address
|
23 |
+
*/
|
24 |
+
public function getAddress()
|
25 |
+
{
|
26 |
+
if (empty($this->_address)) {
|
27 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
28 |
+
}
|
29 |
+
return $this->_address;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Return review quote totals
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function getTotals()
|
38 |
+
{
|
39 |
+
return $this->getQuote()->getTotals();
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Shortcut.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 17.05.2010 10:27:46
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Checkout_Paypal_Shortcut
|
15 |
+
extends Mage_Core_Block_Template
|
16 |
+
{
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retreives the paypal express chechout url.
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getCheckoutUrl()
|
25 |
+
{
|
26 |
+
return $this->getUrl('computop/callback_paypalexpress/start');
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Get checkout button image url.
|
32 |
+
*
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getImageUrl()
|
36 |
+
{
|
37 |
+
return Mage::getModel(
|
38 |
+
'paypal/express_checkout',
|
39 |
+
array(
|
40 |
+
'quote' => Mage::getSingleton('checkout/session')->getQuote(),
|
41 |
+
'config' => $this->_getMethod()->getConfig(),
|
42 |
+
)
|
43 |
+
)->getCheckoutShortcutImageUrl();
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Check whether method is available and render HTML.
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
protected function _toHtml()
|
53 |
+
{
|
54 |
+
if ($this->_getHelper()->isGlobalActive(true)) {
|
55 |
+
$method = $this->_getMethod();
|
56 |
+
if ($method && $method->getConfigData('active')) {
|
57 |
+
return parent::_toHtml();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return '';
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Retrieve payment method model.
|
67 |
+
*
|
68 |
+
* @return Dotsource_Computop_Model_Payment_Paypalexpress
|
69 |
+
*/
|
70 |
+
protected function _getMethod()
|
71 |
+
{
|
72 |
+
return Mage::getModel('computop/payment_paypalexpress');
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Return the computop helper.
|
78 |
+
*
|
79 |
+
* @return Dotsource_Computop_Helper_Data
|
80 |
+
*/
|
81 |
+
protected function _getHelper()
|
82 |
+
{
|
83 |
+
return Mage::helper('computop');
|
84 |
+
}
|
85 |
+
}
|
app/code/community/Dotsource/Computop/Block/Config/Form/Abstract.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Config_Form_Abstract
|
12 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::addColumn()
|
17 |
+
*
|
18 |
+
* @param string $name
|
19 |
+
* @param array $params
|
20 |
+
*/
|
21 |
+
public function addColumn($name, $params)
|
22 |
+
{
|
23 |
+
//check for multi html elements in one column
|
24 |
+
if ($this->_hasMultipleElementsInColumn($params)) {
|
25 |
+
$multipleElements = array();
|
26 |
+
|
27 |
+
foreach ($params as $columnPart) {
|
28 |
+
if (is_array($columnPart)) {
|
29 |
+
$this->addColumn($name, $columnPart);
|
30 |
+
$multipleElements[] = $this->_columns[$name];
|
31 |
+
unset($this->_columns[$name]);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
//Set the column attributes
|
36 |
+
foreach ($params as $key => $value) {
|
37 |
+
if ($this->_isColumnAttribute($key)) {
|
38 |
+
$multipleElements[$key] = $value;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
//Set the multiple columns
|
43 |
+
$this->_columns[$name] = $multipleElements;
|
44 |
+
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
//First do the parent stuff
|
50 |
+
parent::addColumn($name, $params);
|
51 |
+
|
52 |
+
$hasInputType = array_key_exists('input-type', $params) && !empty($params['input-type']);
|
53 |
+
$hasValidation = array_key_exists('validate', $params) && !empty($params['validate']);
|
54 |
+
$hasMultipleSelect = array_key_exists('multiple-select', $params) && is_bool($params['multiple-select']);
|
55 |
+
$hasValues = array_key_exists('values', $params)
|
56 |
+
&& !empty($params['values'])
|
57 |
+
&& is_array($params['values']);
|
58 |
+
//Content before or after the element
|
59 |
+
$hasContentBefor = array_key_exists('content-before-element', $params) && !empty($params['content-before-element']);
|
60 |
+
$hasContentAfter = array_key_exists('content-after-element', $params) && !empty($params['content-after-element']);
|
61 |
+
|
62 |
+
//Check for column title
|
63 |
+
$hasTitle = array_key_exists('title', $params) && !empty($params['title']);
|
64 |
+
|
65 |
+
//Check for an other name for the form element
|
66 |
+
$hasName = array_key_exists('name', $params) && !empty($params['name']);
|
67 |
+
|
68 |
+
//Join the old an the new settings
|
69 |
+
$this->_columns[$name] = array_merge($this->_columns[$name], array(
|
70 |
+
'input-type' => ($hasInputType)? $params['input-type'] : 'text',
|
71 |
+
'multiple-select' => ($hasMultipleSelect)? $params['multiple-select'] : false,
|
72 |
+
'values' => ($hasValues)? $params['values'] : array(),
|
73 |
+
'validate' => ($hasValidation)? $params['validate'] : '',
|
74 |
+
'content-before-element' => ($hasContentBefor)? $params['content-before-element'] : '',
|
75 |
+
'content-after-element' => ($hasContentAfter)? $params['content-after-element'] : '',
|
76 |
+
'title' => ($hasTitle)? $params['title'] : '',
|
77 |
+
'name' => ($hasName)? $params['name'] : '',
|
78 |
+
));
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @see Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::_renderCellTemplate()
|
84 |
+
*
|
85 |
+
* @param string $columnName
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
protected function _renderCellTemplate($columnName)
|
89 |
+
{
|
90 |
+
if (empty($this->_columns[$columnName])) {
|
91 |
+
throw new Exception('Wrong column name specified.');
|
92 |
+
}
|
93 |
+
|
94 |
+
$column = $this->_columns[$columnName];
|
95 |
+
|
96 |
+
//Check for multi html elements in one column
|
97 |
+
if ($this->_hasMultipleElementsInColumn($column)) {
|
98 |
+
$defaultColumn = $column;
|
99 |
+
$htmlCode = '';
|
100 |
+
|
101 |
+
foreach ($column as $columnPart) {
|
102 |
+
if (is_array($columnPart)) {
|
103 |
+
$this->_columns[$columnName] = $columnPart;
|
104 |
+
$htmlCode .= $this->_renderCellTemplate($columnName);
|
105 |
+
unset($this->_columns[$columnName]);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
//Set the multiple columns
|
110 |
+
$this->_columns[$columnName] = $defaultColumn;
|
111 |
+
return $htmlCode;
|
112 |
+
}
|
113 |
+
|
114 |
+
//Check for custom name
|
115 |
+
if (array_key_exists('name', $column) && !empty($column['name'])) {
|
116 |
+
$columnName = $column['name'];
|
117 |
+
}
|
118 |
+
|
119 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
120 |
+
|
121 |
+
if (array_key_exists('renderer', $column) && $column['renderer']) {
|
122 |
+
return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)
|
123 |
+
->toHtml();
|
124 |
+
}
|
125 |
+
|
126 |
+
//Build the input
|
127 |
+
$input = "";
|
128 |
+
|
129 |
+
if (array_key_exists('content-before-element', $column)) {
|
130 |
+
$input = $column['content-before-element'];
|
131 |
+
}
|
132 |
+
|
133 |
+
$input .= '<input name="'. $inputName .'" value="#{'. $columnName .'}"';
|
134 |
+
|
135 |
+
//Set type
|
136 |
+
if (array_key_exists('input-type', $column) && !empty($column['input-type'])) {
|
137 |
+
$input .= ' type="'. $column['input-type'] .'" ';
|
138 |
+
}
|
139 |
+
|
140 |
+
//Set size
|
141 |
+
if (array_key_exists('size', $column) && !empty($column['size'])) {
|
142 |
+
$input .= ' size="'. $column['size'] .'" ';
|
143 |
+
}
|
144 |
+
|
145 |
+
$hasClass = array_key_exists('class', $column) && !empty($column['class']);
|
146 |
+
$hasValidation = array_key_exists('validate', $column) && !empty($column['validate']);
|
147 |
+
|
148 |
+
//Start class tag
|
149 |
+
$input .= ' class="';
|
150 |
+
|
151 |
+
//Add the class
|
152 |
+
if ($hasClass) {
|
153 |
+
$input .= " {$column['class']} ";
|
154 |
+
} else {
|
155 |
+
//Add default
|
156 |
+
$input .= ' input-text ';
|
157 |
+
}
|
158 |
+
|
159 |
+
//Add validation
|
160 |
+
if ($hasValidation) {
|
161 |
+
$input .= " {$column['validate']} ";
|
162 |
+
}
|
163 |
+
|
164 |
+
//End class
|
165 |
+
$input .= '" ';
|
166 |
+
|
167 |
+
//Add style
|
168 |
+
if (array_key_exists('style', $column) && !empty($column['style'])) {
|
169 |
+
$input .= ' style="'. $column['style'] .'"';
|
170 |
+
}
|
171 |
+
|
172 |
+
//End input
|
173 |
+
$input .= ' />';
|
174 |
+
|
175 |
+
//Add the after html
|
176 |
+
if (array_key_exists('content-after-element', $column)) {
|
177 |
+
$input .= $column['content-after-element'];
|
178 |
+
}
|
179 |
+
|
180 |
+
//Return the input
|
181 |
+
return $input;
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Check if the given $column has multiple html elements.
|
187 |
+
*
|
188 |
+
* @param array $columnName
|
189 |
+
*/
|
190 |
+
protected function _hasMultipleElementsInColumn($column)
|
191 |
+
{
|
192 |
+
//check if we can work with the given data
|
193 |
+
if (!is_array($column) || empty($column)) {
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
//If all children an array we have multiple elements
|
198 |
+
foreach ($column as $key => $testColumn) {
|
199 |
+
if ((!$this->_isColumnAttribute($key) && !is_array($testColumn))) {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
return true;
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Check if the given key is an column attribute.
|
210 |
+
*
|
211 |
+
* @param string $key
|
212 |
+
* @return boolean
|
213 |
+
*/
|
214 |
+
protected function _isColumnAttribute($key) {
|
215 |
+
$attributes = array('label', 'title');
|
216 |
+
|
217 |
+
return in_array($key, $attributes);
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Return all elements from the form.
|
223 |
+
*
|
224 |
+
* @param array $columns
|
225 |
+
* @param array $collectedElements
|
226 |
+
* @return array
|
227 |
+
*/
|
228 |
+
public function getAllFormElements(array $columns = array())
|
229 |
+
{
|
230 |
+
//Element for collecting all html elements
|
231 |
+
if (empty($columns)) {
|
232 |
+
$columns = $this->_columns;
|
233 |
+
}
|
234 |
+
|
235 |
+
$collectedElements = array();
|
236 |
+
|
237 |
+
//Iterate over all columns
|
238 |
+
foreach ($columns as $column) {
|
239 |
+
//Check for multi elements in column
|
240 |
+
if ($this->_hasMultipleElementsInColumn($column)) {
|
241 |
+
foreach ($column as $columnPart) {
|
242 |
+
if (is_array($columnPart) && !empty($columnPart)) {
|
243 |
+
$collectedElements = array_merge($collectedElements, $this->getAllFormElements(array($columnPart)));
|
244 |
+
}
|
245 |
+
}
|
246 |
+
} else {
|
247 |
+
//Normal element
|
248 |
+
$collectedElements[] = $column;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
return $collectedElements;
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Return the computop helper
|
258 |
+
*
|
259 |
+
* @return Dotsource_Computop_Helper_Data
|
260 |
+
*/
|
261 |
+
protected function _getHelper()
|
262 |
+
{
|
263 |
+
return Mage::helper('computop');
|
264 |
+
}
|
265 |
+
}
|
app/code/community/Dotsource/Computop/Block/Config/Form/Merchant.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Config_Form_Merchant
|
12 |
+
extends Dotsource_Computop_Block_Config_Form_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
//Country for option key mapping
|
18 |
+
$this->addColumn('currency', array(
|
19 |
+
'label' => $this->_getHelper()->__('Currency'),
|
20 |
+
'title' => $this->_getHelper()->__('Currency'),
|
21 |
+
'style' => 'width:160px',
|
22 |
+
'renderer' => new Dotsource_Computop_Block_Config_Form_Renderer_Select(),
|
23 |
+
'values' => Mage::getSingleton('adminhtml/system_config_source_currency')->toOptionArray(true),
|
24 |
+
'class' => 'currency',
|
25 |
+
'validate' => 'validate-select',
|
26 |
+
));
|
27 |
+
|
28 |
+
//Merchant id
|
29 |
+
$this->addColumn('id', array(
|
30 |
+
'label' => $this->_getHelper()->__('Merchant ID'),
|
31 |
+
'title' => $this->_getHelper()->__('Merchant ID'),
|
32 |
+
'style' => 'width:100px',
|
33 |
+
'validate' => 'required-entry',
|
34 |
+
));
|
35 |
+
|
36 |
+
//Merchant password
|
37 |
+
$this->addColumn('password', array(
|
38 |
+
'label' => $this->_getHelper()->__('Merchant Password'),
|
39 |
+
'title' => $this->_getHelper()->__('Merchant Encryption Password'),
|
40 |
+
array(
|
41 |
+
'name' => 'password',
|
42 |
+
'style' => 'width:120px',
|
43 |
+
'input-type' => 'password',
|
44 |
+
'validate' => 'required-entry',
|
45 |
+
),
|
46 |
+
array(
|
47 |
+
'name' => 'original_password',
|
48 |
+
'input-type' => 'hidden',
|
49 |
+
))
|
50 |
+
);
|
51 |
+
|
52 |
+
//Merchant hmac
|
53 |
+
$this->addColumn('hmac', array(
|
54 |
+
'label' => $this->_getHelper()->__('Merchant Hmac'),
|
55 |
+
'title' => $this->_getHelper()->__('Merchant Hmac'),
|
56 |
+
array(
|
57 |
+
'name' => 'hmac',
|
58 |
+
'style' => 'width:120px',
|
59 |
+
'input-type' => 'password',
|
60 |
+
'validate' => 'required-entry',
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'name' => 'original_hmac',
|
64 |
+
'input-type' => 'hidden',
|
65 |
+
))
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->_addAfter = false;
|
69 |
+
$this->_addButtonLabel = $this->_getHelper()->__('Add New Merchant');
|
70 |
+
|
71 |
+
parent::__construct();
|
72 |
+
|
73 |
+
//Set the right template
|
74 |
+
$this->setTemplate('computop/config/form/field/form.phtml');
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Dotsource/Computop/Block/Config/Form/Renderer/Select.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Config_Form_Renderer_Select
|
12 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Core_Block_Template::_toHtml()
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
protected function _toHtml()
|
21 |
+
{
|
22 |
+
$select = '';
|
23 |
+
$column = $this->getColumn();
|
24 |
+
|
25 |
+
//check for content before html element
|
26 |
+
if (array_key_exists('content-before-element', $column) && !empty($column['content-before-element'])) {
|
27 |
+
$select .= $column['content-before-element'];
|
28 |
+
}
|
29 |
+
|
30 |
+
//Is multiple select?
|
31 |
+
if ($this->isMultipleSelect()) {
|
32 |
+
$select .= '<select name="'. $this->getInputName() .'[]" ';
|
33 |
+
} else {
|
34 |
+
$select .= '<select name="'. $this->getInputName() .'" ';
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
//Multiple select?
|
39 |
+
if ($this->isMultipleSelect()) {
|
40 |
+
$select .= ' multiple="multiple"';
|
41 |
+
}
|
42 |
+
|
43 |
+
//Set size
|
44 |
+
if (array_key_exists('size', $column) && !empty($column['size'])) {
|
45 |
+
$select .= ' size="'. $column['size'] .'" ';
|
46 |
+
}
|
47 |
+
|
48 |
+
$hasClass = array_key_exists('class', $column) && !empty($column['class']);
|
49 |
+
$hasValidation = array_key_exists('validate', $column) && !empty($column['validate']);
|
50 |
+
|
51 |
+
//Start class tag
|
52 |
+
$select .= ' class="';
|
53 |
+
|
54 |
+
//Add the class
|
55 |
+
if ($hasClass) {
|
56 |
+
$select .= " {$column['class']} ";
|
57 |
+
} else {
|
58 |
+
//Add default
|
59 |
+
$select .= ' input-text ';
|
60 |
+
}
|
61 |
+
|
62 |
+
//Add validation
|
63 |
+
if ($hasValidation) {
|
64 |
+
$select .= " {$column['validate']} ";
|
65 |
+
}
|
66 |
+
|
67 |
+
//End class
|
68 |
+
$select .= '" ';
|
69 |
+
|
70 |
+
//Add style
|
71 |
+
if (array_key_exists('style', $column) && !empty($column['style'])) {
|
72 |
+
$select .= ' style="'. $column['style'] .'"';
|
73 |
+
}
|
74 |
+
|
75 |
+
//End the select
|
76 |
+
$select .= '>';
|
77 |
+
|
78 |
+
//Build the options
|
79 |
+
if (array_key_exists('values', $column)
|
80 |
+
&& !empty($column['values'])
|
81 |
+
&& is_array($column['values'])
|
82 |
+
) {
|
83 |
+
foreach ($column['values'] as $country) {
|
84 |
+
$select .= '<option value="'.$country['value'].'">'.$country['label'].'</option>';
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$select .= '</select>';
|
89 |
+
|
90 |
+
if (array_key_exists('content-after-element', $column) && !empty($column['content-after-element'])) {
|
91 |
+
$select .= $column['content-after-element'];
|
92 |
+
}
|
93 |
+
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Return true is the select is an multiple select box.
|
100 |
+
*
|
101 |
+
* @return boolean
|
102 |
+
*/
|
103 |
+
public function isMultipleSelect()
|
104 |
+
{
|
105 |
+
//Get the column
|
106 |
+
$column = $this->getColumn();
|
107 |
+
|
108 |
+
//Get the result
|
109 |
+
return array_key_exists('multiple-select', $column)
|
110 |
+
&& is_bool($column['multiple-select'])
|
111 |
+
&& $column['multiple-select'];
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Check if the select box has a class.
|
117 |
+
*
|
118 |
+
* @return boolean
|
119 |
+
*/
|
120 |
+
public function hasClass()
|
121 |
+
{
|
122 |
+
//Get the column
|
123 |
+
$column = $this->getColumn();
|
124 |
+
|
125 |
+
//Build the result
|
126 |
+
return array_key_exists('class', $column)
|
127 |
+
&& !empty($column['class']);
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Return javascript code which call when a new element add to the form.
|
133 |
+
*
|
134 |
+
* @return string
|
135 |
+
*/
|
136 |
+
public function getCodeForAddActionFormManipulation()
|
137 |
+
{
|
138 |
+
$column = $this->getColumn();
|
139 |
+
$columnName = $this->getColumnName();
|
140 |
+
$js = '';
|
141 |
+
|
142 |
+
if ($this->isMultipleSelect()) {
|
143 |
+
$js .= "var tmpObject = arrayToObject(templateData.$columnName);";
|
144 |
+
}
|
145 |
+
|
146 |
+
//Select the operator
|
147 |
+
$js .= "$(templateData._id).select('.{$column['class']} option').each(function(option) {";
|
148 |
+
|
149 |
+
//Build the
|
150 |
+
if ($this->isMultipleSelect()) {
|
151 |
+
$js .= "if (tmpObject[option.value] != undefined && tmpObject[option.value]) {";
|
152 |
+
$js .= "option.selected = true;";
|
153 |
+
$js .= "}";
|
154 |
+
} else {
|
155 |
+
$js .= "if (option.value == templateData.$columnName) {";
|
156 |
+
$js .= "option.selected = true;";
|
157 |
+
$js .= "return;";
|
158 |
+
$js .= "}";
|
159 |
+
}
|
160 |
+
|
161 |
+
$js .= "});";
|
162 |
+
|
163 |
+
//Return the javascript code
|
164 |
+
return $js;
|
165 |
+
}
|
166 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Abstract.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 26.05.2010 14:48:25
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
abstract class Dotsource_Computop_Block_Form_Abstract
|
15 |
+
extends Mage_Payment_Block_Form
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Holds the URL of the payment logo.
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_logoUrl;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Holds the alt attribute of the payment logo.
|
28 |
+
*
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $_logoAlt;
|
32 |
+
|
33 |
+
protected function _construct()
|
34 |
+
{
|
35 |
+
parent::_construct();
|
36 |
+
|
37 |
+
//Add the logo to the payment method
|
38 |
+
$this->setMethodLabelAfterHtml($this->_getLogoHtml());
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Retreives the html of the logo.
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
protected function _getLogoHtml()
|
48 |
+
{
|
49 |
+
if (!$this->_getLogoUrl() || !Mage::helper('computop')->canShowPaymentLogo()) {
|
50 |
+
return '';
|
51 |
+
}
|
52 |
+
if ( is_array($this->_getLogoUrl()) ) {
|
53 |
+
$logoHtml = '';
|
54 |
+
foreach ( $this->_getLogoUrl() as $logoAlt => $logoUrl ) {
|
55 |
+
$logoHtml .= sprintf(
|
56 |
+
'<img src="%s" alt="%s" class="v-middle" />',
|
57 |
+
$logoUrl,
|
58 |
+
$logoAlt
|
59 |
+
);
|
60 |
+
}
|
61 |
+
if ( $logoHtml != '' ) {
|
62 |
+
return $logoHtml;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return sprintf(
|
66 |
+
'<img src="%s" alt="%s" class="v-middle" />',
|
67 |
+
$this->_getLogoUrl(),
|
68 |
+
$this->_getLogoAlt()
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Retrieves the alt attribute for the logo of the payment method.
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
protected function _getLogoAlt()
|
79 |
+
{
|
80 |
+
return $this->_logoAlt;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Retrieves the url to the logo of the payment method.
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
protected function _getLogoUrl()
|
90 |
+
{
|
91 |
+
return $this->_logoUrl;
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Cc.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Form_Cc
|
12 |
+
extends Dotsource_Computop_Block_Form_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
const DANKORT_AVAIABLE_COUNTRY = 'DK';
|
16 |
+
|
17 |
+
const CARTE_BLEUE_NATIONALE_AVAIABLE_COUNTRY = 'FR';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* add logos
|
21 |
+
* set template
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
$allLogos = Mage::getModel('computop/system_config_source_logos')->toOptionArray();
|
27 |
+
$availableLogos = explode(',', Mage::helper('computop/config')->getAvailableCcLogos());
|
28 |
+
foreach ( $allLogos as $logo ) {
|
29 |
+
if ( !isset($logo['value']) || !isset($logo['label']) || !isset($logo['file']) ) continue;
|
30 |
+
if ( in_array($logo['value'], $availableLogos) && $this->_isLogoAvailable($logo) )
|
31 |
+
$this->_logoUrl[$logo['label']] =
|
32 |
+
$this->getSkinUrl('images/computop/computop_cc/' . $logo['file']);
|
33 |
+
}
|
34 |
+
parent::_construct();
|
35 |
+
$this->setTemplate('computop/form/cc.phtml');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieve payment configuration object.
|
40 |
+
*
|
41 |
+
* @return Mage_Payment_Model_Config
|
42 |
+
*/
|
43 |
+
protected function _getConfig()
|
44 |
+
{
|
45 |
+
return Mage::getSingleton('payment/config');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Retrieve availables credit card types.
|
50 |
+
*
|
51 |
+
* @return array
|
52 |
+
*/
|
53 |
+
public function getCcAvailableTypes()
|
54 |
+
{
|
55 |
+
$types = $this->_getConfig()->getCcTypes();
|
56 |
+
if ($method = $this->getMethod()) {
|
57 |
+
$availableTypes = $method->getConfigData('cctypes');
|
58 |
+
if ($availableTypes) {
|
59 |
+
$availableTypes = explode(',', $availableTypes);
|
60 |
+
foreach ($types as $code=>$name) {
|
61 |
+
if (!in_array($code, $availableTypes)) {
|
62 |
+
unset($types[$code]);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return $types;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Retrieve credit card expire months.
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function getCcMonths()
|
76 |
+
{
|
77 |
+
$months = $this->getData('cc_months');
|
78 |
+
if (is_null($months)) {
|
79 |
+
$months[0] = $this->__('Month');
|
80 |
+
$months = array_merge($months, $this->_getConfig()->getMonths());
|
81 |
+
$this->setData('cc_months', $months);
|
82 |
+
}
|
83 |
+
return $months;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Retrieve credit card expire years.
|
88 |
+
*
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
public function getCcYears()
|
92 |
+
{
|
93 |
+
$years = $this->getData('cc_years');
|
94 |
+
if (is_null($years)) {
|
95 |
+
$years = $this->_getConfig()->getYears();
|
96 |
+
$years = array(0 => $this->__('Year')) + $years;
|
97 |
+
$this->setData('cc_years', $years);
|
98 |
+
}
|
99 |
+
return $years;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Retrive has verification configuration.
|
104 |
+
*
|
105 |
+
* @return boolean
|
106 |
+
*/
|
107 |
+
public function hasVerification()
|
108 |
+
{
|
109 |
+
if ($this->getMethod()) {
|
110 |
+
$configData = $this->getMethod()->getConfigData('useccv');
|
111 |
+
if (null === $configData) {
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
return (bool)$configData;
|
115 |
+
}
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Whether switch/solo card type available.
|
121 |
+
*
|
122 |
+
* @return boolean
|
123 |
+
*/
|
124 |
+
public function hasSsCardType()
|
125 |
+
{
|
126 |
+
$availableTypes =$this->getMethod()->getConfigData('cctypes');
|
127 |
+
if ($availableTypes && in_array('SS', explode(',', $availableTypes))) {
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Solo/switch card start year.
|
135 |
+
*
|
136 |
+
* @return array
|
137 |
+
*/
|
138 |
+
public function getSsStartYears()
|
139 |
+
{
|
140 |
+
$years = array();
|
141 |
+
$first = date('Y');
|
142 |
+
|
143 |
+
for ($index = 5; $index >= 0; $index--) {
|
144 |
+
$year = $first - $index;
|
145 |
+
$years[$year] = $year;
|
146 |
+
}
|
147 |
+
$years = array(0 => $this->__('Year')) + $years;
|
148 |
+
return $years;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* returns true if logo is available
|
153 |
+
*
|
154 |
+
*/
|
155 |
+
protected function _isLogoAvailable($logo)
|
156 |
+
{
|
157 |
+
if ( isset($logo['value']) && $logo['value'] == 'dankort' ) {
|
158 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
159 |
+
if ( !$quote ) return false;
|
160 |
+
$address = $quote->getBillingAddress();
|
161 |
+
if ( !$address ) return false;
|
162 |
+
if ( $address->getCountryId() !== self::DANKORT_AVAIABLE_COUNTRY ) {
|
163 |
+
return false;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
if ( isset($logo['value']) && $logo['value'] == 'carte_bleue_nationale' ) {
|
167 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
168 |
+
if ( !$quote ) return false;
|
169 |
+
$address = $quote->getBillingAddress();
|
170 |
+
if ( !$address ) return false;
|
171 |
+
if ( $address->getCountryId() !== self::CARTE_BLEUE_NATIONALE_AVAIABLE_COUNTRY ) {
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
return true;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Render block HTML.
|
180 |
+
*
|
181 |
+
* @return string
|
182 |
+
*/
|
183 |
+
protected function _toHtml()
|
184 |
+
{
|
185 |
+
Mage::dispatchEvent(
|
186 |
+
'payment_form_block_to_html_before',
|
187 |
+
array(
|
188 |
+
'block' => $this
|
189 |
+
)
|
190 |
+
);
|
191 |
+
return parent::_toHtml();
|
192 |
+
}
|
193 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Directpay.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Form_Directpay
|
12 |
+
extends Dotsource_Computop_Block_Form_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
|
19 |
+
//Change the template
|
20 |
+
$this->setTemplate('computop/form/directpay.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Retrieves the url to the logo of the payment method.
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _getLogoUrl()
|
30 |
+
{
|
31 |
+
return $this->getSkinUrl('images/computop/computop_directpay.gif');
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Retrieves the alt attribute for the logo of the payment method.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
protected function _getLogoAlt()
|
41 |
+
{
|
42 |
+
return Mage::helper('computop')->__('Directpay Logo');
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Eft.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Form_Eft
|
12 |
+
extends Dotsource_Computop_Block_Form_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_logoUrl = $this->getSkinUrl('images/computop/computop_eft.gif');
|
18 |
+
$this->_logoAlt = Mage::helper('computop')->__('EFT Logo');
|
19 |
+
parent::_construct();
|
20 |
+
$this->setTemplate('computop/form/eft.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return the payment information field from the last order with the
|
26 |
+
* current payment method.
|
27 |
+
*
|
28 |
+
* @param string $field
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
protected function _getLastPaymentInformation($field, $escapeHtml = true)
|
32 |
+
{
|
33 |
+
//Get the last payment information from the order with the payment method
|
34 |
+
$lastPaymentInformation = $this->_getHelper()
|
35 |
+
->getPaymentHelper()
|
36 |
+
->getLastEftPaymentinformation($this->getMethodCode());
|
37 |
+
|
38 |
+
//Check if we have the data
|
39 |
+
if ($lastPaymentInformation->hasData() && $lastPaymentInformation->hasData($field)) {
|
40 |
+
//Get the data
|
41 |
+
$data = $lastPaymentInformation->getData($field);
|
42 |
+
|
43 |
+
//Return the data, if available
|
44 |
+
if (!empty($data)) {
|
45 |
+
if ($escapeHtml) {
|
46 |
+
$data = $this->escapeHtml($data);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $data;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return "";
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Return the eft owner from the info instance.
|
59 |
+
* If the info instance has no data and pre-fill is active
|
60 |
+
* the last payment information will be used.
|
61 |
+
*
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getEftOwner()
|
65 |
+
{
|
66 |
+
//Check first the payment info object
|
67 |
+
$eftOwner = $this->getInfoData('eft_owner');
|
68 |
+
|
69 |
+
//Check if we should pre-fill the information
|
70 |
+
if (empty($eftOwner)
|
71 |
+
&& 1 == $this->getMethod()->getConfigData('prefill_paymentinformation')
|
72 |
+
) {
|
73 |
+
//Return the last payment information
|
74 |
+
return $this->_getLastPaymentInformation('eft_owner');
|
75 |
+
}
|
76 |
+
|
77 |
+
return $eftOwner;
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Return the eft ban (bank account number).
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function getEftBan()
|
87 |
+
{
|
88 |
+
//Get the encrypted ban
|
89 |
+
$ban = $this->getMethod()->getInfoInstance()->getData('eft_ban_enc');
|
90 |
+
|
91 |
+
//Check if we should pre-fill the information
|
92 |
+
if (empty($ban)
|
93 |
+
&& 1 == $this->getMethod()->getConfigData('prefill_paymentinformation')
|
94 |
+
) {
|
95 |
+
//Return the last payment information
|
96 |
+
$ban = $this->_getLastPaymentInformation('eft_ban_enc', false);
|
97 |
+
}
|
98 |
+
|
99 |
+
//Decrypt the ban
|
100 |
+
if (!empty($ban)) {
|
101 |
+
$ban = $this->getMethod()->getInfoInstance()->decrypt($ban);
|
102 |
+
|
103 |
+
if (!empty($ban)) {
|
104 |
+
return $this->escapeHtml($ban);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
return "";
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Return the eft bcn (bank code number).
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function getEftBcn()
|
118 |
+
{
|
119 |
+
//Get the data from the info instance
|
120 |
+
$eftBcn = $this->getInfoData('eft_bcn');
|
121 |
+
|
122 |
+
//Check if we should pre-fill the information
|
123 |
+
if (empty($eftBcn)
|
124 |
+
&& 1 == $this->getMethod()->getConfigData('prefill_paymentinformation')
|
125 |
+
) {
|
126 |
+
//Return the last payment information
|
127 |
+
return $this->_getLastPaymentInformation('eft_bcn');
|
128 |
+
}
|
129 |
+
|
130 |
+
return $eftBcn;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Return the computop helper object.
|
136 |
+
*
|
137 |
+
* @return Dotsource_Computop_Helper_Data
|
138 |
+
*/
|
139 |
+
protected function _getHelper()
|
140 |
+
{
|
141 |
+
return Mage::helper('computop');
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Giropay.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Form_Giropay
|
12 |
+
extends Dotsource_Computop_Block_Form_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
|
19 |
+
//Change the template
|
20 |
+
$this->setTemplate('computop/form/giropay.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Retrieves the url to the logo of the payment method.
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _getLogoUrl()
|
30 |
+
{
|
31 |
+
return $this->getSkinUrl('images/computop/computop_giropay.gif');
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Retrieves the alt attribute for the logo of the payment method.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
protected function _getLogoAlt()
|
41 |
+
{
|
42 |
+
return Mage::helper('computop')->__('Giropay Logo');
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Ideal.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Form_Ideal
|
12 |
+
extends Dotsource_Computop_Block_Form_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_logoUrl = $this->getSkinUrl('images/computop/computop_ideal.gif');
|
18 |
+
$this->_logoAlt = Mage::helper('computop')->__('iDeal Logo');
|
19 |
+
parent::_construct();
|
20 |
+
|
21 |
+
//Change the template
|
22 |
+
$this->setTemplate('computop/form/ideal.phtml');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Mpass.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 30.04.2010 16:42:39
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Form_Mpass
|
15 |
+
extends Dotsource_Computop_Block_Form_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_logoUrl = $this->getSkinUrl('images/computop/computop_mpass.gif');
|
21 |
+
$this->_logoAlt = Mage::helper('computop')->__('Mpass Logo');
|
22 |
+
parent::_construct();
|
23 |
+
$this->setTemplate('computop/form/mpass.phtml');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Paypalexpress.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 14:12:50
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Form_Paypalexpress
|
15 |
+
extends Dotsource_Computop_Block_Form_Paypalstandard
|
16 |
+
{
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Retrieve payment method model
|
21 |
+
*
|
22 |
+
* @return Dotsource_Computop_Model_Payment_Paypalexpress
|
23 |
+
*/
|
24 |
+
public function getMethod()
|
25 |
+
{
|
26 |
+
return Mage::getModel('computop/payment_paypalexpress');
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Retrieves the configuration helper for the paypal.
|
32 |
+
*
|
33 |
+
* @return Dotsource_Computop_Helper_Paypal_Config
|
34 |
+
*/
|
35 |
+
protected function _getPaypalExpressConfig()
|
36 |
+
{
|
37 |
+
return Mage::helper('computop/paypal_config');
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Dotsource/Computop/Block/Form/Paypalstandard.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 14:12:50
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Form_Paypalstandard
|
15 |
+
extends Dotsource_Computop_Block_Form_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_logoUrl = $this->getSkinUrl('images/computop/computop_paypal.gif');
|
21 |
+
$this->_logoAlt = Mage::helper('computop')->__('PayPal Logo');
|
22 |
+
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('computop/form/paypalstandard.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Retrieve payment method model
|
30 |
+
*
|
31 |
+
* @return Dotsource_Computop_Model_Payment_Paypalstandard
|
32 |
+
*/
|
33 |
+
public function getMethod()
|
34 |
+
{
|
35 |
+
return Mage::getModel('computop/payment_paypalstandard');
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Retrieves the configuration helper for the paypal.
|
41 |
+
*
|
42 |
+
* @return Dotsource_Computop_Helper_Paypal_Config
|
43 |
+
*/
|
44 |
+
protected function _getPaypalConfig()
|
45 |
+
{
|
46 |
+
return Mage::helper('computop/paypal_config');
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Cc.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Cc
|
12 |
+
extends Mage_Payment_Block_Info_Cc
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info::_construct()
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
|
22 |
+
//Change the template
|
23 |
+
$this->setTemplate('computop/info/callback.phtml');
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @see Mage_Payment_Block_Info_Cc::getCcTypeName()
|
29 |
+
*
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getCcTypeName()
|
33 |
+
{
|
34 |
+
//Check for magento type
|
35 |
+
$ccType = $this->getInfo()->getCcType();
|
36 |
+
if ($this->_getHelper()->getConverter()->isMagentoCcType($ccType)) {
|
37 |
+
return parent::getCcTypeName();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $ccType;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Prepare credit card related payment info
|
46 |
+
*
|
47 |
+
* @param Varien_Object|array $transport
|
48 |
+
* @return Varien_Object
|
49 |
+
*/
|
50 |
+
protected function _prepareSpecificInformation($transport = null)
|
51 |
+
{
|
52 |
+
if (null !== $this->_paymentSpecificInformation) {
|
53 |
+
return $this->_paymentSpecificInformation;
|
54 |
+
}
|
55 |
+
|
56 |
+
//Create a new transport (varien object) object.
|
57 |
+
$transport = Mage_Payment_Block_Info::_prepareSpecificInformation($transport);
|
58 |
+
$data = array();
|
59 |
+
$pseudo = $this->getInfo()->getCcNumberEnc();
|
60 |
+
|
61 |
+
if (!empty($pseudo)) {
|
62 |
+
//Cc type
|
63 |
+
$data[Mage::helper('payment')->__('Credit Card Type')] = $this->getCcTypeName();
|
64 |
+
|
65 |
+
//Set the pseudo cc number
|
66 |
+
if (!$this->getIsSecureMode()) {
|
67 |
+
$ccNumber = Mage::helper('core')->getEncryptor()->decrypt(
|
68 |
+
$this->getInfo()->getCcNumberEnc()
|
69 |
+
);
|
70 |
+
|
71 |
+
$data[$this->_getHelper()->__('Pseudo Credit Card Nr.')] = $ccNumber;
|
72 |
+
} else {
|
73 |
+
$data[$this->_getHelper()->__('Credit Card Nr.')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Return the computop helper.
|
83 |
+
*
|
84 |
+
* @return Dotsource_Computop_Helper_Data
|
85 |
+
*/
|
86 |
+
protected function _getHelper()
|
87 |
+
{
|
88 |
+
return Mage::helper('computop');
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Directpay.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Directpay
|
12 |
+
extends Dotsource_Computop_Block_Info_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info::_construct()
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
|
22 |
+
//Change the template
|
23 |
+
$this->setTemplate('computop/info/callback.phtml');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Eft.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Eft
|
12 |
+
extends Mage_Payment_Block_Info
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info_Cc::_prepareSpecificInformation()
|
17 |
+
*
|
18 |
+
* @param Varien_Object|array $transport
|
19 |
+
* @return Varien_Object
|
20 |
+
*/
|
21 |
+
protected function _prepareSpecificInformation($transport = null)
|
22 |
+
{
|
23 |
+
if (null !== $this->_paymentSpecificInformation) {
|
24 |
+
return $this->_paymentSpecificInformation;
|
25 |
+
}
|
26 |
+
|
27 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
28 |
+
|
29 |
+
$data[Mage::helper('payment')->__('Account holder')] = $this->getInfo()->getEftOwner();
|
30 |
+
$data[Mage::helper('payment')->__('Bank account number')] = sprintf('xxxx-%s', $this->getInfo()->getEftBan4());
|
31 |
+
$data[Mage::helper('payment')->__('Bank code number')] = $this->getInfo()->getEftBcn();
|
32 |
+
|
33 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Giropay.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Giropay
|
12 |
+
extends Dotsource_Computop_Block_Info_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info::_construct()
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
|
22 |
+
//Change the template
|
23 |
+
$this->setTemplate('computop/info/callback.phtml');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Ideal.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Ideal
|
12 |
+
extends Mage_Payment_Block_Info
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info::_construct()
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
|
22 |
+
//Change the template
|
23 |
+
$this->setTemplate('computop/info/callback.phtml');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Mpass.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 30.04.2010 16:44:35
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Block_Info_Mpass
|
15 |
+
extends Mage_Payment_Block_Info
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Mage_Payment_Block_Info::_construct()
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
|
25 |
+
//Change the template
|
26 |
+
$this->setTemplate('computop/info/callback.phtml');
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Dotsource/Computop/Block/Info/Paypalstandard.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Block_Info_Paypalstandard
|
12 |
+
extends Mage_Payment_Block_Info
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Mage_Payment_Block_Info::_construct()
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
|
22 |
+
//Change the template
|
23 |
+
$this->setTemplate('computop/info/callback.phtml');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Dotsource/Computop/Block/Widget/Grid/Column/Renderer/Zerofill.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Block_Widget_Grid_Column_Renderer_Zerofill
|
11 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Format the given value as an computop transaction code (RefNr).
|
16 |
+
*
|
17 |
+
* @param Varien_Object $row
|
18 |
+
*/
|
19 |
+
protected function _getValue(Varien_Object $row)
|
20 |
+
{
|
21 |
+
$value = parent::_getValue($row);
|
22 |
+
|
23 |
+
if (null !== $value) {
|
24 |
+
return $this->_getHelper()->getConverter()->formatAsTransactionCode($value);
|
25 |
+
}
|
26 |
+
|
27 |
+
return $this->getColumn()->getDefault();
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Return the computop helper.
|
33 |
+
*
|
34 |
+
* @return Dotsource_Computop_Helper_Data
|
35 |
+
*/
|
36 |
+
protected function _getHelper()
|
37 |
+
{
|
38 |
+
return Mage::helper('computop');
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Dotsource/Computop/Controller/Callback.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
abstract class Dotsource_Computop_Controller_Callback
|
12 |
+
extends Mage_Core_Controller_Front_Action
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Holds the key for the session params */
|
16 |
+
const SESSION_KEY_PARAM = 'ctmsid';
|
17 |
+
|
18 |
+
|
19 |
+
/** Holds if the redirect is an javascript redirect */
|
20 |
+
protected $_javaScriptRedirect = false;
|
21 |
+
|
22 |
+
/** Holds if we should use the custom session id */
|
23 |
+
protected $_usePreloadCustomSession = true;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Override the pre dispatch method for load a custom session.
|
28 |
+
*
|
29 |
+
* @return Dotsource_Computop_Controller_Callback
|
30 |
+
*/
|
31 |
+
public function preDispatch()
|
32 |
+
{
|
33 |
+
//Global session processing active?
|
34 |
+
if ($this->_usePreloadCustomSession) {
|
35 |
+
//Get a custom session id
|
36 |
+
$sessionId = $this->getRequest()->getParam(self::SESSION_KEY_PARAM, null);
|
37 |
+
|
38 |
+
//Custom session id is available?
|
39 |
+
if (null !== $sessionId) {
|
40 |
+
//Set a pre session id this session id can rewrite with the get session parameter
|
41 |
+
session_id($sessionId);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
//Now do all the parent stuff
|
46 |
+
return parent::preDispatch();
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Set the redirect to the success page.
|
52 |
+
*/
|
53 |
+
protected function _successRedirect()
|
54 |
+
{
|
55 |
+
$this->_redirect('checkout/onepage/success');
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Set the redirect to the back page.
|
61 |
+
*/
|
62 |
+
protected function _backRedirect()
|
63 |
+
{
|
64 |
+
$this->_redirect('checkout/');
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Set the redirect to the failure page.
|
70 |
+
*/
|
71 |
+
protected function _failureRedirect()
|
72 |
+
{
|
73 |
+
$this->_redirect('checkout/cart/');
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Send a 404 http status code.
|
79 |
+
*/
|
80 |
+
protected function _notifyActionError()
|
81 |
+
{
|
82 |
+
$this->getResponse()->setHeader('HTTP/1.1', '404 Not Found');
|
83 |
+
$this->getResponse()->setHeader('Status', '404 File not found');
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @see Mage_Core_Controller_Varien_Action::_redirect()
|
89 |
+
*
|
90 |
+
* @param string $path
|
91 |
+
* @param array $arguments
|
92 |
+
*/
|
93 |
+
protected function _redirect($path, $arguments = array())
|
94 |
+
{
|
95 |
+
if ($this->_javaScriptRedirect) {
|
96 |
+
$this->_javascriptRedirect($path, $arguments);
|
97 |
+
} else {
|
98 |
+
parent::_redirect($path, $arguments);
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* JavaScript redirect can use for redirect from an iframe.
|
105 |
+
*
|
106 |
+
* @param string $url
|
107 |
+
* @param array $arguments
|
108 |
+
*/
|
109 |
+
protected function _javascriptRedirect($path, $arguments = array())
|
110 |
+
{
|
111 |
+
//Build the url
|
112 |
+
$url = Mage::getUrl($path, $arguments);
|
113 |
+
|
114 |
+
//Build the js content
|
115 |
+
$js = '';
|
116 |
+
$js .= '<html>';
|
117 |
+
$js .= '<body>';
|
118 |
+
$js .= '<script type="text/javascript">';
|
119 |
+
$js .= '/* <![CDATA[ */';
|
120 |
+
$js .= 'top.location.href = "' . $url . '";';
|
121 |
+
$js .= '/* ]]> */';
|
122 |
+
$js .= '</script>';
|
123 |
+
$js .= '<a href="' . $url . '" target="_parent">';
|
124 |
+
$js .= $this->_getHelper()->__("If your not getting redirected click here.");
|
125 |
+
$js .= '</a>';
|
126 |
+
$js .= '</body>';
|
127 |
+
$js .= '</html>';
|
128 |
+
|
129 |
+
//Set the javascript redirect
|
130 |
+
Mage::app()->getResponse()->setBody($js);
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Return the computop helper.
|
136 |
+
*
|
137 |
+
* @return Dotsource_Computop_Helper_Data
|
138 |
+
*/
|
139 |
+
protected function _getHelper()
|
140 |
+
{
|
141 |
+
return Mage::helper('computop');
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Dotsource/Computop/Controller/Computopcallback.php
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
abstract class Dotsource_Computop_Controller_Computopcallback
|
12 |
+
extends Dotsource_Computop_Controller_Callback
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Return the payment code to check the response is process
|
17 |
+
* by the right controller.
|
18 |
+
*
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
protected abstract function _getPaymentCode();
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Controller_Callback::notifyAction()
|
26 |
+
*/
|
27 |
+
public function notifyAction()
|
28 |
+
{
|
29 |
+
try {
|
30 |
+
//Parse the response as an response object
|
31 |
+
$response = $this->_getCallbackResponse(
|
32 |
+
$this->getRequest()->getParams(),
|
33 |
+
true
|
34 |
+
);
|
35 |
+
|
36 |
+
//the trans id is the order increment id
|
37 |
+
$transId = $response->getResponse()->getTransid();
|
38 |
+
|
39 |
+
/* @var $order Mage_Sales_Model_Order */
|
40 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($transId);
|
41 |
+
|
42 |
+
//Check for the right controller call
|
43 |
+
if ($this->_getPaymentCode() != $order->getPayment()->getMethodInstance()->getCode()
|
44 |
+
|| $this->_getPaymentCode() != $response->getUserData()->getPaymentCode()
|
45 |
+
) {
|
46 |
+
Mage::throwException("Wrong controller is called for this payment.");
|
47 |
+
}
|
48 |
+
|
49 |
+
//Set the order locale
|
50 |
+
Mage::app()->getLocale()->emulate($order->getStoreId());
|
51 |
+
|
52 |
+
//Register the order
|
53 |
+
Mage::register('computop_notify_order', $order);
|
54 |
+
|
55 |
+
//Add message prefix
|
56 |
+
$payment = $order->getPayment();
|
57 |
+
$payment->setPreparedMessage(Dotsource_Computop_Model_Payment_Abstract::COMPUTOP_PREFIX);
|
58 |
+
|
59 |
+
//Log the response
|
60 |
+
Mage::getModel('computop/action')
|
61 |
+
->logResponse(
|
62 |
+
$response,
|
63 |
+
$payment
|
64 |
+
)
|
65 |
+
->save();
|
66 |
+
|
67 |
+
//Process the right action
|
68 |
+
if (!$response->hasError()) {
|
69 |
+
//Add the payment information
|
70 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
71 |
+
$payment,
|
72 |
+
$response
|
73 |
+
);
|
74 |
+
|
75 |
+
//No need to close the transaction in any case (auth, capture)
|
76 |
+
$payment->setIsTransactionClosed(false);
|
77 |
+
|
78 |
+
//Process the success action
|
79 |
+
$this->_notifySuccessProcessing($response);
|
80 |
+
} else {
|
81 |
+
$this->_notifyErrorProcessing($response);
|
82 |
+
}
|
83 |
+
|
84 |
+
//Save the changes
|
85 |
+
$order->save();
|
86 |
+
|
87 |
+
//Reset to default locale
|
88 |
+
Mage::app()->getLocale()->revert();
|
89 |
+
} catch (Exception $e) {
|
90 |
+
$this->_notifyActionError();
|
91 |
+
Mage::logException($e);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Return the customer browser back to the cart to the error message.
|
98 |
+
*/
|
99 |
+
public function failureAction()
|
100 |
+
{
|
101 |
+
//Parse the response as an response object
|
102 |
+
$response = $this->_getCallbackResponse(
|
103 |
+
$this->getRequest()->getParams(),
|
104 |
+
false
|
105 |
+
);
|
106 |
+
|
107 |
+
//Reactivate the last used quote
|
108 |
+
$this->_getHelper()->restoreQuote(null, Dotsource_Computop_Helper_Data::FRONTEND);
|
109 |
+
|
110 |
+
$this->_getHelper()->getPaymentHelper()
|
111 |
+
->getFrontendErrorManager()
|
112 |
+
->removeHandler('exception')
|
113 |
+
->addHandler('session', 'session', array('session' => 'checkout/session'))
|
114 |
+
->processErrorCode($response->getResponse()->getCode());
|
115 |
+
|
116 |
+
$this->_failureRedirect();
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Redirect the customer browser to the success page.
|
122 |
+
*/
|
123 |
+
public function successAction()
|
124 |
+
{
|
125 |
+
$this->_successRedirect();
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Redirect the customer browser back to the onepage checkout.
|
131 |
+
*/
|
132 |
+
public function backAction()
|
133 |
+
{
|
134 |
+
//Get the checkout session
|
135 |
+
$checkout = $this->_getHelper()->getFrontendCheckoutSession();
|
136 |
+
$cancelStatus = array(
|
137 |
+
Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE,
|
138 |
+
Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION
|
139 |
+
);
|
140 |
+
|
141 |
+
//Check for a last real order id
|
142 |
+
if ($checkout->hasLastRealOrderId()) {
|
143 |
+
/* @var $order Mage_Sales_Model_Order */
|
144 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId(
|
145 |
+
$checkout->getLastRealOrderId()
|
146 |
+
);
|
147 |
+
|
148 |
+
//Check for an valid order
|
149 |
+
if ($order instanceof Mage_Sales_Model_Order
|
150 |
+
&& $order->hasData()
|
151 |
+
&& $order->hasStatus()
|
152 |
+
) {
|
153 |
+
//Check if we can unhold the state and we have an pending payment
|
154 |
+
if ($order->canUnhold()
|
155 |
+
&& in_array($order->getStatus(), $cancelStatus)
|
156 |
+
) {
|
157 |
+
//Unhold first
|
158 |
+
$order->unhold();
|
159 |
+
|
160 |
+
if ($order->canCancel()) {
|
161 |
+
//Cancel the order an create a comment to the order history
|
162 |
+
$order->registerCancellation(
|
163 |
+
$this->createErrorMessage(
|
164 |
+
$this->_getHelper()->__('The customer quit the payment gateway the order will be canceled.')
|
165 |
+
)
|
166 |
+
);
|
167 |
+
} else { //Can't cancel the order
|
168 |
+
//Check if we can rehold the order
|
169 |
+
if ($order->canHold()) {
|
170 |
+
$order->hold();
|
171 |
+
}
|
172 |
+
|
173 |
+
//Add the message
|
174 |
+
$order->addStatusHistoryComment(
|
175 |
+
$this->createErrorMessage(
|
176 |
+
$this->_getHelper()->__("The customer quit the payment gateway but the order can't cancel.")
|
177 |
+
)
|
178 |
+
);
|
179 |
+
}
|
180 |
+
|
181 |
+
//Save the changes
|
182 |
+
$order->save();
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
//Reactivate the last used quote
|
187 |
+
$this->_getHelper()->restoreQuote(null, Dotsource_Computop_Helper_Data::FRONTEND);
|
188 |
+
}
|
189 |
+
|
190 |
+
$this->_backRedirect();
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Process the success of the payment.
|
196 |
+
*
|
197 |
+
* @param Dotsource_Computop_Model_Payment_Response_Response $response
|
198 |
+
*/
|
199 |
+
protected function _notifySuccessProcessing(Dotsource_Computop_Model_Payment_Response_Response $response)
|
200 |
+
{
|
201 |
+
/* @var $order Mage_Sales_Model_Order */
|
202 |
+
$order = Mage::registry('computop_notify_order');
|
203 |
+
$payment = $order->getPayment();
|
204 |
+
|
205 |
+
//Call the right transaction method
|
206 |
+
switch ($response->getUserData()->getCapture()) {
|
207 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
208 |
+
$payment->registerAuthorizationNotification($payment->getAmountAuthorized());
|
209 |
+
$order->setStatus(Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE);
|
210 |
+
break;
|
211 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
212 |
+
$msg = $payment->getPreparedMessage();
|
213 |
+
$msg .= " ".$this->_getHelper()->__(
|
214 |
+
'The book date is %s.',
|
215 |
+
Zend_Date::now()
|
216 |
+
->addHour($response->getUserData()->getHours())
|
217 |
+
->get(Zend_Date::DATETIME_LONG)
|
218 |
+
);
|
219 |
+
$payment->setPreparedMessage($msg);
|
220 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
221 |
+
$order->setData('state', Mage_Sales_Model_Order::STATE_PROCESSING); //Hack
|
222 |
+
$payment->registerCaptureNotification($payment->getAmountAuthorized());
|
223 |
+
break;
|
224 |
+
default:
|
225 |
+
Mage::throwException("Can't detect the payment moment.");
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Process the failing of the payment.
|
232 |
+
*
|
233 |
+
* @param Dotsource_Computop_Model_Payment_Response_Response $response
|
234 |
+
*/
|
235 |
+
protected function _notifyErrorProcessing(Dotsource_Computop_Model_Payment_Response_Response $response)
|
236 |
+
{
|
237 |
+
/* @var $order Mage_Sales_Model_Order */
|
238 |
+
$order = Mage::registry('computop_notify_order');
|
239 |
+
|
240 |
+
//Unhold first
|
241 |
+
if ($order->canUnhold()) {
|
242 |
+
$order->unhold();
|
243 |
+
}
|
244 |
+
|
245 |
+
//Check if we can cancel the order
|
246 |
+
if ($order->canCancel()) {
|
247 |
+
$msg = "";
|
248 |
+
|
249 |
+
switch ($response->getUserData()->getCapture()) {
|
250 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
251 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
252 |
+
$msg = "The capture was failed the order will be canceled.";
|
253 |
+
break;
|
254 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
255 |
+
default:
|
256 |
+
$msg = "The authorization was failed the order will be canceled.";
|
257 |
+
}
|
258 |
+
|
259 |
+
//Cancel the order an create a comment to the order history
|
260 |
+
$order->registerCancellation(
|
261 |
+
$this->createErrorMessage(
|
262 |
+
$this->_getHelper()->__($msg)
|
263 |
+
)
|
264 |
+
);
|
265 |
+
} else {
|
266 |
+
//Check if we can rehold the order
|
267 |
+
if ($order->canHold()) {
|
268 |
+
$order->hold();
|
269 |
+
}
|
270 |
+
|
271 |
+
//Add the message
|
272 |
+
$order->addStatusHistoryComment(
|
273 |
+
$this->createErrorMessage(
|
274 |
+
$this->_getHelper()->__("The authorization/capture was failed but the order can't cancel.")
|
275 |
+
)
|
276 |
+
);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Parse the response from a callback and return a response model.
|
283 |
+
*
|
284 |
+
* @param array $responseData
|
285 |
+
* @param boolean $forcedEncryption
|
286 |
+
* @return Dotsource_Computop_Model_Payment_Response_Response
|
287 |
+
*/
|
288 |
+
protected function _getCallbackResponse(array $responseData = array(), $forcedEncryption = true)
|
289 |
+
{
|
290 |
+
if (empty($responseData)) {
|
291 |
+
$responseData = $this->getRequest()->getParams();
|
292 |
+
}
|
293 |
+
|
294 |
+
//Lower case for access
|
295 |
+
$responseData = array_change_key_case($responseData, CASE_LOWER);
|
296 |
+
|
297 |
+
//Check for merchant information
|
298 |
+
$merchantId = null;
|
299 |
+
if (array_key_exists('plain', $responseData)) {
|
300 |
+
$merchantId = $responseData['plain'];
|
301 |
+
} else if (array_key_exists('merchantid', $responseData)) {
|
302 |
+
$merchantId = $responseData['merchantid'];
|
303 |
+
} else if (array_key_exists('mid', $responseData)) {
|
304 |
+
$merchantId = $responseData['mid'];
|
305 |
+
}
|
306 |
+
|
307 |
+
//Create the response model
|
308 |
+
$response = Mage::getModel('computop/payment_response_response')
|
309 |
+
->setEncryptionSettings(
|
310 |
+
$this->_getHelper()->getConfiguration()->getPaymentSpecificMerchantFieldByMerchantId(
|
311 |
+
$this->_getPaymentCode(),
|
312 |
+
$merchantId
|
313 |
+
)
|
314 |
+
)
|
315 |
+
->setResponse($responseData, $forcedEncryption);
|
316 |
+
|
317 |
+
//Log the response
|
318 |
+
$this->_getHelper()->Log($response->getResponse(), 'Notify');
|
319 |
+
|
320 |
+
return $response;
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Return the message with an computop prefix.
|
326 |
+
*
|
327 |
+
* @param string $message
|
328 |
+
* @return string
|
329 |
+
*/
|
330 |
+
public function createErrorMessage($message)
|
331 |
+
{
|
332 |
+
return Dotsource_Computop_Model_Payment_Abstract::COMPUTOP_PREFIX . " " . $message;
|
333 |
+
}
|
334 |
+
}
|
app/code/community/Dotsource/Computop/Controller/Expresscallback.php
ADDED
@@ -0,0 +1,528 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 18.05.2010 17:00:52
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
abstract class Dotsource_Computop_Controller_Expresscallback
|
15 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Controller_Callback::notifyAction()
|
20 |
+
*
|
21 |
+
* @return null
|
22 |
+
*/
|
23 |
+
public function notifyAction()
|
24 |
+
{
|
25 |
+
try {
|
26 |
+
//Parse the response as an response object
|
27 |
+
$response = $this->_getCallbackResponse(
|
28 |
+
$this->getRequest()->getParams(),
|
29 |
+
false
|
30 |
+
);
|
31 |
+
|
32 |
+
//the trans id is the order entity id
|
33 |
+
$transId = $response->getResponse()->getTransid();
|
34 |
+
|
35 |
+
//Load the order or the quote model
|
36 |
+
$model = $this->_loadOrderOrQuote($transId);
|
37 |
+
|
38 |
+
//No need to process
|
39 |
+
if (null === $model) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
|
43 |
+
//Get the payment from the order or quote
|
44 |
+
$payment = $model->getPayment();
|
45 |
+
|
46 |
+
//Check for the right controller call
|
47 |
+
if ($this->_getPaymentCode() != $payment->getMethodInstance()->getCode()
|
48 |
+
|| $this->_getPaymentCode() != $payment->getMethodInstance()->getCode()
|
49 |
+
) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
//Add message prefix
|
54 |
+
$payment->setPreparedMessage(
|
55 |
+
Dotsource_Computop_Model_Payment_Abstract::COMPUTOP_PREFIX
|
56 |
+
);
|
57 |
+
|
58 |
+
//Log the response
|
59 |
+
Mage::getModel('computop/action')->logResponse($response, $payment)->save();
|
60 |
+
|
61 |
+
//Process the right action
|
62 |
+
if (!$response->hasError()) {
|
63 |
+
//Add the payment information
|
64 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
65 |
+
$payment,
|
66 |
+
$response
|
67 |
+
);
|
68 |
+
|
69 |
+
//Process the quote
|
70 |
+
if ($model instanceof Mage_Sales_Model_Quote) {
|
71 |
+
//Log the essential response data in the payment
|
72 |
+
$payment->setAdditionalInformation(
|
73 |
+
'computop_xid', $response->getResponse()->getXid()
|
74 |
+
);
|
75 |
+
|
76 |
+
$payment->setAdditionalInformation(
|
77 |
+
'computop_payid', $response->getResponse()->getPayid()
|
78 |
+
);
|
79 |
+
|
80 |
+
//Save the capture in the payment
|
81 |
+
$payment->setAdditionalInformation(
|
82 |
+
'computop_capture', $response->getUserData()->getCapture()
|
83 |
+
);
|
84 |
+
|
85 |
+
//Save status to the payment
|
86 |
+
$payment->setAdditionalInformation(
|
87 |
+
'computop_is_pending', $response->isPending()
|
88 |
+
);
|
89 |
+
|
90 |
+
//Remove all addresses
|
91 |
+
$model->removeAllAddresses();
|
92 |
+
|
93 |
+
//Add the addresses from paypal to the quote
|
94 |
+
$model->setShippingAddress(
|
95 |
+
$this->_prepareQuoteShippingAddress($response->getResponse())
|
96 |
+
);
|
97 |
+
|
98 |
+
$model->setBillingAddress(
|
99 |
+
$this->_prepareQuoteBillingAddress($response->getResponse())
|
100 |
+
);
|
101 |
+
|
102 |
+
$model->collectTotals()->save();
|
103 |
+
} else if ($model instanceof Mage_Sales_Model_Order) {
|
104 |
+
$this->_notifySuccessProcessing($response);
|
105 |
+
$model->save();
|
106 |
+
}
|
107 |
+
} else if ($model instanceof Mage_Sales_Model_Order) {
|
108 |
+
//Cancel order if one exists
|
109 |
+
$this->_notifyErrorProcessing($response);
|
110 |
+
$model->save();
|
111 |
+
}
|
112 |
+
} catch (Exception $e) {
|
113 |
+
$this->_notifyActionError();
|
114 |
+
Mage::logException($e);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @see Dotsource_Computop_Controller_Callback::successAction()
|
121 |
+
*/
|
122 |
+
public function successAction()
|
123 |
+
{
|
124 |
+
//Parse the response as an response object
|
125 |
+
$response = $this->_getCallbackResponse(
|
126 |
+
$this->getRequest()->getParams(),
|
127 |
+
true
|
128 |
+
);
|
129 |
+
|
130 |
+
//TransID is the quote reserved increment id
|
131 |
+
$transId = $response->getResponse()->getTransid();
|
132 |
+
|
133 |
+
//Load the order or the quote model
|
134 |
+
$model = $this->_loadOrderOrQuote($transId);
|
135 |
+
|
136 |
+
//If the order currently not exists we are currently in the checkout step
|
137 |
+
//so if the success action is called we can redirect to the review step
|
138 |
+
if (null === $model) {
|
139 |
+
$this->_failureRedirect();
|
140 |
+
return;
|
141 |
+
} else if ($model instanceof Mage_Sales_Model_Quote) {
|
142 |
+
//Valid the quote
|
143 |
+
if (!$this->_validateQuote($model)) {
|
144 |
+
return;
|
145 |
+
}
|
146 |
+
|
147 |
+
//Force the quote for the review step to the quote from the request
|
148 |
+
$this->_getHelper()->getFrontendCheckoutSession()->setQuoteId($model->getId());
|
149 |
+
|
150 |
+
//Redirect to the review page
|
151 |
+
$this->_redirect('*/*/review');
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
|
155 |
+
$this->_successRedirect();
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Review action that generates the overview of the
|
161 |
+
* shipping and billing addresses.
|
162 |
+
*
|
163 |
+
* @return null
|
164 |
+
*/
|
165 |
+
public function reviewAction()
|
166 |
+
{
|
167 |
+
try {
|
168 |
+
//Get the current frontend quote
|
169 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
170 |
+
|
171 |
+
//Redirect to the cart
|
172 |
+
if (!$this->_validateQuote($quote)) {
|
173 |
+
return;
|
174 |
+
}
|
175 |
+
|
176 |
+
$this->loadLayout();
|
177 |
+
$this->_initLayoutMessages('checkout/session');
|
178 |
+
$this->getLayout()
|
179 |
+
->getBlock('computop.checkout.paypal.review')
|
180 |
+
->setQuote($quote)
|
181 |
+
->setCanEditShippingAddress(false)
|
182 |
+
->getChild('details')->setQuote($quote);
|
183 |
+
$this->renderLayout();
|
184 |
+
return;
|
185 |
+
} catch (Mage_Core_Exception $e) {
|
186 |
+
Mage::logException($e);
|
187 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
188 |
+
} catch (Exception $e) {
|
189 |
+
Mage::getSingleton('checkout/session')->addError(
|
190 |
+
$this->__('Unable to initialize Express Checkout review.')
|
191 |
+
);
|
192 |
+
Mage::logException($e);
|
193 |
+
}
|
194 |
+
|
195 |
+
//Back to the cart
|
196 |
+
$this->_failureRedirect();
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Submit the order.
|
202 |
+
*
|
203 |
+
* @return null
|
204 |
+
*/
|
205 |
+
public function placeOrderAction()
|
206 |
+
{
|
207 |
+
try {
|
208 |
+
//Get the session
|
209 |
+
$session = $this->_getHelper()->getFrontendCheckoutSession();
|
210 |
+
|
211 |
+
//Get the current frontend quote
|
212 |
+
$quote = $session->getQuote();
|
213 |
+
|
214 |
+
//Check for the right payment type and throw an exception
|
215 |
+
if (!$this->_validateQuote($quote)) {
|
216 |
+
return;
|
217 |
+
}
|
218 |
+
|
219 |
+
if ($this->getRequest()->getParam('shipping_method')) {
|
220 |
+
$this->_updateShippingMethod(
|
221 |
+
$this->getRequest()->getParam('shipping_method')
|
222 |
+
);
|
223 |
+
}
|
224 |
+
|
225 |
+
if (!$quote->getCustomerId()) {
|
226 |
+
$quote
|
227 |
+
->setCustomerIsGuest(true)
|
228 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
|
229 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail());
|
230 |
+
}
|
231 |
+
|
232 |
+
//Ignore address validation errors
|
233 |
+
$quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
234 |
+
if (!$quote->getIsVirtual()) {
|
235 |
+
$quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
236 |
+
}
|
237 |
+
|
238 |
+
//Recalculate the quote
|
239 |
+
$quote->collectTotals();
|
240 |
+
|
241 |
+
//Get the quote to order service model
|
242 |
+
/* @var $order Mage_Sales_Model_Order */
|
243 |
+
$order = null;
|
244 |
+
$callbackProcessed = false;
|
245 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
246 |
+
$callbackMethods = array('submitOrder', 'submit');
|
247 |
+
|
248 |
+
//Process one the given callbacks
|
249 |
+
foreach ($callbackMethods as $method) {
|
250 |
+
if (method_exists($service, $method)) {
|
251 |
+
$order = call_user_func(array($service, $method));
|
252 |
+
$callbackProcessed = true;
|
253 |
+
break;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
//Quoted submit failed
|
258 |
+
if ($callbackProcessed === false) {
|
259 |
+
throw new Excpetion('Quote submit failed. Callback method not found.');
|
260 |
+
}
|
261 |
+
|
262 |
+
//Check for getOrder method
|
263 |
+
if (method_exists($service, 'getOrder')) {
|
264 |
+
$order = $service->getOrder();
|
265 |
+
}
|
266 |
+
|
267 |
+
//TODO: Statecheck
|
268 |
+
// switch ($order->getState()) {
|
269 |
+
// case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
270 |
+
// break;
|
271 |
+
// case Mage_Sales_Model_Order::STATE_PROCESSING:
|
272 |
+
// case Mage_Sales_Model_Order::STATE_COMPLETE:
|
273 |
+
try {
|
274 |
+
$order->sendNewOrderEmail();
|
275 |
+
} catch (Exception $e) {
|
276 |
+
Mage::logException($e->getMessage());
|
277 |
+
}
|
278 |
+
// break;
|
279 |
+
// }
|
280 |
+
|
281 |
+
//Save the quote to save is_active 0
|
282 |
+
$quote->save();
|
283 |
+
|
284 |
+
//Reset the session information
|
285 |
+
if (method_exists($session, 'clearHelperData')) {
|
286 |
+
$session->clearHelperData();
|
287 |
+
}
|
288 |
+
|
289 |
+
//Set the helper data
|
290 |
+
$session
|
291 |
+
->setLastQuoteId($quote->getId())
|
292 |
+
->setLastSuccessQuoteId($quote->getId())
|
293 |
+
->setLastOrderId($order->getId())
|
294 |
+
->setLastRealOrderId($order->getIncrementId());
|
295 |
+
|
296 |
+
$this->_redirect('checkout/onepage/success');
|
297 |
+
return;
|
298 |
+
} catch (Mage_Core_Exception $e) {
|
299 |
+
$this->_getHelper()->getFrontendCheckoutSession()->addError($e->getMessage());
|
300 |
+
} catch (Exception $e) {
|
301 |
+
$this->_getHelper()->getFrontendCheckoutSession()->addError($this->__('Unable to place the order.'));
|
302 |
+
Mage::logException($e);
|
303 |
+
}
|
304 |
+
|
305 |
+
//Back to the cart
|
306 |
+
$this->_failureRedirect();
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Set shipping method to quote, if needed.
|
312 |
+
*
|
313 |
+
* @param string $methodCode
|
314 |
+
*/
|
315 |
+
protected function _updateShippingMethod($methodCode)
|
316 |
+
{
|
317 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
318 |
+
|
319 |
+
if (!$quote->getIsVirtual() && $shippingAddress = $quote->getShippingAddress()) {
|
320 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
321 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
322 |
+
$quote->collectTotals()->save();
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Update shipping method (combined action for ajax and regular request).
|
330 |
+
*
|
331 |
+
* @return null
|
332 |
+
*/
|
333 |
+
public function saveShippingMethodAction()
|
334 |
+
{
|
335 |
+
try {
|
336 |
+
$this->_updateShippingMethod($this->getRequest()->getParam('shipping_method'));
|
337 |
+
$isAjax = $this->getRequest()->getParam('isAjax');
|
338 |
+
if ($isAjax) {
|
339 |
+
$this->loadLayout('computop_callback_paypalexpress_details');
|
340 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('root')
|
341 |
+
->setQuote($this->_getHelper()->getFrontendQuote())
|
342 |
+
->toHtml());
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
} catch (Mage_Core_Exception $e) {
|
346 |
+
$this->_getSession()->addError($e->getMessage());
|
347 |
+
Mage::logException($e);
|
348 |
+
} catch (Exception $e) {
|
349 |
+
$this->_getSession()->addError($this->__('Unable to update shipping method.'));
|
350 |
+
Mage::logException($e);
|
351 |
+
}
|
352 |
+
if ($isAjax) {
|
353 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
354 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
355 |
+
} else {
|
356 |
+
$this->_redirect('*/*/review', array('_current' => true));
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Set the response data to the shipping and billing addresses of
|
363 |
+
* the given quote.
|
364 |
+
*
|
365 |
+
* @param Dotsource_Computop_Object $response
|
366 |
+
* @return Mage_Sales_Model_Quote_Address
|
367 |
+
*/
|
368 |
+
protected function _prepareQuoteShippingAddress(Dotsource_Computop_Object $response)
|
369 |
+
{
|
370 |
+
//Prepare the shipping address
|
371 |
+
/* @var $address Mage_Sales_Model_Quote_Address */
|
372 |
+
$address = Mage::getModel('sales/quote_address');
|
373 |
+
$address->setStreet(
|
374 |
+
array(
|
375 |
+
$response->getData('addrstreet'),
|
376 |
+
$response->getData('addrstreet2')
|
377 |
+
)
|
378 |
+
);
|
379 |
+
|
380 |
+
$address
|
381 |
+
->setCity($response->getData('addrcity'))
|
382 |
+
->setRegion($response->getData('addrstate'))
|
383 |
+
->setPostcode($response->getData('addrzip'))
|
384 |
+
->setCountryId($response->getData('addrcountrycode'))
|
385 |
+
->setTelephone($response->getData('phone'));
|
386 |
+
|
387 |
+
//Set the name to the address
|
388 |
+
Mage::helper('computop/converter')->setNameToAddress(
|
389 |
+
$address, $response->getData('name')
|
390 |
+
);
|
391 |
+
|
392 |
+
$address->implodeStreetAddress();
|
393 |
+
$address->setCollectShippingRates(true);
|
394 |
+
|
395 |
+
return $address;
|
396 |
+
}
|
397 |
+
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Set the response data as billing address of the given quote.
|
401 |
+
*
|
402 |
+
* @param Dotsource_Computop_Object $response
|
403 |
+
* @return Mage_Sales_Model_Quote_Address
|
404 |
+
*/
|
405 |
+
protected function _prepareQuoteBillingAddress(Dotsource_Computop_Object $response)
|
406 |
+
{
|
407 |
+
/* @var $address Mage_Sales_Model_Quote_Address */
|
408 |
+
//If not sent, use the shipping Address
|
409 |
+
if (!$response->getData('billingname')) {
|
410 |
+
$address = $this->_prepareQuoteShippingAddress($response);
|
411 |
+
} else {
|
412 |
+
$address = Mage::getModel('sales/quote_address');
|
413 |
+
$address->setStreet(
|
414 |
+
array(
|
415 |
+
$response->getData('billingaddrstreet'),
|
416 |
+
$response->getData('billingaddrstreet2')
|
417 |
+
)
|
418 |
+
);
|
419 |
+
$address->setCity($response->getData('billingaddrcity'))
|
420 |
+
->setRegion($response->getData('billingaddrstate'))
|
421 |
+
->setPostcode($response->getData('billingaddrzip'))
|
422 |
+
->setCountryId($response->getData('billingaddrcountrycode'));
|
423 |
+
|
424 |
+
//Set the name to the address
|
425 |
+
Mage::helper('computop/converter')->setNameToAddress(
|
426 |
+
$address, $response->getData('billingname')
|
427 |
+
);
|
428 |
+
|
429 |
+
$address->implodeStreetAddress();
|
430 |
+
}
|
431 |
+
$address->setEmail($response->getData('e-mail'));
|
432 |
+
|
433 |
+
return $address;
|
434 |
+
}
|
435 |
+
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Return the order from the given increment id.
|
439 |
+
*
|
440 |
+
* @param string $incrementId
|
441 |
+
* @return Mage_Sales_Model_Order || null
|
442 |
+
*/
|
443 |
+
protected function _loadOrder($incrementId)
|
444 |
+
{
|
445 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
446 |
+
|
447 |
+
if ($order && $order->getId()) {
|
448 |
+
return $order;
|
449 |
+
}
|
450 |
+
|
451 |
+
return null;
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Return the quote from the given reserved increment id.
|
457 |
+
*
|
458 |
+
* @param string $reservedIncrementId
|
459 |
+
* @return Mage_Sales_Model_Quote || null
|
460 |
+
*/
|
461 |
+
protected function _loadQuote($reservedIncrementId)
|
462 |
+
{
|
463 |
+
$quote = Mage::getModel('sales/quote')->load($reservedIncrementId, 'reserved_order_id');
|
464 |
+
|
465 |
+
if ($quote && $quote->getId()) {
|
466 |
+
return $quote;
|
467 |
+
}
|
468 |
+
|
469 |
+
return null;
|
470 |
+
}
|
471 |
+
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Try to return a order with the given increment id. If the order don't exists
|
475 |
+
* the method try to return a quote with the given increment id (reserved_order_id).
|
476 |
+
* If the quote not exists the method return null.
|
477 |
+
* If the method found an order is will saved under the mage register key computop_notify_order
|
478 |
+
* or a quote will saved under the key computop_notify_quote.
|
479 |
+
*
|
480 |
+
* @param string $incrementId
|
481 |
+
* @return unknown
|
482 |
+
*/
|
483 |
+
protected function _loadOrderOrQuote($incrementId)
|
484 |
+
{
|
485 |
+
//First try to load the order
|
486 |
+
$order = $this->_loadOrder($incrementId);
|
487 |
+
|
488 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
489 |
+
Mage::register('computop_notify_order', $order);
|
490 |
+
return $order;
|
491 |
+
}
|
492 |
+
|
493 |
+
//Try to load an quote
|
494 |
+
$quote = $this->_loadQuote($incrementId);
|
495 |
+
|
496 |
+
if ($quote instanceof Mage_Sales_Model_Quote) {
|
497 |
+
Mage::register('computop_notify_quote', $quote);
|
498 |
+
return $quote;
|
499 |
+
}
|
500 |
+
|
501 |
+
return null;
|
502 |
+
}
|
503 |
+
|
504 |
+
|
505 |
+
/**
|
506 |
+
* A valid quote has use the right controller, has items and has an
|
507 |
+
* valid computop transaction id.
|
508 |
+
*
|
509 |
+
* @param Mage_Sales_Model_Quote || Mage_Sales_Model_Order $model
|
510 |
+
* @return boolean
|
511 |
+
*/
|
512 |
+
protected function _validateQuote($model, $errorHandling = true) {
|
513 |
+
$validQuote = $this->_getPaymentCode() == $model->getPayment()->getMethodInstance()->getCode()
|
514 |
+
&& $model->hasItems()
|
515 |
+
&& (boolean)$model->getPayment()->getData('computop_transaction_id');
|
516 |
+
|
517 |
+
if (!$validQuote && $errorHandling) {
|
518 |
+
$this->_getHelper()->getFrontendCheckoutSession()->addError(
|
519 |
+
$this->_getHelper()->__("You'r current quote is not valid to use PayPal express checkout.")
|
520 |
+
);
|
521 |
+
|
522 |
+
//Redirect to cart
|
523 |
+
$this->_redirect('checkout/cart/');
|
524 |
+
}
|
525 |
+
|
526 |
+
return $validQuote;
|
527 |
+
}
|
528 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Config.php
ADDED
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Helper_Config
|
11 |
+
extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the specific payment merchant ids */
|
15 |
+
const CONNECTION_PAYMENT_MERCHANT_PATH = 'computop_account/%s';
|
16 |
+
|
17 |
+
/** Holds default payment settings */
|
18 |
+
const CONNECTION_SETTINGS_DEFAULT_PATH = 'computop_account/default';
|
19 |
+
|
20 |
+
/** Holds the payment settings */
|
21 |
+
const PAYMENT_SETTINGS_PATH = 'payment/%s';
|
22 |
+
|
23 |
+
/** Holds the xml path the the config */
|
24 |
+
const XML_PATH_AVAIABLE_CC_LOGOS = 'payment/computop_cc/logos';
|
25 |
+
|
26 |
+
/** Holds the payment specific merchant information with the currency as access keys */
|
27 |
+
protected $_additionalCurrencyMerchantSettings = null;
|
28 |
+
|
29 |
+
/** Holds the payment specific merchant information with the merchant id as access keys */
|
30 |
+
protected $_additionalMerchantIdMerchantSettings = null;
|
31 |
+
|
32 |
+
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->_additionalCurrencyMerchantSettings = new Varien_Object();
|
36 |
+
$this->_additionalMerchantIdMerchantSettings = new Varien_Object();
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Return a specific merchant account for the given payment. if no
|
42 |
+
* data available the function return the default value.
|
43 |
+
*
|
44 |
+
* @param string $payment
|
45 |
+
* @param string $country
|
46 |
+
* @param string $field
|
47 |
+
* @return string
|
48 |
+
*/
|
49 |
+
public function getPaymentSpecificMerchantFieldByCurrency($payment, $currency, $field = null)
|
50 |
+
{
|
51 |
+
//Keys are in lower case
|
52 |
+
$currency = strtolower($currency);
|
53 |
+
$field = strtolower($field);
|
54 |
+
|
55 |
+
//Build the path to the data
|
56 |
+
$path = "$payment/$currency";
|
57 |
+
|
58 |
+
//Check for return the complete settings or a field
|
59 |
+
if (!empty($field)) {
|
60 |
+
$path .= "/$field";
|
61 |
+
}
|
62 |
+
|
63 |
+
//Try to load the merchant data from payment
|
64 |
+
$this->_loadSpecificMerchantSettingsFromPayment($payment);
|
65 |
+
|
66 |
+
//Get the data from the path
|
67 |
+
$data = $this->_getAdditionalMerchantSettingsByCurrency()->getData($path);
|
68 |
+
|
69 |
+
//Check if we have data
|
70 |
+
if (!empty($data)) {
|
71 |
+
return $data;
|
72 |
+
}
|
73 |
+
|
74 |
+
return $this->getDefaultSettings($field);
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return a specific merchant account for the given payment. if no
|
80 |
+
* data available the function return the default value.
|
81 |
+
*
|
82 |
+
* @param string $payment
|
83 |
+
* @param string $country
|
84 |
+
* @param string $field
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getPaymentSpecificMerchantFieldByMerchantId($payment, $merchantId, $field = null)
|
88 |
+
{
|
89 |
+
//Keys are in lower case
|
90 |
+
$merchantId = strtolower($merchantId);
|
91 |
+
$field = strtolower($field);
|
92 |
+
|
93 |
+
//Build the path to the data
|
94 |
+
$path = "$payment/$merchantId";
|
95 |
+
|
96 |
+
//Check for return the complete settings or a field
|
97 |
+
if (!empty($field)) {
|
98 |
+
$path .= "/$field";
|
99 |
+
}
|
100 |
+
|
101 |
+
//Try to load the merchant data from payment
|
102 |
+
$this->_loadSpecificMerchantSettingsFromPayment($payment);
|
103 |
+
|
104 |
+
//Get the data from the path
|
105 |
+
$data = $this->_getAdditionalMerchantSettingsByMerchantId()->getData($path);
|
106 |
+
|
107 |
+
//Check if we have data
|
108 |
+
if (!empty($data)) {
|
109 |
+
return $data;
|
110 |
+
}
|
111 |
+
|
112 |
+
return $this->getDefaultSettings($field);
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Return the default settings for an given field.
|
118 |
+
*
|
119 |
+
* @param string $field
|
120 |
+
* @return string
|
121 |
+
*/
|
122 |
+
public function getDefaultSettings($field = null)
|
123 |
+
{
|
124 |
+
//Return all default value if no field is given
|
125 |
+
if (empty($field)) {
|
126 |
+
return array(
|
127 |
+
'id' => $this->getMerchantId(),
|
128 |
+
'password' => $this->getEncryptionPassword() ,
|
129 |
+
'hmac' => $this->getHmac(),
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
//Return the default value
|
134 |
+
switch ($field) {
|
135 |
+
case 'id':
|
136 |
+
return $this->getMerchantId();
|
137 |
+
case 'hmac':
|
138 |
+
return $this->getHmac();
|
139 |
+
case 'password':
|
140 |
+
return $this->getEncryptionPassword();
|
141 |
+
}
|
142 |
+
|
143 |
+
Mage::throwException("No default value for the field \"$field\" available");
|
144 |
+
}
|
145 |
+
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Return the encryption password.
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function getMerchantId()
|
153 |
+
{
|
154 |
+
return Mage::getStoreConfig(self::CONNECTION_SETTINGS_DEFAULT_PATH.'/merchant_id');
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Return the encryption password.
|
160 |
+
*
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function getEncryptionPassword()
|
164 |
+
{
|
165 |
+
return Mage::getStoreConfig(self::CONNECTION_SETTINGS_DEFAULT_PATH.'/encryption_password');
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Return the hmac salt.
|
171 |
+
*
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
public function getHmac()
|
175 |
+
{
|
176 |
+
return Mage::getStoreConfig(self::CONNECTION_SETTINGS_DEFAULT_PATH.'/hmac_salt');
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Return the base url.
|
182 |
+
*
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function getBaseUrl()
|
186 |
+
{
|
187 |
+
return Mage::getStoreConfig(self::CONNECTION_SETTINGS_DEFAULT_PATH.'/baseurl');
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Return the field from the given payment code.
|
193 |
+
*
|
194 |
+
* @param string $payment
|
195 |
+
* @param string $field
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
+
public function getPaymentField($payment, $field)
|
199 |
+
{
|
200 |
+
return Mage::getStoreConfig(sprintf(self::PAYMENT_SETTINGS_PATH, $payment).'/'.$field);
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Load the stored merchant accounts from the given payment.
|
206 |
+
*
|
207 |
+
* @param string $payment
|
208 |
+
*/
|
209 |
+
protected function _loadSpecificMerchantSettingsFromPayment($payment)
|
210 |
+
{
|
211 |
+
//If the key already exists we don't need to do anything
|
212 |
+
if (array_key_exists($payment, $this->_getAdditionalMerchantSettingsByCurrency())) {
|
213 |
+
return;
|
214 |
+
}
|
215 |
+
|
216 |
+
//Get the payment merchant accounts
|
217 |
+
$merchantAccounts = Mage::getStoreConfig(
|
218 |
+
sprintf(self::CONNECTION_PAYMENT_MERCHANT_PATH, $payment).
|
219 |
+
'/merchant_account_info'
|
220 |
+
);
|
221 |
+
|
222 |
+
//Check the result for data
|
223 |
+
if (empty($merchantAccounts) || !is_string($merchantAccounts)) {
|
224 |
+
$this->_getAdditionalMerchantSettingsByCurrency()->setData($payment, array());
|
225 |
+
$this->_getAdditionalMerchantSettingsByMerchantId()->setData($payment, array());
|
226 |
+
return;
|
227 |
+
}
|
228 |
+
|
229 |
+
//Suppress any output by unserializing
|
230 |
+
$merchantAccounts = @unserialize($merchantAccounts);
|
231 |
+
|
232 |
+
//Recheck the result
|
233 |
+
if (empty($merchantAccounts) || !is_array($merchantAccounts)) {
|
234 |
+
$this->_getAdditionalMerchantSettingsByCurrency()->setData($payment, array());
|
235 |
+
$this->_getAdditionalMerchantSettingsByMerchantId()->setData($payment, array());
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
|
239 |
+
//Map the currency as main key for the settings
|
240 |
+
$currencyMappedMerchantAccounts = $this->_getMappedSpecificAccountData('currency', $merchantAccounts);
|
241 |
+
|
242 |
+
//Map the id as main key for the settings
|
243 |
+
$idMappedMerchantAccounts = $this->_getMappedSpecificAccountData('id', $merchantAccounts);
|
244 |
+
|
245 |
+
//Add the data to the mapped array
|
246 |
+
$this->_getAdditionalMerchantSettingsByCurrency()->setData($payment, $currencyMappedMerchantAccounts);
|
247 |
+
$this->_getAdditionalMerchantSettingsByMerchantId()->setData($payment, $idMappedMerchantAccounts);
|
248 |
+
}
|
249 |
+
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Convert the given 2dim array with the call:
|
253 |
+
*
|
254 |
+
* $this->_getMappedSpecificAccountData('optionkey', array(...));
|
255 |
+
*
|
256 |
+
* From:
|
257 |
+
* Array
|
258 |
+
* (
|
259 |
+
* [_1258715461606_606] => Array
|
260 |
+
* (
|
261 |
+
* [optionkey] => DE
|
262 |
+
* [id] => DE_id
|
263 |
+
* [code] => DE_code
|
264 |
+
* )
|
265 |
+
* [_1258716196164_164] => Array
|
266 |
+
* (
|
267 |
+
* [optionkey] => US
|
268 |
+
* [id] => US_id
|
269 |
+
* [code] => Us_code
|
270 |
+
* )
|
271 |
+
* )
|
272 |
+
*
|
273 |
+
* To:
|
274 |
+
* Array
|
275 |
+
* (
|
276 |
+
* [de] => Array
|
277 |
+
* (
|
278 |
+
* [optionkey] => DE
|
279 |
+
* [id] => DE_id
|
280 |
+
* [code] => DE_code
|
281 |
+
* )
|
282 |
+
* [us] => Array
|
283 |
+
* (
|
284 |
+
* [optionkey] => US
|
285 |
+
* [id] => US_id
|
286 |
+
* [code] => Us_code
|
287 |
+
* )
|
288 |
+
* )
|
289 |
+
*
|
290 |
+
* by the given key.
|
291 |
+
*
|
292 |
+
* @param string $key
|
293 |
+
* @param array $array
|
294 |
+
* @return array
|
295 |
+
*/
|
296 |
+
protected function _getMappedSpecificAccountData($key, array $array)
|
297 |
+
{
|
298 |
+
$newArray = array();
|
299 |
+
|
300 |
+
//Map the value from the key as main key
|
301 |
+
foreach ($array as $data) {
|
302 |
+
if (is_array($data) && array_key_exists($key, $data)) {
|
303 |
+
//Default is case sensitive
|
304 |
+
$value = strtolower($data[$key]);
|
305 |
+
|
306 |
+
//Set the value as key with the information
|
307 |
+
$newArray[$value] = array_change_key_case($data, CASE_LOWER);
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
return $newArray;
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Return mapped data.
|
317 |
+
*
|
318 |
+
* @return Varien_Object
|
319 |
+
*/
|
320 |
+
protected function _getAdditionalMerchantSettingsByCurrency()
|
321 |
+
{
|
322 |
+
return $this->_additionalCurrencyMerchantSettings;
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Return mapped data.
|
328 |
+
*
|
329 |
+
* @return Varien_Object
|
330 |
+
*/
|
331 |
+
protected function _getAdditionalMerchantSettingsByMerchantId()
|
332 |
+
{
|
333 |
+
return $this->_additionalMerchantIdMerchantSettings;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* returns the store config: avaiable logos for computop_cc payment
|
338 |
+
* @return string
|
339 |
+
*/
|
340 |
+
public function getAvailableCcLogos()
|
341 |
+
{
|
342 |
+
return Mage::getStoreConfig(self::XML_PATH_AVAIABLE_CC_LOGOS);
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Converter.php
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Helper_Converter
|
12 |
+
extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Converts the given payment to magento */
|
16 |
+
const MAGENTO_TYPE = 1;
|
17 |
+
|
18 |
+
/** Converts the given type to computop */
|
19 |
+
const COMPUTOP_TYPE = 2;
|
20 |
+
|
21 |
+
|
22 |
+
/** Holds the types of the magento -> computop cc types */
|
23 |
+
protected $_ccTypeMap = null;
|
24 |
+
|
25 |
+
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
//Set the cc type map default direction is computop => magento
|
29 |
+
$this->_ccTypeMap = array(
|
30 |
+
'VISA' => 'VI',
|
31 |
+
'MasterCard' => 'MC',
|
32 |
+
'AMEX' => 'AE',
|
33 |
+
'SOLO' => 'SS',
|
34 |
+
'DINERS' => '',
|
35 |
+
'JCB' => '',
|
36 |
+
'CBN' => '',
|
37 |
+
'SWITCH' => '',
|
38 |
+
'ComfortCard' => '',
|
39 |
+
'Dankort' => '',
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return an amount to an computop specific amount.
|
45 |
+
*
|
46 |
+
* @param mixed $price
|
47 |
+
* @return integer
|
48 |
+
*/
|
49 |
+
public function formatPrice($amount, $currencyCode)
|
50 |
+
{
|
51 |
+
// don't use decimal digest for YEN
|
52 |
+
if ('JPY' === strtoupper($currencyCode)) {
|
53 |
+
return floor($amount);
|
54 |
+
}
|
55 |
+
return (int)number_format($amount, 2, '', '');
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Return the computop expire date.
|
61 |
+
*
|
62 |
+
* @param int $month
|
63 |
+
* @param int $year
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getComputopExpireDate($month, $year)
|
67 |
+
{
|
68 |
+
return sprintf('%d%02d', $year, $month);
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Return the full street address from the given address object.
|
74 |
+
*
|
75 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
76 |
+
* @return unknown
|
77 |
+
*/
|
78 |
+
public function getFullStreet(Mage_Customer_Model_Address_Abstract $address)
|
79 |
+
{
|
80 |
+
//Get the full street
|
81 |
+
$streetFull = $address->getStreetFull();
|
82 |
+
|
83 |
+
//Join the street data if we have more than one line
|
84 |
+
if (is_array($streetFull)) {
|
85 |
+
$streetFull = implode(' ', $streetFull);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $streetFull;
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Explodes the given name into first and lastname and add it to the
|
94 |
+
* also given adsress.
|
95 |
+
*
|
96 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
97 |
+
* @param string $name
|
98 |
+
* @return Dotsource_Computop_Helper_Converter
|
99 |
+
*/
|
100 |
+
public function setNameToAddress(Mage_Customer_Model_Address_Abstract $address, $name)
|
101 |
+
{
|
102 |
+
//Split the full name into first- and lastname
|
103 |
+
$names = explode(' ', $name, 2);
|
104 |
+
$address->setFirstname($names[0]);
|
105 |
+
if (isset($names[1])) {
|
106 |
+
$address->setLastname($names[1]);
|
107 |
+
}
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Convert the given string to an latin string.
|
114 |
+
* If the string can't convert the given string will
|
115 |
+
* return.
|
116 |
+
*
|
117 |
+
* @param string $string
|
118 |
+
*/
|
119 |
+
public function convertToLatin($string)
|
120 |
+
{
|
121 |
+
//Check if we need to convert the string
|
122 |
+
if ("UTF-8" == mb_detect_encoding($string, "UTF-8")
|
123 |
+
&& mb_check_encoding($string, "UTF-8")
|
124 |
+
) {
|
125 |
+
//Convert the string
|
126 |
+
$tmp = @iconv('UTF-8', 'ISO-8859-1', $string);
|
127 |
+
|
128 |
+
//Check if the conversion are successfully
|
129 |
+
if (!empty($string) && !empty($tmp)) {
|
130 |
+
return $tmp;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
//Fallback
|
135 |
+
return $string;
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Convert the given string to an utf8 string.
|
141 |
+
* If the string can't convert the given string will
|
142 |
+
* return.
|
143 |
+
*
|
144 |
+
* @param string $string
|
145 |
+
*/
|
146 |
+
public function convertToUtf8($string)
|
147 |
+
{
|
148 |
+
//Check if we need to convert the string
|
149 |
+
if ("UTF-8" != mb_detect_encoding($string, "UTF-8")
|
150 |
+
|| !mb_check_encoding($string, "UTF-8")
|
151 |
+
) {
|
152 |
+
//Convert the string
|
153 |
+
$tmp = @iconv('ISO-8859-1', 'UTF-8', $string);
|
154 |
+
|
155 |
+
//Check if the conversion are successfully
|
156 |
+
if (!empty($string) && !empty($tmp)) {
|
157 |
+
return $tmp;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
//Fallback
|
162 |
+
return $string;
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Convert a boolean to an integer.
|
168 |
+
* true = 1
|
169 |
+
* false = 0
|
170 |
+
*
|
171 |
+
* @param boolean $boolean
|
172 |
+
* @return int
|
173 |
+
*/
|
174 |
+
public function convertBooleanToInt($boolean)
|
175 |
+
{
|
176 |
+
//Check for boolean
|
177 |
+
if (!is_bool($boolean)) {
|
178 |
+
Mage::throwException('No boolean given.');
|
179 |
+
}
|
180 |
+
|
181 |
+
if ($boolean) {
|
182 |
+
return 1;
|
183 |
+
}
|
184 |
+
|
185 |
+
return 0;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Strip all dangerous tags from the content.
|
191 |
+
*
|
192 |
+
* @param array $tags
|
193 |
+
* @param Dotsource_Computop_Object $content
|
194 |
+
*/
|
195 |
+
public function stripDangerousTags(array $tags, Dotsource_Computop_Object $content)
|
196 |
+
{
|
197 |
+
//Strip the tags from the given object
|
198 |
+
foreach ($tags as $tag) {
|
199 |
+
//Override the value from the tag
|
200 |
+
if (array_key_exists($tag, $content)) {
|
201 |
+
$content[$tag] = '*';
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Return the converted cc type.
|
209 |
+
*
|
210 |
+
* @param string $ccType
|
211 |
+
* @param int $returnType
|
212 |
+
*/
|
213 |
+
public function getCcType($ccType, $returnType = self::MAGENTO_TYPE)
|
214 |
+
{
|
215 |
+
//Check for already right type is given
|
216 |
+
if (self::MAGENTO_TYPE == $returnType) {
|
217 |
+
if ($this->isMagentoCcType($ccType)) {
|
218 |
+
return strtoupper($ccType);
|
219 |
+
}
|
220 |
+
} else if (self::COMPUTOP_TYPE == $returnType) {
|
221 |
+
if ($this->isComputopCcType($ccType)) {
|
222 |
+
return $ccType;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
//Get the cc map array and lower case the keys
|
227 |
+
$ccMap = $this->_ccTypeMap;
|
228 |
+
$ccMap = array_change_key_case($ccMap, CASE_LOWER);
|
229 |
+
|
230 |
+
//If we want a computop type we need to flip the direction
|
231 |
+
if (self::COMPUTOP_TYPE == $returnType) {
|
232 |
+
$ccMap = array_flip($ccMap);
|
233 |
+
}
|
234 |
+
|
235 |
+
//Check if the key exists
|
236 |
+
$lowerCcType = strtolower($ccType);
|
237 |
+
$convertType = null;
|
238 |
+
if (array_key_exists($lowerCcType, $ccMap)) {
|
239 |
+
$convertType = $ccMap[$lowerCcType];
|
240 |
+
}
|
241 |
+
|
242 |
+
//if the value if empty we return the given type
|
243 |
+
if (empty($convertType)) {
|
244 |
+
if (self::MAGENTO_TYPE == $returnType) {
|
245 |
+
return 'OT';
|
246 |
+
}
|
247 |
+
|
248 |
+
//Default is the given one
|
249 |
+
return $ccType;
|
250 |
+
}
|
251 |
+
|
252 |
+
return $convertType;
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Check if the given cc type is in the magento format.
|
258 |
+
*
|
259 |
+
* @param string $type
|
260 |
+
* @return boolean
|
261 |
+
*/
|
262 |
+
public function isMagentoCcType($type)
|
263 |
+
{
|
264 |
+
return array_key_exists(
|
265 |
+
strtoupper($type),
|
266 |
+
Mage::getSingleton('payment/config')->getCcTypes()
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* check if the given type is a computop cc type.
|
273 |
+
*
|
274 |
+
* @param string $type
|
275 |
+
* @return boolean
|
276 |
+
*/
|
277 |
+
public function isComputopCcType($type)
|
278 |
+
{
|
279 |
+
$ccMap = $this->_ccTypeMap;
|
280 |
+
|
281 |
+
return array_key_exists(
|
282 |
+
strtolower($type),
|
283 |
+
array_change_key_case($ccMap, CASE_LOWER)
|
284 |
+
);
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Return the given id as transaction code.
|
290 |
+
*
|
291 |
+
* @param int $id
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
public function formatAsTransactionCode($id)
|
295 |
+
{
|
296 |
+
return (string)sprintf("%09s", $id);
|
297 |
+
}
|
298 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Data.php
ADDED
@@ -0,0 +1,636 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Helper_Data
|
11 |
+
extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Try to get the model from the right section */
|
15 |
+
const AUTO = 1;
|
16 |
+
|
17 |
+
/** Try to get the model from the frontend section */
|
18 |
+
const FRONTEND = 2;
|
19 |
+
|
20 |
+
/** Try to return the model from the backend section */
|
21 |
+
const BACKEND = 3;
|
22 |
+
|
23 |
+
|
24 |
+
/** Holds the computop encryption model */
|
25 |
+
protected $_encryptor = null;
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return the encryptor.
|
30 |
+
*
|
31 |
+
* @return Dotsource_Computop_Model_Encryption
|
32 |
+
*/
|
33 |
+
public function getEncryptor()
|
34 |
+
{
|
35 |
+
if (is_null($this->_encryptor)) {
|
36 |
+
$this->_encryptor = Mage::getModel('computop/encryption');
|
37 |
+
$this->_encryptor->setHelper($this);
|
38 |
+
}
|
39 |
+
|
40 |
+
return $this->_encryptor;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return the current in use transaction model.
|
46 |
+
*
|
47 |
+
* @param int $transactionId
|
48 |
+
* @return Dotsource_Computop_Model_Transaction
|
49 |
+
*/
|
50 |
+
public function getTransactionModel(
|
51 |
+
$transactionId = null,
|
52 |
+
$section = self::AUTO
|
53 |
+
)
|
54 |
+
{
|
55 |
+
if (self::AUTO == $section) {
|
56 |
+
if ($this->isFrontend()) {
|
57 |
+
return $this->getFrontendTransactionModel($transactionId);
|
58 |
+
} else {
|
59 |
+
return $this->getBackendTransactionModel($transactionId);
|
60 |
+
}
|
61 |
+
} elseif (self::FRONTEND == $section) {
|
62 |
+
return $this->getFrontendTransactionModel($transactionId);
|
63 |
+
} elseif (self::BACKEND == $section) {
|
64 |
+
return $this->getBackendTransactionModel($transactionId);
|
65 |
+
}
|
66 |
+
|
67 |
+
//Something is wrong
|
68 |
+
Mage::throwException(
|
69 |
+
'No logic available for this area %s to get the transaction model',
|
70 |
+
Mage::getDesign()->getArea()
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Try to load a transaction model from the given transaction id
|
77 |
+
* or get the transaction model from the session or create a new one.
|
78 |
+
*
|
79 |
+
* @param int $transactionId
|
80 |
+
* @return Dotsource_Computop_Model_Transaction
|
81 |
+
*/
|
82 |
+
public function getFrontendTransactionModel($transactionId = null)
|
83 |
+
{
|
84 |
+
$session = Mage::getSingleton('computop/session');
|
85 |
+
|
86 |
+
if (null !== $transactionId) {
|
87 |
+
$session->setTransactionModelId($transactionId);
|
88 |
+
}
|
89 |
+
|
90 |
+
return $session->getTransactionModel();
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Logic for saving the current transaction model in the backend area.
|
96 |
+
*
|
97 |
+
* @param mixed $transactionId
|
98 |
+
* @return Dotsource_Computop_Model_Transaction
|
99 |
+
*/
|
100 |
+
public function getBackendTransactionModel($transactionId = null)
|
101 |
+
{
|
102 |
+
//Try to get the model from the registry
|
103 |
+
$transactionModel = $this->getTransactionModelFromRegistry();
|
104 |
+
|
105 |
+
if (!empty($transactionId)) {
|
106 |
+
//Check if we have the right model
|
107 |
+
if (!$this->_isValidTransactionModel($transactionModel, $transactionId)) {
|
108 |
+
//Load the model from the reference id
|
109 |
+
$transactionModel = Mage::getModel('computop/transaction')
|
110 |
+
->load($transactionId);
|
111 |
+
|
112 |
+
//Add the model to the registry
|
113 |
+
$this->addTransactionModelToRegistry($transactionModel);
|
114 |
+
}
|
115 |
+
} else { //No transaction id is given we can only return the current model from the registry
|
116 |
+
if (!$this->_isValidTransactionModel($transactionModel)) {
|
117 |
+
Mage::throwException("Can't get any transaction model.");
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
//Return the valid model
|
122 |
+
return $transactionModel;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Add the transaction model to the registry.
|
128 |
+
*
|
129 |
+
* @return Dotsource_Computop_Model_Transaction
|
130 |
+
*/
|
131 |
+
public function getTransactionModelFromRegistry()
|
132 |
+
{
|
133 |
+
return Mage::registry('transactionModel');
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Add the transaction model to the registry.
|
139 |
+
*
|
140 |
+
* @param Dotsource_Computop_Model_Transaction $model
|
141 |
+
* @return Dotsource_Computop_Model_Transaction
|
142 |
+
*/
|
143 |
+
public function addTransactionModelToRegistry(Dotsource_Computop_Model_Transaction $model)
|
144 |
+
{
|
145 |
+
//Check if the transaction model is valid
|
146 |
+
if ($this->_isValidTransactionModel($model)) {
|
147 |
+
Mage::unregister('transactionModel');
|
148 |
+
Mage::register('transactionModel', $model);
|
149 |
+
} else {
|
150 |
+
Mage::throwException("The given transaction model is not valid.");
|
151 |
+
}
|
152 |
+
|
153 |
+
return $model;
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Check if a Transaction model is valid
|
159 |
+
*
|
160 |
+
* @param mixed $model
|
161 |
+
* @param int $transactionId
|
162 |
+
*/
|
163 |
+
protected function _isValidTransactionModel($model, $transactionId = null)
|
164 |
+
{
|
165 |
+
return !empty($model)
|
166 |
+
&& $model instanceof Dotsource_Computop_Model_Transaction
|
167 |
+
&& (null === $transactionId || $transactionId == $model->getId());
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Check if a customer model is available.
|
173 |
+
*
|
174 |
+
* @return boolean
|
175 |
+
*/
|
176 |
+
public function isCustomerAvailable($section = self::AUTO)
|
177 |
+
{
|
178 |
+
if (self::AUTO == $section) {
|
179 |
+
if ($this->isFrontend()) {
|
180 |
+
return Mage::getSingleton('customer/session')->isLoggedIn();
|
181 |
+
} else {
|
182 |
+
$section = self::BACKEND;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
//Get the customer
|
187 |
+
$customer = $this->getCustomer($section);
|
188 |
+
|
189 |
+
//check for valid customer
|
190 |
+
return !empty($customer)
|
191 |
+
&& $customer instanceof Mage_Customer_Model_Customer
|
192 |
+
&& $customer->hasData();
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Return the customer object from the quote.
|
198 |
+
*
|
199 |
+
* @return Mage_Customer_Model_Customer
|
200 |
+
*/
|
201 |
+
public function getCustomer($section = self::AUTO)
|
202 |
+
{
|
203 |
+
return $this->getQuote($section)->getCustomer();
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Return the quote from the session.
|
209 |
+
*
|
210 |
+
* @return Mage_Sales_Model_Quote
|
211 |
+
*/
|
212 |
+
public function getQuote($section = self::AUTO)
|
213 |
+
{
|
214 |
+
return $this->getCheckoutSession($section)->getQuote();
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Return the current using session.
|
220 |
+
*
|
221 |
+
* @return Mage_Checkout_Model_Session
|
222 |
+
*/
|
223 |
+
public function getCheckoutSession($section = self::AUTO)
|
224 |
+
{
|
225 |
+
if (self::AUTO == $section) {
|
226 |
+
if ($this->isFrontend()) {
|
227 |
+
return $this->getFrontendCheckoutSession();
|
228 |
+
} else {
|
229 |
+
return $this->getBackendCheckoutSession();
|
230 |
+
}
|
231 |
+
} else if(self::FRONTEND == $section) {
|
232 |
+
return $this->getFrontendCheckoutSession();
|
233 |
+
} else if(self::BACKEND == $section) {
|
234 |
+
return $this->getBackendCheckoutSession();
|
235 |
+
}
|
236 |
+
|
237 |
+
//Something is wrong
|
238 |
+
Mage::throwException(
|
239 |
+
'No logic available for this area %s to get the transaction model',
|
240 |
+
Mage::getDesign()->getArea()
|
241 |
+
);
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Log the given data.
|
247 |
+
*
|
248 |
+
* @param mixed $data
|
249 |
+
* @param string $prefix
|
250 |
+
* @return Dotsource_Computop_Helper_Data
|
251 |
+
*/
|
252 |
+
public function Log($data, $prefix = null)
|
253 |
+
{
|
254 |
+
//Only debug in demo mode
|
255 |
+
if (!$this->isDemoMode()) {
|
256 |
+
return $this;
|
257 |
+
}
|
258 |
+
|
259 |
+
//If we got an object it's better to clone
|
260 |
+
if (is_object($data)) {
|
261 |
+
$data = clone $data;
|
262 |
+
}
|
263 |
+
|
264 |
+
//Setup the prefix
|
265 |
+
if (is_string($prefix)) {
|
266 |
+
$prefix = "\n$prefix:\n";
|
267 |
+
} else {
|
268 |
+
$prefix = '';
|
269 |
+
}
|
270 |
+
|
271 |
+
//If we got an Varien_Object (includes Dotsource_Computop_Object)
|
272 |
+
if ($data instanceof Varien_Object) {
|
273 |
+
//Get the array
|
274 |
+
$dataArray = $data->getData();
|
275 |
+
|
276 |
+
//change the key case to lower case
|
277 |
+
$dataArray = array_change_key_case($dataArray, CASE_LOWER);
|
278 |
+
|
279 |
+
//Additional logging handling for Dotsource_Computop_Object objects
|
280 |
+
if ($data instanceof Dotsource_Computop_Object) {
|
281 |
+
//Decrypt the request
|
282 |
+
if ($data->hasEncryptor()
|
283 |
+
&& array_key_exists('data', $dataArray)
|
284 |
+
&& is_string($dataArray['data'])
|
285 |
+
) {
|
286 |
+
$dataArray = $data->getEncryptor()->decrypt($dataArray['data']);
|
287 |
+
$dataArray = array_change_key_case($dataArray, CASE_LOWER);
|
288 |
+
}
|
289 |
+
|
290 |
+
//Decrypt the userdata
|
291 |
+
if (array_key_exists('userdata', $dataArray)) {
|
292 |
+
if (is_string($dataArray['userdata'])) {
|
293 |
+
$tmp = new Dotsource_Computop_Object();
|
294 |
+
$tmp->setData(base64_decode($dataArray['userdata']));
|
295 |
+
|
296 |
+
$dataArray['userdata'] = $tmp->getData();
|
297 |
+
} elseif ($dataArray['userdata'] instanceof Varien_Object) {
|
298 |
+
$dataArray['userdata'] = $dataArray['userdata']->getData();
|
299 |
+
}
|
300 |
+
|
301 |
+
//lower case for user data
|
302 |
+
if (is_array($dataArray['userdata'])) {
|
303 |
+
$dataArray['userdata'] = array_change_key_case($dataArray['userdata'], CASE_LOWER);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
//Override
|
309 |
+
$data = $dataArray;
|
310 |
+
}
|
311 |
+
|
312 |
+
//Convert the array to string
|
313 |
+
if (is_array($data)) {
|
314 |
+
$data = $this->_getString($data);
|
315 |
+
}
|
316 |
+
|
317 |
+
//We need an string to log
|
318 |
+
Mage::log("$prefix$data\n", null, 'computop_connection.log');
|
319 |
+
|
320 |
+
return $this;
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Helper for process array in array constructs.
|
326 |
+
*
|
327 |
+
* @param array $data
|
328 |
+
* @param string $glue
|
329 |
+
* @param string $prefix
|
330 |
+
* @param string $suffix
|
331 |
+
* @param string $appendPrefix
|
332 |
+
* @return string
|
333 |
+
*/
|
334 |
+
protected function _getString(array $data, $glue = ' = ', $prefix = "\t", $suffix = "\n", $appendPrefix = null)
|
335 |
+
{
|
336 |
+
//Holds the string
|
337 |
+
$string = "";
|
338 |
+
|
339 |
+
//Use the current prefix as append prefix for the next recursion
|
340 |
+
if (null === $appendPrefix) {
|
341 |
+
$appendPrefix = $prefix;
|
342 |
+
}
|
343 |
+
|
344 |
+
foreach ($data as $key => $value) {
|
345 |
+
$valueFromRecursion = false;
|
346 |
+
$key = $this->getConverter()->convertToUtf8($key);
|
347 |
+
|
348 |
+
//Convert logic
|
349 |
+
if ($value instanceof Varien_Object) {
|
350 |
+
$value = $value->getData();
|
351 |
+
}
|
352 |
+
|
353 |
+
if (is_array($value)) {
|
354 |
+
$valueFromRecursion = true;
|
355 |
+
//Recursion add the suffix as prefix for the recursion string
|
356 |
+
$value = $this->_getString($value, $glue, $prefix . $appendPrefix, $suffix, $appendPrefix);
|
357 |
+
} else if (is_object($value)) {
|
358 |
+
$value = 'Object class ' . get_class($value);
|
359 |
+
} else if (is_resource($value)) {
|
360 |
+
$value = 'Resource type ' . get_resource_type($value);
|
361 |
+
} else {
|
362 |
+
$value = $this->getConverter()->convertToUtf8($value);
|
363 |
+
}
|
364 |
+
|
365 |
+
//Create the string
|
366 |
+
if (!$valueFromRecursion) {
|
367 |
+
$string .= $prefix . '[' . $key . ']' . $glue . $value . $suffix;
|
368 |
+
} else {
|
369 |
+
$string .= $prefix . '[' . $key . ']' . $glue . $suffix . $value;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
return $string;
|
374 |
+
}
|
375 |
+
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Reactivate the given quote id ($quoteId) in the given section ($section).
|
379 |
+
*
|
380 |
+
* If no quote if was given the method will reactivate the quote id which is
|
381 |
+
* placed in the checkout session as 'last_quote_id'.
|
382 |
+
*
|
383 |
+
* If a active quote should be replaced the $forceReplace is need to set true.
|
384 |
+
* The current quote will deactivated and replaced with the given quoted id.
|
385 |
+
*
|
386 |
+
* @param int $quoteId
|
387 |
+
* @param int $section
|
388 |
+
* @param boolean $forceReplace
|
389 |
+
* @return unknown
|
390 |
+
*/
|
391 |
+
public function restoreQuote($quoteId = null, $section = self::AUTO, $forceReplace = false)
|
392 |
+
{
|
393 |
+
//Checkout session
|
394 |
+
$session = $this->getCheckoutSession($section);
|
395 |
+
|
396 |
+
//Try to get the last used quote id
|
397 |
+
if (null === $quoteId) {
|
398 |
+
$quoteId = $session->getLastQuoteId();
|
399 |
+
}
|
400 |
+
|
401 |
+
//We need a quote id for restoring
|
402 |
+
if (empty($quoteId)) {
|
403 |
+
return $this;
|
404 |
+
}
|
405 |
+
|
406 |
+
//Get the current quote
|
407 |
+
$currentQuote = $session->getQuote();
|
408 |
+
$validCurrentQuote = $currentQuote instanceof Mage_Sales_Model_Quote
|
409 |
+
&& (boolean)$currentQuote->getId();
|
410 |
+
|
411 |
+
//Check for reactivating the current quote
|
412 |
+
if ($validCurrentQuote && $quoteId == $currentQuote->getId()) {
|
413 |
+
//Reactive the current quote if needed
|
414 |
+
if (!$currentQuote->getData('is_active')) {
|
415 |
+
$currentQuote->setData('is_active', 1)->save();
|
416 |
+
}
|
417 |
+
} else {
|
418 |
+
//If we should forced to replace, deactivate the current quote if needed
|
419 |
+
if ($forceReplace && $validCurrentQuote && $currentQuote->getData('is_active')) {
|
420 |
+
$currentQuote->setData('is_active', 0)->save();
|
421 |
+
}
|
422 |
+
|
423 |
+
//Reactivate the given quote id only if we don't have a valid current quote
|
424 |
+
//or the current quote if not activate
|
425 |
+
if (!$validCurrentQuote || !$currentQuote->getData('is_active')) {
|
426 |
+
$restoreQuote = Mage::getModel('sales/quote')->load($quoteId);
|
427 |
+
|
428 |
+
//Reactivate the last quote if possible
|
429 |
+
if ($restoreQuote instanceof Mage_Sales_Model_Quote && $restoreQuote->getId()) {
|
430 |
+
//Reactivate
|
431 |
+
$restoreQuote->setData('is_active', 1)->save();
|
432 |
+
|
433 |
+
//Set in current session
|
434 |
+
$session->replaceQuote($restoreQuote);
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
return $this;
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Return the frontend quote.
|
445 |
+
*
|
446 |
+
* @return Mage_Sales_Model_Quote
|
447 |
+
*/
|
448 |
+
public function getFrontendQuote()
|
449 |
+
{
|
450 |
+
return $this->getFrontendCheckoutSession()->getQuote();
|
451 |
+
}
|
452 |
+
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Return the backend quote.
|
456 |
+
*
|
457 |
+
* @return Mage_Sales_Model_Quote
|
458 |
+
*/
|
459 |
+
public function getBackendQuote()
|
460 |
+
{
|
461 |
+
return $this->getBackendCheckoutSession()->getQuote();
|
462 |
+
}
|
463 |
+
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Return the frontend checkout session.
|
467 |
+
*
|
468 |
+
* @return Mage_Checkout_Model_Session
|
469 |
+
*/
|
470 |
+
public function getFrontendCheckoutSession()
|
471 |
+
{
|
472 |
+
return Mage::getSingleton('checkout/session');
|
473 |
+
}
|
474 |
+
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Return the backend checkout session.
|
478 |
+
*
|
479 |
+
* @return Mage_Adminhtml_Model_Session_Quote
|
480 |
+
*/
|
481 |
+
public function getBackendCheckoutSession()
|
482 |
+
{
|
483 |
+
return Mage::getSingleton('adminhtml/sales_order_create')->getSession();
|
484 |
+
}
|
485 |
+
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Return true if the design area is frontend and the the
|
489 |
+
* cronjob flag are not set.
|
490 |
+
*
|
491 |
+
* @return boolean
|
492 |
+
*/
|
493 |
+
public function isFrontend()
|
494 |
+
{
|
495 |
+
return Mage_Core_Model_App_Area::AREA_FRONTEND == Mage::getDesign()->getArea()
|
496 |
+
&& !$this->isCronJob();
|
497 |
+
}
|
498 |
+
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Return if the current magento is in backend.
|
502 |
+
*
|
503 |
+
* @return boolean
|
504 |
+
*/
|
505 |
+
public function isBackend()
|
506 |
+
{
|
507 |
+
return 'adminhtml' == Mage::getDesign()->getArea();
|
508 |
+
}
|
509 |
+
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Return true if the regitry key 'cronjob' is true.
|
513 |
+
*
|
514 |
+
* @return boolean
|
515 |
+
*/
|
516 |
+
public function isCronJob()
|
517 |
+
{
|
518 |
+
return is_bool(Mage::registry('cronjob')) && Mage::registry('cronjob');
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Set the cronjob area the active in the registry.
|
524 |
+
*/
|
525 |
+
public function enableCronJobArea()
|
526 |
+
{
|
527 |
+
Mage::register('cronjob', true, true);
|
528 |
+
}
|
529 |
+
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Return true if computop is in demo modus.
|
533 |
+
*
|
534 |
+
* @return boolean
|
535 |
+
*/
|
536 |
+
public function isDemoMode()
|
537 |
+
{
|
538 |
+
return Mage::registry('computopDemoMode') || isset($_SERVER['COMPUTOP_DEMO_MODE']);
|
539 |
+
}
|
540 |
+
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Return true if the modul can use.
|
544 |
+
*
|
545 |
+
* @param boolean $ignoreDemoMode
|
546 |
+
* @return boolean
|
547 |
+
*/
|
548 |
+
public function isGlobalActive($ignoreDemoMode = false)
|
549 |
+
{
|
550 |
+
return ($this->isDemoMode() && !$ignoreDemoMode)
|
551 |
+
|| $this->isHttpsUrl(
|
552 |
+
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)
|
553 |
+
);
|
554 |
+
}
|
555 |
+
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Return true if the given url begins with https.
|
559 |
+
*
|
560 |
+
* @param string $url
|
561 |
+
* @return bool
|
562 |
+
*/
|
563 |
+
public function isHttpsUrl($url)
|
564 |
+
{
|
565 |
+
return $this->isStringStartsWith(trim($url), 'https://');
|
566 |
+
}
|
567 |
+
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Checks if the haystack starts with the given needel.
|
571 |
+
*
|
572 |
+
* @param string $haystack
|
573 |
+
* @param string $needel
|
574 |
+
* @return boolean
|
575 |
+
*/
|
576 |
+
public function isStringStartsWith($haystack, $needel)
|
577 |
+
{
|
578 |
+
return 0 === strcasecmp($needel, substr($haystack, 0, strlen($needel)));
|
579 |
+
}
|
580 |
+
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Return the computop converter.
|
584 |
+
*
|
585 |
+
* @return Dotsource_Computop_Helper_Converter
|
586 |
+
*/
|
587 |
+
public function getConverter()
|
588 |
+
{
|
589 |
+
return Mage::helper('computop/converter');
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Return the computop configuration model.
|
595 |
+
*
|
596 |
+
* @return Dotsource_Computop_Helper_Config
|
597 |
+
*/
|
598 |
+
public function getConfiguration()
|
599 |
+
{
|
600 |
+
return Mage::helper('computop/config');
|
601 |
+
}
|
602 |
+
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Return the payment helper.
|
606 |
+
*
|
607 |
+
* @return Dotsource_Computop_Helper_Payment
|
608 |
+
*/
|
609 |
+
public function getPaymentHelper()
|
610 |
+
{
|
611 |
+
return Mage::helper('computop/payment');
|
612 |
+
}
|
613 |
+
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Return the feature helper.
|
617 |
+
*
|
618 |
+
* @return Dotsource_Computop_Helper_Feature
|
619 |
+
*/
|
620 |
+
public function getFeatureHelper()
|
621 |
+
{
|
622 |
+
return Mage::helper('computop/feature');
|
623 |
+
}
|
624 |
+
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Indicates if the payment logos should be shown in the cheakout
|
628 |
+
* process beneath the payment method.
|
629 |
+
*
|
630 |
+
* @return boolean
|
631 |
+
*/
|
632 |
+
public function canShowPaymentLogo()
|
633 |
+
{
|
634 |
+
return true;
|
635 |
+
}
|
636 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Feature.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Helper_Feature
|
11 |
+
extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds if the current magento instance has flat tables */
|
15 |
+
protected $_hasFlatTables = null;
|
16 |
+
|
17 |
+
/** Holds if the current magento instance has grid tables */
|
18 |
+
protected $_hasGridTables = null;
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Return if the current magento instance has support for flat tables.
|
23 |
+
*
|
24 |
+
* @return boolean
|
25 |
+
*/
|
26 |
+
public function hasFlatTables()
|
27 |
+
{
|
28 |
+
if (null === $this->_hasFlatTables) {
|
29 |
+
//TODO: Don't compare magento version check the database for sales_flat_order
|
30 |
+
$this->_hasFlatTables = version_compare(Mage::getVersion(), '1.4.1.0', '>=');
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->_hasFlatTables;
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Return if the current magento instance has support for grid tables.
|
39 |
+
*
|
40 |
+
* @return boolean
|
41 |
+
*/
|
42 |
+
public function hasGridTables()
|
43 |
+
{
|
44 |
+
if (null === $this->_hasGridTables) {
|
45 |
+
$this->_hasGridTables = (boolean)@Mage::getResourceSingleton('sales/order_grid_collection');
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->_hasGridTables;
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Payment.php
ADDED
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Helper_Payment
|
11 |
+
extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the payment information cache */
|
15 |
+
protected static $_paymentCache = array();
|
16 |
+
|
17 |
+
/** Holds the prefix for the disable paymentss */
|
18 |
+
protected $_disablePaymentKey = "disable_payments";
|
19 |
+
|
20 |
+
/** Holds the disable time for the current session */
|
21 |
+
protected $_disableTimeForCheckout = 86400;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Add general information to the transaction payment model.
|
26 |
+
*
|
27 |
+
* @param Mage_Payment_Model_Info $payment
|
28 |
+
* @param Dotsource_Computop_Model_Payment_Response_Response $response
|
29 |
+
*/
|
30 |
+
public function addTransactionInfoToPayment(
|
31 |
+
Mage_Payment_Model_Info $payment,
|
32 |
+
Dotsource_Computop_Model_Payment_Response_Response $response
|
33 |
+
) {
|
34 |
+
//Use the xid as transaction id
|
35 |
+
$payment
|
36 |
+
->setPreparedMessage(Dotsource_Computop_Model_Payment_Abstract::COMPUTOP_PREFIX)
|
37 |
+
->setTransactionId($response->getResponse()->getXid());
|
38 |
+
|
39 |
+
//Add the payid to the additional payment information
|
40 |
+
$payment->setTransactionAdditionalInfo(
|
41 |
+
'payid',
|
42 |
+
$response->getResponse()->getPayid()
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Return the last eft payment informations.
|
49 |
+
* Returns:
|
50 |
+
* - eft_owner
|
51 |
+
* - eft_ban_enc
|
52 |
+
* - eft_bcn
|
53 |
+
*
|
54 |
+
* @param string $paymentCode
|
55 |
+
* @return Varien_Object
|
56 |
+
*/
|
57 |
+
public function getLastEftPaymentinformation($paymentCode)
|
58 |
+
{
|
59 |
+
return $this->getLastPaymentInformation(
|
60 |
+
$paymentCode,
|
61 |
+
array(
|
62 |
+
'eft_owner',
|
63 |
+
'eft_ban_enc',
|
64 |
+
'eft_bcn',
|
65 |
+
)
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Return the last eft payment informations.
|
72 |
+
* Returns:
|
73 |
+
* - cc_number_enc
|
74 |
+
* - cc_last4
|
75 |
+
* - cc_exp_year
|
76 |
+
* - cc_exp_month
|
77 |
+
* - cc_type
|
78 |
+
*
|
79 |
+
* @param string $paymentCode
|
80 |
+
* @return Varien_Object
|
81 |
+
*/
|
82 |
+
public function getLastCcPaymentinformation($paymentCode)
|
83 |
+
{
|
84 |
+
return $this->getLastPaymentInformation(
|
85 |
+
$paymentCode,
|
86 |
+
array(
|
87 |
+
'cc_number_enc',
|
88 |
+
'cc_last4',
|
89 |
+
'cc_exp_year',
|
90 |
+
'cc_exp_month',
|
91 |
+
'cc_type',
|
92 |
+
)
|
93 |
+
);
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Return the last used payment information from the user.
|
99 |
+
*
|
100 |
+
* @param string $paymentCode
|
101 |
+
* @return Varien_Object
|
102 |
+
*/
|
103 |
+
public function getLastPaymentInformation($paymentCode, array $paymentFields)
|
104 |
+
{
|
105 |
+
//Holds the payment information
|
106 |
+
$paymentInformation = new Varien_Object();
|
107 |
+
|
108 |
+
//Payment code is needed and fields also
|
109 |
+
if (empty($paymentCode) || empty($paymentFields)) {
|
110 |
+
return $paymentInformation;
|
111 |
+
}
|
112 |
+
|
113 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
114 |
+
$customer = $this->_getHelper()->getCustomer();
|
115 |
+
|
116 |
+
//Check if we have a customer id
|
117 |
+
if (!$customer instanceof Mage_Customer_Model_Customer || !$customer->getId()) {
|
118 |
+
return $paymentInformation;
|
119 |
+
}
|
120 |
+
|
121 |
+
//Attributes are only need once and sort for the cache key
|
122 |
+
$paymentFields = array_unique($paymentFields);
|
123 |
+
natcasesort($paymentFields);
|
124 |
+
|
125 |
+
//Build the cache key
|
126 |
+
$cacheKey = md5("{$customer->getId()}$paymentCode".implode('', $paymentFields));
|
127 |
+
|
128 |
+
//Return the cache key
|
129 |
+
if (array_key_exists($cacheKey, self::$_paymentCache)) {
|
130 |
+
return self::$_paymentCache[$cacheKey];
|
131 |
+
} else { //Set the empty object as default cached value
|
132 |
+
self::$_paymentCache[$cacheKey] = $paymentInformation;
|
133 |
+
}
|
134 |
+
|
135 |
+
/* @var $order Mage_Sales_Model_Mysql4_Order_Collection */
|
136 |
+
$order = Mage::getResourceModel('sales/order_collection');
|
137 |
+
|
138 |
+
//Get only orders from the current customer
|
139 |
+
$order
|
140 |
+
->addAttributeToFilter('customer_id', $customer->getId())
|
141 |
+
->addFieldToFilter(
|
142 |
+
'status',
|
143 |
+
array(
|
144 |
+
'nin' => array(
|
145 |
+
Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE,
|
146 |
+
Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION,
|
147 |
+
Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE,
|
148 |
+
)
|
149 |
+
)
|
150 |
+
);
|
151 |
+
|
152 |
+
//Get the select and reset the selected data
|
153 |
+
$order->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
154 |
+
|
155 |
+
//Bridge for eav or flat tables
|
156 |
+
if (version_compare(Mage::getVersion(), '1.4.1.0', '<')) {
|
157 |
+
$order = $this->_getLastPaymentInformationSqlForEav($paymentCode, $paymentFields, $order);
|
158 |
+
} else {
|
159 |
+
$order = $this->_getLastPaymentInformationSqlForFlatTables($paymentCode, $paymentFields, $order);
|
160 |
+
}
|
161 |
+
|
162 |
+
//Get the select from the returned collection object
|
163 |
+
$select = $order->getSelect();
|
164 |
+
|
165 |
+
//Only get the last payment information
|
166 |
+
$select->limit(1);
|
167 |
+
|
168 |
+
//Get the first row
|
169 |
+
$result = $order->getResource()->getReadConnection()->fetchRow($select);
|
170 |
+
|
171 |
+
//Check for data
|
172 |
+
if (empty($result) || !is_array($result)) {
|
173 |
+
return $paymentInformation;
|
174 |
+
}
|
175 |
+
|
176 |
+
//Set the selected fields
|
177 |
+
return $paymentInformation->setData($result);
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Join the flat tables.
|
183 |
+
*
|
184 |
+
* @param string $paymentCode
|
185 |
+
* @param array $paymentFields
|
186 |
+
* @param Mage_Sales_Model_Mysql4_Order_Collection $order
|
187 |
+
* @return Mage_Sales_Model_Mysql4_Order_Collection
|
188 |
+
*/
|
189 |
+
public function _getLastPaymentInformationSqlForFlatTables(
|
190 |
+
$paymentCode,
|
191 |
+
array $paymentFields,
|
192 |
+
Mage_Sales_Model_Mysql4_Order_Collection $order
|
193 |
+
)
|
194 |
+
{
|
195 |
+
//Get the select object
|
196 |
+
$select = $order->getSelect();
|
197 |
+
|
198 |
+
//Join the payment information
|
199 |
+
$select
|
200 |
+
->joinLeft(
|
201 |
+
array('payment' => $order->getTable('sales/order_payment')),
|
202 |
+
'payment.parent_id=main_table.entity_id',
|
203 |
+
$paymentFields
|
204 |
+
)
|
205 |
+
->where('payment.method=?', $paymentCode);
|
206 |
+
|
207 |
+
return $order;
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Join the eav attributes.
|
213 |
+
*
|
214 |
+
* @param string $paymentCode
|
215 |
+
* @param array $paymentFields
|
216 |
+
* @param Mage_Sales_Model_Mysql4_Order_Collection $order
|
217 |
+
* @return Mage_Sales_Model_Mysql4_Order_Collection
|
218 |
+
*/
|
219 |
+
public function _getLastPaymentInformationSqlForEav(
|
220 |
+
$paymentCode,
|
221 |
+
array $paymentFields,
|
222 |
+
Mage_Sales_Model_Mysql4_Order_Collection $order
|
223 |
+
)
|
224 |
+
{
|
225 |
+
/* @var $attributeModel Mage_Eav_Model_Config */
|
226 |
+
$attributeModel = Mage::getSingleton('eav/config');
|
227 |
+
$paymentMethodAttribute = $attributeModel->getAttribute('order_payment', 'method');
|
228 |
+
$select = $order->getSelect();
|
229 |
+
|
230 |
+
//Join the payment id and the payment method
|
231 |
+
$select->joinLeft(
|
232 |
+
array('payment' => $order->getTable('sales/order_entity')),
|
233 |
+
'payment.parent_id=e.entity_id AND '
|
234 |
+
. 'payment.entity_type_id=' . $paymentMethodAttribute->getEntityTypeId(),
|
235 |
+
array(/*'payment_id' => 'value'*/)
|
236 |
+
)
|
237 |
+
->joinInner(
|
238 |
+
array('_table_payment_method' => $paymentMethodAttribute->getBackendTable()),
|
239 |
+
'payment.entity_id=_table_payment_method.entity_id AND '
|
240 |
+
. '_table_payment_method.attribute_id=' . $paymentMethodAttribute->getId(),
|
241 |
+
array(/*'payment_method' => 'value'*/)
|
242 |
+
);
|
243 |
+
|
244 |
+
//Join the payment fields
|
245 |
+
foreach ($paymentFields as $field) {
|
246 |
+
$attribute = $attributeModel->getAttribute('order_payment', $field);
|
247 |
+
|
248 |
+
if ($attribute->hasData() && $attribute->getId()) {
|
249 |
+
//Build a table name
|
250 |
+
$tableName = "_table_$field";
|
251 |
+
|
252 |
+
//Join the attribute
|
253 |
+
$select
|
254 |
+
->joinInner(
|
255 |
+
array($tableName => $attribute->getBackendTable()),
|
256 |
+
"payment.entity_id=$tableName.entity_id AND $tableName.attribute_id={$attribute->getId()}",
|
257 |
+
array($field => 'value')
|
258 |
+
);
|
259 |
+
} else {
|
260 |
+
Mage::throwException("Can't find the attribute \"$field\" of the \"order_payment\" entity.");
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
//Only get the last payment information
|
265 |
+
$select
|
266 |
+
->order('e.created_at DESC')
|
267 |
+
->where('_table_payment_method.value=?', $paymentCode);
|
268 |
+
|
269 |
+
return $order;
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Return true if the amount is zero.
|
275 |
+
*
|
276 |
+
* @param float $amount
|
277 |
+
* @param float $lambda
|
278 |
+
* @return boolean
|
279 |
+
*/
|
280 |
+
public function isZeroAmount($amount, $lambda = 0.0001)
|
281 |
+
{
|
282 |
+
return !$this->isPositiveAmount($amount, $lambda)
|
283 |
+
&& !$this->isNegativeAmount($amount, $lambda);
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Check if an given amount if > 0.
|
289 |
+
*
|
290 |
+
* @param float $amount
|
291 |
+
* @param float $lambda
|
292 |
+
* @return boolean
|
293 |
+
*/
|
294 |
+
public function isPositiveAmount($amount, $lambda = 0.0001)
|
295 |
+
{
|
296 |
+
return $amount > $lambda;
|
297 |
+
}
|
298 |
+
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Check if an given amount if < 0.
|
302 |
+
*
|
303 |
+
* @param float $amount
|
304 |
+
* @param float $lambda
|
305 |
+
* @return boolean
|
306 |
+
*/
|
307 |
+
public function isNegativeAmount($amount, $lambda = 0.0001)
|
308 |
+
{
|
309 |
+
return $amount < -$lambda;
|
310 |
+
}
|
311 |
+
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Return the backend error manager.
|
315 |
+
*
|
316 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
317 |
+
*/
|
318 |
+
public function getBackendErrorManager($special = null)
|
319 |
+
{
|
320 |
+
if (empty($special) || null === Mage::registry("error_{$special}_manager")) {
|
321 |
+
return Mage::getModel('computop/error_manager')
|
322 |
+
->addHandler('message', 'message', array(), 1)
|
323 |
+
->addHandler('translate', 'translate', array('helper' => 'computop'), 2)
|
324 |
+
->addHandler('session', 'session', array('session' => 'adminhtml/session'))
|
325 |
+
->addHandler('exception', 'exception', array(), 1000);
|
326 |
+
}
|
327 |
+
|
328 |
+
return Mage::registry("error_{$special}_manager")->reset();
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Return the frontend error manager.
|
334 |
+
*
|
335 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
336 |
+
*/
|
337 |
+
public function getFrontendErrorManager()
|
338 |
+
{
|
339 |
+
return Mage::getModel('computop/error_manager')
|
340 |
+
->addHandler('message', 'message', array(), 1)
|
341 |
+
->addHandler('translate', 'translate', array('helper' => 'computop'), 2)
|
342 |
+
->addHandler('exception', 'exception', array(), 1000);
|
343 |
+
}
|
344 |
+
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Set the disable payment keys in the current checkout session for one day.
|
348 |
+
*
|
349 |
+
* @param string $payment_code
|
350 |
+
* @param int $area
|
351 |
+
*/
|
352 |
+
public function disablePaymentForCheckoutSession($payment_code, $area = Dotsource_Computop_Helper_Data::AUTO)
|
353 |
+
{
|
354 |
+
//Get the session
|
355 |
+
$session = $this->_getHelper()->getCheckoutSession($area);
|
356 |
+
$disabledPayments = array();
|
357 |
+
|
358 |
+
//Check for array
|
359 |
+
if ($session->hasData($this->_disablePaymentKey)) {
|
360 |
+
$data = $session->getData($this->_disablePaymentKey);
|
361 |
+
|
362 |
+
//Recreate the array
|
363 |
+
if (!is_array($data) || empty($data)) {
|
364 |
+
$disabledPayments = array();
|
365 |
+
} else {
|
366 |
+
$disabledPayments = $data;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
//Save the disable key and the next avilable time
|
371 |
+
$disabledPayments[$payment_code] = time() + $this->_disableTimeForCheckout;
|
372 |
+
|
373 |
+
//Save the new disable payment keys
|
374 |
+
$session->setData($this->_disablePaymentKey, $disabledPayments);
|
375 |
+
}
|
376 |
+
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Check if the given payment code is disabled for the current checkout
|
380 |
+
* session.
|
381 |
+
*
|
382 |
+
* @param string $payment_code
|
383 |
+
* @param int $area
|
384 |
+
* @return boolean
|
385 |
+
*/
|
386 |
+
public function isPaymentDisabled($payment_code, $area = Dotsource_Computop_Helper_Data::AUTO)
|
387 |
+
{
|
388 |
+
//Get the session
|
389 |
+
$session = $this->_getHelper()->getCheckoutSession($area);
|
390 |
+
|
391 |
+
//Check for array
|
392 |
+
if ($session->hasData($this->_disablePaymentKey)) {
|
393 |
+
$data = $session->getData($this->_disablePaymentKey);
|
394 |
+
|
395 |
+
//Recreate the array
|
396 |
+
if (!empty($data) && is_array($data) && array_key_exists($payment_code, $data)) {
|
397 |
+
return $data[$payment_code] > time();
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
return false;
|
402 |
+
}
|
403 |
+
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Clear the payment deactivation in the checkout session.
|
407 |
+
*
|
408 |
+
* @param int $area
|
409 |
+
*/
|
410 |
+
public function clearPaymentDeactivation($area = Dotsource_Computop_Helper_Data::AUTO)
|
411 |
+
{
|
412 |
+
//Get the session
|
413 |
+
$session = $this->_getHelper()->getCheckoutSession($area);
|
414 |
+
|
415 |
+
//Check if we have the key
|
416 |
+
if ($session->hasData($this->_disablePaymentKey)) {
|
417 |
+
//Remove the data
|
418 |
+
$session->unsetData($this->_disablePaymentKey);
|
419 |
+
}
|
420 |
+
}
|
421 |
+
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Return the supported language for the given country code and payment.
|
425 |
+
*
|
426 |
+
* @param string $countryCode
|
427 |
+
* @param Mage_Payment_Model_Method_Abstract $payment
|
428 |
+
* @return string
|
429 |
+
*/
|
430 |
+
public function getPaygateLanguage($countryCode, Mage_Payment_Model_Method_Abstract $payment)
|
431 |
+
{
|
432 |
+
//Prepare the code
|
433 |
+
$countryCode = strtolower(trim($countryCode));
|
434 |
+
|
435 |
+
//Check for de code
|
436 |
+
if ('de' == $countryCode) {
|
437 |
+
return 'de';
|
438 |
+
}
|
439 |
+
|
440 |
+
//Fallback is english
|
441 |
+
return 'en';
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Return the computop helper.
|
447 |
+
*
|
448 |
+
* @return Dotsource_Computop_Helper_Data
|
449 |
+
*/
|
450 |
+
protected function _getHelper()
|
451 |
+
{
|
452 |
+
return Mage::helper('computop');
|
453 |
+
}
|
454 |
+
}
|
app/code/community/Dotsource/Computop/Helper/Paypal/Config.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 14:41:01
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Helper_Paypal_Config
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Get PayPal "mark" image URL supposed to be used on payment methods
|
19 |
+
* selection.
|
20 |
+
* $staticSize is applicable for static images only.
|
21 |
+
*
|
22 |
+
* @param string $localeCode
|
23 |
+
* @param float $orderTotal
|
24 |
+
* @param string $pal
|
25 |
+
* @param string $staticSize
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null)
|
29 |
+
{
|
30 |
+
return $this->_getPaypalConfig()->getPaymentMarkImageUrl(
|
31 |
+
$localeCode, $orderTotal, $pal, $staticSize
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Retrieves the localized "What Is PayPal" url.
|
38 |
+
*
|
39 |
+
* This method is supposed to be used with "mark" as popup window.
|
40 |
+
*
|
41 |
+
* @param Mage_Core_Model_Locale $locale
|
42 |
+
*/
|
43 |
+
public function getPaymentMarkWhatIsPaypalUrl(Mage_Core_Model_Locale $locale = null)
|
44 |
+
{
|
45 |
+
return $this->_getPaypalConfig()->getPaymentMarkWhatIsPaypalUrl($locale);
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Retrieves the payment form logo image url.
|
51 |
+
*
|
52 |
+
* @param string $localeCode
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getPaymentFormLogoUrl($localeCode)
|
56 |
+
{
|
57 |
+
return $this->_getPaypalConfig()->getPaymentFormLogoUrl($localeCode);
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Express checkout shortcut pic URL getter
|
63 |
+
* PayPal will ignore "pal", if there is no total amount specified
|
64 |
+
*
|
65 |
+
* @param string $localeCode
|
66 |
+
* @param float $orderTotal
|
67 |
+
* @param string $pal encrypted summary about merchant
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null)
|
71 |
+
{
|
72 |
+
return $this->_getPaypalConfig()->getExpressCheckoutShortcutImageUrl(
|
73 |
+
$localeCode, $orderTotal, $pal
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Retrieves the PayPal configuration model.
|
80 |
+
*
|
81 |
+
* @return Mage_Paypal_Model_Config
|
82 |
+
*/
|
83 |
+
protected function _getPaypalConfig()
|
84 |
+
{
|
85 |
+
return Mage::getSingleton('paypal/config');
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Dotsource/Computop/Model/Action.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Action
|
12 |
+
extends Mage_Core_Model_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('computop/action');
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add the given connection in the computop action.
|
24 |
+
*
|
25 |
+
* @param Dotsource_Computop_Model_Payment_Connection_Abstract $container
|
26 |
+
* @return Dotsource_Computop_Model_Action
|
27 |
+
*/
|
28 |
+
public function logRequest(Dotsource_Computop_Model_Payment_Request_Request $request)
|
29 |
+
{
|
30 |
+
//Get the last used transaction models
|
31 |
+
$transactionModel = $request->getComputopTransactionModel();
|
32 |
+
|
33 |
+
/* @var $response Dotsource_Computop_Object */
|
34 |
+
$response = $request->getResponseModel()->getResponse();
|
35 |
+
|
36 |
+
//Set the data and save the action
|
37 |
+
$this->setTransactionId($transactionModel->getId())
|
38 |
+
->setRequestPayid($request->getPayid())
|
39 |
+
->setResponsePayid($request->getResponseModel()->getResponse()->getPayid())
|
40 |
+
->setXid($response->getXid())
|
41 |
+
->setAction($request->getRequestFile())
|
42 |
+
->setErrorCode($response->getCode())
|
43 |
+
->setErrorDescription($response->getDescription());
|
44 |
+
|
45 |
+
//Set the error flag if something went wrong
|
46 |
+
if ($request->getResponseModel()->hasError()) {
|
47 |
+
$this->setError('1');
|
48 |
+
} else {
|
49 |
+
$this->setError('0');
|
50 |
+
}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add the given response from the callback controller
|
57 |
+
* to the computop action.
|
58 |
+
*
|
59 |
+
* @param Dotsource_Computop_Model_Payment_Response_Response $response
|
60 |
+
* @param Mage_Payment_Model_Info $payment
|
61 |
+
* @return Dotsource_Computop_Model_Action
|
62 |
+
*/
|
63 |
+
public function logResponse(
|
64 |
+
Dotsource_Computop_Model_Payment_Response_Response $response,
|
65 |
+
Mage_Payment_Model_Info $payment,
|
66 |
+
$requestPayid = null
|
67 |
+
)
|
68 |
+
{
|
69 |
+
//Set the data and save the action
|
70 |
+
$this->setTransactionId($payment->getComputopTransactionId())
|
71 |
+
->setRequestPayid($requestPayid)
|
72 |
+
->setResponsePayid($response->getResponse()->getPayid())
|
73 |
+
->setXid($response->getResponse()->getXid())
|
74 |
+
->setAction($payment->getMethodInstance()->getCode())
|
75 |
+
->setErrorCode($response->getResponse()->getCode())
|
76 |
+
->setErrorDescription($response->getResponse()->getDescription());
|
77 |
+
|
78 |
+
//Set the error flag if something went wrong
|
79 |
+
if ($response->hasError()) {
|
80 |
+
$this->setError('1');
|
81 |
+
} else {
|
82 |
+
$this->setError('0');
|
83 |
+
}
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @see Mage_Core_Model_Abstract::_beforeSave()
|
90 |
+
*
|
91 |
+
* @return Mage_Core_Model_Abstract
|
92 |
+
*/
|
93 |
+
protected function _beforeSave()
|
94 |
+
{
|
95 |
+
parent::_beforeSave();
|
96 |
+
|
97 |
+
//If new created set the created_at time to now
|
98 |
+
if (!$this->getId()) {
|
99 |
+
$this->setCreatedAt(now());
|
100 |
+
}
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Return the computop helper.
|
107 |
+
*
|
108 |
+
* @return Dotsource_Computop_Helper_Data
|
109 |
+
*/
|
110 |
+
protected function _getHelper()
|
111 |
+
{
|
112 |
+
return Mage::helper('computop');
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Dotsource/Computop/Model/Cancelprocess.php
ADDED
@@ -0,0 +1,584 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Cancelprocess {
|
11 |
+
|
12 |
+
/** Holds the current payment */
|
13 |
+
protected $_payment = null;
|
14 |
+
|
15 |
+
/** Holds the online paid invoices */
|
16 |
+
protected $_onlineInvoices = null;
|
17 |
+
|
18 |
+
/** Holds the online paid credit memos */
|
19 |
+
protected $_onlineCreditmemos = null;
|
20 |
+
|
21 |
+
/** Holds to an invoice id all credit memo models */
|
22 |
+
protected $_invoiceCreditmemosMap = null;
|
23 |
+
|
24 |
+
/** Maps the xid of every invoice as key */
|
25 |
+
protected $_xidInvoiceMap = null;
|
26 |
+
|
27 |
+
/** Maps the xid of every credit memo as key */
|
28 |
+
protected $_xidCreditmemoMap = null;
|
29 |
+
|
30 |
+
/** Holds all invoice referenced to the payid */
|
31 |
+
protected $_payidInvoiceMap = null;
|
32 |
+
|
33 |
+
/** Holds all credit memo referenced to the payid */
|
34 |
+
protected $_payidCreditmemoMap = null;
|
35 |
+
|
36 |
+
/** Holds all payids referenced to the invoice */
|
37 |
+
protected $_invoicePayidMap = null;
|
38 |
+
|
39 |
+
/** Holds all payids referenced to the credit memo */
|
40 |
+
protected $_creditmemoPayidMap = null;
|
41 |
+
|
42 |
+
/** Holds all open online transactions */
|
43 |
+
protected $_onlineCaptureTransactions = null;
|
44 |
+
|
45 |
+
/** Holds all transactions with the payid as key */
|
46 |
+
protected $_payidTransaction = null;
|
47 |
+
|
48 |
+
/** Holds the related objects for the order */
|
49 |
+
protected $_needToSaveObject = null;
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set the order payment.
|
54 |
+
*
|
55 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
56 |
+
*/
|
57 |
+
public function setPayment(Mage_Sales_Model_Order_Payment $payment)
|
58 |
+
{
|
59 |
+
$this->_payment = $payment;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Return the current payment.
|
66 |
+
*
|
67 |
+
* @return Mage_Sales_Model_Order_Payment
|
68 |
+
*/
|
69 |
+
protected function _getPayment()
|
70 |
+
{
|
71 |
+
return $this->_payment;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get the order from the current payment.
|
77 |
+
*
|
78 |
+
* @return Mage_Sales_Model_Order
|
79 |
+
*/
|
80 |
+
protected function _getOrder()
|
81 |
+
{
|
82 |
+
return $this->_getPayment()->getOrder();
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Return all online captured transactions.
|
88 |
+
*
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
public function getOnlineCaptureTransaction()
|
92 |
+
{
|
93 |
+
if (null === $this->_onlineCaptureTransactions) {
|
94 |
+
/* @var $captures Mage_Sales_Model_Mysql4_Order_Payment_Transaction_Collection */
|
95 |
+
$captures = Mage::getResourceModel('sales/order_payment_transaction_collection')
|
96 |
+
->addPaymentIdFilter($this->_getPayment()->getId())
|
97 |
+
->addTxnTypeFilter(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
98 |
+
|
99 |
+
//We only need open captures
|
100 |
+
$captures->getSelect()->where('is_closed=?', 0);
|
101 |
+
|
102 |
+
$this->_onlineCaptureTransactions = $captures->getItems();
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this->_onlineCaptureTransactions;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Create a full credit memo for the given invoice and the amount.
|
111 |
+
*
|
112 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
113 |
+
* @return Mage_Sales_Model_Order_Creditmemo
|
114 |
+
*/
|
115 |
+
public function createFullCreditmemoFromInvoice(Mage_Sales_Model_Order_Invoice $invoice)
|
116 |
+
{
|
117 |
+
//Get the return able invoice
|
118 |
+
$amount = $this->getRefundableAmountFromInvoice($invoice);
|
119 |
+
|
120 |
+
//Nothing to do
|
121 |
+
if ($this->isAmountZero($amount)) {
|
122 |
+
return null;
|
123 |
+
}
|
124 |
+
|
125 |
+
//Create a converter object and create a credit memo
|
126 |
+
/* @var $converter Mage_Sales_Model_Convert_Order */
|
127 |
+
$converter = Mage::getModel('sales/convert_order');
|
128 |
+
$creditmemo = $converter->toCreditmemo($this->_getOrder());
|
129 |
+
|
130 |
+
//Add all information to the credit memo
|
131 |
+
$creditmemo
|
132 |
+
->setRefundRequested(true)
|
133 |
+
->setOfflineRequested(false)
|
134 |
+
->setInvoice($invoice);
|
135 |
+
|
136 |
+
//Add all items to the credit memo from the invoice
|
137 |
+
foreach ($invoice->getAllItems() as $invoiceItem) {
|
138 |
+
/* @var $invoiceItem Mage_Sales_Model_Order_Invoice_Item */
|
139 |
+
$orderItem = $invoiceItem->getOrderItem();
|
140 |
+
|
141 |
+
if (!$orderItem->isDummy() && !$orderItem->getQtyToRefund()) {
|
142 |
+
continue;
|
143 |
+
}
|
144 |
+
|
145 |
+
$item = $converter->itemToCreditmemoItem($orderItem);
|
146 |
+
|
147 |
+
if ($orderItem->isDummy()) {
|
148 |
+
$qty = 1;
|
149 |
+
} else {
|
150 |
+
$qty = min($orderItem->getQtyToRefund(), $invoiceItem->getQty());
|
151 |
+
|
152 |
+
foreach ($this->getCreditmemosFromInvoiceId($invoice->getId()) as $onlineCreditmemo) {
|
153 |
+
foreach ($onlineCreditmemo->getAllItems() as $creditmemoItem) {
|
154 |
+
if ($orderItem->getId() == $creditmemoItem->getOrderItem()->getId()) {
|
155 |
+
$qty -= $creditmemoItem->getQty();
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
$item
|
162 |
+
->setQty($qty)
|
163 |
+
->setBackToStock(false);
|
164 |
+
|
165 |
+
$creditmemo->addItem($item);
|
166 |
+
}
|
167 |
+
|
168 |
+
//Collect the totals
|
169 |
+
$creditmemo->collectTotals();
|
170 |
+
|
171 |
+
//NOW! Don't use the magento calculated price the price is depends on the qyt
|
172 |
+
//but you can refund money without depending on the items
|
173 |
+
$diff = $amount - $creditmemo->getBaseGrandTotal();
|
174 |
+
|
175 |
+
//If the difference is zero we no need to change something
|
176 |
+
if (!$this->isAmountZero($diff)) {
|
177 |
+
if ($this->_getHelper()->getPaymentHelper()->isNegativeAmount($diff)) {
|
178 |
+
$creditmemo->setAdjustmentNegative(abs($diff));
|
179 |
+
} else if($this->_getHelper()->getPaymentHelper()->isPositiveAmount($diff)) {
|
180 |
+
$creditmemo->setAdjustmentPositive($diff);
|
181 |
+
}
|
182 |
+
|
183 |
+
//Recollect the totals
|
184 |
+
$creditmemo
|
185 |
+
->setGrandTotal(0)
|
186 |
+
->setBaseGrandTotal(0)
|
187 |
+
->collectTotals();
|
188 |
+
}
|
189 |
+
|
190 |
+
return $creditmemo;
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Return the total amount who is online refundable.
|
196 |
+
*
|
197 |
+
* @return float
|
198 |
+
*/
|
199 |
+
public function getTotalRefundableAmount()
|
200 |
+
{
|
201 |
+
$payidAmounts = $this->getRefundableAmountPerPayid();
|
202 |
+
|
203 |
+
//Check if we have a amount for refunding
|
204 |
+
if (!empty($payidAmounts)) {
|
205 |
+
return array_sum($payidAmounts);
|
206 |
+
}
|
207 |
+
|
208 |
+
return 0.0;
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Return the available amount for every payid.
|
214 |
+
*
|
215 |
+
* @return array
|
216 |
+
*/
|
217 |
+
public function getRefundableAmountPerPayid()
|
218 |
+
{
|
219 |
+
//Holds the refunds per payid
|
220 |
+
$refunds = array();
|
221 |
+
|
222 |
+
foreach ($this->getOnlinePaidInvoices() as $invoice) {
|
223 |
+
$payid = $this->getPayidFromInvoiceId($invoice->getId());
|
224 |
+
|
225 |
+
if (!array_key_exists($payid, $refunds)) {
|
226 |
+
$refunds[$payid] = 0.0;
|
227 |
+
}
|
228 |
+
|
229 |
+
//Add the invoice amount
|
230 |
+
$refunds[$payid] += (float)$invoice->getBaseGrandTotal();
|
231 |
+
|
232 |
+
foreach ($this->getCreditmemosFromInvoiceId($invoice->getId()) as $creditmemo) {
|
233 |
+
$refunds[$payid] -= (float)$creditmemo->getBaseGrandTotal();
|
234 |
+
}
|
235 |
+
|
236 |
+
//Unset the zero amounts
|
237 |
+
if ($this->isAmountZero($refunds[$payid])) {
|
238 |
+
unset($refunds[$payid]);
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
return $refunds;
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Return the returnable invoice amount.
|
248 |
+
*
|
249 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
250 |
+
* @return float
|
251 |
+
*/
|
252 |
+
public function getRefundableAmountFromInvoice(Mage_Sales_Model_Order_Invoice $invoice)
|
253 |
+
{
|
254 |
+
//Get the invoicd amount
|
255 |
+
$amount = $invoice->getBaseGrandTotal();
|
256 |
+
|
257 |
+
//Subtract the already refunded amount
|
258 |
+
foreach ($this->getCreditmemosFromInvoiceId($invoice->getId()) as $creditmemo) {
|
259 |
+
$amount -= (float)$creditmemo->getBaseGrandTotal();
|
260 |
+
}
|
261 |
+
|
262 |
+
return $amount;
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Return the the online paid invoices.
|
268 |
+
*
|
269 |
+
* @param Mage_Sales_Model_Order $order
|
270 |
+
* @return array
|
271 |
+
*/
|
272 |
+
public function getOnlinePaidInvoices()
|
273 |
+
{
|
274 |
+
if (null === $this->_onlineInvoices) {
|
275 |
+
$items = array();
|
276 |
+
|
277 |
+
//Collect all online paid invoices
|
278 |
+
foreach ($this->_getOrder()->getInvoiceCollection() as $invoice) {
|
279 |
+
if (Mage_Sales_Model_Order_Invoice::STATE_PAID == $invoice->getState()
|
280 |
+
&& $invoice->hasTransactionId()
|
281 |
+
) {
|
282 |
+
$items[] = $invoice;
|
283 |
+
$this->_xidInvoiceMap[$invoice->getTransactionId()] = $invoice;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
$this->_onlineInvoices = $items;
|
288 |
+
}
|
289 |
+
|
290 |
+
return $this->_onlineInvoices;
|
291 |
+
}
|
292 |
+
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Return the the online refunded credit memos.
|
296 |
+
*
|
297 |
+
* @param Mage_Sales_Model_Order $order
|
298 |
+
* @return array
|
299 |
+
*/
|
300 |
+
public function getOnlineRefundedCreditmemos()
|
301 |
+
{
|
302 |
+
if (null === $this->_onlineCreditmemos) {
|
303 |
+
$items = array();
|
304 |
+
|
305 |
+
//Collect all online refunded credit memos
|
306 |
+
foreach ($this->_getOrder()->getCreditmemosCollection() as $creditmemo) {
|
307 |
+
if (Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED == $creditmemo->getState()
|
308 |
+
&& $creditmemo->hasTransactionId()
|
309 |
+
&& $creditmemo->hasInvoiceId()
|
310 |
+
) {
|
311 |
+
$items[] = $creditmemo;
|
312 |
+
$this->_xidCreditmemoMap[$creditmemo->getTransactionId()] = $creditmemo;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
$this->_onlineCreditmemos = $items;
|
317 |
+
}
|
318 |
+
|
319 |
+
return $this->_onlineCreditmemos;
|
320 |
+
}
|
321 |
+
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Build the mapping from the invoice id to the referenced credit memos.
|
325 |
+
*
|
326 |
+
* @return Dotsource_Computop_Model_Cancelprocess
|
327 |
+
*/
|
328 |
+
protected function _createInvoiceCreditmemoMapping()
|
329 |
+
{
|
330 |
+
if (null === $this->_invoiceCreditmemosMap) {
|
331 |
+
foreach ($this->getOnlinePaidInvoices() as $invoice) {
|
332 |
+
$this->_invoiceCreditmemosMap[$invoice->getId()] = array();
|
333 |
+
|
334 |
+
foreach ($this->getOnlineRefundedCreditmemos() as $creditmemo) {
|
335 |
+
if ($invoice->getId() == $creditmemo->getInvoiceId()) {
|
336 |
+
$this->_invoiceCreditmemosMap[$invoice->getId()][] = $creditmemo;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
return $this;
|
343 |
+
}
|
344 |
+
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Return an array with all credit memos who are referenced with the given invoice id.
|
348 |
+
*
|
349 |
+
* @param int $invoiceId
|
350 |
+
* @return array
|
351 |
+
*/
|
352 |
+
public function getCreditmemosFromInvoiceId($invoiceId)
|
353 |
+
{
|
354 |
+
$this->_createInvoiceCreditmemoMapping();
|
355 |
+
if (array_key_exists($invoiceId, $this->_invoiceCreditmemosMap)) {
|
356 |
+
return $this->_invoiceCreditmemosMap[$invoiceId];
|
357 |
+
}
|
358 |
+
|
359 |
+
return array();
|
360 |
+
}
|
361 |
+
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Return the invoice to the given xid.
|
365 |
+
*
|
366 |
+
* @param string $xid
|
367 |
+
* @return Mage_Sales_Model_Order_Invoice
|
368 |
+
*/
|
369 |
+
public function getInvoiceFromXid($xid)
|
370 |
+
{
|
371 |
+
$this->getOnlinePaidInvoices();
|
372 |
+
if (array_key_exists($xid, $this->_xidInvoiceMap)) {
|
373 |
+
return $this->_xidInvoiceMap[$xid];
|
374 |
+
}
|
375 |
+
|
376 |
+
return null;
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Return the invoices to the given payid.
|
382 |
+
*
|
383 |
+
* @param string $payid
|
384 |
+
* @return array
|
385 |
+
*/
|
386 |
+
public function getInvoicesFromPayid($payid)
|
387 |
+
{
|
388 |
+
$this->_processPayidMapping();
|
389 |
+
if (array_key_exists($payid, $this->_payidInvoiceMap)) {
|
390 |
+
return $this->_payidInvoiceMap[$payid];
|
391 |
+
}
|
392 |
+
|
393 |
+
return array();
|
394 |
+
}
|
395 |
+
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Return the credit memo to the given xid.
|
399 |
+
*
|
400 |
+
* @param string $xid
|
401 |
+
* @return Mage_Sales_Model_Order_Creditmemo
|
402 |
+
*/
|
403 |
+
public function getCreditmemoFromXid($xid)
|
404 |
+
{
|
405 |
+
$this->getOnlineRefundedCreditmemos();
|
406 |
+
if (array_key_exists($xid, $this->_xidCreditmemoMap)) {
|
407 |
+
return $this->_xidCreditmemoMap[$xid];
|
408 |
+
}
|
409 |
+
|
410 |
+
return null;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Return the credit memos to the given payid.
|
416 |
+
*
|
417 |
+
* @param string $payid
|
418 |
+
* @return array
|
419 |
+
*/
|
420 |
+
public function getCreditmemosFromPayid($payid)
|
421 |
+
{
|
422 |
+
$this->_processPayidMapping();
|
423 |
+
if (array_key_exists($payid, $this->_payidCreditmemoMap)) {
|
424 |
+
return $this->_payidCreditmemoMap[$payid];
|
425 |
+
}
|
426 |
+
|
427 |
+
return array();
|
428 |
+
}
|
429 |
+
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Return the invoices to the given credit memo id.
|
433 |
+
*
|
434 |
+
* @param string $invoiceId
|
435 |
+
* @return string || null
|
436 |
+
*/
|
437 |
+
public function getPayidFromInvoiceId($invoiceId)
|
438 |
+
{
|
439 |
+
$this->_processPayidMapping();
|
440 |
+
if (array_key_exists($invoiceId, $this->_invoicePayidMap)) {
|
441 |
+
return $this->_invoicePayidMap[$invoiceId];
|
442 |
+
}
|
443 |
+
|
444 |
+
return null;
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Return the invoices to the given credit memo id.
|
450 |
+
*
|
451 |
+
* @param string $creditmemoId
|
452 |
+
* @return string || null
|
453 |
+
*/
|
454 |
+
public function getPayidFromCreditmemoId($creditmemoId)
|
455 |
+
{
|
456 |
+
$this->_processPayidMapping();
|
457 |
+
if (array_key_exists($creditmemoId, $this->_creditmemoPayidMap)) {
|
458 |
+
return $this->_creditmemoPayidMap[$creditmemoId];
|
459 |
+
}
|
460 |
+
|
461 |
+
return null;
|
462 |
+
}
|
463 |
+
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Build the mapping from the payid to the invoices and credit memos and the
|
467 |
+
* invoice ids and credit memo ids to the payid.
|
468 |
+
*/
|
469 |
+
protected function _processPayidMapping()
|
470 |
+
{
|
471 |
+
if (null === $this->_payidInvoiceMap
|
472 |
+
|| null === $this->_payidCreditmemoMap
|
473 |
+
|| null === $this->_invoicePayidMap
|
474 |
+
|| null === $this->_creditmemoPayidMap
|
475 |
+
|| null === $this->_payidTransaction
|
476 |
+
) {
|
477 |
+
$this->_payidInvoiceMap = array();
|
478 |
+
$this->_payidCreditmemoMap = array();
|
479 |
+
$this->_invoicePayidMap = array();
|
480 |
+
$this->_creditmemoPayidMap = array();
|
481 |
+
$this->_payidTransaction = array();
|
482 |
+
$transactions = $this->getOnlineCaptureTransaction();
|
483 |
+
|
484 |
+
foreach ($transactions as $transaction) {
|
485 |
+
$payid = $transaction->getAdditionalInformation('payid');
|
486 |
+
$xid = $transaction->getTxnId();
|
487 |
+
|
488 |
+
if (!array_key_exists($payid, $this->_payidTransaction)) {
|
489 |
+
$this->_payidTransaction[$payid] = array();
|
490 |
+
}
|
491 |
+
|
492 |
+
$this->_payidTransaction[$payid][] = $transaction;
|
493 |
+
|
494 |
+
//Create invoice mapping
|
495 |
+
foreach ($this->getOnlinePaidInvoices() as $invoice) {
|
496 |
+
if ($xid == $invoice->getTransactionId()) {
|
497 |
+
if (!array_key_exists($payid, $this->_payidInvoiceMap)) {
|
498 |
+
$this->_payidInvoiceMap[$payid] = array();
|
499 |
+
}
|
500 |
+
|
501 |
+
$this->_payidInvoiceMap[$payid][] = $invoice;
|
502 |
+
$this->_invoicePayidMap[$invoice->getId()] = $payid;
|
503 |
+
|
504 |
+
//Create credit memo mapping
|
505 |
+
foreach ($this->getOnlineRefundedCreditmemos() as $creditmemo) {
|
506 |
+
if ($invoice->getId() == $creditmemo->getInvoiceId()) {
|
507 |
+
if (!array_key_exists($payid, $this->_payidCreditmemoMap)) {
|
508 |
+
$this->_payidCreditmemoMap[$payid] = array();
|
509 |
+
}
|
510 |
+
|
511 |
+
$this->_payidCreditmemoMap[$payid][] = $creditmemo;
|
512 |
+
$this->_creditmemoPayidMap[$creditmemo->getId()] = $payid;
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Return all online capture transactions with the given payid.
|
524 |
+
*
|
525 |
+
* @param string $payid
|
526 |
+
* @return array
|
527 |
+
*/
|
528 |
+
protected function getOnlineCaptureTransactionFromPayid($payid)
|
529 |
+
{
|
530 |
+
$this->_processPayidMapping();
|
531 |
+
if (array_key_exists($payid, $this->_payidTransaction)) {
|
532 |
+
return $this->_payidTransaction[$payid];
|
533 |
+
}
|
534 |
+
|
535 |
+
return array();
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Check if the given amount (float) is zero.
|
541 |
+
*
|
542 |
+
* @param float $amount
|
543 |
+
* @return boolean
|
544 |
+
*/
|
545 |
+
public function isAmountZero($amount)
|
546 |
+
{
|
547 |
+
return $this->_getHelper()->getPaymentHelper()->isZeroAmount($amount);
|
548 |
+
}
|
549 |
+
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Add the object in the intern related object array.
|
553 |
+
*
|
554 |
+
* @param Mage_Core_Model_Abstract $object
|
555 |
+
*/
|
556 |
+
protected function _addRelatedObject(Mage_Core_Model_Abstract $object)
|
557 |
+
{
|
558 |
+
$this->_needToSaveObject[] = $object;
|
559 |
+
}
|
560 |
+
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Sync all intern related objects to the order.
|
564 |
+
*/
|
565 |
+
public function syncRelatedObjects()
|
566 |
+
{
|
567 |
+
foreach ($this->_needToSaveObject as $object) {
|
568 |
+
$this->_getOrder()->addRelatedObject($object);
|
569 |
+
}
|
570 |
+
|
571 |
+
$this->_needToSaveObject = array();
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Return the computop helper.
|
577 |
+
*
|
578 |
+
* @return Dotsource_Computop_Helper_Data
|
579 |
+
*/
|
580 |
+
protected function _getHelper()
|
581 |
+
{
|
582 |
+
return Mage::helper('computop');
|
583 |
+
}
|
584 |
+
}
|
app/code/community/Dotsource/Computop/Model/Connection.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Connection
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the connection settings */
|
15 |
+
protected $_connectionSettings = array();
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Send a request to computop.
|
20 |
+
*
|
21 |
+
* @param Dotsource_Computop_Model_Payment_Request_Request $request
|
22 |
+
*/
|
23 |
+
public function sendRequest(Dotsource_Computop_Model_Payment_Request_Request $request)
|
24 |
+
{
|
25 |
+
//Send the request and get the response
|
26 |
+
$response = $this->_send($request);
|
27 |
+
|
28 |
+
//Set the response to the request object
|
29 |
+
$request->setResponse($response, false);
|
30 |
+
|
31 |
+
//Log the response
|
32 |
+
$this->_getHelper()->Log($request->getResponseModel()->getResponse(), 'Response');
|
33 |
+
|
34 |
+
//Log the request
|
35 |
+
if ($request->logRequest()) {
|
36 |
+
//Log the request as action
|
37 |
+
Mage::getModel('computop/action')->logRequest($request)->save();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Send the request to computop and save the response.
|
44 |
+
*
|
45 |
+
* @param Dotsource_Computop_Model_Payment_Request_Request $request
|
46 |
+
*/
|
47 |
+
protected function _send(Dotsource_Computop_Model_Payment_Request_Request $request)
|
48 |
+
{
|
49 |
+
//Only send requests if the computop payment module is global activated
|
50 |
+
if (!$this->_getHelper()->isGlobalActive()) {
|
51 |
+
Mage::throwException(
|
52 |
+
$this->_getHelper()->__('The Computop payment module is global deactivated. Please check our Magento backend.')
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
//Get a new client model
|
57 |
+
$client = $this->_getClient();
|
58 |
+
|
59 |
+
//Set the request uri
|
60 |
+
$client->setUri($this->_getHelper()->getConfiguration()->getBaseUrl()."{$request->getRequestFile()}");
|
61 |
+
|
62 |
+
//Set the post data
|
63 |
+
$client->setParameterPost(
|
64 |
+
$request->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_ARRAY)
|
65 |
+
);
|
66 |
+
|
67 |
+
//Send the request to computop and get the response
|
68 |
+
$response = $client->request(Zend_Http_Client::POST);
|
69 |
+
|
70 |
+
//Check if the response is successful
|
71 |
+
if (!$response->isSuccessful()) {
|
72 |
+
return null;
|
73 |
+
}
|
74 |
+
|
75 |
+
return $response->getBody();
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Return an already configured client.
|
81 |
+
*
|
82 |
+
* @return Zend_Http_Client
|
83 |
+
*/
|
84 |
+
protected function _getClient()
|
85 |
+
{
|
86 |
+
//Create a new client
|
87 |
+
$client = new Zend_Http_Client(
|
88 |
+
null,
|
89 |
+
array(
|
90 |
+
'adapter' => 'Zend_Http_Client_Adapter_Socket',
|
91 |
+
'ssltransport' => 'tls'
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
//Return the configured client object
|
96 |
+
return $client;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Set the current connection settings data.
|
102 |
+
*
|
103 |
+
* @param array $field
|
104 |
+
* @return Dotsource_Computop_Model_Connection
|
105 |
+
*/
|
106 |
+
public function setConnectionSettings(array $settings)
|
107 |
+
{
|
108 |
+
$this->_connectionSettings = $settings;
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Return the specified url.
|
115 |
+
*
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
protected function _getUrl()
|
119 |
+
{
|
120 |
+
return $this->_getConnectionSettingsField('url');
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Return the specified username.
|
126 |
+
*
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
protected function _getUsername()
|
130 |
+
{
|
131 |
+
return $this->_getConnectionSettingsField('username');
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Return the specified password.
|
137 |
+
*
|
138 |
+
* @return string
|
139 |
+
*/
|
140 |
+
protected function _getPassword()
|
141 |
+
{
|
142 |
+
//First step get the password
|
143 |
+
$password = $this->_getConnectionSettingsField('password');
|
144 |
+
|
145 |
+
try {
|
146 |
+
//Try to decrypt password
|
147 |
+
$decrypted = Mage::helper('core')->decrypt($password);
|
148 |
+
|
149 |
+
//Check of valid data
|
150 |
+
if (!empty($decrypted)) {
|
151 |
+
$password = $decrypted;
|
152 |
+
}
|
153 |
+
} catch (Exception $e) {} //Do nothing on exception
|
154 |
+
|
155 |
+
return $password;
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Return a specified field from the config settings.
|
161 |
+
*
|
162 |
+
* @param string $field
|
163 |
+
* @return string
|
164 |
+
*/
|
165 |
+
protected function _getConnectionSettingsField($field)
|
166 |
+
{
|
167 |
+
if (!array_key_exists($field, $this->_connectionSettings)) {
|
168 |
+
Mage::throwException(
|
169 |
+
$this->_getHelper()->__('No connection setting field with the name is %s specified.', $field)
|
170 |
+
);
|
171 |
+
}
|
172 |
+
|
173 |
+
//If the data exists return the value
|
174 |
+
return $this->_connectionSettings[$field];
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Return the computop helper.
|
180 |
+
*
|
181 |
+
* @return Dotsource_Computop_Helper_Data
|
182 |
+
*/
|
183 |
+
protected function _getHelper()
|
184 |
+
{
|
185 |
+
return Mage::helper('computop');
|
186 |
+
}
|
187 |
+
}
|
app/code/community/Dotsource/Computop/Model/Encryption.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Encryption
|
12 |
+
extends Mage_Core_Model_Encryption
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Holds the mcrypt model */
|
16 |
+
protected $_crypt = null;
|
17 |
+
|
18 |
+
/** Holds the crypt settings */
|
19 |
+
protected $_data = null;
|
20 |
+
|
21 |
+
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
$args = func_get_args();
|
25 |
+
|
26 |
+
if (empty($args[0])) {
|
27 |
+
$args[0] = array();
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_data = $args[0];
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Instantiate crypt model
|
36 |
+
*
|
37 |
+
* @param string $key
|
38 |
+
* @return Varien_Crypt_Mcrypt
|
39 |
+
*/
|
40 |
+
protected function _getCrypt($key = null)
|
41 |
+
{
|
42 |
+
if (is_null($this->_crypt)) {
|
43 |
+
//Get the key from the config
|
44 |
+
$key = $this->getPassword();
|
45 |
+
|
46 |
+
//We need an encryption key
|
47 |
+
if (empty($key)) {
|
48 |
+
Mage::throwException('The computop encryption key is missing.');
|
49 |
+
}
|
50 |
+
|
51 |
+
//Decrypt the key with the magento default decrypter
|
52 |
+
$key = Mage::helper('core')->getEncryptor()->decrypt($key);
|
53 |
+
|
54 |
+
//Create a new mcrypt instance
|
55 |
+
$this->_crypt = Varien_Crypt::factory()
|
56 |
+
->setCipher(MCRYPT_BLOWFISH)
|
57 |
+
->init($key);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->_crypt;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Encrypt a string.
|
66 |
+
*
|
67 |
+
* @param string $data
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function encrypt($data)
|
71 |
+
{
|
72 |
+
if (!is_string($data) || empty($data)) {
|
73 |
+
Mage::throwException('The given data is not valid string.');
|
74 |
+
}
|
75 |
+
|
76 |
+
return bin2hex($this->_getCrypt()->encrypt($data));
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Decrypt a hex string string.
|
82 |
+
*
|
83 |
+
* @param string $data
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function decrypt($data)
|
87 |
+
{
|
88 |
+
return str_replace("\x0", '', trim($this->_getCrypt()->decrypt(pack('H*', $data))));
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Return true if we can use a hmac.
|
94 |
+
*
|
95 |
+
* @return boolean
|
96 |
+
*/
|
97 |
+
public function hasHmac()
|
98 |
+
{
|
99 |
+
$data = $this->getHmac();
|
100 |
+
return !empty($data);
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Creates the hmac for the given data.
|
106 |
+
*
|
107 |
+
* @param string $payId
|
108 |
+
* @param string $transId
|
109 |
+
* @param string $merchantId
|
110 |
+
* @param string $amount
|
111 |
+
* @param string $currency
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function createHmac($payId, $transId, $merchantId, $amount, $currency)
|
115 |
+
{
|
116 |
+
//check if we have an hmac
|
117 |
+
if (!$this->hasHmac()) {
|
118 |
+
Mage::throwException('No hmac salt is configured.');
|
119 |
+
}
|
120 |
+
|
121 |
+
//Get the hmac salt
|
122 |
+
$key = Mage::helper('core')->getEncryptor()->decrypt(
|
123 |
+
$this->getHmac()
|
124 |
+
);
|
125 |
+
|
126 |
+
//Create and return the hmac
|
127 |
+
return hash_hmac(
|
128 |
+
"sha256",
|
129 |
+
"$payId*$transId*$merchantId*$amount*$currency",
|
130 |
+
$key
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Return the given hmac.
|
137 |
+
*
|
138 |
+
* @return string
|
139 |
+
*/
|
140 |
+
public function getHmac()
|
141 |
+
{
|
142 |
+
return $this->_data['hmac'];
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Return the given password.
|
148 |
+
*
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
public function getPassword()
|
152 |
+
{
|
153 |
+
return $this->_data['password'];
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Return the computop helper.
|
159 |
+
*
|
160 |
+
* @return Dotsource_Computop_Helper_Data
|
161 |
+
*/
|
162 |
+
protected function _getHelper()
|
163 |
+
{
|
164 |
+
return Mage::helper('computop');
|
165 |
+
}
|
166 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Handler/Abstract.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
abstract class Dotsource_Computop_Model_Error_Handler_Abstract
|
11 |
+
extends Varien_Object
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the manager */
|
15 |
+
protected $_manager = null;
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Process the request.
|
20 |
+
*
|
21 |
+
* @param Varien_Object $request
|
22 |
+
*/
|
23 |
+
public abstract function processHandler(Varien_Object $request);
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the manager to the handler..
|
28 |
+
*
|
29 |
+
* @param Dotsource_Computop_Model_Error_Manager $manager
|
30 |
+
*/
|
31 |
+
public function addManager(Dotsource_Computop_Model_Error_Manager $manager)
|
32 |
+
{
|
33 |
+
$this->_manager = $manager;
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Return the manager from the handler.
|
39 |
+
*
|
40 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
41 |
+
*/
|
42 |
+
protected function _getManager()
|
43 |
+
{
|
44 |
+
return $this->_manager;
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Return the computop helper.
|
50 |
+
*
|
51 |
+
* @return Dotsource_Computop_Helper_Data
|
52 |
+
*/
|
53 |
+
protected function _getHelper()
|
54 |
+
{
|
55 |
+
return Mage::helper('computop');
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Handler/Exception.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Handler_Exception
|
11 |
+
extends Dotsource_Computop_Model_Error_Handler_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Dotsource_Computop_Model_Error_Handler_Interface::processHandler()
|
16 |
+
*
|
17 |
+
* @param Varien_Object $request
|
18 |
+
*/
|
19 |
+
public function processHandler(Varien_Object $request)
|
20 |
+
{
|
21 |
+
$message = $request->getMessage();
|
22 |
+
$module = $this->getModule();
|
23 |
+
|
24 |
+
//Throw the right exception
|
25 |
+
if (empty($module)) {
|
26 |
+
throw new Exception($message);
|
27 |
+
} else {
|
28 |
+
//Throw the exception
|
29 |
+
throw Mage::exception($module, $message);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Handler/Message.php
ADDED
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Handler_Message
|
11 |
+
extends Dotsource_Computop_Model_Error_Handler_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** const for the backend area error messages */
|
15 |
+
const BACKEND = 'backend';
|
16 |
+
|
17 |
+
/** const for the frontend area error messages */
|
18 |
+
const FRONTEND = 'frontend';
|
19 |
+
|
20 |
+
/** Holds the string for the default messages */
|
21 |
+
const DEFAULT_MESSAGE = 'fallback-error-msg';
|
22 |
+
|
23 |
+
|
24 |
+
/** Holds the error mapping */
|
25 |
+
protected static $_errorCodes = null;
|
26 |
+
|
27 |
+
/** Holds the xpath routes */
|
28 |
+
protected static $_xpathRoutes = null;
|
29 |
+
|
30 |
+
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
//Create the xpath routes
|
34 |
+
if (null == self::$_xpathRoutes) {
|
35 |
+
//Create the xpath routes
|
36 |
+
self::$_xpathRoutes = array(
|
37 |
+
'//%1$s/error[normalize-space(@code)="%2$s"][1]',
|
38 |
+
'//%1$s/error[starts-with(normalize-space(@code), "%2$s ") '
|
39 |
+
.'or contains(normalize-space(@code), " %2$s ") '
|
40 |
+
.'or substring(normalize-space(@code), string-length(normalize-space(@code)) - %3$s) = " %2$s"][1]',
|
41 |
+
);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @see Dotsource_Computop_Model_Error_Handler_Interface::processHandler()
|
48 |
+
*
|
49 |
+
* @param Varien_Object $request
|
50 |
+
*/
|
51 |
+
public function processHandler(Varien_Object $request)
|
52 |
+
{
|
53 |
+
//Holds the current message
|
54 |
+
$message = $request->getMessage();
|
55 |
+
|
56 |
+
//Get the message from the code
|
57 |
+
if ($this->isCode($message)) {
|
58 |
+
if ($this->hasMessageFromCode($message)) {
|
59 |
+
//Get the real code
|
60 |
+
$code = $message;
|
61 |
+
|
62 |
+
//Get the message from the xml
|
63 |
+
$message = $this->getMessageFromCode($code);
|
64 |
+
|
65 |
+
//Set message
|
66 |
+
$request->setMessage($message);
|
67 |
+
|
68 |
+
//Process the error code callback if exists
|
69 |
+
$this->processCallbackFromCode($code);
|
70 |
+
} else {
|
71 |
+
if ($this->_getHelper()->isDemoMode()) {
|
72 |
+
$request
|
73 |
+
->setMessage('Missing message for error code "%s".')
|
74 |
+
->setArguments(array($message));
|
75 |
+
} else {
|
76 |
+
//Holds the default message if no 'fallback-error-msg' are available
|
77 |
+
$msg = 'There was an undocumented error by processing your payment. Please try again or choose another payment method.';
|
78 |
+
|
79 |
+
//Check if we have a fallback default message
|
80 |
+
if ($this->hasMessageFromCode(self::DEFAULT_MESSAGE, false)) {
|
81 |
+
$msg = $this->getMessageFromCode(self::DEFAULT_MESSAGE, false);
|
82 |
+
|
83 |
+
//Process callback for default message
|
84 |
+
$this->processCallbackFromCode(self::DEFAULT_MESSAGE, false);
|
85 |
+
}
|
86 |
+
|
87 |
+
//Replace the current message code
|
88 |
+
$request
|
89 |
+
->setMessage($msg)
|
90 |
+
->setArguments(array());
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Is message code.
|
99 |
+
*
|
100 |
+
* @param string $code
|
101 |
+
* @return boolean
|
102 |
+
*/
|
103 |
+
public function isCode($code)
|
104 |
+
{
|
105 |
+
return (boolean) $this->_getManager()->getRequest()->getIsErrorCode();
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Return the area for the error messages.
|
111 |
+
*
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
protected function _getArea()
|
115 |
+
{
|
116 |
+
$request = $this->_getManager()->getRequest();
|
117 |
+
$area = Dotsource_Computop_Helper_Data::AUTO;
|
118 |
+
|
119 |
+
//Get the area from the request
|
120 |
+
if ($request->hasArea()) {
|
121 |
+
return $request->getArea();
|
122 |
+
}
|
123 |
+
|
124 |
+
//Detect the right area
|
125 |
+
if (Dotsource_Computop_Helper_Data::AUTO == $area) {
|
126 |
+
if ($this->_getHelper()->isFrontend()) {
|
127 |
+
$area = Dotsource_Computop_Helper_Data::FRONTEND;
|
128 |
+
} else {
|
129 |
+
$area = Dotsource_Computop_Helper_Data::BACKEND;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
//Return the area string
|
134 |
+
if (Dotsource_Computop_Helper_Data::FRONTEND == $area) {
|
135 |
+
return self::FRONTEND;
|
136 |
+
} else {
|
137 |
+
return self::BACKEND;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Prepare the error code.
|
144 |
+
*
|
145 |
+
* @param string $code
|
146 |
+
* @return string
|
147 |
+
*/
|
148 |
+
public function prepareCode($code)
|
149 |
+
{
|
150 |
+
//Only get the last 4 codes
|
151 |
+
if (strlen($code) > 4) {
|
152 |
+
$code = substr($code, -4);
|
153 |
+
}
|
154 |
+
|
155 |
+
return sprintf("%04s", $code);
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Check if we have an error tag to the error code.
|
161 |
+
*
|
162 |
+
* @param string $code
|
163 |
+
* @param boolean $prepareCode
|
164 |
+
* @return boolean
|
165 |
+
*/
|
166 |
+
public function hasMessageFromCode($code, $prepareCode = true)
|
167 |
+
{
|
168 |
+
$message = $this->getMessageFromCode($code, $prepareCode);
|
169 |
+
return is_string($message);
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Return the message from the error code.
|
175 |
+
*
|
176 |
+
* @param string $code
|
177 |
+
* @param boolean $prepareCode
|
178 |
+
* @return string
|
179 |
+
*/
|
180 |
+
public function getMessageFromCode($code, $prepareCode = true)
|
181 |
+
{
|
182 |
+
//Get the xml error node
|
183 |
+
$node = $this->_getXmlErrorNode($code, $prepareCode);
|
184 |
+
|
185 |
+
//Process the node of exists
|
186 |
+
if ($node) {
|
187 |
+
return (String)$node;
|
188 |
+
}
|
189 |
+
|
190 |
+
return null;
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Process a error code callback.
|
196 |
+
*
|
197 |
+
* @param string $code
|
198 |
+
* @return unknown
|
199 |
+
*/
|
200 |
+
public function processCallbackFromCode($code, $prepareCode = true)
|
201 |
+
{
|
202 |
+
//Check if we could use callbacks
|
203 |
+
if ($this->_getManager()->getRequest()->hasUseCallback()
|
204 |
+
&& $this->_getManager()->getRequest()->getUseCallback()
|
205 |
+
) {
|
206 |
+
return null;
|
207 |
+
}
|
208 |
+
|
209 |
+
//Get the xml error node
|
210 |
+
$node = $this->_getXmlErrorNode($code, $prepareCode);
|
211 |
+
|
212 |
+
//Process the node of exists
|
213 |
+
if ($node && $node->attributes()->callback) {
|
214 |
+
try {
|
215 |
+
//Process the callback
|
216 |
+
$this->_processCallback(
|
217 |
+
(String)$node->attributes()->callback,
|
218 |
+
$code
|
219 |
+
);
|
220 |
+
} catch(Exception $e) {
|
221 |
+
Mage::logException($e);
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
return null;
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Process the given callback.
|
231 |
+
*
|
232 |
+
* @param string $model
|
233 |
+
* @param string $code
|
234 |
+
*/
|
235 |
+
protected function _processCallback($model, $code)
|
236 |
+
{
|
237 |
+
//Defaults
|
238 |
+
$callback = array();
|
239 |
+
$arguments = array();
|
240 |
+
$run = array();
|
241 |
+
|
242 |
+
//Check the callback string
|
243 |
+
if (is_string($model) && !empty($model)) {
|
244 |
+
if (!preg_match(Mage_Cron_Model_Observer::REGEX_RUN_MODEL, $model, $run)) {
|
245 |
+
Mage::throwException(Mage::helper('cron')->__('Invalid model/method definition, expecting "model/class::method".'));
|
246 |
+
}
|
247 |
+
|
248 |
+
if (!($model = Mage::getModel($run[1])) || !method_exists($model, $run[2])) {
|
249 |
+
Mage::throwException(Mage::helper('cron')->__('Invalid callback: %s::%s does not exist', $run[1], $run[2]));
|
250 |
+
}
|
251 |
+
|
252 |
+
//Create the callbacks
|
253 |
+
$callback = array($model, $run[2]);
|
254 |
+
$arguments = array($code, $this->_getManager());
|
255 |
+
}
|
256 |
+
|
257 |
+
//Check for a right callback
|
258 |
+
if (empty($callback)) {
|
259 |
+
Mage::throwException(Mage::helper('cron')->__('No callbacks found'));
|
260 |
+
}
|
261 |
+
|
262 |
+
//Call the callback
|
263 |
+
call_user_func_array($callback, $arguments);
|
264 |
+
}
|
265 |
+
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Return the error node to the given error code.
|
269 |
+
*
|
270 |
+
* @param string $code
|
271 |
+
* @param boolean $prepareCode
|
272 |
+
* @return SimpleXMLElement || null
|
273 |
+
*/
|
274 |
+
protected function _getXmlErrorNode($code, $prepareCode = true)
|
275 |
+
{
|
276 |
+
//Check if we need to prepare the code
|
277 |
+
if ($prepareCode) {
|
278 |
+
$code = $this->prepareCode($code);
|
279 |
+
}
|
280 |
+
|
281 |
+
//Check for the error codes
|
282 |
+
foreach (self::$_xpathRoutes as $xpath) {
|
283 |
+
//Get a specific error message
|
284 |
+
$message = $this->_getXml()->xpath(
|
285 |
+
sprintf(
|
286 |
+
"$xpath",
|
287 |
+
$this->_getArea(),
|
288 |
+
$code,
|
289 |
+
strlen($code) //Don't substact 1 we need to calc. one extra space
|
290 |
+
)
|
291 |
+
);
|
292 |
+
|
293 |
+
if (is_array($message) && count($message) > 0) {
|
294 |
+
return current($message);
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
return null;
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Return the xml object with all error codes.
|
304 |
+
*
|
305 |
+
* @return SimpleXMLElement
|
306 |
+
*/
|
307 |
+
protected function _getXml()
|
308 |
+
{
|
309 |
+
//Get teh xml object
|
310 |
+
if (null === self::$_errorCodes) {
|
311 |
+
|
312 |
+
//Get the error file
|
313 |
+
$errorFile = Mage::getConfig()->getModuleDir('etc', 'Dotsource_Computop').DS.'errors.xml';
|
314 |
+
|
315 |
+
//Set the xml object
|
316 |
+
self::$_errorCodes = simplexml_load_file($errorFile);
|
317 |
+
}
|
318 |
+
|
319 |
+
return self::$_errorCodes;
|
320 |
+
}
|
321 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Handler/Session.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Handler_Session
|
11 |
+
extends Dotsource_Computop_Model_Error_Handler_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
//Add default callback for error
|
17 |
+
if (!$this->hasCallback()) {
|
18 |
+
$this->setCallback('addError');
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @see Dotsource_Computop_Model_Error_Handler_Interface::processHandler()
|
24 |
+
*
|
25 |
+
* @param Varien_Object $request
|
26 |
+
*/
|
27 |
+
public function processHandler(Varien_Object $request)
|
28 |
+
{
|
29 |
+
//Get the message
|
30 |
+
$message = $request->getMessage();
|
31 |
+
|
32 |
+
//If the message is empty we no need to add the message
|
33 |
+
if (empty($message)) {
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
//Get the callback settings
|
38 |
+
$session = $this->getSession();
|
39 |
+
$callback = $this->getCallback();
|
40 |
+
|
41 |
+
//Check for configured session
|
42 |
+
if (!empty($session) && !empty($callback)) {
|
43 |
+
//Check for model path
|
44 |
+
if(is_string($session)) {
|
45 |
+
$session = Mage::getSingleton($session);
|
46 |
+
} else if (!$session instanceof Mage_Core_Model_Session_Abstract) {
|
47 |
+
$this->_getManager()->setError('Session need to extends from the class Mage_Core_Model_Session_Abstract.');
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
+
//Check the callability
|
52 |
+
if (!is_callable(array($session, $callback))) {
|
53 |
+
$this->_getManager()->setError('The callback method can\'t call for the current session.');
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
//Add the message to the session
|
58 |
+
$session->$callback($message);
|
59 |
+
} else {
|
60 |
+
$this->_getManager()->setError('Session and callback are not configured.');
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Handler/Translate.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Handler_Translate
|
11 |
+
extends Dotsource_Computop_Model_Error_Handler_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
//Add default helper
|
17 |
+
if (!$this->hasHelper()) {
|
18 |
+
$this->setHelper('core');
|
19 |
+
}
|
20 |
+
|
21 |
+
//Add default args
|
22 |
+
if (!$this->hasArguments()) {
|
23 |
+
$this->setArguments(array());
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @see Dotsource_Computop_Model_Error_Handler_Interface::processHandler()
|
30 |
+
*
|
31 |
+
* @param Varien_Object $request
|
32 |
+
*/
|
33 |
+
public function processHandler(Varien_Object $request)
|
34 |
+
{
|
35 |
+
$message = $request->getMessage();
|
36 |
+
$args = $request->getArguments();
|
37 |
+
$helper = $this->getHelper();
|
38 |
+
|
39 |
+
//Get helper from string
|
40 |
+
if (is_string($helper)) {
|
41 |
+
$helper = Mage::helper($helper);
|
42 |
+
}
|
43 |
+
|
44 |
+
//Check for helper
|
45 |
+
if(!$helper instanceof Mage_Core_Helper_Abstract) {
|
46 |
+
$this->_getManager()->setError('Helper object is not an instance of Mage_Core_Helper_Abstract.');
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
//We need an array
|
51 |
+
if (empty($args)) {
|
52 |
+
$args = array();
|
53 |
+
}
|
54 |
+
|
55 |
+
//Add to the args
|
56 |
+
array_unshift($args, $message);
|
57 |
+
|
58 |
+
//Set the translated massage
|
59 |
+
$message = call_user_func_array(array($helper, '__'), $args);
|
60 |
+
$request->setMessage($message);
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Manager.php
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Manager
|
11 |
+
{
|
12 |
+
|
13 |
+
/** Holds the chain elements */
|
14 |
+
protected $_handler = array();
|
15 |
+
|
16 |
+
/** Holds a error */
|
17 |
+
protected $_error = null;
|
18 |
+
|
19 |
+
/** Holds the request */
|
20 |
+
protected $_request = null;
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Add a new handler with the given priority.
|
25 |
+
* Lower priority will process first.
|
26 |
+
*
|
27 |
+
* @param mixed $handler
|
28 |
+
* @param string $alias
|
29 |
+
* @param int $priority
|
30 |
+
* @param array $args
|
31 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
32 |
+
*/
|
33 |
+
public function addHandler($handler, $alias, array $args = array(), $priority = 100)
|
34 |
+
{
|
35 |
+
//Get the object
|
36 |
+
if (is_string($handler)) {
|
37 |
+
$handler = Mage::getModel('computop/error_handler_'.$handler, $args);
|
38 |
+
}
|
39 |
+
|
40 |
+
//Check the object
|
41 |
+
if (!$handler instanceof Dotsource_Computop_Model_Error_Handler_Abstract) {
|
42 |
+
Mage::throwException('Handler need to extends from class Dotsource_Computop_Model_Error_Handler_Abstract.');
|
43 |
+
}
|
44 |
+
|
45 |
+
//Create a new bucket for the priority
|
46 |
+
if (!array_key_exists($priority, $this->_handler)) {
|
47 |
+
$this->_handler[$priority] = array();
|
48 |
+
}
|
49 |
+
|
50 |
+
//Add the handler
|
51 |
+
$this->_handler[$priority][$alias] = $handler;
|
52 |
+
$handler->addManager($this);
|
53 |
+
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Remove the given handler.
|
60 |
+
*
|
61 |
+
* @param mixed $alias
|
62 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
63 |
+
*/
|
64 |
+
public function removeHandler($alias)
|
65 |
+
{
|
66 |
+
//Check the given alias
|
67 |
+
$isAliasString = is_string($alias);
|
68 |
+
$isAliasObject = is_object($alias);
|
69 |
+
|
70 |
+
//Check if we can do something
|
71 |
+
if (!($isAliasObject || $isAliasString)) {
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
//Now try to remove the alias
|
76 |
+
foreach ($this->_getHandler() as $priority => $handlers) {
|
77 |
+
foreach ($handlers as $handlerAlias => $handler) {
|
78 |
+
if (($isAliasString && $alias == $handlerAlias)
|
79 |
+
|| ($isAliasObject && $alias == $handler)
|
80 |
+
) {
|
81 |
+
unset($this->_handler[$priority][$handlerAlias]);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Update the handler.
|
92 |
+
*
|
93 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
94 |
+
*/
|
95 |
+
public function updateHandler($alias, $method, $args = array())
|
96 |
+
{
|
97 |
+
//Check the given alias
|
98 |
+
$isAliasString = is_string($alias);
|
99 |
+
$isAliasObject = is_object($alias);
|
100 |
+
|
101 |
+
//Check if we can do something
|
102 |
+
if (!($isAliasObject || $isAliasString)) {
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
//Args need to be an array
|
107 |
+
if (!is_array($args)) {
|
108 |
+
$args = array($args);
|
109 |
+
}
|
110 |
+
|
111 |
+
//Now try to remove the alias
|
112 |
+
foreach ($this->_getHandler() as $handlers) {
|
113 |
+
foreach ($handlers as $handlerAlias => $handler) {
|
114 |
+
if (($isAliasString && $alias == $handlerAlias)
|
115 |
+
|| ($isAliasObject && $alias == $handler)
|
116 |
+
) {
|
117 |
+
//Call the method with the given args
|
118 |
+
call_user_func_array(array($handler, $method), $args);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Process the given request object.
|
129 |
+
*
|
130 |
+
* @param Varien_Object $request
|
131 |
+
*/
|
132 |
+
public function processChain(Varien_Object $request)
|
133 |
+
{
|
134 |
+
//Set the request as current processing request
|
135 |
+
$this->_request = $request;
|
136 |
+
|
137 |
+
//Sort the handlers
|
138 |
+
ksort($this->_handler);
|
139 |
+
|
140 |
+
/* @var $handler Dotsource_Computop_Model_Error_Handler_Abstract */
|
141 |
+
foreach ($this->_getHandler() as $handlers) {
|
142 |
+
foreach ($handlers as $handler) {
|
143 |
+
//Process the handler
|
144 |
+
$handler->processHandler($request);
|
145 |
+
|
146 |
+
//Check for error
|
147 |
+
if ($this->hasError()) {
|
148 |
+
Mage::log($this->getError(), Zend_Log::ERR, 'computop_error_manager.log');
|
149 |
+
return false;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return true;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Process the given message with the given arguments.
|
160 |
+
*
|
161 |
+
* @param string $message
|
162 |
+
* @param boolean $useCallbacks
|
163 |
+
* @param array $args
|
164 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
165 |
+
*/
|
166 |
+
public function processMessage($message, $useCallbacks = true, array $args = array())
|
167 |
+
{
|
168 |
+
return $this->processChain(new Varien_Object(
|
169 |
+
array(
|
170 |
+
'message' => $message,
|
171 |
+
'use_callbacks' => $useCallbacks,
|
172 |
+
'arguments' => $args
|
173 |
+
)
|
174 |
+
));
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Process the given error code.
|
180 |
+
*
|
181 |
+
* @param string $message
|
182 |
+
* @param boolean $useCallbacks
|
183 |
+
* @param array $args
|
184 |
+
* @return Dotsource_Clickpay_Model_Error_Manager
|
185 |
+
*/
|
186 |
+
public function processErrorCode($errorCode, $useCallbacks = true, array $args = array())
|
187 |
+
{
|
188 |
+
return $this->processChain(new Varien_Object(
|
189 |
+
array(
|
190 |
+
'message' => $errorCode,
|
191 |
+
'use_callbacks' => $useCallbacks,
|
192 |
+
'arguments' => $args,
|
193 |
+
'is_error_code' => true,
|
194 |
+
)
|
195 |
+
));
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Return the current processing request.
|
201 |
+
*
|
202 |
+
* @return Varien_Object
|
203 |
+
*/
|
204 |
+
public function getRequest()
|
205 |
+
{
|
206 |
+
return $this->_request;
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Return the chain elements as array.
|
212 |
+
*
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
protected function _getHandler()
|
216 |
+
{
|
217 |
+
return $this->_handler;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Set a error message to the manager.
|
223 |
+
*
|
224 |
+
* @param string $message
|
225 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
226 |
+
*/
|
227 |
+
public function setError($message)
|
228 |
+
{
|
229 |
+
$this->_error = $message;
|
230 |
+
return $this;
|
231 |
+
}
|
232 |
+
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Return the error.
|
236 |
+
*
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
public function getError()
|
240 |
+
{
|
241 |
+
return $this->_error;
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Check if the manager has an error message.
|
247 |
+
*
|
248 |
+
* @return boolean
|
249 |
+
*/
|
250 |
+
public function hasError()
|
251 |
+
{
|
252 |
+
return null !== $this->_error;
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Reset the error message.
|
258 |
+
*
|
259 |
+
* @return Dotsource_Computop_Model_Error_Manager
|
260 |
+
*/
|
261 |
+
public function reset()
|
262 |
+
{
|
263 |
+
$this->_error = null;
|
264 |
+
$this->_request = null;
|
265 |
+
return $this;
|
266 |
+
}
|
267 |
+
}
|
app/code/community/Dotsource/Computop/Model/Error/Observer.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Error_Observer
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Destroys the quote and redirect to the base url.
|
15 |
+
*
|
16 |
+
* @param string $code
|
17 |
+
* @param Dotsource_Computop_Model_Error_Manager $manager
|
18 |
+
*/
|
19 |
+
public function destroyQuote($code, Dotsource_Computop_Model_Error_Manager $manager)
|
20 |
+
{
|
21 |
+
$this->_getHelper()->getFrontendCheckoutSession()->clear();
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Update the exception handler for redirect to the checkout payment.
|
27 |
+
*
|
28 |
+
* @param string $code
|
29 |
+
* @param Dotsource_Computop_Model_Error_Manager $manager
|
30 |
+
*/
|
31 |
+
public function checkoutPaymentRedirect($code, Dotsource_Computop_Model_Error_Manager $manager)
|
32 |
+
{
|
33 |
+
//Redirect to payment method
|
34 |
+
$this->_getHelper()->getFrontendCheckoutSession()
|
35 |
+
->setGotoSection('payment')
|
36 |
+
->setUpdateSection('payment-method');
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Clears the current quote payment.
|
42 |
+
*
|
43 |
+
* @param string $code
|
44 |
+
* @param Dotsource_Computop_Model_Error_Manager $manager
|
45 |
+
*/
|
46 |
+
public function clearQuotePayment($code, Dotsource_Computop_Model_Error_Manager $manager)
|
47 |
+
{
|
48 |
+
//Get the current payment
|
49 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
50 |
+
$payment = $quote->getPayment();
|
51 |
+
|
52 |
+
//Check if we need to reset the payment
|
53 |
+
if ($payment instanceof Mage_Sales_Model_Quote_Payment
|
54 |
+
&& $payment->hasData($payment->getIdFieldName())
|
55 |
+
) {
|
56 |
+
//Remove the payment
|
57 |
+
$quote
|
58 |
+
->removePayment()
|
59 |
+
->save();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Disable the current used payment method for the current checkout
|
66 |
+
* session.
|
67 |
+
*
|
68 |
+
* @param string $code
|
69 |
+
* @param Dotsource_Computop_Model_Error_Manager $manager
|
70 |
+
*/
|
71 |
+
public function disablePaymentMethod($code, Dotsource_Computop_Model_Error_Manager $manager)
|
72 |
+
{
|
73 |
+
//Get the current payment
|
74 |
+
$session = $this->_getHelper()->getFrontendCheckoutSession();
|
75 |
+
$quote = $session->getQuote();
|
76 |
+
$payment = $quote->getPayment();
|
77 |
+
|
78 |
+
//Check if we need to reset the payment
|
79 |
+
if ($payment instanceof Mage_Sales_Model_Quote_Payment
|
80 |
+
&& $payment->hasData($payment->getIdFieldName())
|
81 |
+
) {
|
82 |
+
//Disable the current used payment method
|
83 |
+
$this->_getHelper()->getPaymentHelper()->disablePaymentForCheckoutSession(
|
84 |
+
$payment->getMethod()
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
//Also clear the payment
|
89 |
+
$this->clearQuotePayment($code, $manager);
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Return the computop helper.
|
95 |
+
*
|
96 |
+
* @return Dotsource_Computop_Helper_Data
|
97 |
+
*/
|
98 |
+
protected function _getHelper()
|
99 |
+
{
|
100 |
+
return Mage::helper('computop');
|
101 |
+
}
|
102 |
+
}
|
app/code/community/Dotsource/Computop/Model/Exception.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 18.05.2010 10:40:37
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Exception extends Exception
|
15 |
+
{
|
16 |
+
|
17 |
+
}
|
app/code/community/Dotsource/Computop/Model/Mysql4/Action.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Mysql4_Action
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('computop/action', 'entity_id');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Dotsource/Computop/Model/Mysql4/Action/Collection.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Mysql4_Action_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('computop/action');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Dotsource/Computop/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Mysql4_Setup
|
11 |
+
extends Mage_Sales_Model_Mysql4_Setup
|
12 |
+
{
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Return the flat table name from the given entity type.
|
17 |
+
* If the given entity type is not a flat table the method
|
18 |
+
* return null.
|
19 |
+
*
|
20 |
+
* @param string $entityType
|
21 |
+
* @return string || null
|
22 |
+
*/
|
23 |
+
public function getFlatTableName($entityType)
|
24 |
+
{
|
25 |
+
if ($this->isFlatTable($entityType)) {
|
26 |
+
return $this->_flatEntityTables[$entityType];
|
27 |
+
}
|
28 |
+
|
29 |
+
return null;
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Return true if the entity type has a flat table.
|
35 |
+
*
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
public function isFlatTable($entityType)
|
39 |
+
{
|
40 |
+
return isset($this->_flatEntityTables[$entityType]);
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return true if the flat table exists in the database.
|
46 |
+
*
|
47 |
+
* @param string $entityType
|
48 |
+
* @return boolean
|
49 |
+
*/
|
50 |
+
public function flatTableExists($entityType)
|
51 |
+
{
|
52 |
+
return $this->isFlatTable($entityType)
|
53 |
+
&& $this->_flatTableExist($this->getFlatTableName($entityType));
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @see Mage_Eav_Model_Entity_Setup::removeAttribute()
|
59 |
+
*
|
60 |
+
* @param mixed $entityTypeId
|
61 |
+
* @param mixed $code
|
62 |
+
* @return Dotsource_Computop_Model_Mysql4_Setup
|
63 |
+
*/
|
64 |
+
public function removeAttribute($entityTypeId, $code)
|
65 |
+
{
|
66 |
+
if ($this->flatTableExists($entityTypeId)) {
|
67 |
+
$this->_removeFlatAttribute($this->getFlatTableName($entityTypeId), $code);
|
68 |
+
} else {
|
69 |
+
parent::removeAttribute($entityTypeId, $code);
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Drop the given column from the given table.
|
78 |
+
*
|
79 |
+
* @param string $table
|
80 |
+
* @param string $column
|
81 |
+
* @return Dotsource_Computop_Model_Mysql4_Setup
|
82 |
+
*/
|
83 |
+
public function _removeFlatAttribute($table, $column)
|
84 |
+
{
|
85 |
+
$tableInfo = $this->getConnection()->describeTable($this->getTable($table));
|
86 |
+
if (isset($tableInfo[$column])) {
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->getConnection()->dropColumn($this->getTable($table), $column);
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Add a Grid Attribute.
|
97 |
+
*
|
98 |
+
* @param $table
|
99 |
+
* @param $attribute
|
100 |
+
* @param $attr
|
101 |
+
* @param $entityTypeId
|
102 |
+
*/
|
103 |
+
public function addFlatGridAttribute($entityTypeId, $code, array $attr)
|
104 |
+
{
|
105 |
+
//Check if a flat table exists
|
106 |
+
if ($this->isFlatTable($entityTypeId)) {
|
107 |
+
//Force add grid
|
108 |
+
$attr['grid'] = true;
|
109 |
+
|
110 |
+
//Create new grid attribute
|
111 |
+
$this->_addGridAttribute($this->getFlatTableName($entityTypeId), $code, $attr, $entityTypeId);
|
112 |
+
}
|
113 |
+
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
}
|
app/code/community/Dotsource/Computop/Model/Mysql4/Transaction.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Mysql4_Transaction
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('computop/transaction', 'entity_id');
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Check if the given reference code is unique.
|
23 |
+
*
|
24 |
+
* @param string $reference
|
25 |
+
* @return boolean
|
26 |
+
*/
|
27 |
+
public function isTransactionCodeUnique($reference)
|
28 |
+
{
|
29 |
+
//Empty is bad
|
30 |
+
if (empty($reference)) {
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
|
34 |
+
//Try to select the reference code
|
35 |
+
$select = $this->_getReadAdapter()
|
36 |
+
->select()
|
37 |
+
->from($this->getMainTable())
|
38 |
+
->where('transaction_code = ?', $reference);
|
39 |
+
|
40 |
+
//Execute the query
|
41 |
+
$result = $this->_getReadAdapter()->fetchOne($select);
|
42 |
+
|
43 |
+
//If the row count is zero the reference code is not in the table
|
44 |
+
return empty($result);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Dotsource/Computop/Model/Mysql4/Transaction/Collection.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Mysql4_Transaction_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('computop/transaction');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Dotsource/Computop/Model/Observer.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Observer
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Delete all transaction information from the computop session, quote
|
16 |
+
* and quote payment to create a new transaction model.
|
17 |
+
*/
|
18 |
+
public function deleteComputopTransaction()
|
19 |
+
{
|
20 |
+
//Clear the session
|
21 |
+
Mage::getSingleton('computop/session')->clearSession();
|
22 |
+
|
23 |
+
//Get the quote for delete the transaction id from the payment
|
24 |
+
//and delete the reserved increment id
|
25 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
26 |
+
|
27 |
+
//Have a valid quote?
|
28 |
+
if (!$quote || !$quote->getId() || !$quote->getPayment()->getComputopTransactionId()) {
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
//Reset the computop transaction id and the save the quote
|
33 |
+
$quote->getPayment()
|
34 |
+
->setComputopTransactionId(null)
|
35 |
+
->save();
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Clear the payment deactivation for the current.
|
41 |
+
*/
|
42 |
+
public function clearPaymentDeactivation()
|
43 |
+
{
|
44 |
+
$this->_getHelper()->getPaymentHelper()->clearPaymentDeactivation();
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Add mass actions to the sales order view grid.
|
50 |
+
*
|
51 |
+
* @param unknown_type $observer
|
52 |
+
*/
|
53 |
+
public function onAdminhtmlBlockHtmlBefore($observer)
|
54 |
+
{
|
55 |
+
/* @var $block Mage_Adminhtml_Block_Sales_Order_Grid */
|
56 |
+
$block = $observer->getBlock();
|
57 |
+
|
58 |
+
//Only need to add mass actions for Mage_Adminhtml_Block_Sales_Order_Grid block
|
59 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
|
60 |
+
//Create a full invoice
|
61 |
+
$block->getMassactionBlock()->addItem(
|
62 |
+
'computop_create_invoice',
|
63 |
+
array(
|
64 |
+
'label' => $this->_getHelper()->__('CT: Create Invoice'),
|
65 |
+
'url' => $block->getUrl('computop/adminhtml_massaction/massInvoice'),
|
66 |
+
)
|
67 |
+
);
|
68 |
+
|
69 |
+
//Add massaction create invoice and ship
|
70 |
+
$block->getMassactionBlock()->addItem(
|
71 |
+
'computop_create_invoice_shipment',
|
72 |
+
array(
|
73 |
+
'label' => $this->_getHelper()->__('CT: Create Invoice and Shipment'),
|
74 |
+
'url' => $block->getUrl('computop/adminhtml_massaction/massInvoiceShipment'),
|
75 |
+
)
|
76 |
+
);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Only can create online refunds.
|
83 |
+
*
|
84 |
+
* @param unknown_type $observer
|
85 |
+
*/
|
86 |
+
public function onSalesOrderCreditmemoRefund($observer)
|
87 |
+
{
|
88 |
+
/* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
|
89 |
+
$creditmemo = $observer->getCreditmemo();
|
90 |
+
$order = $creditmemo->getOrder();
|
91 |
+
|
92 |
+
//If we use a non computop payment we don't need to process this
|
93 |
+
if (!$order->getPayment()->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
//If we use a computop payment we force to refund online only
|
98 |
+
if (!$creditmemo->hasInvoiceId()) {
|
99 |
+
Mage::throwException(
|
100 |
+
$this->_getHelper()->__('You can only create a credit memo in referenced to an invoiced.')
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
//Check for online credit memo
|
105 |
+
if ($creditmemo->hasDoTransaction() && !$creditmemo->getDoTransaction()) {
|
106 |
+
Mage::throwException(
|
107 |
+
$this->_getHelper()->__('You can only create online credit memos.')
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
//Check for online credit memo
|
112 |
+
if ($creditmemo->getPaymentRefundDisallowed()) {
|
113 |
+
Mage::throwException(
|
114 |
+
$this->_getHelper()->__('The payment method not allow to refund.')
|
115 |
+
);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Only can create online invoices.
|
122 |
+
*
|
123 |
+
* @param unknown_type $observer
|
124 |
+
*/
|
125 |
+
public function onSalesOrderInvoicePay($observer)
|
126 |
+
{
|
127 |
+
/* @var $invoice Mage_Sales_Model_Order_Invoice */
|
128 |
+
$invoice = $observer->getInvoice();
|
129 |
+
$order = $invoice->getOrder();
|
130 |
+
|
131 |
+
//If we use a non computop payment we don't need to process this
|
132 |
+
if (!$order->getPayment()->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
|
136 |
+
//If we use a computop payment we force to refund online only
|
137 |
+
if ($invoice->hasRequestedCaptureCase()
|
138 |
+
&& Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE != $invoice->getRequestedCaptureCase()
|
139 |
+
) {
|
140 |
+
Mage::throwException(
|
141 |
+
$this->_getHelper()->__('This order was paid with an computop payment. You\'r only allowed to create online invoices.')
|
142 |
+
);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Extends the sales order grid with the RefNr from the payment.
|
149 |
+
*
|
150 |
+
* @param $observer
|
151 |
+
*/
|
152 |
+
public function onSalesOrderResourceInitVirtualGridColumns($observer)
|
153 |
+
{
|
154 |
+
/* @var $resource Mage_Sales_Model_Mysql4_Order */
|
155 |
+
$resource = $observer->getResource();
|
156 |
+
|
157 |
+
//Add the computop_transaction_id from the payment
|
158 |
+
$resource->addVirtualGridColumn(
|
159 |
+
'computop_transaction_id',
|
160 |
+
'sales/order_payment',
|
161 |
+
array('entity_id' => 'parent_id'),
|
162 |
+
'computop_transaction_id'
|
163 |
+
);
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Return the computop helper.
|
169 |
+
*
|
170 |
+
* @return Dotsource_Computop_Helper_Data
|
171 |
+
*/
|
172 |
+
protected function _getHelper()
|
173 |
+
{
|
174 |
+
return Mage::helper('computop');
|
175 |
+
}
|
176 |
+
}
|
app/code/community/Dotsource/Computop/Model/Observer/Session.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Session
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* If the checkout session getting cleared we need to unset the data
|
16 |
+
* in the computop session.
|
17 |
+
*
|
18 |
+
* @param Varien_Event_Observer $observer
|
19 |
+
*/
|
20 |
+
public function clearCustomerSession(Varien_Event_Observer $observer)
|
21 |
+
{
|
22 |
+
//Clear the computop session
|
23 |
+
Mage::getSingleton('computop/session')->clearSession();
|
24 |
+
|
25 |
+
//Clear the iframe url from the checkout session
|
26 |
+
$this->_getHelper()->getCheckoutSession()->unsIframeUrl();
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Return the computop helper.
|
32 |
+
*
|
33 |
+
* @return Dotsource_Computop_Helper_Data
|
34 |
+
*/
|
35 |
+
protected function _getHelper()
|
36 |
+
{
|
37 |
+
return Mage::helper('computop');
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Abstract.php
ADDED
@@ -0,0 +1,982 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class Dotsource_Computop_Model_Payment_Abstract
|
3 |
+
extends Mage_Payment_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
/** Holds the transaction prefix */
|
7 |
+
const COMPUTOP_PREFIX = 'Computop Payment:';
|
8 |
+
|
9 |
+
const WAITING_AUTHORIZATION = 'waiting_auth_computop_note';
|
10 |
+
|
11 |
+
const WAITING_CAPTURE = 'waiting_capture_computop_note';
|
12 |
+
|
13 |
+
const READY_FOR_CAPTURE = 'ready_computop_capture';
|
14 |
+
|
15 |
+
protected $_isGateway = true;
|
16 |
+
|
17 |
+
protected $_canAuthorize = true;
|
18 |
+
|
19 |
+
protected $_canCapture = true;
|
20 |
+
|
21 |
+
protected $_canCapturePartial = true;
|
22 |
+
|
23 |
+
protected $_canRefund = true;
|
24 |
+
|
25 |
+
protected $_canRefundInvoicePartial = true;
|
26 |
+
|
27 |
+
protected $_canVoid = true;
|
28 |
+
|
29 |
+
/** Don't available in backend */
|
30 |
+
protected $_canUseInternal = false;
|
31 |
+
|
32 |
+
protected $_canUseCheckout = true;
|
33 |
+
|
34 |
+
protected $_canUseForMultishipping = true;
|
35 |
+
|
36 |
+
/** Check if we can capture direct from the backend */
|
37 |
+
protected $_canBackendDirectCapture = false;
|
38 |
+
|
39 |
+
/** Holds the path to the model */
|
40 |
+
protected $_requestModelInfo = null;
|
41 |
+
|
42 |
+
/** Holds the default path for the request models */
|
43 |
+
protected $_requestModelDefault = 'computop/payment_request_default_';
|
44 |
+
|
45 |
+
/** Holds the process cancel model */
|
46 |
+
protected $_cancelProcessModel = null;
|
47 |
+
|
48 |
+
/** Holds the redirect url */
|
49 |
+
//Static to fix issue
|
50 |
+
protected static $_redirectUrl = null;
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @see Mage_Payment_Model_Method_Abstract::canUseCheckout()
|
55 |
+
*
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
public function canUseCheckout()
|
59 |
+
{
|
60 |
+
//The payment method can use if the payment method can use in checkout and demo mode is active or
|
61 |
+
//the payment method is not currently blocked
|
62 |
+
return parent::canUseCheckout()
|
63 |
+
&& $this->_getHelper()->isGlobalActive(true)
|
64 |
+
&& ($this->_getHelper()->isDemoMode() || !$this->_getHelper()->getPaymentHelper()->isPaymentDisabled($this->getCode()));
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Disable payment method if it's global deactivated.
|
70 |
+
*
|
71 |
+
* @return boolean
|
72 |
+
*/
|
73 |
+
public function canUseInternal()
|
74 |
+
{
|
75 |
+
return parent::canUseInternal() && $this->_getHelper()->isGlobalActive(true);
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Create an return a configured request model.
|
81 |
+
*
|
82 |
+
* @param string $requestModelName
|
83 |
+
* @param Varien_Object $payment
|
84 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
85 |
+
*/
|
86 |
+
protected function _createRequestModel($requestModelName, Varien_Object $payment, $computopArea = null)
|
87 |
+
{
|
88 |
+
//Set auto as default
|
89 |
+
if (null === $computopArea) {
|
90 |
+
$computopArea = Dotsource_Computop_Helper_Data::AUTO;
|
91 |
+
}
|
92 |
+
|
93 |
+
//We only can ship invoiced items
|
94 |
+
$payment->setPreparedMessage(self::COMPUTOP_PREFIX);
|
95 |
+
|
96 |
+
//Get the right request model and set the payment model
|
97 |
+
$request = null;
|
98 |
+
|
99 |
+
try {
|
100 |
+
$request = Mage::getModel($this->_getRequestModelPath().$requestModelName);
|
101 |
+
} catch (Exception $e) {}
|
102 |
+
|
103 |
+
//check for default request
|
104 |
+
if (empty($request)) {
|
105 |
+
$request = Mage::getModel($this->_getDefaultRequestModelPath().$requestModelName);
|
106 |
+
}
|
107 |
+
|
108 |
+
//Register the current payment object
|
109 |
+
$request
|
110 |
+
->setComputopTransactionArea($computopArea)
|
111 |
+
->setPayment($payment)
|
112 |
+
->setPaymentMethod($this);
|
113 |
+
|
114 |
+
//Return the configured request model
|
115 |
+
return $request;
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
121 |
+
*
|
122 |
+
* @param Varien_Object $payment
|
123 |
+
* @param unknown_type $amount
|
124 |
+
* @return Mage_Payment_Model_Abstract
|
125 |
+
*/
|
126 |
+
public function authorize(Varien_Object $payment, $amount)
|
127 |
+
{
|
128 |
+
//Get the request model
|
129 |
+
$request = $this->_createRequestModel('authorize', $payment);
|
130 |
+
|
131 |
+
//No need to close the transaction in any case (auth, capture)
|
132 |
+
$payment->setIsTransactionClosed(false);
|
133 |
+
|
134 |
+
//Set the amount
|
135 |
+
$request->setAmount($amount);
|
136 |
+
|
137 |
+
//Send the capture request to computop
|
138 |
+
$this->_getConnection()->sendRequest($request);
|
139 |
+
|
140 |
+
//Check if the transaction has produce an error
|
141 |
+
if (!$request->getResponseModel()->hasError()) {
|
142 |
+
//Add transaction information
|
143 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
144 |
+
$payment,
|
145 |
+
$request->getResponseModel()
|
146 |
+
);
|
147 |
+
} else {
|
148 |
+
$this->_getHelper()->getPaymentHelper()
|
149 |
+
->getFrontendErrorManager()
|
150 |
+
->updateHandler('exception', 'setModule', 'Mage_Core')
|
151 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
152 |
+
}
|
153 |
+
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* @see Mage_Payment_Model_Method_Abstract::capture()
|
160 |
+
*
|
161 |
+
* @param Varien_Object $payment
|
162 |
+
* @param float $amount
|
163 |
+
* @return Mage_Payment_Model_Abstract
|
164 |
+
*/
|
165 |
+
public function capture(Varien_Object $payment, $amount)
|
166 |
+
{
|
167 |
+
//Choose the right backend capture method
|
168 |
+
if ($this->_canCaptureAuthorization($payment)) {
|
169 |
+
$this->_capture($payment, $amount);
|
170 |
+
} else if($this->canBackendDirectCapture()) {
|
171 |
+
$this->_directBackendCapture($payment, $amount);
|
172 |
+
} else {
|
173 |
+
$this->_getHelper()->getPaymentHelper()
|
174 |
+
->getBackendErrorManager('capture')
|
175 |
+
->processMessage('There is no open authorization to capture.');
|
176 |
+
}
|
177 |
+
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Capture an open authorization.
|
184 |
+
*
|
185 |
+
* @param Varien_Object $payment
|
186 |
+
* @param float $amount
|
187 |
+
*/
|
188 |
+
protected function _capture(Varien_Object $payment, $amount)
|
189 |
+
{
|
190 |
+
//check for open authorization
|
191 |
+
$hasAvilableAuth = $this->_canCaptureAuthorization($payment);
|
192 |
+
|
193 |
+
//We need for etm and non etm a open authorization
|
194 |
+
if (!$hasAvilableAuth) {
|
195 |
+
$this->_getHelper()->getPaymentHelper()
|
196 |
+
->getBackendErrorManager('capture')
|
197 |
+
->processMessage('There is no open authorization to capture.');
|
198 |
+
}
|
199 |
+
|
200 |
+
//Get the request model
|
201 |
+
$request = $this->_createRequestModel('capture', $payment);
|
202 |
+
|
203 |
+
//Set the authorization transaction model and the invoice amount
|
204 |
+
$request
|
205 |
+
->setReferencedTransactionModel($payment->getAuthorizationTransaction())
|
206 |
+
->setAmount($amount);
|
207 |
+
|
208 |
+
//Send the capture request to computop
|
209 |
+
$this->_getConnection()->sendRequest($request);
|
210 |
+
|
211 |
+
//Check if the transaction has produce an error
|
212 |
+
if (!$request->getResponseModel()->hasError()) {
|
213 |
+
//Add transaction information
|
214 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
215 |
+
$payment,
|
216 |
+
$request->getResponseModel()
|
217 |
+
);
|
218 |
+
|
219 |
+
//Magento checks if the parent transaction is need to close but if etm
|
220 |
+
//is disabled we force to close the parent transaction
|
221 |
+
if (!$this->getConfigData('etm_active')) {
|
222 |
+
$payment->setShouldCloseParentTransaction(true);
|
223 |
+
}
|
224 |
+
|
225 |
+
//Don't close the capture transaction we are available to refund
|
226 |
+
$payment->setIsTransactionClosed(false);
|
227 |
+
} else {
|
228 |
+
$this->_getHelper()->getPaymentHelper()
|
229 |
+
->getBackendErrorManager('capture')
|
230 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Process a capture if no previous authorization is open but
|
237 |
+
* all payment information are available to process a new capture.
|
238 |
+
*
|
239 |
+
* @param Varien_Object $payment
|
240 |
+
* @param float $amount
|
241 |
+
*/
|
242 |
+
protected function _directBackendCapture(Varien_Object $payment, $amount)
|
243 |
+
{
|
244 |
+
//Get the request model
|
245 |
+
$request = $this->_createRequestModel('capture_new', $payment);
|
246 |
+
|
247 |
+
//Set the invoice amount
|
248 |
+
$request->setAmount($amount);
|
249 |
+
|
250 |
+
//We do a direct capture
|
251 |
+
//Don't close the parant -> we don't have a parent (auth) transaction
|
252 |
+
$payment
|
253 |
+
->setParentTransactionId(null)
|
254 |
+
->setShouldCloseParentTransaction(false);
|
255 |
+
|
256 |
+
//Send the capture request to computop
|
257 |
+
$this->_getConnection()->sendRequest($request);
|
258 |
+
|
259 |
+
//Check if the transaction has produce an error
|
260 |
+
if (!$request->getResponseModel()->hasError()) {
|
261 |
+
//Add transaction information
|
262 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
263 |
+
$payment,
|
264 |
+
$request->getResponseModel()
|
265 |
+
);
|
266 |
+
|
267 |
+
//Don't close the capture transaction we are available to refund
|
268 |
+
$payment->setIsTransactionClosed(false);
|
269 |
+
} else {
|
270 |
+
$this->_getHelper()->getPaymentHelper()
|
271 |
+
->getBackendErrorManager('capture')
|
272 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
/**
|
278 |
+
* @see Mage_Payment_Model_Method_Abstract::cancel()
|
279 |
+
*
|
280 |
+
* @param Varien_Object $payment
|
281 |
+
* @return Mage_Payment_Model_Abstract
|
282 |
+
*/
|
283 |
+
public function cancel(Varien_Object $payment)
|
284 |
+
{
|
285 |
+
//Do void the amount if we can
|
286 |
+
if ($this->canVoid($payment)) {
|
287 |
+
$this->void($payment);
|
288 |
+
return $this;
|
289 |
+
}
|
290 |
+
|
291 |
+
/* @var $order Mage_Sales_Model_Order */
|
292 |
+
$order = $payment->getOrder();
|
293 |
+
|
294 |
+
/* @var $cancelProcess Dotsource_Computop_Model_Cancelprocess */
|
295 |
+
$cancelProcess = $this->getCancelProcessModel($payment);
|
296 |
+
$errors = array();
|
297 |
+
$success = array();
|
298 |
+
|
299 |
+
//Create a special error manager for refund method
|
300 |
+
if (null === Mage::registry('error_refund_manager')) {
|
301 |
+
$errorRefundManager = $this->_getHelper()->getPaymentHelper()
|
302 |
+
->getBackendErrorManager()
|
303 |
+
->removeHandler('session')
|
304 |
+
->updateHandler('exception', 'unsetData', 'module');
|
305 |
+
|
306 |
+
//Register the error manager
|
307 |
+
Mage::register('error_refund_manager', $errorRefundManager);
|
308 |
+
}
|
309 |
+
|
310 |
+
//Do refunding all online invoices
|
311 |
+
foreach ($cancelProcess->getOnlinePaidInvoices() as $invoice) {
|
312 |
+
try {
|
313 |
+
//Create a credit memo from the invoice
|
314 |
+
$creditmemo = $cancelProcess->createFullCreditmemoFromInvoice($invoice);
|
315 |
+
|
316 |
+
//We only need to process real credit memos
|
317 |
+
if (null === $creditmemo) {
|
318 |
+
continue;
|
319 |
+
}
|
320 |
+
|
321 |
+
//If we register the credit memo we call automatically the refund method
|
322 |
+
//with the right transaction
|
323 |
+
$creditmemo->register();
|
324 |
+
|
325 |
+
//Save the credit memo
|
326 |
+
$order->addRelatedObject($creditmemo);
|
327 |
+
|
328 |
+
//Add the success message
|
329 |
+
$success[] = $this->_getHelper()->__(
|
330 |
+
"Successfully refund an amount of %s from invoice #%s.",
|
331 |
+
$order->getBaseCurrency()->formatPrecision($creditmemo->getBaseGrandTotal(), 2, array(), false),
|
332 |
+
$invoice->getIncrementId()
|
333 |
+
);
|
334 |
+
} catch (Exception $e) {
|
335 |
+
try {
|
336 |
+
$amount = $cancelProcess->getRefundableAmountFromInvoice($invoice);
|
337 |
+
$errors[] = $this->_getHelper()->__(
|
338 |
+
"Can't refund the amount of %s from invoice #%s. (%s)",
|
339 |
+
$order->getBaseCurrency()->formatPrecision($amount, 2, array(), false),
|
340 |
+
$invoice->getIncrementId(),
|
341 |
+
$e->getMessage()
|
342 |
+
);
|
343 |
+
} catch (Exception $innerE) {
|
344 |
+
$errors[] = $this->_getHelper()->__(
|
345 |
+
"Can't refund the invoice #%s.",
|
346 |
+
$invoice->getIncrementId(),
|
347 |
+
$innerE->getMessage()
|
348 |
+
);
|
349 |
+
}
|
350 |
+
}
|
351 |
+
}
|
352 |
+
|
353 |
+
//Get the managers
|
354 |
+
$successManagement = $this->_getHelper()->getPaymentHelper('cancel')->getBackendErrorManager();
|
355 |
+
$errorManagement = $this->_getHelper()->getPaymentHelper('cancel')->getBackendErrorManager();
|
356 |
+
|
357 |
+
//No need to convert the message
|
358 |
+
$errorManagement
|
359 |
+
->removeHandler('message');
|
360 |
+
|
361 |
+
//Success manager don't need to throw exception and change the session callback
|
362 |
+
$successManagement
|
363 |
+
->removeHandler('message')
|
364 |
+
->removeHandler('exception')
|
365 |
+
->updateHandler('session', 'setCallback', 'addSuccess');
|
366 |
+
|
367 |
+
//Process error handling
|
368 |
+
if (empty($success) && empty($errors)) {
|
369 |
+
$successManagement
|
370 |
+
->updateHandler('session', 'setCallback', 'addNotice')
|
371 |
+
->processMessage("There was no online refunding.");
|
372 |
+
} else {
|
373 |
+
//Remove the exception handler if we have an success action
|
374 |
+
if (!empty($success)) {
|
375 |
+
$errorManagement->removeHandler('exception');
|
376 |
+
}
|
377 |
+
|
378 |
+
if (!empty($success)) {
|
379 |
+
$message = implode('<br/>', $success);
|
380 |
+
$successManagement->processMessage($message);
|
381 |
+
}
|
382 |
+
|
383 |
+
if (!empty($errors)) {
|
384 |
+
$message = implode('<br/>', $errors);
|
385 |
+
$errorManagement->processMessage($message);
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
return $this;
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
/**
|
394 |
+
* @see Mage_Payment_Model_Method_Abstract::refund()
|
395 |
+
*
|
396 |
+
* @param Varien_Object $payment
|
397 |
+
* @param unknown_type $amount
|
398 |
+
* @return Mage_Payment_Model_Abstract
|
399 |
+
*/
|
400 |
+
public function refund(Varien_Object $payment, $amount)
|
401 |
+
{
|
402 |
+
/* @var $order Mage_Sales_Model_Order */
|
403 |
+
$order = $payment->getOrder();
|
404 |
+
|
405 |
+
//Get the transaction id from the invoice this is the parent id for the creditmemo
|
406 |
+
/* @var $payment Mage_Sales_Model_Order_Payment */
|
407 |
+
$captureTransaction = $payment->getParentTransactionId();
|
408 |
+
|
409 |
+
//We need a parent id for refunding
|
410 |
+
if (empty($captureTransaction)) {
|
411 |
+
$this->_getHelper()->getPaymentHelper()
|
412 |
+
->getBackendErrorManager('refund')
|
413 |
+
->processMessage('There is no transaction id for refunding.');
|
414 |
+
}
|
415 |
+
|
416 |
+
//Get the transaction model from the id
|
417 |
+
/* @var $captureTransaction Mage_Sales_Model_Order_Payment_Transaction */
|
418 |
+
$captureTransaction = $payment->getTransaction($captureTransaction);
|
419 |
+
|
420 |
+
//Check for valid type
|
421 |
+
if (!$captureTransaction instanceof Mage_Sales_Model_Order_Payment_Transaction) {
|
422 |
+
$this->_getHelper()->getPaymentHelper()
|
423 |
+
->getBackendErrorManager('refund')
|
424 |
+
->processMessage(
|
425 |
+
"Can't load the capture transaction (%s).",
|
426 |
+
true,
|
427 |
+
array($payment->getParentTransactionId())
|
428 |
+
);
|
429 |
+
}
|
430 |
+
|
431 |
+
//Check the type
|
432 |
+
if (Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE != $captureTransaction->getTxnType()) {
|
433 |
+
$this->_getHelper()->getPaymentHelper()
|
434 |
+
->getBackendErrorManager('refund')
|
435 |
+
->processMessage(
|
436 |
+
'The transaction (%s) is not a capture transaction. Only capture transaction can refund.',
|
437 |
+
true,
|
438 |
+
array($captureTransaction->getTxnId())
|
439 |
+
);
|
440 |
+
}
|
441 |
+
|
442 |
+
/* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
|
443 |
+
$creditmemo = $payment->getCreditmemo();
|
444 |
+
|
445 |
+
if (!$creditmemo instanceof Mage_Sales_Model_Order_Creditmemo) {
|
446 |
+
$this->_getHelper()->getPaymentHelper()
|
447 |
+
->getBackendErrorManager('refund')
|
448 |
+
->processMessage('No credit memo available.');
|
449 |
+
}
|
450 |
+
|
451 |
+
/* @var $invoice Mage_Sales_Model_Order_Invoice */
|
452 |
+
$invoice = $creditmemo->getInvoice();
|
453 |
+
|
454 |
+
if (!$invoice instanceof Mage_Sales_Model_Order_Invoice) {
|
455 |
+
$this->_getHelper()->getPaymentHelper()
|
456 |
+
->getBackendErrorManager('refund')
|
457 |
+
->processMessage('The credit memo has no referenced invoice available.');
|
458 |
+
}
|
459 |
+
|
460 |
+
//Collect the already refunded amount in referenced to the invoice
|
461 |
+
$alreadyRefunded = 0;
|
462 |
+
foreach ($order->getCreditmemosCollection() as $singleCreditmemo) {
|
463 |
+
if ($singleCreditmemo->getInvoiceId() == $invoice->getId()) {
|
464 |
+
$alreadyRefunded += (float)$singleCreditmemo->getBaseGrandTotal();
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
//Close the capture if we have refund the complete amount
|
469 |
+
$sumRefunded = $alreadyRefunded + (float)$creditmemo->getBaseGrandTotal();
|
470 |
+
$amountdiff = ((float)$invoice->getBaseGrandTotal() - $sumRefunded);
|
471 |
+
|
472 |
+
if ($this->_getHelper()->getPaymentHelper()->isZeroAmount($amountdiff)) {
|
473 |
+
$payment->setShouldCloseParentTransaction(true);
|
474 |
+
} else if ($this->_getHelper()->getPaymentHelper()->isNegativeAmount($amountdiff)) {
|
475 |
+
$this->_getHelper()->getPaymentHelper()
|
476 |
+
->getBackendErrorManager('refund')
|
477 |
+
->processMessage(
|
478 |
+
'We only can refund an amount of %s.',
|
479 |
+
true,
|
480 |
+
array(
|
481 |
+
$order->getBaseCurrency()->formatPrecision(
|
482 |
+
$invoice->getBaseGrandTotal() - $alreadyRefunded,
|
483 |
+
2,
|
484 |
+
array(),
|
485 |
+
false
|
486 |
+
)
|
487 |
+
)
|
488 |
+
);
|
489 |
+
} else {
|
490 |
+
$payment->setShouldCloseParentTransaction(false);
|
491 |
+
}
|
492 |
+
|
493 |
+
//Don't allow reverse on refunds
|
494 |
+
$payment->setIsTransactionClosed(true);
|
495 |
+
|
496 |
+
//Get the request model
|
497 |
+
$request = $this->_createRequestModel(__FUNCTION__, $payment);
|
498 |
+
|
499 |
+
//Set the transaction model and the refund amount
|
500 |
+
$request
|
501 |
+
->setReferencedTransactionModel($captureTransaction)
|
502 |
+
->setAmount($amount);
|
503 |
+
|
504 |
+
//Send the capture request to computop
|
505 |
+
$this->_getConnection()->sendRequest($request);
|
506 |
+
|
507 |
+
//Check if the transaction has produce an error
|
508 |
+
if (!$request->getResponseModel()->hasError()) {
|
509 |
+
//Add transaction information
|
510 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
511 |
+
$payment,
|
512 |
+
$request->getResponseModel()
|
513 |
+
);
|
514 |
+
} else {
|
515 |
+
$this->_getHelper()->getPaymentHelper()
|
516 |
+
->getBackendErrorManager('refund')
|
517 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
518 |
+
}
|
519 |
+
|
520 |
+
return $this;
|
521 |
+
}
|
522 |
+
|
523 |
+
|
524 |
+
/**
|
525 |
+
* @see Mage_Payment_Model_Method_Abstract::void()
|
526 |
+
*
|
527 |
+
* @param Varien_Object $payment
|
528 |
+
* @return Mage_Payment_Model_Abstract
|
529 |
+
*/
|
530 |
+
public function void(Varien_Object $payment)
|
531 |
+
{
|
532 |
+
//Holds the referenced transaction
|
533 |
+
$transaction = null;
|
534 |
+
|
535 |
+
if ($this->_canVoidAuthorization()) {
|
536 |
+
$transaction = $payment->getAuthorizationTransaction();
|
537 |
+
} else if($this->_canVoidCapture()) {
|
538 |
+
$transaction = $payment->getTransaction($payment->getLastTransId());
|
539 |
+
} else {
|
540 |
+
$this->_getHelper()->getPaymentHelper()
|
541 |
+
->getBackendErrorManager('void')
|
542 |
+
->processMessage("Can't void this order.");
|
543 |
+
}
|
544 |
+
|
545 |
+
//Get the request model
|
546 |
+
$request = $this->_createRequestModel('reverse', $payment);
|
547 |
+
|
548 |
+
//Set the transaction model
|
549 |
+
$request->setReferencedTransactionModel($transaction);
|
550 |
+
|
551 |
+
//Send the capture request to computop
|
552 |
+
$this->_getConnection()->sendRequest($request);
|
553 |
+
|
554 |
+
//Check if the transaction has produce an error
|
555 |
+
if (!$request->getResponseModel()->hasError()) {
|
556 |
+
//Add transaction information
|
557 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
558 |
+
$payment,
|
559 |
+
$request->getResponseModel()
|
560 |
+
);
|
561 |
+
} else {
|
562 |
+
$this->_getHelper()->getPaymentHelper()
|
563 |
+
->getBackendErrorManager('void')
|
564 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
565 |
+
}
|
566 |
+
|
567 |
+
return $this;
|
568 |
+
}
|
569 |
+
|
570 |
+
|
571 |
+
/**
|
572 |
+
* @see Mage_Payment_Model_Method_Abstract::canVoid()
|
573 |
+
*
|
574 |
+
* @param Varien_Object $payment
|
575 |
+
* @return bool
|
576 |
+
*/
|
577 |
+
public function canVoid(Varien_Object $document)
|
578 |
+
{
|
579 |
+
$canVoid = parent::canVoid($document);
|
580 |
+
|
581 |
+
if (!$canVoid) {
|
582 |
+
return $canVoid;
|
583 |
+
}
|
584 |
+
|
585 |
+
return $this->_canVoidAuthorization() || $this->_canVoidCapture();
|
586 |
+
}
|
587 |
+
|
588 |
+
|
589 |
+
/**
|
590 |
+
* @see Mage_Payment_Model_Method_Abstract::canCapture()
|
591 |
+
*
|
592 |
+
* @return bool
|
593 |
+
*/
|
594 |
+
public function canCapture()
|
595 |
+
{
|
596 |
+
$canCapture = parent::canCapture();
|
597 |
+
|
598 |
+
if (!$canCapture) {
|
599 |
+
return $canCapture;
|
600 |
+
}
|
601 |
+
|
602 |
+
/* @var $payment Mage_Sales_Model_Order_Payment */
|
603 |
+
$payment = $this->getInfoInstance();
|
604 |
+
|
605 |
+
return $this->_canCaptureAuthorization($payment)
|
606 |
+
|| $this->canBackendDirectCapture();
|
607 |
+
}
|
608 |
+
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Check if we can capture a open authorization.
|
612 |
+
*
|
613 |
+
* @param unknown_type $payment
|
614 |
+
* @return boolean
|
615 |
+
*/
|
616 |
+
protected function _canCaptureAuthorization($payment)
|
617 |
+
{
|
618 |
+
//Get the payment
|
619 |
+
if (empty($payment)) {
|
620 |
+
/* @var $payment Mage_Sales_Model_Order_Payment */
|
621 |
+
$payment = $this->getInfoInstance();
|
622 |
+
}
|
623 |
+
|
624 |
+
//Get a authorization
|
625 |
+
$authorization = $payment->getAuthorizationTransaction();
|
626 |
+
|
627 |
+
//Check if we can capture a authorization
|
628 |
+
return $authorization instanceof Mage_Sales_Model_Order_Payment_Transaction
|
629 |
+
&& !$authorization->getIsClosed();
|
630 |
+
}
|
631 |
+
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Check if we can void an authorization.
|
635 |
+
*
|
636 |
+
* @param Varien_Object $document
|
637 |
+
* @return booleans
|
638 |
+
*/
|
639 |
+
protected function _canVoidAuthorization()
|
640 |
+
{
|
641 |
+
/* @var $payment Mage_Sales_Model_Order_Payment */
|
642 |
+
$payment = $this->getInfoInstance();
|
643 |
+
$order = $payment->getOrder();
|
644 |
+
|
645 |
+
$authTransaction = $payment->getAuthorizationTransaction();
|
646 |
+
$onlinePaid = $this->getCancelProcessModel($order)->getTotalRefundableAmount();
|
647 |
+
|
648 |
+
return $authTransaction instanceof Mage_Sales_Model_Order_Payment_Transaction
|
649 |
+
&& !$authTransaction->getIsClosed()
|
650 |
+
&& $authTransaction->canVoidAuthorizationCompletely()
|
651 |
+
&& $this->_getHelper()->getPaymentHelper()->isZeroAmount($onlinePaid);
|
652 |
+
}
|
653 |
+
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Check if we can void an single capture.
|
657 |
+
*
|
658 |
+
* @param Varien_Object $document
|
659 |
+
* @return boolean
|
660 |
+
*/
|
661 |
+
protected function _canVoidCapture()
|
662 |
+
{
|
663 |
+
/* @var $payment Mage_Sales_Model_Order_Payment */
|
664 |
+
$payment = $this->getInfoInstance();
|
665 |
+
$order = $payment->getOrder();
|
666 |
+
$lastTransaction = $payment->getTransaction($payment->getLastTransId());
|
667 |
+
|
668 |
+
//Check for an voidable capture
|
669 |
+
if(!$lastTransaction instanceof Mage_Sales_Model_Order_Payment_Transaction
|
670 |
+
|| $lastTransaction->getIsClosed()
|
671 |
+
) {
|
672 |
+
return false;
|
673 |
+
}
|
674 |
+
|
675 |
+
$onlinePaid = $this->getCancelProcessModel($order)->getTotalRefundableAmount();
|
676 |
+
|
677 |
+
if($this->_getHelper()->getPaymentHelper()->isPositiveAmount($onlinePaid)
|
678 |
+
&& $this->_getHelper()->getPaymentHelper()->isZeroAmount($order->getBaseTotalOnlineRefunded())
|
679 |
+
&& count($this->getCancelProcessModel($order)->getOnlinePaidInvoices()) == 1
|
680 |
+
) {
|
681 |
+
//get the only invoice in the array
|
682 |
+
$invoice = $this->getCancelProcessModel($order)->getOnlinePaidInvoices();
|
683 |
+
$invoice = array_pop($invoice);
|
684 |
+
|
685 |
+
//Check the same date
|
686 |
+
return date('Ymd') == date('Ymd', strtotime($invoice->getCreatedAt()));
|
687 |
+
}
|
688 |
+
|
689 |
+
return false;
|
690 |
+
}
|
691 |
+
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Return the amount who will be refunded by the cancel action.
|
695 |
+
*
|
696 |
+
* @param Mage_Sales_Model_Order $order
|
697 |
+
* @param boolean $formated
|
698 |
+
* @return unknown
|
699 |
+
*/
|
700 |
+
public function getCancelAmount(Mage_Sales_Model_Order $order, $formated = true)
|
701 |
+
{
|
702 |
+
//Get the refund able amount
|
703 |
+
$amount = $this->getCancelProcessModel($order)->getTotalRefundableAmount();
|
704 |
+
|
705 |
+
if ($formated) {
|
706 |
+
$amount = $order->getBaseCurrency()->formatPrecision($amount, 2, array(), false);
|
707 |
+
}
|
708 |
+
|
709 |
+
return $amount;
|
710 |
+
}
|
711 |
+
|
712 |
+
|
713 |
+
/**
|
714 |
+
* Return the request model prefix.
|
715 |
+
*
|
716 |
+
* @return string
|
717 |
+
*/
|
718 |
+
protected function _getRequestModelPath()
|
719 |
+
{
|
720 |
+
if (is_null($this->_requestModelInfo)) {
|
721 |
+
Mage::throwException(
|
722 |
+
$this->_getHelper()->__(
|
723 |
+
'The payment method with the code "%s" has a undefined variable _requestModelInfo.',
|
724 |
+
$this->getCode()
|
725 |
+
)
|
726 |
+
);
|
727 |
+
}
|
728 |
+
|
729 |
+
return $this->_requestModelInfo;
|
730 |
+
}
|
731 |
+
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Return the default request model prefix.
|
735 |
+
*
|
736 |
+
* @return string
|
737 |
+
*/
|
738 |
+
protected function _getDefaultRequestModelPath()
|
739 |
+
{
|
740 |
+
return $this->_requestModelDefault;
|
741 |
+
}
|
742 |
+
|
743 |
+
|
744 |
+
/**
|
745 |
+
* Checks if we can create a new capture without a previous
|
746 |
+
* authorization and we have all data for that.
|
747 |
+
*
|
748 |
+
* @return boolean
|
749 |
+
*/
|
750 |
+
public function canBackendDirectCapture()
|
751 |
+
{
|
752 |
+
return $this->_canBackendDirectCapture;
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Set the redirect url. The title is only use in the iframe modus.
|
758 |
+
*
|
759 |
+
* @param string $url
|
760 |
+
* @param boolean $iframe
|
761 |
+
* @param string $title
|
762 |
+
*/
|
763 |
+
protected function _setOrderPlaceRedirectUrl($url, $iframe = false, $title = null)
|
764 |
+
{
|
765 |
+
//check for iframe redirect
|
766 |
+
if ($iframe) {
|
767 |
+
//Set the given url as iframe url
|
768 |
+
$this->_getHelper()
|
769 |
+
->getCheckoutSession(Dotsource_Computop_Helper_Data::FRONTEND)
|
770 |
+
->setIframeUrl($url);
|
771 |
+
|
772 |
+
//Set the titel
|
773 |
+
if (!empty($title)) {
|
774 |
+
$this->_getHelper()
|
775 |
+
->getCheckoutSession(Dotsource_Computop_Helper_Data::FRONTEND)
|
776 |
+
->setIframeTitle($title);
|
777 |
+
}
|
778 |
+
|
779 |
+
//now override the redirect url to the iframe
|
780 |
+
$url = Mage::getUrl(
|
781 |
+
'computop/iframe/show',
|
782 |
+
array('_forced_secure' => true)
|
783 |
+
);
|
784 |
+
}
|
785 |
+
|
786 |
+
//Magento will redirect to this url after order place
|
787 |
+
Dotsource_Computop_Model_Payment_Abstract::$_redirectUrl = $url;
|
788 |
+
}
|
789 |
+
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Return the redirect url.
|
793 |
+
*
|
794 |
+
* @return string
|
795 |
+
*/
|
796 |
+
public function getOrderPlaceRedirectUrl()
|
797 |
+
{
|
798 |
+
return Dotsource_Computop_Model_Payment_Abstract::$_redirectUrl;
|
799 |
+
}
|
800 |
+
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Return a connection model.
|
804 |
+
*
|
805 |
+
* @return Dotsource_Computop_Model_Connection
|
806 |
+
*/
|
807 |
+
protected function _getConnection()
|
808 |
+
{
|
809 |
+
return Mage::getModel('computop/connection');
|
810 |
+
}
|
811 |
+
|
812 |
+
|
813 |
+
/**
|
814 |
+
* Return true if the current payment model use booking as payment action.
|
815 |
+
*
|
816 |
+
* @return boolean
|
817 |
+
*/
|
818 |
+
protected function _isPaymentBooking()
|
819 |
+
{
|
820 |
+
return Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING
|
821 |
+
== $this->getConfigData('payment_action_computop');
|
822 |
+
}
|
823 |
+
|
824 |
+
|
825 |
+
/**
|
826 |
+
* Return true if the current payment model use authorize as payment action.
|
827 |
+
*
|
828 |
+
* @return boolean
|
829 |
+
*/
|
830 |
+
protected function _isPaymentAuthorize()
|
831 |
+
{
|
832 |
+
return Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE
|
833 |
+
== $this->getConfigData('payment_action_computop');
|
834 |
+
}
|
835 |
+
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Check if the payment has ipzone support.
|
839 |
+
*
|
840 |
+
* @return boolean
|
841 |
+
*/
|
842 |
+
public function useIpZones()
|
843 |
+
{
|
844 |
+
$zoneAction = $this->getConfigData('allowedipzones');
|
845 |
+
$zones = $this->getConfigData('ipzones');
|
846 |
+
|
847 |
+
return !empty($zoneAction)
|
848 |
+
&& !empty($zones)
|
849 |
+
&& Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction::ALLOW_ALL_ZONES != $zoneAction;
|
850 |
+
}
|
851 |
+
|
852 |
+
|
853 |
+
/**
|
854 |
+
* Check if the payment has country zone support
|
855 |
+
*
|
856 |
+
* @return boolean
|
857 |
+
*/
|
858 |
+
public function useCountryZones()
|
859 |
+
{
|
860 |
+
$zoneAction = $this->getConfigData('allowedcountries');
|
861 |
+
$zones = $this->getConfigData('countriesiso3');
|
862 |
+
|
863 |
+
return !empty($zoneAction)
|
864 |
+
&& !empty($zones)
|
865 |
+
&& Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::ALLOW_ALL_COUNTRIES != $zoneAction;
|
866 |
+
}
|
867 |
+
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Return the ip zones in computop format.
|
871 |
+
* Respects the ip zone action all, specific and restrict.
|
872 |
+
*
|
873 |
+
* @return string
|
874 |
+
*/
|
875 |
+
public function convertedIpZone()
|
876 |
+
{
|
877 |
+
//Get the ip zones from the payment
|
878 |
+
$zones = $this->getConfigData('ipzones');
|
879 |
+
|
880 |
+
if (empty($zones)) {
|
881 |
+
return '';
|
882 |
+
}
|
883 |
+
|
884 |
+
//We need the ipzones as array
|
885 |
+
$zones = explode(',', $zones);
|
886 |
+
|
887 |
+
if (is_array($zones)) {
|
888 |
+
$zoneAction = $this->getConfigData('allowedipzones');
|
889 |
+
|
890 |
+
if ($zoneAction == Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction::ALLOW_ANY_ZONES) {
|
891 |
+
return implode(',', $zones);
|
892 |
+
} else if ($zoneAction == Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction::RESTRICT_ANY_ZONES) {
|
893 |
+
return '!'.implode(',!', $zones);
|
894 |
+
}
|
895 |
+
}
|
896 |
+
|
897 |
+
return '';
|
898 |
+
}
|
899 |
+
|
900 |
+
|
901 |
+
/**
|
902 |
+
* Return the ip zones in computop format.
|
903 |
+
* Respects the ip zone action all, specific and restrict.
|
904 |
+
*
|
905 |
+
* @return string
|
906 |
+
*/
|
907 |
+
public function convertedCountryZone()
|
908 |
+
{
|
909 |
+
//Get the ip zones from the payment
|
910 |
+
$zones = $this->getConfigData('countriesiso3');
|
911 |
+
|
912 |
+
if (empty($zones)) {
|
913 |
+
return '';
|
914 |
+
}
|
915 |
+
|
916 |
+
//We need the ipzones as array
|
917 |
+
$zones = explode(',', $zones);
|
918 |
+
|
919 |
+
if (is_array($zones)) {
|
920 |
+
$zoneAction = $this->getConfigData('allowedcountries');
|
921 |
+
|
922 |
+
if ($zoneAction == Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::ALLOW_ANY_COUNTRIES) {
|
923 |
+
return implode(',', $zones);
|
924 |
+
} elseif ($zoneAction == Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::RESTRICT_ANY_COUNTRIES) {
|
925 |
+
return '!'.implode(',!', $zones);
|
926 |
+
}
|
927 |
+
}
|
928 |
+
|
929 |
+
return '';
|
930 |
+
}
|
931 |
+
|
932 |
+
|
933 |
+
/**
|
934 |
+
* Return the cancel process model.
|
935 |
+
*
|
936 |
+
* @param mixed $payment
|
937 |
+
* @return Dotsource_Computop_Model_Cancelprocess
|
938 |
+
*/
|
939 |
+
public function getCancelProcessModel($payment)
|
940 |
+
{
|
941 |
+
//Get the right model
|
942 |
+
if ($payment instanceof Mage_Sales_Model_Order) {
|
943 |
+
$payment = $payment->getPayment();
|
944 |
+
}
|
945 |
+
|
946 |
+
//Create the cancel model
|
947 |
+
if (null === $this->_cancelProcessModel) {
|
948 |
+
$this->_cancelProcessModel = Mage::getModel('computop/cancelprocess');
|
949 |
+
$this->_cancelProcessModel->setPayment($payment);
|
950 |
+
}
|
951 |
+
|
952 |
+
return $this->_cancelProcessModel;
|
953 |
+
}
|
954 |
+
|
955 |
+
|
956 |
+
/**
|
957 |
+
* Check for an custom 'order_status'.
|
958 |
+
*
|
959 |
+
* @param string $field
|
960 |
+
* @param integer $storeId
|
961 |
+
* @return mixed
|
962 |
+
*/
|
963 |
+
public function getConfigData($field, $storeId = null)
|
964 |
+
{
|
965 |
+
if ('order_status' == $field && $this->hasNewOrderStatus()) {
|
966 |
+
return $this->getNewOrderStatus();
|
967 |
+
}
|
968 |
+
|
969 |
+
return parent::getConfigData($field, $storeId);
|
970 |
+
}
|
971 |
+
|
972 |
+
|
973 |
+
/**
|
974 |
+
* Return the computop helper.
|
975 |
+
*
|
976 |
+
* @return Dotsource_Computop_Helper_Data
|
977 |
+
*/
|
978 |
+
protected function _getHelper()
|
979 |
+
{
|
980 |
+
return Mage::helper('computop');
|
981 |
+
}
|
982 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Cc.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Cc
|
12 |
+
extends Dotsource_Computop_Model_Payment_Abstract
|
13 |
+
{
|
14 |
+
/** Check if we can capture direct from the backend */
|
15 |
+
protected $_canBackendDirectCapture = true;
|
16 |
+
|
17 |
+
/** Holds the block source path */
|
18 |
+
protected $_formBlockType = 'computop/form_cc';
|
19 |
+
|
20 |
+
/** Holds the info source path */
|
21 |
+
protected $_infoBlockType = 'computop/info_cc';
|
22 |
+
|
23 |
+
/** Holds the payment code */
|
24 |
+
protected $_code = 'computop_cc';
|
25 |
+
|
26 |
+
/** Holds the path to the request models */
|
27 |
+
protected $_requestModelInfo = 'computop/payment_request_cc_';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @see Mage_Payment_Model_Method_Abstract::assignData()
|
31 |
+
*
|
32 |
+
* @param mixed $data
|
33 |
+
* @return Mage_Payment_Model_Info
|
34 |
+
*/
|
35 |
+
public function assignData($data)
|
36 |
+
{
|
37 |
+
parent::assignData($data);
|
38 |
+
|
39 |
+
//Check if we should use payment information
|
40 |
+
if ('1' != $this->getConfigData('use_pseudo_data')
|
41 |
+
|| '1' != $this->getConfigData('prefill_paymentinformation')
|
42 |
+
) {
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
$info = $this->getInfoInstance();
|
47 |
+
|
48 |
+
//Get old payment information
|
49 |
+
$oldPaymentInformation = $this->_getHelper()
|
50 |
+
->getPaymentHelper()
|
51 |
+
->getLastCcPaymentinformation($this->getCode());
|
52 |
+
|
53 |
+
//Set the data if we can
|
54 |
+
if ($oldPaymentInformation instanceof Varien_Object
|
55 |
+
&& $oldPaymentInformation->hasCcNumberEnc()
|
56 |
+
&& $oldPaymentInformation->hasCcExpYear()
|
57 |
+
&& $oldPaymentInformation->hasCcExpMonth()
|
58 |
+
&& $oldPaymentInformation->hasCcType()
|
59 |
+
) {
|
60 |
+
$info->addData($oldPaymentInformation->getData());
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
68 |
+
*
|
69 |
+
* @param Varien_Object $payment
|
70 |
+
* @param unknown_type $amount
|
71 |
+
* @return Mage_Payment_Model_Abstract
|
72 |
+
*/
|
73 |
+
public function authorize(Varien_Object $payment, $amount)
|
74 |
+
{
|
75 |
+
//Get the request model
|
76 |
+
$requestModel = $this->_createRequestModel(__FUNCTION__, $payment);
|
77 |
+
|
78 |
+
//Set the amount
|
79 |
+
$requestModel
|
80 |
+
->setAmount($amount);
|
81 |
+
|
82 |
+
//Process the request data and create the redirect url for the payment gateway
|
83 |
+
$this->_setOrderPlaceRedirectUrl(
|
84 |
+
$this->_getHelper()->getConfiguration()->getBaseUrl().
|
85 |
+
$requestModel->getRequestFile().
|
86 |
+
'?'.
|
87 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING),
|
88 |
+
true,
|
89 |
+
$this->_getHelper()->__('Credit Card Payment Gateway')
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @see Dotsource_Computop_Model_Payment_Abstract::canBackendDirectCapture()
|
96 |
+
*
|
97 |
+
* @return boolean
|
98 |
+
*/
|
99 |
+
public function canBackendDirectCapture()
|
100 |
+
{
|
101 |
+
//Check if we support direct capture
|
102 |
+
if(parent::canBackendDirectCapture() && $this->getConfigData('use_pseudo_data')) {
|
103 |
+
$data = array();
|
104 |
+
$data[] = $this->getInfoInstance()->getCcNumberEnc();
|
105 |
+
$data[] = $this->getInfoInstance()->getCcExpYear();
|
106 |
+
$data[] = $this->getInfoInstance()->getCcExpMonth();
|
107 |
+
$data[] = $this->getInfoInstance()->getCcType();
|
108 |
+
|
109 |
+
//Check the data
|
110 |
+
foreach ($data as $checkData) {
|
111 |
+
if (empty($checkData)) {
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
//No empty data
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Directpay.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Directpay
|
12 |
+
extends Dotsource_Computop_Model_Payment_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_canCapture = false;
|
16 |
+
|
17 |
+
protected $_canCapturePartial = false;
|
18 |
+
|
19 |
+
protected $_canRefund = false;
|
20 |
+
|
21 |
+
protected $_canRefundInvoicePartial = false;
|
22 |
+
|
23 |
+
protected $_canVoid = false;
|
24 |
+
|
25 |
+
/** Holds the block source path */
|
26 |
+
protected $_formBlockType = 'computop/form_directpay';
|
27 |
+
|
28 |
+
/** Holds the info source path */
|
29 |
+
protected $_infoBlockType = 'computop/info_directpay';
|
30 |
+
|
31 |
+
/** Holds the payment code */
|
32 |
+
protected $_code = 'computop_directpay';
|
33 |
+
|
34 |
+
/** Holds the path to the request models */
|
35 |
+
protected $_requestModelInfo = 'computop/payment_request_directpay_';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
39 |
+
*
|
40 |
+
* @param Varien_Object $payment
|
41 |
+
* @param unknown_type $amount
|
42 |
+
* @return Mage_Payment_Model_Abstract
|
43 |
+
*/
|
44 |
+
public function authorize(Varien_Object $payment, $amount)
|
45 |
+
{
|
46 |
+
//Get the request model
|
47 |
+
$requestModel = $this->_createRequestModel(__FUNCTION__, $payment);
|
48 |
+
|
49 |
+
//Set the amount
|
50 |
+
$requestModel
|
51 |
+
->setAmount($amount);
|
52 |
+
|
53 |
+
//Process the request data and create the redirect url for the payment gateway
|
54 |
+
$this->_setOrderPlaceRedirectUrl(
|
55 |
+
$this->_getHelper()->getConfiguration()->getBaseUrl().
|
56 |
+
$requestModel->getRequestFile().
|
57 |
+
'?'.
|
58 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING)
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Eft.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Eft
|
12 |
+
extends Dotsource_Computop_Model_Payment_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_canCapturePartial = false;
|
16 |
+
|
17 |
+
protected $_canRefund = false;
|
18 |
+
|
19 |
+
protected $_canRefundInvoicePartial = false;
|
20 |
+
|
21 |
+
/** Holds the block source path */
|
22 |
+
protected $_formBlockType = 'computop/form_eft';
|
23 |
+
|
24 |
+
/** Holds the info source path */
|
25 |
+
protected $_infoBlockType = 'computop/info_eft';
|
26 |
+
|
27 |
+
/** Holds the payment code */
|
28 |
+
protected $_code = 'computop_eft';
|
29 |
+
|
30 |
+
/** Holds the path to the request models */
|
31 |
+
protected $_requestModelInfo = 'computop/payment_request_eft_';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @see Mage_Payment_Model_Method_Abstract::assignData()
|
35 |
+
*
|
36 |
+
* @param mixed $data
|
37 |
+
* @return Mage_Payment_Model_Info
|
38 |
+
*/
|
39 |
+
public function assignData($data)
|
40 |
+
{
|
41 |
+
if (!$data instanceof Varien_Object) {
|
42 |
+
$data = new Varien_Object($data);
|
43 |
+
}
|
44 |
+
|
45 |
+
$info = $this->getInfoInstance();
|
46 |
+
$ban = $data->getEftBan();
|
47 |
+
$bcn = $data->getEftBcn();
|
48 |
+
|
49 |
+
//Remove spaces
|
50 |
+
$ban = str_replace(' ', '', $ban);
|
51 |
+
$bcn = str_replace(' ', '', $bcn);
|
52 |
+
|
53 |
+
$info
|
54 |
+
->setEftOwner($data->getEftOwner())
|
55 |
+
->setEftBanEnc($info->encrypt($ban))
|
56 |
+
->setEftBan4(substr($ban, -3))
|
57 |
+
->setEftBcn($bcn);
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @see Dotsource_Computop_Model_Payment_Abstract::canCapture()
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function canCapture()
|
68 |
+
{
|
69 |
+
return $this->_getHelper()->isFrontend() || parent::canCapture();
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @see Dotsource_Computop_Model_Payment_Abstract::authorize()
|
75 |
+
*
|
76 |
+
* @param Varien_Object $payment
|
77 |
+
* @param unknown_type $amount
|
78 |
+
* @return Mage_Payment_Model_Abstract
|
79 |
+
*/
|
80 |
+
public function authorize(Varien_Object $payment, $amount)
|
81 |
+
{
|
82 |
+
parent::authorize($payment, $amount);
|
83 |
+
|
84 |
+
//If we use auth set the ready capture status
|
85 |
+
if (Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE
|
86 |
+
== $this->getConfigData('payment_action_computop')
|
87 |
+
) {
|
88 |
+
$this->setNewOrderStatus(Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE);
|
89 |
+
}
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @see Dotsource_Computop_Model_Payment_Abstract::capture()
|
97 |
+
*
|
98 |
+
* @param Varien_Object $payment
|
99 |
+
* @param float $amount
|
100 |
+
* @return Mage_Payment_Model_Abstract
|
101 |
+
*/
|
102 |
+
public function capture(Varien_Object $payment, $amount)
|
103 |
+
{
|
104 |
+
//If we call the capture method from the frontend we can use the
|
105 |
+
//the authorize method to capture the payment
|
106 |
+
if ($this->_getHelper()->isFrontend()) {
|
107 |
+
return $this->authorize($payment, $amount);
|
108 |
+
} else {
|
109 |
+
return parent::capture($payment, $amount);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @see Mage_Payment_Model_Method_Abstract::validate()
|
116 |
+
*
|
117 |
+
* @return Dotsource_Computop_Model_Payment_Eft
|
118 |
+
*/
|
119 |
+
public function validate()
|
120 |
+
{
|
121 |
+
//Do parent stuff first
|
122 |
+
parent::validate();
|
123 |
+
|
124 |
+
//Get the data
|
125 |
+
$info = $this->getInfoInstance();
|
126 |
+
|
127 |
+
//Check name
|
128 |
+
if (!Zend_Validate::is($info->getEftOwner(), 'NotEmpty')) {
|
129 |
+
$msg = 'Your account holder is invalid.';
|
130 |
+
$msg = $this->_getHelper()->__($msg);
|
131 |
+
$code = "{$this->getCode()}_eft_owner";
|
132 |
+
throw Mage::exception('Mage_Payment', $msg, $code);
|
133 |
+
}
|
134 |
+
|
135 |
+
//Check ban
|
136 |
+
if (!Zend_Validate::is($info->decrypt($info->getEftBanEnc()), 'Digits')) {
|
137 |
+
$msg = 'Your bank account number is invalid.';
|
138 |
+
$msg = $this->_getHelper()->__($msg);
|
139 |
+
$code = "{$this->getCode()}_eft_ban";
|
140 |
+
throw Mage::exception('Mage_Payment', $msg, $code);
|
141 |
+
}
|
142 |
+
|
143 |
+
//Check bcn
|
144 |
+
if (!Zend_Validate::is($info->getEftBcn(), 'Digits')) {
|
145 |
+
$msg = 'Your bank code number is invalid.';
|
146 |
+
$msg = $this->_getHelper()->__($msg);
|
147 |
+
$code = "{$this->getCode()}_eft_bcn";
|
148 |
+
throw Mage::exception('Mage_Payment', $msg, $code);
|
149 |
+
}
|
150 |
+
|
151 |
+
return $this;
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Retrieves the configuration for the payment method.
|
157 |
+
*
|
158 |
+
* @param string $field
|
159 |
+
* @param integer $storeId
|
160 |
+
* @return mixed
|
161 |
+
*/
|
162 |
+
public function getConfigData($field, $storeId = null)
|
163 |
+
{
|
164 |
+
//Return the right payment action
|
165 |
+
if ('payment_action' == $field) {
|
166 |
+
switch ($this->getConfigData('payment_action_computop', $storeId)) {
|
167 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
168 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
169 |
+
return Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING;
|
170 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
171 |
+
return Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
return parent::getConfigData($field, $storeId);
|
176 |
+
}
|
177 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Giropay.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Giropay
|
12 |
+
extends Dotsource_Computop_Model_Payment_Eft
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_canCapture = false;
|
16 |
+
|
17 |
+
protected $_canCapturePartial = false;
|
18 |
+
|
19 |
+
protected $_canRefund = false;
|
20 |
+
|
21 |
+
protected $_canRefundInvoicePartial = false;
|
22 |
+
|
23 |
+
protected $_canVoid = false;
|
24 |
+
|
25 |
+
|
26 |
+
/** Holds the block source path */
|
27 |
+
protected $_formBlockType = 'computop/form_giropay';
|
28 |
+
|
29 |
+
/** Holds the info source path */
|
30 |
+
protected $_infoBlockType = 'computop/info_giropay';
|
31 |
+
|
32 |
+
/** Holds the payment code */
|
33 |
+
protected $_code = 'computop_giropay';
|
34 |
+
|
35 |
+
/** Holds the path to the request models */
|
36 |
+
protected $_requestModelInfo = 'computop/payment_request_giropay_';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @see Dotsource_Computop_Model_Payment_Eft::validate()
|
40 |
+
*
|
41 |
+
* @return Dotsource_Computop_Model_Payment_Giropay
|
42 |
+
*/
|
43 |
+
public function validate()
|
44 |
+
{
|
45 |
+
//Validate the bank data
|
46 |
+
parent::validate();
|
47 |
+
|
48 |
+
//Get the payment data
|
49 |
+
$info = $this->getInfoInstance();
|
50 |
+
|
51 |
+
//Check active?
|
52 |
+
if ('1' != $this->getConfigData('bcn_check') || !$info->hasEftBcn()) {
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
|
56 |
+
//Get the giropay check request model
|
57 |
+
/* @var $request Dotsource_Computop_Model_Payment_Request_Giropay_Check */
|
58 |
+
$request = $this->_createRequestModel('check', $this->getInfoInstance());
|
59 |
+
|
60 |
+
//Send the capture request to computop
|
61 |
+
$this->_getConnection()->sendRequest($request);
|
62 |
+
|
63 |
+
//Check if the transaction has produce an error
|
64 |
+
if (!$request->getResponseModel()->hasError()) {
|
65 |
+
//Get the list from the response
|
66 |
+
$activeBanList = $request->getResponseModel()->getResponse()->getData('accibanlist');
|
67 |
+
$activeBanList = trim($activeBanList);
|
68 |
+
|
69 |
+
//We need data for processing
|
70 |
+
if (empty($activeBanList)) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
//Explode
|
75 |
+
$activeBanList = explode(',', $activeBanList);
|
76 |
+
|
77 |
+
//Check if the customer ban is active
|
78 |
+
if (!in_array($info->getEftBcn(), $activeBanList)) {
|
79 |
+
throw Mage::exception(
|
80 |
+
'Mage_Payment',
|
81 |
+
$this->_getHelper()->__("Your bank don't support this payment method."),
|
82 |
+
$this->getCode().'_eft_bcn'
|
83 |
+
);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
return true;
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
93 |
+
*
|
94 |
+
* @param Varien_Object $payment
|
95 |
+
* @param unknown_type $amount
|
96 |
+
* @return Mage_Payment_Model_Abstract
|
97 |
+
*/
|
98 |
+
public function authorize(Varien_Object $payment, $amount)
|
99 |
+
{
|
100 |
+
//Get the request model
|
101 |
+
$requestModel = $this->_createRequestModel(__FUNCTION__, $payment);
|
102 |
+
|
103 |
+
//Set the amount
|
104 |
+
$requestModel
|
105 |
+
->setAmount($amount);
|
106 |
+
|
107 |
+
//Process the request data and create the redirect url for the payment gateway
|
108 |
+
$this->_setOrderPlaceRedirectUrl(
|
109 |
+
$this->_getHelper()->getConfiguration()->getBaseUrl().
|
110 |
+
$requestModel->getRequestFile().
|
111 |
+
'?'.
|
112 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING)
|
113 |
+
);
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Ideal.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Ideal
|
12 |
+
extends Dotsource_Computop_Model_Payment_Giropay
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_canCapture = false;
|
16 |
+
|
17 |
+
protected $_canCapturePartial = false;
|
18 |
+
|
19 |
+
protected $_canRefund = false;
|
20 |
+
|
21 |
+
protected $_canRefundInvoicePartial = false;
|
22 |
+
|
23 |
+
protected $_canVoid = false;
|
24 |
+
|
25 |
+
/** Holds the block source path */
|
26 |
+
protected $_formBlockType = 'computop/form_ideal';
|
27 |
+
|
28 |
+
/** Holds the info source path */
|
29 |
+
protected $_infoBlockType = 'computop/info_ideal';
|
30 |
+
|
31 |
+
/** Holds the payment code */
|
32 |
+
protected $_code = 'computop_ideal';
|
33 |
+
|
34 |
+
/** Holds the path to the request models */
|
35 |
+
protected $_requestModelInfo = 'computop/payment_request_ideal_';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @see Dotsource_Computop_Model_Payment_Giropay::validate()
|
39 |
+
*
|
40 |
+
* @return Dotsource_Computop_Model_Payment_Giropay
|
41 |
+
*/
|
42 |
+
public function validate()
|
43 |
+
{
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Mpass.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 30.04.2010 16:31:18
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Mpass
|
15 |
+
extends Dotsource_Computop_Model_Payment_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
protected $_canRefund = false;
|
19 |
+
|
20 |
+
protected $_canRefundInvoicePartial = false;
|
21 |
+
|
22 |
+
/** Holds the block source path */
|
23 |
+
protected $_formBlockType = 'computop/form_mpass';
|
24 |
+
|
25 |
+
/** Holds the info source path */
|
26 |
+
protected $_infoBlockType = 'computop/info_mpass';
|
27 |
+
|
28 |
+
/** Holds the payment code */
|
29 |
+
protected $_code = 'computop_mpass';
|
30 |
+
|
31 |
+
/** Holds the path to the request models */
|
32 |
+
protected $_requestModelInfo = 'computop/payment_request_mpass_';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
36 |
+
*
|
37 |
+
* @param Varien_Object $payment
|
38 |
+
* @param unknown_type $amount
|
39 |
+
* @return Mage_Payment_Model_Abstract
|
40 |
+
*/
|
41 |
+
public function authorize(Varien_Object $payment, $amount)
|
42 |
+
{
|
43 |
+
//Get the request model
|
44 |
+
$requestModel = $this->_createRequestModel(__FUNCTION__, $payment);
|
45 |
+
|
46 |
+
//Set the amount
|
47 |
+
$requestModel->setAmount($amount);
|
48 |
+
|
49 |
+
//Process the request data and create the redirect url for the payment gateway
|
50 |
+
$this->_setOrderPlaceRedirectUrl(
|
51 |
+
$this->_getHelper()->getConfiguration()->getBaseUrl().
|
52 |
+
$requestModel->getRequestFile().
|
53 |
+
'?'.
|
54 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING)
|
55 |
+
);
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Paypalexpress.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 12:20:34
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Paypalexpress
|
15 |
+
extends Dotsource_Computop_Model_Payment_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
protected $_canUseCheckout = false;
|
19 |
+
|
20 |
+
/** Holds the block source path */
|
21 |
+
protected $_formBlockType = 'computop/form_paypalexpress';
|
22 |
+
|
23 |
+
/** Holds the info source path */
|
24 |
+
protected $_infoBlockType = 'paypal/payment_info';
|
25 |
+
|
26 |
+
/** Holds the payment code */
|
27 |
+
protected $_code = 'computop_paypal_express';
|
28 |
+
|
29 |
+
/** Holds the path to the request models */
|
30 |
+
protected $_requestModelInfo = 'computop/payment_request_paypalexpress_';
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Retrieve information from payment configuration.
|
35 |
+
*
|
36 |
+
* @return Mage_Paypal_Model_Config
|
37 |
+
*/
|
38 |
+
public function getConfig()
|
39 |
+
{
|
40 |
+
return Mage::getModel('paypal/config');
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Checkout redirect URL getter for onepage checkout.
|
46 |
+
* @see Mage_Checkout_OnepageController::savePaymentAction()
|
47 |
+
* @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getCheckoutRedirectUrl()
|
52 |
+
{
|
53 |
+
return Mage::getUrl('computop/callback_paypalexpress/start');
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Overwritten authorize method. This method uses the payment
|
59 |
+
* additional information to rebuild a response that was recieved
|
60 |
+
* in the callbackControllers notifyAction().
|
61 |
+
*
|
62 |
+
* @see Dotsource_Computop_Callback_PaypalexpressController::notifyAction().
|
63 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
64 |
+
*
|
65 |
+
* @param Varien_Object $payment
|
66 |
+
* @param float $amount
|
67 |
+
* @return Mage_Payment_Model_Abstract
|
68 |
+
*/
|
69 |
+
public function authorize(Varien_Object $payment, $amount)
|
70 |
+
{
|
71 |
+
//Need quote payment for additional payment information
|
72 |
+
$quotePayment = $this->_getHelper()->getFrontendQuote()->getPayment();
|
73 |
+
|
74 |
+
//Fake a response with the additional information to create the magento
|
75 |
+
//transaction information
|
76 |
+
$responseModel = Mage::getModel('computop/payment_response_response');
|
77 |
+
|
78 |
+
/* @var $responseModel Dotsource_Computop_Model_Payment_Response_Response */
|
79 |
+
$responseModel->setResponse(
|
80 |
+
array(
|
81 |
+
'xid' => $quotePayment->getAdditionalInformation('computop_xid'),
|
82 |
+
'payid' => $quotePayment->getAdditionalInformation('computop_payid')
|
83 |
+
),
|
84 |
+
false
|
85 |
+
);
|
86 |
+
|
87 |
+
if ($quotePayment->getAdditionalInformation('computop_is_pending')) {
|
88 |
+
$payment
|
89 |
+
->setIsTransactionPending(true)
|
90 |
+
->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION);
|
91 |
+
} else {
|
92 |
+
//Used for getConfigData('order_status')
|
93 |
+
$this->setNewOrderStatus(Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE);
|
94 |
+
}
|
95 |
+
|
96 |
+
//Don't close the capture transaction we are available to refund
|
97 |
+
$payment->setIsTransactionClosed(false);
|
98 |
+
|
99 |
+
//Add the transaction info to the payment
|
100 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment($payment, $responseModel);
|
101 |
+
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Check if we can capture direct.
|
108 |
+
*
|
109 |
+
* @return boolean
|
110 |
+
*/
|
111 |
+
public function canBackendDirectCapture()
|
112 |
+
{
|
113 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
114 |
+
return $quote->getId()
|
115 |
+
&& $quote->getPayment()->hasAdditionalInformation('computop_xid')
|
116 |
+
&& $quote->getPayment()->hasAdditionalInformation('computop_payid');
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* This method is not used for backend direct capture. The method has refactored
|
122 |
+
* for capturing in frontend by pressing the place oder button.
|
123 |
+
*
|
124 |
+
* @param Varien_Object $payment
|
125 |
+
* @param float $amount
|
126 |
+
*/
|
127 |
+
protected function _directBackendCapture(Varien_Object $payment, $amount)
|
128 |
+
{
|
129 |
+
//At this point we don't have a valid previous transaction for capture
|
130 |
+
//But all the information are available in the current quote
|
131 |
+
$quotePayment = $this->_getHelper()->getFrontendQuote()->getPayment();
|
132 |
+
|
133 |
+
//Data we need from the quote
|
134 |
+
$xid = $quotePayment->getAdditionalInformation('computop_xid');
|
135 |
+
$payid = $quotePayment->getAdditionalInformation('computop_payid');
|
136 |
+
|
137 |
+
//Fake previous authorization transaction for capturing.
|
138 |
+
//The authorization transaction was processed be clicking the paypal express
|
139 |
+
//button and redirect to the review page
|
140 |
+
$authTransaction = Mage::getModel('sales/order_payment_transaction')
|
141 |
+
->setXid($xid)
|
142 |
+
->setAdditionalInformation('payid', $payid);
|
143 |
+
|
144 |
+
//Get the request model
|
145 |
+
$request = $this->_createRequestModel('capture', $payment);
|
146 |
+
|
147 |
+
//Set the invoice amount
|
148 |
+
$request
|
149 |
+
->setReferencedTransactionModel($authTransaction)
|
150 |
+
->setAmount($amount);
|
151 |
+
|
152 |
+
//Send the capture request to computop
|
153 |
+
$this->_getConnection()->sendRequest($request);
|
154 |
+
|
155 |
+
//Check if the transaction has produce an error
|
156 |
+
if (!$request->getResponseModel()->hasError()) {
|
157 |
+
//Add transaction information
|
158 |
+
$this->_getHelper()->getPaymentHelper()->addTransactionInfoToPayment(
|
159 |
+
$payment,
|
160 |
+
$request->getResponseModel()
|
161 |
+
);
|
162 |
+
|
163 |
+
//Don't close the capture transaction we are available to refund
|
164 |
+
$payment->setIsTransactionClosed(false);
|
165 |
+
|
166 |
+
if ($request->getResponseModel()->isPending()) {
|
167 |
+
$payment->setIsTransactionPending(true);
|
168 |
+
$payment->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
169 |
+
}
|
170 |
+
} else {
|
171 |
+
//Process the error manager
|
172 |
+
$this->_getHelper()->getPaymentHelper()->getFrontendErrorManager()
|
173 |
+
->processErrorCode($request->getResponseModel()->getResponse()->getCode());
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
180 |
+
*
|
181 |
+
* @param Varien_Object $payment
|
182 |
+
* @param float $amount
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function getRequestUrl(Varien_Object $payment, $amount)
|
186 |
+
{
|
187 |
+
//Get the request model
|
188 |
+
$requestModel = $this->_createRequestModel('authorize', $payment);
|
189 |
+
|
190 |
+
//Set the amount
|
191 |
+
$requestModel->setAmount($amount);
|
192 |
+
|
193 |
+
//Process the request data and create the redirect url for the payment gateway
|
194 |
+
return $this->_getHelper()->getConfiguration()->getBaseUrl() .
|
195 |
+
$requestModel->getRequestFile() .
|
196 |
+
'?' .
|
197 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING);
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Retrieves the configuration for the payment method.
|
203 |
+
*
|
204 |
+
* @param string $field
|
205 |
+
* @param integer $storeId
|
206 |
+
* @return mixed
|
207 |
+
*/
|
208 |
+
public function getConfigData($field, $storeId = null)
|
209 |
+
{
|
210 |
+
if ('payment_action' == $field) {
|
211 |
+
return $this->getConfigData('payment_action_computop', $storeId);
|
212 |
+
}
|
213 |
+
|
214 |
+
return parent::getConfigData($field, $storeId);
|
215 |
+
}
|
216 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Paypalstandard.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 12:20:34
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Paypalstandard
|
15 |
+
extends Dotsource_Computop_Model_Payment_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
/** Holds the block source path */
|
19 |
+
protected $_formBlockType = 'computop/form_paypalstandard';
|
20 |
+
|
21 |
+
/** Holds the info source path */
|
22 |
+
protected $_infoBlockType = 'computop/info_paypalstandard';
|
23 |
+
|
24 |
+
/** Holds the payment code */
|
25 |
+
protected $_code = 'computop_paypal_standard';
|
26 |
+
|
27 |
+
/** Holds the path to the request models */
|
28 |
+
protected $_requestModelInfo = 'computop/payment_request_paypal_';
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @see Mage_Payment_Model_Method_Abstract::authorize()
|
33 |
+
*
|
34 |
+
* @param Varien_Object $payment
|
35 |
+
* @param float $amount
|
36 |
+
* @return Mage_Payment_Model_Abstract
|
37 |
+
*/
|
38 |
+
public function authorize(Varien_Object $payment, $amount)
|
39 |
+
{
|
40 |
+
//Get the request model
|
41 |
+
$requestModel = $this->_createRequestModel('authorize', $payment);
|
42 |
+
|
43 |
+
//Set the amount
|
44 |
+
$requestModel->setAmount($amount);
|
45 |
+
|
46 |
+
//Process the request data and create the redirect url for the payment gateway
|
47 |
+
$this->_setOrderPlaceRedirectUrl(
|
48 |
+
$this->_getHelper()->getConfiguration()->getBaseUrl() .
|
49 |
+
$requestModel->getRequestFile() .
|
50 |
+
'?' .
|
51 |
+
$requestModel->getRequest(Dotsource_Computop_Model_Payment_Request_Request::REQUEST_AS_STRING)
|
52 |
+
);
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Authorize.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Payment_Request_Cc_Authorize
|
11 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Enable using ip zones */
|
15 |
+
protected $_useIpZones = true;
|
16 |
+
|
17 |
+
/** enable using country zones */
|
18 |
+
protected $_useCountryZones = true;
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
23 |
+
*/
|
24 |
+
public function getRequestFile()
|
25 |
+
{
|
26 |
+
return 'payssl.aspx';
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
32 |
+
*/
|
33 |
+
protected function _preProcessRequestData()
|
34 |
+
{
|
35 |
+
//Do the parent stuff first
|
36 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
37 |
+
|
38 |
+
//Get the request objects
|
39 |
+
$encryptData = $this->_getEncryptionDataObject();
|
40 |
+
$userData = $this->_getUserDataObject();
|
41 |
+
$paymentAction = $this->getPaymentMethod()->getConfigData('payment_action_computop');
|
42 |
+
|
43 |
+
//Authorize is always a async payment
|
44 |
+
$this
|
45 |
+
->getPayment()
|
46 |
+
->setIsTransactionPending(true);
|
47 |
+
|
48 |
+
//Set the payment action
|
49 |
+
switch ($paymentAction) {
|
50 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
51 |
+
$encryptData['Capture'] = "AUTO";
|
52 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING);
|
53 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
54 |
+
break;
|
55 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
56 |
+
$encryptData['Capture'] = "MANUAL";
|
57 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE);
|
58 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION);
|
59 |
+
break;
|
60 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
61 |
+
$encryptData['Capture'] = $this->getPaymentMethod()->getConfigData('showdebitinhours');
|
62 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING);
|
63 |
+
$userData->setHours($this->getPaymentMethod()->getConfigData('showdebitinhours'));
|
64 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
65 |
+
break;
|
66 |
+
default:
|
67 |
+
Mage::throwException("Can't detect the payment moment.");
|
68 |
+
}
|
69 |
+
|
70 |
+
//This information is needed to check if the right controller is called
|
71 |
+
$userData->setPaymentCode($this->getPaymentMethod()->getCode());
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
77 |
+
*/
|
78 |
+
protected function _getRequestData()
|
79 |
+
{
|
80 |
+
//Get the request object
|
81 |
+
$request = $this->_getRequestObject();
|
82 |
+
$encryptData = $this->_getEncryptionDataObject();
|
83 |
+
$infoInstance = $this->getPaymentMethod()->getInfoInstance();
|
84 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
85 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
86 |
+
);
|
87 |
+
|
88 |
+
//Set the encrypt data
|
89 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
90 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
91 |
+
$encryptData['ReqID'] = $encryptData['TransID'].time();
|
92 |
+
|
93 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " . $orderDesc;
|
94 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
95 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
96 |
+
$encryptData['Response'] = 'encrypt';
|
97 |
+
|
98 |
+
|
99 |
+
//Build the params for the user callback urls
|
100 |
+
$sessionId = Mage::getSingleton('core/session')->getSessionId();
|
101 |
+
$userUrlParams = array(Dotsource_Computop_Controller_Callback::SESSION_KEY_PARAM => $sessionId);
|
102 |
+
|
103 |
+
//global param for all urls
|
104 |
+
$globalParams = array('_forced_secure' => true);
|
105 |
+
|
106 |
+
//Callback urls for computop
|
107 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_cc/success', array_merge($globalParams, $userUrlParams));
|
108 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_cc/failure', array_merge($globalParams, $userUrlParams));
|
109 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_cc/notify', $globalParams);
|
110 |
+
|
111 |
+
//Send this data not encrypted
|
112 |
+
//check for using xslt
|
113 |
+
if ($this->getPaymentMethod()->getConfigData('use_template')) {
|
114 |
+
$request['Template'] = $this->getPaymentMethod()->getConfigData('template');
|
115 |
+
}
|
116 |
+
|
117 |
+
$request['Language'] = $this->_getHelper()->getPaymentHelper()->getPaygateLanguage(
|
118 |
+
$this->_getBillingAddress()->getCountryModel()->getIso2Code(),
|
119 |
+
$this->getPaymentMethod()
|
120 |
+
);
|
121 |
+
|
122 |
+
$request['URLBack'] = Mage::getUrl('computop/callback_cc/back', array('_forced_secure' => true));
|
123 |
+
|
124 |
+
//If we have all data from the info instance
|
125 |
+
if ($this->getPaymentMethod()->getConfigData('use_pseudo_data')
|
126 |
+
&& $this->getPaymentMethod()->getConfigData('prefill_paymentinformation')
|
127 |
+
&& $infoInstance->hasCcNumberEnc()
|
128 |
+
&& $infoInstance->hasCcExpYear()
|
129 |
+
&& $infoInstance->hasCcExpMonth()
|
130 |
+
&& $infoInstance->hasCcType()
|
131 |
+
) {
|
132 |
+
$request['PCNr'] = $infoInstance->decrypt($infoInstance->getCcNumberEnc());
|
133 |
+
$request['PCNrBrand'] = $infoInstance->getCcType();
|
134 |
+
$request['PCNrMonth'] = $infoInstance->getCcExpMonth();
|
135 |
+
$request['PCNrYear'] = $infoInstance->getCcExpYear();
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Capture/New.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Cc_Capture_New
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
17 |
+
*/
|
18 |
+
public function getRequestFile()
|
19 |
+
{
|
20 |
+
return 'direct.aspx';
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
26 |
+
*/
|
27 |
+
protected function _getRequestData()
|
28 |
+
{
|
29 |
+
//Get the request object
|
30 |
+
$encryptData = $this->_getEncryptionDataObject();
|
31 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
32 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
33 |
+
);
|
34 |
+
|
35 |
+
//Set the encrypt data
|
36 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
37 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
38 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " . $orderDesc;
|
39 |
+
|
40 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
41 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
42 |
+
$encryptData['Capture'] = 'AUTO';
|
43 |
+
|
44 |
+
//Set the cc number
|
45 |
+
$encryptData['CCNr'] = Mage::helper('core')->getEncryptor()->decrypt(
|
46 |
+
$this->getPayment()->getCcNumberEnc()
|
47 |
+
);
|
48 |
+
|
49 |
+
//Cc expire date
|
50 |
+
$encryptData['CCExpiry'] = $this->_getHelper()->getConverter()->getComputopExpireDate(
|
51 |
+
$this->getPayment()->getCcExpMonth(),
|
52 |
+
$this->getPayment()->getCcExpYear()
|
53 |
+
);
|
54 |
+
|
55 |
+
//Set the brand
|
56 |
+
$encryptData['CCBrand'] = $this->_getHelper()->getConverter()->getCcType(
|
57 |
+
$this->getPayment()->getCcType(),
|
58 |
+
Dotsource_Computop_Helper_Converter::COMPUTOP_TYPE
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Capture.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Default_Capture
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
17 |
+
*/
|
18 |
+
public function getRequestFile()
|
19 |
+
{
|
20 |
+
return 'capture.aspx';
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
26 |
+
*/
|
27 |
+
protected function _getRequestData()
|
28 |
+
{
|
29 |
+
//Get the request object
|
30 |
+
$encryptData = $this->_getEncryptionDataObject();
|
31 |
+
|
32 |
+
//Set the encrypt data
|
33 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
34 |
+
$encryptData['PayID'] = $this->getReferencedTransactionModel()->getAdditionalInformation('payid');
|
35 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
36 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Refund.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Default_Refund
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
17 |
+
*/
|
18 |
+
public function getRequestFile()
|
19 |
+
{
|
20 |
+
return 'credit.aspx';
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
26 |
+
*/
|
27 |
+
protected function _getRequestData()
|
28 |
+
{
|
29 |
+
//Get the request object
|
30 |
+
$encryptData = $this->_getEncryptionDataObject();
|
31 |
+
|
32 |
+
//Set the encrypt data
|
33 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
34 |
+
$encryptData['PayID'] = $this->getReferencedTransactionModel()->getAdditionalInformation('payid');
|
35 |
+
|
36 |
+
if ($this->hasAmount()) {
|
37 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
38 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Reverse.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Default_Reverse
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
17 |
+
*/
|
18 |
+
public function getRequestFile()
|
19 |
+
{
|
20 |
+
return 'reverse.aspx';
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
26 |
+
*/
|
27 |
+
protected function _getRequestData()
|
28 |
+
{
|
29 |
+
//Get the request object
|
30 |
+
$encryptData = $this->_getEncryptionDataObject();
|
31 |
+
|
32 |
+
//Set the encrypt data
|
33 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
34 |
+
$encryptData['PayID'] = $this->getReferencedTransactionModel()->getAdditionalInformation('payid');
|
35 |
+
|
36 |
+
//Check if we should use amount
|
37 |
+
if ($this->hasAmount()) {
|
38 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
39 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Directpay/Authorize.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Directpay_Authorize
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Giropay_Authorize
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Giropay_Authorize::getRequestFile()
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getRequestFile()
|
21 |
+
{
|
22 |
+
return 'sofort.aspx';
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
28 |
+
*/
|
29 |
+
protected function _preProcessRequestData()
|
30 |
+
{
|
31 |
+
parent::_preProcessRequestData();
|
32 |
+
|
33 |
+
//Get the request objects
|
34 |
+
$encryptData = $this->_getEncryptionDataObject();
|
35 |
+
|
36 |
+
//Unset the key for direct pay
|
37 |
+
$encryptData->unsetData('otfMethod');
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
43 |
+
*/
|
44 |
+
protected function _getRequestData()
|
45 |
+
{
|
46 |
+
parent::_getRequestData();
|
47 |
+
|
48 |
+
//Get the encrypted request object
|
49 |
+
$encryptData = $this->_getEncryptionDataObject();
|
50 |
+
|
51 |
+
$orderDesc2 = $this->_getConverter()->convertToUtf8(
|
52 |
+
$this->getPaymentMethod()->getConfigData('orderdesc2')
|
53 |
+
);
|
54 |
+
|
55 |
+
$encryptData['OrderDesc2'] = $orderDesc2;
|
56 |
+
|
57 |
+
//Unset the data
|
58 |
+
$encryptData->unsetData('AutoStart');
|
59 |
+
|
60 |
+
//Override the information
|
61 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_directpay/success', array('_forced_secure' => true));
|
62 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_directpay/failure', array('_forced_secure' => true));
|
63 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_directpay/notify', array('_forced_secure' => true));
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Eft/Authorize.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Eft_Authorize
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Enable using ip zones */
|
16 |
+
protected $_useIpZones = true;
|
17 |
+
|
18 |
+
/** Disable using country zones */
|
19 |
+
protected $_useCountryZones = false;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
23 |
+
*/
|
24 |
+
public function getRequestFile()
|
25 |
+
{
|
26 |
+
return 'edddirect.aspx';
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
32 |
+
*/
|
33 |
+
protected function _preProcessRequestData()
|
34 |
+
{
|
35 |
+
//Do the parent stuff first
|
36 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
37 |
+
|
38 |
+
//Get the request objects
|
39 |
+
$encryptData = $this->_getEncryptionDataObject();
|
40 |
+
$userData = $this->_getUserDataObject();
|
41 |
+
$paymentAction = $this->getPaymentMethod()->getConfigData('payment_action_computop');
|
42 |
+
|
43 |
+
//Set the payment action
|
44 |
+
switch ($paymentAction) {
|
45 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
46 |
+
$encryptData['Capture'] = "AUTO";
|
47 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING);
|
48 |
+
break;
|
49 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
50 |
+
$encryptData['Capture'] = "MANUAL";
|
51 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE);
|
52 |
+
break;
|
53 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
54 |
+
$encryptData['Capture'] = $this->getPaymentMethod()->getConfigData('showdebitinhours');
|
55 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING);
|
56 |
+
$userData->setHours($this->getPaymentMethod()->getConfigData('showdebitinhours'));
|
57 |
+
break;
|
58 |
+
default:
|
59 |
+
Mage::throwException("Can't detect the payment moment.");
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
66 |
+
*/
|
67 |
+
protected function _getRequestData()
|
68 |
+
{
|
69 |
+
//Get the request objects
|
70 |
+
$encryptData = $this->_getEncryptionDataObject();
|
71 |
+
|
72 |
+
//Get the data we need
|
73 |
+
$infoInstance = $this->getPaymentMethod()->getInfoInstance();
|
74 |
+
|
75 |
+
//Get the order description
|
76 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
77 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
78 |
+
);
|
79 |
+
|
80 |
+
$orderDesc2 = $this->_getConverter()->convertToUtf8(
|
81 |
+
$this->getPaymentMethod()->getConfigData('orderdesc2')
|
82 |
+
);
|
83 |
+
|
84 |
+
//Set the encrypt data
|
85 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
86 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
87 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " .$orderDesc;
|
88 |
+
$encryptData['OrderDesc2'] = $orderDesc2;
|
89 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
90 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
91 |
+
$encryptData['Response'] = "encrypt";
|
92 |
+
|
93 |
+
//Set the user account information
|
94 |
+
$encryptData['AccOwner'] = $infoInstance->getEftOwner();
|
95 |
+
$encryptData['AccNr'] = $infoInstance->decrypt($infoInstance->getEftBanEnc());
|
96 |
+
$encryptData['AccIBAN'] = $infoInstance->getEftBcn();
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Authorize.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Giropay_Authorize
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
17 |
+
*/
|
18 |
+
public function getRequestFile()
|
19 |
+
{
|
20 |
+
return 'payOTF.aspx';
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
26 |
+
*/
|
27 |
+
protected function _preProcessRequestData()
|
28 |
+
{
|
29 |
+
//Do the parent stuff first
|
30 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
31 |
+
|
32 |
+
//Get the request objects
|
33 |
+
$encryptData = $this->_getEncryptionDataObject();
|
34 |
+
$userData = $this->_getUserDataObject();
|
35 |
+
|
36 |
+
//Authorize is always a async payment
|
37 |
+
$this
|
38 |
+
->getPayment()
|
39 |
+
->setIsTransactionPending(true)
|
40 |
+
->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
41 |
+
|
42 |
+
//Set giropay tag
|
43 |
+
$encryptData['otfMethod'] = 'giropay';
|
44 |
+
|
45 |
+
//Add the mode to the user data and the payment code
|
46 |
+
//The information are needed to check if the right controller is called
|
47 |
+
$userData
|
48 |
+
->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING)
|
49 |
+
->setPaymentCode($this->getPaymentMethod()->getCode());
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
55 |
+
*/
|
56 |
+
protected function _getRequestData()
|
57 |
+
{
|
58 |
+
//Get the request objects
|
59 |
+
$encryptData = $this->_getEncryptionDataObject();
|
60 |
+
$infoInstance = $this->getPaymentMethod()->getInfoInstance();
|
61 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
62 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
63 |
+
);
|
64 |
+
|
65 |
+
//Set the encrypt data
|
66 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
67 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
68 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " .$orderDesc;
|
69 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
70 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
71 |
+
$encryptData['Response'] = "encrypt";
|
72 |
+
|
73 |
+
//Callback urls for computop
|
74 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_giropay/success', array('_forced_secure' => true));
|
75 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_giropay/failure', array('_forced_secure' => true));
|
76 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_giropay/notify', array('_forced_secure' => true));
|
77 |
+
|
78 |
+
//Set the data if they exists in the info instance
|
79 |
+
if ($infoInstance->hasEftOwner()
|
80 |
+
&& $infoInstance->hasEftBanEnc()
|
81 |
+
&& $infoInstance->hasEftBcn()
|
82 |
+
) {
|
83 |
+
//Owner
|
84 |
+
$encryptData['AccOwner'] = $infoInstance->getEftOwner();
|
85 |
+
|
86 |
+
//Bank account number
|
87 |
+
$encryptData['AccNr'] = $infoInstance->decrypt($infoInstance->getEftBanEnc());
|
88 |
+
|
89 |
+
//Bank code number
|
90 |
+
$encryptData['AccIBAN'] = $infoInstance->getEftBcn();
|
91 |
+
|
92 |
+
//No need the change payment information on giropay site
|
93 |
+
$encryptData['AutoStart'] = '1';
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Check.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Giropay_Check
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Deactivate sending the hmac */
|
16 |
+
protected $_useHmac = false;
|
17 |
+
|
18 |
+
/** Deactivate logging the request */
|
19 |
+
protected $_logRequest = false;
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
24 |
+
*/
|
25 |
+
public function getRequestFile()
|
26 |
+
{
|
27 |
+
return 'giropayblz.aspx';
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getResponseModelCode()
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
protected function _getResponseModelCode()
|
37 |
+
{
|
38 |
+
return 'computop/payment_response_giropay_check';
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
44 |
+
*/
|
45 |
+
protected function _getRequestData()
|
46 |
+
{
|
47 |
+
//Get the request objects
|
48 |
+
$request = $this->_getRequestObject();
|
49 |
+
$encryptData = $this->_getEncryptionDataObject();
|
50 |
+
|
51 |
+
//Fill the request data to the non encrypt
|
52 |
+
$encryptData['MerchantID'] = $request['MerchantID'];
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Ideal/Authorize.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Request_Ideal_Authorize
|
12 |
+
extends Dotsource_Computop_Model_Payment_Request_Giropay_Authorize
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Request_Giropay_Authorize::_preProcessRequestData()
|
17 |
+
*/
|
18 |
+
protected function _preProcessRequestData()
|
19 |
+
{
|
20 |
+
parent::_preProcessRequestData();
|
21 |
+
|
22 |
+
//Get the request objects
|
23 |
+
$encryptData = $this->_getEncryptionDataObject();
|
24 |
+
|
25 |
+
//Override the old value
|
26 |
+
$encryptData['otfMethod'] = 'iDEAL';
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @see Dotsource_Computop_Model_Payment_Request_Giropay_Authorize::_getRequestData()
|
32 |
+
*/
|
33 |
+
protected function _getRequestData()
|
34 |
+
{
|
35 |
+
parent::_getRequestData();
|
36 |
+
|
37 |
+
//Get the encrypted request object
|
38 |
+
$encryptData = $this->_getEncryptionDataObject();
|
39 |
+
|
40 |
+
//Override the information
|
41 |
+
$encryptData['AutoStart'] = '0';
|
42 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_ideal/success', array('_forced_secure' => true));
|
43 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_ideal/failure', array('_forced_secure' => true));
|
44 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_ideal/notify', array('_forced_secure' => true));
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Mpass/Authorize.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 30.04.2010 17:10:23
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Request_Mpass_Authorize
|
15 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
20 |
+
*/
|
21 |
+
public function getRequestFile()
|
22 |
+
{
|
23 |
+
return 'mpass.aspx';
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
29 |
+
*/
|
30 |
+
protected function _preProcessRequestData()
|
31 |
+
{
|
32 |
+
//Do the parent stuff first
|
33 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
34 |
+
|
35 |
+
//Get the request objects
|
36 |
+
$encryptData = $this->_getEncryptionDataObject();
|
37 |
+
$userData = $this->_getUserDataObject();
|
38 |
+
$paymentAction = $this->getPaymentMethod()->getConfigData('payment_action_computop');
|
39 |
+
|
40 |
+
//Authorize is always a async payment
|
41 |
+
$this->getPayment()
|
42 |
+
->setIsTransactionPending(true);
|
43 |
+
|
44 |
+
//Set the payment action
|
45 |
+
switch ($paymentAction) {
|
46 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
47 |
+
$encryptData['Capture'] = 'AUTO';
|
48 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING);
|
49 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
50 |
+
break;
|
51 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
52 |
+
$encryptData['Capture'] = 'MANUAL';
|
53 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE);
|
54 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION);
|
55 |
+
break;
|
56 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
57 |
+
$encryptData['Capture'] = $this->getPaymentMethod()->getConfigData('showdebitinhours');
|
58 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING);
|
59 |
+
$userData->setHours($this->getPaymentMethod()->getConfigData('showdebitinhours'));
|
60 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
61 |
+
break;
|
62 |
+
default:
|
63 |
+
Mage::throwException('Can\'t detect the payment moment.');
|
64 |
+
}
|
65 |
+
|
66 |
+
//This information is needed to check if the right controller is called
|
67 |
+
$userData->setPaymentCode($this->getPaymentMethod()->getCode());
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
73 |
+
*/
|
74 |
+
protected function _getRequestData()
|
75 |
+
{
|
76 |
+
//Get the request object
|
77 |
+
$encryptData = $this->_getEncryptionDataObject();
|
78 |
+
$order = $this->getPayment()->getOrder();
|
79 |
+
$billingAddress = $order->getBillingAddress();
|
80 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
81 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
82 |
+
);
|
83 |
+
|
84 |
+
//Set the encrypt data
|
85 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
86 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
87 |
+
$encryptData['ReqID'] = $encryptData['TransID'].time();
|
88 |
+
|
89 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " .$orderDesc;
|
90 |
+
$encryptData['Amount'] = $this->_getConverter()->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
91 |
+
$encryptData['Currency'] = $this->_getConverter()->convertToUtf8($this->_getCurrencyCode());
|
92 |
+
$encryptData['Language'] = $this->_getHelper()->getPaymentHelper()->getPaygateLanguage(
|
93 |
+
$billingAddress->getCountryModel()->getIso2Code(),
|
94 |
+
$this->getPaymentMethod()
|
95 |
+
);
|
96 |
+
|
97 |
+
//Callback urls for computop
|
98 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_mpass/success', array('_forced_secure' => true));
|
99 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_mpass/failure', array('_forced_secure' => true));
|
100 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_mpass/notify', array('_forced_secure' => true));
|
101 |
+
}
|
102 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Paypal/Authorize.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 12:20:34
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Request_Paypal_Authorize
|
15 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getRequestFile()
|
24 |
+
{
|
25 |
+
return 'paypal.aspx';
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
31 |
+
*
|
32 |
+
* @return null
|
33 |
+
*/
|
34 |
+
protected function _preProcessRequestData()
|
35 |
+
{
|
36 |
+
//Do the parent stuff first
|
37 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
38 |
+
|
39 |
+
//Get the request objects
|
40 |
+
/* @var $encryptData Dotsource_Computop_Object */
|
41 |
+
$encryptData = $this->_getEncryptionDataObject();
|
42 |
+
$userData = $this->_getUserDataObject();
|
43 |
+
$paymentAction = $this->getPaymentMethod()->getConfigData('payment_action_computop');
|
44 |
+
|
45 |
+
//Authorize is always a async payment
|
46 |
+
$this->getPayment()
|
47 |
+
->setIsTransactionPending(true);
|
48 |
+
|
49 |
+
//Set the payment action
|
50 |
+
switch ($paymentAction) {
|
51 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
52 |
+
$encryptData['Capture'] = 'AUTO';
|
53 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING);
|
54 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
55 |
+
break;
|
56 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
57 |
+
$encryptData['Capture'] = 'MANUAL';
|
58 |
+
$encryptData['Txtype'] = $this->getPaymentMethod()->getConfigData('payment_action_txtype');
|
59 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE);
|
60 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_AUTHORIZATION);
|
61 |
+
break;
|
62 |
+
// TODO maybe this isn't supported
|
63 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING:
|
64 |
+
$encryptData['Capture'] = $this->getPaymentMethod()->getConfigData('showdebitinhours');
|
65 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::TIMEDBOOKING);
|
66 |
+
$userData->setHours($this->getPaymentMethod()->getConfigData('showdebitinhours'));
|
67 |
+
$this->getPayment()->setTransactionPendingStatus(Dotsource_Computop_Model_Payment_Abstract::WAITING_CAPTURE);
|
68 |
+
break;
|
69 |
+
default:
|
70 |
+
Mage::throwException('Can\'t detect the payment moment.');
|
71 |
+
}
|
72 |
+
|
73 |
+
//This information is needed to check if the right controller is called
|
74 |
+
$userData->setPaymentCode($this->getPaymentMethod()->getCode());
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
80 |
+
*/
|
81 |
+
protected function _getRequestData()
|
82 |
+
{
|
83 |
+
//Get the request objects
|
84 |
+
$encryptData = $this->_getEncryptionDataObject();
|
85 |
+
|
86 |
+
//Get the data we need
|
87 |
+
$order = $this->getPayment()->getOrder();
|
88 |
+
$billingAddress = $order->getBillingAddress();
|
89 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
90 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
91 |
+
);
|
92 |
+
|
93 |
+
/* @var $conv Dotsource_Computop_Helper_Converter */
|
94 |
+
$conv = $this->_getConverter();
|
95 |
+
|
96 |
+
//Set the encrypt data
|
97 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
98 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
99 |
+
$encryptData['ReqID'] = $encryptData['TransID'].time();
|
100 |
+
|
101 |
+
$encryptData['Amount'] = $conv->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
102 |
+
$encryptData['Currency'] = $conv->convertToUtf8($this->_getCurrencyCode());
|
103 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " .$orderDesc;
|
104 |
+
$encryptData['Response'] = 'encrypt';
|
105 |
+
$encryptData['Language'] = $this->_getHelper()->getPaymentHelper()->getPaygateLanguage(
|
106 |
+
$billingAddress->getCountryModel()->getIso2Code(),
|
107 |
+
$this->getPaymentMethod()
|
108 |
+
);
|
109 |
+
|
110 |
+
$shippingAddress = $order->getShippingAddress();
|
111 |
+
|
112 |
+
//Set the addressdata
|
113 |
+
$encryptData['FirstName'] = $conv->convertToUtf8($order->getCustomerFirstname());
|
114 |
+
$encryptData['LastName'] = $conv->convertToUtf8($order->getCustomerLastname());
|
115 |
+
|
116 |
+
// TODO should be forced to maxlength ?
|
117 |
+
$encryptData['AddrStreet'] = $conv->convertToUtf8($shippingAddress->getStreet1());
|
118 |
+
$encryptData['AddrStreet2'] = $conv->convertToUtf8($shippingAddress->getStreet2());
|
119 |
+
$encryptData['AddrCity'] = $conv->convertToUtf8($shippingAddress->getCity());
|
120 |
+
$encryptData['AddrState'] = $conv->convertToUtf8($shippingAddress->getRegion());
|
121 |
+
$encryptData['AddrZIP'] = $conv->convertToUtf8($shippingAddress->getPostcode());
|
122 |
+
$encryptData['AddrCountryCode'] = $conv->convertToUtf8($shippingAddress->getCountryModel()->getIso3Code());
|
123 |
+
$encryptData['Phone'] = $conv->convertToUtf8($shippingAddress->getTelephone());
|
124 |
+
$encryptData['BillingAddrStreet2'] = $conv->convertToUtf8($billingAddress->getStreetFull());
|
125 |
+
|
126 |
+
//Callback urls for computop
|
127 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_paypal/success', array('_forced_secure' => true));
|
128 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_paypal/failure', array('_forced_secure' => true));
|
129 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_paypal/notify', array('_forced_secure' => true));
|
130 |
+
}
|
131 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Paypalexpress/Authorize.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 12:20:34
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_Payment_Request_Paypalexpress_Authorize
|
15 |
+
extends Dotsource_Computop_Model_Payment_Request_Request
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::getRequestFile()
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getRequestFile()
|
24 |
+
{
|
25 |
+
return 'paypal.aspx';
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData()
|
31 |
+
*
|
32 |
+
* @return null
|
33 |
+
*/
|
34 |
+
protected function _preProcessRequestData()
|
35 |
+
{
|
36 |
+
//Do the parent stuff first
|
37 |
+
Dotsource_Computop_Model_Payment_Request_Request::_preProcessRequestData();
|
38 |
+
|
39 |
+
//Get the request objects
|
40 |
+
/* @var $encryptData Dotsource_Computop_Object */
|
41 |
+
$encryptData = $this->_getEncryptionDataObject();
|
42 |
+
$userData = $this->_getUserDataObject();
|
43 |
+
$paymentAction = $this->getPaymentMethod()->getConfigData('payment_action_computop');
|
44 |
+
|
45 |
+
//Set the payment action
|
46 |
+
switch ($paymentAction) {
|
47 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING:
|
48 |
+
$encryptData['Capture'] = 'MANUAL';
|
49 |
+
$encryptData['Txtype'] = 'Order';
|
50 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::BOOKING);
|
51 |
+
break;
|
52 |
+
case Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE:
|
53 |
+
$encryptData['Capture'] = 'MANUAL';
|
54 |
+
$encryptData['Txtype'] = $this->getPaymentMethod()->getConfigData('payment_action_txtype');
|
55 |
+
$userData->setCapture(Dotsource_Computop_Model_System_Config_Source_Paymentaction::AUTHORIZE);
|
56 |
+
break;
|
57 |
+
default:
|
58 |
+
Mage::throwException('Can\'t detect the payment moment.');
|
59 |
+
}
|
60 |
+
|
61 |
+
//This information is needed to check if the right controller is called
|
62 |
+
$userData->setPaymentCode($this->getPaymentMethod()->getCode());
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Retrieves the default country model.
|
68 |
+
*
|
69 |
+
* @return Mage_Directory_Model_Country
|
70 |
+
*/
|
71 |
+
protected function _getDefaultCountryModel()
|
72 |
+
{
|
73 |
+
$defaultCountryId = Mage::getStoreConfig('general/country/default');
|
74 |
+
$model = Mage::getModel('directory/country');
|
75 |
+
return $model->load($defaultCountryId);
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @see Dotsource_Computop_Model_Payment_Request_Request::_getRequestData()
|
81 |
+
*/
|
82 |
+
protected function _getRequestData()
|
83 |
+
{
|
84 |
+
//Get the request objects
|
85 |
+
$encryptData = $this->_getEncryptionDataObject();
|
86 |
+
|
87 |
+
//Get the data we need
|
88 |
+
$orderDesc = $this->_getConverter()->convertToUtf8(
|
89 |
+
$this->getPaymentMethod()->getConfigData('orderdesc')
|
90 |
+
);
|
91 |
+
|
92 |
+
/* @var $conv Dotsource_Computop_Helper_Converter */
|
93 |
+
$conv = $this->_getConverter();
|
94 |
+
|
95 |
+
//Set the encrypt data
|
96 |
+
$encryptData['TransID'] = $this->_getIncrementId();
|
97 |
+
$encryptData['RefNr'] = $this->getComputopTransactionModel()->getTransactionCode();
|
98 |
+
$encryptData['ReqID'] = $encryptData['TransID'].time();
|
99 |
+
|
100 |
+
$encryptData['Amount'] = $conv->formatPrice($this->getAmount(), $this->_getCurrencyCode());
|
101 |
+
$encryptData['Currency'] = $conv->convertToUtf8($this->_getCurrencyCode());
|
102 |
+
$encryptData['OrderDesc'] = $encryptData['TransID'] . " " .$orderDesc;
|
103 |
+
$encryptData['Response'] = 'encrypt';
|
104 |
+
$encryptData['Language'] = $this->_getHelper()->getPaymentHelper()->getPaygateLanguage(
|
105 |
+
$this->_getDefaultCountryModel()->getIso2Code(),
|
106 |
+
$this->getPaymentMethod()
|
107 |
+
);
|
108 |
+
|
109 |
+
//Callback urls for computop
|
110 |
+
$encryptData['URLSuccess'] = Mage::getUrl('computop/callback_paypalexpress/success', array('_forced_secure' => true));
|
111 |
+
$encryptData['URLFailure'] = Mage::getUrl('computop/callback_paypalexpress/failure', array('_forced_secure' => true));
|
112 |
+
$encryptData['URLNotify'] = Mage::getUrl('computop/callback_paypalexpress/notify', array('_forced_secure' => true));
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Request/Request.php
ADDED
@@ -0,0 +1,835 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
abstract class Dotsource_Computop_Model_Payment_Request_Request
|
11 |
+
extends Dotsource_Computop_Object
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the const for gettings the request as array */
|
15 |
+
const REQUEST_AS_ARRAY = 1;
|
16 |
+
|
17 |
+
/** Holds the request for getting the request as string */
|
18 |
+
const REQUEST_AS_STRING = 2;
|
19 |
+
|
20 |
+
/** Holds the default model code to instanciate the response model */
|
21 |
+
const DEFAULT_RESPONSE_MODEL_CODE = 'computop/payment_response_response';
|
22 |
+
|
23 |
+
|
24 |
+
/** If the value is true the response model try to add country zones */
|
25 |
+
protected $_useIpZones = false;
|
26 |
+
|
27 |
+
/** If the value is true the response model try to add country zones */
|
28 |
+
protected $_useCountryZones = false;
|
29 |
+
|
30 |
+
/** Holds a flag if we use encryption */
|
31 |
+
protected $_useEncryption = true;
|
32 |
+
|
33 |
+
/** Holds if the request should use hmac */
|
34 |
+
protected $_useHmac = true;
|
35 |
+
|
36 |
+
/** Holds if the request will logs by the connection */
|
37 |
+
protected $_logRequest = true;
|
38 |
+
|
39 |
+
|
40 |
+
/** Holds the current container for the response */
|
41 |
+
protected $_requestObject = null;
|
42 |
+
|
43 |
+
/** Holds the encryption data object */
|
44 |
+
protected $_encryptionDataObject = null;
|
45 |
+
|
46 |
+
/** Holds the user data object */
|
47 |
+
protected $_userDataObject = null;
|
48 |
+
|
49 |
+
/** Holds the request as string */
|
50 |
+
protected $_requestArray = null;
|
51 |
+
|
52 |
+
/** Holds the response model */
|
53 |
+
protected $_responseModel = null;
|
54 |
+
|
55 |
+
/** Holds the dangerous tags we need to remove from the request */
|
56 |
+
protected $_dangerousTags = array('MerchantID');
|
57 |
+
|
58 |
+
/** Holds the payment */
|
59 |
+
protected $_payment = null;
|
60 |
+
|
61 |
+
/** Holds the payment method */
|
62 |
+
protected $_paymentMethod = null;
|
63 |
+
|
64 |
+
/** Holds a specific amount */
|
65 |
+
protected $_amount = null;
|
66 |
+
|
67 |
+
/** Holds the referenced transaction model */
|
68 |
+
protected $_referencedTransaction = null;
|
69 |
+
|
70 |
+
/** Default we use the auto as area */
|
71 |
+
protected $_computopTransactionArea = Dotsource_Computop_Helper_Data::AUTO;
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* This abstract method create the real request data.
|
76 |
+
*/
|
77 |
+
protected abstract function _getRequestData();
|
78 |
+
|
79 |
+
/**
|
80 |
+
* This abstract method return the file name.
|
81 |
+
*/
|
82 |
+
public abstract function getRequestFile();
|
83 |
+
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Return the used object for parsing the response.
|
87 |
+
*
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
protected function _getResponseModelCode()
|
91 |
+
{
|
92 |
+
return self::DEFAULT_RESPONSE_MODEL_CODE;
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Retrieves the base currency code.
|
98 |
+
*
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
protected function _getCurrencyCode()
|
102 |
+
{
|
103 |
+
//Get the current payment
|
104 |
+
$payment = $this->getPayment();
|
105 |
+
|
106 |
+
if ($payment instanceof Mage_Sales_Model_Order_Payment) {
|
107 |
+
return $payment->getOrder()->getBaseCurrencyCode();
|
108 |
+
} else if($payment instanceof Mage_Sales_Model_Quote_Payment) {
|
109 |
+
return $payment->getQuote()->getBaseCurrencyCode();
|
110 |
+
}
|
111 |
+
|
112 |
+
Mage::throwException('Can\'t process the current payment.');
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Return the order or the quote reserved inrement id.
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
protected function _getIncrementId()
|
122 |
+
{
|
123 |
+
//Get the current payment
|
124 |
+
$payment = $this->getPayment();
|
125 |
+
|
126 |
+
if ($payment instanceof Mage_Sales_Model_Order_Payment) {
|
127 |
+
return $payment->getOrder()->getIncrementId();
|
128 |
+
} else if($payment instanceof Mage_Sales_Model_Quote_Payment) {
|
129 |
+
return $payment->getQuote()->reserveOrderId()->getReservedOrderId();
|
130 |
+
}
|
131 |
+
|
132 |
+
Mage::throwException('Can\'t process the current payment.');
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Do a pre process of the request.
|
138 |
+
*/
|
139 |
+
protected function _preProcessRequestData()
|
140 |
+
{
|
141 |
+
$request = $this->_getRequestObject();
|
142 |
+
$encryptData = $this->_getEncryptionDataObject();
|
143 |
+
|
144 |
+
//Add the merchant id in depends on the payment and the currency
|
145 |
+
$request['MerchantID'] = $this->_getHelper()->getConfiguration()->getPaymentSpecificMerchantFieldByCurrency(
|
146 |
+
$this->getPaymentMethod()->getCode(),
|
147 |
+
$this->_getCurrencyCode(),
|
148 |
+
'id'
|
149 |
+
);
|
150 |
+
|
151 |
+
//We need the merchant id for callbacks
|
152 |
+
$encryptData['plain'] = $request['MerchantID'];
|
153 |
+
|
154 |
+
//Check if we use encryption mode for the request and set the encryption
|
155 |
+
//settings in depends of the payment and merchant
|
156 |
+
if ($this->useEncryption() && !$encryptData->hasEncryptionSettings()) {
|
157 |
+
$encryptData->setEncryptionSettings(
|
158 |
+
$this->_getHelper()->getConfiguration()->getPaymentSpecificMerchantFieldByMerchantId(
|
159 |
+
$this->getPaymentMethod()->getCode(),
|
160 |
+
$request['MerchantID']
|
161 |
+
)
|
162 |
+
);
|
163 |
+
}
|
164 |
+
|
165 |
+
//Add ip zones to the result
|
166 |
+
if ($this->useIpZones() && $this->getPaymentMethod()->useIpZones()) {
|
167 |
+
$encryptData['IPZone'] = $this->getPaymentMethod()->convertedIpZone();
|
168 |
+
$encryptData['IPAddr'] = Mage::app()->getRequest()->getClientIp();
|
169 |
+
}
|
170 |
+
|
171 |
+
//Add country zone if we have all data
|
172 |
+
if ($this->useCountryZones() && $this->getPaymentMethod()->useCountryZones()) {
|
173 |
+
$encryptData['Zone'] = $this->getPaymentMethod()->convertedCountryZone();
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* The post process method is used for set the mac if the
|
180 |
+
* and used for the encryption part.
|
181 |
+
*
|
182 |
+
*/
|
183 |
+
protected function _postProcessRequestData()
|
184 |
+
{
|
185 |
+
//Get the request objects
|
186 |
+
$dirty = false;
|
187 |
+
$request = $this->_getRequestObject();
|
188 |
+
$encryptData = $this->_getEncryptionDataObject();
|
189 |
+
$userData = $this->_getUserDataObject();
|
190 |
+
|
191 |
+
//Check if we have already a mac
|
192 |
+
if ($this->useHmac() && $encryptData->isDataEmpty('MAC')) {
|
193 |
+
//set the dirty flag for refresh data field
|
194 |
+
$dirty = true;
|
195 |
+
|
196 |
+
//Create the mac
|
197 |
+
$mac = $encryptData->getEncryptor()->createHmac(
|
198 |
+
$encryptData->getDataOrDefault('PayID', ''),
|
199 |
+
$encryptData->getDataOrDefault('TransID', ''),
|
200 |
+
$request->getDataOrDefault('MerchantID', ''),
|
201 |
+
$encryptData->getDataOrDefault('Amount', ''),
|
202 |
+
$encryptData->getDataOrDefault('Currency', '')
|
203 |
+
);
|
204 |
+
|
205 |
+
//Set the max to the encrypt data
|
206 |
+
$encryptData->setData('MAC', $mac);
|
207 |
+
} else {
|
208 |
+
//Unset the mac
|
209 |
+
$encryptData->unsetData('MAC');
|
210 |
+
}
|
211 |
+
|
212 |
+
//Check if we have user data we need to convert to string
|
213 |
+
if (!is_string($encryptData->getData('UserData'))) {
|
214 |
+
$dirty = true;
|
215 |
+
|
216 |
+
if (!$userData->isEmpty()) {
|
217 |
+
$encryptData->setData('UserData', base64_encode($userData->toString()));
|
218 |
+
} else {
|
219 |
+
$encryptData->unsetData('UserData');
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
//Check for refresh the data and len field in the request object
|
224 |
+
if ($this->useEncryption()) {
|
225 |
+
if ($dirty || !is_string($request->getData('Data'))) {
|
226 |
+
//Set the data as encrypted string
|
227 |
+
$request
|
228 |
+
->setData('Len', $encryptData->getStringLength())
|
229 |
+
->setData('Data', $encryptData->toString());
|
230 |
+
}
|
231 |
+
} else {
|
232 |
+
$request->unsetData('Data');
|
233 |
+
$request->addData($encryptData);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Create one request object for the request data.
|
240 |
+
*
|
241 |
+
* @return Dotsource_Computop_Object
|
242 |
+
*/
|
243 |
+
protected function _getRequestObject()
|
244 |
+
{
|
245 |
+
if (is_null($this->_requestObject)) {
|
246 |
+
$this->_requestObject = new Dotsource_Computop_Object();
|
247 |
+
$this->_requestObject->setEncryption(false);
|
248 |
+
}
|
249 |
+
|
250 |
+
return $this->_requestObject;
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Create a encryption object for the data container in the request.
|
256 |
+
*
|
257 |
+
* @return Dotsource_Computop_Object
|
258 |
+
*/
|
259 |
+
protected function _getEncryptionDataObject()
|
260 |
+
{
|
261 |
+
if (is_null($this->_encryptionDataObject)) {
|
262 |
+
$this->_encryptionDataObject = new Dotsource_Computop_Object();
|
263 |
+
$this->_encryptionDataObject->setEncryption(true);
|
264 |
+
|
265 |
+
//Set the encryption data object to the main request object
|
266 |
+
$this->_getRequestObject()->setData('Data', $this->_encryptionDataObject);
|
267 |
+
}
|
268 |
+
|
269 |
+
return $this->_encryptionDataObject;
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Retrieves the encrypted PayID of the request.
|
275 |
+
*
|
276 |
+
* @return string
|
277 |
+
*/
|
278 |
+
public function getPayid()
|
279 |
+
{
|
280 |
+
return $this->_getEncryptionDataObject()->getData('PayID');
|
281 |
+
}
|
282 |
+
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Return the user data container from the request.
|
286 |
+
*
|
287 |
+
* @return Dotsource_Computop_Object
|
288 |
+
*/
|
289 |
+
protected function _getUserDataObject()
|
290 |
+
{
|
291 |
+
if (is_null($this->_userDataObject)) {
|
292 |
+
$this->_userDataObject = new Dotsource_Computop_Object();
|
293 |
+
$this->_userDataObject->setEncryption(false);
|
294 |
+
|
295 |
+
//Set the encryption data object to the main request object
|
296 |
+
$this->_getEncryptionDataObject()->setData('UserData', $this->_userDataObject);
|
297 |
+
}
|
298 |
+
|
299 |
+
return $this->_userDataObject;
|
300 |
+
}
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Check if we have already a request.
|
305 |
+
*
|
306 |
+
* @return boolean
|
307 |
+
*/
|
308 |
+
protected function _hasRequest()
|
309 |
+
{
|
310 |
+
return !is_null($this->_requestArray);
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Add the given string or the given array to the
|
316 |
+
* dangerous tag list.
|
317 |
+
*
|
318 |
+
* @param array || string $tag
|
319 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
320 |
+
*/
|
321 |
+
protected function _addDangerousTag($tag)
|
322 |
+
{
|
323 |
+
//We need an array
|
324 |
+
if (!is_array($tag)) {
|
325 |
+
$tag = array($tag);
|
326 |
+
}
|
327 |
+
|
328 |
+
//Add the given tags to the object tags list
|
329 |
+
$this->_dangerousTags = array_merge($this->_dangerousTags, $tag);
|
330 |
+
|
331 |
+
return $this;
|
332 |
+
}
|
333 |
+
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Return the array with dangerous tags who need to
|
337 |
+
* strip from the xml structure.
|
338 |
+
*
|
339 |
+
* @return array
|
340 |
+
*/
|
341 |
+
public function getDangerousTag()
|
342 |
+
{
|
343 |
+
return $this->_dangerousTags;
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Return the request as string. The first call of
|
349 |
+
* this method return a full request with all tags, all
|
350 |
+
* next calls will get the clean request with filtered tags.
|
351 |
+
*
|
352 |
+
* @return array
|
353 |
+
*/
|
354 |
+
public function getRequest($format = self::REQUEST_AS_ARRAY)
|
355 |
+
{
|
356 |
+
//Check if we have an response already
|
357 |
+
if (!$this->_hasRequest()) {
|
358 |
+
//Do the pre process
|
359 |
+
$this->_preProcessRequestData();
|
360 |
+
|
361 |
+
//this method writes the data in the xml writer
|
362 |
+
$this->_getRequestData();
|
363 |
+
|
364 |
+
//Do the post process
|
365 |
+
$this->_postProcessRequestData();
|
366 |
+
|
367 |
+
//Log
|
368 |
+
if ($this->_getHelper()->isDemoMode()) {
|
369 |
+
if ($this->useEncryption()) {
|
370 |
+
$this->_getHelper()->Log($this->_getEncryptionDataObject(), 'Request');
|
371 |
+
} else {
|
372 |
+
$this->_getHelper()->Log($this->_getRequestObject(), 'Request');
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
//Check for setting up the computop transaction id
|
377 |
+
$this->_syncComputopTransactionIdToPayment();
|
378 |
+
|
379 |
+
//Convert the full request to the output format
|
380 |
+
$requestData = $this->_formatRequest($this->_getRequestObject(), $format);
|
381 |
+
|
382 |
+
//Now clean the data and request object
|
383 |
+
$this->_getConverter()->stripDangerousTags(
|
384 |
+
$this->getDangerousTag(),
|
385 |
+
$this->_getRequestObject()
|
386 |
+
);
|
387 |
+
|
388 |
+
//Convert the filtered data in the output format
|
389 |
+
$this->_requestArray = $this->_formatRequest($this->_getRequestObject(), $format);
|
390 |
+
|
391 |
+
//The first call get the full request all other get the clean request array
|
392 |
+
return $requestData;
|
393 |
+
}
|
394 |
+
|
395 |
+
//Return the response
|
396 |
+
return $this->_requestArray;
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Set the computop transaction id if the current payment has no
|
402 |
+
*
|
403 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
404 |
+
*/
|
405 |
+
protected function _syncComputopTransactionIdToPayment()
|
406 |
+
{
|
407 |
+
//We need a payment for that
|
408 |
+
if (!$this->hasPayment()) {
|
409 |
+
return $this;
|
410 |
+
}
|
411 |
+
|
412 |
+
//Check if we have already a computop transaction id
|
413 |
+
if (!$this->getPayment()->getComputopTransactionId()) {
|
414 |
+
//Get the transaction model
|
415 |
+
$transactionModel = $this->getComputopTransactionModel();
|
416 |
+
|
417 |
+
//If the model has an id we store this in the payment
|
418 |
+
if ($transactionModel->hasId()) {
|
419 |
+
$this->getPayment()->setComputopTransactionId($transactionModel->getId());
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
return $this;
|
424 |
+
}
|
425 |
+
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Formats the given request and the given data in the given format.
|
429 |
+
*
|
430 |
+
* @param mixed $request
|
431 |
+
* @param int $format
|
432 |
+
* @return mixed
|
433 |
+
*/
|
434 |
+
protected function _formatRequest($request, $format)
|
435 |
+
{
|
436 |
+
if (self::REQUEST_AS_ARRAY === $format) {
|
437 |
+
return $request->toArray();
|
438 |
+
} else if(self::REQUEST_AS_STRING === $format) {
|
439 |
+
return $request->toString();
|
440 |
+
}
|
441 |
+
|
442 |
+
Mage::throwException("Can't process the given format.");
|
443 |
+
}
|
444 |
+
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Create a response model from the given response string.
|
448 |
+
*
|
449 |
+
* @param string $responseString
|
450 |
+
* @param boolean $forceEncryption
|
451 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
452 |
+
*/
|
453 |
+
public function setResponse($responseString, $forceEncryption = true)
|
454 |
+
{
|
455 |
+
//This method can only used once per object
|
456 |
+
if (null === $this->_responseModel) {
|
457 |
+
//Create the response object
|
458 |
+
$this->_responseModel = Mage::getModel($this->_getResponseModelCode());
|
459 |
+
|
460 |
+
//check for the right object type
|
461 |
+
if ($this->_responseModel instanceof Dotsource_Computop_Model_Payment_Response_Response) {
|
462 |
+
//Set the encryptor model for decryption to the response model
|
463 |
+
if ($this->useEncryption()) {
|
464 |
+
$this->_responseModel->setEncryptor($this->_getEncryptionDataObject()->getEncryptor());
|
465 |
+
}
|
466 |
+
|
467 |
+
//Set the response
|
468 |
+
$this->_responseModel->setResponse($responseString, $forceEncryption);
|
469 |
+
} else {
|
470 |
+
throw new Exception('The object must be an instance of Dotsource_Computop_Model_Payment_Response_Response.');
|
471 |
+
}
|
472 |
+
} else {
|
473 |
+
throw new Exception('The request object has already a response.');
|
474 |
+
}
|
475 |
+
|
476 |
+
return $this;
|
477 |
+
}
|
478 |
+
|
479 |
+
|
480 |
+
/**
|
481 |
+
* @see Dotsource_Computop_Object::toString()
|
482 |
+
*
|
483 |
+
* @param string $noNeed
|
484 |
+
* @return string
|
485 |
+
*/
|
486 |
+
public function toString($noNeed = null)
|
487 |
+
{
|
488 |
+
//If we have an request object we return the string from the request object
|
489 |
+
if ($this->_hasRequest()) {
|
490 |
+
return $this->_getRequestObject()->toString();
|
491 |
+
}
|
492 |
+
|
493 |
+
return "";
|
494 |
+
}
|
495 |
+
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Return the response model who was created
|
499 |
+
* with the method setResponse(...).
|
500 |
+
*
|
501 |
+
* @return Dotsource_Computop_Model_Payment_Response_Response
|
502 |
+
*/
|
503 |
+
public function getResponseModel()
|
504 |
+
{
|
505 |
+
return $this->_responseModel;
|
506 |
+
}
|
507 |
+
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Set the payment for the request action.
|
511 |
+
*
|
512 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
513 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
514 |
+
*/
|
515 |
+
public function setPayment(Mage_Payment_Model_Info $payment)
|
516 |
+
{
|
517 |
+
$this->_payment = $payment;
|
518 |
+
return $this;
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Return the payment.
|
524 |
+
*
|
525 |
+
* @return Mage_Sales_Model_Order_Payment
|
526 |
+
*/
|
527 |
+
public function getPayment()
|
528 |
+
{
|
529 |
+
return $this->_payment;
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Checks if an payment is set.
|
535 |
+
*
|
536 |
+
* @return boolean
|
537 |
+
*/
|
538 |
+
public function hasPayment()
|
539 |
+
{
|
540 |
+
return null !== $this->getPayment();
|
541 |
+
}
|
542 |
+
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Return the payment method.
|
546 |
+
*
|
547 |
+
* @return Dotsource_Computop_Model_Payment_Abstract
|
548 |
+
*/
|
549 |
+
public function getPaymentMethod()
|
550 |
+
{
|
551 |
+
return $this->_paymentMethod;
|
552 |
+
}
|
553 |
+
|
554 |
+
|
555 |
+
/**
|
556 |
+
* Set the payment method.
|
557 |
+
*
|
558 |
+
* @param Mage_Payment_Model_Method_Abstract $paymentMethod
|
559 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
560 |
+
*/
|
561 |
+
public function setPaymentMethod(Mage_Payment_Model_Method_Abstract $paymentMethod)
|
562 |
+
{
|
563 |
+
$this->_paymentMethod = $paymentMethod;
|
564 |
+
return $this;
|
565 |
+
}
|
566 |
+
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Return true if we have an payment method.
|
570 |
+
*
|
571 |
+
* @return boolean
|
572 |
+
*/
|
573 |
+
public function hasPaymentMethod()
|
574 |
+
{
|
575 |
+
return null !== $this->getPaymentMethod();
|
576 |
+
}
|
577 |
+
|
578 |
+
|
579 |
+
/**
|
580 |
+
* Checks if the request model has an specific amount.
|
581 |
+
*
|
582 |
+
* @return boolean
|
583 |
+
*/
|
584 |
+
public function hasAmount()
|
585 |
+
{
|
586 |
+
return null !== $this->getAmount();
|
587 |
+
}
|
588 |
+
|
589 |
+
|
590 |
+
/**
|
591 |
+
* Return the specific amount.
|
592 |
+
*
|
593 |
+
* @return float
|
594 |
+
*/
|
595 |
+
public function getAmount()
|
596 |
+
{
|
597 |
+
return $this->_amount;
|
598 |
+
}
|
599 |
+
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Set a specific amount for the request.
|
603 |
+
*
|
604 |
+
* @param float $amount
|
605 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
606 |
+
*/
|
607 |
+
public function setAmount($amount)
|
608 |
+
{
|
609 |
+
$this->_amount = $amount;
|
610 |
+
return $this;
|
611 |
+
}
|
612 |
+
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Set the computop transaction area.
|
616 |
+
*
|
617 |
+
* @param int $_computopTransactionArea
|
618 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
619 |
+
*/
|
620 |
+
public function setComputopTransactionArea($computopTransactionArea)
|
621 |
+
{
|
622 |
+
$this->_computopTransactionArea = $computopTransactionArea;
|
623 |
+
return $this;
|
624 |
+
}
|
625 |
+
|
626 |
+
|
627 |
+
/**
|
628 |
+
* Return the computop area.
|
629 |
+
*
|
630 |
+
* @return int
|
631 |
+
*/
|
632 |
+
public function getComputopTransactionArea()
|
633 |
+
{
|
634 |
+
return $this->_computopTransactionArea;
|
635 |
+
}
|
636 |
+
|
637 |
+
|
638 |
+
/**
|
639 |
+
* Check if the request has an referenced transaction model.
|
640 |
+
*
|
641 |
+
* @return boolean
|
642 |
+
*/
|
643 |
+
public function hasReferencedTransactionModel()
|
644 |
+
{
|
645 |
+
return $this->getReferencedTransactionModel() instanceof Mage_Sales_Model_Order_Payment_Transaction;
|
646 |
+
}
|
647 |
+
|
648 |
+
|
649 |
+
/**
|
650 |
+
* Return the referenced transaction model.
|
651 |
+
*
|
652 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
653 |
+
*/
|
654 |
+
public function getReferencedTransactionModel()
|
655 |
+
{
|
656 |
+
return $this->_referencedTransaction;
|
657 |
+
}
|
658 |
+
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Set a referenced transaction model.
|
662 |
+
*
|
663 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $referencedTransactionModel
|
664 |
+
* @return Dotsource_Computop_Model_Payment_Request_Request
|
665 |
+
*/
|
666 |
+
public function setReferencedTransactionModel(Mage_Sales_Model_Order_Payment_Transaction $referencedTransactionModel)
|
667 |
+
{
|
668 |
+
$this->_referencedTransaction = $referencedTransactionModel;
|
669 |
+
return $this;
|
670 |
+
}
|
671 |
+
|
672 |
+
|
673 |
+
/**
|
674 |
+
* Return the computop transaction model in depends of the configured area.
|
675 |
+
*
|
676 |
+
* @return Dotsource_Computop_Model_Transaction
|
677 |
+
*/
|
678 |
+
public function getComputopTransactionModel()
|
679 |
+
{
|
680 |
+
$transactionId = null;
|
681 |
+
|
682 |
+
//Get the previous transaction id from the current payment
|
683 |
+
if ($this->hasPayment() && $this->getPayment()->getComputopTransactionId()) {
|
684 |
+
$transactionId = $this->getPayment()->getComputopTransactionId();
|
685 |
+
}
|
686 |
+
|
687 |
+
//Return the transaction model
|
688 |
+
$transactionModel = $this->_getHelper()->getTransactionModel(
|
689 |
+
$transactionId,
|
690 |
+
$this->getComputopTransactionArea()
|
691 |
+
);
|
692 |
+
|
693 |
+
return $transactionModel;
|
694 |
+
}
|
695 |
+
|
696 |
+
|
697 |
+
/**
|
698 |
+
* Return if we can use ip zones.
|
699 |
+
*
|
700 |
+
* @return boolean
|
701 |
+
*/
|
702 |
+
public function useIpZones()
|
703 |
+
{
|
704 |
+
return $this->_useIpZones;
|
705 |
+
}
|
706 |
+
|
707 |
+
|
708 |
+
/**
|
709 |
+
* Return if we can use country zones.
|
710 |
+
*
|
711 |
+
* @return unknown
|
712 |
+
*/
|
713 |
+
public function useCountryZones()
|
714 |
+
{
|
715 |
+
return $this->_useCountryZones;
|
716 |
+
}
|
717 |
+
|
718 |
+
|
719 |
+
/**
|
720 |
+
* First the method try to return the billing address object from the
|
721 |
+
* object data container. If no billing address object is available
|
722 |
+
* the billing address from the quote is getting returned.
|
723 |
+
*
|
724 |
+
* @return Mage_Sales_Model_Quote_Address
|
725 |
+
*/
|
726 |
+
protected function _getBillingAddress()
|
727 |
+
{
|
728 |
+
//Check for an billing object in the current data container
|
729 |
+
if ($this->hasBillingAddress()) {
|
730 |
+
return $this->getBillingAddress();
|
731 |
+
}
|
732 |
+
|
733 |
+
//Check if we can use the billing address from the order
|
734 |
+
if ($this->hasPayment()) {
|
735 |
+
$payment = $this->getPayment();
|
736 |
+
|
737 |
+
if ($payment instanceof Mage_Sales_Model_Order_Payment) {
|
738 |
+
return $payment->getOrder()->getBillingAddress();
|
739 |
+
} else if($payment instanceof Mage_Sales_Model_Quote_Payment) {
|
740 |
+
return $payment->getQuote()->getBillingAddress();
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
+
//Get the billing address from the current quote
|
745 |
+
return $this->_getHelper()->getQuote()->getBillingAddress();
|
746 |
+
}
|
747 |
+
|
748 |
+
|
749 |
+
/**
|
750 |
+
* Return the email address from the customer.
|
751 |
+
*
|
752 |
+
* @return string
|
753 |
+
*/
|
754 |
+
protected function _getEmailAddress()
|
755 |
+
{
|
756 |
+
//Check if the current customer has an email address
|
757 |
+
$customer = $this->_getHelper()->getCustomer();
|
758 |
+
|
759 |
+
if (!empty($customer) && $customer->hasEmail()) {
|
760 |
+
return $customer->getEmail();
|
761 |
+
}
|
762 |
+
|
763 |
+
//Check if we can get the email from the quote or order
|
764 |
+
$model = null;
|
765 |
+
if ($this->hasPayment()) {
|
766 |
+
$model = $this->getPayment()->getOrder();
|
767 |
+
} else {
|
768 |
+
$model = $this->_getHelper()->getQuote();
|
769 |
+
}
|
770 |
+
|
771 |
+
//Check for quote or the order from the email address
|
772 |
+
if ($model->hasCustomerEmail()) {
|
773 |
+
return $model->getCustomerEmail();
|
774 |
+
} else if ($this->getBillingAddress()->hasEmail()) {
|
775 |
+
return $this->getBillingAddress()->getEmail();
|
776 |
+
}
|
777 |
+
|
778 |
+
Mage::throwException("Can't find a email address.");
|
779 |
+
}
|
780 |
+
|
781 |
+
|
782 |
+
/**
|
783 |
+
* Return is we use encryption.
|
784 |
+
*
|
785 |
+
* @return boolean
|
786 |
+
*/
|
787 |
+
public function useEncryption()
|
788 |
+
{
|
789 |
+
return $this->_useEncryption;
|
790 |
+
}
|
791 |
+
|
792 |
+
|
793 |
+
/**
|
794 |
+
* Return if the request should use hmac.
|
795 |
+
*
|
796 |
+
* @return boolean
|
797 |
+
*/
|
798 |
+
public function useHmac()
|
799 |
+
{
|
800 |
+
return $this->_useHmac;
|
801 |
+
}
|
802 |
+
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Return if the current request should be logged
|
806 |
+
*
|
807 |
+
* @return boolean
|
808 |
+
*/
|
809 |
+
public function logRequest()
|
810 |
+
{
|
811 |
+
return $this->_logRequest;
|
812 |
+
}
|
813 |
+
|
814 |
+
|
815 |
+
/**
|
816 |
+
* Return the computop converter.
|
817 |
+
*
|
818 |
+
* @return Dotsource_Computop_Helper_Converter
|
819 |
+
*/
|
820 |
+
protected function _getConverter()
|
821 |
+
{
|
822 |
+
return Mage::helper('computop/converter');
|
823 |
+
}
|
824 |
+
|
825 |
+
|
826 |
+
/**
|
827 |
+
* Return the computop helper.
|
828 |
+
*
|
829 |
+
* @return Dotsource_Computop_Helper_Data
|
830 |
+
*/
|
831 |
+
protected function _getHelper()
|
832 |
+
{
|
833 |
+
return Mage::helper('computop');
|
834 |
+
}
|
835 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Response/Giropay/Check.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Response_Giropay_Check
|
12 |
+
extends Dotsource_Computop_Model_Payment_Response_Response
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @see Dotsource_Computop_Model_Payment_Response_Response::hasError()
|
17 |
+
*
|
18 |
+
* @return boolean
|
19 |
+
*/
|
20 |
+
public function hasError()
|
21 |
+
{
|
22 |
+
if ($this->isResponseValid()) {
|
23 |
+
//check for a ban list
|
24 |
+
$list = $this->getResponse()->getData('accibanlist');
|
25 |
+
|
26 |
+
//Check for items
|
27 |
+
return empty($list);
|
28 |
+
}
|
29 |
+
|
30 |
+
return true;
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Dotsource/Computop/Model/Payment/Response/Response.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_Payment_Response_Response
|
12 |
+
extends Dotsource_Computop_Object
|
13 |
+
{
|
14 |
+
/** Holds the computop object */
|
15 |
+
protected $_responseObject = null;
|
16 |
+
|
17 |
+
/** Holds the user data object */
|
18 |
+
protected $_userDataObject = null;
|
19 |
+
|
20 |
+
/** Holds the response data as string */
|
21 |
+
protected $_responseString = null;
|
22 |
+
|
23 |
+
/** Holds the error status */
|
24 |
+
protected $_errorStatus = array('failed');
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Fill the data container from the current response object.
|
29 |
+
*
|
30 |
+
* @param string || array $response
|
31 |
+
* @param $encrypted boolean
|
32 |
+
* @return Dotsource_Computop_Model_Payment_Response_Response
|
33 |
+
*/
|
34 |
+
public function setResponse($response, $forcedEncryption = true)
|
35 |
+
{
|
36 |
+
//We need an array
|
37 |
+
if (is_string($response)) {
|
38 |
+
//Parse the data to an array
|
39 |
+
parse_str($response, $response);
|
40 |
+
}
|
41 |
+
|
42 |
+
//Set the keys to lower case
|
43 |
+
$response = array_change_key_case($response, CASE_LOWER);
|
44 |
+
|
45 |
+
//Check if we need
|
46 |
+
if (array_key_exists('data', $response)) {
|
47 |
+
$response = $this->getEncryptor()->decrypt($response['data']);
|
48 |
+
} elseif($forcedEncryption) {
|
49 |
+
Mage::throwException('Only encrypted response are allowed to pass.');
|
50 |
+
}
|
51 |
+
|
52 |
+
//Holds the response string
|
53 |
+
$this->_responseObject = new Dotsource_Computop_Object();
|
54 |
+
$this->getResponse()->setData($response);
|
55 |
+
|
56 |
+
//Reset the user data
|
57 |
+
$this->_userDataObject = null;
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Check if the response is well formed.
|
65 |
+
*
|
66 |
+
* @return boolean
|
67 |
+
*/
|
68 |
+
public function isResponseValid()
|
69 |
+
{
|
70 |
+
return $this->getResponse() instanceof Dotsource_Computop_Object
|
71 |
+
&& $this->getResponse()->hasData();
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Return true if the response as an error.
|
77 |
+
*
|
78 |
+
* @return boolean
|
79 |
+
*/
|
80 |
+
public function hasError()
|
81 |
+
{
|
82 |
+
if ($this->isResponseValid()) {
|
83 |
+
//Check status for an error state
|
84 |
+
$status = $this->getResponse()->getStatus();
|
85 |
+
|
86 |
+
//We need an non empty code and a non error status
|
87 |
+
if (empty($status) || in_array(strtolower($status), $this->_errorStatus)) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
|
91 |
+
//Check code
|
92 |
+
$code = $this->getResponse()->getCode();
|
93 |
+
|
94 |
+
//The only good code is 0
|
95 |
+
//check for numeric and if the code is numeric check for zero
|
96 |
+
return !(is_numeric($code) && intval($code) == 0);
|
97 |
+
}
|
98 |
+
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Indicates if the response is pending.
|
105 |
+
*
|
106 |
+
* @return boolean
|
107 |
+
*/
|
108 |
+
public function isPending()
|
109 |
+
{
|
110 |
+
if (!$this->hasError()) {
|
111 |
+
$status = $this->getResponse()->getStatus();
|
112 |
+
return 'pending' === strtolower($status);
|
113 |
+
}
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Indicates if the response is ok.
|
120 |
+
*
|
121 |
+
* @return boolean
|
122 |
+
*/
|
123 |
+
public function isOk()
|
124 |
+
{
|
125 |
+
if (!$this->hasError()) {
|
126 |
+
$status = $this->getResponse()->getStatus();
|
127 |
+
return 'ok' === strtolower($status);
|
128 |
+
}
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Return the response from the current object.
|
135 |
+
*
|
136 |
+
* @return Dotsource_Computop_Object
|
137 |
+
*/
|
138 |
+
public function getResponse()
|
139 |
+
{
|
140 |
+
return $this->_responseObject;
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Return the user data object.
|
146 |
+
*
|
147 |
+
* @return Dotsource_Computop_Object || null
|
148 |
+
*/
|
149 |
+
public function getUserData()
|
150 |
+
{
|
151 |
+
//already created
|
152 |
+
if (null === $this->_userDataObject) {
|
153 |
+
$this->_userDataObject = new Dotsource_Computop_Object();
|
154 |
+
|
155 |
+
//check if we have some user data to parse
|
156 |
+
if (!$this->getResponse()->isDataEmpty('userdata')) {
|
157 |
+
$this->_userDataObject->setData(base64_decode($this->getResponse()->getData('userdata')));
|
158 |
+
}
|
159 |
+
|
160 |
+
//Set the user data in the response
|
161 |
+
$this->getResponse()->setData('userdata', $this->_userDataObject);
|
162 |
+
}
|
163 |
+
|
164 |
+
return $this->_userDataObject;
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Return true if the request has user data.
|
170 |
+
*
|
171 |
+
* @return boolean
|
172 |
+
*/
|
173 |
+
public function hasUserData()
|
174 |
+
{
|
175 |
+
return $this->getUserData()->isEmpty();
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @see Dotsource_Computop_Object::toString()
|
181 |
+
*
|
182 |
+
* @param string $noNeed
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function toString($noNeed = null)
|
186 |
+
{
|
187 |
+
//If we have an response object we return the string from the request object
|
188 |
+
if ($this->isResponseValid()) {
|
189 |
+
return $this->getResponse()->toString();
|
190 |
+
}
|
191 |
+
|
192 |
+
return "";
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Return the computop helper.
|
198 |
+
*
|
199 |
+
* @return Dotsource_Computop_Helper_Data
|
200 |
+
*/
|
201 |
+
protected function _getHelper()
|
202 |
+
{
|
203 |
+
return Mage::helper('computop');
|
204 |
+
}
|
205 |
+
}
|
app/code/community/Dotsource/Computop/Model/Rewrite/Sales/Order/Payment.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Rewrite_Sales_Order_Payment
|
11 |
+
extends Mage_Sales_Model_Order_Payment
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Mage_Sales_Model_Order_Payment::cancel()
|
16 |
+
*
|
17 |
+
* @return Mage_Sales_Model_Order_Payment
|
18 |
+
*/
|
19 |
+
public function cancel()
|
20 |
+
{
|
21 |
+
//We need a other logic for cancel processing
|
22 |
+
if (!$this->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
23 |
+
parent::cancel();
|
24 |
+
} else if ($this->getMethodInstance()->canVoid(new Varien_Object())) {
|
25 |
+
$this->_void(true);
|
26 |
+
Mage::dispatchEvent('sales_order_payment_void', array('payment' => $this, 'invoice' => new Varien_Object()));
|
27 |
+
} else {
|
28 |
+
//Call the cancel method
|
29 |
+
$this->getMethodInstance()->cancel($this);
|
30 |
+
Mage::dispatchEvent('sales_order_payment_cancel', array('payment' => $this));
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @see Mage_Sales_Model_Order_Payment::canCapture()
|
39 |
+
*
|
40 |
+
* @return unknown
|
41 |
+
*/
|
42 |
+
public function canCapture()
|
43 |
+
{
|
44 |
+
//We need a other logic for cancel processing
|
45 |
+
if (!$this->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
46 |
+
return parent::canCapture();
|
47 |
+
}
|
48 |
+
|
49 |
+
return $this->getMethodInstance()->canCapture();
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @see Mage_Sales_Model_Order_Payment::canVoid()
|
55 |
+
*
|
56 |
+
* @param Varien_Object $document
|
57 |
+
* @return bool
|
58 |
+
*/
|
59 |
+
public function canVoid(Varien_Object $document)
|
60 |
+
{
|
61 |
+
//We need a other logic for cancel processing
|
62 |
+
if (!$this->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
63 |
+
return parent::canVoid($document);
|
64 |
+
}
|
65 |
+
|
66 |
+
return $this->getMethodInstance()->canVoid($document);
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Don't append transaction information to the order comment.
|
72 |
+
*
|
73 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction|null $transaction
|
74 |
+
* @param string $message
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
protected function _appendTransactionToMessage($transaction, $message)
|
78 |
+
{
|
79 |
+
//Call the default logic for non computop payment
|
80 |
+
if (!$this->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
|
81 |
+
return parent::_appendTransactionToMessage($transaction, $message);
|
82 |
+
}
|
83 |
+
|
84 |
+
return $message;
|
85 |
+
}
|
86 |
+
}
|
app/code/community/Dotsource/Computop/Model/Session.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Session
|
11 |
+
extends Mage_Core_Model_Session_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds the computop transaction model */
|
15 |
+
protected $_transactionModel = null;
|
16 |
+
|
17 |
+
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
$this->init('computop');
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Clear the computop transaction model.
|
26 |
+
*/
|
27 |
+
public function clearSession()
|
28 |
+
{
|
29 |
+
$this->_transactionModel = null;
|
30 |
+
$this->unsTransactionModelId();
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Return a new computop transaction model or an already used
|
36 |
+
* transaction model in the current checkout session.
|
37 |
+
*
|
38 |
+
* @return Dotsource_Computop_Model_Transaction
|
39 |
+
*/
|
40 |
+
public function getTransactionModel()
|
41 |
+
{
|
42 |
+
//Already restored?
|
43 |
+
if (empty($this->_transactionModel)) {
|
44 |
+
//Get the computop transaction model id from the current session
|
45 |
+
$modelId = $this->getTransactionModelId();
|
46 |
+
|
47 |
+
/* @var $transactionModel Dotsource_Computop_Model_Transaction */
|
48 |
+
$transactionModel = null;
|
49 |
+
|
50 |
+
//Load the old one or create a new one
|
51 |
+
if (!empty($modelId)) {
|
52 |
+
//Restore the transaction model
|
53 |
+
$transactionModel = Mage::getModel('computop/transaction')->load($modelId);
|
54 |
+
|
55 |
+
//Validate the transaction model
|
56 |
+
if (empty($transactionModel) || !$transactionModel->hasId()) {
|
57 |
+
$this->clearSession();
|
58 |
+
|
59 |
+
if ($this->_getHelper()->isDemoMode()) {
|
60 |
+
Mage::throwException("Can't restore old transaction model from session. Please try again.");
|
61 |
+
} else {
|
62 |
+
return $this->getTransactionModel();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
} else {
|
66 |
+
$transactionModel = Mage::getModel('computop/transaction');
|
67 |
+
}
|
68 |
+
|
69 |
+
//Set the transaction model id for new created model
|
70 |
+
if (empty($modelId) && $transactionModel->hasId()) {
|
71 |
+
$this->setTransactionModelId($transactionModel->getId());
|
72 |
+
}
|
73 |
+
|
74 |
+
//Store the transaction model in the session
|
75 |
+
$this->_transactionModel = $transactionModel;
|
76 |
+
}
|
77 |
+
|
78 |
+
return $this->_transactionModel;
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Return the computop helper.
|
84 |
+
*
|
85 |
+
* @return Dotsource_Computop_Helper_Data
|
86 |
+
*/
|
87 |
+
protected function _getHelper()
|
88 |
+
{
|
89 |
+
return Mage::helper('computop');
|
90 |
+
}
|
91 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Backend/Orderdesc.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ssl - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Backend_Orderdesc
|
12 |
+
extends Mage_Core_Model_Config_Data
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_blacklistChars = array(
|
16 |
+
'"', "'", '+', '*', '#', '=', '&', '?', '%', '>', '<', '|', '~', '“'
|
17 |
+
);
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @see Mage_Core_Model_Config_Data::_beforeSave()
|
21 |
+
*/
|
22 |
+
protected function _beforeSave()
|
23 |
+
{
|
24 |
+
//Get the data
|
25 |
+
$value = $this->getValue();
|
26 |
+
|
27 |
+
//replace blacklist chars
|
28 |
+
$value = str_replace($this->_blacklistChars, '', $value);
|
29 |
+
|
30 |
+
//Set the value again
|
31 |
+
$this->setValue($value);
|
32 |
+
|
33 |
+
//Call the parents
|
34 |
+
parent::_beforeSave();
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Backend/Serialized/Merchant.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Backend_Serialized_Merchant
|
12 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* @see Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array::_beforeSave()
|
16 |
+
*/
|
17 |
+
protected function _beforeSave()
|
18 |
+
{
|
19 |
+
//Get the data
|
20 |
+
$value = $this->getValue();
|
21 |
+
|
22 |
+
//Check if we have data
|
23 |
+
if (!empty($value) && is_array($value)) {
|
24 |
+
foreach ($value as &$row) {
|
25 |
+
//Check if we have data and have all fields
|
26 |
+
if (empty($row)) {
|
27 |
+
continue;
|
28 |
+
}
|
29 |
+
|
30 |
+
//Check if we need to encrypt the password
|
31 |
+
if (!array_key_exists('original_password', $row)
|
32 |
+
|| $row['password'] != $row['original_password']
|
33 |
+
) {
|
34 |
+
$row['password'] = Mage::helper('core')->encrypt($row['password']);
|
35 |
+
$row['original_password'] = $row['password'];
|
36 |
+
}
|
37 |
+
|
38 |
+
//Check if we need to encrypt the hmac
|
39 |
+
if (!array_key_exists('original_hmac', $row)
|
40 |
+
|| $row['hmac'] != $row['original_hmac']
|
41 |
+
) {
|
42 |
+
$row['hmac'] = Mage::helper('core')->encrypt($row['hmac']);
|
43 |
+
$row['original_hmac'] = $row['hmac'];
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
//Set the value again
|
49 |
+
$this->setValue($value);
|
50 |
+
|
51 |
+
//Call the parents
|
52 |
+
parent::_beforeSave();
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Abstract.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 10:36:18
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
abstract class Dotsource_Computop_Model_System_Config_Source_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Retrieves the computop helper.
|
19 |
+
*
|
20 |
+
* @return Dotsource_Computop_Helper_Data
|
21 |
+
*/
|
22 |
+
protected function _getHelper()
|
23 |
+
{
|
24 |
+
return Mage::helper('computop');
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedcountriesAction.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
const ALLOW_ALL_COUNTRIES = 1;
|
16 |
+
|
17 |
+
const ALLOW_ANY_COUNTRIES = 2;
|
18 |
+
|
19 |
+
const RESTRICT_ANY_COUNTRIES = 3;
|
20 |
+
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
array( //(alles erlauben)
|
25 |
+
'value' => self::ALLOW_ALL_COUNTRIES,
|
26 |
+
'label' => $this->_getHelper()->__('Allow all countries')
|
27 |
+
),
|
28 |
+
array( //(Laender zulassen)
|
29 |
+
'value' => self::ALLOW_ANY_COUNTRIES,
|
30 |
+
'label' => $this->_getHelper()->__('Allow any countries')
|
31 |
+
),
|
32 |
+
array( //(Laender verbieten)
|
33 |
+
'value' => self::RESTRICT_ANY_COUNTRIES,
|
34 |
+
'label' => $this->_getHelper()->__('Restrict any countries')
|
35 |
+
)
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedipzonesAction.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
const ALLOW_ALL_ZONES = 1;
|
16 |
+
|
17 |
+
const ALLOW_ANY_ZONES = 2;
|
18 |
+
|
19 |
+
const RESTRICT_ANY_ZONES = 3;
|
20 |
+
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
array( //(alle IP Zonen erlauben)
|
25 |
+
'value' => self::ALLOW_ALL_ZONES,
|
26 |
+
'label' => $this->_getHelper()->__('Allow all ip zones')
|
27 |
+
),
|
28 |
+
array( //(IP Zonen zulassen)
|
29 |
+
'value' => self::ALLOW_ANY_ZONES,
|
30 |
+
'label' => $this->_getHelper()->__('Allow specific ip zones')
|
31 |
+
),
|
32 |
+
array( //(IP Zonen verbieten)
|
33 |
+
'value' => self::RESTRICT_ANY_ZONES,
|
34 |
+
'label' => $this->_getHelper()->__('Restrict specific ip zones')
|
35 |
+
)
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Baseurl.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_Baseurl
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
/** Const for default */
|
15 |
+
const NETKAUF = 'https://netkauf.de/paygate/';
|
16 |
+
|
17 |
+
/** const for alternative */
|
18 |
+
const COMPUTOP = 'https://www.computop-paygate.com/';
|
19 |
+
|
20 |
+
public function toOptionArray()
|
21 |
+
{
|
22 |
+
return array(
|
23 |
+
array( //(default)
|
24 |
+
'value' => self::NETKAUF,
|
25 |
+
'label' => $this->_getHelper()->__(self::NETKAUF)
|
26 |
+
),
|
27 |
+
array( //(altenativ)
|
28 |
+
'value' => self::COMPUTOP,
|
29 |
+
'label' => $this->_getHelper()->__(self::COMPUTOP)
|
30 |
+
)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Countryiso3.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_Countryiso3
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Retrieves the options array for alle known countries.
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
$collection = Mage::getResourceModel('directory/country_collection')
|
22 |
+
->loadData();
|
23 |
+
|
24 |
+
$sort = array();
|
25 |
+
foreach ($collection as $countryModel) {
|
26 |
+
$name = Mage::app()->getLocale()->getCountryTranslation($countryModel->getCountryId());
|
27 |
+
if ($name) {
|
28 |
+
$sort[$name] = $countryModel->getIso3Code();
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
ksort($sort, SORT_STRING);
|
33 |
+
|
34 |
+
$options = array();
|
35 |
+
foreach ($sort as $label => $value) {
|
36 |
+
$options[] = array(
|
37 |
+
'value' => $value,
|
38 |
+
'label' => $label
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
return $options;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Logos.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ssl - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_Logos
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
const MASTERCARD = 'computop_mastercard.png';
|
16 |
+
const MASTERCARD_SECURE_CODE = 'computop_mastercard_secure_code.png';
|
17 |
+
const VISA = 'computop_visa.png';
|
18 |
+
const VERIFIED_BY_VISA = 'computop_verified_by_visa.png';
|
19 |
+
const AMERICAN_EXPRESS = 'computop_american_express.png';
|
20 |
+
const DANKORT = 'computop_dankort.png';
|
21 |
+
const MAESTRO = 'computop_maestro.png';
|
22 |
+
const CARTE_BLEUE_NATIONALE = 'computop_cartebleue.png';
|
23 |
+
const JCB = 'computop_jcb.png';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Retrieves the options array for all computop
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function toOptionArray()
|
31 |
+
{
|
32 |
+
|
33 |
+
return array(
|
34 |
+
array(
|
35 |
+
'file' => self::MASTERCARD,
|
36 |
+
'label' => $this->_getHelper()->__('Mastercard'),
|
37 |
+
'value' => 'mastercard',
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'file' => self::MASTERCARD_SECURE_CODE,
|
41 |
+
'label' => $this->_getHelper()->__('Mastercard Secure Code'),
|
42 |
+
'value' => 'mastercard_secure_code',
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'file' => self::VISA,
|
46 |
+
'label' => $this->_getHelper()->__('VISA'),
|
47 |
+
'value' => 'visa',
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'file' => self::VERIFIED_BY_VISA,
|
51 |
+
'label' => $this->_getHelper()->__('Verified by VISA'),
|
52 |
+
'value' => 'verified_by_visa',
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'file' => self::AMERICAN_EXPRESS,
|
56 |
+
'label' => $this->_getHelper()->__('American Express'),
|
57 |
+
'value' => 'american_express',
|
58 |
+
),
|
59 |
+
array(
|
60 |
+
'file' => self::DANKORT,
|
61 |
+
'label' => $this->_getHelper()->__('Dankort'),
|
62 |
+
'value' => 'dankort',
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'file' => self::MAESTRO,
|
66 |
+
'label' => $this->_getHelper()->__('Maestro'),
|
67 |
+
'value' => 'maestro',
|
68 |
+
),
|
69 |
+
array(
|
70 |
+
'file' => self::CARTE_BLEUE_NATIONALE,
|
71 |
+
'label' => $this->_getHelper()->__('Carte Bleue Nationale'),
|
72 |
+
'value' => 'carte_bleue_nationale',
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'file' => self::JCB,
|
76 |
+
'label' => $this->_getHelper()->__('JCB'),
|
77 |
+
'value' => 'jcb',
|
78 |
+
),
|
79 |
+
);
|
80 |
+
}
|
81 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Modus.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_Modus
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Const for live modus */
|
16 |
+
const LIVE = 'live';
|
17 |
+
|
18 |
+
/** Const for demo modus */
|
19 |
+
const DEMO = 'demo';
|
20 |
+
|
21 |
+
|
22 |
+
public function toOptionArray()
|
23 |
+
{
|
24 |
+
return array(
|
25 |
+
array(
|
26 |
+
'value' => self::LIVE,
|
27 |
+
'label' => $this->_getHelper()->__('Live')
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'value' => self::DEMO,
|
31 |
+
'label' => $this->_getHelper()->__('Demo')
|
32 |
+
),
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Paymentaction.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Dotsource_Computop_Model_System_Config_Source_Paymentaction
|
12 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
/** Const for auth mode */
|
16 |
+
const AUTHORIZE = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
17 |
+
|
18 |
+
/** const for booking mode */
|
19 |
+
const BOOKING = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
20 |
+
|
21 |
+
/** const for booking mode */
|
22 |
+
const TIMEDBOOKING = 'timebooking_authorize_capture';
|
23 |
+
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
return array(
|
27 |
+
array( //(manuell)
|
28 |
+
'value' => self::AUTHORIZE,
|
29 |
+
'label' => $this->_getHelper()->__('Debit on Delivery')
|
30 |
+
),
|
31 |
+
array( //(auto)
|
32 |
+
'value' => self::BOOKING,
|
33 |
+
'label' => $this->_getHelper()->__('Immediate payment')
|
34 |
+
),
|
35 |
+
array( //("Zahl")
|
36 |
+
'value' => self::TIMEDBOOKING,
|
37 |
+
'label' => $this->_getHelper()->__('Debit in x hours')
|
38 |
+
)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Paypalpaymentaction.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 25.05.2010 12:28:47
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_System_Config_Source_Paypalpaymentaction
|
15 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
/** Const for auth mode */
|
19 |
+
const AUTHORIZE = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
20 |
+
|
21 |
+
/** const for booking mode */
|
22 |
+
const BOOKING = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
23 |
+
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
return array(
|
27 |
+
array( //(manuell)
|
28 |
+
'value' => self::AUTHORIZE,
|
29 |
+
'label' => $this->_getHelper()->__('Debit on Delivery')
|
30 |
+
),
|
31 |
+
array( //(auto)
|
32 |
+
'value' => self::BOOKING,
|
33 |
+
'label' => $this->_getHelper()->__('Immediate payment')
|
34 |
+
),
|
35 |
+
);
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Dotsource/Computop/Model/System/Config/Source/Txtype.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 28.04.2010 11:00:58
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Model_System_Config_Source_Txtype
|
15 |
+
extends Dotsource_Computop_Model_System_Config_Source_Abstract
|
16 |
+
{
|
17 |
+
|
18 |
+
const ORDER = 'Order';
|
19 |
+
const AUTH = 'Auth';
|
20 |
+
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
array(
|
25 |
+
'value' => self::ORDER,
|
26 |
+
'label' => $this->_getHelper()->__('Order')
|
27 |
+
),
|
28 |
+
array(
|
29 |
+
'value' => self::AUTH,
|
30 |
+
'label' => $this->_getHelper()->__('Authorization')
|
31 |
+
)
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Dotsource/Computop/Model/Transaction.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Model_Transaction
|
11 |
+
extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('computop/transaction');
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @see Varien_Object::hasDataChanges()
|
23 |
+
* Need to fix magento bug:
|
24 |
+
* http://www.magentocommerce.com/bug-tracking/issue?issue=9506
|
25 |
+
*
|
26 |
+
* @return bool
|
27 |
+
*/
|
28 |
+
public function hasDataChanges()
|
29 |
+
{
|
30 |
+
return true;
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Return the reference code and save the model if need.
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getTransactionCode()
|
40 |
+
{
|
41 |
+
//Check if the current model is already saved
|
42 |
+
if (!$this->hasId()) {
|
43 |
+
$this->save();
|
44 |
+
}
|
45 |
+
|
46 |
+
//The transaction code as zero filled id
|
47 |
+
return $this->_getHelper()->getConverter()->formatAsTransactionCode(
|
48 |
+
$this->getId()
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Return the id as int.
|
55 |
+
*
|
56 |
+
* @return int
|
57 |
+
*/
|
58 |
+
public function getId()
|
59 |
+
{
|
60 |
+
//Get the current id
|
61 |
+
$id = parent::getId();
|
62 |
+
|
63 |
+
//If we have an id cast to int
|
64 |
+
if (null !== $id) {
|
65 |
+
$id = (int)$id;
|
66 |
+
}
|
67 |
+
|
68 |
+
return $id;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Check if the current model has an id.
|
74 |
+
*
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
public function hasId()
|
78 |
+
{
|
79 |
+
$id = $this->getIdFieldName();
|
80 |
+
|
81 |
+
//check if field id name is setup
|
82 |
+
if (empty($id)) {
|
83 |
+
return $this->hasData('id');
|
84 |
+
} else {
|
85 |
+
return $this->hasData($id);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Return the computop helper.
|
92 |
+
*
|
93 |
+
* @return Dotsource_Computop_Helper_Data
|
94 |
+
*/
|
95 |
+
protected function _getHelper()
|
96 |
+
{
|
97 |
+
return Mage::helper('computop');
|
98 |
+
}
|
99 |
+
}
|
app/code/community/Dotsource/Computop/Object.php
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
class Dotsource_Computop_Object
|
11 |
+
extends Varien_Object
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Holds is the data getting encrypted */
|
15 |
+
protected $_encryption = false;
|
16 |
+
|
17 |
+
/** Holds the encryption settings */
|
18 |
+
protected $_encryptionSettings = array();
|
19 |
+
|
20 |
+
/** Holds the encryption model */
|
21 |
+
protected $_encryptionModel = null;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Check if id field is setup in the data array.
|
26 |
+
* If id field name is setup the id fields name is used.
|
27 |
+
*
|
28 |
+
* @return unknown
|
29 |
+
*/
|
30 |
+
public function hasId()
|
31 |
+
{
|
32 |
+
$id = $this->getIdFieldName();
|
33 |
+
|
34 |
+
//check if field id name is setup
|
35 |
+
if (empty($id)) {
|
36 |
+
return $this->hasData('id');
|
37 |
+
} else {
|
38 |
+
return $this->hasData($id);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return true if the value from the given key is empty.
|
45 |
+
*
|
46 |
+
* @param string || null $key
|
47 |
+
* @return boolean
|
48 |
+
*/
|
49 |
+
public function isDataEmpty($key = null)
|
50 |
+
{
|
51 |
+
if (is_null($key)) {
|
52 |
+
return $this->isEmpty();
|
53 |
+
}
|
54 |
+
|
55 |
+
//Get the value from the key
|
56 |
+
$data = $this->getData($key);
|
57 |
+
|
58 |
+
//Return the result
|
59 |
+
return empty($data);
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Set/Get attribute wrapper
|
65 |
+
*
|
66 |
+
* @param string $method
|
67 |
+
* @param array $args
|
68 |
+
* @return mixed
|
69 |
+
*/
|
70 |
+
public function __call($method, $args)
|
71 |
+
{
|
72 |
+
try {
|
73 |
+
return parent::__call($method, $args);
|
74 |
+
} catch(Exception $e) {
|
75 |
+
switch (substr($method, 0, 5)) {
|
76 |
+
case 'empty' :
|
77 |
+
$key = $this->_underscore(substr($method, 5));
|
78 |
+
return isset($this->_data[$key]) && empty($this->_data[$key]);
|
79 |
+
}
|
80 |
+
|
81 |
+
//throw the old exception
|
82 |
+
throw $e;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @see Varien_Object::toString()
|
89 |
+
*
|
90 |
+
* @param string $noNeed
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function toString($noNeed = null)
|
94 |
+
{
|
95 |
+
//Get the string
|
96 |
+
$data = $this->_getString();
|
97 |
+
|
98 |
+
//Encrypt the data
|
99 |
+
if ($this->getEncryption()) {
|
100 |
+
$data = $this->getEncryptor()->encrypt($data);
|
101 |
+
}
|
102 |
+
|
103 |
+
return $data;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Return the length of the given string in the container.
|
109 |
+
*
|
110 |
+
* @return int
|
111 |
+
*/
|
112 |
+
public function getStringLength()
|
113 |
+
{
|
114 |
+
return strlen($this->_getString());
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Applies charset convertion to the entries of parents::toArray() method.
|
120 |
+
*
|
121 |
+
* @param array $arrAttributes
|
122 |
+
* @return array
|
123 |
+
*/
|
124 |
+
public function toArray(array $arrAttributes = array())
|
125 |
+
{
|
126 |
+
$data = parent::toArray($arrAttributes);
|
127 |
+
$outData = array();
|
128 |
+
foreach ($data as $key => $value) {
|
129 |
+
if (is_string($key) && !is_array($value) && !is_object($value)) {
|
130 |
+
$key = $this->_getHelper()->getConverter()->convertToLatin($key);
|
131 |
+
$value = $this->_getHelper()->getConverter()->convertToLatin($value);
|
132 |
+
$outData[$key] = $value;
|
133 |
+
} else {
|
134 |
+
//Put alos the array or object values in the array
|
135 |
+
$outData[$key] = $value;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
return $outData;
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Return the string of the data container.
|
144 |
+
*
|
145 |
+
* @return string
|
146 |
+
*/
|
147 |
+
protected function _getString()
|
148 |
+
{
|
149 |
+
$data = array();
|
150 |
+
|
151 |
+
foreach ($this->toArray() as $key => $value) {
|
152 |
+
if (is_string($key) && !is_array($value) && !is_object($value)) {
|
153 |
+
$data[] = "$key=$value";
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
//Return as string
|
158 |
+
return implode('&', $data);
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @see Varien_Object::setData()
|
164 |
+
*
|
165 |
+
* @param string|array $key
|
166 |
+
* @param mixed $value
|
167 |
+
* @return Varien_Object
|
168 |
+
*/
|
169 |
+
public function setData($key, $value = null)
|
170 |
+
{
|
171 |
+
if (!empty($key) && is_string($key) && is_null($value)) {
|
172 |
+
$responseArray = array();
|
173 |
+
$convertArray = array();
|
174 |
+
|
175 |
+
//Parse the data to an array
|
176 |
+
parse_str($key, $responseArray);
|
177 |
+
|
178 |
+
//Change the keys to lower case
|
179 |
+
$responseArray = array_change_key_case($responseArray, CASE_LOWER);
|
180 |
+
|
181 |
+
//Convert to uft8
|
182 |
+
foreach ($responseArray as $key => $value) {
|
183 |
+
$key = $this->_getConverter()->convertToUtf8($key);
|
184 |
+
$value = $this->_getConverter()->convertToUtf8($value);
|
185 |
+
|
186 |
+
$convertArray[$key] = $value;
|
187 |
+
}
|
188 |
+
|
189 |
+
//Convert the keys to lower case
|
190 |
+
array_change_key_case($convertArray, CASE_LOWER);
|
191 |
+
|
192 |
+
//Set the value for parent processing
|
193 |
+
$key = $convertArray;
|
194 |
+
}
|
195 |
+
|
196 |
+
//Do the parent stuff
|
197 |
+
return parent::setData($key, $value);
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Return the value who is saved under the given key or the default value
|
203 |
+
* will returned is the key not exists.
|
204 |
+
*
|
205 |
+
* @param string $key
|
206 |
+
* @param mixed $default
|
207 |
+
* @return mixed
|
208 |
+
*/
|
209 |
+
public function getDataOrDefault($key, $default)
|
210 |
+
{
|
211 |
+
//Check if the key exists
|
212 |
+
if ($this->hasData($key)) {
|
213 |
+
return $this->getData($key);
|
214 |
+
}
|
215 |
+
|
216 |
+
return $default;
|
217 |
+
}
|
218 |
+
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Turn the encryption mode on or off.
|
222 |
+
*
|
223 |
+
* @param boolean $_encryption
|
224 |
+
* @return Dotsource_Computop_Object
|
225 |
+
*/
|
226 |
+
public function setEncryption($encryption)
|
227 |
+
{
|
228 |
+
$this->_encryption = $encryption;
|
229 |
+
return $this;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Return if the data need to encrypt.
|
235 |
+
*
|
236 |
+
* @return boolean
|
237 |
+
*/
|
238 |
+
public function getEncryption()
|
239 |
+
{
|
240 |
+
return $this->_encryption;
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Set the already exist encryption model.
|
246 |
+
*
|
247 |
+
* @param Dotsource_Computop_Model_Encryption $encryptionModel
|
248 |
+
* @return Varien_Object
|
249 |
+
*/
|
250 |
+
public function setEncryptor(Dotsource_Computop_Model_Encryption $encryptorModel)
|
251 |
+
{
|
252 |
+
$this->_encryptionModel = $encryptorModel;
|
253 |
+
return $this;
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Return the encryption model.
|
259 |
+
*
|
260 |
+
* @return Dotsource_Computop_Model_Encryption
|
261 |
+
*/
|
262 |
+
public function getEncryptor()
|
263 |
+
{
|
264 |
+
if (!$this->hasEncryptor()) {
|
265 |
+
//Create the new encryption model
|
266 |
+
$this->_encryptionModel = Mage::getModel(
|
267 |
+
'computop/encryption',
|
268 |
+
$this->getEncryptionSettings()
|
269 |
+
);
|
270 |
+
}
|
271 |
+
|
272 |
+
return $this->_encryptionModel;
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Return true if an encryption model is available.
|
278 |
+
*
|
279 |
+
* @return boolean
|
280 |
+
*/
|
281 |
+
public function hasEncryptor()
|
282 |
+
{
|
283 |
+
return null !== $this->_encryptionModel;
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Set the encryption model settings. You can only set the settings
|
289 |
+
* if the encryption model not exists.
|
290 |
+
*
|
291 |
+
* @param array $settings
|
292 |
+
* @return Dotsource_Computop_Object
|
293 |
+
*/
|
294 |
+
public function setEncryptionSettings(array $settings)
|
295 |
+
{
|
296 |
+
//Settings only available if no encryption model exists
|
297 |
+
if ($this->hasEncryptor()) {
|
298 |
+
Mage::throwException('You can\'t change the encryption settings the encryption model already exist. ');
|
299 |
+
}
|
300 |
+
|
301 |
+
//Set the settings
|
302 |
+
$this->_encryptionSettings = $settings;
|
303 |
+
return $this;
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Return the encryption settings.
|
309 |
+
*
|
310 |
+
* @return array
|
311 |
+
*/
|
312 |
+
public function getEncryptionSettings()
|
313 |
+
{
|
314 |
+
return $this->_encryptionSettings;
|
315 |
+
}
|
316 |
+
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Return true if encryption settings are available.
|
320 |
+
*
|
321 |
+
* @return boolean
|
322 |
+
*/
|
323 |
+
public function hasEncryptionSettings()
|
324 |
+
{
|
325 |
+
return !empty($this->_encryptionSettings);
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Return the computop converter.
|
331 |
+
*
|
332 |
+
* @return Dotsource_Computop_Helper_Converter
|
333 |
+
*/
|
334 |
+
protected function _getConverter()
|
335 |
+
{
|
336 |
+
return Mage::helper('computop/converter');
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Return the computop helper.
|
342 |
+
*
|
343 |
+
* @return Dotsource_Computop_Helper_Data
|
344 |
+
*/
|
345 |
+
protected function _getHelper()
|
346 |
+
{
|
347 |
+
return Mage::helper('computop');
|
348 |
+
}
|
349 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Adminhtml/ActionController.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 05.05.2010 15:37:47
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Adminhtml_ActionController
|
15 |
+
extends Mage_Adminhtml_Controller_Action
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initialize order model instance.
|
20 |
+
* @see Mage_Adminhtml_Sales_OrderController::_initOrder();
|
21 |
+
*
|
22 |
+
* @return Mage_Sales_Model_Order || false
|
23 |
+
*/
|
24 |
+
protected function _initOrder()
|
25 |
+
{
|
26 |
+
$id = $this->getRequest()->getParam('order_id');
|
27 |
+
$order = Mage::getModel('sales/order')->load($id);
|
28 |
+
|
29 |
+
if (!$order->getId()) {
|
30 |
+
$this->_getSession()->addError($this->__('This order no longer exists.'));
|
31 |
+
$this->_redirect('*/*/');
|
32 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
Mage::register('sales_order', $order);
|
36 |
+
Mage::register('current_order', $order);
|
37 |
+
return $order;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* This action causes the generation of the action grid in the sales view.
|
42 |
+
*
|
43 |
+
* @return null
|
44 |
+
*/
|
45 |
+
public function gridAction()
|
46 |
+
{
|
47 |
+
$this->_initOrder();
|
48 |
+
$this->getResponse()->setBody(
|
49 |
+
$this->getLayout()->createBlock('computop/adminhtml_sales_order_view_tab_action')->toHtml()
|
50 |
+
);
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Adminhtml/MassactionController.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php';
|
11 |
+
class Dotsource_Computop_Adminhtml_MassactionController
|
12 |
+
extends Mage_Adminhtml_Sales_Order_InvoiceController
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->setUsedModuleName('Dotsource_Computop');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Create for every order a invoice.
|
23 |
+
*/
|
24 |
+
public function massInvoiceAction()
|
25 |
+
{
|
26 |
+
$this->_processInvoiceMassActions(false);
|
27 |
+
$this->_redirect('adminhtml/sales_order/index');
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
public function massInvoiceShipmentAction()
|
32 |
+
{
|
33 |
+
$this->_processInvoiceMassActions(true);
|
34 |
+
$this->_redirect('adminhtml/sales_order/index');
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Process the invoice creation.
|
40 |
+
*
|
41 |
+
* @param boolean $createShipment
|
42 |
+
*/
|
43 |
+
protected function _processInvoiceMassActions($createShipment)
|
44 |
+
{
|
45 |
+
$orderIds = $this->getRequest()->getPost('order_ids', array());
|
46 |
+
$notice = array();
|
47 |
+
$success = array();
|
48 |
+
$error = array();
|
49 |
+
|
50 |
+
//Filter order ids
|
51 |
+
if (!empty($orderIds) && is_array($orderIds)) {
|
52 |
+
/* @var $collection Mage_Sales_Model_Mysql4_Order_Collection */
|
53 |
+
$collection = Mage::getResourceModel('sales/order_collection');
|
54 |
+
|
55 |
+
//Reset the default cols
|
56 |
+
$collection->getSelect()
|
57 |
+
->reset(Zend_Db_Select::COLUMNS)
|
58 |
+
->columns($collection->getResource()->getIdFieldName())
|
59 |
+
->where("{$collection->getResource()->getIdFieldName()} IN (?)", $orderIds)
|
60 |
+
->where("status = ?", Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE);
|
61 |
+
|
62 |
+
//Get the order ids
|
63 |
+
$orderIds = $collection->getConnection()->fetchCol($collection->getSelect());
|
64 |
+
}
|
65 |
+
|
66 |
+
foreach ($orderIds as $orderId) {
|
67 |
+
/* @var $order Mage_Sales_Model_Order */
|
68 |
+
$order = null;
|
69 |
+
|
70 |
+
/* @var $invoices Mage_Sales_Model_Mysql4_Order_Invoice_Collection */
|
71 |
+
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
|
72 |
+
->addAttributeToSelect('*')
|
73 |
+
->setOrderFilter($orderId);
|
74 |
+
|
75 |
+
//Get the invoice size
|
76 |
+
$invoiceSize = $invoices->getSize();
|
77 |
+
|
78 |
+
//Only create invoice if we have no invoices
|
79 |
+
if ($invoiceSize > 0) {
|
80 |
+
//Get the order for the increment id
|
81 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
82 |
+
|
83 |
+
//Add to the notice
|
84 |
+
$notice[] = $this->_getComputopHelper()->__(
|
85 |
+
'The order #%s has already %s invoice(s).',
|
86 |
+
$order->getIncrementId(),
|
87 |
+
$invoiceSize
|
88 |
+
);
|
89 |
+
} else {
|
90 |
+
try {
|
91 |
+
//Manipulate the params for the invoice actions
|
92 |
+
Mage::unregister('current_invoice');
|
93 |
+
$this->getRequest()->setParam('order_id', $orderId);
|
94 |
+
|
95 |
+
//Create the invoice
|
96 |
+
$invoice = $this->_initInvoice(false);
|
97 |
+
|
98 |
+
//We need a good value here
|
99 |
+
if (!$invoice) {
|
100 |
+
//Get the order for the increment id
|
101 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
102 |
+
|
103 |
+
//Create error message for the current order
|
104 |
+
$error[] = $this->_getComputopHelper()->__(
|
105 |
+
"Can't create invoice for order #%s.",
|
106 |
+
$order->getIncrementId()
|
107 |
+
);
|
108 |
+
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
|
112 |
+
//Get the order from the invoice
|
113 |
+
$order = $invoice->getOrder();
|
114 |
+
|
115 |
+
$order->setCustomerNoteNotify(0);
|
116 |
+
$order->setIsInProcess(true);
|
117 |
+
|
118 |
+
//Check for computop payment
|
119 |
+
if (!$order->getPayment()->getMethodInstance()
|
120 |
+
instanceof Dotsource_Computop_Model_Payment_Abstract
|
121 |
+
) {
|
122 |
+
//Create error message for the current order
|
123 |
+
$error[] = $this->_getComputopHelper()->__(
|
124 |
+
"The order #%s was not paid with a computop payment and can't invoiced.",
|
125 |
+
$order->getIncrementId()
|
126 |
+
);
|
127 |
+
|
128 |
+
continue;
|
129 |
+
} else if (!$order->getPayment()->canCapture()) {
|
130 |
+
//Create error message for the current order
|
131 |
+
$error[] = $this->_getComputopHelper()->__(
|
132 |
+
"The order #%s can't capture.",
|
133 |
+
$order->getIncrementId()
|
134 |
+
);
|
135 |
+
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
|
139 |
+
//Computop paid orders are always captured online
|
140 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
141 |
+
$invoice->register();
|
142 |
+
|
143 |
+
//Save the invoice
|
144 |
+
$order->addRelatedObject($invoice);
|
145 |
+
|
146 |
+
//Create the shipment if we need
|
147 |
+
if ($createShipment || (int) $order->getForcedDoShipmentWithInvoice()) {
|
148 |
+
//Create the shipment
|
149 |
+
$shipment = $this->_prepareShipment($invoice);
|
150 |
+
|
151 |
+
//We need a good value
|
152 |
+
if ($shipment) {
|
153 |
+
$order->addRelatedObject($shipment);
|
154 |
+
} else {
|
155 |
+
//Create error message for the current order
|
156 |
+
$error[] = $this->_getComputopHelper()->__(
|
157 |
+
"Can't create shipment for order #%s.",
|
158 |
+
$order->getIncrementId()
|
159 |
+
);
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
//Save the order with the related products
|
164 |
+
$order->save();
|
165 |
+
|
166 |
+
//Get the right message
|
167 |
+
$message = "";
|
168 |
+
if ($createShipment && $shipment) {
|
169 |
+
$message = "Successfully create invoice and shipment for order #%s in amount of %s.";
|
170 |
+
} else {
|
171 |
+
$message = "Successfully create invoice for order #%s in amount of %s.";
|
172 |
+
}
|
173 |
+
|
174 |
+
//Add success message
|
175 |
+
$success[] = $this->_getComputopHelper()->__(
|
176 |
+
$message,
|
177 |
+
$order->getIncrementId(),
|
178 |
+
$order->getBaseCurrency()->formatPrecision($invoice->getBaseGrandTotal(), 2, array(), false)
|
179 |
+
);
|
180 |
+
} catch (Exception $e) {
|
181 |
+
//Get the order for the increment id
|
182 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
183 |
+
$message = "";
|
184 |
+
|
185 |
+
//Get the right message
|
186 |
+
if ($createShipment) {
|
187 |
+
$message = "Can't create invoice and shipment for order #%s. (%s)";
|
188 |
+
} else {
|
189 |
+
$message = "Can't create invoice for order #%s. (%s)";
|
190 |
+
}
|
191 |
+
|
192 |
+
//Create error message for the current order
|
193 |
+
$error[] = $this->_getComputopHelper()->__(
|
194 |
+
$message,
|
195 |
+
$order->getIncrementId(),
|
196 |
+
$e->getMessage()
|
197 |
+
);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
//No need to show the messages from the
|
203 |
+
$this->_getSession()->getMessages(true);
|
204 |
+
|
205 |
+
//There is was nothing to do
|
206 |
+
if (empty($notice) && empty($success) && empty($error)) {
|
207 |
+
$this->_getSession()->addNotice(
|
208 |
+
$this->_getComputopHelper()->__(
|
209 |
+
'No orders selected with the status "%s".',
|
210 |
+
Mage::getSingleton('sales/order_config')->getStatusLabel(Dotsource_Computop_Model_Payment_Abstract::READY_FOR_CAPTURE)
|
211 |
+
)
|
212 |
+
);
|
213 |
+
} else {
|
214 |
+
if (!empty($notice)) {
|
215 |
+
$this->_getSession()->addNotice(implode('<br/>', $notice));
|
216 |
+
}
|
217 |
+
|
218 |
+
if (!empty($success)) {
|
219 |
+
$this->_getSession()->addSuccess(implode('<br/>', $success));
|
220 |
+
}
|
221 |
+
|
222 |
+
if (!empty($error)) {
|
223 |
+
$this->_getSession()->addError(implode('<br/>', $error));
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Return the computop helper.
|
231 |
+
*
|
232 |
+
* @return Dotsource_Computop_Helper_Data
|
233 |
+
*/
|
234 |
+
protected function _getComputopHelper()
|
235 |
+
{
|
236 |
+
return Mage::helper('computop');
|
237 |
+
}
|
238 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/CcController.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Callback_CcController
|
11 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
12 |
+
{
|
13 |
+
|
14 |
+
/** Enable javascript redirect for breaking out the iframe */
|
15 |
+
protected $_javaScriptRedirect = true;
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
protected function _getPaymentCode()
|
24 |
+
{
|
25 |
+
return 'computop_cc';
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_notifySuccessProcessing()
|
31 |
+
*
|
32 |
+
* @param Dotsource_Computop_Model_Payment_Response_Response $response
|
33 |
+
*/
|
34 |
+
protected function _notifySuccessProcessing(Dotsource_Computop_Model_Payment_Response_Response $response)
|
35 |
+
{
|
36 |
+
//Do the parent stuff first
|
37 |
+
parent::_notifySuccessProcessing($response);
|
38 |
+
|
39 |
+
/* @var $order Mage_Sales_Model_Order */
|
40 |
+
$order = Mage::registry('computop_notify_order');
|
41 |
+
$payment = $order->getPayment();
|
42 |
+
|
43 |
+
//Check for storing pseudo data
|
44 |
+
if ('1' != $payment->getMethodInstance()->getConfigData('use_pseudo_data', $order->getStoreId())) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
//Try to store pseudo cc data
|
49 |
+
if (!$response->getResponse()->emptyPcnr()) {
|
50 |
+
$payment
|
51 |
+
->setCcNumberEnc(
|
52 |
+
Mage::helper('core')->getEncryptor()->encrypt(
|
53 |
+
$response->getResponse()->getPcnr()
|
54 |
+
)
|
55 |
+
)
|
56 |
+
->setCcLast4(substr($response->getResponse()->getPcnr(), -3))
|
57 |
+
->setCcExpYear(substr($response->getResponse()->getCcexpiry(), 0, 4))
|
58 |
+
->setCcExpMonth(substr($response->getResponse()->getCcexpiry(), -2))
|
59 |
+
->setCcType($response->getResponse()->getCcbrand());
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/DirectpayController.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Callback_DirectpayController
|
11 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getPaymentCode()
|
20 |
+
{
|
21 |
+
return 'computop_directpay';
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/GiropayController.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Callback_GiropayController
|
11 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getPaymentCode()
|
20 |
+
{
|
21 |
+
return 'computop_giropay';
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/IdealController.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_Callback_IdealController
|
11 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getPaymentCode()
|
20 |
+
{
|
21 |
+
return 'computop_ideal';
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/MpassController.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 30.04.2010 17:10:23
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Callback_MpassController
|
15 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
protected function _getPaymentCode()
|
24 |
+
{
|
25 |
+
return 'computop_mpass';
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/PaypalController.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 28.04.2010 14:40:18
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Callback_PaypalController
|
15 |
+
extends Dotsource_Computop_Controller_Computopcallback
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retreives the code for the paymentmethod.
|
20 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
protected function _getPaymentCode()
|
25 |
+
{
|
26 |
+
return 'computop_paypal_standard';
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Dotsource/Computop/controllers/Callback/PaypalexpressController.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 18.05.2010 16:48:28
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Computop_Callback_PaypalexpressController
|
15 |
+
extends Dotsource_Computop_Controller_Expresscallback
|
16 |
+
{
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retreives the code for the paymentmethod.
|
20 |
+
* @see Dotsource_Computop_Controller_Computopcallback::_getPaymentCode()
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
protected function _getPaymentCode()
|
25 |
+
{
|
26 |
+
return 'computop_paypal_express';
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Startaction for the paypal express checkout.
|
32 |
+
*
|
33 |
+
* @return null
|
34 |
+
*/
|
35 |
+
public function startAction()
|
36 |
+
{
|
37 |
+
try {
|
38 |
+
$quote = $this->_getHelper()->getFrontendQuote();
|
39 |
+
|
40 |
+
if ($quote && !$quote->hasItems()) {
|
41 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
42 |
+
throw new Dotsource_Computop_Model_Exception(
|
43 |
+
Mage::helper('computop')->__('Unable to initialize Express Checkout')
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
//Set the payment in quote the quote will automatically saved
|
48 |
+
Mage::getSingleton('checkout/type_onepage')->savePayment(
|
49 |
+
array('method' => $this->_getPaymentCode())
|
50 |
+
);
|
51 |
+
|
52 |
+
//Reload the quote to get the right save handling
|
53 |
+
$quote = Mage::getModel('sales/quote')->load($quote->getId());
|
54 |
+
|
55 |
+
//Reserve an order increment id
|
56 |
+
$quote->reserveOrderId();
|
57 |
+
|
58 |
+
$url = $quote->getPayment()->getMethodInstance()->getRequestUrl(
|
59 |
+
$quote->getPayment(),
|
60 |
+
$quote->getBaseGrandTotal()
|
61 |
+
);
|
62 |
+
|
63 |
+
//Save payment
|
64 |
+
$quote->getPayment()->save();
|
65 |
+
|
66 |
+
//Save quote to persist the computop_transaction_id
|
67 |
+
$quote->save();
|
68 |
+
|
69 |
+
$this->getResponse()->setRedirect($url);
|
70 |
+
return;
|
71 |
+
} catch (Mage_Core_Exception $e) {
|
72 |
+
$this->_getHelper()->getCheckoutSession()->addError($e->getMessage());
|
73 |
+
} catch (Exception $e) {
|
74 |
+
$this->_getHelper()->getCheckoutSession()->addError($this->__('Unable to start Express Checkout.'));
|
75 |
+
Mage::logException($e);
|
76 |
+
}
|
77 |
+
|
78 |
+
$this->_redirect('checkout/cart');
|
79 |
+
}
|
80 |
+
}
|
app/code/community/Dotsource/Computop/controllers/IframeController.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_IframeController
|
11 |
+
extends Dotsource_Computop_Controller_Callback
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Show the iframe in the checkout process.
|
16 |
+
*/
|
17 |
+
public function showAction()
|
18 |
+
{
|
19 |
+
if ($this->hasIframeUrl()) {
|
20 |
+
//load the layout
|
21 |
+
$this->loadLayout();
|
22 |
+
|
23 |
+
//Get the block and set the iframe url
|
24 |
+
$this->getLayout()
|
25 |
+
->getBlock('checkout_iframe')
|
26 |
+
->setIframeUrl($this->getIframeUrl())
|
27 |
+
->setIframeTitle($this->getIframeTitle());
|
28 |
+
|
29 |
+
$this->renderLayout();
|
30 |
+
} else {
|
31 |
+
$this->_noIframeUrlError();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Check if we have a iframe url (source).
|
38 |
+
*
|
39 |
+
* @return boolean
|
40 |
+
*/
|
41 |
+
protected function hasIframeUrl()
|
42 |
+
{
|
43 |
+
//Get the current iframe source url.
|
44 |
+
$url = $this->getIframeUrl();
|
45 |
+
|
46 |
+
//check for non empty string
|
47 |
+
return !empty($url) && is_string($url);
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Check if we have a iframe title.
|
53 |
+
*
|
54 |
+
* @return boolean
|
55 |
+
*/
|
56 |
+
protected function hasIframeTitle()
|
57 |
+
{
|
58 |
+
//Get the current iframe source url.
|
59 |
+
$title = $this->getIframeTitle();
|
60 |
+
|
61 |
+
//check for non empty string
|
62 |
+
return !empty($title) && is_string($title);
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Return the iframe url.
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
protected function getIframeUrl()
|
72 |
+
{
|
73 |
+
return $this->_getHelper()
|
74 |
+
->getCheckoutSession(Dotsource_Computop_Helper_Data::FRONTEND)
|
75 |
+
->getIframeUrl();
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Return the iframe title.
|
81 |
+
*
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
protected function getIframeTitle()
|
85 |
+
{
|
86 |
+
$title = $this->_getHelper()
|
87 |
+
->getCheckoutSession(Dotsource_Computop_Helper_Data::FRONTEND)
|
88 |
+
->getIframeTitle();
|
89 |
+
|
90 |
+
//Check for an title
|
91 |
+
if (!empty($title)) {
|
92 |
+
return $title;
|
93 |
+
}
|
94 |
+
|
95 |
+
return $this->_getHelper()->__('Payment Gateway');
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Holds the error message if no iframe url is available.
|
101 |
+
*/
|
102 |
+
protected function _noIframeUrlError()
|
103 |
+
{
|
104 |
+
//Build the message
|
105 |
+
$msg = 'The iframe url to the computop paygate is missing. '.
|
106 |
+
'Please try again to pay or choose another payment method.';
|
107 |
+
|
108 |
+
//Add a error message
|
109 |
+
$this->_getHelper()->getCheckoutSession()->addError(
|
110 |
+
$this->_getHelper()->__($msg)
|
111 |
+
);
|
112 |
+
|
113 |
+
//Redirect to cart to show the error message
|
114 |
+
$this->_redirect('checkout/cart/');
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Return the computop helper.
|
120 |
+
*
|
121 |
+
* @return Dotsource_Computop_Helper_Data
|
122 |
+
*/
|
123 |
+
protected function _getHelper()
|
124 |
+
{
|
125 |
+
return Mage::helper('computop');
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Dotsource/Computop/controllers/IndexController.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
class Dotsource_Computop_IndexController
|
11 |
+
extends Mage_Core_Controller_Front_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
// public function indexAction()
|
15 |
+
// {
|
16 |
+
//
|
17 |
+
// }
|
18 |
+
|
19 |
+
|
20 |
+
// /**
|
21 |
+
// * Imports the error list from csv to xml.
|
22 |
+
// */
|
23 |
+
// public function importerrorsAction()
|
24 |
+
// {
|
25 |
+
// /* @var $error Dotsource_Computop_Model_Error_Handler_Message */
|
26 |
+
// $error = Mage::getModel('computop/error_handler_message');
|
27 |
+
// $csv = new Varien_File_Csv();
|
28 |
+
//
|
29 |
+
// $csv->setLineLength(16384)
|
30 |
+
// ->setDelimiter(';');
|
31 |
+
//
|
32 |
+
// $data = $csv->getDataPairs(Mage::getConfig()->getModuleDir(null, 'Dotsource_Computop').DS.'errorcodes.csv', 0 , 2);
|
33 |
+
//
|
34 |
+
// $xml = new XMLWriter();
|
35 |
+
// $xml->openMemory();
|
36 |
+
// $xml->setIndent(true);
|
37 |
+
// $xml->setIndentString(' ');
|
38 |
+
// $xml->startElement('backend');
|
39 |
+
//
|
40 |
+
// $xmlErrors = new XMLWriter();
|
41 |
+
// $xmlErrors->openMemory();
|
42 |
+
// $xmlErrors->setIndent(true);
|
43 |
+
// $xmlErrors->setIndentString(' ');
|
44 |
+
// $xmlErrors->startElement('backend');
|
45 |
+
// $xmlErrors->startElement('error');
|
46 |
+
// $xmlErrors->startAttribute('code');
|
47 |
+
//
|
48 |
+
// foreach ($data as $code => $errormsg) {
|
49 |
+
// $xmlErrors->text($error->prepareCode($code)." ");
|
50 |
+
//
|
51 |
+
// $xml->startElement('error');
|
52 |
+
// $xml->writeAttribute('code', $error->prepareCode($code));
|
53 |
+
// $xml->text($errormsg);
|
54 |
+
// $xml->endElement();
|
55 |
+
// }
|
56 |
+
//
|
57 |
+
// $xmlErrors->endAttribute();
|
58 |
+
// $xml->endElement();
|
59 |
+
//
|
60 |
+
// echo '<pre>';
|
61 |
+
// echo str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $xml->outputMemory());
|
62 |
+
// echo '</br></br></br>';
|
63 |
+
// echo str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $xmlErrors->outputMemory());
|
64 |
+
// echo '</pre>';
|
65 |
+
// }
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Return the computop helper.
|
70 |
+
*
|
71 |
+
* @return Dotsource_Computop_Helper_Data
|
72 |
+
*/
|
73 |
+
protected function _getHelper()
|
74 |
+
{
|
75 |
+
return Mage::helper('computop');
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Dotsource/Computop/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<computop_account translate="title" module="computop">
|
12 |
+
<title translate="label">Computop Account Section</title>
|
13 |
+
<sort_order>701</sort_order>
|
14 |
+
</computop_account>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/Dotsource/Computop/etc/config.xml
ADDED
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Dotsource_Computop>
|
5 |
+
<version>1.4.1.1.5</version>
|
6 |
+
</Dotsource_Computop>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<fieldsets>
|
10 |
+
<sales_convert_quote_payment>
|
11 |
+
<computop_transaction_id><to_order_payment>*</to_order_payment></computop_transaction_id>
|
12 |
+
<eft_owner><to_order_payment>*</to_order_payment></eft_owner>
|
13 |
+
<eft_ban_enc><to_order_payment>*</to_order_payment></eft_ban_enc>
|
14 |
+
<eft_ban4><to_order_payment>*</to_order_payment></eft_ban4>
|
15 |
+
<eft_bcn><to_order_payment>*</to_order_payment></eft_bcn>
|
16 |
+
</sales_convert_quote_payment>
|
17 |
+
<sales_convert_order_payment>
|
18 |
+
<computop_transaction_id><to_quote_payment>*</to_quote_payment></computop_transaction_id>
|
19 |
+
<eft_owner><to_quote_payment>*</to_quote_payment></eft_owner>
|
20 |
+
<eft_ban_enc><to_quote_payment>*</to_quote_payment></eft_ban_enc>
|
21 |
+
<eft_ban4><to_quote_payment>*</to_quote_payment></eft_ban4>
|
22 |
+
<eft_bcn><to_quote_payment>*</to_quote_payment></eft_bcn>
|
23 |
+
</sales_convert_order_payment>
|
24 |
+
</fieldsets>
|
25 |
+
<models>
|
26 |
+
<computop>
|
27 |
+
<class>Dotsource_Computop_Model</class>
|
28 |
+
<resourceModel>computop_mysql4</resourceModel>
|
29 |
+
</computop>
|
30 |
+
<computop_mysql4>
|
31 |
+
<class>Dotsource_Computop_Model_Mysql4</class>
|
32 |
+
<entities>
|
33 |
+
<action>
|
34 |
+
<table>computop_action</table>
|
35 |
+
</action>
|
36 |
+
<transaction>
|
37 |
+
<table>computop_transaction</table>
|
38 |
+
</transaction>
|
39 |
+
</entities>
|
40 |
+
</computop_mysql4>
|
41 |
+
<sales>
|
42 |
+
<rewrite>
|
43 |
+
<order_payment>Dotsource_Computop_Model_Rewrite_Sales_Order_Payment</order_payment>
|
44 |
+
</rewrite>
|
45 |
+
</sales>
|
46 |
+
</models>
|
47 |
+
<helpers>
|
48 |
+
<computop>
|
49 |
+
<class>Dotsource_Computop_Helper</class>
|
50 |
+
</computop>
|
51 |
+
</helpers>
|
52 |
+
<blocks>
|
53 |
+
<computop>
|
54 |
+
<class>Dotsource_Computop_Block</class>
|
55 |
+
</computop>
|
56 |
+
<adminhtml>
|
57 |
+
<rewrite>
|
58 |
+
<sales_order_view>Dotsource_Computop_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
59 |
+
<sales_order_grid>Dotsource_Computop_Block_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
|
60 |
+
</rewrite>
|
61 |
+
</adminhtml>
|
62 |
+
</blocks>
|
63 |
+
<resources>
|
64 |
+
<computop_setup>
|
65 |
+
<setup>
|
66 |
+
<module>Dotsource_Computop</module>
|
67 |
+
<class>Dotsource_Computop_Model_Mysql4_Setup</class>
|
68 |
+
</setup>
|
69 |
+
<connection>
|
70 |
+
<use>core_setup</use>
|
71 |
+
</connection>
|
72 |
+
</computop_setup>
|
73 |
+
<computop_write>
|
74 |
+
<connection>
|
75 |
+
<use>core_write</use>
|
76 |
+
</connection>
|
77 |
+
</computop_write>
|
78 |
+
<computop_read>
|
79 |
+
<connection>
|
80 |
+
<use>core_read</use>
|
81 |
+
</connection>
|
82 |
+
</computop_read>
|
83 |
+
</resources>
|
84 |
+
<sales>
|
85 |
+
<order>
|
86 |
+
<statuses>
|
87 |
+
<waiting_capture_computop_note translate="label"><label>Waiting For Capture Notification</label></waiting_capture_computop_note>
|
88 |
+
<waiting_auth_computop_note translate="label"><label>Waiting For Authorization Notification</label></waiting_auth_computop_note>
|
89 |
+
<ready_computop_capture translate="label"><label>Ready For Computop Capture Action</label></ready_computop_capture>
|
90 |
+
</statuses>
|
91 |
+
</order>
|
92 |
+
</sales>
|
93 |
+
<events>
|
94 |
+
<sales_order_resource_init_virtual_grid_columns>
|
95 |
+
<observers>
|
96 |
+
<check_for_online_refund>
|
97 |
+
<class>computop/observer</class>
|
98 |
+
<method>onSalesOrderResourceInitVirtualGridColumns</method>
|
99 |
+
</check_for_online_refund>
|
100 |
+
</observers>
|
101 |
+
</sales_order_resource_init_virtual_grid_columns>
|
102 |
+
<sales_order_creditmemo_refund>
|
103 |
+
<observers>
|
104 |
+
<check_for_online_refund>
|
105 |
+
<class>computop/observer</class>
|
106 |
+
<method>onSalesOrderCreditmemoRefund</method>
|
107 |
+
</check_for_online_refund>
|
108 |
+
</observers>
|
109 |
+
</sales_order_creditmemo_refund>
|
110 |
+
<sales_order_invoice_pay>
|
111 |
+
<observers>
|
112 |
+
<check_for_online_invoice>
|
113 |
+
<class>computop/observer</class>
|
114 |
+
<method>onSalesOrderInvoicePay</method>
|
115 |
+
</check_for_online_invoice>
|
116 |
+
</observers>
|
117 |
+
</sales_order_invoice_pay>
|
118 |
+
<adminhtml_block_html_before>
|
119 |
+
<observers>
|
120 |
+
<computop_adminhtml_block_html_before_massaction>
|
121 |
+
<class>computop/observer</class>
|
122 |
+
<method>onAdminhtmlBlockHtmlBefore</method>
|
123 |
+
</computop_adminhtml_block_html_before_massaction>
|
124 |
+
</observers>
|
125 |
+
</adminhtml_block_html_before>
|
126 |
+
<controller_action_predispatch_checkout_cart_index>
|
127 |
+
<observers>
|
128 |
+
<controller_action_predispatch_checkout_cart_index_recreate_computop_transaction>
|
129 |
+
<class>computop/observer</class>
|
130 |
+
<method>deleteComputopTransaction</method>
|
131 |
+
</controller_action_predispatch_checkout_cart_index_recreate_computop_transaction>
|
132 |
+
</observers>
|
133 |
+
</controller_action_predispatch_checkout_cart_index>
|
134 |
+
<controller_action_predispatch_checkout_onepage_index>
|
135 |
+
<observers>
|
136 |
+
<controller_action_predispatch_checkout_onepage_index_recreate_computop_transaction>
|
137 |
+
<class>computop/observer</class>
|
138 |
+
<method>deleteComputopTransaction</method>
|
139 |
+
</controller_action_predispatch_checkout_onepage_index_recreate_computop_transaction>
|
140 |
+
</observers>
|
141 |
+
</controller_action_predispatch_checkout_onepage_index>
|
142 |
+
</events>
|
143 |
+
</global>
|
144 |
+
<frontend>
|
145 |
+
<translate>
|
146 |
+
<modules>
|
147 |
+
<Dotsource_Computop>
|
148 |
+
<files>
|
149 |
+
<default>Dotsource_Computop.csv</default>
|
150 |
+
</files>
|
151 |
+
</Dotsource_Computop>
|
152 |
+
</modules>
|
153 |
+
</translate>
|
154 |
+
<secure_url>
|
155 |
+
<computop_callback>/computop/callback</computop_callback>
|
156 |
+
</secure_url>
|
157 |
+
<routers>
|
158 |
+
<computop>
|
159 |
+
<use>standard</use>
|
160 |
+
<args>
|
161 |
+
<module>Dotsource_Computop</module>
|
162 |
+
<frontName>computop</frontName>
|
163 |
+
</args>
|
164 |
+
</computop>
|
165 |
+
</routers>
|
166 |
+
<layout>
|
167 |
+
<updates>
|
168 |
+
<computop>
|
169 |
+
<file>computop.xml</file>
|
170 |
+
</computop>
|
171 |
+
</updates>
|
172 |
+
</layout>
|
173 |
+
<events>
|
174 |
+
<checkout_quote_destroy>
|
175 |
+
<observers>
|
176 |
+
<computop_clear_transaction_session>
|
177 |
+
<type>singleton</type>
|
178 |
+
<class>computop/session</class>
|
179 |
+
<method>clearSession</method>
|
180 |
+
</computop_clear_transaction_session>
|
181 |
+
<computop_clear_payment_deactivation>
|
182 |
+
<type>singleton</type>
|
183 |
+
<class>computop/observer</class>
|
184 |
+
<method>clearPaymentDeactivation</method>
|
185 |
+
</computop_clear_payment_deactivation>
|
186 |
+
</observers>
|
187 |
+
</checkout_quote_destroy>
|
188 |
+
</events>
|
189 |
+
</frontend>
|
190 |
+
<admin>
|
191 |
+
<routers>
|
192 |
+
<computop>
|
193 |
+
<use>standard</use>
|
194 |
+
<args>
|
195 |
+
<module>Dotsource_Computop</module>
|
196 |
+
<frontName>computop</frontName>
|
197 |
+
</args>
|
198 |
+
</computop>
|
199 |
+
</routers>
|
200 |
+
</admin>
|
201 |
+
<adminhtml>
|
202 |
+
<layout>
|
203 |
+
<updates>
|
204 |
+
<computop>
|
205 |
+
<file>computop.xml</file>
|
206 |
+
</computop>
|
207 |
+
</updates>
|
208 |
+
</layout>
|
209 |
+
<translate>
|
210 |
+
<modules>
|
211 |
+
<Dotsource_Computop>
|
212 |
+
<files>
|
213 |
+
<default>Dotsource_Computop.csv</default>
|
214 |
+
</files>
|
215 |
+
</Dotsource_Computop>
|
216 |
+
</modules>
|
217 |
+
</translate>
|
218 |
+
</adminhtml>
|
219 |
+
<default>
|
220 |
+
<payment>
|
221 |
+
<computop_cc>
|
222 |
+
<model>computop/payment_cc</model>
|
223 |
+
<active>0</active>
|
224 |
+
<title>Computop Credit Card</title>
|
225 |
+
<etm_active>0</etm_active>
|
226 |
+
<use_pseudo_data>0</use_pseudo_data>
|
227 |
+
<allowspecific>0</allowspecific>
|
228 |
+
<specificcountry></specificcountry>
|
229 |
+
<allowedcountries>allowAllCountries</allowedcountries>
|
230 |
+
<payment_action>authorize</payment_action>
|
231 |
+
<use_template>0</use_template>
|
232 |
+
<logos>mastercard,visa</logos>
|
233 |
+
</computop_cc>
|
234 |
+
<computop_eft>
|
235 |
+
<model>computop/payment_eft</model>
|
236 |
+
<active>0</active>
|
237 |
+
<title>Computop Direct Debit</title>
|
238 |
+
<allowspecific>1</allowspecific>
|
239 |
+
<specificcountry>DE</specificcountry>
|
240 |
+
<payment_action>authorize</payment_action>
|
241 |
+
</computop_eft>
|
242 |
+
<computop_giropay>
|
243 |
+
<model>computop/payment_giropay</model>
|
244 |
+
<active>0</active>
|
245 |
+
<title>Computop giropay</title>
|
246 |
+
<bcn_check>1</bcn_check>
|
247 |
+
<prefill_paymentinformation>1</prefill_paymentinformation>
|
248 |
+
<allowspecific>1</allowspecific>
|
249 |
+
<specificcountry>DE</specificcountry>
|
250 |
+
<payment_action>authorize</payment_action>
|
251 |
+
</computop_giropay>
|
252 |
+
<computop_ideal>
|
253 |
+
<model>computop/payment_ideal</model>
|
254 |
+
<active>0</active>
|
255 |
+
<title>Computop iDeal</title>
|
256 |
+
<prefill_paymentinformation>0</prefill_paymentinformation>
|
257 |
+
<allowspecific>1</allowspecific>
|
258 |
+
<specificcountry>NL</specificcountry>
|
259 |
+
<payment_action>authorize</payment_action>
|
260 |
+
</computop_ideal>
|
261 |
+
<computop_directpay>
|
262 |
+
<model>computop/payment_directpay</model>
|
263 |
+
<active>0</active>
|
264 |
+
<title>Computop Direct Transfer</title>
|
265 |
+
<prefill_paymentinformation>1</prefill_paymentinformation>
|
266 |
+
<allowspecific>1</allowspecific>
|
267 |
+
<specificcountry>DE,AT,CH,BE,NL,GB</specificcountry>
|
268 |
+
<payment_action>authorize</payment_action>
|
269 |
+
</computop_directpay>
|
270 |
+
<computop_mpass>
|
271 |
+
<model>computop/payment_mpass</model>
|
272 |
+
<active>0</active>
|
273 |
+
<title>Computop mpass</title>
|
274 |
+
<allowspecific>1</allowspecific>
|
275 |
+
<specificcountry>DE</specificcountry>
|
276 |
+
<payment_action_computop>authorize</payment_action_computop>
|
277 |
+
<payment_action>authorize</payment_action>
|
278 |
+
</computop_mpass>
|
279 |
+
<computop_paypal_standard>
|
280 |
+
<model>computop/payment_paypalstandard</model>
|
281 |
+
<active>0</active>
|
282 |
+
<title>Computop PayPal</title>
|
283 |
+
<payment_action_computop>authorize</payment_action_computop>
|
284 |
+
<payment_action_txtype>Order</payment_action_txtype>
|
285 |
+
<payment_action>authorize</payment_action>
|
286 |
+
</computop_paypal_standard>
|
287 |
+
<computop_paypal_express>
|
288 |
+
<model>computop/payment_paypalexpress</model>
|
289 |
+
<active>0</active>
|
290 |
+
<title>Computop PayPal Express</title>
|
291 |
+
<visible_on_cart>0</visible_on_cart>
|
292 |
+
<payment_action_computop>authorize</payment_action_computop>
|
293 |
+
<payment_action_txtype>Order</payment_action_txtype>
|
294 |
+
<payment_action>authorize</payment_action>
|
295 |
+
</computop_paypal_express>
|
296 |
+
</payment>
|
297 |
+
<computop_account>
|
298 |
+
<default>
|
299 |
+
<baseurl>https://netkauf.de/paygate/</baseurl>
|
300 |
+
</default>
|
301 |
+
</computop_account>
|
302 |
+
</default>
|
303 |
+
</config>
|
app/code/community/Dotsource/Computop/etc/errors.xml
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<errorhandling>
|
3 |
+
<frontend>
|
4 |
+
<error code="0053" />
|
5 |
+
<error code="0023">Please check your account owner.</error>
|
6 |
+
<error callback="computop/error_observer::checkoutPaymentRedirect" code="0500 0501 0502">Please check your bank account number and bank code number.</error>
|
7 |
+
<error callback="computop/error_observer::destroyQuote" code="0073 0105 0111 0161 0162 0163 0164 0165 0190 0191 0192 0200 0331 0703"></error>
|
8 |
+
<error callback="computop/error_observer::clearQuotePayment" code="0094 0100 0102 0103 0110 0120 0302 0304 0305 0313 0314 0333 0334 0343 0351 0356 0359 0362 0385 0105 0190 0191 0192 0200 0703">The current used credit card can not use for the checkout. Please use another credit card or another payment method.</error>
|
9 |
+
<error callback="computop/error_observer::disablePaymentMethod" code="fallback-error-msg">Your are not allowed to use the current payment method. Please use another payment method.</error>
|
10 |
+
</frontend>
|
11 |
+
<backend>
|
12 |
+
<error code="0000">Nicht spezifizierbares Problem, das manuell analysiert werden muss.</error>
|
13 |
+
<error code="0001">Der Parameter PayID verursacht das Problem.</error>
|
14 |
+
<error code="0002">Der Parameter TransID verursacht das Problem.</error>
|
15 |
+
<error code="0003">Der Parameter MerchantID verursacht das Problem.</error>
|
16 |
+
<error code="0004">Der Parameter ReqID verursacht das Problem.</error>
|
17 |
+
<error code="0005">Der Parameter Amount verursacht das Problem.</error>
|
18 |
+
<error code="0006">Der Parameter Currency verursacht das Problem.</error>
|
19 |
+
<error code="0007">Der Parameter Data verursacht das Problem.</error>
|
20 |
+
<error code="0008">Der Parameter Len verursacht das Problem.</error>
|
21 |
+
<error code="0009">Der Parameter Capture verursacht das Problem.</error>
|
22 |
+
<error code="0010">Der Parameter Response verursacht das Problem.</error>
|
23 |
+
<error code="0011">Der Parameter OrderDesc verursacht das Problem.</error>
|
24 |
+
<error code="0012">Der Parameter OrderDesc2 verursacht das Problem.</error>
|
25 |
+
<error code="0013">Der Parameter UserData verursacht das Problem.</error>
|
26 |
+
<error code="0014">Der Parameter UserData verursacht das Problem.</error>
|
27 |
+
<error code="0015">Der Parameter CCNr verursacht das Problem.</error>
|
28 |
+
<error code="0016">Der Parameter CCNr verursacht das Problem.</error>
|
29 |
+
<error code="0017">Der Parameter CCExpiry verursacht das Problem.</error>
|
30 |
+
<error code="0018">Der Parameter CCBrand verursacht das Problem.</error>
|
31 |
+
<error code="0019">Der Parameter CCCVC verursacht das Problem.</error>
|
32 |
+
<error code="0020">Der Parameter URLSuccess verursacht das Problem.</error>
|
33 |
+
<error code="0021">Der Parameter URLFailure verursacht das Problem.</error>
|
34 |
+
<error code="0022">Der Parameter URLNotify verursacht das Problem.</error>
|
35 |
+
<error code="0023">Der Parameter AccOwner verursacht das Problem.</error>
|
36 |
+
<error code="0024">Der Parameter AccNr verursacht das Problem.</error>
|
37 |
+
<error code="0025">Der Parameter AccBank verursacht das Problem.</error>
|
38 |
+
<error code="0026">Der Parameter AccIBAN verursacht das Problem.</error>
|
39 |
+
<error code="0027">Der Parameter AccIBANList verursacht das Problem.</error>
|
40 |
+
<error code="0028">Der Parameter PARes verursacht das Problem.</error>
|
41 |
+
<error code="0029">Der Parameter MobileNo verursacht das Problem.</error>
|
42 |
+
<error code="0030">Der Parameter MobileNet verursacht das Problem.</error>
|
43 |
+
<error code="0031">Der Parameter Status verursacht das Problem.</error>
|
44 |
+
<error code="0032">Der Parameter RefNr verusacht das Problem.</error>
|
45 |
+
<error code="0033">Der Parameter Zone verursacht das Problem.</error>
|
46 |
+
<error code="0034">Der Parameter TransURL verursacht das Problem.</error>
|
47 |
+
<error code="0035">Der Parameter Textfeld1 verursacht das Problem (OTF).</error>
|
48 |
+
<error code="0036">Der Parameter Textfeld2 verursacht das Problem (OTF).</error>
|
49 |
+
<error code="003D">Die IP-Adresse ist ungültig.</error>
|
50 |
+
<error code="0040">Nachgelagerte Systeme reagieren nicht z.B. im Bankrechenzentrum.</error>
|
51 |
+
<error code="040A">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
52 |
+
<error code="040B">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
53 |
+
<error code="0045">berlastung des Kassensystems.</error>
|
54 |
+
<error code="0046">Es ist keine weitere TerminalID für die Transaktion verfügbar.</error>
|
55 |
+
<error code="0047">Die notwendige TerminalID fehlt.</error>
|
56 |
+
<error code="0048">Die Vertragsunternehmensnummer des Akzeptanzvertrages fehlt.</error>
|
57 |
+
<error code="0050">Das Paygate oder nachgelagerte Server meldet einen Systemfehler.</error>
|
58 |
+
<error code="0051">Transaktionsfehler durch eine Zeitüberschreitung.</error>
|
59 |
+
<error code="0052">Störung durch einen Kommunikationsfehler.</error>
|
60 |
+
<error code="0053">Abbruch durch den Benutzer.</error>
|
61 |
+
<error code="0054">Die Stornierung einer Transaktion verursacht ein Problem.</error>
|
62 |
+
<error code="0055">Unbekannte Fehlerursache, die manuell analysiert werden muss.</error>
|
63 |
+
<error code="0056">Das individuell vereinbarte Timeout wurde überschritten (NVAG)</error>
|
64 |
+
<error code="0060">Der Transaktionstyp ist in der Konfiguration derzeit nicht aktiviert.</error>
|
65 |
+
<error code="0061">Die Zahlung wird aufgrund einer falschen PayID nicht gefunden.</error>
|
66 |
+
<error code="0062">Eine andere Transaktion (z.B. Buchung) behindert die Verarbeitung.</error>
|
67 |
+
<error code="0063">Die Transaktion ist nicht zulässig.</error>
|
68 |
+
<error code="0068">Die Verified- oder SecureCode-Zahlung wurde schon autorisiert.</error>
|
69 |
+
<error code="0069">Die Gutschrift ist gescheitert, da keine Buchung voran gegangen ist</error>
|
70 |
+
<error code="0070">Keine Buchung, weil der Mindestbetrag unterschritten ist.</error>
|
71 |
+
<error code="0071">Diese Funktion ist deaktivert, z.B. Buchungen in der Testphase.</error>
|
72 |
+
<error code="0072">Die Buchung ist bereits erfolgt und kann nicht wiederholt werden.</error>
|
73 |
+
<error code="0073">Die Transaktion wurde abgebrochen.</error>
|
74 |
+
<error code="0074">Der Buchungsbetrag ist höher als der Betrag der zugrunde liegenden Autorisierung.</error>
|
75 |
+
<error code="0075">Es fehlt eine Autorisierung, die der Transaktion vorausgehen muss.</error>
|
76 |
+
<error code="0076">Die Buchung wird verarbeitet (Capture_Request, Capture_Waiting) und kann daher nicht abgebrochen werden.</error>
|
77 |
+
<error code="0077">Die gewünschte Zahlungsart ist für diese HändlerID nicht konfiguriert.</error>
|
78 |
+
<error code="0078">Die Zahlungsmethode ist mit diesem PayType nicht zulässig.</error>
|
79 |
+
<error code="0080">Die Zahlungsmethode wird mit diesem PayType nicht unterstützt.</error>
|
80 |
+
<error code="0081">Die Zahlungsmethode unterstützt diesen Transaktionstype nicht, z.B. Buchung bei GeldKarte-Zahlungen.</error>
|
81 |
+
<error code="0082">Der angegebene Mobilfunkbetreiber wird nicht unterstützt.</error>
|
82 |
+
<error code="0083">Die angegebene Mobilfunknummer ist zu lang.</error>
|
83 |
+
<error code="0084">Die angegebene Mobilfunknummer ist ungültig.</error>
|
84 |
+
<error code="0090">Die Initialisierung des Merchant Plugin für Verified by Visa und MasterCard SecureCode ist gescheitert.</error>
|
85 |
+
<error code="0091">Die Kreditkarte des Kunden ist noch nicht für Verified by Visa oder MasterCard SecureCode registriert.</error>
|
86 |
+
<error code="0092">Der Parameter PAResponse wurde nicht an die Direct3D.aspx übergeben.</error>
|
87 |
+
<error code="0093">Der Browser des Kunden unterstützt kein JavaScript, das zum Beispiel für Verified by Visa und SecureCode benötigt wird.</error>
|
88 |
+
<error code="0094">Das Ablaufdatum der Karte ist überschritten.</error>
|
89 |
+
<error code="0100">Die Karten ausgebende Bank hat die Transaktion regulär abgelehnt.</error>
|
90 |
+
<error code="0101">Der Transaktionstyp ist deaktiviert und wurde nicht ausgeführt.</error>
|
91 |
+
<error code="0102">Die angegebene Kartennummer ist ungültig.</error>
|
92 |
+
<error code="0103">Die Karten ausgebende Bank bittet um Rückruf.</error>
|
93 |
+
<error code="0105">Keine Übereinstimmung der American Express Adressverifikation</error>
|
94 |
+
<error code="0110">Das Ablaufdatum der Kreditkarte ist überschritten.</error>
|
95 |
+
<error code="0111">Die angegebene Kartenmarke ist ungültig.</error>
|
96 |
+
<error code="011A">Die Zahlung wurde aufgrund der Einstellungen des IP-Checks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Tag). </error>
|
97 |
+
<error code="011B">Die Zahlung wurde aufgrund der Einstellungen des Kartenchecks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Tag). </error>
|
98 |
+
<error code="011C">Die Zahlung wurde aufgrund der Einstellungen des Betrags-Checks in Kombination mit dem IP-Check innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Tag). </error>
|
99 |
+
<error code="011D">Die Zahlung wurde aufgrund der Einstellungen des Betragschecks in Kombination mit dem Kartencheck innerhalb der Betrugsprävention abgelehnt (Limit pro Tag).</error>
|
100 |
+
<error code="011E">Die Zahlung wurde aufgrund der Einstellungen des Parameter-Checks (gleiche Referenznummer und/oder TransID) innerhalb der Betrugsprävention SecurePay abgelehnt (Limit pro Tag). </error>
|
101 |
+
<error code="011F">Die Zahlung wurde aufgrund der Einstellungen des Karten/IP-Checks innerhalb der Betrugsprävention von Securepay abgelehnt (Limit pro Tag). </error>
|
102 |
+
<error code="012A">Die Zahlung wurde aufgrund der Einstellungen des IP-Checks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Woche). </error>
|
103 |
+
<error code="012B">Die Zahlung wurde aufgrund der Einstellungen des Kartenchecks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Woche). </error>
|
104 |
+
<error code="012C">Die Zahlung wurde aufgrund der Einstellungen des Betrags-Checks in Kombination mit dem IP-Check innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Woche). </error>
|
105 |
+
<error code="012D">Die Zahlung wurde aufgrund der Einstellungen des Betragschecks in Kombination mit dem Kartencheck innerhalb der Betrugsprävention abgelehnt (Limit pro Woche).</error>
|
106 |
+
<error code="012E">Die Zahlung wurde aufgrund der Einstellungen des Parameter-Checks (gleiche Referenznummer und/oder TransID) innerhalb der Betrugsprävention SecurePay abgelehnt (Limit pro Woche). </error>
|
107 |
+
<error code="012F">Die Zahlung wurde aufgrund der Einstellungen des Karten/IP-Checks innerhalb der Betrugsprävention von Securepay abgelehnt (Limit pro Woche). </error>
|
108 |
+
<error code="013A">Die Zahlung wurde aufgrund der Einstellungen des IP-Checks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Monat). </error>
|
109 |
+
<error code="013B">Die Zahlung wurde aufgrund der Einstellungen des Kartenchecks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Monat). </error>
|
110 |
+
<error code="013C">Die Zahlung wurde aufgrund der Einstellungen des Betrags-Checks in Kombination mit dem IP-Check innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Monat). </error>
|
111 |
+
<error code="013D">Die Zahlung wurde aufgrund der Einstellungen des Betragschecks in Kombination mit dem Kartencheck innerhalb der Betrugsprävention abgelehnt (Limit pro Monat).</error>
|
112 |
+
<error code="013E">Die Zahlung wurde aufgrund der Einstellungen des Parameter-Checks (gleiche Referenznummer und/oder TransID) innerhalb der Betrugsprävention SecurePay abgelehnt (Limit pro Monat). </error>
|
113 |
+
<error code="013F">Die Zahlung wurde aufgrund der Einstellungen des Karten/IP-Checks innerhalb der Betrugsprävention von Securepay abgelehnt (Limit pro Monat). </error>
|
114 |
+
<error code="014A">Die Zahlung wurde abgelehnt, da die IP-Adresse aufgrund der Securepay-Einstellungen temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
115 |
+
<error code="014B">Die Zahlung wurde abgelehnt, da die Kartennummer aufgrund der Securepay-Einstellungen temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
116 |
+
<error code="014C">Die Zahlung wurde abgelehnt, da die IP-Adresse aufgrund der Securepay-Einstellungen (Umsatzlimit erreicht) temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
117 |
+
<error code="014D">Die Zahlung wurde abgelehnt, da die Karte aufgrund der Securepay-Einstellungen (Umsatzlimit erreicht) temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
118 |
+
<error code="014E">Die Zahlung wurde abgelehnt, da der Parameter-Wert aufgrund der Securepay-Einstellungen (Limit erreicht) temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
119 |
+
<error code="014F">Die Zahlung wurde abgelehnt, da die IP aufgrund der Securepay-Einstellungen (max. Anzahl unterschiedlicher Karten über betreffende IP-Adresse) temporär gesperrt ist. Sie können die Sperre in den Securepay-Einstellungen der Payshow aufheben.</error>
|
120 |
+
<error code="0120">Aufforderung zum Einziehen einer ungültigen Karte (stationär).</error>
|
121 |
+
<error code="0121">Die Karten ausgebende Bank ist temporär nicht erreichbar.</error>
|
122 |
+
<error code="0130">Die Pseudo-Kartennummer (PKN) ist nicht gültig</error>
|
123 |
+
<error code="0150">Die XISO-Schnittstelle meldet ein Timeout, Formatfehler oder technischen Probleme im Bankrechenzentrum.</error>
|
124 |
+
<error code="0151">Die XISO-Schnittstelle konnte keine Antwort senden.</error>
|
125 |
+
<error code="0161">Die Zahlung wurde aufgrund der Einstellungen des IP-Checks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Stunde). </error>
|
126 |
+
<error code="0162">Die Zahlung wurde aufgrund der Einstellungen des Kartenchecks innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Stunde). </error>
|
127 |
+
<error code="0163">Die Zahlung wurde aufgrund der Einstellungen des Betrags-Checks in Kombination mit dem IP-Check innerhalb der Betrugsprävention abgelehnt (max. Anzahl pro Stunde). </error>
|
128 |
+
<error code="0164">Die Zahlung wurde aufgrund der Einstellungen des Betragschecks in Kombination mit dem Kartencheck innerhalb der Betrugsprävention abgelehnt (Limit pro Stunde).</error>
|
129 |
+
<error code="0165">Die Zahlung wurde aufgrund der Einstellungen des Parameter-Checks (gleiche Referenznummer und/oder TransID) innerhalb der Betrugsprävention SecurePay abgelehnt (Limit pro Stunde). </error>
|
130 |
+
<error code="0166">Die Zahlung wurde aufgrund der Einstellungen des Karten/IP-Checks innerhalb der Betrugsprävention von Securepay abgelehnt (Limit pro Stunde). </error>
|
131 |
+
<error code="0190">Das angegebene Lieferland stimmt nicht mit dem Herkunftsland der Kreditkarte überein.</error>
|
132 |
+
<error code="0191">Der Kunde nutzt eine IP-Adresse aus einem Land, das nicht auf Ihrer Länderliste enthalten ist.</error>
|
133 |
+
<error code="0192">Der Kunde nutzt eine IP-Adresse aus einem Land, das nicht mit dem Herkunftsland der Kreditkarte übereinstimmt.</error>
|
134 |
+
<error code="0193">Bei der Analyse der IP-Adresse des Kunden ist ein Fehler aufgetreten.</error>
|
135 |
+
<error code="0200">Die Authentisierung mit Verified by Visa und MasterCard SecureCode ist fehlgeschlagen.</error>
|
136 |
+
<error code="0301">Die Antwort vom Bankrechenzentrum ist unvollständig.</error>
|
137 |
+
<error code="0302">Die Zahlung wurde abgelehnt.</error>
|
138 |
+
<error code="0303">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
139 |
+
<error code="0304">Die verwendete Karte ist nicht zulässig.</error>
|
140 |
+
<error code="0305">Die Anfrage wurde vom Autorisierungssystem abgelehnt. Den Grund dafür kennt nur die Bank des Kunden. Die Information fällt unter Datenschutz.</error>
|
141 |
+
<error code="0306">Reserviert.</error>
|
142 |
+
<error code="0312">Die Transaktion ist ungültig, z.B. Währung ist nicht zulässig.</error>
|
143 |
+
<error code="0313">Der verfügbare Betrag wurde überschritten</error>
|
144 |
+
<error code="0314">Die verwendete Karte ist ungültig.</error>
|
145 |
+
<error code="0321">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
146 |
+
<error code="0330">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
147 |
+
<error code="0331">Der Kartenherausgeber ist nicht zulässig.</error>
|
148 |
+
<error code="0333">Das Verfalldatum der Karte ist überschritten</error>
|
149 |
+
<error code="0334">Es liegt Verdacht auf Manipulation oder Betrug vor.</error>
|
150 |
+
<error code="0340">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
151 |
+
<error code="0343">Die wurde Karte gestohlen, bitte einziehen.</error>
|
152 |
+
<error code="0350">Es wurde eine doppelte Autorisierung veranlasst.</error>
|
153 |
+
<error code="0351">Das Kartenlimit wurde überschritten.</error>
|
154 |
+
<error code="0354">Die verwendete Chipkarte ist abgelaufen.</error>
|
155 |
+
<error code="0355">Die angegebene Geheimzahl ist falsch.</error>
|
156 |
+
<error code="0356">Die verwendete Karte ist ungültig.</error>
|
157 |
+
<error code="0357">Die verwendete Karte stimmt nicht mit der Ursprungtransaktion überein.</error>
|
158 |
+
<error code="0358">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
159 |
+
<error code="0359">Es liegt Verdacht auf Manipulation oder Betrug vor.</error>
|
160 |
+
<error code="0361">Die Karte ist in lokaler Sperrliste gesperrt.</error>
|
161 |
+
<error code="0362">Die Karte ist gesperrt.</error>
|
162 |
+
<error code="0376">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
163 |
+
<error code="0383">Ein PIN-Pad-Wechsel ist nicht möglich.</error>
|
164 |
+
<error code="0385">Die Transaktion wurde vom Kreditkarteninstitut abgelehnt.</error>
|
165 |
+
<error code="0386">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
166 |
+
<error code="0387">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
167 |
+
<error code="0391">Der Kartenherausgeber oder das Banknetzwerk sind im Moment nicht verfügbar.</error>
|
168 |
+
<error code="0392">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
169 |
+
<error code="0396">Eine Verarbeitung ist derzeit nicht möglich.</error>
|
170 |
+
<error code="0397">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
171 |
+
<error code="0398">Systemfehler im Bankrechenzentrum: Entweder sind die Datum/Zeit-Angaben falsch oder die Trace-Nr. ist nicht aufsteigend.</error>
|
172 |
+
<error code="0399">Es ist ein Systemfehler im Bankrechenzentrum aufgetreten.</error>
|
173 |
+
<error code="0400">Die eingegebene Rufnummer ist keine gültige Prepaid-Rufnummer.</error>
|
174 |
+
<error code="0401">Die Aufladung der Prepaid-Karte ist derzeit nicht möglich.</error>
|
175 |
+
<error code="0402">Die Aufladung der Prepaid-Karte ist derzeit nicht möglich.</error>
|
176 |
+
<error code="0403">Der maximale Aufladebetrag der Prepaid-Karte wurde erreicht.</error>
|
177 |
+
<error code="0404">Die Auflademöglichkeit ist gesperrt. Die Kreditkarte wurde nicht belastet.</error>
|
178 |
+
<error code="0405">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
179 |
+
<error code="0406">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
180 |
+
<error code="0407">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
181 |
+
<error code="0408">Die eingegebene Rufnummer ist keine gültige Prepaid-Rufnummer.</error>
|
182 |
+
<error code="0409">Die Aufladung war nicht erfolgreich. Die Kreditkarte wurde nicht belastet.</error>
|
183 |
+
<error code="0410">Der angegebene Aufladebetrag ist nicht zulässig.</error>
|
184 |
+
<error code="0411">Der Ausgang des Ladevorgangs ist unbekannt. Bitte bei T-Mobile nachfragen.</error>
|
185 |
+
<error code="0412">Der Ausgang des Ladevorgangs ist unbekannt. Bitte bei Vodafone nachfragen.</error>
|
186 |
+
<error code="0413">Ausgang des Aufladevorgangs ist unbekannt. Bitte bei der GZS-Hotline nachfragen.</error>
|
187 |
+
<error code="0414">Die VU-Nummer Ihres Kreditkartenvertrages ist ungültig. Bitte melden Sie sich beim Computop Support.</error>
|
188 |
+
<error code="0500">Die Kombination von Bankleitzahl und Kontonummer ist ungültig.</error>
|
189 |
+
<error code="0501">Die Datei mit den Bankleitzahlen ist nicht verfügbar.</error>
|
190 |
+
<error code="0502">Beim Überprüfen der Bankverbindung ist ein Systemfehler aufgetreten.</error>
|
191 |
+
<error code="0600">Die Gutschrift bezieht sich auf eine unbekannte Zahlung.</error>
|
192 |
+
<error code="0601">Die Durchführung der Gutschrift wurde abgelehnt.</error>
|
193 |
+
<error code="0650">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
194 |
+
<error code="0651">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
195 |
+
<error code="0652">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
196 |
+
<error code="0653">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
197 |
+
<error code="0654">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
198 |
+
<error code="0655">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
199 |
+
<error code="0665">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
200 |
+
<error code="0656">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
201 |
+
<error code="0657">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
202 |
+
<error code="0658">Die Konfiguration der Zahlungsmethode ist nicht vollständig.</error>
|
203 |
+
<error code="0664">Online-Überweisung: Ungültige Kontoverbindung</error>
|
204 |
+
<error code="0701">Die Antwort vom Bankrechenzentrum entspricht nicht der Anfrage.</error>
|
205 |
+
<error code="0702">Die gestellte Zahlungsanfrage ist ungültig.</error>
|
206 |
+
<error code="0703">Die Anfrage wurde durch den Benutzer abgebrochen.</error>
|
207 |
+
<error code="0704">Die Autorisierung wurde ‘Offline’ durchgeführt.</error>
|
208 |
+
<error code="0705">Der Ausgang der Zahlungsanfrage ist unbekannt.</error>
|
209 |
+
<error code="0708">Die Anfrage konnte nicht durchgeführt werden.</error>
|
210 |
+
<error code="0709">Die Anfrage ist noch nicht komplett verarbeitet.</error>
|
211 |
+
<error code="0710">Der Antwortstatus im Bankrechenzentrum ist unbekannt.</error>
|
212 |
+
<error code="0851">Keine zuverlässige Namensanalyse möglich: Daten ungültig bzw. mehrere Personen angegeben</error>
|
213 |
+
<error code="0852">Die Adressdaten sind unvollständig</error>
|
214 |
+
<error code="0853">-</error>
|
215 |
+
<error code="0854">Datenfehler: Namen korrigieren</error>
|
216 |
+
<error code="0855">Datenfehler: Adresse korrigieren</error>
|
217 |
+
<error code="0856">Datenfehler: Ungültiger Datentyp in XML-Nachricht zu KQIS</error>
|
218 |
+
<error code="0857">-</error>
|
219 |
+
<error code="0861">Schlechte Bonitätsbeurteilung oder weich negative Merkmale zur Person gespeichert</error>
|
220 |
+
<error code="0862">Mittel- oder hart-negative Merkmale zur Person gespeichert oder Adresse ungültig bzw. unvollständig</error>
|
221 |
+
<error code="0921">Das Financial Transaction Gateway der Banken wird gewartet.</error>
|
222 |
+
<error code="0922">Das Kreditinstitut ist derzeit nicht erreichbar.</error>
|
223 |
+
<error code="0923">Aufgrund der Fusion zweier Kreditinstitute ist die Bankleitzahl des Kunden nicht mehr verwendbar.</error>
|
224 |
+
<error code="0924">Das Konto des Kunden ist wegen eines Sperrlisteneintrags nicht zugelassen.</error>
|
225 |
+
<error code="0925">Das Konto des Kunden ist wegen fehlender Informationen nicht zugelassen.</error>
|
226 |
+
<error code="0926">Interner Fehler im Bankennetz.</error>
|
227 |
+
<error code="0927">Der Parameter MerchantTxId stimmt nicht mit der Computop PayID überein.</error>
|
228 |
+
<error code="0928">Der Paramter TxID fehlt.</error>
|
229 |
+
<error code="0929">Der Parameter RedirectURL fehlt.</error>
|
230 |
+
<error code="0930">Nach Eingabe von PIN und TAN war das Kreditinstitut nicht mehr erreichbar.</error>
|
231 |
+
<error code="0931">Zeitüberschreitung bei Eingabe von PIN oder TAN.</error>
|
232 |
+
<error code="0932">Die Bank meldet, daß die angegebene Kontoverbindung kein Online-Banking zulässt.</error>
|
233 |
+
<error code="0933">Die Transaktion konnte nicht autorisiert werden.</error>
|
234 |
+
<error code="0934">Der Transaktionsstatus konnte nicht eindeutig ermittelt werden.</error>
|
235 |
+
<error code="0950">Die Autorisierung ist gescheitert, kein detaillierter Fehler bekannt</error>
|
236 |
+
<error code="0951">Die Buchungist gescheitert, kein detaillierter Fehler bekannt</error>
|
237 |
+
<error code="0952">Die Gutschrift ist gescheitert, kein detaillierter Fehler bekannt</error>
|
238 |
+
<error code="0961">Der Parameter TicketNr verursacht ein Problem.</error>
|
239 |
+
<error code="0962">Der Parameter PassengerNr verursacht ein Problem.</error>
|
240 |
+
<error code="0963">Der Parameter FlightDate verursacht ein Problem.</error>
|
241 |
+
<error code="0964">Der Parameter Origin1 verursacht ein Problem.</error>
|
242 |
+
<error code="0965">Der Parameter Destination1 verursacht ein Problem.</error>
|
243 |
+
<error code="0966">Der Parameter Carrier1 verursacht ein Problem.</error>
|
244 |
+
<error code="0971">Der Parameter AddrStreet verursacht ein Problem.</error>
|
245 |
+
<error code="0972">Der Parameter AddrHouseNr verursacht ein Problem.</error>
|
246 |
+
<error code="0973">Der Parameter AddrCountryCode verursacht ein Problem.</error>
|
247 |
+
<error code="0974">Der Parameter AddrZipCode verursacht ein Problem.</error>
|
248 |
+
<error code="0975">Der Parameter AddrCity verursacht ein Problem.</error>
|
249 |
+
<error code="0976">Der Parameter LastName verursacht ein Problem.</error>
|
250 |
+
<error code="0977">Der Parameter CompanyOrPerson verursacht ein Problem.</error>
|
251 |
+
<error code="0991">Ablehnung durch Acquirer aufgrund des Betrugsrisikos</error>
|
252 |
+
<error code="0992">Nicht unterstützte Funktion</error>
|
253 |
+
</backend>
|
254 |
+
</errorhandling>
|
app/code/community/Dotsource/Computop/etc/system.xml
ADDED
@@ -0,0 +1,776 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment translate="label" module="computop">
|
5 |
+
<groups>
|
6 |
+
<computop_cc translate="label">
|
7 |
+
<label>Computop Credit Card</label>
|
8 |
+
<sort_order>-100</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<fields>
|
13 |
+
<active translate="label">
|
14 |
+
<label>Enabled</label>
|
15 |
+
<frontend_type>select</frontend_type>
|
16 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
17 |
+
<sort_order>1</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>0</show_in_store>
|
21 |
+
</active>
|
22 |
+
<title translate="label">
|
23 |
+
<label>Title</label>
|
24 |
+
<frontend_type>text</frontend_type>
|
25 |
+
<sort_order>10</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>1</show_in_store>
|
29 |
+
<!--<validate>required-entry</validate>-->
|
30 |
+
</title>
|
31 |
+
<orderdesc translate="label comment">
|
32 |
+
<label>Reference</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<backend_model>computop/system_config_backend_orderdesc</backend_model>
|
35 |
+
<comment>Maximum length is 756. Attention: some special characters will deleted automatically.</comment>
|
36 |
+
<sort_order>15</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<validate>validate-length maximum-length-756</validate>
|
41 |
+
</orderdesc>
|
42 |
+
<etm_active translate="label">
|
43 |
+
<label>Advanced transaction management</label>
|
44 |
+
<frontend_type>select</frontend_type>
|
45 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
46 |
+
<sort_order>20</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
</etm_active>
|
51 |
+
<use_pseudo_data translate="label">
|
52 |
+
<label>Use Pseudo Credit Card Information</label>
|
53 |
+
<frontend_type>select</frontend_type>
|
54 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
55 |
+
<sort_order>30</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>0</show_in_store>
|
59 |
+
</use_pseudo_data>
|
60 |
+
<prefill_paymentinformation translate="label">
|
61 |
+
<label>Pre-Fill Payment Information</label>
|
62 |
+
<frontend_type>select</frontend_type>
|
63 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
64 |
+
<sort_order>31</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>0</show_in_store>
|
68 |
+
<depends><use_pseudo_data>1</use_pseudo_data></depends>
|
69 |
+
</prefill_paymentinformation>
|
70 |
+
<payment_action_computop translate="label">
|
71 |
+
<label>Payment moment</label>
|
72 |
+
<frontend_type>select</frontend_type>
|
73 |
+
<sort_order>40</sort_order>
|
74 |
+
<frontend_class>applicable-moment</frontend_class>
|
75 |
+
<source_model>computop/system_config_source_paymentaction</source_model>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</payment_action_computop>
|
80 |
+
<showdebitinhours translate="label">
|
81 |
+
<label>Debit in x hours</label>
|
82 |
+
<frontend_type>text</frontend_type>
|
83 |
+
<sort_order>41</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
<show_in_website>1</show_in_website>
|
86 |
+
<show_in_store>0</show_in_store>
|
87 |
+
<validate>validate-digits validate-length maximum-length-3 validate-greater-than-zero</validate>
|
88 |
+
<depends><payment_action_computop>timebooking_authorize_capture</payment_action_computop></depends>
|
89 |
+
</showdebitinhours>
|
90 |
+
<allowspecific translate="label">
|
91 |
+
<label>Payment from applicable countries</label>
|
92 |
+
<frontend_type>allowspecific</frontend_type>
|
93 |
+
<sort_order>50</sort_order>
|
94 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>0</show_in_store>
|
98 |
+
</allowspecific>
|
99 |
+
<specificcountry translate="label">
|
100 |
+
<label>Payment from Specific countries</label>
|
101 |
+
<frontend_type>multiselect</frontend_type>
|
102 |
+
<sort_order>51</sort_order>
|
103 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>0</show_in_store>
|
107 |
+
<depends><allowspecific>1</allowspecific></depends>
|
108 |
+
</specificcountry>
|
109 |
+
<allowedcountries translate="label">
|
110 |
+
<label>Allow/Restrict countries</label>
|
111 |
+
<frontend_type>select</frontend_type>
|
112 |
+
<sort_order>60</sort_order>
|
113 |
+
<frontend_class>allow-all-countries</frontend_class>
|
114 |
+
<source_model>computop/system_config_source_allowedcountriesAction</source_model>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>0</show_in_store>
|
118 |
+
</allowedcountries>
|
119 |
+
<countriesiso3 translate="label">
|
120 |
+
<label>Choose allowed/restricted countries</label>
|
121 |
+
<frontend_type>multiselect</frontend_type>
|
122 |
+
<sort_order>61</sort_order>
|
123 |
+
<source_model>computop/system_config_source_countryiso3</source_model>
|
124 |
+
<show_in_default>1</show_in_default>
|
125 |
+
<show_in_website>1</show_in_website>
|
126 |
+
<show_in_store>0</show_in_store>
|
127 |
+
</countriesiso3>
|
128 |
+
<allowedipzones translate="label">
|
129 |
+
<label>Allow IP zones</label>
|
130 |
+
<frontend_type>select</frontend_type>
|
131 |
+
<sort_order>70</sort_order>
|
132 |
+
<source_model>computop/system_config_source_allowedipzonesAction</source_model>
|
133 |
+
<frontend_class>allow-ip-zones</frontend_class>
|
134 |
+
<show_in_default>1</show_in_default>
|
135 |
+
<show_in_website>1</show_in_website>
|
136 |
+
<show_in_store>0</show_in_store>
|
137 |
+
</allowedipzones>
|
138 |
+
<ipzones translate="label">
|
139 |
+
<label>IP Zones</label>
|
140 |
+
<frontend_type>text</frontend_type>
|
141 |
+
<sort_order>71</sort_order>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>1</show_in_website>
|
144 |
+
<show_in_store>0</show_in_store>
|
145 |
+
<validate>validate-length maximum-length-350</validate>
|
146 |
+
</ipzones>
|
147 |
+
<use_template translate="label">
|
148 |
+
<label>Use XSLT Template</label>
|
149 |
+
<frontend_type>select</frontend_type>
|
150 |
+
<sort_order>80</sort_order>
|
151 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
152 |
+
<show_in_default>1</show_in_default>
|
153 |
+
<show_in_website>1</show_in_website>
|
154 |
+
<show_in_store>0</show_in_store>
|
155 |
+
</use_template>
|
156 |
+
<template translate="label">
|
157 |
+
<label>Template</label>
|
158 |
+
<frontend_type>text</frontend_type>
|
159 |
+
<sort_order>81</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>1</show_in_website>
|
162 |
+
<show_in_store>0</show_in_store>
|
163 |
+
<validate>required-entry</validate>
|
164 |
+
<depends><use_template>1</use_template></depends>
|
165 |
+
</template>
|
166 |
+
<logos translate="label">
|
167 |
+
<label>Logos</label>
|
168 |
+
<frontend_type>multiselect</frontend_type>
|
169 |
+
<sort_order>82</sort_order>
|
170 |
+
<source_model>computop/system_config_source_logos</source_model>
|
171 |
+
<show_in_default>1</show_in_default>
|
172 |
+
<show_in_website>1</show_in_website>
|
173 |
+
<show_in_store>1</show_in_store>
|
174 |
+
</logos>
|
175 |
+
<sort_order translate="label">
|
176 |
+
<label>Sort order</label>
|
177 |
+
<frontend_type>text</frontend_type>
|
178 |
+
<sort_order>90</sort_order>
|
179 |
+
<show_in_default>1</show_in_default>
|
180 |
+
<show_in_website>1</show_in_website>
|
181 |
+
<show_in_store>1</show_in_store>
|
182 |
+
</sort_order>
|
183 |
+
</fields>
|
184 |
+
</computop_cc>
|
185 |
+
<computop_eft translate="label">
|
186 |
+
<label>Computop Direct Debit</label>
|
187 |
+
<sort_order>-99</sort_order>
|
188 |
+
<show_in_default>1</show_in_default>
|
189 |
+
<show_in_website>1</show_in_website>
|
190 |
+
<show_in_store>1</show_in_store>
|
191 |
+
<fields>
|
192 |
+
<active translate="label">
|
193 |
+
<label>Enabled</label>
|
194 |
+
<frontend_type>select</frontend_type>
|
195 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
196 |
+
<sort_order>1</sort_order>
|
197 |
+
<show_in_default>1</show_in_default>
|
198 |
+
<show_in_website>1</show_in_website>
|
199 |
+
<show_in_store>0</show_in_store>
|
200 |
+
</active>
|
201 |
+
<title translate="label">
|
202 |
+
<label>Title</label>
|
203 |
+
<frontend_type>text</frontend_type>
|
204 |
+
<sort_order>10</sort_order>
|
205 |
+
<show_in_default>1</show_in_default>
|
206 |
+
<show_in_website>1</show_in_website>
|
207 |
+
<show_in_store>1</show_in_store>
|
208 |
+
<!--<validate>required-entry</validate>-->
|
209 |
+
</title>
|
210 |
+
<orderdesc translate="label comment">
|
211 |
+
<label>1. Reference Line</label>
|
212 |
+
<frontend_type>text</frontend_type>
|
213 |
+
<comment>Maximum length is 15</comment>
|
214 |
+
<sort_order>15</sort_order>
|
215 |
+
<show_in_default>1</show_in_default>
|
216 |
+
<show_in_website>1</show_in_website>
|
217 |
+
<show_in_store>1</show_in_store>
|
218 |
+
<validate>validate-length maximum-length-15</validate>
|
219 |
+
</orderdesc>
|
220 |
+
<orderdesc2 translate="label comment">
|
221 |
+
<label>2. Reference Line</label>
|
222 |
+
<frontend_type>text</frontend_type>
|
223 |
+
<comment>Maximum length is 27</comment>
|
224 |
+
<sort_order>16</sort_order>
|
225 |
+
<show_in_default>1</show_in_default>
|
226 |
+
<show_in_website>1</show_in_website>
|
227 |
+
<show_in_store>1</show_in_store>
|
228 |
+
<validate>validate-length maximum-length-27</validate>
|
229 |
+
</orderdesc2>
|
230 |
+
<payment_action_computop translate="label">
|
231 |
+
<label>Payment moment</label>
|
232 |
+
<frontend_type>select</frontend_type>
|
233 |
+
<sort_order>20</sort_order>
|
234 |
+
<frontend_class>applicable-moment</frontend_class>
|
235 |
+
<source_model>computop/system_config_source_paymentaction</source_model>
|
236 |
+
<show_in_default>1</show_in_default>
|
237 |
+
<show_in_website>1</show_in_website>
|
238 |
+
<show_in_store>0</show_in_store>
|
239 |
+
</payment_action_computop>
|
240 |
+
<showdebitinhours translate="label">
|
241 |
+
<label>Debit in x hours</label>
|
242 |
+
<frontend_type>text</frontend_type>
|
243 |
+
<sort_order>21</sort_order>
|
244 |
+
<show_in_default>1</show_in_default>
|
245 |
+
<show_in_website>1</show_in_website>
|
246 |
+
<show_in_store>0</show_in_store>
|
247 |
+
<validate>validate-digits validate-length maximum-length-3 validate-greater-than-zero</validate>
|
248 |
+
<depends><payment_action_computop>timebooking_authorize_capture</payment_action_computop></depends>
|
249 |
+
</showdebitinhours>
|
250 |
+
<allowspecific translate="label">
|
251 |
+
<label>Payment from applicable countries</label>
|
252 |
+
<frontend_type>allowspecific</frontend_type>
|
253 |
+
<sort_order>30</sort_order>
|
254 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
255 |
+
<show_in_default>1</show_in_default>
|
256 |
+
<show_in_website>1</show_in_website>
|
257 |
+
<show_in_store>0</show_in_store>
|
258 |
+
</allowspecific>
|
259 |
+
<specificcountry translate="label">
|
260 |
+
<label>Payment from Specific countries</label>
|
261 |
+
<frontend_type>multiselect</frontend_type>
|
262 |
+
<sort_order>31</sort_order>
|
263 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
264 |
+
<show_in_default>1</show_in_default>
|
265 |
+
<show_in_website>1</show_in_website>
|
266 |
+
<show_in_store>0</show_in_store>
|
267 |
+
<depends><allowspecific>1</allowspecific></depends>
|
268 |
+
</specificcountry>
|
269 |
+
<allowedipzones translate="label">
|
270 |
+
<label>Allow IP zones</label>
|
271 |
+
<frontend_type>select</frontend_type>
|
272 |
+
<sort_order>40</sort_order>
|
273 |
+
<source_model>computop/system_config_source_allowedipzonesAction</source_model>
|
274 |
+
<frontend_class>allow-ip-zones</frontend_class>
|
275 |
+
<show_in_default>1</show_in_default>
|
276 |
+
<show_in_website>1</show_in_website>
|
277 |
+
<show_in_store>0</show_in_store>
|
278 |
+
</allowedipzones>
|
279 |
+
<ipzones translate="label">
|
280 |
+
<label>IP Zones</label>
|
281 |
+
<frontend_type>text</frontend_type>
|
282 |
+
<sort_order>41</sort_order>
|
283 |
+
<show_in_default>1</show_in_default>
|
284 |
+
<show_in_website>1</show_in_website>
|
285 |
+
<show_in_store>0</show_in_store>
|
286 |
+
</ipzones>
|
287 |
+
<sort_order translate="label">
|
288 |
+
<label>Sort order</label>
|
289 |
+
<frontend_type>text</frontend_type>
|
290 |
+
<sort_order>60</sort_order>
|
291 |
+
<show_in_default>1</show_in_default>
|
292 |
+
<show_in_website>1</show_in_website>
|
293 |
+
<show_in_store>1</show_in_store>
|
294 |
+
</sort_order>
|
295 |
+
</fields>
|
296 |
+
</computop_eft>
|
297 |
+
<computop_giropay translate="label">
|
298 |
+
<label>Computop giropay</label>
|
299 |
+
<sort_order>-98</sort_order>
|
300 |
+
<show_in_default>1</show_in_default>
|
301 |
+
<show_in_website>1</show_in_website>
|
302 |
+
<show_in_store>1</show_in_store>
|
303 |
+
<fields>
|
304 |
+
<active translate="label">
|
305 |
+
<label>Enabled</label>
|
306 |
+
<frontend_type>select</frontend_type>
|
307 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
308 |
+
<sort_order>1</sort_order>
|
309 |
+
<show_in_default>1</show_in_default>
|
310 |
+
<show_in_website>1</show_in_website>
|
311 |
+
<show_in_store>0</show_in_store>
|
312 |
+
</active>
|
313 |
+
<title translate="label">
|
314 |
+
<label>Title</label>
|
315 |
+
<frontend_type>text</frontend_type>
|
316 |
+
<sort_order>10</sort_order>
|
317 |
+
<show_in_default>1</show_in_default>
|
318 |
+
<show_in_website>1</show_in_website>
|
319 |
+
<show_in_store>1</show_in_store>
|
320 |
+
<!--<validate>required-entry</validate>-->
|
321 |
+
</title>
|
322 |
+
<orderdesc translate="label comment">
|
323 |
+
<label>Reference</label>
|
324 |
+
<frontend_type>text</frontend_type>
|
325 |
+
<comment>Maximum length is 15</comment>
|
326 |
+
<sort_order>15</sort_order>
|
327 |
+
<show_in_default>1</show_in_default>
|
328 |
+
<show_in_website>1</show_in_website>
|
329 |
+
<show_in_store>1</show_in_store>
|
330 |
+
<validate>validate-length maximum-length-15</validate>
|
331 |
+
</orderdesc>
|
332 |
+
<bcn_check translate="label">
|
333 |
+
<label>Bank Code Number Available Check</label>
|
334 |
+
<frontend_type>select</frontend_type>
|
335 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
336 |
+
<sort_order>20</sort_order>
|
337 |
+
<show_in_default>1</show_in_default>
|
338 |
+
<show_in_website>1</show_in_website>
|
339 |
+
<show_in_store>0</show_in_store>
|
340 |
+
</bcn_check>
|
341 |
+
<prefill_paymentinformation translate="label">
|
342 |
+
<label>Pre-Fill Payment Information</label>
|
343 |
+
<frontend_type>select</frontend_type>
|
344 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
345 |
+
<sort_order>30</sort_order>
|
346 |
+
<show_in_default>1</show_in_default>
|
347 |
+
<show_in_website>1</show_in_website>
|
348 |
+
<show_in_store>0</show_in_store>
|
349 |
+
</prefill_paymentinformation>
|
350 |
+
<sort_order translate="label">
|
351 |
+
<label>Sort order</label>
|
352 |
+
<frontend_type>text</frontend_type>
|
353 |
+
<sort_order>40</sort_order>
|
354 |
+
<show_in_default>1</show_in_default>
|
355 |
+
<show_in_website>1</show_in_website>
|
356 |
+
<show_in_store>1</show_in_store>
|
357 |
+
</sort_order>
|
358 |
+
</fields>
|
359 |
+
</computop_giropay>
|
360 |
+
<computop_ideal translate="label">
|
361 |
+
<label>Computop iDeal</label>
|
362 |
+
<sort_order>-97</sort_order>
|
363 |
+
<show_in_default>1</show_in_default>
|
364 |
+
<show_in_website>1</show_in_website>
|
365 |
+
<show_in_store>1</show_in_store>
|
366 |
+
<fields>
|
367 |
+
<active translate="label">
|
368 |
+
<label>Enabled</label>
|
369 |
+
<frontend_type>select</frontend_type>
|
370 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
371 |
+
<sort_order>1</sort_order>
|
372 |
+
<show_in_default>1</show_in_default>
|
373 |
+
<show_in_website>1</show_in_website>
|
374 |
+
<show_in_store>0</show_in_store>
|
375 |
+
</active>
|
376 |
+
<title translate="label">
|
377 |
+
<label>Title</label>
|
378 |
+
<frontend_type>text</frontend_type>
|
379 |
+
<sort_order>10</sort_order>
|
380 |
+
<show_in_default>1</show_in_default>
|
381 |
+
<show_in_website>1</show_in_website>
|
382 |
+
<show_in_store>1</show_in_store>
|
383 |
+
<!--<validate>required-entry</validate>-->
|
384 |
+
</title>
|
385 |
+
<orderdesc translate="label comment">
|
386 |
+
<label>Reference</label>
|
387 |
+
<frontend_type>text</frontend_type>
|
388 |
+
<comment>Maximum length is 15</comment>
|
389 |
+
<sort_order>15</sort_order>
|
390 |
+
<show_in_default>1</show_in_default>
|
391 |
+
<show_in_website>1</show_in_website>
|
392 |
+
<show_in_store>1</show_in_store>
|
393 |
+
<validate>validate-length maximum-length-15</validate>
|
394 |
+
</orderdesc>
|
395 |
+
<sort_order translate="label">
|
396 |
+
<label>Sort order</label>
|
397 |
+
<frontend_type>text</frontend_type>
|
398 |
+
<sort_order>20</sort_order>
|
399 |
+
<show_in_default>1</show_in_default>
|
400 |
+
<show_in_website>1</show_in_website>
|
401 |
+
<show_in_store>1</show_in_store>
|
402 |
+
</sort_order>
|
403 |
+
</fields>
|
404 |
+
</computop_ideal>
|
405 |
+
<computop_directpay translate="label">
|
406 |
+
<label>Computop Direct Pay</label>
|
407 |
+
<sort_order>-96</sort_order>
|
408 |
+
<show_in_default>1</show_in_default>
|
409 |
+
<show_in_website>1</show_in_website>
|
410 |
+
<show_in_store>1</show_in_store>
|
411 |
+
<fields>
|
412 |
+
<active translate="label">
|
413 |
+
<label>Enabled</label>
|
414 |
+
<frontend_type>select</frontend_type>
|
415 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
416 |
+
<sort_order>1</sort_order>
|
417 |
+
<show_in_default>1</show_in_default>
|
418 |
+
<show_in_website>1</show_in_website>
|
419 |
+
<show_in_store>0</show_in_store>
|
420 |
+
</active>
|
421 |
+
<title translate="label">
|
422 |
+
<label>Title</label>
|
423 |
+
<frontend_type>text</frontend_type>
|
424 |
+
<sort_order>10</sort_order>
|
425 |
+
<show_in_default>1</show_in_default>
|
426 |
+
<show_in_website>1</show_in_website>
|
427 |
+
<show_in_store>1</show_in_store>
|
428 |
+
<!--<validate>required-entry</validate>-->
|
429 |
+
</title>
|
430 |
+
<orderdesc translate="label comment">
|
431 |
+
<label>1. Reference Line</label>
|
432 |
+
<frontend_type>text</frontend_type>
|
433 |
+
<backend_model>computop/system_config_backend_orderdesc</backend_model>
|
434 |
+
<comment>Maximum length is 15. Attention: some special characters will deleted automatically.</comment>
|
435 |
+
<sort_order>15</sort_order>
|
436 |
+
<show_in_default>1</show_in_default>
|
437 |
+
<show_in_website>1</show_in_website>
|
438 |
+
<show_in_store>1</show_in_store>
|
439 |
+
<validate>validate-length maximum-length-15</validate>
|
440 |
+
</orderdesc>
|
441 |
+
<orderdesc2 translate="label comment">
|
442 |
+
<label>2. Reference Line</label>
|
443 |
+
<frontend_type>text</frontend_type>
|
444 |
+
<backend_model>computop/system_config_backend_orderdesc</backend_model>
|
445 |
+
<comment>Maximum length is 27. Attention: some special characters will deleted automatically.</comment>
|
446 |
+
<sort_order>16</sort_order>
|
447 |
+
<show_in_default>1</show_in_default>
|
448 |
+
<show_in_website>1</show_in_website>
|
449 |
+
<show_in_store>1</show_in_store>
|
450 |
+
<validate>validate-length maximum-length-27</validate>
|
451 |
+
</orderdesc2>
|
452 |
+
<prefill_paymentinformation translate="label">
|
453 |
+
<label>Pre-Fill Payment Information</label>
|
454 |
+
<frontend_type>select</frontend_type>
|
455 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
456 |
+
<sort_order>20</sort_order>
|
457 |
+
<show_in_default>1</show_in_default>
|
458 |
+
<show_in_website>1</show_in_website>
|
459 |
+
<show_in_store>0</show_in_store>
|
460 |
+
</prefill_paymentinformation>
|
461 |
+
<sort_order translate="label">
|
462 |
+
<label>Sort order</label>
|
463 |
+
<frontend_type>text</frontend_type>
|
464 |
+
<sort_order>30</sort_order>
|
465 |
+
<show_in_default>1</show_in_default>
|
466 |
+
<show_in_website>1</show_in_website>
|
467 |
+
<show_in_store>1</show_in_store>
|
468 |
+
</sort_order>
|
469 |
+
</fields>
|
470 |
+
</computop_directpay>
|
471 |
+
<computop_mpass translate="label">
|
472 |
+
<label>Computop mpass</label>
|
473 |
+
<sort_order>-95</sort_order>
|
474 |
+
<show_in_default>1</show_in_default>
|
475 |
+
<show_in_website>1</show_in_website>
|
476 |
+
<show_in_store>1</show_in_store>
|
477 |
+
<fields>
|
478 |
+
<active translate="label">
|
479 |
+
<label>Enabled</label>
|
480 |
+
<frontend_type>select</frontend_type>
|
481 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
482 |
+
<sort_order>10</sort_order>
|
483 |
+
<show_in_default>1</show_in_default>
|
484 |
+
<show_in_website>1</show_in_website>
|
485 |
+
<show_in_store>0</show_in_store>
|
486 |
+
</active>
|
487 |
+
<title translate="label">
|
488 |
+
<label>Title</label>
|
489 |
+
<frontend_type>text</frontend_type>
|
490 |
+
<sort_order>10</sort_order>
|
491 |
+
<show_in_default>1</show_in_default>
|
492 |
+
<show_in_website>1</show_in_website>
|
493 |
+
<show_in_store>1</show_in_store>
|
494 |
+
<!--<validate>required-entry</validate>-->
|
495 |
+
</title>
|
496 |
+
<orderdesc translate="label comment">
|
497 |
+
<label>Reference</label>
|
498 |
+
<frontend_type>text</frontend_type>
|
499 |
+
<comment>Maximum length is 47</comment>
|
500 |
+
<sort_order>15</sort_order>
|
501 |
+
<show_in_default>1</show_in_default>
|
502 |
+
<show_in_website>1</show_in_website>
|
503 |
+
<show_in_store>1</show_in_store>
|
504 |
+
<validate>validate-length maximum-length-47</validate>
|
505 |
+
</orderdesc>
|
506 |
+
<payment_action_computop translate="label">
|
507 |
+
<label>Payment moment</label>
|
508 |
+
<frontend_type>select</frontend_type>
|
509 |
+
<sort_order>20</sort_order>
|
510 |
+
<source_model>computop/system_config_source_paymentaction
|
511 |
+
</source_model>
|
512 |
+
<show_in_default>1</show_in_default>
|
513 |
+
<show_in_website>1</show_in_website>
|
514 |
+
<show_in_store>0</show_in_store>
|
515 |
+
</payment_action_computop>
|
516 |
+
<showdebitinhours translate="label">
|
517 |
+
<label>Debit in x hours</label>
|
518 |
+
<frontend_type>text</frontend_type>
|
519 |
+
<sort_order>21</sort_order>
|
520 |
+
<show_in_default>1</show_in_default>
|
521 |
+
<show_in_website>1</show_in_website>
|
522 |
+
<show_in_store>0</show_in_store>
|
523 |
+
<validate>validate-digits validate-length maximum-length-3 validate-greater-than-zero</validate>
|
524 |
+
<depends><payment_action_computop>timebooking_authorize_capture</payment_action_computop></depends>
|
525 |
+
</showdebitinhours>
|
526 |
+
<allowspecific translate="label">
|
527 |
+
<label>Payment from applicable countries</label>
|
528 |
+
<frontend_type>allowspecific</frontend_type>
|
529 |
+
<sort_order>30</sort_order>
|
530 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
531 |
+
<show_in_default>1</show_in_default>
|
532 |
+
<show_in_website>1</show_in_website>
|
533 |
+
<show_in_store>0</show_in_store>
|
534 |
+
</allowspecific>
|
535 |
+
<specificcountry translate="label">
|
536 |
+
<label>Payment from Specific countries</label>
|
537 |
+
<frontend_type>multiselect</frontend_type>
|
538 |
+
<sort_order>31</sort_order>
|
539 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
540 |
+
<show_in_default>1</show_in_default>
|
541 |
+
<show_in_website>1</show_in_website>
|
542 |
+
<show_in_store>0</show_in_store>
|
543 |
+
<depends><allowspecific>1</allowspecific></depends>
|
544 |
+
</specificcountry>
|
545 |
+
<sort_order translate="label">
|
546 |
+
<label>Sort order</label>
|
547 |
+
<frontend_type>text</frontend_type>
|
548 |
+
<sort_order>40</sort_order>
|
549 |
+
<show_in_default>1</show_in_default>
|
550 |
+
<show_in_website>1</show_in_website>
|
551 |
+
<show_in_store>1</show_in_store>
|
552 |
+
</sort_order>
|
553 |
+
</fields>
|
554 |
+
</computop_mpass>
|
555 |
+
<computop_paypal_standard translate="label">
|
556 |
+
<label>Computop PayPal</label>
|
557 |
+
<sort_order>-94</sort_order>
|
558 |
+
<show_in_default>1</show_in_default>
|
559 |
+
<show_in_website>1</show_in_website>
|
560 |
+
<show_in_store>1</show_in_store>
|
561 |
+
<fields>
|
562 |
+
<active translate="label">
|
563 |
+
<label>Enabled</label>
|
564 |
+
<frontend_type>select</frontend_type>
|
565 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
566 |
+
<sort_order>1</sort_order>
|
567 |
+
<show_in_default>1</show_in_default>
|
568 |
+
<show_in_website>1</show_in_website>
|
569 |
+
<show_in_store>0</show_in_store>
|
570 |
+
</active>
|
571 |
+
<title translate="label">
|
572 |
+
<label>Title</label>
|
573 |
+
<frontend_type>text</frontend_type>
|
574 |
+
<sort_order>10</sort_order>
|
575 |
+
<show_in_default>1</show_in_default>
|
576 |
+
<show_in_website>1</show_in_website>
|
577 |
+
<show_in_store>1</show_in_store>
|
578 |
+
<!--<validate>required-entry</validate>-->
|
579 |
+
</title>
|
580 |
+
<orderdesc translate="label comment">
|
581 |
+
<label>Reference</label>
|
582 |
+
<frontend_type>text</frontend_type>
|
583 |
+
<comment>Maximum length is 115</comment>
|
584 |
+
<sort_order>15</sort_order>
|
585 |
+
<show_in_default>1</show_in_default>
|
586 |
+
<show_in_website>1</show_in_website>
|
587 |
+
<show_in_store>1</show_in_store>
|
588 |
+
<validate>validate-length maximum-length-115</validate>
|
589 |
+
</orderdesc>
|
590 |
+
<payment_action_computop translate="label">
|
591 |
+
<label>Payment moment</label>
|
592 |
+
<frontend_type>select</frontend_type>
|
593 |
+
<sort_order>20</sort_order>
|
594 |
+
<source_model>computop/system_config_source_paypalpaymentaction</source_model>
|
595 |
+
<show_in_default>1</show_in_default>
|
596 |
+
<show_in_website>1</show_in_website>
|
597 |
+
<show_in_store>0</show_in_store>
|
598 |
+
</payment_action_computop>
|
599 |
+
<showdebitinhours translate="label">
|
600 |
+
<label>Debit in x hours</label>
|
601 |
+
<frontend_type>text</frontend_type>
|
602 |
+
<sort_order>21</sort_order>
|
603 |
+
<show_in_default>1</show_in_default>
|
604 |
+
<show_in_website>1</show_in_website>
|
605 |
+
<show_in_store>0</show_in_store>
|
606 |
+
<validate>validate-digits validate-length maximum-length-3 validate-greater-than-zero</validate>
|
607 |
+
<depends><payment_action_computop>timebooking_authorize_capture</payment_action_computop></depends>
|
608 |
+
</showdebitinhours>
|
609 |
+
<payment_action_txtype translate="label">
|
610 |
+
<label>Payment Action</label>
|
611 |
+
<frontend_type>select</frontend_type>
|
612 |
+
<sort_order>22</sort_order>
|
613 |
+
<source_model>computop/system_config_source_txtype</source_model>
|
614 |
+
<show_in_default>1</show_in_default>
|
615 |
+
<show_in_website>1</show_in_website>
|
616 |
+
<show_in_store>0</show_in_store>
|
617 |
+
<depends><payment_action_computop>authorize</payment_action_computop></depends>
|
618 |
+
</payment_action_txtype>
|
619 |
+
<sort_order translate="label">
|
620 |
+
<label>Sort order</label>
|
621 |
+
<frontend_type>text</frontend_type>
|
622 |
+
<sort_order>30</sort_order>
|
623 |
+
<show_in_default>1</show_in_default>
|
624 |
+
<show_in_website>1</show_in_website>
|
625 |
+
<show_in_store>1</show_in_store>
|
626 |
+
</sort_order>
|
627 |
+
</fields>
|
628 |
+
</computop_paypal_standard>
|
629 |
+
<computop_paypal_express translate="label">
|
630 |
+
<label>Computop PayPal Express</label>
|
631 |
+
<sort_order>-93</sort_order>
|
632 |
+
<show_in_default>1</show_in_default>
|
633 |
+
<show_in_website>1</show_in_website>
|
634 |
+
<show_in_store>1</show_in_store>
|
635 |
+
<fields>
|
636 |
+
<active translate="label">
|
637 |
+
<label>Enabled</label>
|
638 |
+
<frontend_type>select</frontend_type>
|
639 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
640 |
+
<sort_order>1</sort_order>
|
641 |
+
<show_in_default>1</show_in_default>
|
642 |
+
<show_in_website>1</show_in_website>
|
643 |
+
<show_in_store>0</show_in_store>
|
644 |
+
</active>
|
645 |
+
<title translate="label">
|
646 |
+
<label>Title</label>
|
647 |
+
<frontend_type>text</frontend_type>
|
648 |
+
<sort_order>10</sort_order>
|
649 |
+
<show_in_default>1</show_in_default>
|
650 |
+
<show_in_website>1</show_in_website>
|
651 |
+
<show_in_store>1</show_in_store>
|
652 |
+
<!--<validate>required-entry</validate>-->
|
653 |
+
</title>
|
654 |
+
<orderdesc translate="label comment">
|
655 |
+
<label>Reference</label>
|
656 |
+
<frontend_type>text</frontend_type>
|
657 |
+
<comment>Maximum length is 115</comment>
|
658 |
+
<sort_order>15</sort_order>
|
659 |
+
<show_in_default>1</show_in_default>
|
660 |
+
<show_in_website>1</show_in_website>
|
661 |
+
<show_in_store>1</show_in_store>
|
662 |
+
<validate>validate-length maximum-length-115</validate>
|
663 |
+
</orderdesc>
|
664 |
+
<payment_action_computop translate="label">
|
665 |
+
<label>Payment moment</label>
|
666 |
+
<frontend_type>select</frontend_type>
|
667 |
+
<sort_order>20</sort_order>
|
668 |
+
<!-- TODO without timebooking -->
|
669 |
+
<source_model>computop/system_config_source_paypalpaymentaction</source_model>
|
670 |
+
<show_in_default>1</show_in_default>
|
671 |
+
<show_in_website>1</show_in_website>
|
672 |
+
<show_in_store>0</show_in_store>
|
673 |
+
</payment_action_computop>
|
674 |
+
<payment_action_txtype translate="label">
|
675 |
+
<label>Payment Action</label>
|
676 |
+
<frontend_type>select</frontend_type>
|
677 |
+
<sort_order>22</sort_order>
|
678 |
+
<source_model>computop/system_config_source_txtype</source_model>
|
679 |
+
<show_in_default>1</show_in_default>
|
680 |
+
<show_in_website>1</show_in_website>
|
681 |
+
<show_in_store>0</show_in_store>
|
682 |
+
<depends><payment_action_computop>authorize</payment_action_computop></depends>
|
683 |
+
</payment_action_txtype>
|
684 |
+
<sort_order translate="label">
|
685 |
+
<label>Sort order</label>
|
686 |
+
<frontend_type>text</frontend_type>
|
687 |
+
<sort_order>40</sort_order>
|
688 |
+
<show_in_default>1</show_in_default>
|
689 |
+
<show_in_website>1</show_in_website>
|
690 |
+
<show_in_store>1</show_in_store>
|
691 |
+
</sort_order>
|
692 |
+
</fields>
|
693 |
+
</computop_paypal_express>
|
694 |
+
</groups>
|
695 |
+
</payment>
|
696 |
+
</sections>
|
697 |
+
<sections>
|
698 |
+
<computop_account translate="label" module="computop">
|
699 |
+
<label>Computop Account</label>
|
700 |
+
<tab>sales</tab>
|
701 |
+
<sort_order>600</sort_order>
|
702 |
+
<show_in_default>1</show_in_default>
|
703 |
+
<show_in_website>1</show_in_website>
|
704 |
+
<show_in_store>0</show_in_store>
|
705 |
+
<groups>
|
706 |
+
<default translate="label">
|
707 |
+
<label>Global Connection Settings</label>
|
708 |
+
<sort_order>10</sort_order>
|
709 |
+
<show_in_default>1</show_in_default>
|
710 |
+
<show_in_website>1</show_in_website>
|
711 |
+
<show_in_store>0</show_in_store>
|
712 |
+
<fields>
|
713 |
+
<baseurl translate="label">
|
714 |
+
<label>Base URL</label>
|
715 |
+
<frontend_type>select</frontend_type>
|
716 |
+
<source_model>computop/system_config_source_baseurl</source_model>
|
717 |
+
<sort_order>20</sort_order>
|
718 |
+
<show_in_default>1</show_in_default>
|
719 |
+
<show_in_website>1</show_in_website>
|
720 |
+
<show_in_store>0</show_in_store>
|
721 |
+
<validate>validate-select</validate>
|
722 |
+
</baseurl>
|
723 |
+
<merchant_id translate="label">
|
724 |
+
<label>Merchant ID</label>
|
725 |
+
<frontend_type>text</frontend_type>
|
726 |
+
<sort_order>30</sort_order>
|
727 |
+
<show_in_default>1</show_in_default>
|
728 |
+
<show_in_website>1</show_in_website>
|
729 |
+
<show_in_store>0</show_in_store>
|
730 |
+
<validate>required-entry</validate>
|
731 |
+
</merchant_id>
|
732 |
+
<encryption_password translate="label">
|
733 |
+
<label>Merchant Encryption Password</label>
|
734 |
+
<frontend_type>password</frontend_type>
|
735 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
736 |
+
<sort_order>40</sort_order>
|
737 |
+
<show_in_default>1</show_in_default>
|
738 |
+
<show_in_website>1</show_in_website>
|
739 |
+
<show_in_store>0</show_in_store>
|
740 |
+
<validate>required-entry</validate>
|
741 |
+
</encryption_password>
|
742 |
+
<hmac_salt translate="label">
|
743 |
+
<label>Merchant Hmac</label>
|
744 |
+
<frontend_type>password</frontend_type>
|
745 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
746 |
+
<sort_order>50</sort_order>
|
747 |
+
<show_in_default>1</show_in_default>
|
748 |
+
<show_in_website>1</show_in_website>
|
749 |
+
<show_in_store>0</show_in_store>
|
750 |
+
<validate></validate>
|
751 |
+
</hmac_salt>
|
752 |
+
</fields>
|
753 |
+
</default>
|
754 |
+
<computop_cc translate="label">
|
755 |
+
<label>Specific Credit Card Account Information</label>
|
756 |
+
<sort_order>20</sort_order>
|
757 |
+
<show_in_default>1</show_in_default>
|
758 |
+
<show_in_website>1</show_in_website>
|
759 |
+
<show_in_store>0</show_in_store>
|
760 |
+
<fields>
|
761 |
+
<merchant_account_info translate="label">
|
762 |
+
<label>You can setup specify account data for the payment method credit card. If you don't setup any currency the global account settings are used.</label>
|
763 |
+
<frontend_model>computop/config_form_merchant</frontend_model>
|
764 |
+
<backend_model>computop/system_config_backend_serialized_merchant</backend_model>
|
765 |
+
<sort_order>10</sort_order>
|
766 |
+
<show_in_default>1</show_in_default>
|
767 |
+
<show_in_website>1</show_in_website>
|
768 |
+
<show_in_store>0</show_in_store>
|
769 |
+
<comment></comment>
|
770 |
+
</merchant_account_info>
|
771 |
+
</fields>
|
772 |
+
</computop_cc>
|
773 |
+
</groups>
|
774 |
+
</computop_account>
|
775 |
+
</sections>
|
776 |
+
</config>
|
app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-install-1.4.0.1.1.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Dotsource_Computop_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
//Add the new payment fields
|
6 |
+
$this->addAttribute('order_payment', 'computop_transaction_id', array('type' => 'int'));
|
7 |
+
$this->addAttribute('quote_payment', 'computop_transaction_id', array('type' => 'int'));
|
8 |
+
|
9 |
+
$this->addAttribute('order_payment', 'eft_owner', array('type'=>'varchar'));
|
10 |
+
$this->addAttribute('quote_payment', 'eft_owner', array('type'=>'varchar'));
|
11 |
+
|
12 |
+
$this->addAttribute('order_payment', 'eft_ban_enc', array('type'=>'varchar'));
|
13 |
+
$this->addAttribute('quote_payment', 'eft_ban_enc', array('type'=>'varchar'));
|
14 |
+
|
15 |
+
$this->addAttribute('order_payment', 'eft_ban4', array('type'=>'varchar'));
|
16 |
+
$this->addAttribute('quote_payment', 'eft_ban4', array('type'=>'varchar'));
|
17 |
+
|
18 |
+
$this->addAttribute('order_payment', 'eft_bcn', array('type'=>'varchar'));
|
19 |
+
$this->addAttribute('quote_payment', 'eft_bcn', array('type'=>'varchar'));
|
20 |
+
|
21 |
+
//Holds the table names
|
22 |
+
$tableAction = $this->getTable('computop_action');
|
23 |
+
$tableTransaction = $this->getTable('computop_transaction');
|
24 |
+
|
25 |
+
//Transaction table
|
26 |
+
$this->run("
|
27 |
+
CREATE TABLE IF NOT EXISTS `$tableTransaction` (
|
28 |
+
entity_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
29 |
+
transaction_code VARCHAR(32),
|
30 |
+
PRIMARY KEY(entity_id)
|
31 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
32 |
+
");
|
33 |
+
|
34 |
+
//Holds communication actions
|
35 |
+
$this->run("
|
36 |
+
CREATE TABLE IF NOT EXISTS `$tableAction` (
|
37 |
+
entity_id INT NOT NULL AUTO_INCREMENT,
|
38 |
+
transaction_id INT UNSIGNED NOT NULL,
|
39 |
+
request_payid VARCHAR(32) NOT NULL,
|
40 |
+
response_payid VARCHAR(32) NOT NULL,
|
41 |
+
xid VARCHAR(64) NOT NULL,
|
42 |
+
created_at DATETIME,
|
43 |
+
action VARCHAR(24) NOT NULL,
|
44 |
+
error CHAR(1) NOT NULL default 0,
|
45 |
+
error_code CHAR(8) NOT NULL,
|
46 |
+
error_description TEXT NOT NULL,
|
47 |
+
PRIMARY KEY(entity_id),
|
48 |
+
CONSTRAINT `FK_COMPUTOP_TRANSACTION_ENTITY_ID`
|
49 |
+
FOREIGN KEY (`transaction_id`)
|
50 |
+
REFERENCES $tableTransaction (`entity_id`)
|
51 |
+
ON UPDATE CASCADE
|
52 |
+
ON DELETE CASCADE
|
53 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
54 |
+
");
|
55 |
+
|
56 |
+
$this->endSetup();
|
app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.0.1.1-1.4.1.1.2.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Dotsource_Computop_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
//Use the right table
|
6 |
+
$orderTable = $this->getFlatTableName('order');
|
7 |
+
if (null === $orderTable) {
|
8 |
+
$orderTable = 'sales_order';
|
9 |
+
}
|
10 |
+
|
11 |
+
//Convert the old order status to the new one
|
12 |
+
$waitingAuth = substr('waiting_authorization_notification_computop ', 0, 32);
|
13 |
+
$waitingCapture = substr('waiting_capture_notification_computop ', 0, 32);
|
14 |
+
$captureReady = substr('ready_for_computop_capture_action ', 0, 32);
|
15 |
+
|
16 |
+
//Update the old status to the new status to the length problems in flat_tables
|
17 |
+
$this->run("
|
18 |
+
UPDATE {$this->getTable($orderTable)}
|
19 |
+
SET status = 'waiting_auth_computop_note'
|
20 |
+
WHERE
|
21 |
+
status LIKE '$waitingAuth%';
|
22 |
+
|
23 |
+
UPDATE {$this->getTable($orderTable)}
|
24 |
+
SET status = 'waiting_capture_computop_note'
|
25 |
+
WHERE
|
26 |
+
status LIKE '$waitingCapture%';
|
27 |
+
|
28 |
+
UPDATE {$this->getTable($orderTable)}
|
29 |
+
SET status = 'ready_computop_capture'
|
30 |
+
WHERE
|
31 |
+
status LIKE '$captureReady%';
|
32 |
+
");
|
33 |
+
|
34 |
+
//Update order history comments
|
35 |
+
$orderHistoryTable = $this->getFlatTableName('order_status_history');
|
36 |
+
if (null !== $orderHistoryTable) {
|
37 |
+
//Update the old status to the new status to the length problems in flat_tables
|
38 |
+
$this->run("
|
39 |
+
UPDATE {$this->getTable($orderHistoryTable)}
|
40 |
+
SET status = 'waiting_auth_computop_note'
|
41 |
+
WHERE
|
42 |
+
status LIKE '$waitingAuth%';
|
43 |
+
|
44 |
+
UPDATE {$this->getTable($orderHistoryTable)}
|
45 |
+
SET status = 'waiting_capture_computop_note'
|
46 |
+
WHERE
|
47 |
+
status LIKE '$waitingCapture%';
|
48 |
+
|
49 |
+
UPDATE {$this->getTable($orderHistoryTable)}
|
50 |
+
SET status = 'ready_computop_capture'
|
51 |
+
WHERE
|
52 |
+
status LIKE '$captureReady%';
|
53 |
+
");
|
54 |
+
} else {
|
55 |
+
/* @var $attributeModel Mage_Eav_Model_Config */
|
56 |
+
$attributeModel = Mage::getModel('eav/config');
|
57 |
+
$statusAttribute = $attributeModel->getAttribute('order_status_history', 'status');
|
58 |
+
|
59 |
+
if ($statusAttribute) {
|
60 |
+
//Get the data we need for the update
|
61 |
+
$statusEntityTypeId = $statusAttribute->getEntityTypeId();
|
62 |
+
$statusAttributeId = $statusAttribute->getAttributeId();
|
63 |
+
|
64 |
+
$this->run("
|
65 |
+
UPDATE {$statusAttribute->getBackendTable()}
|
66 |
+
SET value = 'waiting_auth_computop_note'
|
67 |
+
WHERE
|
68 |
+
value LIKE '$waitingAuth%' AND entity_type_id = $statusEntityTypeId AND attribute_id = $statusAttributeId;
|
69 |
+
|
70 |
+
UPDATE {$statusAttribute->getBackendTable()}
|
71 |
+
SET value = 'waiting_capture_computop_note'
|
72 |
+
WHERE
|
73 |
+
value LIKE '$waitingCapture%' AND entity_type_id = $statusEntityTypeId AND attribute_id = $statusAttributeId;
|
74 |
+
|
75 |
+
UPDATE {$statusAttribute->getBackendTable()}
|
76 |
+
SET value = 'ready_computop_capture'
|
77 |
+
WHERE
|
78 |
+
value LIKE '$captureReady%' AND entity_type_id = $statusEntityTypeId AND attribute_id = $statusAttributeId;
|
79 |
+
");
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->endSetup();
|
app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.2-1.4.1.1.3.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Dotsource_Computop_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("ALTER TABLE `{$this->getTable('computop_transaction')}` CHANGE `transaction_code` `transaction_code` VARCHAR(50) NOT NULL");
|
6 |
+
$this->run("ALTER TABLE `{$this->getTable('computop_transaction')}` ADD UNIQUE (`transaction_code`)");
|
7 |
+
|
8 |
+
$this->endSetup();
|
app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.3-1.4.1.1.4.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Dotsource_Computop_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("ALTER TABLE `{$this->getTable('computop_transaction')}` CHANGE `entity_id` `entity_id` INT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT;");
|
6 |
+
$this->run("ALTER TABLE `{$this->getTable('computop_transaction')}` DROP `transaction_code`;");
|
7 |
+
|
8 |
+
$this->endSetup();
|
app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.4-1.4.1.1.5.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Dotsource_Computop_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
//Add the Grid attribute for the transaction refnr
|
6 |
+
$this->addFlatGridAttribute('order', 'computop_transaction_id', array('type' => 'int'));
|
7 |
+
|
8 |
+
$this->endSetup();
|
app/code/community/Dotsource/Dsrevision/Block/Adminhtml/System/Revision.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 16.08.2010 14:52:11
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* aherold - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Dotsource_Dsrevision_Block_Adminhtml_System_Revision extends Mage_Adminhtml_Block_System_Config_Form_Field
|
15 |
+
{
|
16 |
+
const DEPLOY_REVISION_FILENAME = 'DEPLOYED_REVISION';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Return a string for the Backend Field
|
20 |
+
*
|
21 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
22 |
+
*/
|
23 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
24 |
+
{
|
25 |
+
$revision = $this->getRevisionId();
|
26 |
+
|
27 |
+
if (!$revision) {
|
28 |
+
return 'No Revision found!';
|
29 |
+
} else {
|
30 |
+
return $revision;
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->getRevisionId();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get the revision Id of the highest Filename
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function getRevisionId()
|
42 |
+
{
|
43 |
+
try {
|
44 |
+
//Get all Files with the right name in an array
|
45 |
+
$files = glob(Mage::getBaseDir() . DS . self::DEPLOY_REVISION_FILENAME);
|
46 |
+
//get only the last file
|
47 |
+
$lastRev = end($files);
|
48 |
+
$content = file_get_contents($lastRev);
|
49 |
+
|
50 |
+
$matches = array();
|
51 |
+
//match to all numbers over 5 signs
|
52 |
+
preg_match('/\d{5,}/', $content, $matches);
|
53 |
+
|
54 |
+
return $matches[0];
|
55 |
+
|
56 |
+
} catch (Exception $e) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Dotsource/Dsrevision/etc/config.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
**************************************************************************
|
4 |
+
*
|
5 |
+
* XML erstellt von / created by:
|
6 |
+
*
|
7 |
+
* dotSource GmbH
|
8 |
+
* http://www.dotsource.de
|
9 |
+
*
|
10 |
+
**************************************************************************
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<Dotsource_Dsrevision>
|
15 |
+
<version>0.1.0</version>
|
16 |
+
</Dotsource_Dsrevision>
|
17 |
+
</modules>
|
18 |
+
<global>
|
19 |
+
<blocks>
|
20 |
+
<dsrevision>
|
21 |
+
<class>Dotsource_Dsrevision_Block</class>
|
22 |
+
</dsrevision>
|
23 |
+
</blocks>
|
24 |
+
</global>
|
25 |
+
</config>
|
app/code/community/Dotsource/Dsrevision/etc/system.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
**************************************************************************
|
4 |
+
*
|
5 |
+
* XML erstellt von / created by:
|
6 |
+
*
|
7 |
+
* dotSource GmbH
|
8 |
+
* http://www.dotsource.de
|
9 |
+
*
|
10 |
+
**************************************************************************
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<sections>
|
14 |
+
<system>
|
15 |
+
<groups>
|
16 |
+
<revision translate="label">
|
17 |
+
<label>Revision</label>
|
18 |
+
<frontend_type>text</frontend_type>
|
19 |
+
<sort_order>300</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>0</show_in_website>
|
22 |
+
<show_in_store>0</show_in_store>
|
23 |
+
<fields>
|
24 |
+
<current_revision translate="label">
|
25 |
+
<label>Current Revision</label>
|
26 |
+
<frontend_type>label</frontend_type>
|
27 |
+
<frontend_model>dsrevision/adminhtml_system_revision</frontend_model>
|
28 |
+
<sort_order>3</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>0</show_in_website>
|
31 |
+
<show_in_store>0</show_in_store>
|
32 |
+
</current_revision>
|
33 |
+
</fields>
|
34 |
+
</revision>
|
35 |
+
</groups>
|
36 |
+
</system>
|
37 |
+
</sections>
|
38 |
+
</config>
|
app/code/community/Mage/Sales/Model/Order/Payment-1.4.0.X.php
ADDED
@@ -0,0 +1,964 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Sales
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Order payment information
|
29 |
+
*/
|
30 |
+
class Mage_Sales_Model_Order_Payment extends Mage_Payment_Model_Info
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Order model object
|
34 |
+
*
|
35 |
+
* @var Mage_Sales_Model_Order
|
36 |
+
*/
|
37 |
+
protected $_order;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Whether can void
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $_canVoidLookup = null;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Transactions registry to spare resource calls
|
47 |
+
* array(txn_id => sales/order_payment_transaction)
|
48 |
+
* @var array
|
49 |
+
*/
|
50 |
+
protected $_transactionsLookup = array();
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Transaction addditional information container
|
54 |
+
*
|
55 |
+
* @var array
|
56 |
+
*/
|
57 |
+
protected $_transactionAdditionalInfo = array();
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Initialize resource model
|
61 |
+
*/
|
62 |
+
protected function _construct()
|
63 |
+
{
|
64 |
+
$this->_init('sales/order_payment');
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Declare order model object
|
69 |
+
*
|
70 |
+
* @param Mage_Sales_Model_Order $order
|
71 |
+
* @return Mage_Sales_Model_Order_Payment
|
72 |
+
*/
|
73 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
74 |
+
{
|
75 |
+
$this->_order = $order;
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Retrieve order model object
|
81 |
+
*
|
82 |
+
* @return Mage_Sales_Model_Order
|
83 |
+
*/
|
84 |
+
public function getOrder()
|
85 |
+
{
|
86 |
+
return $this->_order;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check order payment capture action availability
|
91 |
+
*
|
92 |
+
* @return unknown
|
93 |
+
*/
|
94 |
+
public function canCapture()
|
95 |
+
{
|
96 |
+
/**
|
97 |
+
* Check Authoriztion transaction state
|
98 |
+
*/
|
99 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
100 |
+
if ($authTransaction) {
|
101 |
+
return !$authTransaction->getIsClosed();
|
102 |
+
}
|
103 |
+
return $this->getMethodInstance()->canCapture();
|
104 |
+
}
|
105 |
+
|
106 |
+
public function canRefund()
|
107 |
+
{
|
108 |
+
return $this->getMethodInstance()->canRefund();
|
109 |
+
}
|
110 |
+
|
111 |
+
public function canRefundPartialPerInvoice()
|
112 |
+
{
|
113 |
+
return $this->getMethodInstance()->canRefundPartialPerInvoice();
|
114 |
+
}
|
115 |
+
|
116 |
+
public function canCapturePartial()
|
117 |
+
{
|
118 |
+
return $this->getMethodInstance()->canCapturePartial();
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Authorize or authorize and capture payment on gateway, if applicable
|
123 |
+
* This method is supposed to be called only when order is placed
|
124 |
+
*
|
125 |
+
* @return Mage_Sales_Model_Order_Payment
|
126 |
+
*/
|
127 |
+
public function place()
|
128 |
+
{
|
129 |
+
Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
|
130 |
+
$order = $this->getOrder();
|
131 |
+
|
132 |
+
$this->setAmountOrdered($order->getTotalDue());
|
133 |
+
$this->setBaseAmountOrdered($order->getBaseTotalDue());
|
134 |
+
$this->setShippingAmount($order->getShippingAmount());
|
135 |
+
$this->setBaseShippingAmount($order->getBaseShippingAmount());
|
136 |
+
|
137 |
+
$methodInstance = $this->getMethodInstance();
|
138 |
+
$methodInstance->setStore($order->getStoreId());
|
139 |
+
|
140 |
+
$orderState = Mage_Sales_Model_Order::STATE_NEW;
|
141 |
+
$orderStatus= false;
|
142 |
+
|
143 |
+
$stateObject = new Varien_Object();
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Do order payment validation on payment method level
|
147 |
+
*/
|
148 |
+
$methodInstance->validate();
|
149 |
+
$action = $methodInstance->getConfigPaymentAction();
|
150 |
+
if ($action) {
|
151 |
+
if ($methodInstance->isInitializeNeeded()) {
|
152 |
+
/**
|
153 |
+
* For method initialization we have to use original config value for payment action
|
154 |
+
*/
|
155 |
+
$methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
|
156 |
+
} else {
|
157 |
+
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
158 |
+
switch ($action) {
|
159 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
|
160 |
+
$this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
|
161 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
162 |
+
break;
|
163 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
|
164 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
165 |
+
$this->setBaseAmountAuthorized($order->getBaseTotalDue());
|
166 |
+
$this->capture(null);
|
167 |
+
break;
|
168 |
+
default:
|
169 |
+
break;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
$orderIsNotified = null;
|
175 |
+
if ($stateObject->getState() && $stateObject->getStatus()) {
|
176 |
+
$orderState = $stateObject->getState();
|
177 |
+
$orderStatus = $stateObject->getStatus();
|
178 |
+
$orderIsNotified = $stateObject->getIsNotified();
|
179 |
+
} else {
|
180 |
+
$orderStatus = $methodInstance->getConfigData('order_status');
|
181 |
+
if (!$orderStatus || $order->getIsVirtual()) {
|
182 |
+
$orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
|
186 |
+
$message = $order->getCustomerNote();
|
187 |
+
|
188 |
+
//add message if order was holded duering authorization or capture
|
189 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
|
190 |
+
if ($message) {
|
191 |
+
$order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
|
192 |
+
}
|
193 |
+
$order->setHoldBeforeState($orderState);
|
194 |
+
$order->setHoldBeforeStatus($orderStatus);
|
195 |
+
}
|
196 |
+
// add message to history if order state already declared
|
197 |
+
elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message)) {
|
198 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
199 |
+
}
|
200 |
+
// set order state
|
201 |
+
elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message) {
|
202 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
203 |
+
}
|
204 |
+
|
205 |
+
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
|
206 |
+
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Capture the payment online
|
212 |
+
* Requires an invoice. If there is no invoice specified, will automatically prepare an invoice for order
|
213 |
+
* Updates transactions hierarchy, if required
|
214 |
+
* Updates payment totals, updates order status and adds proper comments
|
215 |
+
*
|
216 |
+
* @return Mage_Sales_Model_Order_Payment
|
217 |
+
*/
|
218 |
+
public function capture($invoice)
|
219 |
+
{
|
220 |
+
if (is_null($invoice)) {
|
221 |
+
$invoice = $this->_invoice();
|
222 |
+
$this->setCreatedInvoice($invoice);
|
223 |
+
return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
|
224 |
+
}
|
225 |
+
$amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
|
226 |
+
|
227 |
+
$paidWorkaround = 0;
|
228 |
+
if (!$invoice->wasPayCalled()) {
|
229 |
+
$paidWorkaround = (float)$amountToCapture;
|
230 |
+
}
|
231 |
+
$this->_isCaptureFinal($paidWorkaround);
|
232 |
+
$baseTransaction = false;
|
233 |
+
if ($invoice->getTransactionId()) {
|
234 |
+
$baseTransaction = $this->_lookupTransaction($invoice->getTransactionId());
|
235 |
+
} else {
|
236 |
+
$baseTransaction = $this->getAuthorizationTransaction();
|
237 |
+
}
|
238 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $baseTransaction);
|
239 |
+
|
240 |
+
Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
|
241 |
+
|
242 |
+
|
243 |
+
$this->getMethodInstance()
|
244 |
+
->setStore($this->getOrder()->getStoreId())
|
245 |
+
->capture($this, $amountToCapture);
|
246 |
+
|
247 |
+
// update transactions, set order state (order will close itself if required)
|
248 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
|
249 |
+
/**
|
250 |
+
* Check if payment transaction is under pending state.
|
251 |
+
* Gateway can accept peyment transaction but mark it as pending.
|
252 |
+
* We need hold such kind of orders
|
253 |
+
*/
|
254 |
+
if ($this->getIsTransactionPending()) {
|
255 |
+
$message = Mage::helper('sales')->__('Amount of %s pending approval on gateway.', $this->_formatPrice($amountToCapture));
|
256 |
+
$message = $this->_prependMessage($message);
|
257 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
258 |
+
$status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
|
259 |
+
$this->getOrder()->setState(Mage_Sales_Model_Order::STATE_HOLDED, $status, $message);
|
260 |
+
$invoice->setIsPaid(false);
|
261 |
+
} else {
|
262 |
+
$this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
|
263 |
+
$message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
|
264 |
+
$message = $this->_prependMessage($message);
|
265 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
266 |
+
$this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
267 |
+
$invoice->setIsPaid(true);
|
268 |
+
}
|
269 |
+
$this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
|
270 |
+
return $this;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Process a capture notification from a payment gateway for specified amount
|
275 |
+
* Creates an invoice automatically if the amount covers the order base grand total completely
|
276 |
+
* Updates transactions hierarchy, if required
|
277 |
+
* Prevents transaction double processing
|
278 |
+
* Updates payment totals, updates order status and adds proper comments
|
279 |
+
*
|
280 |
+
* @param float $amount
|
281 |
+
* @return Mage_Sales_Model_Order_Payment
|
282 |
+
*/
|
283 |
+
public function registerCaptureNotification($amount)
|
284 |
+
{
|
285 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
|
286 |
+
$this->getAuthorizationTransaction()
|
287 |
+
);
|
288 |
+
$this->_avoidDoubleTransactionProcessing();
|
289 |
+
$order = $this->getOrder();
|
290 |
+
$invoice = null;
|
291 |
+
$amount = (float)$amount;
|
292 |
+
|
293 |
+
// prepare invoice if total paid is going to be equal to order grand total
|
294 |
+
// possible bug: we are not protected from case when order grand total != total authorized
|
295 |
+
if ($this->_isCaptureFinal($amount)) {
|
296 |
+
// ok, we may create an invoice
|
297 |
+
if (!$order->canInvoice()) {
|
298 |
+
Mage::throwException(Mage::helper('sales')->__('Order does not allow to create an invoice.'));
|
299 |
+
}
|
300 |
+
$invoice = $order->prepareInvoice()->register()->pay();
|
301 |
+
$order->addRelatedObject($invoice);
|
302 |
+
$this->setCreatedInvoice($invoice);
|
303 |
+
} else {
|
304 |
+
$this->_updateTotals(array('base_amount_paid_online' => $amount));
|
305 |
+
// shipping captured amount should be updated with the invoice
|
306 |
+
}
|
307 |
+
|
308 |
+
// update transactions, set order state (order will close itself later if required)
|
309 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice);
|
310 |
+
$message = Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatPrice($amount));
|
311 |
+
$message = $this->_prependMessage($message);
|
312 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
313 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
314 |
+
return $this;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Process authorization notification
|
319 |
+
*
|
320 |
+
* @see self::_authorize()
|
321 |
+
* @param float $amount
|
322 |
+
* @return Mage_Sales_Model_Order_Payment
|
323 |
+
*/
|
324 |
+
public function registerAuthorizationNotification($amount)
|
325 |
+
{
|
326 |
+
$this->_avoidDoubleTransactionProcessing();
|
327 |
+
return $this->_authorize(false, $amount);
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Register payment fact: update self totals from the invoice
|
332 |
+
*
|
333 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
334 |
+
* @return Mage_Sales_Model_Order_Payment
|
335 |
+
*/
|
336 |
+
public function pay($invoice)
|
337 |
+
{
|
338 |
+
$this->_updateTotals(array(
|
339 |
+
'amount_paid' => $invoice->getGrandTotal(),
|
340 |
+
'base_amount_paid' => $invoice->getBaseGrandTotal(),
|
341 |
+
'shipping_captured' => $invoice->getShippingAmount(),
|
342 |
+
'base_shipping_captured' => $invoice->getBaseShippingAmount(),
|
343 |
+
));
|
344 |
+
Mage::dispatchEvent('sales_order_payment_pay', array('payment' => $this, 'invoice' => $invoice));
|
345 |
+
return $this;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Cancel specified invoice: update self totals from it
|
350 |
+
*
|
351 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
352 |
+
* @return Mage_Sales_Model_Order_Payment
|
353 |
+
*/
|
354 |
+
public function cancelInvoice($invoice)
|
355 |
+
{
|
356 |
+
$this->_updateTotals(array(
|
357 |
+
'amount_paid' => -1 * $invoice->getGrandTotal(),
|
358 |
+
'base_amount_paid' => -1 * $invoice->getBaseGrandTotal(),
|
359 |
+
'shipping_captured' => -1 * $invoice->getShippingAmount(),
|
360 |
+
'base_shipping_captured' => -1 * $invoice->getBaseShippingAmount(),
|
361 |
+
));
|
362 |
+
Mage::dispatchEvent('sales_order_payment_cancel_invoice', array('payment' => $this, 'invoice' => $invoice));
|
363 |
+
return $this;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Create new invoice with maximum qty for invoice for each item
|
368 |
+
* register this invoice and capture
|
369 |
+
*
|
370 |
+
* @return Mage_Sales_Model_Order_Invoice
|
371 |
+
*/
|
372 |
+
protected function _invoice()
|
373 |
+
{
|
374 |
+
$invoice = $this->getOrder()->prepareInvoice();
|
375 |
+
|
376 |
+
$invoice->register();
|
377 |
+
if ($this->getMethodInstance()->canCapture()) {
|
378 |
+
$invoice->capture();
|
379 |
+
}
|
380 |
+
|
381 |
+
$this->getOrder()->addRelatedObject($invoice);
|
382 |
+
return $invoice;
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Check order payment void availability
|
387 |
+
*
|
388 |
+
* @return bool
|
389 |
+
*/
|
390 |
+
public function canVoid(Varien_Object $document)
|
391 |
+
{
|
392 |
+
if (null === $this->_canVoidLookup) {
|
393 |
+
$this->_canVoidLookup = (bool)$this->getMethodInstance()->canVoid($document);
|
394 |
+
if ($this->_canVoidLookup) {
|
395 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
396 |
+
$this->_canVoidLookup = (bool)$authTransaction && !(int)$authTransaction->getIsClosed();
|
397 |
+
}
|
398 |
+
}
|
399 |
+
return $this->_canVoidLookup;
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Void payment online
|
404 |
+
*
|
405 |
+
* @see self::_void()
|
406 |
+
* @param Varien_Object $document
|
407 |
+
* @return Mage_Sales_Model_Order_Payment
|
408 |
+
*/
|
409 |
+
public function void(Varien_Object $document)
|
410 |
+
{
|
411 |
+
$this->_void(true);
|
412 |
+
Mage::dispatchEvent('sales_order_payment_void', array('payment' => $this, 'invoice' => $document));
|
413 |
+
return $this;
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Process void notification
|
418 |
+
*
|
419 |
+
* @see self::_void()
|
420 |
+
* @param float $amount
|
421 |
+
* @return Mage_Sales_Model_Payment
|
422 |
+
*/
|
423 |
+
public function registerVoidNotification($amount = null)
|
424 |
+
{
|
425 |
+
if (!$this->hasMessage()) {
|
426 |
+
$this->setMessage(Mage::helper('sales')->__('Registered a Void notification.'));
|
427 |
+
}
|
428 |
+
return $this->_void(false, $amount);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Refund payment online or offline, depending on whether there is invoice set in the creditmemo instance
|
433 |
+
* Updates transactions hierarchy, if required
|
434 |
+
* Updates payment totals, updates order status and adds proper comments
|
435 |
+
*
|
436 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
437 |
+
* @return Mage_Sales_Model_Order_Payment
|
438 |
+
*/
|
439 |
+
public function refund($creditmemo)
|
440 |
+
{
|
441 |
+
$baseAmountToRefund = $this->_formatAmount($creditmemo->getBaseGrandTotal());
|
442 |
+
$order = $this->getOrder();
|
443 |
+
|
444 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
445 |
+
|
446 |
+
// call refund from gateway if required
|
447 |
+
$isOnline = false;
|
448 |
+
$gateway = $this->getMethodInstance();
|
449 |
+
$invoice = null;
|
450 |
+
if ($gateway->canRefund() && $creditmemo->getDoTransaction()) {
|
451 |
+
$this->setCreditmemo($creditmemo);
|
452 |
+
$invoice = $creditmemo->getInvoice();
|
453 |
+
if ($invoice) {
|
454 |
+
$isOnline = true;
|
455 |
+
$captureTxn = $this->_lookupTransaction($invoice->getTransactionId());
|
456 |
+
if ($captureTxn) {
|
457 |
+
$this->setParentTransactionId($captureTxn->getTxnId());
|
458 |
+
}
|
459 |
+
$this->setShouldCloseParentTransaction(true); // TODO: implement multiple refunds per capture
|
460 |
+
try {
|
461 |
+
$gateway->setStore($this->getOrder()->getStoreId())
|
462 |
+
->processBeforeRefund($invoice, $this)
|
463 |
+
->refund($this, $baseAmountToRefund)
|
464 |
+
->processCreditmemo($creditmemo, $this)
|
465 |
+
;
|
466 |
+
} catch (Mage_Core_Exception $e) {
|
467 |
+
if (!$captureTxn) {
|
468 |
+
$e->setMessage(' ' . Mage::helper('sales')->__('If the invoice was created offline, try creating an offline creditmemo.'), true);
|
469 |
+
}
|
470 |
+
throw $e;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
// update self totals from creditmemo
|
476 |
+
$this->_updateTotals(array(
|
477 |
+
'amount_refunded' => $creditmemo->getGrandTotal(),
|
478 |
+
'base_amount_refunded' => $baseAmountToRefund,
|
479 |
+
'base_amount_refunded_online' => $isOnline ? $baseAmountToRefund : null,
|
480 |
+
'shipping_refunded' => $creditmemo->getShippingAmount(),
|
481 |
+
'base_shipping_refunded' => $creditmemo->getBaseShippingAmount(),
|
482 |
+
));
|
483 |
+
|
484 |
+
// update transactions and order state
|
485 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo, $isOnline);
|
486 |
+
if ($invoice) {
|
487 |
+
$message = Mage::helper('sales')->__('Refunded amount of %s online.', $this->_formatPrice($baseAmountToRefund));
|
488 |
+
} else {
|
489 |
+
$message = $this->hasMessage() ? $this->getMessage()
|
490 |
+
: Mage::helper('sales')->__('Refunded amount of %s offline.', $this->_formatPrice($baseAmountToRefund));
|
491 |
+
}
|
492 |
+
$message = $message = $this->_prependMessage($message);
|
493 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
494 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
495 |
+
|
496 |
+
Mage::dispatchEvent('sales_order_payment_refund', array('payment' => $this, 'creditmemo' => $creditmemo));
|
497 |
+
return $this;
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Process payment refund notification
|
502 |
+
* Updates transactions hierarchy, if required
|
503 |
+
* Prevents transaction double processing
|
504 |
+
* Updates payment totals, updates order status and adds proper comments
|
505 |
+
* TODO: potentially a full capture can be refunded. In this case if there was only one invoice for that transaction
|
506 |
+
* then we should create a creditmemo from invoice and also refund it offline
|
507 |
+
*
|
508 |
+
* @param float $amount
|
509 |
+
* @return Mage_Sales_Model_Order_Payment
|
510 |
+
*/
|
511 |
+
public function registerRefundNotification($amount)
|
512 |
+
{
|
513 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
|
514 |
+
$this->_lookupTransaction($this->getParentTransactionId())
|
515 |
+
);
|
516 |
+
$this->_avoidDoubleTransactionProcessing();
|
517 |
+
$order = $this->getOrder();
|
518 |
+
|
519 |
+
// create an offline creditmemo (from order), if the entire grand total of order is covered by this refund
|
520 |
+
$creditmemo = null;
|
521 |
+
if ($amount == $order->getBaseGrandTotal()) {
|
522 |
+
/*
|
523 |
+
$creditmemo = $order->prepareCreditmemo()->register()->refund();
|
524 |
+
$this->_updateTotals(array(
|
525 |
+
'amount_refunded' => $creditmemo->getGrandTotal(),
|
526 |
+
'shipping_refunded' => $creditmemo->getShippingRefunded(),
|
527 |
+
'base_shipping_refunded' => $creditmemo->getBaseShippingRefunded()
|
528 |
+
));
|
529 |
+
$order->addRelatedObject($creditmemo);
|
530 |
+
$this->setCreatedCreditmemo($creditmemo);
|
531 |
+
*/
|
532 |
+
}
|
533 |
+
$this->_updateTotals(array('base_amount_refunded_online' => $amount));
|
534 |
+
|
535 |
+
// update transactions and order state
|
536 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo);
|
537 |
+
$message = $this->_prependMessage(
|
538 |
+
Mage::helper('sales')->__('Registered notification about refunded amount of %s.', $this->_formatPrice($amount))
|
539 |
+
);
|
540 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
541 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
542 |
+
return $this;
|
543 |
+
}
|
544 |
+
|
545 |
+
/**
|
546 |
+
* Cancel a creditmemo: substract its totals from the payment
|
547 |
+
*
|
548 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
549 |
+
* @return Mage_Sales_Model_Order_Payment
|
550 |
+
*/
|
551 |
+
public function cancelCreditmemo($creditmemo)
|
552 |
+
{
|
553 |
+
$this->_updateTotals(array(
|
554 |
+
'amount_refunded' => -1 * $creditmemo->getGrandTotal(),
|
555 |
+
'base_amount_refunded' => -1 * $creditmemo->getBaseGrandTotal(),
|
556 |
+
'shipping_refunded' => -1 * $creditmemo->getShippingAmount(),
|
557 |
+
'base_shipping_refunded' => -1 * $creditmemo->getBaseShippingAmount()
|
558 |
+
));
|
559 |
+
Mage::dispatchEvent('sales_order_payment_cancel_creditmemo',
|
560 |
+
array('payment' => $this, 'creditmemo' => $creditmemo)
|
561 |
+
);
|
562 |
+
return $this;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Order cancellation hook for payment method instance
|
567 |
+
* Adds void transaction if needed
|
568 |
+
* @return Mage_Sales_Model_Order_Payment
|
569 |
+
*/
|
570 |
+
public function cancel()
|
571 |
+
{
|
572 |
+
$isOnline = true;
|
573 |
+
if (!$this->canVoid(new Varien_Object())) {
|
574 |
+
$isOnline = false;
|
575 |
+
}
|
576 |
+
|
577 |
+
if (!$this->hasMessage()) {
|
578 |
+
$this->setMessage($isOnline ? Mage::helper('sales')->__('Cancelled order online.')
|
579 |
+
: Mage::helper('sales')->__('Cancelled order offline.')
|
580 |
+
);
|
581 |
+
}
|
582 |
+
$this->_void($isOnline, null, 'cancel');
|
583 |
+
|
584 |
+
Mage::dispatchEvent('sales_order_payment_cancel', array('payment' => $this));
|
585 |
+
|
586 |
+
return $this;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Authorize payment either online or offline (process auth notification)
|
591 |
+
* Updates transactions hierarchy, if required
|
592 |
+
* Prevents transaction double processing
|
593 |
+
* Updates payment totals, updates order status and adds proper comments
|
594 |
+
*
|
595 |
+
* @param bool $isOnline
|
596 |
+
* @param float $amount
|
597 |
+
* @return Mage_Sales_Model_Order_Payment
|
598 |
+
*/
|
599 |
+
protected function _authorize($isOnline, $amount)
|
600 |
+
{
|
601 |
+
// update totals
|
602 |
+
$amount = $this->_formatAmount($amount, true);
|
603 |
+
$this->setBaseAmountAuthorized($amount);
|
604 |
+
|
605 |
+
// do authorization
|
606 |
+
$order = $this->getOrder();
|
607 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
608 |
+
$status = true;
|
609 |
+
if ($isOnline) {
|
610 |
+
$this->getMethodInstance()
|
611 |
+
->setStore($order->getStoreId())
|
612 |
+
->authorize($this, $amount);
|
613 |
+
if ($this->getIsTransactionPending()) {
|
614 |
+
$status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
|
615 |
+
$state = Mage_Sales_Model_Order::STATE_HOLDED;
|
616 |
+
$message = Mage::helper('sales')->__('Authorization amount %s pending approval on gateway.', $this->_formatPrice($amount));
|
617 |
+
} else {
|
618 |
+
$message = Mage::helper('sales')->__('Authorized amount of %s.', $this->_formatPrice($amount));
|
619 |
+
}
|
620 |
+
} else {
|
621 |
+
$message = Mage::helper('sales')->__('Registered notification about authorized amount of %s.', $this->_formatPrice($amount));
|
622 |
+
}
|
623 |
+
|
624 |
+
// update transactions, order state and add comments
|
625 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
626 |
+
$message = $this->_prependMessage($message);
|
627 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
628 |
+
$order->setState($state, $status, $message);
|
629 |
+
|
630 |
+
return $this;
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Void payment either online or offline (process void notification)
|
635 |
+
* NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use
|
636 |
+
* the amount void amount, for informational purposes.
|
637 |
+
* Updates payment totals, updates order status and adds proper comments
|
638 |
+
*
|
639 |
+
* @param bool $isOnline
|
640 |
+
* @param float $amount
|
641 |
+
* @param string $gatewayCallback
|
642 |
+
* @return Mage_Sales_Model_Order_Payment
|
643 |
+
*/
|
644 |
+
protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
|
645 |
+
{
|
646 |
+
$order = $this->getOrder();
|
647 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
648 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, $authTransaction);
|
649 |
+
$this->setShouldCloseParentTransaction(true);
|
650 |
+
|
651 |
+
// attempt to void
|
652 |
+
if ($isOnline) {
|
653 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->$gatewayCallback($this);
|
654 |
+
} else {
|
655 |
+
$this->_avoidDoubleTransactionProcessing();
|
656 |
+
}
|
657 |
+
|
658 |
+
// if the authorization was untouched, we may assume voided amount = order grand total
|
659 |
+
// but only if the payment auth amount equals to order grand total
|
660 |
+
if ($authTransaction && ($order->getBaseGrandTotal() == $this->getBaseAmountAuthorized())
|
661 |
+
&& (0 == $this->getBaseAmountCanceled())) {
|
662 |
+
if ($authTransaction->canVoidAuthorizationCompletely()) {
|
663 |
+
$amount = (float)$order->getBaseGrandTotal();
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
if ($amount) {
|
668 |
+
$amount = $this->_formatAmount($amount);
|
669 |
+
}
|
670 |
+
|
671 |
+
// update transactions, order state and add comments
|
672 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
|
673 |
+
$message = $this->hasMessage() ? $this->getMessage() : Mage::helper('sales')->__('Voided authorization.');
|
674 |
+
$message = $this->_prependMessage($message);
|
675 |
+
if ($amount) {
|
676 |
+
$message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $this->_formatPrice($amount));
|
677 |
+
}
|
678 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
679 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
680 |
+
return $this;
|
681 |
+
}
|
682 |
+
|
683 |
+
// /**
|
684 |
+
// * TODO: implement this
|
685 |
+
// * @param Mage_Sales_Model_Order_Invoice $invoice
|
686 |
+
// * @return Mage_Sales_Model_Order_Payment
|
687 |
+
// */
|
688 |
+
// public function cancelCapture($invoice = null)
|
689 |
+
// {
|
690 |
+
// }
|
691 |
+
|
692 |
+
/**
|
693 |
+
* Create transaction, prepare its insertion into hierarchy and add its information to payment and comments
|
694 |
+
*
|
695 |
+
* To add transactions and related information, the following information should be set to payment before processing:
|
696 |
+
* - transaction_id
|
697 |
+
* - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
|
698 |
+
* - parent_transaction_id (optional)
|
699 |
+
* - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
|
700 |
+
*
|
701 |
+
* If the sales document is specified, it will be linked to the transaction as related for future usage.
|
702 |
+
* Currently transaction ID is set into the sales object
|
703 |
+
* This method writes the added transaction ID into last_trans_id field of the payment object
|
704 |
+
*
|
705 |
+
* To make sure transaction object won't cause trouble before saving, use $failsafe = true
|
706 |
+
*
|
707 |
+
* @param string $type
|
708 |
+
* @param Mage_Sales_Model_Abstract $salesDocument
|
709 |
+
* @param bool $failsafe
|
710 |
+
* @return null|Mage_Sales_Model_Order_Payment_Transaction
|
711 |
+
*/
|
712 |
+
protected function _addTransaction($type, $salesDocument = null, $failsafe = false)
|
713 |
+
{
|
714 |
+
// look for set transaction ids
|
715 |
+
$transactionId = $this->getTransactionId();
|
716 |
+
if (null !== $transactionId) {
|
717 |
+
// set transaction parameters
|
718 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
719 |
+
->setOrderPaymentObject($this)
|
720 |
+
->setTxnType($type)
|
721 |
+
->setTxnId($transactionId)
|
722 |
+
->isFailsafe($failsafe)
|
723 |
+
;
|
724 |
+
if ($this->hasIsTransactionClosed()) {
|
725 |
+
$transaction->setIsClosed((int)$this->getIsTransactionClosed());
|
726 |
+
}
|
727 |
+
|
728 |
+
//set transaction addition information
|
729 |
+
if ($this->_transactionAdditionalInfo) {
|
730 |
+
foreach ($this->_transactionAdditionalInfo as $key => $value) {
|
731 |
+
$transaction->setAdditionalInformation($key, $value);
|
732 |
+
}
|
733 |
+
}
|
734 |
+
|
735 |
+
// link with sales entities
|
736 |
+
$this->setLastTransId($transactionId);
|
737 |
+
$this->setCreatedTransaction($transaction);
|
738 |
+
$this->getOrder()->addRelatedObject($transaction);
|
739 |
+
if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
|
740 |
+
$salesDocument->setTransactionId($transactionId);
|
741 |
+
// TODO: linking transaction with the sales document
|
742 |
+
}
|
743 |
+
|
744 |
+
// link with parent transaction
|
745 |
+
$parentTransactionId = $this->getParentTransactionId();
|
746 |
+
|
747 |
+
if ($parentTransactionId) {
|
748 |
+
$transaction->setParentTxnId($parentTransactionId);
|
749 |
+
if ($this->getShouldCloseParentTransaction()) {
|
750 |
+
$parentTransaction = $this->_lookupTransaction($parentTransactionId);
|
751 |
+
if ($parentTransaction) {
|
752 |
+
$parentTransaction->isFailsafe($failsafe)->close(false);
|
753 |
+
$this->getOrder()->addRelatedObject($parentTransaction);
|
754 |
+
}
|
755 |
+
}
|
756 |
+
}
|
757 |
+
return $transaction;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
|
761 |
+
/**
|
762 |
+
* Totals updater utility method
|
763 |
+
* Updates self totals by keys in data array('key' => $delta)
|
764 |
+
*
|
765 |
+
* @param array $data
|
766 |
+
*/
|
767 |
+
protected function _updateTotals($data)
|
768 |
+
{
|
769 |
+
foreach ($data as $key => $amount) {
|
770 |
+
if (null !== $amount) {
|
771 |
+
$was = $this->getDataUsingMethod($key);
|
772 |
+
$this->setDataUsingMethod($key, $was + $amount);
|
773 |
+
}
|
774 |
+
}
|
775 |
+
}
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Prevent double processing of the same transaction by a payment notification
|
779 |
+
* Uses either specified txn_id or the transaction id that was set before
|
780 |
+
*
|
781 |
+
* @param string $txnId
|
782 |
+
* @throws Mage_Core_Exception
|
783 |
+
*/
|
784 |
+
protected function _avoidDoubleTransactionProcessing($txnId = null)
|
785 |
+
{
|
786 |
+
if (null === $txnId) {
|
787 |
+
$txnId = $this->getTransactionId();
|
788 |
+
}
|
789 |
+
if ($txnId) {
|
790 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
791 |
+
->setOrderPaymentObject($this)
|
792 |
+
->loadByTxnId($txnId);
|
793 |
+
if ($transaction->getId()) {
|
794 |
+
Mage::throwException(
|
795 |
+
Mage::helper('sales')->__('Transaction "%s" was already processed.', $transaction->getTxnId())
|
796 |
+
);
|
797 |
+
}
|
798 |
+
}
|
799 |
+
}
|
800 |
+
|
801 |
+
/**
|
802 |
+
* Append transaction ID (if any) message to the specified message
|
803 |
+
*
|
804 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction|null $transaction
|
805 |
+
* @param string $message
|
806 |
+
* @return string
|
807 |
+
*/
|
808 |
+
protected function _appendTransactionToMessage($transaction, $message)
|
809 |
+
{
|
810 |
+
if ($transaction) {
|
811 |
+
$message .= ' ' . Mage::helper('sales')->__('Transaction ID: "%s".', $transaction->getTxnId());
|
812 |
+
}
|
813 |
+
return $message;
|
814 |
+
}
|
815 |
+
|
816 |
+
/**
|
817 |
+
* Prepend a "prepared_message" that may be set to the payment instance before, to the specified message
|
818 |
+
* Prepends value to the specified string or to the comment of specified order status history item instance
|
819 |
+
*
|
820 |
+
* @param string|Mage_Sales_Model_Order_Status_History $messagePrependTo
|
821 |
+
* @return string|Mage_Sales_Model_Order_Status_History
|
822 |
+
*/
|
823 |
+
protected function _prependMessage($messagePrependTo)
|
824 |
+
{
|
825 |
+
$preparedMessage = $this->getPreparedMessage();
|
826 |
+
if ($preparedMessage) {
|
827 |
+
if (is_string($preparedMessage)) {
|
828 |
+
return $preparedMessage . ' ' . $messagePrependTo;
|
829 |
+
}
|
830 |
+
elseif (is_object($preparedMessage) && ($preparedMessage instanceof Mage_Sales_Model_Order_Status_History)) {
|
831 |
+
$comment = $preparedMessage->getComment() . ' ' . $messagePrependTo;
|
832 |
+
$preparedMessage->setComment($comment);
|
833 |
+
return $comment;
|
834 |
+
}
|
835 |
+
}
|
836 |
+
return $messagePrependTo;
|
837 |
+
}
|
838 |
+
|
839 |
+
/**
|
840 |
+
* Round up and cast specified amount to float or string
|
841 |
+
*
|
842 |
+
* @param string|float $amount
|
843 |
+
* @param bool $asFloat
|
844 |
+
* @return string|float
|
845 |
+
*/
|
846 |
+
protected function _formatAmount($amount, $asFloat = false)
|
847 |
+
{
|
848 |
+
$amount = sprintf('%.2F', $amount); // "f" depends on locale, "F" doesn't
|
849 |
+
return $asFloat ? (float)$amount : $amount;
|
850 |
+
}
|
851 |
+
|
852 |
+
/**
|
853 |
+
* Format price with currency sign
|
854 |
+
* @param float $amount
|
855 |
+
* @return string
|
856 |
+
*/
|
857 |
+
protected function _formatPrice($amount)
|
858 |
+
{
|
859 |
+
return $this->getOrder()->getBaseCurrency()->formatTxt($amount);
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Find one transaction by ID or type
|
864 |
+
* @param string $txnId
|
865 |
+
* @param string $txnType
|
866 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
867 |
+
*/
|
868 |
+
protected function _lookupTransaction($txnId, $txnType = false)
|
869 |
+
{
|
870 |
+
if (!$txnId) {
|
871 |
+
if ($txnType && $this->getId()) {
|
872 |
+
$collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
|
873 |
+
->addPaymentIdFilter($this->getId())
|
874 |
+
->addTxnTypeFilter($txnType);
|
875 |
+
foreach ($collection as $txn) {
|
876 |
+
$txn->setOrderPaymentObject($this);
|
877 |
+
$this->_transactionsLookup[$txn->getTxnId()] = $txn;
|
878 |
+
return $txn;
|
879 |
+
}
|
880 |
+
}
|
881 |
+
return false;
|
882 |
+
}
|
883 |
+
if (isset($this->_transactionsLookup[$txnId])) {
|
884 |
+
return $this->_transactionsLookup[$txnId];
|
885 |
+
}
|
886 |
+
$txn = Mage::getModel('sales/order_payment_transaction')
|
887 |
+
->setOrderPaymentObject($this)
|
888 |
+
->loadByTxnId($txnId);
|
889 |
+
if ($txn->getId()) {
|
890 |
+
$this->_transactionsLookup[$txnId] = $txn;
|
891 |
+
} else {
|
892 |
+
$this->_transactionsLookup[$txnId] = false;
|
893 |
+
}
|
894 |
+
return $this->_transactionsLookup[$txnId];
|
895 |
+
}
|
896 |
+
|
897 |
+
/**
|
898 |
+
* Lookup an authorization transaction using parent transaction id, if set
|
899 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
900 |
+
*/
|
901 |
+
public function getAuthorizationTransaction()
|
902 |
+
{
|
903 |
+
$txn = $this->_lookupTransaction($this->getParentTransactionId());
|
904 |
+
if (!$txn) {
|
905 |
+
$txn = $this->_lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
906 |
+
}
|
907 |
+
return $txn;
|
908 |
+
}
|
909 |
+
|
910 |
+
/**
|
911 |
+
* Lookup an transaction by id
|
912 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
913 |
+
*/
|
914 |
+
public function getTransaction($transaction_id)
|
915 |
+
{
|
916 |
+
return $this->_lookupTransaction($transaction_id);
|
917 |
+
}
|
918 |
+
|
919 |
+
/**
|
920 |
+
* Update transaction ids for further processing
|
921 |
+
* If no transactions were set before invoking, may generate an "offline" transaction id
|
922 |
+
*
|
923 |
+
* @param string $type
|
924 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transactionBasedOn
|
925 |
+
*/
|
926 |
+
protected function _generateTransactionId($type, $transactionBasedOn = false)
|
927 |
+
{
|
928 |
+
if (!$this->getParentTransactionId() && !$this->getTransactionId() && $transactionBasedOn) {
|
929 |
+
$this->setParentTransactionId($transactionBasedOn->getTxnId());
|
930 |
+
}
|
931 |
+
// generate transaction id for an offline action or payment method that didn't set it
|
932 |
+
if (($parentTxnId = $this->getParentTransactionId()) && !$this->getTransactionId()) {
|
933 |
+
$this->setTransactionId("{$parentTxnId}-{$type}");
|
934 |
+
}
|
935 |
+
}
|
936 |
+
|
937 |
+
/**
|
938 |
+
* Decide whether authorization transaction may close (if the amount to capture will cover entire order)
|
939 |
+
* @param float $amountToCapture
|
940 |
+
* @return bool
|
941 |
+
*/
|
942 |
+
protected function _isCaptureFinal($amountToCapture)
|
943 |
+
{
|
944 |
+
if ((float)$this->getOrder()->getBaseGrandTotal() ===
|
945 |
+
((float)$this->getBaseAmountPaidOnline() + $amountToCapture)) {
|
946 |
+
if (false !== $this->getShouldCloseParentTransaction()) {
|
947 |
+
$this->setShouldCloseParentTransaction(true);
|
948 |
+
}
|
949 |
+
return true;
|
950 |
+
}
|
951 |
+
return false;
|
952 |
+
}
|
953 |
+
|
954 |
+
/**
|
955 |
+
* Additionnal transaction info setter
|
956 |
+
*
|
957 |
+
* @param sting $key
|
958 |
+
* @param string $value
|
959 |
+
*/
|
960 |
+
public function setTransactionAdditionalInfo($key, $value)
|
961 |
+
{
|
962 |
+
$this->_transactionAdditionalInfo[$key] = $value;
|
963 |
+
}
|
964 |
+
}
|
app/code/community/Mage/Sales/Model/Order/Payment-1.4.1.X.php
ADDED
@@ -0,0 +1,1294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Sales
|
23 |
+
* @copyright Copyright (c) 2010 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 |
+
* Order payment information
|
29 |
+
*/
|
30 |
+
class Mage_Sales_Model_Order_Payment extends Mage_Payment_Model_Info
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Actions for payment when it triggered review state
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
const REVIEW_ACTION_ACCEPT = 'accept';
|
38 |
+
const REVIEW_ACTION_DENY = 'deny';
|
39 |
+
const REVIEW_ACTION_UPDATE = 'update';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Order model object
|
43 |
+
*
|
44 |
+
* @var Mage_Sales_Model_Order
|
45 |
+
*/
|
46 |
+
protected $_order;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Billing agreement instance that may be created during payment processing
|
50 |
+
*
|
51 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
52 |
+
*/
|
53 |
+
protected $_billingAgreement = null;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Whether can void
|
57 |
+
* @var string
|
58 |
+
*/
|
59 |
+
protected $_canVoidLookup = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Transactions registry to spare resource calls
|
63 |
+
* array(txn_id => sales/order_payment_transaction)
|
64 |
+
* @var array
|
65 |
+
*/
|
66 |
+
protected $_transactionsLookup = array();
|
67 |
+
|
68 |
+
protected $_eventPrefix = 'sales_order_payment';
|
69 |
+
protected $_eventObject = 'payment';
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Transaction addditional information container
|
73 |
+
*
|
74 |
+
* @var array
|
75 |
+
*/
|
76 |
+
protected $_transactionAdditionalInfo = array();
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Initialize resource model
|
80 |
+
*/
|
81 |
+
protected function _construct()
|
82 |
+
{
|
83 |
+
$this->_init('sales/order_payment');
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Declare order model object
|
88 |
+
*
|
89 |
+
* @param Mage_Sales_Model_Order $order
|
90 |
+
* @return Mage_Sales_Model_Order_Payment
|
91 |
+
*/
|
92 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
93 |
+
{
|
94 |
+
$this->_order = $order;
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Retrieve order model object
|
100 |
+
*
|
101 |
+
* @return Mage_Sales_Model_Order
|
102 |
+
*/
|
103 |
+
public function getOrder()
|
104 |
+
{
|
105 |
+
return $this->_order;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Check order payment capture action availability
|
110 |
+
*
|
111 |
+
* @return bool
|
112 |
+
*/
|
113 |
+
public function canCapture()
|
114 |
+
{
|
115 |
+
if (!$this->getMethodInstance()->canCapture()) {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
// Check Authoriztion transaction state
|
119 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
120 |
+
if ($authTransaction && $authTransaction->getIsClosed()) {
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
return true;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function canRefund()
|
127 |
+
{
|
128 |
+
return $this->getMethodInstance()->canRefund();
|
129 |
+
}
|
130 |
+
|
131 |
+
public function canRefundPartialPerInvoice()
|
132 |
+
{
|
133 |
+
return $this->getMethodInstance()->canRefundPartialPerInvoice();
|
134 |
+
}
|
135 |
+
|
136 |
+
public function canCapturePartial()
|
137 |
+
{
|
138 |
+
return $this->getMethodInstance()->canCapturePartial();
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Authorize or authorize and capture payment on gateway, if applicable
|
143 |
+
* This method is supposed to be called only when order is placed
|
144 |
+
*
|
145 |
+
* @return Mage_Sales_Model_Order_Payment
|
146 |
+
*/
|
147 |
+
public function place()
|
148 |
+
{
|
149 |
+
Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
|
150 |
+
$order = $this->getOrder();
|
151 |
+
|
152 |
+
$this->setAmountOrdered($order->getTotalDue());
|
153 |
+
$this->setBaseAmountOrdered($order->getBaseTotalDue());
|
154 |
+
$this->setShippingAmount($order->getShippingAmount());
|
155 |
+
$this->setBaseShippingAmount($order->getBaseShippingAmount());
|
156 |
+
|
157 |
+
$methodInstance = $this->getMethodInstance();
|
158 |
+
$methodInstance->setStore($order->getStoreId());
|
159 |
+
|
160 |
+
$orderState = Mage_Sales_Model_Order::STATE_NEW;
|
161 |
+
$orderStatus= false;
|
162 |
+
|
163 |
+
$stateObject = new Varien_Object();
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Do order payment validation on payment method level
|
167 |
+
*/
|
168 |
+
$methodInstance->validate();
|
169 |
+
$action = $methodInstance->getConfigPaymentAction();
|
170 |
+
if ($action) {
|
171 |
+
if ($methodInstance->isInitializeNeeded()) {
|
172 |
+
/**
|
173 |
+
* For method initialization we have to use original config value for payment action
|
174 |
+
*/
|
175 |
+
$methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
|
176 |
+
} else {
|
177 |
+
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
178 |
+
switch ($action) {
|
179 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
|
180 |
+
$this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
|
181 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
182 |
+
break;
|
183 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
|
184 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
185 |
+
$this->setBaseAmountAuthorized($order->getBaseTotalDue());
|
186 |
+
$this->capture(null);
|
187 |
+
break;
|
188 |
+
default:
|
189 |
+
break;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
$this->_createBillingAgreement();
|
195 |
+
|
196 |
+
$orderIsNotified = null;
|
197 |
+
if ($stateObject->getState() && $stateObject->getStatus()) {
|
198 |
+
$orderState = $stateObject->getState();
|
199 |
+
$orderStatus = $stateObject->getStatus();
|
200 |
+
$orderIsNotified = $stateObject->getIsNotified();
|
201 |
+
} else {
|
202 |
+
$orderStatus = $methodInstance->getConfigData('order_status');
|
203 |
+
if (!$orderStatus || $order->getIsVirtual()) {
|
204 |
+
$orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
$isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
|
208 |
+
$message = $order->getCustomerNote();
|
209 |
+
|
210 |
+
// add message if order was put into review during authorization or capture
|
211 |
+
if ($this->getIsTransactionPending()
|
212 |
+
|| $order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW
|
213 |
+
) {
|
214 |
+
if ($message) {
|
215 |
+
$order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
|
216 |
+
}
|
217 |
+
|
218 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
|
219 |
+
$order->setHoldBeforeState($orderState);
|
220 |
+
$order->setHoldBeforeStatus($orderStatus);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
// add message to history if order state already declared
|
224 |
+
elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message)) {
|
225 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
226 |
+
}
|
227 |
+
// set order state
|
228 |
+
elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message) {
|
229 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
230 |
+
}
|
231 |
+
|
232 |
+
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
|
233 |
+
|
234 |
+
return $this;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Capture the payment online
|
239 |
+
* Requires an invoice. If there is no invoice specified, will automatically prepare an invoice for order
|
240 |
+
* Updates transactions hierarchy, if required
|
241 |
+
* Updates payment totals, updates order status and adds proper comments
|
242 |
+
*
|
243 |
+
* TODO: eliminate logic duplication with registerCaptureNotification()
|
244 |
+
*
|
245 |
+
* @return Mage_Sales_Model_Order_Payment
|
246 |
+
* @throws Mage_Core_Exception
|
247 |
+
*/
|
248 |
+
public function capture($invoice)
|
249 |
+
{
|
250 |
+
if (is_null($invoice)) {
|
251 |
+
$invoice = $this->_invoice();
|
252 |
+
$this->setCreatedInvoice($invoice);
|
253 |
+
return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
|
254 |
+
}
|
255 |
+
$amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
|
256 |
+
$order = $this->getOrder();
|
257 |
+
|
258 |
+
// prepare parent transaction and its amount
|
259 |
+
$paidWorkaround = 0;
|
260 |
+
if (!$invoice->wasPayCalled()) {
|
261 |
+
$paidWorkaround = (float)$amountToCapture;
|
262 |
+
}
|
263 |
+
$this->_isCaptureFinal($paidWorkaround);
|
264 |
+
|
265 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction());
|
266 |
+
|
267 |
+
Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Fetch an update about existing transaction. It can determine whether the transaction can be paid
|
271 |
+
* Capture attempt will happen only when invoice is not yet paid and the transaction can be paid
|
272 |
+
*/
|
273 |
+
if ($invoice->getTransactionId()) {
|
274 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->fetchTransactionInfo($this, $invoice->getTransactionId());
|
275 |
+
}
|
276 |
+
$status = true;
|
277 |
+
if (!$invoice->getIsPaid() && !$this->getIsTransactionPending()) {
|
278 |
+
// attempt to capture: this can trigger "is_transaction_pending"
|
279 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture);
|
280 |
+
|
281 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
|
282 |
+
|
283 |
+
if ($this->getIsTransactionPending()) {
|
284 |
+
$message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amountToCapture));
|
285 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
286 |
+
if ($this->getIsFraudDetected()) {
|
287 |
+
$status = 'fraud';
|
288 |
+
} elseif ($this->getTransactionPendingStatus()) {
|
289 |
+
$state = Mage_Sales_Model_Order::STATE_HOLDED;
|
290 |
+
$status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
|
291 |
+
}
|
292 |
+
$invoice->setIsPaid(false);
|
293 |
+
} else { // normal online capture: invoice is marked as "paid"
|
294 |
+
$message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
|
295 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
296 |
+
$invoice->setIsPaid(true);
|
297 |
+
$this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
|
298 |
+
}
|
299 |
+
if ($order->isNominal()) {
|
300 |
+
$message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
|
301 |
+
} else {
|
302 |
+
$message = $this->_prependMessage($message);
|
303 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
304 |
+
}
|
305 |
+
$order->setState($state, $status, $message);
|
306 |
+
$this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
|
307 |
+
return $this;
|
308 |
+
}
|
309 |
+
Mage::throwException(
|
310 |
+
Mage::helper('sales')->__('The transaction "%s" cannot be captured yet.', $invoice->getTransactionId())
|
311 |
+
);
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Process a capture notification from a payment gateway for specified amount
|
316 |
+
* Creates an invoice automatically if the amount covers the order base grand total completely
|
317 |
+
* Updates transactions hierarchy, if required
|
318 |
+
* Prevents transaction double processing
|
319 |
+
* Updates payment totals, updates order status and adds proper comments
|
320 |
+
*
|
321 |
+
* TODO: eliminate logic duplication with capture()
|
322 |
+
*
|
323 |
+
* @param float $amount
|
324 |
+
* @return Mage_Sales_Model_Order_Payment
|
325 |
+
*/
|
326 |
+
public function registerCaptureNotification($amount)
|
327 |
+
{
|
328 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
|
329 |
+
$this->getAuthorizationTransaction()
|
330 |
+
);
|
331 |
+
|
332 |
+
$order = $this->getOrder();
|
333 |
+
$amount = (float)$amount;
|
334 |
+
$invoice = $this->_getInvoiceForTransactionId($this->getTransactionId());
|
335 |
+
|
336 |
+
// register new capture
|
337 |
+
if (!$invoice) {
|
338 |
+
if ($this->_isCaptureFinal($amount)) {
|
339 |
+
$invoice = $order->prepareInvoice()->register();
|
340 |
+
$order->addRelatedObject($invoice);
|
341 |
+
$this->setCreatedInvoice($invoice);
|
342 |
+
} else {
|
343 |
+
$this->_updateTotals(array('base_amount_paid_online' => $amount));
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
$status = true;
|
348 |
+
if ($this->getIsTransactionPending()) {
|
349 |
+
$message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amount));
|
350 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
351 |
+
if ($this->getIsFraudDetected()) {
|
352 |
+
$status = 'fraud';
|
353 |
+
} elseif ($this->getTransactionPendingStatus()) {
|
354 |
+
$state = Mage_Sales_Model_Order::STATE_HOLDED;
|
355 |
+
$status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
|
356 |
+
}
|
357 |
+
} else {
|
358 |
+
$message = Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatPrice($amount));
|
359 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
360 |
+
// register capture for an existing invoice
|
361 |
+
if ($invoice && Mage_Sales_Model_Order_Invoice::STATE_OPEN == $invoice->getState()) {
|
362 |
+
$invoice->pay();
|
363 |
+
$this->_updateTotals(array('base_amount_paid_online' => $amount));
|
364 |
+
$order->addRelatedObject($invoice);
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
|
369 |
+
$message = $this->_prependMessage($message);
|
370 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
371 |
+
$order->setState($state, $status, $message);
|
372 |
+
return $this;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Process authorization notification
|
377 |
+
*
|
378 |
+
* @see self::_authorize()
|
379 |
+
* @param float $amount
|
380 |
+
* @return Mage_Sales_Model_Order_Payment
|
381 |
+
*/
|
382 |
+
public function registerAuthorizationNotification($amount)
|
383 |
+
{
|
384 |
+
return ($this->_isTransactionExists()) ? $this : $this->_authorize(false, $amount);
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Register payment fact: update self totals from the invoice
|
389 |
+
*
|
390 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
391 |
+
* @return Mage_Sales_Model_Order_Payment
|
392 |
+
*/
|
393 |
+
public function pay($invoice)
|
394 |
+
{
|
395 |
+
$this->_updateTotals(array(
|
396 |
+
'amount_paid' => $invoice->getGrandTotal(),
|
397 |
+
'base_amount_paid' => $invoice->getBaseGrandTotal(),
|
398 |
+
'shipping_captured' => $invoice->getShippingAmount(),
|
399 |
+
'base_shipping_captured' => $invoice->getBaseShippingAmount(),
|
400 |
+
));
|
401 |
+
Mage::dispatchEvent('sales_order_payment_pay', array('payment' => $this, 'invoice' => $invoice));
|
402 |
+
return $this;
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Cancel specified invoice: update self totals from it
|
407 |
+
*
|
408 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
409 |
+
* @return Mage_Sales_Model_Order_Payment
|
410 |
+
*/
|
411 |
+
public function cancelInvoice($invoice)
|
412 |
+
{
|
413 |
+
$this->_updateTotals(array(
|
414 |
+
'amount_paid' => -1 * $invoice->getGrandTotal(),
|
415 |
+
'base_amount_paid' => -1 * $invoice->getBaseGrandTotal(),
|
416 |
+
'shipping_captured' => -1 * $invoice->getShippingAmount(),
|
417 |
+
'base_shipping_captured' => -1 * $invoice->getBaseShippingAmount(),
|
418 |
+
));
|
419 |
+
Mage::dispatchEvent('sales_order_payment_cancel_invoice', array('payment' => $this, 'invoice' => $invoice));
|
420 |
+
return $this;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Create new invoice with maximum qty for invoice for each item
|
425 |
+
* register this invoice and capture
|
426 |
+
*
|
427 |
+
* @return Mage_Sales_Model_Order_Invoice
|
428 |
+
*/
|
429 |
+
protected function _invoice()
|
430 |
+
{
|
431 |
+
$invoice = $this->getOrder()->prepareInvoice();
|
432 |
+
|
433 |
+
$invoice->register();
|
434 |
+
if ($this->getMethodInstance()->canCapture()) {
|
435 |
+
$invoice->capture();
|
436 |
+
}
|
437 |
+
|
438 |
+
$this->getOrder()->addRelatedObject($invoice);
|
439 |
+
return $invoice;
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Check order payment void availability
|
444 |
+
*
|
445 |
+
* @return bool
|
446 |
+
*/
|
447 |
+
public function canVoid(Varien_Object $document)
|
448 |
+
{
|
449 |
+
if (null === $this->_canVoidLookup) {
|
450 |
+
$this->_canVoidLookup = (bool)$this->getMethodInstance()->canVoid($document);
|
451 |
+
if ($this->_canVoidLookup) {
|
452 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
453 |
+
$this->_canVoidLookup = (bool)$authTransaction && !(int)$authTransaction->getIsClosed();
|
454 |
+
}
|
455 |
+
}
|
456 |
+
return $this->_canVoidLookup;
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Void payment online
|
461 |
+
*
|
462 |
+
* @see self::_void()
|
463 |
+
* @param Varien_Object $document
|
464 |
+
* @return Mage_Sales_Model_Order_Payment
|
465 |
+
*/
|
466 |
+
public function void(Varien_Object $document)
|
467 |
+
{
|
468 |
+
$this->_void(true);
|
469 |
+
Mage::dispatchEvent('sales_order_payment_void', array('payment' => $this, 'invoice' => $document));
|
470 |
+
return $this;
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Process void notification
|
475 |
+
*
|
476 |
+
* @see self::_void()
|
477 |
+
* @param float $amount
|
478 |
+
* @return Mage_Sales_Model_Payment
|
479 |
+
*/
|
480 |
+
public function registerVoidNotification($amount = null)
|
481 |
+
{
|
482 |
+
if (!$this->hasMessage()) {
|
483 |
+
$this->setMessage(Mage::helper('sales')->__('Registered a Void notification.'));
|
484 |
+
}
|
485 |
+
return $this->_void(false, $amount);
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Refund payment online or offline, depending on whether there is invoice set in the creditmemo instance
|
490 |
+
* Updates transactions hierarchy, if required
|
491 |
+
* Updates payment totals, updates order status and adds proper comments
|
492 |
+
*
|
493 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
494 |
+
* @return Mage_Sales_Model_Order_Payment
|
495 |
+
*/
|
496 |
+
public function refund($creditmemo)
|
497 |
+
{
|
498 |
+
$baseAmountToRefund = $this->_formatAmount($creditmemo->getBaseGrandTotal());
|
499 |
+
$order = $this->getOrder();
|
500 |
+
|
501 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
502 |
+
|
503 |
+
// call refund from gateway if required
|
504 |
+
$isOnline = false;
|
505 |
+
$gateway = $this->getMethodInstance();
|
506 |
+
$invoice = null;
|
507 |
+
if ($gateway->canRefund() && $creditmemo->getDoTransaction()) {
|
508 |
+
$this->setCreditmemo($creditmemo);
|
509 |
+
$invoice = $creditmemo->getInvoice();
|
510 |
+
if ($invoice) {
|
511 |
+
$isOnline = true;
|
512 |
+
$captureTxn = $this->_lookupTransaction($invoice->getTransactionId());
|
513 |
+
if ($captureTxn) {
|
514 |
+
$this->setParentTransactionId($captureTxn->getTxnId());
|
515 |
+
}
|
516 |
+
$this->setShouldCloseParentTransaction(true); // TODO: implement multiple refunds per capture
|
517 |
+
try {
|
518 |
+
$gateway->setStore($this->getOrder()->getStoreId())
|
519 |
+
->processBeforeRefund($invoice, $this)
|
520 |
+
->refund($this, $baseAmountToRefund)
|
521 |
+
->processCreditmemo($creditmemo, $this)
|
522 |
+
;
|
523 |
+
} catch (Mage_Core_Exception $e) {
|
524 |
+
if (!$captureTxn) {
|
525 |
+
$e->setMessage(' ' . Mage::helper('sales')->__('If the invoice was created offline, try creating an offline creditmemo.'), true);
|
526 |
+
}
|
527 |
+
throw $e;
|
528 |
+
}
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
// update self totals from creditmemo
|
533 |
+
$this->_updateTotals(array(
|
534 |
+
'amount_refunded' => $creditmemo->getGrandTotal(),
|
535 |
+
'base_amount_refunded' => $baseAmountToRefund,
|
536 |
+
'base_amount_refunded_online' => $isOnline ? $baseAmountToRefund : null,
|
537 |
+
'shipping_refunded' => $creditmemo->getShippingAmount(),
|
538 |
+
'base_shipping_refunded' => $creditmemo->getBaseShippingAmount(),
|
539 |
+
));
|
540 |
+
|
541 |
+
// update transactions and order state
|
542 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo, $isOnline);
|
543 |
+
if ($invoice) {
|
544 |
+
$message = Mage::helper('sales')->__('Refunded amount of %s online.', $this->_formatPrice($baseAmountToRefund));
|
545 |
+
} else {
|
546 |
+
$message = $this->hasMessage() ? $this->getMessage()
|
547 |
+
: Mage::helper('sales')->__('Refunded amount of %s offline.', $this->_formatPrice($baseAmountToRefund));
|
548 |
+
}
|
549 |
+
$message = $message = $this->_prependMessage($message);
|
550 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
551 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
552 |
+
|
553 |
+
Mage::dispatchEvent('sales_order_payment_refund', array('payment' => $this, 'creditmemo' => $creditmemo));
|
554 |
+
return $this;
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Process payment refund notification
|
559 |
+
* Updates transactions hierarchy, if required
|
560 |
+
* Prevents transaction double processing
|
561 |
+
* Updates payment totals, updates order status and adds proper comments
|
562 |
+
* TODO: potentially a full capture can be refunded. In this case if there was only one invoice for that transaction
|
563 |
+
* then we should create a creditmemo from invoice and also refund it offline
|
564 |
+
* TODO: implement logic of chargebacks reimbursements (via negative amount)
|
565 |
+
*
|
566 |
+
* @param float $amount
|
567 |
+
* @return Mage_Sales_Model_Order_Payment
|
568 |
+
*/
|
569 |
+
public function registerRefundNotification($amount)
|
570 |
+
{
|
571 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
|
572 |
+
$this->_lookupTransaction($this->getParentTransactionId())
|
573 |
+
);
|
574 |
+
if ($this->_isTransactionExists()) {
|
575 |
+
return $this;
|
576 |
+
}
|
577 |
+
$order = $this->getOrder();
|
578 |
+
|
579 |
+
// create an offline creditmemo (from order), if the entire grand total of order is covered by this refund
|
580 |
+
$creditmemo = null;
|
581 |
+
if ($amount == $order->getBaseGrandTotal()) {
|
582 |
+
/*
|
583 |
+
$creditmemo = $order->prepareCreditmemo()->register()->refund();
|
584 |
+
$this->_updateTotals(array(
|
585 |
+
'amount_refunded' => $creditmemo->getGrandTotal(),
|
586 |
+
'shipping_refunded' => $creditmemo->getShippingRefunded(),
|
587 |
+
'base_shipping_refunded' => $creditmemo->getBaseShippingRefunded()
|
588 |
+
));
|
589 |
+
$order->addRelatedObject($creditmemo);
|
590 |
+
$this->setCreatedCreditmemo($creditmemo);
|
591 |
+
*/
|
592 |
+
}
|
593 |
+
$this->_updateTotals(array('base_amount_refunded_online' => $amount));
|
594 |
+
|
595 |
+
// update transactions and order state
|
596 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo);
|
597 |
+
$message = $this->_prependMessage(
|
598 |
+
Mage::helper('sales')->__('Registered notification about refunded amount of %s.', $this->_formatPrice($amount))
|
599 |
+
);
|
600 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
601 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
602 |
+
return $this;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Cancel a creditmemo: substract its totals from the payment
|
607 |
+
*
|
608 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
609 |
+
* @return Mage_Sales_Model_Order_Payment
|
610 |
+
*/
|
611 |
+
public function cancelCreditmemo($creditmemo)
|
612 |
+
{
|
613 |
+
$this->_updateTotals(array(
|
614 |
+
'amount_refunded' => -1 * $creditmemo->getGrandTotal(),
|
615 |
+
'base_amount_refunded' => -1 * $creditmemo->getBaseGrandTotal(),
|
616 |
+
'shipping_refunded' => -1 * $creditmemo->getShippingAmount(),
|
617 |
+
'base_shipping_refunded' => -1 * $creditmemo->getBaseShippingAmount()
|
618 |
+
));
|
619 |
+
Mage::dispatchEvent('sales_order_payment_cancel_creditmemo',
|
620 |
+
array('payment' => $this, 'creditmemo' => $creditmemo)
|
621 |
+
);
|
622 |
+
return $this;
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* Order cancellation hook for payment method instance
|
627 |
+
* Adds void transaction if needed
|
628 |
+
* @return Mage_Sales_Model_Order_Payment
|
629 |
+
*/
|
630 |
+
public function cancel()
|
631 |
+
{
|
632 |
+
$isOnline = true;
|
633 |
+
if (!$this->canVoid(new Varien_Object())) {
|
634 |
+
$isOnline = false;
|
635 |
+
}
|
636 |
+
|
637 |
+
if (!$this->hasMessage()) {
|
638 |
+
$this->setMessage($isOnline ? Mage::helper('sales')->__('Canceled order online.')
|
639 |
+
: Mage::helper('sales')->__('Canceled order offline.')
|
640 |
+
);
|
641 |
+
}
|
642 |
+
|
643 |
+
if ($isOnline) {
|
644 |
+
$this->_void($isOnline, null, 'cancel');
|
645 |
+
}
|
646 |
+
|
647 |
+
Mage::dispatchEvent('sales_order_payment_cancel', array('payment' => $this));
|
648 |
+
|
649 |
+
return $this;
|
650 |
+
}
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Check order payment review availability
|
654 |
+
*
|
655 |
+
* @return bool
|
656 |
+
*/
|
657 |
+
public function canReviewPayment()
|
658 |
+
{
|
659 |
+
return (bool)$this->getMethodInstance()->canReviewPayment($this);
|
660 |
+
}
|
661 |
+
|
662 |
+
public function canFetchTransactionInfo()
|
663 |
+
{
|
664 |
+
return (bool)$this->getMethodInstance()->canFetchTransactionInfo();
|
665 |
+
}
|
666 |
+
|
667 |
+
/**
|
668 |
+
* Accept online a payment that is in review state
|
669 |
+
*
|
670 |
+
* @return Mage_Sales_Model_Order_Payment
|
671 |
+
*/
|
672 |
+
public function accept()
|
673 |
+
{
|
674 |
+
$this->registerPaymentReviewAction(self::REVIEW_ACTION_ACCEPT, true);
|
675 |
+
return $this;
|
676 |
+
}
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Accept order with payment method instance
|
680 |
+
*
|
681 |
+
* @return Mage_Sales_Model_Order_Payment
|
682 |
+
*/
|
683 |
+
public function deny()
|
684 |
+
{
|
685 |
+
$this->registerPaymentReviewAction(self::REVIEW_ACTION_DENY, true);
|
686 |
+
return $this;
|
687 |
+
}
|
688 |
+
|
689 |
+
/**
|
690 |
+
* Perform the payment review action: either initiated by merchant or by a notification
|
691 |
+
*
|
692 |
+
* Sets order to processing state and optionally approves invoice or cancels the order
|
693 |
+
*
|
694 |
+
* @param string $action
|
695 |
+
* @param bool $isOnline
|
696 |
+
* @return Mage_Sales_Model_Order_Payment
|
697 |
+
*/
|
698 |
+
public function registerPaymentReviewAction($action, $isOnline)
|
699 |
+
{
|
700 |
+
$order = $this->getOrder();
|
701 |
+
|
702 |
+
$transactionId = $isOnline ? $this->getLastTransId() : $this->getTransactionId();
|
703 |
+
if (!$this->_lookupTransaction($transactionId)) {
|
704 |
+
Mage::throwException(Mage::helper('sales')->__('No valid transaction found for this payment review.'));
|
705 |
+
}
|
706 |
+
$invoice = $this->_getInvoiceForTransactionId($transactionId);
|
707 |
+
|
708 |
+
// invoke the payment method to determine what to do with the transaction
|
709 |
+
$result = null; $message = null;
|
710 |
+
switch ($action) {
|
711 |
+
case self::REVIEW_ACTION_ACCEPT:
|
712 |
+
if ($isOnline) {
|
713 |
+
if ($this->getMethodInstance()->setStore($order->getStoreId())->acceptPayment($this)) {
|
714 |
+
$result = true;
|
715 |
+
$message = Mage::helper('sales')->__('Approved the payment online.');
|
716 |
+
} else {
|
717 |
+
$result = -1;
|
718 |
+
$message = Mage::helper('sales')->__('There is no need to approve this payment.');
|
719 |
+
}
|
720 |
+
} else {
|
721 |
+
$result = (bool)$this->getNotificationResult() ? true : -1;
|
722 |
+
$message = Mage::helper('sales')->__('Registered notification about approved payment.');
|
723 |
+
}
|
724 |
+
break;
|
725 |
+
case self::REVIEW_ACTION_DENY:
|
726 |
+
if ($isOnline) {
|
727 |
+
if ($this->getMethodInstance()->setStore($order->getStoreId())->denyPayment($this)) {
|
728 |
+
$result = false;
|
729 |
+
$message = Mage::helper('sales')->__('Denied the payment online.');
|
730 |
+
} else {
|
731 |
+
$result = -1;
|
732 |
+
$message = Mage::helper('sales')->__('There is no need to deny this payment.');
|
733 |
+
}
|
734 |
+
} else {
|
735 |
+
$result = (bool)$this->getNotificationResult() ? false : -1;
|
736 |
+
$message = Mage::helper('sales')->__('Registered notification about denied payment.');
|
737 |
+
}
|
738 |
+
break;
|
739 |
+
case self::REVIEW_ACTION_UPDATE:
|
740 |
+
if ($isOnline) {
|
741 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->fetchTransactionInfo($this, $transactionId);
|
742 |
+
} else {
|
743 |
+
// notification mechanism is responsible to update the payment object first
|
744 |
+
}
|
745 |
+
if ($this->getIsTransactionApproved()) {
|
746 |
+
$result = true;
|
747 |
+
$message = Mage::helper('sales')->__('Registered update about approved payment.');
|
748 |
+
} elseif ($this->getIsTransactionDenied()) {
|
749 |
+
$result = false;
|
750 |
+
$message = Mage::helper('sales')->__('Registered update about approved payment.');
|
751 |
+
} else {
|
752 |
+
$result = -1;
|
753 |
+
$message = Mage::helper('sales')->__('There is no update for the payment.');
|
754 |
+
}
|
755 |
+
break;
|
756 |
+
default:
|
757 |
+
throw new Exception('Not implemented.');
|
758 |
+
}
|
759 |
+
$message = $this->_prependMessage($message);
|
760 |
+
$message = $this->_appendTransactionToMessage($transactionId, $message);
|
761 |
+
|
762 |
+
// process payment in case of positive or negative result, or add a comment
|
763 |
+
if (-1 === $result) { // switch won't work with such $result!
|
764 |
+
$order->addStatusHistoryComment($message);
|
765 |
+
} elseif (true === $result) {
|
766 |
+
if ($invoice) {
|
767 |
+
$invoice->pay();
|
768 |
+
$this->_updateTotals(array('base_amount_paid_online' => $invoice->getBaseGrandTotal()));
|
769 |
+
$order->addRelatedObject($invoice);
|
770 |
+
}
|
771 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
772 |
+
} elseif (false === $result) {
|
773 |
+
if ($invoice) {
|
774 |
+
$invoice->cancel();
|
775 |
+
$order->addRelatedObject($invoice);
|
776 |
+
}
|
777 |
+
$order->registerCancellation($message, false);
|
778 |
+
}
|
779 |
+
return $this;
|
780 |
+
}
|
781 |
+
|
782 |
+
/**
|
783 |
+
* Authorize payment either online or offline (process auth notification)
|
784 |
+
* Updates transactions hierarchy, if required
|
785 |
+
* Prevents transaction double processing
|
786 |
+
* Updates payment totals, updates order status and adds proper comments
|
787 |
+
*
|
788 |
+
* @param bool $isOnline
|
789 |
+
* @param float $amount
|
790 |
+
* @return Mage_Sales_Model_Order_Payment
|
791 |
+
*/
|
792 |
+
protected function _authorize($isOnline, $amount)
|
793 |
+
{
|
794 |
+
// update totals
|
795 |
+
$amount = $this->_formatAmount($amount, true);
|
796 |
+
$this->setBaseAmountAuthorized($amount);
|
797 |
+
|
798 |
+
// do authorization
|
799 |
+
$order = $this->getOrder();
|
800 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
801 |
+
$status = true;
|
802 |
+
if ($isOnline) {
|
803 |
+
|
804 |
+
// invoke authorization on gateway
|
805 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->authorize($this, $amount);
|
806 |
+
|
807 |
+
// similar logic of "payment review" order as in capturing
|
808 |
+
if ($this->getIsTransactionPending()) {
|
809 |
+
$message = Mage::helper('sales')->__('Authorizing amount of %s is pending approval on gateway.', $this->_formatPrice($amount));
|
810 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
811 |
+
if ($this->getIsFraudDetected()) {
|
812 |
+
$status = 'fraud';
|
813 |
+
} elseif ($this->getTransactionPendingStatus()) {
|
814 |
+
$state = Mage_Sales_Model_Order::STATE_HOLDED;
|
815 |
+
$status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
|
816 |
+
}
|
817 |
+
} else {
|
818 |
+
$message = Mage::helper('sales')->__('Authorized amount of %s.', $this->_formatPrice($amount));
|
819 |
+
}
|
820 |
+
} else {
|
821 |
+
$message = Mage::helper('sales')->__('Registered notification about authorized amount of %s.', $this->_formatPrice($amount));
|
822 |
+
}
|
823 |
+
|
824 |
+
// update transactions, order state and add comments
|
825 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
826 |
+
if ($order->isNominal()) {
|
827 |
+
$message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
|
828 |
+
} else {
|
829 |
+
$message = $this->_prependMessage($message);
|
830 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
831 |
+
}
|
832 |
+
$order->setState($state, $status, $message);
|
833 |
+
|
834 |
+
return $this;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Public access to _authorize method
|
839 |
+
* @param bool $isOnline
|
840 |
+
* @param float $amount
|
841 |
+
*/
|
842 |
+
public function authorize($isOnline, $amount)
|
843 |
+
{
|
844 |
+
return $this->_authorize($isOnline, $amount);
|
845 |
+
}
|
846 |
+
|
847 |
+
/**
|
848 |
+
* Void payment either online or offline (process void notification)
|
849 |
+
* NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use
|
850 |
+
* the amount void amount, for informational purposes.
|
851 |
+
* Updates payment totals, updates order status and adds proper comments
|
852 |
+
*
|
853 |
+
* @param bool $isOnline
|
854 |
+
* @param float $amount
|
855 |
+
* @param string $gatewayCallback
|
856 |
+
* @return Mage_Sales_Model_Order_Payment
|
857 |
+
*/
|
858 |
+
protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
|
859 |
+
{
|
860 |
+
$order = $this->getOrder();
|
861 |
+
$authTransaction = $this->getAuthorizationTransaction();
|
862 |
+
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, $authTransaction);
|
863 |
+
$this->setShouldCloseParentTransaction(true);
|
864 |
+
|
865 |
+
// attempt to void
|
866 |
+
if ($isOnline) {
|
867 |
+
$this->getMethodInstance()->setStore($order->getStoreId())->$gatewayCallback($this);
|
868 |
+
}
|
869 |
+
if ($this->_isTransactionExists()) {
|
870 |
+
return $this;
|
871 |
+
}
|
872 |
+
|
873 |
+
// if the authorization was untouched, we may assume voided amount = order grand total
|
874 |
+
// but only if the payment auth amount equals to order grand total
|
875 |
+
if ($authTransaction && ($order->getBaseGrandTotal() == $this->getBaseAmountAuthorized())
|
876 |
+
&& (0 == $this->getBaseAmountCanceled())) {
|
877 |
+
if ($authTransaction->canVoidAuthorizationCompletely()) {
|
878 |
+
$amount = (float)$order->getBaseGrandTotal();
|
879 |
+
}
|
880 |
+
}
|
881 |
+
|
882 |
+
if ($amount) {
|
883 |
+
$amount = $this->_formatAmount($amount);
|
884 |
+
}
|
885 |
+
|
886 |
+
// update transactions, order state and add comments
|
887 |
+
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
|
888 |
+
$message = $this->hasMessage() ? $this->getMessage() : Mage::helper('sales')->__('Voided authorization.');
|
889 |
+
$message = $this->_prependMessage($message);
|
890 |
+
if ($amount) {
|
891 |
+
$message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $this->_formatPrice($amount));
|
892 |
+
}
|
893 |
+
$message = $this->_appendTransactionToMessage($transaction, $message);
|
894 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
895 |
+
return $this;
|
896 |
+
}
|
897 |
+
|
898 |
+
// /**
|
899 |
+
// * TODO: implement this
|
900 |
+
// * @param Mage_Sales_Model_Order_Invoice $invoice
|
901 |
+
// * @return Mage_Sales_Model_Order_Payment
|
902 |
+
// */
|
903 |
+
// public function cancelCapture($invoice = null)
|
904 |
+
// {
|
905 |
+
// }
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Create transaction, prepare its insertion into hierarchy and add its information to payment and comments
|
909 |
+
*
|
910 |
+
* To add transactions and related information, the following information should be set to payment before processing:
|
911 |
+
* - transaction_id
|
912 |
+
* - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
|
913 |
+
* - parent_transaction_id (optional)
|
914 |
+
* - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
|
915 |
+
*
|
916 |
+
* If the sales document is specified, it will be linked to the transaction as related for future usage.
|
917 |
+
* Currently transaction ID is set into the sales object
|
918 |
+
* This method writes the added transaction ID into last_trans_id field of the payment object
|
919 |
+
*
|
920 |
+
* To make sure transaction object won't cause trouble before saving, use $failsafe = true
|
921 |
+
*
|
922 |
+
* @param string $type
|
923 |
+
* @param Mage_Sales_Model_Abstract $salesDocument
|
924 |
+
* @param bool $failsafe
|
925 |
+
* @return null|Mage_Sales_Model_Order_Payment_Transaction
|
926 |
+
*/
|
927 |
+
protected function _addTransaction($type, $salesDocument = null, $failsafe = false)
|
928 |
+
{
|
929 |
+
// look for set transaction ids
|
930 |
+
$transactionId = $this->getTransactionId();
|
931 |
+
if (null !== $transactionId) {
|
932 |
+
// set transaction parameters
|
933 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
934 |
+
->setOrderPaymentObject($this)
|
935 |
+
->setTxnType($type)
|
936 |
+
->setTxnId($transactionId)
|
937 |
+
->isFailsafe($failsafe)
|
938 |
+
;
|
939 |
+
if ($this->hasIsTransactionClosed()) {
|
940 |
+
$transaction->setIsClosed((int)$this->getIsTransactionClosed());
|
941 |
+
}
|
942 |
+
|
943 |
+
//set transaction addition information
|
944 |
+
if ($this->_transactionAdditionalInfo) {
|
945 |
+
foreach ($this->_transactionAdditionalInfo as $key => $value) {
|
946 |
+
$transaction->setAdditionalInformation($key, $value);
|
947 |
+
}
|
948 |
+
}
|
949 |
+
|
950 |
+
// link with sales entities
|
951 |
+
$this->setLastTransId($transactionId);
|
952 |
+
$this->setCreatedTransaction($transaction);
|
953 |
+
$this->getOrder()->addRelatedObject($transaction);
|
954 |
+
if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
|
955 |
+
$salesDocument->setTransactionId($transactionId);
|
956 |
+
// TODO: linking transaction with the sales document
|
957 |
+
}
|
958 |
+
|
959 |
+
// link with parent transaction
|
960 |
+
$parentTransactionId = $this->getParentTransactionId();
|
961 |
+
|
962 |
+
if ($parentTransactionId) {
|
963 |
+
$transaction->setParentTxnId($parentTransactionId);
|
964 |
+
if ($this->getShouldCloseParentTransaction()) {
|
965 |
+
$parentTransaction = $this->_lookupTransaction($parentTransactionId);
|
966 |
+
if ($parentTransaction) {
|
967 |
+
$parentTransaction->isFailsafe($failsafe)->close(false);
|
968 |
+
$this->getOrder()->addRelatedObject($parentTransaction);
|
969 |
+
}
|
970 |
+
}
|
971 |
+
}
|
972 |
+
return $transaction;
|
973 |
+
}
|
974 |
+
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Public acces to _addTransaction method
|
978 |
+
*
|
979 |
+
* @param string $type
|
980 |
+
* @param Mage_Sales_Model_Abstract $salesDocument
|
981 |
+
* @param bool $failsafe
|
982 |
+
* @return null|Mage_Sales_Model_Order_Payment_Transaction
|
983 |
+
*/
|
984 |
+
public function addTransaction($type, $salesDocument = null, $failsafe = false)
|
985 |
+
{
|
986 |
+
return $this->_addTransaction($type, $salesDocument, $failsafe);
|
987 |
+
}
|
988 |
+
|
989 |
+
/**
|
990 |
+
* Import details data of specified transaction
|
991 |
+
*
|
992 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transactionTo
|
993 |
+
* @return Mage_Sales_Model_Order_Payment
|
994 |
+
*/
|
995 |
+
public function importTransactionInfo(Mage_Sales_Model_Order_Payment_Transaction $transactionTo)
|
996 |
+
{
|
997 |
+
$data = $this->getMethodInstance()
|
998 |
+
->setStore($this->getOrder()->getStoreId())
|
999 |
+
->fetchTransactionInfo($this, $transactionTo->getTxnId());
|
1000 |
+
if ($data) {
|
1001 |
+
$transactionTo->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $data);
|
1002 |
+
}
|
1003 |
+
return $this;
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
/**
|
1007 |
+
* Get the billing agreement, if any
|
1008 |
+
*
|
1009 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
1010 |
+
*/
|
1011 |
+
public function getBillingAgreement()
|
1012 |
+
{
|
1013 |
+
return $this->_billingAgreement;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
/**
|
1017 |
+
* Totals updater utility method
|
1018 |
+
* Updates self totals by keys in data array('key' => $delta)
|
1019 |
+
*
|
1020 |
+
* @param array $data
|
1021 |
+
*/
|
1022 |
+
protected function _updateTotals($data)
|
1023 |
+
{
|
1024 |
+
foreach ($data as $key => $amount) {
|
1025 |
+
if (null !== $amount) {
|
1026 |
+
$was = $this->getDataUsingMethod($key);
|
1027 |
+
$this->setDataUsingMethod($key, $was + $amount);
|
1028 |
+
}
|
1029 |
+
}
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
/**
|
1033 |
+
* Prevent double processing of the same transaction by a payment notification
|
1034 |
+
* Uses either specified txn_id or the transaction id that was set before
|
1035 |
+
*
|
1036 |
+
* @deprecated after 1.4.0.1
|
1037 |
+
* @param string $txnId
|
1038 |
+
* @throws Mage_Core_Exception
|
1039 |
+
*/
|
1040 |
+
protected function _avoidDoubleTransactionProcessing($txnId = null)
|
1041 |
+
{
|
1042 |
+
if ($this->_isTransactionExists($txnId)) {
|
1043 |
+
Mage::throwException(
|
1044 |
+
Mage::helper('sales')->__('Transaction "%s" was already processed.', $txnId)
|
1045 |
+
);
|
1046 |
+
}
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
/**
|
1050 |
+
* Check transaction existence by specified transaction id
|
1051 |
+
*
|
1052 |
+
* @param string $txnId
|
1053 |
+
* @return boolean
|
1054 |
+
*/
|
1055 |
+
protected function _isTransactionExists($txnId = null)
|
1056 |
+
{
|
1057 |
+
if (null === $txnId) {
|
1058 |
+
$txnId = $this->getTransactionId();
|
1059 |
+
}
|
1060 |
+
if ($txnId) {
|
1061 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
1062 |
+
->setOrderPaymentObject($this)
|
1063 |
+
->loadByTxnId($txnId);
|
1064 |
+
return (bool)$transaction->getId();
|
1065 |
+
}
|
1066 |
+
return false;
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* Append transaction ID (if any) message to the specified message
|
1071 |
+
*
|
1072 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction|null $transaction
|
1073 |
+
* @param string $message
|
1074 |
+
* @return string
|
1075 |
+
*/
|
1076 |
+
protected function _appendTransactionToMessage($transaction, $message)
|
1077 |
+
{
|
1078 |
+
if ($transaction) {
|
1079 |
+
$txnId = is_object($transaction) ? $transaction->getTxnId() : $transaction;
|
1080 |
+
$message .= ' ' . Mage::helper('sales')->__('Transaction ID: "%s".', $txnId);
|
1081 |
+
}
|
1082 |
+
return $message;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
/**
|
1086 |
+
* Prepend a "prepared_message" that may be set to the payment instance before, to the specified message
|
1087 |
+
* Prepends value to the specified string or to the comment of specified order status history item instance
|
1088 |
+
*
|
1089 |
+
* @param string|Mage_Sales_Model_Order_Status_History $messagePrependTo
|
1090 |
+
* @return string|Mage_Sales_Model_Order_Status_History
|
1091 |
+
*/
|
1092 |
+
protected function _prependMessage($messagePrependTo)
|
1093 |
+
{
|
1094 |
+
$preparedMessage = $this->getPreparedMessage();
|
1095 |
+
if ($preparedMessage) {
|
1096 |
+
if (is_string($preparedMessage)) {
|
1097 |
+
return $preparedMessage . ' ' . $messagePrependTo;
|
1098 |
+
}
|
1099 |
+
elseif (is_object($preparedMessage) && ($preparedMessage instanceof Mage_Sales_Model_Order_Status_History)) {
|
1100 |
+
$comment = $preparedMessage->getComment() . ' ' . $messagePrependTo;
|
1101 |
+
$preparedMessage->setComment($comment);
|
1102 |
+
return $comment;
|
1103 |
+
}
|
1104 |
+
}
|
1105 |
+
return $messagePrependTo;
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
/**
|
1109 |
+
* Round up and cast specified amount to float or string
|
1110 |
+
*
|
1111 |
+
* @param string|float $amount
|
1112 |
+
* @param bool $asFloat
|
1113 |
+
* @return string|float
|
1114 |
+
*/
|
1115 |
+
protected function _formatAmount($amount, $asFloat = false)
|
1116 |
+
{
|
1117 |
+
$amount = sprintf('%.2F', $amount); // "f" depends on locale, "F" doesn't
|
1118 |
+
return $asFloat ? (float)$amount : $amount;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
/**
|
1122 |
+
* Format price with currency sign
|
1123 |
+
* @param float $amount
|
1124 |
+
* @return string
|
1125 |
+
*/
|
1126 |
+
protected function _formatPrice($amount)
|
1127 |
+
{
|
1128 |
+
return $this->getOrder()->getBaseCurrency()->formatTxt($amount);
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
/**
|
1132 |
+
* Find one transaction by ID or type
|
1133 |
+
* @param string $txnId
|
1134 |
+
* @param string $txnType
|
1135 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
1136 |
+
*/
|
1137 |
+
protected function _lookupTransaction($txnId, $txnType = false)
|
1138 |
+
{
|
1139 |
+
if (!$txnId) {
|
1140 |
+
if ($txnType && $this->getId()) {
|
1141 |
+
$collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
|
1142 |
+
->setOrderFilter($this->getOrder())
|
1143 |
+
->addPaymentIdFilter($this->getId())
|
1144 |
+
->addTxnTypeFilter($txnType);
|
1145 |
+
foreach ($collection as $txn) {
|
1146 |
+
$txn->setOrderPaymentObject($this);
|
1147 |
+
$this->_transactionsLookup[$txn->getTxnId()] = $txn;
|
1148 |
+
return $txn;
|
1149 |
+
}
|
1150 |
+
}
|
1151 |
+
return false;
|
1152 |
+
}
|
1153 |
+
if (isset($this->_transactionsLookup[$txnId])) {
|
1154 |
+
return $this->_transactionsLookup[$txnId];
|
1155 |
+
}
|
1156 |
+
$txn = Mage::getModel('sales/order_payment_transaction')
|
1157 |
+
->setOrderPaymentObject($this)
|
1158 |
+
->loadByTxnId($txnId);
|
1159 |
+
if ($txn->getId()) {
|
1160 |
+
$this->_transactionsLookup[$txnId] = $txn;
|
1161 |
+
} else {
|
1162 |
+
$this->_transactionsLookup[$txnId] = false;
|
1163 |
+
}
|
1164 |
+
return $this->_transactionsLookup[$txnId];
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
/**
|
1168 |
+
* Lookup an authorization transaction using parent transaction id, if set
|
1169 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
1170 |
+
*/
|
1171 |
+
public function getAuthorizationTransaction()
|
1172 |
+
{
|
1173 |
+
if ($this->getParentTransactionId()) {
|
1174 |
+
$txn = $this->_lookupTransaction($this->getParentTransactionId());
|
1175 |
+
} else {
|
1176 |
+
$txn = false;
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
if (!$txn) {
|
1180 |
+
$txn = $this->_lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
1181 |
+
}
|
1182 |
+
return $txn;
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
/**
|
1186 |
+
* Lookup the transaction by id
|
1187 |
+
* @param string $transactionId
|
1188 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|false
|
1189 |
+
*/
|
1190 |
+
public function getTransaction($transactionId)
|
1191 |
+
{
|
1192 |
+
return $this->_lookupTransaction($transactionId);
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
/**
|
1196 |
+
* Update transaction ids for further processing
|
1197 |
+
* If no transactions were set before invoking, may generate an "offline" transaction id
|
1198 |
+
*
|
1199 |
+
* @param string $type
|
1200 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transactionBasedOn
|
1201 |
+
*/
|
1202 |
+
protected function _generateTransactionId($type, $transactionBasedOn = false)
|
1203 |
+
{
|
1204 |
+
if (!$this->getParentTransactionId() && !$this->getTransactionId() && $transactionBasedOn) {
|
1205 |
+
$this->setParentTransactionId($transactionBasedOn->getTxnId());
|
1206 |
+
}
|
1207 |
+
// generate transaction id for an offline action or payment method that didn't set it
|
1208 |
+
if (($parentTxnId = $this->getParentTransactionId()) && !$this->getTransactionId()) {
|
1209 |
+
$this->setTransactionId("{$parentTxnId}-{$type}");
|
1210 |
+
}
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
/**
|
1214 |
+
* Decide whether authorization transaction may close (if the amount to capture will cover entire order)
|
1215 |
+
* @param float $amountToCapture
|
1216 |
+
* @return bool
|
1217 |
+
*/
|
1218 |
+
protected function _isCaptureFinal($amountToCapture)
|
1219 |
+
{
|
1220 |
+
$orderGrandTotal = sprintf('%.4F', $this->getOrder()->getBaseGrandTotal());
|
1221 |
+
if ($orderGrandTotal == sprintf('%.4F', ($this->getBaseAmountPaidOnline() + $amountToCapture))) {
|
1222 |
+
if (false !== $this->getShouldCloseParentTransaction()) {
|
1223 |
+
$this->setShouldCloseParentTransaction(true);
|
1224 |
+
}
|
1225 |
+
return true;
|
1226 |
+
}
|
1227 |
+
return false;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
/**
|
1231 |
+
* Before object save manipulations
|
1232 |
+
*
|
1233 |
+
* @return Mage_Sales_Model_Order_Payment
|
1234 |
+
*/
|
1235 |
+
protected function _beforeSave()
|
1236 |
+
{
|
1237 |
+
parent::_beforeSave();
|
1238 |
+
|
1239 |
+
if (!$this->getParentId() && $this->getOrder()) {
|
1240 |
+
$this->setParentId($this->getOrder()->getId());
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
return $this;
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
/**
|
1247 |
+
* Generate billing agreement object if there is billing agreement data
|
1248 |
+
* Adds it to order as related object
|
1249 |
+
*/
|
1250 |
+
protected function _createBillingAgreement()
|
1251 |
+
{
|
1252 |
+
if ($this->getBillingAgreementData()) {
|
1253 |
+
$order = $this->getOrder();
|
1254 |
+
$agreement = Mage::getModel('sales/billing_agreement')->importOrderPayment($this);
|
1255 |
+
if ($agreement->isValid()) {
|
1256 |
+
$message = Mage::helper('sales')->__('Created billing agreement #%s.', $agreement->getReferenceId());
|
1257 |
+
$order->addRelatedObject($agreement);
|
1258 |
+
$this->_billingAgreement = $agreement;
|
1259 |
+
} else {
|
1260 |
+
$message = Mage::helper('sales')->__('Failed to create billing agreement for this order.');
|
1261 |
+
}
|
1262 |
+
$comment = $order->addStatusHistoryComment($message);
|
1263 |
+
$order->addRelatedObject($comment);
|
1264 |
+
}
|
1265 |
+
}
|
1266 |
+
|
1267 |
+
/**
|
1268 |
+
* Additionnal transaction info setter
|
1269 |
+
*
|
1270 |
+
* @param sting $key
|
1271 |
+
* @param string $value
|
1272 |
+
*/
|
1273 |
+
public function setTransactionAdditionalInfo($key, $value)
|
1274 |
+
{
|
1275 |
+
$this->_transactionAdditionalInfo[$key] = $value;
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
/**
|
1279 |
+
* Return invoice model for transaction
|
1280 |
+
*
|
1281 |
+
* @param string $transactionId
|
1282 |
+
* @return Mage_Sales_Model_Order_Invoice
|
1283 |
+
*/
|
1284 |
+
protected function _getInvoiceForTransactionId($transactionId)
|
1285 |
+
{
|
1286 |
+
foreach ($this->getOrder()->getInvoiceCollection() as $invoice) {
|
1287 |
+
if ($invoice->getTransactionId() == $transactionId) {
|
1288 |
+
$invoice->load($invoice->getId()); // to make sure all data will properly load (maybe not required)
|
1289 |
+
return $invoice;
|
1290 |
+
}
|
1291 |
+
}
|
1292 |
+
return false;
|
1293 |
+
}
|
1294 |
+
}
|
app/code/community/Mage/Sales/Model/Order/Payment.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (version_compare(Mage::getVersion(), '1.4.0.0', '>=')
|
3 |
+
&& version_compare(Mage::getVersion(), '1.4.1.0', '<')
|
4 |
+
) {
|
5 |
+
require 'Payment-1.4.0.X.php';
|
6 |
+
} elseif (version_compare(Mage::getVersion(), '1.4.1.0', '>=')) {
|
7 |
+
require 'Payment-1.4.1.X.php';
|
8 |
+
} else {
|
9 |
+
die('Our current Magento version "'. Mage::getVersion() .'" is not supported by the Computop module.');
|
10 |
+
}
|
app/design/adminhtml/default/default/layout/computop.xml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="js">
|
5 |
+
<block type="core/template" name="depends_allallowedcountries" template="computop/depends/allallowedcountries.phtml"/>
|
6 |
+
<block type="core/template" name="depends_ipzones" template="computop/depends/ipzones.phtml"/>
|
7 |
+
</reference>
|
8 |
+
<reference name="notifications">
|
9 |
+
<block type="computop/adminhtml_notification_secureurl" name="computop_notification_secureurl" as="computop_notification_secureurl" template="computop/notification/secureurl.phtml" />
|
10 |
+
</reference>
|
11 |
+
</default>
|
12 |
+
|
13 |
+
<adminhtml_sales_order_view>
|
14 |
+
<reference name="sales_order_tabs">
|
15 |
+
<action method="addTab"><name>computop_action</name><block>computop/adminhtml_sales_order_view_tab_action</block></action>
|
16 |
+
</reference>
|
17 |
+
</adminhtml_sales_order_view>
|
18 |
+
|
19 |
+
<adminhtml_sales_order_index>
|
20 |
+
<reference name="sales_order.grid">
|
21 |
+
<action method="addColumn">
|
22 |
+
<index>computop_transaction_id</index>
|
23 |
+
<array>
|
24 |
+
<header>CT RefNr</header>
|
25 |
+
<title>Computop Reference Number</title>
|
26 |
+
<index>computop_transaction_id</index>
|
27 |
+
<type>text</type>
|
28 |
+
<width>65px</width>
|
29 |
+
<renderer>computop/widget_grid_column_renderer_zerofill</renderer>
|
30 |
+
</array>
|
31 |
+
</action>
|
32 |
+
<action method="addColumnsOrder">
|
33 |
+
<columnId>computop_transaction_id</columnId>
|
34 |
+
<after>real_order_id</after>
|
35 |
+
</action>
|
36 |
+
</reference>
|
37 |
+
</adminhtml_sales_order_index>
|
38 |
+
|
39 |
+
<adminhtml_sales_order_grid>
|
40 |
+
<reference name="sales_order.grid">
|
41 |
+
<action method="addColumn">
|
42 |
+
<index>computop_transaction_id</index>
|
43 |
+
<array>
|
44 |
+
<header>CT RefNr</header>
|
45 |
+
<title>Computop Reference Number</title>
|
46 |
+
<index>computop_transaction_id</index>
|
47 |
+
<type>text</type>
|
48 |
+
<width>65px</width>
|
49 |
+
<renderer>computop/widget_grid_column_renderer_zerofill</renderer>
|
50 |
+
</array>
|
51 |
+
</action>
|
52 |
+
<action method="addColumnsOrder">
|
53 |
+
<columnId>computop_transaction_id</columnId>
|
54 |
+
<after>real_order_id</after>
|
55 |
+
</action>
|
56 |
+
</reference>
|
57 |
+
</adminhtml_sales_order_grid>
|
58 |
+
</layout>
|
app/design/adminhtml/default/default/template/computop/config/form/field/form.phtml
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
|
11 |
+
/* @var $this Dotsource_Computop_Block_Config_Form_Abstract */
|
12 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
13 |
+
|
14 |
+
$_colspan = 2;
|
15 |
+
if (!$this->_addAfter) {
|
16 |
+
$_colspan -= 1;
|
17 |
+
}
|
18 |
+
$_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
|
19 |
+
?>
|
20 |
+
|
21 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>">
|
22 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
23 |
+
<tbody>
|
24 |
+
|
25 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
26 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
27 |
+
<?php if (array_key_exists('title', $column) && !empty($column['title'])): ?>
|
28 |
+
<th title="<?php echo $this->htmlEscape($column['title']) ?>"><?php echo $this->htmlEscape($column['label']) ?></th>
|
29 |
+
<?php else: ?>
|
30 |
+
<th><?php echo $this->htmlEscape($column['label']) ?></th>
|
31 |
+
<?php endif; ?>
|
32 |
+
<?php endforeach;?>
|
33 |
+
<th <?php echo $_colspan?>></th>
|
34 |
+
</tr>
|
35 |
+
|
36 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
37 |
+
<td colspan="<?php echo count($this->_columns) ?>"></td>
|
38 |
+
<td <?php echo $_colspan?>>
|
39 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
|
40 |
+
<span><?php echo $this->htmlEscape($this->_addButtonLabel) ?></span>
|
41 |
+
</button>
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
|
45 |
+
</tbody>
|
46 |
+
</table>
|
47 |
+
<input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
|
48 |
+
</div>
|
49 |
+
|
50 |
+
<div id="empty<?php echo $_htmlId ?>">
|
51 |
+
<button style="" onclick="" class="scalable add" type="button" id="emptyAddBtn<?php echo $_htmlId ?>">
|
52 |
+
<span><?php echo $this->htmlEscape($this->_addButtonLabel) ?></span>
|
53 |
+
</button>
|
54 |
+
</div>
|
55 |
+
|
56 |
+
<?php if ($this->hasDescription()): ?>
|
57 |
+
<div>
|
58 |
+
<?php echo $this->getDescription(); ?>
|
59 |
+
</div>
|
60 |
+
<?php endif; ?>
|
61 |
+
|
62 |
+
<script type="text/javascript">
|
63 |
+
//<![CDATA[
|
64 |
+
// create row creator
|
65 |
+
var arrayRow<?php echo $_htmlId ?> = {
|
66 |
+
// define row prototypeJS template
|
67 |
+
template : new Template(
|
68 |
+
'<tr id="#{_id}">'
|
69 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
70 |
+
+'<td><div class="field-row">'
|
71 |
+
+'<?php echo $this->_renderCellTemplate($columnName)?>'
|
72 |
+
+'<\/div><\/td>'
|
73 |
+
<?php endforeach;?>
|
74 |
+
<?php if ($this->_addAfter):?>
|
75 |
+
+'<td><button onclick="" class="scalable add" type="button" id="addAfterBtn#{_id}"><span><?php echo Mage::helper('adminhtml')->__('Add after') ?><\/span><\/button><\/td>'
|
76 |
+
<?php endif;?>
|
77 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>.del(\'#{_id}\')" class="scalable delete" type="button"><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/button>'
|
78 |
+
+'<\/td>'
|
79 |
+
+'<\/tr>'
|
80 |
+
),
|
81 |
+
|
82 |
+
rowsCount : 0,
|
83 |
+
|
84 |
+
add : function(templateData, insertAfterId)
|
85 |
+
{
|
86 |
+
// generate default template data
|
87 |
+
if ('' == templateData) {
|
88 |
+
var d = new Date();
|
89 |
+
var templateData = {
|
90 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
91 |
+
<?php echo $columnName ?> : '',
|
92 |
+
<?php endforeach;?>
|
93 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
94 |
+
};
|
95 |
+
}
|
96 |
+
|
97 |
+
// insert before last row
|
98 |
+
if ('' == insertAfterId) {
|
99 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
100 |
+
}
|
101 |
+
// insert after specified row
|
102 |
+
else {
|
103 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
104 |
+
}
|
105 |
+
|
106 |
+
<?php if ($this->_addAfter):?>
|
107 |
+
Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
|
108 |
+
<?php endif;?>
|
109 |
+
|
110 |
+
<?php foreach ($this->getAllFormElements() as $formelement) : ?>
|
111 |
+
<?php if(array_key_exists('renderer', $formelement)
|
112 |
+
&& !empty($formelement['renderer'])
|
113 |
+
&& $formelement['renderer'] instanceof Mage_Core_Block_Abstract
|
114 |
+
&& method_exists($formelement['renderer'], 'getCodeForAddActionFormManipulation')) : ?>
|
115 |
+
<?php echo $formelement['renderer']->getCodeForAddActionFormManipulation(); ?>
|
116 |
+
<?php endif; ?>
|
117 |
+
<?php endforeach; ?>
|
118 |
+
|
119 |
+
this.rowsCount += 1;
|
120 |
+
},
|
121 |
+
|
122 |
+
del : function(rowId)
|
123 |
+
{
|
124 |
+
$(rowId).remove();
|
125 |
+
this.rowsCount -= 1;
|
126 |
+
if (0 == this.rowsCount) {
|
127 |
+
this.showButtonOnly();
|
128 |
+
}
|
129 |
+
},
|
130 |
+
|
131 |
+
showButtonOnly : function()
|
132 |
+
{
|
133 |
+
$('grid<?php echo $_htmlId ?>').hide();
|
134 |
+
$('empty<?php echo $_htmlId ?>').show();
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
// bind add action to "Add" button in last row
|
139 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
|
140 |
+
|
141 |
+
// add existing rows
|
142 |
+
<?php
|
143 |
+
$_addAfterId = "headings{$_htmlId}";
|
144 |
+
foreach ($this->getArrayRows() as $_rowId => $_row) {
|
145 |
+
echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
146 |
+
$_addAfterId = $_rowId;
|
147 |
+
}
|
148 |
+
?>
|
149 |
+
|
150 |
+
// initialize standalone button
|
151 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
152 |
+
Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
|
153 |
+
$('grid<?php echo $_htmlId ?>').show();
|
154 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
155 |
+
arrayRow<?php echo $_htmlId ?>.add('', '');
|
156 |
+
});
|
157 |
+
|
158 |
+
// if no rows, hide grid and show button only
|
159 |
+
<?php if (!$this->getArrayRows()):?>
|
160 |
+
arrayRow<?php echo $_htmlId ?>.showButtonOnly();
|
161 |
+
<?php endif;?>
|
162 |
+
|
163 |
+
// toggle the grid, if element is disabled (depending on scope)
|
164 |
+
<?php if ($this->getElement()->getDisabled()):?>
|
165 |
+
toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
|
166 |
+
<?php endif;?>
|
167 |
+
|
168 |
+
function arrayToObject(data) {
|
169 |
+
var object = new Object();
|
170 |
+
|
171 |
+
for(var i = 0; i < data.length; i++) {
|
172 |
+
object[data[i]] = true;
|
173 |
+
}
|
174 |
+
|
175 |
+
return object;
|
176 |
+
}
|
177 |
+
//]]>
|
178 |
+
</script>
|
app/design/adminhtml/default/default/template/computop/depends/allallowedcountries.phtml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<script type="text/javascript">
|
28 |
+
//<![CDATA[
|
29 |
+
var AllCountriesModel = Class.create();
|
30 |
+
AllCountriesModel.prototype = {
|
31 |
+
|
32 |
+
initialize : function()
|
33 |
+
{
|
34 |
+
this.reload = false;
|
35 |
+
this.bindAllCountriesRelation();
|
36 |
+
},
|
37 |
+
|
38 |
+
bindAllCountriesRelation : function(parentId)
|
39 |
+
{
|
40 |
+
if(parentId) {
|
41 |
+
// todo: fix bug in IE
|
42 |
+
var applyAllCountriesElements = $$('#'+parentId+' .allow-all-countries');
|
43 |
+
} else {
|
44 |
+
var applyAllCountriesElements = $$('.allow-all-countries');
|
45 |
+
}
|
46 |
+
|
47 |
+
for(var i=0;i<applyAllCountriesElements.length; i++) {
|
48 |
+
//anmelden der Select-Box fuer das change-event:
|
49 |
+
Event.observe(applyAllCountriesElements[i], 'change', this.checkSpecificCountryChoice.bind(this));
|
50 |
+
this.initSpecificCountryChoice(applyAllCountriesElements[i]);
|
51 |
+
}
|
52 |
+
},
|
53 |
+
|
54 |
+
initSpecificCountryChoice : function(element)
|
55 |
+
{
|
56 |
+
var applyCountryChoiceElement = element;
|
57 |
+
if (applyCountryChoiceElement && applyCountryChoiceElement.id) {
|
58 |
+
var showMethodElement = $(applyCountryChoiceElement.id.replace(/allowedcountries/, 'countriesiso3'));
|
59 |
+
if( showMethodElement ){
|
60 |
+
if( applyCountryChoiceElement.value == "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::ALLOW_ANY_COUNTRIES ?>" ||
|
61 |
+
applyCountryChoiceElement.value == "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::RESTRICT_ANY_COUNTRIES ?>"
|
62 |
+
){
|
63 |
+
this.showElement(showMethodElement.up(1));
|
64 |
+
}
|
65 |
+
else{
|
66 |
+
this.hideElement(showMethodElement.up(1));
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
},
|
71 |
+
|
72 |
+
//Event-Handler-Methode:
|
73 |
+
checkSpecificCountryChoice : function(event)
|
74 |
+
{
|
75 |
+
var applyCountryChoiceElement = Event.element(event);
|
76 |
+
if (applyCountryChoiceElement && applyCountryChoiceElement.id) {
|
77 |
+
var showMethodElement = $(applyCountryChoiceElement.id.replace(/allowedcountries/, 'countriesiso3'));
|
78 |
+
if( showMethodElement ){
|
79 |
+
if( applyCountryChoiceElement.value == "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::ALLOW_ANY_COUNTRIES ?>" ||
|
80 |
+
applyCountryChoiceElement.value == "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedcountriesAction::RESTRICT_ANY_COUNTRIES ?>"
|
81 |
+
){
|
82 |
+
this.showElement(showMethodElement.up(1));
|
83 |
+
}
|
84 |
+
else{
|
85 |
+
this.hideElement(showMethodElement.up(1));
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
},
|
90 |
+
|
91 |
+
unselectSpecificMoment : function(element)
|
92 |
+
{
|
93 |
+
for (var i=0; i<element.options.length; i++) {
|
94 |
+
if (element.options[i].selected) {
|
95 |
+
element.options[i].selected=false;;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
},
|
99 |
+
|
100 |
+
showElement : function(elm)
|
101 |
+
{
|
102 |
+
if (elm) {
|
103 |
+
if (!elm.down('.shipping-skip-show')) {
|
104 |
+
elm.show();
|
105 |
+
}
|
106 |
+
}
|
107 |
+
},
|
108 |
+
|
109 |
+
hideElement : function(elm)
|
110 |
+
{
|
111 |
+
if (elm) {
|
112 |
+
if (!elm.down('.shipping-skip-hide')) {
|
113 |
+
elm.hide();
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
allCountriesModel = new AllCountriesModel();
|
119 |
+
//]]>
|
120 |
+
</script>
|
app/design/adminhtml/default/default/template/computop/depends/ipzones.phtml
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<script type="text/javascript">
|
28 |
+
//<![CDATA[
|
29 |
+
var IpZoneModel = Class.create();
|
30 |
+
IpZoneModel.prototype = {
|
31 |
+
|
32 |
+
initialize : function()
|
33 |
+
{
|
34 |
+
this.reload = false;
|
35 |
+
this.bindAllCountriesRelation();
|
36 |
+
},
|
37 |
+
|
38 |
+
bindAllCountriesRelation : function(parentId)
|
39 |
+
{
|
40 |
+
if(parentId) {
|
41 |
+
// todo: fix bug in IE
|
42 |
+
var applyAllCountriesElements = $$('#'+parentId+' .allow-ip-zones');
|
43 |
+
} else {
|
44 |
+
var applyAllCountriesElements = $$('.allow-ip-zones');
|
45 |
+
}
|
46 |
+
|
47 |
+
for(var i=0;i<applyAllCountriesElements.length; i++) {
|
48 |
+
//anmelden der Select-Box fuer das change-event:
|
49 |
+
Event.observe(applyAllCountriesElements[i], 'change', this.checkSpecificCountryChoice.bind(this));
|
50 |
+
this.initSpecificCountryChoice(applyAllCountriesElements[i]);
|
51 |
+
}
|
52 |
+
},
|
53 |
+
|
54 |
+
initSpecificCountryChoice : function(element)
|
55 |
+
{
|
56 |
+
var applyCountryChoiceElement = element;
|
57 |
+
if (applyCountryChoiceElement && applyCountryChoiceElement.id) {
|
58 |
+
var showMethodElement = $(applyCountryChoiceElement.id.replace(/allowedipzones/, 'ipzones'));
|
59 |
+
if( showMethodElement ){
|
60 |
+
if(applyCountryChoiceElement.value != "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction::ALLOW_ALL_ZONES ?>"){
|
61 |
+
this.showElement(showMethodElement.up(1));
|
62 |
+
} else {
|
63 |
+
this.hideElement(showMethodElement.up(1));
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
},
|
68 |
+
|
69 |
+
//Event-Handler-Methode:
|
70 |
+
checkSpecificCountryChoice : function(event)
|
71 |
+
{
|
72 |
+
var applyCountryChoiceElement = Event.element(event);
|
73 |
+
if (applyCountryChoiceElement && applyCountryChoiceElement.id) {
|
74 |
+
var showMethodElement = $(applyCountryChoiceElement.id.replace(/allowedipzones/, 'ipzones'));
|
75 |
+
if(showMethodElement) {
|
76 |
+
if(applyCountryChoiceElement.value != "<?php echo Dotsource_Computop_Model_System_Config_Source_AllowedipzonesAction::ALLOW_ALL_ZONES ?>"){
|
77 |
+
this.showElement(showMethodElement.up(1));
|
78 |
+
} else{
|
79 |
+
this.hideElement(showMethodElement.up(1));
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
},
|
84 |
+
|
85 |
+
unselectSpecificMoment : function(element)
|
86 |
+
{
|
87 |
+
for (var i=0; i<element.options.length; i++) {
|
88 |
+
if (element.options[i].selected) {
|
89 |
+
element.options[i].selected=false;;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
},
|
93 |
+
|
94 |
+
showElement : function(elm)
|
95 |
+
{
|
96 |
+
if (elm) {
|
97 |
+
if (!elm.down('.shipping-skip-show')) {
|
98 |
+
elm.show();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
},
|
102 |
+
|
103 |
+
hideElement : function(elm)
|
104 |
+
{
|
105 |
+
if (elm) {
|
106 |
+
if (!elm.down('.shipping-skip-hide')) {
|
107 |
+
elm.hide();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
IpZoneModel = new IpZoneModel();
|
113 |
+
//]]>
|
114 |
+
</script>
|
app/design/adminhtml/default/default/template/computop/form/eft.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Eft */
|
11 |
+
?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
14 |
+
<li>
|
15 |
+
<label for="<?php echo $_code ?>_eft_owner" class="required"><em>*</em><?php echo $this->__('Account holder') ?></label>
|
16 |
+
<div class="input-box">
|
17 |
+
<input type="text" id="<?php echo $_code ?>_eft_owner" name="payment[eft_owner]" title="<?php echo $this->__('Account holder') ?>" class="input-text required-entry" value="<?php echo $this->getEftOwner() ?>" />
|
18 |
+
</div>
|
19 |
+
</li>
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_eft_ban" class="required"><em>*</em><?php echo $this->__('Bank account number') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<input type="text" id="<?php echo $_code ?>_eft_ban" name="payment[eft_ban]" title="<?php echo $this->__('Bank account number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBan() ?>" />
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="<?php echo $_code ?>_eft_bcn" class="required"><em>*</em><?php echo $this->__('Bank code number') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input type="text" id="<?php echo $_code ?>_eft_bcn" name="payment[eft_bcn]" title="<?php echo $this->__('Bank code number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBcn() ?>" />
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
</ul>
|
app/design/adminhtml/default/default/template/computop/info/callback.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Mage_Payment_Block_Info */
|
11 |
+
?>
|
12 |
+
<?php echo $this->escapeHtml($this->getMethod()->getTitle()); ?>
|
13 |
+
|
14 |
+
<?php if ($_specificInfo = $this->getSpecificInformation()):?>
|
15 |
+
<table>
|
16 |
+
<?php foreach ($_specificInfo as $_label => $_value):?>
|
17 |
+
<tr>
|
18 |
+
<td><?php echo $this->escapeHtml($_label)?>:</td>
|
19 |
+
<td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
|
20 |
+
</tr>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</table>
|
23 |
+
<?php endif;?>
|
24 |
+
|
25 |
+
<?php echo $this->getChildHtml()?>
|
app/design/adminhtml/default/default/template/computop/notification/secureurl.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Adminhtml_Notification_Secureurl */
|
11 |
+
?>
|
12 |
+
<?php $_url = $this->getConfigUrl(); ?>
|
13 |
+
<?php if ($_url) : ?>
|
14 |
+
<div class="notification-global notification-global-notice">
|
15 |
+
<?php echo $this->escapeHtml($this->__('Your secure base url is not secure. Please use an url starting with "https://". Otherwise the Computop payment module is not activated.')); ?>
|
16 |
+
<?php echo $this->__('Please change this <a href="%s">configuration</a>.', $this->urlEscape($_url)); ?>
|
17 |
+
</div>
|
18 |
+
<?php endif; ?>
|
app/design/frontend/base/default/layout/computop.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<computop_iframe_show>
|
4 |
+
<reference name="root">
|
5 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="content">
|
8 |
+
<remove name="cart_sidebar" />
|
9 |
+
<block type="computop/checkout_iframe" name="checkout_iframe" template="computop/checkout/iframe.phtml"/>
|
10 |
+
</reference>
|
11 |
+
</computop_iframe_show>
|
12 |
+
|
13 |
+
<checkout_cart_index>
|
14 |
+
<reference name="checkout.cart.top_methods">
|
15 |
+
<block type="computop/checkout_paypal_shortcut" name="computop.checkout.cart.methods.paypal_express" template="computop/checkout/paypal/shortcut.phtml"/>
|
16 |
+
</reference>
|
17 |
+
|
18 |
+
<reference name="checkout.cart.methods">
|
19 |
+
<block type="computop/checkout_paypal_shortcut" name="computop.checkout.cart.methods.paypal_express" template="computop/checkout/paypal/shortcut.phtml"/>
|
20 |
+
</reference>
|
21 |
+
</checkout_cart_index>
|
22 |
+
|
23 |
+
<computop_callback_paypalexpress_review translate="label">
|
24 |
+
<label>PayPal Express Order Review Form</label>
|
25 |
+
<remove name="right"/>
|
26 |
+
<remove name="left"/>
|
27 |
+
|
28 |
+
<reference name="root">
|
29 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
30 |
+
</reference>
|
31 |
+
<reference name="content">
|
32 |
+
<block type="computop/checkout_paypal_review" name="computop.checkout.paypal.review" template="computop/checkout/paypal/review.phtml">
|
33 |
+
<block type="computop/checkout_paypal_review_details" name="computop.checkout.paypal.review.details" as="details" template="computop/checkout/paypal/review/details.phtml">
|
34 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
35 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
36 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
37 |
+
<block type="checkout/cart_totals" name="computop.paypalexpress.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
38 |
+
</block>
|
39 |
+
</block>
|
40 |
+
</reference>
|
41 |
+
<reference name="head">
|
42 |
+
<action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action>
|
43 |
+
</reference>
|
44 |
+
</computop_callback_paypalexpress_review>
|
45 |
+
|
46 |
+
<!-- this is called out of the callback_paypalexpress controllers saveShippingMethodAction() -->
|
47 |
+
<computop_callback_paypalexpress_details>
|
48 |
+
<block type="computop/checkout_paypal_review_details" name="root" output="toHtml" template="computop/checkout/paypal/review/details.phtml">
|
49 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
50 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
51 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
52 |
+
<block type="checkout/cart_totals" name="computop.paypalexpress.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
53 |
+
</block>
|
54 |
+
</computop_callback_paypalexpress_details>
|
55 |
+
</layout>
|
app/design/frontend/base/default/template/computop/checkout/iframe.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Checkout_Iframe */
|
11 |
+
?>
|
12 |
+
<div class="page-title">
|
13 |
+
<h3><?php echo $this->escapeHtml($this->getIframeTitle()); ?></h3>
|
14 |
+
</div>
|
15 |
+
<iframe id="ccgateway-iframe" src="<?php echo $this->getIframeUrl(); ?>" width="100%" height="600" frameborder="0" scrolling="no">
|
16 |
+
<p>
|
17 |
+
<?php echo $this->__("Your browser doesn't support iframes."); ?>
|
18 |
+
<br />
|
19 |
+
<a href="<?php echo $this->getIframeUrl(); ?>"><?php echo $this->__('Please click here to open the credit card payment gateway in the current window.'); ?></a>
|
20 |
+
</p>
|
21 |
+
</iframe>
|
app/design/frontend/base/default/template/computop/checkout/paypal/review.phtml
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 17.05.2010 15:05:16
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
<div class="page-title">
|
15 |
+
<h1><?php echo $this->__('Review Order') ?></h1>
|
16 |
+
</div>
|
17 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
18 |
+
<?php if ($this->getShippingAddress()): ?>
|
19 |
+
<div class="info-set col2-set">
|
20 |
+
<h2 class="legend"><?php echo $this->__('Shipping Information') ?></h2>
|
21 |
+
<div class="col-1">
|
22 |
+
<div class="box">
|
23 |
+
<div class="box-title">
|
24 |
+
<h3><?php echo $this->__('Shipping Address') ?></h3>
|
25 |
+
</div>
|
26 |
+
<div class="box-content">
|
27 |
+
<address>
|
28 |
+
<?php echo $this->getShippingAddress()->getFormated(true) ?>
|
29 |
+
</address>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
<div class="col-2">
|
34 |
+
<div class="box">
|
35 |
+
<div class="box-title">
|
36 |
+
<h3><?php echo $this->__('Shipping Method') ?></h3>
|
37 |
+
</div>
|
38 |
+
<div class="box-content">
|
39 |
+
<?php if ($this->isVirtual()): ?>
|
40 |
+
<p><strong><?php echo $this->__('No shipping method required.') ?></strong></p>
|
41 |
+
<?php else: ?>
|
42 |
+
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
|
43 |
+
<p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
|
44 |
+
<?php else: ?>
|
45 |
+
<form method="post" id="shipping_method_form" action="<?php echo $this->getSaveShippingMethodUrl(); ?>">
|
46 |
+
<fieldset>
|
47 |
+
<select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
|
48 |
+
<?php if(!$this->getAddressShippingMethod()): ?>
|
49 |
+
<option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
|
50 |
+
<?php endif ?>
|
51 |
+
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
|
52 |
+
<optgroup label="<?php echo $this->getCarrierName($code) ?>" style="font-style:normal;">
|
53 |
+
<?php foreach ($_rates as $_rate): ?>
|
54 |
+
<?php if ($_rate->getErrorMessage()): ?>
|
55 |
+
<option value="">
|
56 |
+
<?php echo $_rate->getErrorMessage() ?>
|
57 |
+
</option>
|
58 |
+
<?php else: ?>
|
59 |
+
<option value="<?php echo $_rate->getCode() ?>"<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?> selected="selected"<?php endif ?> style="margin-left:16px;">
|
60 |
+
<?php echo $_rate->getMethodTitle() ?> -
|
61 |
+
|
62 |
+
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
|
63 |
+
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
|
64 |
+
|
65 |
+
<?php echo $_excl; ?>
|
66 |
+
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
|
67 |
+
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
|
68 |
+
<?php endif; ?>
|
69 |
+
</option>
|
70 |
+
<?php endif ?>
|
71 |
+
<?php endforeach; ?>
|
72 |
+
</optgroup>
|
73 |
+
<?php endforeach; ?>
|
74 |
+
</select>
|
75 |
+
<p class="actions">
|
76 |
+
<button id="update_shipping_method_submit" type="submit" class="button"><span><span><?php echo $this->__('Update Shipping Method') ?></span></span></button>
|
77 |
+
</p>
|
78 |
+
</fieldset>
|
79 |
+
</form>
|
80 |
+
<?php endif; ?>
|
81 |
+
<?php endif; ?>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
<?php endif; ?>
|
87 |
+
<div class="info-set col2-set">
|
88 |
+
<h2 class="legend"><?php echo $this->__('Billing Information') ?></h2>
|
89 |
+
<div class="col-1">
|
90 |
+
<div class="box">
|
91 |
+
<div class="box-title">
|
92 |
+
<h3><?php echo $this->__('Billing Address') ?></h3>
|
93 |
+
</div>
|
94 |
+
<div class="box-content">
|
95 |
+
<address>
|
96 |
+
<?php echo $this->getBillingAddress()->getFormated(true) ?><br />
|
97 |
+
<?php echo $this->__('Payer Email: %s', $this->getBillingAddress()->getEmail()) ?>
|
98 |
+
</address>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
<div class="info-set">
|
104 |
+
<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>
|
105 |
+
<div id="details-reload">
|
106 |
+
<?php echo $this->getChildHtml('details') ?>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl(); ?>">
|
110 |
+
<div class="buttons-set buttons-set-order" id="review-buttons-container">
|
111 |
+
<button id="review_button" value="<?php echo $this->__('Place an Order') ?>" title="<?php echo $this->__('Place an Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place an Order') ?></span></span></button>
|
112 |
+
<button type="submit" id="review_submit" value="<?php echo $this->__('Place an Order') ?>" title="<?php echo $this->__('Place an Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place an Order') ?></span></span></button>
|
113 |
+
<span class="please-wait" id="review-please-wait" style="display:none;">
|
114 |
+
<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...') ?>
|
115 |
+
</span>
|
116 |
+
</div>
|
117 |
+
</form>
|
118 |
+
<script type="text/javascript">
|
119 |
+
//<![CDATA[
|
120 |
+
<?php // submit buttons are not needed when submitting with ajax ?>
|
121 |
+
$('review_submit').hide();
|
122 |
+
if ($('update_shipping_method_submit')) {
|
123 |
+
$('update_shipping_method_submit').hide();
|
124 |
+
}
|
125 |
+
PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'),
|
126 |
+
$('shipping_method'), $('shipping_method_form'), 'details-reload'
|
127 |
+
);
|
128 |
+
PayPalExpressAjax.addPleaseWait($('review-please-wait'));
|
129 |
+
//]]>
|
130 |
+
</script>
|
app/design/frontend/base/default/template/computop/checkout/paypal/review/details.phtml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 17.05.2010 15:05:16
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
if ($this->helper('tax')->displayCartBothPrices()):
|
15 |
+
$colspan = $rowspan = 2;
|
16 |
+
else:
|
17 |
+
$colspan = $rowspan = 1;
|
18 |
+
endif;
|
19 |
+
?>
|
20 |
+
<table id="details-table" class="data-table">
|
21 |
+
<col />
|
22 |
+
<col width="1" />
|
23 |
+
<col width="1" />
|
24 |
+
<col width="1" />
|
25 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
26 |
+
<col width="1" />
|
27 |
+
<col width="1" />
|
28 |
+
<?php endif; ?>
|
29 |
+
<thead>
|
30 |
+
<tr>
|
31 |
+
<th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
|
32 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
|
33 |
+
<th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
34 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
|
35 |
+
</tr>
|
36 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
37 |
+
<tr>
|
38 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
39 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
40 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
41 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
42 |
+
</tr>
|
43 |
+
<?php endif; ?>
|
44 |
+
</thead>
|
45 |
+
<?php echo $this->getChildHtml('totals'); ?>
|
46 |
+
<tbody>
|
47 |
+
<?php foreach($this->getItems() as $_item): ?>
|
48 |
+
<?php echo $this->getItemHtml($_item) ?>
|
49 |
+
<?php endforeach; ?>
|
50 |
+
</tbody>
|
51 |
+
</table>
|
52 |
+
<script type="text/javascript">decorateTable('details-table');</script>
|
app/design/frontend/base/default/template/computop/checkout/paypal/shortcut.phtml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 17.05.2010 15:05:16
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
|
14 |
+
/* @var $this Dotsource_Computop_Block_Checkout_Paypal_Shortcut */
|
15 |
+
?>
|
16 |
+
<li>
|
17 |
+
<a href="<?php echo $this->getCheckoutUrl()?>" title="<?php echo Mage::helper('paypal')->__('PayPal Checkout');?>">
|
18 |
+
<img src="<?php echo $this->getImageUrl()?>" alt="<?php echo Mage::helper('paypal')->__('PayPal Checkout');?>" />
|
19 |
+
</a>
|
20 |
+
</li>
|
app/design/frontend/base/default/template/computop/form/cc.phtml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Cc */
|
11 |
+
?>
|
12 |
+
<fieldset class="form-list">
|
13 |
+
<?php $_code = $this->getMethodCode() ?>
|
14 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
15 |
+
<li>
|
16 |
+
<?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?>
|
17 |
+
</li>
|
18 |
+
</ul>
|
19 |
+
</fieldset>
|
app/design/frontend/base/default/template/computop/form/directpay.phtml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Directpay */
|
11 |
+
?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
14 |
+
<li>
|
15 |
+
<label for="<?php echo $_code ?>_eft_owner" class="required"><em>*</em><?php echo $this->__('Account holder') ?></label>
|
16 |
+
<div class="input-box">
|
17 |
+
<input type="text" id="<?php echo $_code ?>_eft_owner" name="payment[eft_owner]" title="<?php echo $this->__('Account holder') ?>" class="input-text required-entry" value="<?php echo $this->getEftOwner() ?>" />
|
18 |
+
</div>
|
19 |
+
</li>
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_eft_ban" class="required"><em>*</em><?php echo $this->__('Bank account number') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<input type="text" id="<?php echo $_code ?>_eft_ban" name="payment[eft_ban]" title="<?php echo $this->__('Bank account number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBan() ?>" />
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="<?php echo $_code ?>_eft_bcn" class="required"><em>*</em><?php echo $this->__('Bank code number') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input type="text" id="<?php echo $_code ?>_eft_bcn" name="payment[eft_bcn]" title="<?php echo $this->__('Bank code number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBcn() ?>" />
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
<li>
|
33 |
+
<?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?>
|
34 |
+
</li>
|
35 |
+
</ul>
|
app/design/frontend/base/default/template/computop/form/eft.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Eft */
|
11 |
+
?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
14 |
+
<li>
|
15 |
+
<label for="<?php echo $_code ?>_eft_owner" class="required"><em>*</em><?php echo $this->__('Account holder') ?></label>
|
16 |
+
<div class="input-box">
|
17 |
+
<input type="text" id="<?php echo $_code ?>_eft_owner" name="payment[eft_owner]" title="<?php echo $this->__('Account holder') ?>" class="input-text required-entry" value="<?php echo $this->getEftOwner() ?>" />
|
18 |
+
</div>
|
19 |
+
</li>
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_eft_ban" class="required"><em>*</em><?php echo $this->__('Bank account number') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<input type="text" id="<?php echo $_code ?>_eft_ban" name="payment[eft_ban]" title="<?php echo $this->__('Bank account number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBan() ?>" />
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="<?php echo $_code ?>_eft_bcn" class="required"><em>*</em><?php echo $this->__('Bank code number') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input type="text" id="<?php echo $_code ?>_eft_bcn" name="payment[eft_bcn]" title="<?php echo $this->__('Bank code number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBcn() ?>" />
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
</ul>
|
app/design/frontend/base/default/template/computop/form/giropay.phtml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Giropay */
|
11 |
+
?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
14 |
+
<li>
|
15 |
+
<label for="<?php echo $_code ?>_eft_owner" class="required"><em>*</em><?php echo $this->__('Account holder') ?></label>
|
16 |
+
<div class="input-box">
|
17 |
+
<input type="text" id="<?php echo $_code ?>_eft_owner" name="payment[eft_owner]" title="<?php echo $this->__('Account holder') ?>" class="input-text required-entry" value="<?php echo $this->getEftOwner() ?>" />
|
18 |
+
</div>
|
19 |
+
</li>
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_eft_ban" class="required"><em>*</em><?php echo $this->__('Bank account number') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<input type="text" id="<?php echo $_code ?>_eft_ban" name="payment[eft_ban]" title="<?php echo $this->__('Bank account number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBan() ?>" />
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="<?php echo $_code ?>_eft_bcn" class="required"><em>*</em><?php echo $this->__('Bank code number') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input type="text" id="<?php echo $_code ?>_eft_bcn" name="payment[eft_bcn]" title="<?php echo $this->__('Bank code number') ?>" class="input-text required-entry validate-number" value="<?php echo $this->getEftBcn() ?>" />
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
<li>
|
33 |
+
<?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?>
|
34 |
+
</li>
|
35 |
+
</ul>
|
app/design/frontend/base/default/template/computop/form/ideal.phtml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
**/
|
10 |
+
/* @var $this Dotsource_Computop_Block_Form_Ideal */
|
11 |
+
?>
|
12 |
+
<fieldset class="form-list">
|
13 |
+
<?php $_code = $this->getMethodCode() ?>
|
14 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
15 |
+
<li>
|
16 |
+
<?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?>
|
17 |
+
</li>
|
18 |
+
</ul>
|
19 |
+
</fieldset>
|
app/design/frontend/base/default/template/computop/form/mpass.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 03.05.2010 10:44:25
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
<fieldset class="form-list">
|
15 |
+
<?php $_code = $this->getMethodCode() ?>
|
16 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
17 |
+
<li>
|
18 |
+
<?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?>
|
19 |
+
</li>
|
20 |
+
</ul>
|
21 |
+
</fieldset>
|
app/design/frontend/base/default/template/computop/form/paypalstandard.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Created:
|
8 |
+
* 27.04.2010 14:25:17
|
9 |
+
*
|
10 |
+
* Contributors:
|
11 |
+
* dcarl - initial contents
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
|
15 |
+
<li><?php echo $this->__('At the End of the checkout you get redirected to the payment site.'); ?></li>
|
16 |
+
</ul>
|
app/design/frontend/base/default/template/computop/info/callback.phtml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2008-2010 dotSource GmbH.
|
4 |
+
* All rights reserved.
|
5 |
+
* http://www.dotsource.de
|
6 |
+
*
|
7 |
+
* Contributors:
|
8 |
+
* ewohllebe - initial contents
|
9 |
+
*/
|
10 |
+
/* @var $this Mage_Payment_Block_Info */
|
11 |
+
?>
|
12 |
+
<?php echo $this->escapeHtml($this->getMethod()->getTitle()); ?>
|
13 |
+
|
14 |
+
<?php if ($_specificInfo = $this->getSpecificInformation()):?>
|
15 |
+
<table>
|
16 |
+
<?php foreach ($_specificInfo as $_label => $_value):?>
|
17 |
+
<tr>
|
18 |
+
<td><?php echo $this->escapeHtml($_label)?>:</td>
|
19 |
+
<td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
|
20 |
+
</tr>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</table>
|
23 |
+
<?php endif;?>
|
24 |
+
|
25 |
+
<br/><?php echo $this->escapeHtml($this->__('At the End of the checkout you get redirected to the payment site.')); ?>
|
26 |
+
|
27 |
+
<?php echo $this->getChildHtml()?>
|
app/etc/modules/Dotsource_Computop.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Dotsource_Computop>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
<Mage_Sales />
|
10 |
+
<Mage_Checkout />
|
11 |
+
<Mage_Customer />
|
12 |
+
<Mage_Adminhtml />
|
13 |
+
</depends>
|
14 |
+
</Dotsource_Computop>
|
15 |
+
</modules>
|
16 |
+
</config>
|
app/etc/modules/Dotsource_Dsrevision.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
**************************************************************************
|
4 |
+
*
|
5 |
+
* XML erstellt von / created by:
|
6 |
+
*
|
7 |
+
* dotSource GmbH
|
8 |
+
* http://www.dotsource.de
|
9 |
+
*
|
10 |
+
**************************************************************************
|
11 |
+
-->
|
12 |
+
|
13 |
+
<config>
|
14 |
+
<modules>
|
15 |
+
<Dotsource_Dsrevision>
|
16 |
+
<active>true</active>
|
17 |
+
<codePool>community</codePool>
|
18 |
+
</Dotsource_Dsrevision>
|
19 |
+
</modules>
|
20 |
+
</config>
|
app/locale/de_DE/Dotsource_Computop.csv
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Acceptance Mark","Acceptance Mark"
|
2 |
+
"Account holder", "Kontoinhaber"
|
3 |
+
"Action","Aktion"
|
4 |
+
"Add New Merchant", "Neuen Händler hinzufügen"
|
5 |
+
"Merchant ID", "Merchant-ID"
|
6 |
+
"Merchant Encryption Password", "Merchant-Verschlüsselungs-Passwort"
|
7 |
+
"Merchant Hmac", "Merchant-HMAC"
|
8 |
+
"Merchant Password", "Merchant-Passwort"
|
9 |
+
"Global Connection Settings", "Globale Verbindungseinstellungen"
|
10 |
+
"Advanced transaction management", "Erweitertes Transaktions Management"
|
11 |
+
"All Allowed Countries", "Alle Länder"
|
12 |
+
"Allow all countries", "Alle Länder zulassen"
|
13 |
+
"Allow all ip zones", "Alle IP-Zonen zulassen"
|
14 |
+
"Allow any countries", "Bestimmte Länder zulassen"
|
15 |
+
"Allow IP zones", "Zugelassene IP-Zonen"
|
16 |
+
"Allow specific ip zones", "Bestimmte IP-Zonen zulassen"
|
17 |
+
"Restrict specific ip zones", "Bestimmte IP-Zonen ausschließen"
|
18 |
+
"Allow/Restrict countries", "Zulassen/Ausschließen von Ländern"
|
19 |
+
"At the End of the checkout you get redirected to the payment site.", "Am Ende des Bestellprozesses werden Sie auf die Zahlungsseite umgeleitet."
|
20 |
+
"Authorization","Autorisierung"
|
21 |
+
"Bank account number", "Kontonummer"
|
22 |
+
"Bank Code Number Available Check", "BLZ Verfügbarkeitsprüfung"
|
23 |
+
"Bank code number", "Bankleitzahl"
|
24 |
+
"Base URL", "Basis-URL"
|
25 |
+
"Choose allowed/restricted countries", "Zugelassene/ Ausgeschlossene Länder auswählen"
|
26 |
+
"Created At","Erzeugt am"
|
27 |
+
"Computop Transaction", "Computop-Transaktion"
|
28 |
+
"Currency", "Währung"
|
29 |
+
"Debit in x hours", "Belastung in x Stunden"
|
30 |
+
"Debit on Delivery", "Belastung bei Lieferung"
|
31 |
+
"Enabled", "Aktiviert"
|
32 |
+
"Error Code","Fehlernummer"
|
33 |
+
"Description","Beschreibung"
|
34 |
+
"Immediate payment", "Sofortige Belastung"
|
35 |
+
"ID","ID"
|
36 |
+
"IP Zones", "IP-Zonen"
|
37 |
+
"No", "Nein"
|
38 |
+
"Order","Order"
|
39 |
+
"PayID,"PayID"
|
40 |
+
"Payment Action", "Buchungsmethode"
|
41 |
+
"Payment moment", "Buchungszeitpunkt"
|
42 |
+
"Payment to applicable countries", "Umfang der Zahlungszulassung"
|
43 |
+
"Payment to Specific countries", "Zahlungszulassung für bestimmte Länder"
|
44 |
+
"Please click here to open the payment gateway in the current window.", "Klick Sie hier um das Zahlungs-Gateway im aktuellen Fenster zu öffnen."
|
45 |
+
"Pre-Fill Payment Information", "Zahlungsinformationen vorausfüllen"
|
46 |
+
"Credit Card Nr.", "Kreditkarten-Nr."
|
47 |
+
"Restrict any countries", "Bestimmte Länder ausschließen"
|
48 |
+
"Sort order", "Sortierreihenfolge"
|
49 |
+
"Successful","Erfolgreich"
|
50 |
+
"Specific Countries", "Bestimmte Länder"
|
51 |
+
"Specific Credit Card Account Information", "Spezifische Händlerinformationen für Kreditkarten"
|
52 |
+
"The iframe url to the computop paygate is missing. Please try again to pay or choose another payment method.", "Die iframe-Url zum Computop Paygate fehlt. Bitte versuchen Sie erneut zu bezahlen oder wählen Sie eine andere Zahlungsart."
|
53 |
+
"Title", "Titel"
|
54 |
+
"TransactionID","Transactions Id"
|
55 |
+
"Unable to initialize Express Checkout","Express Bestellprozess konnte nicht initialisiert werden"
|
56 |
+
"Visible on Shopping Cart Page","Auf Warenkorbseite sichtbar"
|
57 |
+
"XID","XID"
|
58 |
+
"RefNr","RefNr"
|
59 |
+
"Yes", "Ja"
|
60 |
+
"You can setup specify account data for the payment method credit card. If you don't setup any currency the global account settings are used.", "Sie haben die Möglichkeit spezifische Händlerdaten für die Zahlungsart Kreditkarte anzulegen. Wenn Sie keine spezifische Händlerdaten anlegen werden die globalen Händlerdaten benutzt."
|
61 |
+
"Your billing address will be ignored and you will be redirected to PayPal website.","Ihre Rechnungsadresse wird ignoriert und Sie werden bei Bestellabschluss zu PayPal weitergeleitet."
|
62 |
+
"Your browser doesn't support iframes.", "Ihr Browser unterstützt keine iframes."
|
63 |
+
"You will be redirected to PayPal website when you place an order.", "Am Ende des Bestellprozesses werden Sie zu PayPal weitergeleitet."
|
64 |
+
"You can only create a credit memo in referenced to an invoiced.", "Sie können nur zu einer referenzierten Rechung eine Gutschrift erstellen."
|
65 |
+
"You can only create online credit memos.", "Sie können nur online Gutschriften erstellen."
|
66 |
+
"The payment method not allow to refund.", "Die Zahlungsmethode erlaubt keine online Gutschrift."
|
67 |
+
"Use Pseudo Credit Card Information", "Benutze Pseudo-Kreditkartendaten"
|
68 |
+
"No credit memo available.", "Es ist keine Gutschrift verfügbar"
|
69 |
+
"The credit memo has no referenced invoice available.", "Die Gutschrift hat keine referenzierte Rechung."
|
70 |
+
"Transaction Code", "Transaktions-Code"
|
71 |
+
"Request PayID", "Bezugs-Pay-ID"
|
72 |
+
"Response PayID", "Antwort-Pay-ID"
|
73 |
+
"Use XSLT Template", "XSLT-Template Benutzen"
|
74 |
+
"Template Name", "Templatename"
|
75 |
+
"PayPal Checkout","PayPal Bestellung"
|
76 |
+
"Missing message for error code ""%s"".", "Keine Nachricht für den Fehlercode ""%s"" vorhanden."
|
77 |
+
"The current used credit card can not use for the checkout. Please use another credit card or another payment method.", "Die von Ihnen verwendete Kreditkarte kann nicht verarbeitet werden. Bitte wählen Sie eine andere Kreditkarte oder eine andere Zahlart aus."
|
78 |
+
"Your are not allowed to use the current payment method. Please use another payment method.", "Die von Ihnen gewählte Zahlart steht zur Zeit nicht zur Verfügung. Bitte wählen Sie eine andere Zahlart aus."
|
79 |
+
"Computop Credit Card", "Computop Kreditkarte"
|
80 |
+
"Computop Direct Debit", "Computop Lastschrift"
|
81 |
+
"Computop giropay", "Computop giropay"
|
82 |
+
"Computop iDeal", "Computop iDeal"
|
83 |
+
"Computop Direct Pay", "Computop Sofortüberweisung"
|
84 |
+
"Computop mpass", "Computop mpass"
|
85 |
+
"Computop PayPal", "Computop PayPal"
|
86 |
+
"Computop PayPal Express", "Computop PayPal Express"
|
87 |
+
"Your bank don't support this payment method.", "Ihre Bank unterstützt diese Zahlungsart nicht."
|
88 |
+
"The book date is %s.", "Das Buchungsdatum ist am %s."
|
89 |
+
"Reference", "Verwendungszweck"
|
90 |
+
"1. Reference Line", "1. Verwendungszweck-Zeile"
|
91 |
+
"2. Reference Line", "2. Verwendungszweck-Zeile"
|
92 |
+
"Review Order","Bestellübersicht"
|
93 |
+
"Shipping Information","Versandinformation"
|
94 |
+
"Shipping Address","Versandadresse"
|
95 |
+
"Shipping Method","Versandart"
|
96 |
+
"No shipping method required.","Keine Versandart nötig."
|
97 |
+
"Sorry, no quotes are available for this order at this time.","Entschuldigung, momentan gibt es keine Angebote für diese Bestellung."
|
98 |
+
"Please select a shipping method...","Bitte wählen Sie eine Versandart..."
|
99 |
+
"Incl. Tax","Inkl. MwSt."
|
100 |
+
"Update Shipping Method","Versandart ändern"
|
101 |
+
"Billing Information","Rechnungsinformation"
|
102 |
+
"Billing Address","Rechnungsadresse"
|
103 |
+
"Payer Email: %s","Rechnungs E-Mail: %s"
|
104 |
+
"Items in Your Shopping Cart","Artikel in Ihrem Warenkorb"
|
105 |
+
"Edit Shopping Cart","Warenkorb bearbeiten"
|
106 |
+
"Place an Order","Bestellung aufgeben"
|
107 |
+
"Submitting order information...","Bestellung wird übermittelt..."
|
108 |
+
"Product Name","Produktname"
|
109 |
+
"Price","Preis"
|
110 |
+
"Qty","Stück"
|
111 |
+
"Subtotal","Zwischensumme"
|
112 |
+
"Waiting For Capture Notification", "Warte auf Buchungsbestätigung"
|
113 |
+
"Waiting For Authorization Notification", "Warte auf Autorisierungsbestätigung"
|
114 |
+
"Ready For Computop Capture Action", "Bereit für Computop-Buchung"
|
115 |
+
"Please check your bank account number and bank code number.", "Bitte überprüfen Sie Ihre Kontonummer und Bankleitzahl."
|
116 |
+
"Your account holder is invalid.", "Ihr Kontoinhaber ist ungültig."
|
117 |
+
"Your bank account number is invalid.", "Ihre Kontonummer ist ungültig."
|
118 |
+
"Your bank code number is invalid.", "Ihre Bankleitzahl ist ungültig."
|
119 |
+
"If your not getting redirected click here.", "Wenn Sie nicht weitergeleitet werden, klicken Sie bitte hier."
|
120 |
+
"The capture was failed the order will be canceled.", "Das Buchen schlug fehl, die Bestellung wird storniert."
|
121 |
+
"The authorization was failed the order will be canceled.", "Das Autorisieren schlug fehl, die Bestellung wird storniert."
|
122 |
+
"The authorization/capture was failed but the order can't cancel.", "Das Autorisieren/Buchen schlug fehl, die Bestellung konnte aber nicht storniert werden."
|
123 |
+
"Are you sure you want to cancel this order and refund an amount of %s?", "Sind Sie sicher die aktuelle Bestellung zu stornieren und den Betrag von %s zurückzubuchen?"
|
124 |
+
"CT: Create Invoice", "CT: Rechnung erstellen"
|
125 |
+
"CT: Create Invoice and Shipment", "CT: Rechnung und Lieferung erstellen"
|
126 |
+
"Credit Card Type", "Kreditkartenmarke"
|
127 |
+
"The order #%s has already %s invoice(s).", "Die Bestellung #%s besitzt bereits %s Rechnung(en)."
|
128 |
+
"Can't create invoice for order #%s.", "Es konnte keine Rechnung für die Bestellung #%s erstellt werden."
|
129 |
+
"The order #%s was not paid with a computop payment and can't invoiced.", "Die Bestellung #%s wurde nicht mit einer Computop-Zahlungsart bezahlt und kann deswegen nicht in Rechnung gestellt werden."
|
130 |
+
"The order #%s can't capture.", "Die Bestellung #%s kann nicht in Rechnung gestellt werden."
|
131 |
+
"Can't create shipment for order #%s.", "Es konnten keine Lieferungen für die Bestellung #%s erstellt werden."
|
132 |
+
"Can't create invoice and shipment for order #%s. (%s)", "Es konnte keine Rechnung und Lieferung für die Bestellung #%s erstellt werden. (%s)"
|
133 |
+
"Can't create invoice for order #%s. (%s)", "Es konnte keine Rechnung für die Bestellung #%s erstellt werden."
|
134 |
+
"Successfully create invoice and shipment for order #%s in amount of %s.", "Es konnte eine Rechnung und Lieferung, für die Bestellung #%s, erfolgreich in Höhe von %s erstellt werden."
|
135 |
+
"Successfully create invoice for order #%s in amount of %s.", "Es konnte eine Rechnung, für die Bestellung #%s, erfolgreich in Höhe von %s erstellt werden."
|
136 |
+
"Successfully refund an amount of %s from invoice #%s.", "Der Betrag von %s konnte erfolgreich von der Rechnung #%s zurückgebucht werden."
|
137 |
+
"Can't refund the amount of %s from invoice #%s. (%s)", "Der Betrag von %s kann nicht von der Rechnung #%s zurückgebucht werden."
|
138 |
+
"Can't refund the invoice #%s.", "Es kann kein Betrag von der Rechnung #%s zurückgebucht werden."
|
139 |
+
"Credit Card Payment Gateway", "Kreditkarten Payment Gateway"
|
140 |
+
"No orders selected with the status ""%s"".", "Es wurden keine Bestellungen mit dem Status ""%s"" ausgewählt."
|
141 |
+
"Credit Card Logos","Kreditkarten Logos"
|
142 |
+
"Giropay Logo","Giropay Logo"
|
143 |
+
"EFT Logo","EFT Logo"
|
144 |
+
"Directpay Logo","Directpay Logo"
|
145 |
+
"iDeal Logo","iDeal Logo"
|
146 |
+
"Mpass Logo","Mpass Logo"
|
147 |
+
"PayPal Logo","PayPal Logo"
|
148 |
+
"Maximum length is 756. Attention: some special characters will deleted automatically.", "Maximum beträgt 756 Zeichen. Achtung: Einige Sonderzeichen werden automatisch gelöscht."
|
149 |
+
"Maximum length is 27. Attention: some special characters will deleted automatically.", "Maximum beträgt 27 Zeichen. Achtung: Einige Sonderzeichen werden automatisch gelöscht."
|
150 |
+
"Maximum length is 15. Attention: some special characters will deleted automatically.", "Maximum beträgt 15 Zeichen. Achtung: Einige Sonderzeichen werden automatisch gelöscht."
|
151 |
+
"Maximum length is 756", "Maximum beträgt 756 Zeichen"
|
152 |
+
"Maximum length is 115", "Maximum beträgt 115 Zeichen"
|
153 |
+
"Maximum length is 47", "Maximum beträgt 47 Zeichen"
|
154 |
+
"Maximum length is 27", "Maximum beträgt 27 Zeichen"
|
155 |
+
"Maximum length is 15", "Maximum beträgt 15 Zeichen"
|
156 |
+
"The customer quit the payment gateway the order will be canceled.", "Der Kunde hat den Payment Gatway verlassen, die Bestellung wird stornieren."
|
157 |
+
"The customer quit the payment gateway but the order can't cancel.", "Der Kunde hat den Payment Gatway verlassen, die Bestellung konnte aber nicht stornieren werden."
|
158 |
+
"Transaction ID: ""%s"".", "Transaktions-ID: ""%s""."
|
159 |
+
"Amount of %s pending approval on gateway.", "Die Buchungs-Genehmigung des Betrages von %s steht noch aus."
|
160 |
+
"Captured amount of %s online.", "Die Buchung des Betrages von %s wurde online durchgeführt."
|
161 |
+
"Registered notification about captured amount of %s.", "Es wurde eine Verbuchung des Betrages von %s verzeichnet."
|
162 |
+
"Refunded amount of %s online.", "Die Online-Rückbuchung von %s wurde erfolgreich durchgeführt."
|
163 |
+
"Refunded amount of %s offline.", "Es wurde eine Offline-Rückbuchung von %s durchgeführt."
|
164 |
+
"Authorization amount %s pending approval on gateway.", "Die Autorisierungs-Genehmigung des Betrages von %s steht noch aus."
|
165 |
+
"Authorized amount of %s.", "Die Autorisierung des Betrages von %s wurde online durchgeführt."
|
166 |
+
"Registered notification about authorized amount of %s.", "Es wurde eine Autorisierung des Betrages von %s verzeichnet."
|
167 |
+
"Voided authorization.", "Die Autorisierung wurde zurückgezogen."
|
168 |
+
"Amount: %s.", "Betrag %s."
|
169 |
+
"Missing message for error code "%s".", "Nachricht für Fehlercode ""%s"" fehlt."
|
170 |
+
"There was an undocumented error by processing your payment. Please try again or choose another payment method.", "Beim Verarbeiten Ihrer Bestellung kam es leider zu einem undokumentierten Fehler. Bitten versuchen Sie es erneut oder wählen Sie eine andere Zahlungsart."
|
171 |
+
"Pseudo Credit Card Nr.","Pseudokreditkarten-Nr."
|
172 |
+
"Authorizing amount of %s is pending approval on gateway.", "Die Autorisierungs-Genehmigung des Betrages von %s steht noch aus."
|
173 |
+
"Your secure base url is not secure. Please use an url starting with ""https://"". Otherwise the Computop payment module is not activated.", "Ihre sichere Basis-Url ist ungesichert. Bitte nutzen Sie eine Url die mit ""https://"" beginnt. Andernfalls ist das Computop-Payment-Modul nicht aktiv."
|
174 |
+
"Please change this <a href=""%s"">configuration</a>.", "Bitte ändern Sie diese <a href=""%s"">Einstellung</a>."
|
175 |
+
"You'r not allowed to use the PayPal Express Checkout with other payments apart from PayPal.", "Sie können keine PayPal Express-Zahlung mit anderen Zahlungsarten nutzen außer PayPal."
|
176 |
+
"Please check your account owner.", "Bitte überprüfen Sie Ihren Kontoinhaber."
|
177 |
+
"You'r current quote is not valid to use PayPal express checkout.", "Ihr aktueller Warenkorb kann nicht für den PayPal Express-Kauf benutzt werden."
|
178 |
+
"Capture", "Buchung"
|
179 |
+
"Refund", "Rückbuchung"
|
180 |
+
"Void", "Stornierung (Void)"
|
181 |
+
"Transactions", "Transaktionen"
|
182 |
+
"Is Closed", "Geschlossen"
|
183 |
+
"Transaction Type", "Transaktionstyp"
|
184 |
+
"Payment Method Name", "Zahlungsmethoden-Name"
|
185 |
+
"Parent Transaction ID", "Bezugs-Transaktionsnummer"
|
186 |
+
"Transaction ID", "Transaktionsnummer"
|
187 |
+
"Order ID", "Bestell-Nr."
|
188 |
+
"From", "Von"
|
189 |
+
"To", "Bis"
|
package.xml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Official_Computop_Payment_Modul</name>
|
4 |
+
<version>1.0.0.16623</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>The modul provides a large base of Computop payment services.</summary>
|
10 |
+
<description>The modul provides a large base of Computop payment services.
|
11 |
+
This includes:
|
12 |
+
• Computop CreditCard
|
13 |
+
• Computop DirectDebit
|
14 |
+
• Computop giropay
|
15 |
+
• Computop iDeal
|
16 |
+
• Computop DirectTransfer
|
17 |
+
• Computop mpass
|
18 |
+
• Computop PayPal
|
19 |
+
• Computop PayPal Express</description>
|
20 |
+
<notes>Released at Revision 16623</notes>
|
21 |
+
<authors><author><name>Christian Mailk</name><user>auto-converted</user><email>c.malik@dotsource.de</email></author></authors>
|
22 |
+
<date>2010-09-03</date>
|
23 |
+
<time>15:48:16</time>
|
24 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="computop.xml" hash="d851e1863b88c9a748a0bc779cb85112"/></dir><dir name="template"><dir name="computop"><dir name="config"><dir name="form"><dir name="field"><file name="form.phtml" hash="3f8e9dc1af4f288b01042c9f7a3d49ba"/></dir></dir></dir><dir name="depends"><file name="allallowedcountries.phtml" hash="d261d51166fd0c7ac7895a8927b025ca"/><file name="ipzones.phtml" hash="f47d15e58f1b81c2e1cdf68f02dc185d"/></dir><dir name="form"><file name="eft.phtml" hash="7e438648fbd306706fcf1175e44dcdb7"/></dir><dir name="info"><file name="callback.phtml" hash="f0095596bc9012287901846660099bac"/></dir><dir name="notification"><file name="secureurl.phtml" hash="00b317c6dd96cdd763afde00f8dcb3ff"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="computop.xml" hash="19515e1f07beafcfd1c195cdeb4380db"/></dir><dir name="template"><dir name="computop"><dir name="checkout"><dir name="paypal"><dir name="review"><file name="details.phtml" hash="3b3eb20cb459a6acb203829e9575f335"/></dir><file name="review.phtml" hash="f61a7c443a0e63225f19b163fa313b75"/><file name="shortcut.phtml" hash="9393a77a632aa03d99eab6654b46b9a9"/></dir><file name="iframe.phtml" hash="f8a92c88bdee6ecd9bf079873f654037"/></dir><dir name="form"><file name="cc.phtml" hash="2013446b94f9a86acaa3e5e65ca4902f"/><file name="directpay.phtml" hash="02c0a2ee5f2eaefed5320ed5ad73c366"/><file name="eft.phtml" hash="7e438648fbd306706fcf1175e44dcdb7"/><file name="giropay.phtml" hash="a848b3a60eda44cb5c2f1f794514debb"/><file name="ideal.phtml" hash="9a99b16e4a6e43d52f169791a58b3caf"/><file name="mpass.phtml" hash="ddc53e51557867d91c6aed4f4b825159"/><file name="paypalstandard.phtml" hash="caa6d6aefa7f33d8be6591d83462e247"/></dir><dir name="info"><file name="callback.phtml" hash="3a7cb0db35de546e3df8344ac95502c3"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Dotsource_Computop.csv" hash="4ec3679e1766246be367305f7dcfb786"/></dir></target><target name="magecommunity"><dir name="Dotsource"><dir name="Computop"><dir name="Block"><dir name="Adminhtml"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="afb5f33d5cef154b03ac002ac1cdb143"/></dir></dir></dir><dir name="Notification"><file name="Secureurl.php" hash="f85d6a19227237bd3d59b742515ac173"/></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Action.php" hash="a400c817c579bae8772bab9742eb9f0f"/></dir></dir><file name="View.php" hash="a7eb2d8a19623d8cc9831beaa55ac598"/></dir></dir></dir><dir name="Checkout"><dir name="Paypal"><dir name="Review"><file name="Details.php" hash="f5971c378a10e278227743b975196a53"/></dir><file name="Review.php" hash="b705ca0ea0d75a4cd602c783257334fe"/><file name="Shortcut.php" hash="0f04e5bdf617ff47c89b69c3bbc002e7"/></dir><file name="Iframe.php" hash="400736118314701b674f34e3f24adec9"/></dir><dir name="Config"><dir name="Form"><dir name="Renderer"><file name="Select.php" hash="ca2d3e9fd728858ec79c7cb46be772a4"/></dir><file name="Abstract.php" hash="a287b26fda7b9c0e13f102289ba6069a"/><file name="Merchant.php" hash="20926cf37621e1ee9cfcc68425ca9d3c"/></dir></dir><dir name="Form"><file name="Abstract.php" hash="f2791cd731a32019ca7f2b9f5dc56489"/><file name="Cc.php" hash="822ff807573d8aa14439431c885bf73a"/><file name="Directpay.php" hash="c0fda4901e4726d7ae91e89e5252b125"/><file name="Eft.php" hash="fd4aded4ccf89dc597d9e6a1f9fe762a"/><file name="Giropay.php" hash="e154a62ed3742d390b7e366aaf335646"/><file name="Ideal.php" hash="f99578c74c082bee1919050216524bb1"/><file name="Mpass.php" hash="921ab65935c02b0746ac6822cb3806e8"/><file name="Paypalexpress.php" hash="04b06d78dccf96f8a1c32040d47217cf"/><file name="Paypalstandard.php" hash="dcf4326fcf0f3481c06c2e5c0cd89e20"/></dir><dir name="Info"><file name="Cc.php" hash="8689a58ef520259091e202c108944136"/><file name="Directpay.php" hash="a18eff351d2b284ce64bd4ec1c861999"/><file name="Eft.php" hash="c9f2e40567b3b72085443f7ba4f4cfc3"/><file name="Giropay.php" hash="5a996683c63a2a48a1e4f13320668ed1"/><file name="Ideal.php" hash="358a1e9c50d091ad4d13d3d684a20762"/><file name="Mpass.php" hash="ef5ddf92f5f93a4d3ac571fb8988ced5"/><file name="Paypalstandard.php" hash="abc2e1b4996448a14814689151abe4a7"/></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Zerofill.php" hash="ba6a4c6923d0faa27f6c2707d226695e"/></dir></dir></dir></dir></dir><dir name="Controller"><file name="Callback.php" hash="6f7e3a153ad5e2f382360e58268c8beb"/><file name="Computopcallback.php" hash="521e919539b3a2f18f4a0bfb80126f51"/><file name="Expresscallback.php" hash="302cc0e24cd3062dbdb36869a3160301"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ActionController.php" hash="51489ad4d9fc9c310efbf6a06df21324"/><file name="MassactionController.php" hash="5c72965e8e8fc7c937d755c593e70172"/></dir><dir name="Callback"><file name="CcController.php" hash="495a09c893f0c4afc5f07b2cb440d230"/><file name="DirectpayController.php" hash="fc20fb67af25324d3be9ee07e97e9b6b"/><file name="GiropayController.php" hash="0c58c7dc7744a9f4b944d7fc151c3561"/><file name="IdealController.php" hash="5e2e443d675ea958c3f4faf280ddf53a"/><file name="MpassController.php" hash="75fb275966e9cb2a479d8df2589d0dd8"/><file name="PaypalController.php" hash="f4adcdca639b0d70b84c088868fbcd59"/><file name="PaypalexpressController.php" hash="086fa25918c4b3ce220c80ec3625d533"/></dir><file name="IframeController.php" hash="7572bf27391cd8331ae70a38e084a98d"/><file name="IndexController.php" hash="50bcc19a72bea98d4833ddc8ee894f3c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9107783406db7df9087734fa944d50a4"/><file name="config.xml" hash="ed82f545c6421f436d526aeb8860ab48"/><file name="errors.xml" hash="2d518db252889668bafe218cb2e247fe"/><file name="system.xml" hash="6b28ff2fdf646eed290f1c3d9fb7f79b"/></dir><dir name="Helper"><dir name="Paypal"><file name="Config.php" hash="f4c839e7d686e23d5a23a9709bc3585e"/></dir><file name="Config.php" hash="c5d656f5463a31e49d701f253074a0d2"/><file name="Converter.php" hash="8153516b4a5de30efbad60d536b6d06d"/><file name="Data.php" hash="2a894c56fec70c746b7a7029406ad20a"/><file name="Feature.php" hash="704f75593ad24f23808414410c04565d"/><file name="Payment.php" hash="c5f22e7d28eaf96fd5f6151ebb2fd308"/></dir><dir name="Model"><dir name="Error"><dir name="Handler"><file name="Abstract.php" hash="8b136efb969f303657cdf1f60f167f3f"/><file name="Exception.php" hash="9883a7687935df31d3dedc86424835b4"/><file name="Message.php" hash="d738b19157463a6f4b42fe7bb189f7a8"/><file name="Session.php" hash="7c77d81ff03ba3c0d6315b7949b42bf2"/><file name="Translate.php" hash="fdcfe4dc637afb87efa2fb433a4ae585"/></dir><file name="Manager.php" hash="bf22cedd241d337e2f4de5a83ed3a1d7"/><file name="Observer.php" hash="0bda49d2dd243a75e9d6b0ec4fc6f5c1"/></dir><dir name="Mysql4"><dir name="Action"><file name="Collection.php" hash="7ee614cb4c4a575ea390aa11289b9422"/></dir><dir name="Transaction"><file name="Collection.php" hash="9b1852b15cfab7c227271be62ebb20ba"/></dir><file name="Action.php" hash="8c35a152e7f864ab543d22cb0debba97"/><file name="Setup.php" hash="ed7f53b5d54ad87a4a58486ed5c5847c"/><file name="Transaction.php" hash="3c42d3816ffd75f1b0aac04d7d9c7985"/></dir><dir name="Observer"><file name="Session.php" hash="b56119142391d686c253eeb0c6455b69"/></dir><dir name="Payment"><dir name="Request"><dir name="Cc"><dir name="Capture"><file name="New.php" hash="0dbe7a56458c3d83e0ed31da5895e126"/></dir><file name="Authorize.php" hash="0e73ef051d18af834a66b6cc3784bffe"/></dir><dir name="Default"><file name="Capture.php" hash="273aaf3f066f767749937cad1c208919"/><file name="Refund.php" hash="c9f79a743ade1e18d4617345daa1d0f5"/><file name="Reverse.php" hash="756f74ba40128b19d7ce673cb81477e8"/></dir><dir name="Directpay"><file name="Authorize.php" hash="ea77b1b9a8ac64862a39c350a35baa72"/></dir><dir name="Eft"><file name="Authorize.php" hash="a6c78d78a3e327e7d3c071d83e2805de"/></dir><dir name="Giropay"><file name="Authorize.php" hash="78c14f936da49bd58d79573b295d4fef"/><file name="Check.php" hash="311988d36dc33f6c50403f13cba64053"/></dir><dir name="Ideal"><file name="Authorize.php" hash="d9985c1677d02b347f56d14838109c64"/></dir><dir name="Mpass"><file name="Authorize.php" hash="cabfbeb60df5cc1229f75f94c75dc5a9"/></dir><dir name="Paypal"><file name="Authorize.php" hash="f4502b7aef50535c71c102beeb2ac7de"/></dir><dir name="Paypalexpress"><file name="Authorize.php" hash="987ed2dc70052967505008f48dde4256"/></dir><file name="Request.php" hash="a5923ebd420f62cb25536316390ff2be"/></dir><dir name="Response"><dir name="Giropay"><file name="Check.php" hash="0df5b6503c951302b1fc2b3a3c3a8f58"/></dir><file name="Response.php" hash="7982d75ba2efc3af7b987db51d80c931"/></dir><file name="Abstract.php" hash="f16ac204b64311e41df72cf84accc518"/><file name="Cc.php" hash="18145e8fd7db5b2a662201b4ef91cc43"/><file name="Directpay.php" hash="1faaff7f3399cbb588111e14339e4aed"/><file name="Eft.php" hash="6ffafb44ca24e320b7008f37dd88b401"/><file name="Giropay.php" hash="e7684a64f8bbdbea744514e35bf1de4a"/><file name="Ideal.php" hash="5bbc7be96d41d6c306a741eda9463f1b"/><file name="Mpass.php" hash="9a4d7887af61523dfb64b27de408942a"/><file name="Paypalexpress.php" hash="4b39b7800a6e9ae0e1d55da9d57f47ed"/><file name="Paypalstandard.php" hash="a1146edec62a4911bb000f13ec3336b0"/></dir><dir name="Rewrite"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="b977f74bea49f71a2618bdda3389bc1d"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Serialized"><file name="Merchant.php" hash="532f1574c416b562e207c2e5a414d6e9"/></dir><file name="Orderdesc.php" hash="24eab78a1de3626ce66022663742a14b"/></dir><dir name="Source"><file name="Abstract.php" hash="87700cc4dd02b93310df846376e995c6"/><file name="AllowedcountriesAction.php" hash="9c35b66ce30cdf611a4e57d1d5aa3256"/><file name="AllowedipzonesAction.php" hash="c6306415a075def83ead0faadc1189ec"/><file name="Baseurl.php" hash="f0ec88b5fc69e60e01932397841af703"/><file name="Countryiso3.php" hash="e380f0dfefb4646d6715f7045cc37bc2"/><file name="Logos.php" hash="c8f683dbad121f1ac0fce70c5d48083d"/><file name="Modus.php" hash="a8dd324ef4cbc066e3cb4489ce405551"/><file name="Paymentaction.php" hash="431513680846433772f20d2ef2049f51"/><file name="Paypalpaymentaction.php" hash="0e6d624bee68178b928521fb30a5bdcc"/><file name="Txtype.php" hash="90143d404d40fc4245c2e61285eec284"/></dir></dir></dir><file name="Action.php" hash="e5bb4450aecbbc3cc5ebb8a9ec3279b5"/><file name="Cancelprocess.php" hash="c3e240c495b919a76d11b00276cee008"/><file name="Connection.php" hash="c52c8050454e29572486ae9a18c13faa"/><file name="Encryption.php" hash="f53bfd44526a4229eb6e9c8a64184864"/><file name="Exception.php" hash="136ebb40e0ac1df7d9c6a15183f94238"/><file name="Observer.php" hash="c9946477ecdccbeb543bbc0253efc47a"/><file name="Session.php" hash="21a621fcb45c368be3ad26a546e0886c"/><file name="Transaction.php" hash="80b31e9aa11e32c71dae857bce5d8a30"/></dir><dir name="sql"><dir name="computop_setup"><file name="mysql4-install-1.4.0.1.1.php" hash="ad40f312f8e529ecf91526e31fe3c4e0"/><file name="mysql4-upgrade-1.4.0.1.1-1.4.1.1.2.php" hash="61749300a08aec0dfbb5da8d849578b9"/><file name="mysql4-upgrade-1.4.1.1.2-1.4.1.1.3.php" hash="5b3268d3a37425920611aa69c24e8071"/><file name="mysql4-upgrade-1.4.1.1.3-1.4.1.1.4.php" hash="52dafb473166229abe7ef072e25ebd74"/><file name="mysql4-upgrade-1.4.1.1.4-1.4.1.1.5.php" hash="55ecef7e2e23ecaadb5f135ef7d92824"/></dir></dir><file name="Object.php" hash="4bb86c2a03eeec5085562faa17d03907"/></dir><dir name="Dsrevision"><dir name="Block"><dir name="Adminhtml"><dir name="System"><file name="Revision.php" hash="a2c169d67b66fa9cadb8ffb94a01a5c5"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="b558f303d3902476f7577fe6c6deed77"/><file name="system.xml" hash="1e2ece20819f1ac5bd925053e8bed834"/></dir></dir></dir><dir name="Mage"><dir name="Sales"><dir name="Model"><dir name="Order"><file name="Payment-1.4.0.X.php" hash="924d9e4daea2d6e850afde8d17b3ef51"/><file name="Payment-1.4.1.X.php" hash="f935a1a1a8c0dbe6c62ea1de471f399d"/><file name="Payment.php" hash="5a199da13e38e52b7b2397841d433ad3"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="computop"><dir name="computop_cc"><file name="computop_american_express.png" hash="31519cbedd7877614c981a40b95cb34b"/><file name="computop_cartebleue.png" hash="76fccfa968d9bd2c0973ffd6b12941c0"/><file name="computop_dankort.png" hash="02921379072bc8680a0e8b45793c5f7a"/><file name="computop_jcb.png" hash="42c92c497c80379611c26c454190100b"/><file name="computop_maestro.png" hash="f96045351fdb46f7316d3dda77aa4b57"/><file name="computop_mastercard.png" hash="d9b0765d4a144b617d7087e92fd3bca2"/><file name="computop_mastercard_secure_code.png" hash="3b71e801f3ae85ac244ae39f5b5360ad"/><file name="computop_verified_by_visa.png" hash="a2fd98064f7c172bafa9808e1695d430"/><file name="computop_visa.png" hash="7dbfe6f75219770612ea9be73352fb90"/></dir><file name="computop_directpay.gif" hash="f39a6b8370b8c364906e36e539886582"/><file name="computop_eft.gif" hash="de672cabd4404868ccb5deed1e23cf8d"/><file name="computop_giropay.gif" hash="7ba195ff8d69fc30d5068cee07065377"/><file name="computop_ideal.gif" hash="74caed7d2e87b6ff4ca7214ad51b3a7d"/><file name="computop_mpass.gif" hash="b2906001b44b1a9ec5cf99f1efa5da30"/><file name="computop_o2.gif" hash="5d9f1b5a1fffa176eb162e4c5210586e"/><file name="computop_paypal.gif" hash="d0209b4f23ee42a4a837f26fcd3dc33d"/><file name="computop_vodafone.gif" hash="d449c5fe22ffe8bbf68267dabeffc61a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dotsource_Computop.xml" hash="7d7f30713b2bb01da8d234a1636ecec7"/><file name="Dotsource_Dsrevision.xml" hash="6127f307070fb629abbe5d56a390a827"/></dir></target><target name="mage"><dir name="."><file name="DEPLOYED_REVISION" hash="bcc85e3ab2ddd7404e861440296ca41f"/></dir></target></contents>
|
25 |
+
<compatible/>
|
26 |
+
<dependencies/>
|
27 |
+
</package>
|
skin/frontend/base/default/images/computop/computop_cc/computop_american_express.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_cartebleue.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_dankort.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_jcb.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_maestro.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_mastercard.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_mastercard_secure_code.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_verified_by_visa.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_cc/computop_visa.png
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_directpay.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_eft.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_giropay.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_ideal.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_mpass.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_o2.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_paypal.gif
ADDED
Binary file
|
skin/frontend/base/default/images/computop/computop_vodafone.gif
ADDED
Binary file
|