Allopass_Hipay - Version 1.0.0

Version Notes

-New iframe templates

Download this release

Release Info

Developer Kassim_Profileo
Extension Allopass_Hipay
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (104) hide show
  1. app/code/community/Allopass/Hipay/.DS_Store +0 -0
  2. app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/3dsRule.php +44 -0
  3. app/code/community/Allopass/Hipay/Block/Checkout/Pending.php +30 -0
  4. app/code/community/Allopass/Hipay/Block/Form/Abstract.php +74 -0
  5. app/code/community/Allopass/Hipay/Block/Form/Cc.php +113 -0
  6. app/code/community/Allopass/Hipay/Block/Form/Hosted.php +10 -0
  7. app/code/community/Allopass/Hipay/Block/Info/Cc.php +103 -0
  8. app/code/community/Allopass/Hipay/Block/Info/Hosted.php +9 -0
  9. app/code/community/Allopass/Hipay/Controller/Payment.php +271 -0
  10. app/code/community/Allopass/Hipay/Helper/Data.php +203 -0
  11. app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Curl.php +483 -0
  12. app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Stream.php +20 -0
  13. app/code/community/Allopass/Hipay/Model/Api/Request.php +219 -0
  14. app/code/community/Allopass/Hipay/Model/Api/Response/Abstract.php +17 -0
  15. app/code/community/Allopass/Hipay/Model/Api/Response/Error.php +12 -0
  16. app/code/community/Allopass/Hipay/Model/Api/Response/Gateway.php +114 -0
  17. app/code/community/Allopass/Hipay/Model/Api/Response/Notification.php +33 -0
  18. app/code/community/Allopass/Hipay/Model/Api/Response/Vault.php +9 -0
  19. app/code/community/Allopass/Hipay/Model/Config.php +234 -0
  20. app/code/community/Allopass/Hipay/Model/Log/Adapter.php +118 -0
  21. app/code/community/Allopass/Hipay/Model/Method/Abstract.php +1003 -0
  22. app/code/community/Allopass/Hipay/Model/Method/Cbc.php +5 -0
  23. app/code/community/Allopass/Hipay/Model/Method/Cc.php +517 -0
  24. app/code/community/Allopass/Hipay/Model/Method/Dexia.php +5 -0
  25. app/code/community/Allopass/Hipay/Model/Method/Giropay.php +5 -0
  26. app/code/community/Allopass/Hipay/Model/Method/Hosted.php +118 -0
  27. app/code/community/Allopass/Hipay/Model/Method/Ideal.php +5 -0
  28. app/code/community/Allopass/Hipay/Model/Method/Ing.php +5 -0
  29. app/code/community/Allopass/Hipay/Model/Method/Kbc.php +5 -0
  30. app/code/community/Allopass/Hipay/Model/Method/Przelewy24.php +5 -0
  31. app/code/community/Allopass/Hipay/Model/Method/Przelewy24Api.php +83 -0
  32. app/code/community/Allopass/Hipay/Model/Method/Qiwi.php +5 -0
  33. app/code/community/Allopass/Hipay/Model/Method/Sisal.php +5 -0
  34. app/code/community/Allopass/Hipay/Model/Method/SisalApi.php +83 -0
  35. app/code/community/Allopass/Hipay/Model/Method/Sofort.php +5 -0
  36. app/code/community/Allopass/Hipay/Model/Method/SofortApi.php +83 -0
  37. app/code/community/Allopass/Hipay/Model/Method/Webmoney.php +5 -0
  38. app/code/community/Allopass/Hipay/Model/Method/WebmoneyApi.php +83 -0
  39. app/code/community/Allopass/Hipay/Model/Method/Yandex.php +5 -0
  40. app/code/community/Allopass/Hipay/Model/Method/YandexApi.php +83 -0
  41. app/code/community/Allopass/Hipay/Model/Observer.php +96 -0
  42. app/code/community/Allopass/Hipay/Model/Resource/Rule.php +19 -0
  43. app/code/community/Allopass/Hipay/Model/Resource/Rule/Collection.php +20 -0
  44. app/code/community/Allopass/Hipay/Model/Rule.php +44 -0
  45. app/code/community/Allopass/Hipay/Model/Rule/Condition/Address.php +231 -0
  46. app/code/community/Allopass/Hipay/Model/Rule/Condition/Combine.php +183 -0
  47. app/code/community/Allopass/Hipay/Model/Rule/Condition/Customer.php +186 -0
  48. app/code/community/Allopass/Hipay/Model/Rule/Condition/Product.php +128 -0
  49. app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Combine.php +172 -0
  50. app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Found.php +70 -0
  51. app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Subselect.php +102 -0
  52. app/code/community/Allopass/Hipay/Model/Rule/Config.php +93 -0
  53. app/code/community/Allopass/Hipay/Model/Source/3ds.php +39 -0
  54. app/code/community/Allopass/Hipay/Model/Source/CcType.php +24 -0
  55. app/code/community/Allopass/Hipay/Model/Source/CcTypeHosted.php +24 -0
  56. app/code/community/Allopass/Hipay/Model/Source/Order/HipayStatusValidate.php +20 -0
  57. app/code/community/Allopass/Hipay/Model/Source/Order/Status.php +28 -0
  58. app/code/community/Allopass/Hipay/Model/Source/Order/Status/Accepted.php +12 -0
  59. app/code/community/Allopass/Hipay/Model/Source/Order/Status/Canceled.php +11 -0
  60. app/code/community/Allopass/Hipay/Model/Source/Order/Status/New.php +11 -0
  61. app/code/community/Allopass/Hipay/Model/Source/Order/Status/Refused.php +12 -0
  62. app/code/community/Allopass/Hipay/Model/Source/PaymentAction.php +17 -0
  63. app/code/community/Allopass/Hipay/Model/Source/Pendingredirect.php +19 -0
  64. app/code/community/Allopass/Hipay/Model/Source/Template.php +35 -0
  65. app/code/community/Allopass/Hipay/controllers/Adminhtml/RuleController.php +37 -0
  66. app/code/community/Allopass/Hipay/controllers/CbcController.php +8 -0
  67. app/code/community/Allopass/Hipay/controllers/CcController.php +15 -0
  68. app/code/community/Allopass/Hipay/controllers/CheckoutController.php +40 -0
  69. app/code/community/Allopass/Hipay/controllers/DexiaController.php +8 -0
  70. app/code/community/Allopass/Hipay/controllers/GiropayController.php +8 -0
  71. app/code/community/Allopass/Hipay/controllers/HostedController.php +12 -0
  72. app/code/community/Allopass/Hipay/controllers/IdealController.php +8 -0
  73. app/code/community/Allopass/Hipay/controllers/IngController.php +8 -0
  74. app/code/community/Allopass/Hipay/controllers/KbcController.php +8 -0
  75. app/code/community/Allopass/Hipay/controllers/NotifyController.php +193 -0
  76. app/code/community/Allopass/Hipay/controllers/Przelewy24Controller.php +8 -0
  77. app/code/community/Allopass/Hipay/controllers/Przelewy24apiController.php +8 -0
  78. app/code/community/Allopass/Hipay/controllers/QiwiController.php +8 -0
  79. app/code/community/Allopass/Hipay/controllers/SisalController.php +8 -0
  80. app/code/community/Allopass/Hipay/controllers/SisalapiController.php +8 -0
  81. app/code/community/Allopass/Hipay/controllers/SofortController.php +8 -0
  82. app/code/community/Allopass/Hipay/controllers/SofortapiController.php +8 -0
  83. app/code/community/Allopass/Hipay/controllers/WebmoneyController.php +8 -0
  84. app/code/community/Allopass/Hipay/controllers/WebmoneyapiController.php +8 -0
  85. app/code/community/Allopass/Hipay/controllers/YandexController.php +8 -0
  86. app/code/community/Allopass/Hipay/controllers/YandexapiController.php +8 -0
  87. app/code/community/Allopass/Hipay/etc/config.xml +637 -0
  88. app/code/community/Allopass/Hipay/etc/system.xml +2586 -0
  89. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-install-0.1.0.php +45 -0
  90. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.0-0.1.1.php +123 -0
  91. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.1-0.1.2.php +38 -0
  92. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.2-0.1.3.php +72 -0
  93. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.4-0.1.5.php +24 -0
  94. app/design/adminhtml/default/default/layout/hipay.xml +12 -0
  95. app/design/adminhtml/default/default/template/hipay/system/config/form/field/rules.phtml +17 -0
  96. app/design/frontend/default/default/layout/hipay.xml +12 -0
  97. app/design/frontend/default/default/template/hipay/checkout/pending.phtml +8 -0
  98. app/design/frontend/default/default/template/hipay/form/cc.phtml +144 -0
  99. app/design/frontend/default/default/template/hipay/form/hosted.phtml +134 -0
  100. app/etc/modules/Allopass_Hipay.xml +9 -0
  101. app/locale/en_US/Allopass_Hipay.csv +107 -0
  102. app/locale/fr_FR/Allopass_Hipay.csv +107 -0
  103. package.xml +18 -0
  104. skin/adminhtml/default/default/hipay/js/rules.js +386 -0
app/code/community/Allopass/Hipay/.DS_Store ADDED
Binary file
app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/3dsRule.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_System_Config_Form_Field_3dsRule extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ /**
6
+ * Check if columns are defined, set template
7
+ *
8
+ */
9
+ public function __construct()
10
+ {
11
+ if (!$this->_addButtonLabel) {
12
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add');
13
+ }
14
+ parent::__construct();
15
+ if (!$this->getTemplate()) {
16
+ $this->setTemplate('hipay/system/config/form/field/rules.phtml');
17
+ }
18
+ }
19
+
20
+ public function getNewChildUrl(){
21
+ return Mage::getUrl('hipay/adminhtml_rule/newConditionHtml/form/rule_conditions_fieldset');
22
+ }
23
+
24
+ /**
25
+ * Enter description here...
26
+ *
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ */
30
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ $partsId = explode("_", $element->getId());
33
+ $method_code = $partsId[1]. "_" . $partsId[2];
34
+ $rule = Mage::getModel('hipay/rule');
35
+ $rule->setMethodCode($method_code);
36
+ if($element->getValue())
37
+ $rule->load($element->getValue());
38
+
39
+ $element->setRule($rule);
40
+
41
+ $this->setElement($element);
42
+ return $this->_toHtml();
43
+ }
44
+ }
app/code/community/Allopass/Hipay/Block/Checkout/Pending.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Block_Checkout_Pending extends Mage_Core_Block_Template
3
+ {
4
+ public function getRealOrderId()
5
+ {
6
+ return Mage::getSingleton('checkout/session')->getLastRealOrderId();
7
+ }
8
+
9
+ /**
10
+ * Payment custom error message
11
+ *
12
+ * @return string
13
+ */
14
+ public function getErrorMessage ()
15
+ {
16
+ $error = Mage::getSingleton('checkout/session')->getErrorMessage();
17
+ // Mage::getSingleton('checkout/session')->unsErrorMessage();
18
+ return $error;
19
+ }
20
+
21
+ /**
22
+ * Continue shopping URL
23
+ *
24
+ * @return string
25
+ */
26
+ public function getContinueShoppingUrl()
27
+ {
28
+ return Mage::getUrl('checkout/cart');
29
+ }
30
+ }
app/code/community/Allopass/Hipay/Block/Form/Abstract.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_Form
3
+ {
4
+
5
+ /**
6
+ * Retrieve payment configuration object
7
+ *
8
+ * @return Allopass_Hipay_Model_Config
9
+ */
10
+ protected function _getConfig()
11
+ {
12
+ return Mage::getSingleton('hipay/config');
13
+ }
14
+
15
+
16
+ public function getCustomerHasAlias()
17
+ {
18
+ return $this->getCustomer()->getHipayAliasOneclick() != "";
19
+
20
+ }
21
+
22
+ public function getCustomer()
23
+ {
24
+ return Mage::getSingleton('customer/session')->getCustomer();
25
+ }
26
+
27
+ public function ccExpDateIsValid()
28
+ {
29
+ return $this->helper('hipay')->checkIfCcExpDateIsValid((int)Mage::getSingleton('customer/session')->getCustomerId());
30
+ }
31
+
32
+ public function oneClickIsAllowed()
33
+ {
34
+ $checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
35
+
36
+ if($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST || !$this->allowUseOneClick())
37
+ return false;
38
+
39
+ return true;
40
+
41
+ }
42
+
43
+ public function getQuote()
44
+ {
45
+ return Mage::getSingleton('checkout/session')->getQuote();
46
+ }
47
+
48
+
49
+ public function allowUseOneClick()
50
+ {
51
+ return $this->getMethod()->getConfigData('allow_use_oneclick');
52
+ }
53
+
54
+ public function getIframeConfig()
55
+ {
56
+ $iframe['iframe_width'] = $this->getMethod()->getConfigData('iframe_width');
57
+ $iframe['iframe_height'] = $this->getMethod()->getConfigData('iframe_height');
58
+ $iframe['iframe_style'] = $this->getMethod()->getConfigData('iframe_style');
59
+ return $iframe;
60
+ }
61
+
62
+ /**
63
+ * Render block HTML
64
+ *
65
+ * @return string
66
+ */
67
+ protected function _toHtml()
68
+ {
69
+ Mage::dispatchEvent('payment_form_block_to_html_before', array(
70
+ 'block' => $this
71
+ ));
72
+ return parent::_toHtml();
73
+ }
74
+ }
app/code/community/Allopass/Hipay/Block/Form/Cc.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Block_Form_Cc extends Allopass_Hipay_Block_Form_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('hipay/form/cc.phtml');
8
+ }
9
+
10
+
11
+ /**
12
+ * Retrieve availables credit card types
13
+ *
14
+ * @return array
15
+ */
16
+ public function getCcAvailableTypes()
17
+ {
18
+ $types =$this->_getConfig()->getCcTypes();
19
+ if ($method = $this->getMethod()) {
20
+ $availableTypes = $method->getConfigData('cctypes');
21
+ if ($availableTypes) {
22
+ $availableTypes = explode(',', $availableTypes);
23
+ foreach ($types as $code=>$name) {
24
+ if (!in_array($code, $availableTypes)) {
25
+ unset($types[$code]);
26
+ }
27
+ }
28
+ }
29
+ }
30
+ return $types;
31
+ }
32
+
33
+ /**
34
+ * Retrieve credit card expire months
35
+ *
36
+ * @return array
37
+ */
38
+ public function getCcMonths()
39
+ {
40
+ $months = $this->getData('cc_months');
41
+ if (is_null($months)) {
42
+ $months["0"] = $this->__('Month');
43
+ $months = array_merge($months, $this->_getConfig()->getMonths());
44
+ $this->setData('cc_months', $months);
45
+ }
46
+ return $months;
47
+ }
48
+
49
+ /**
50
+ * Retrieve credit card expire years
51
+ *
52
+ * @return array
53
+ */
54
+ public function getCcYears()
55
+ {
56
+ $years = $this->getData('cc_years');
57
+ if (is_null($years)) {
58
+ $years = $this->_getConfig()->getYears();
59
+ $years = array(0=>$this->__('Year'))+$years;
60
+ $this->setData('cc_years', $years);
61
+ }
62
+ return $years;
63
+ }
64
+
65
+ /**
66
+ * Retrive has verification configuration
67
+ *
68
+ * @return boolean
69
+ */
70
+ public function hasVerification()
71
+ {
72
+ if ($this->getMethod()) {
73
+ $configData = $this->getMethod()->getConfigData('useccv');
74
+ if(is_null($configData)){
75
+ return true;
76
+ }
77
+ return (bool) $configData;
78
+ }
79
+ return true;
80
+ }
81
+
82
+ /*
83
+ * Whether switch/solo card type available
84
+ */
85
+ public function hasSsCardType()
86
+ {
87
+ $availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
88
+ $ssPresenations = array_intersect(array('SS', 'SM', 'SO'), $availableTypes);
89
+ if ($availableTypes && count($ssPresenations) > 0) {
90
+ return true;
91
+ }
92
+ return false;
93
+ }
94
+
95
+ /*
96
+ * solo/switch card start year
97
+ * @return array
98
+ */
99
+ public function getSsStartYears()
100
+ {
101
+ $years = array();
102
+ $first = date("Y");
103
+
104
+ for ($index=5; $index>=0; $index--) {
105
+ $year = $first - $index;
106
+ $years[$year] = $year;
107
+ }
108
+ $years = array(0=>$this->__('Year'))+$years;
109
+ return $years;
110
+ }
111
+
112
+
113
+ }
app/code/community/Allopass/Hipay/Block/Form/Hosted.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Block_Form_Hosted extends Allopass_Hipay_Block_Form_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('hipay/form/hosted.phtml');
8
+ }
9
+
10
+ }
app/code/community/Allopass/Hipay/Block/Info/Cc.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Credit card hipay payment info
5
+ */
6
+ class Allopass_Hipay_Block_Info_Cc extends Mage_Payment_Block_Info
7
+ {
8
+ /**
9
+ * Retrieve credit card type name
10
+ *
11
+ * @return string
12
+ */
13
+ public function getCcTypeName()
14
+ {
15
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
16
+ $ccType = $this->getInfo()->getCcType();
17
+ if (isset($types[$ccType])) {
18
+ return $types[$ccType];
19
+ }
20
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
21
+ }
22
+
23
+ /**
24
+ * Whether current payment method has credit card expiration info
25
+ *
26
+ * @return bool
27
+ */
28
+ public function hasCcExpDate()
29
+ {
30
+ return (int)$this->getInfo()->getCcExpMonth() || (int)$this->getInfo()->getCcExpYear();
31
+ }
32
+
33
+ /**
34
+ * Retrieve CC expiration month
35
+ *
36
+ * @return string
37
+ */
38
+ public function getCcExpMonth()
39
+ {
40
+ $month = $this->getInfo()->getCcExpMonth();
41
+ if ($month<10) {
42
+ $month = '0'.$month;
43
+ }
44
+ return $month;
45
+ }
46
+
47
+ /**
48
+ * Retrieve CC expiration date
49
+ *
50
+ * @return Zend_Date
51
+ */
52
+ public function getCcExpDate()
53
+ {
54
+ $date = Mage::app()->getLocale()->date(0);
55
+ $date->setYear($this->getInfo()->getCcExpYear());
56
+ $date->setMonth($this->getInfo()->getCcExpMonth());
57
+ return $date;
58
+ }
59
+
60
+ /**
61
+ * Prepare credit card related payment info
62
+ *
63
+ * @param Varien_Object|array $transport
64
+ * @return Varien_Object
65
+ */
66
+ protected function _prepareSpecificInformation($transport = null)
67
+ {
68
+ if (null !== $this->_paymentSpecificInformation) {
69
+ return $this->_paymentSpecificInformation;
70
+ }
71
+ $transport = parent::_prepareSpecificInformation($transport);
72
+ $data = array();
73
+ if ($ccType = $this->getCcTypeName()) {
74
+ $data[Mage::helper('payment')->__('Credit Card Type')] = $ccType;
75
+ }
76
+ if ($this->getInfo()->getCcLast4()) {
77
+ $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
78
+ }
79
+ if (!$this->getIsSecureMode()) {
80
+ if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
81
+ $data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
82
+ }
83
+ $year = $this->getInfo()->getCcSsStartYear();
84
+ $month = $this->getInfo()->getCcSsStartMonth();
85
+ if ($year && $month) {
86
+ $data[Mage::helper('payment')->__('Switch/Solo/Maestro Start Date')] = $this->_formatCardDate($year, $month);
87
+ }
88
+ }
89
+ return $transport->setData(array_merge($data, $transport->getData()));
90
+ }
91
+
92
+ /**
93
+ * Format year/month on the credit card
94
+ *
95
+ * @param string $year
96
+ * @param string $month
97
+ * @return string
98
+ */
99
+ protected function _formatCardDate($year, $month)
100
+ {
101
+ return sprintf('%s/%s', sprintf('%02d', $month), $year);
102
+ }
103
+ }
app/code/community/Allopass/Hipay/Block/Info/Hosted.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * hosted hipay payment info
5
+ */
6
+ class Allopass_Hipay_Block_Info_Hosted extends Mage_Payment_Block_Info
7
+ {
8
+
9
+ }
app/code/community/Allopass/Hipay/Controller/Payment.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Action
3
+ {
4
+ /**
5
+ *
6
+ * @var Mage_Sales_Model_Order $order
7
+ */
8
+ protected $_order = null;
9
+
10
+
11
+ /**
12
+ * @return Mage_Core_Controller_Front_Action
13
+ */
14
+ public function preDispatch() {
15
+ parent::preDispatch();
16
+
17
+ if (!$this->_validateSignature()) {
18
+ $this->getResponse()->setBody("NOK. Wrong Signature!");
19
+ $this->setFlag('', 'no-dispatch', true);
20
+ }
21
+ }
22
+
23
+
24
+ protected function _validateSignature()
25
+ {
26
+ /* @var $_helper Allopass_Hipay_Helper_Data */
27
+ $_helper = Mage::helper('hipay');
28
+ $signature = $this->getRequest()->getParam('hash');
29
+ return $_helper->checkSignature($signature);
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @return Allopass_Hipay_Model_Method_Abstract $methodInstance
35
+ */
36
+ protected function _getMethodInstance()
37
+ {
38
+ Mage::throwException("Method: '" . __METHOD__ . "' must be implemented!");
39
+ }
40
+
41
+ public function sendRequestAction()
42
+ {
43
+ $order = $this->getOrder();
44
+ $payment = $order->getPayment();
45
+ $methodInstance = $this->_getMethodInstance();
46
+
47
+ try
48
+ {
49
+ $redirectUrl = $methodInstance->place($payment,$order->getBaseTotalDue());
50
+ }
51
+ catch (Exception $e)
52
+ {
53
+ Mage::logException($e);
54
+ $this->getCheckout()->addError($e->getMessage());
55
+ $this->_redirect('checkout/cart');
56
+ return $this;
57
+ }
58
+
59
+
60
+ $this->_redirectUrl($redirectUrl);
61
+
62
+ return $this;
63
+
64
+ }
65
+
66
+
67
+ public function acceptAction()
68
+ {
69
+ if(($profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds()))
70
+ {
71
+ if(is_array($profileIds))
72
+ {
73
+ /* @var $gatewayResponse Allopass_Hipay_Model_Api_Response_Gateway */
74
+ $gatewayResponse = Mage::getSingleton('hipay/api_response_gateway',$this->getRequest()->getParams());
75
+ $collection = Mage::getModel('sales/recurring_profile')->getCollection()
76
+ ->addFieldToFilter('profile_id', array('in' => $profileIds))
77
+ ;
78
+ $profiles = array();
79
+ foreach ($collection as $profile) {
80
+ //$referenceId = $gatewayResponse->getToken()."-".$profile->getId();
81
+ $additionalInfo = array();
82
+ $additionalInfo['ccType'] = $gatewayResponse->getBrand();
83
+ $additionalInfo['ccExpMonth'] = $gatewayResponse->getCardExpiryMonth() ;
84
+ $additionalInfo['ccExpYear'] = $gatewayResponse->getCardExpiryYear();
85
+ $additionalInfo['token'] = $gatewayResponse->getToken();
86
+ $additionalInfo['transaction_id'] = $gatewayResponse->getTransactionReference();
87
+ $profile->setAdditionalInfo($additionalInfo);
88
+ //$profile->setReferenceId($referenceId);
89
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
90
+
91
+ $profile->save();
92
+ }
93
+ }
94
+ }
95
+ /*else
96
+ {
97
+ $this->processResponse();
98
+ }*/
99
+ $this->processResponse();
100
+ $this->_redirect('checkout/onepage/success');
101
+
102
+ return $this;
103
+ }
104
+
105
+ public function pendingAction()
106
+ {
107
+ $this->processResponse();
108
+ $this->_redirect($this->_getMethodInstance()->getConfigData('pending_redirect_page'));
109
+
110
+ return $this;
111
+ }
112
+
113
+ public function declineAction()
114
+ {
115
+ $this->processResponse();
116
+ $this->_redirect('checkout/onepage/failure');
117
+ return $this;
118
+ }
119
+
120
+
121
+ public function exceptionAction()
122
+ {
123
+ $this->_redirect('checkout/onepage/failure');
124
+ return $this;
125
+ }
126
+
127
+
128
+ public function cancelAction()
129
+ {
130
+ $this->processResponse();
131
+ $this->_redirect('checkout/cart');
132
+ return $this;
133
+ }
134
+
135
+ protected function processResponse()
136
+ {
137
+ $order = $this->getOrder();
138
+ $payment = $order->getPayment();
139
+
140
+ /* @var $gatewayResponse Allopass_Hipay_Model_Api_Response_Gateway */
141
+ $gatewayResponse = Mage::getSingleton('hipay/api_response_gateway',$this->getRequest()->getParams());
142
+
143
+ $this->_getMethodInstance()->processResponseToRedirect($gatewayResponse, $payment, $order->getBaseTotalDue());
144
+ }
145
+
146
+
147
+
148
+ /**
149
+ *
150
+ * @return Mage_Sales_Model_Order
151
+ */
152
+ protected function getOrder()
153
+ {
154
+ if(is_null($this->_order))
155
+ {
156
+
157
+ if(($profileIds = $this->getCheckout()->getLastRecurringProfileIds()))
158
+ {
159
+
160
+ if (is_array($profileIds)) {
161
+
162
+ foreach ($profileIds as $profileId)
163
+ {
164
+ /* @var $profile Mage_Sales_Model_Recurring_Profile */
165
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
166
+ /* @var $_helperRecurring Allopass_Hipayrecurring_Helper_Data */
167
+ $_helperRecurring = Mage::helper('hipayrecurring');
168
+
169
+ if($_helperRecurring->isInitialProfileOrder($profile))
170
+ $this->_order = $_helperRecurring->createOrderFromProfile($profile);
171
+ else
172
+ {
173
+ $orderId = current($profile->getChildOrderIds());
174
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
175
+
176
+ $additionalInfo = $profile->getAdditionalInfo();
177
+
178
+ $this->_order->getPayment()->setCcType(isset($additionalInfo['ccType']) ? $additionalInfo['ccType'] : "");
179
+ $this->_order->getPayment()->setCcExpMonth(isset($additionalInfo['ccExpMonth']) ? $additionalInfo['ccExpMonth'] : "");
180
+ $this->_order->getPayment()->setCcExpYear(isset($additionalInfo['ccExpYear']) ? $additionalInfo['ccExpYear'] : "");
181
+ $this->_order->getPayment()->setAdditionalInformation('token',isset($additionalInfo['token']) ? $additionalInfo['token'] : "");
182
+ $this->_order->getPayment()->setAdditionalInformation('create_oneclick',isset($additionalInfo['create_oneclick']) ? $additionalInfo['create_oneclick'] : 1);
183
+ $this->_order->getPayment()->setAdditionalInformation('use_oneclick',isset($additionalInfo['use_oneclick']) ? $additionalInfo['use_oneclick'] : 0);
184
+ }
185
+
186
+
187
+
188
+ return $this->_order; //because only one nominal item in cart is authorized and Hipay not manage many profiles
189
+
190
+ //$amount = $this->getAmountFromProfile($profile);
191
+
192
+ /*$productItemInfo = new Varien_Object;
193
+ $type = "Regular";
194
+ if ($type == 'Trial') {
195
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
196
+ } elseif ($type == 'Regular') {
197
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
198
+ }
199
+
200
+
201
+ if($this->isInitialProfileOrder($profile))// because is not additonned in prodile obj
202
+ $productItemInfo->setPrice($profile->getBillingAmount() + $profile->getInitAmount());
203
+
204
+ $this->_order = $profile->createOrder($productItemInfo);
205
+
206
+ $additionalInfo = $profile->getAdditionalInfo();
207
+
208
+ $this->_order->getPayment()->setCcType($additionalInfo['ccType']);
209
+ $this->_order->getPayment()->setCcExpMonth($additionalInfo['ccExpMonth']);
210
+ $this->_order->getPayment()->setCcExpYear($additionalInfo['ccExpYear']);
211
+ $this->_order->getPayment()->setAdditionalInformation('token',$additionalInfo['token']);
212
+ $this->_order->getPayment()->setAdditionalInformation('create_oneclick',$additionalInfo['create_oneclick']);
213
+ $this->_order->getPayment()->setAdditionalInformation('use_oneclick',$additionalInfo['use_oneclick']);
214
+
215
+ $orderId = 'create-recurring';
216
+ $orderId .= "-".$profileId;
217
+ //$this->_order->setIncrementId($orderId);
218
+ $this->_order->save();
219
+ $profile->addOrderRelation($this->_order->getId());
220
+ $profile->save();*/
221
+ return $this->_order; //because only one nominal item in cart is authorized and Hipay not manage many profiles
222
+ //break;
223
+ }
224
+
225
+
226
+ }
227
+
228
+ Mage::throwException("An error occured. Profile Ids not present!");
229
+
230
+
231
+
232
+ }
233
+ else
234
+ $this->_order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId());
235
+ }
236
+
237
+ return $this->_order;
238
+ }
239
+
240
+ /**
241
+ * Add method to calculate amount from recurring profile
242
+ * @param Mage_Sales_Model_Recurring_Profile $profile
243
+ * @return int $amount
244
+ **/
245
+ public function getAmountFromProfile(Mage_Sales_Model_Recurring_Profile $profile) {
246
+ $amount = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
247
+
248
+ if($this->isInitialProfileOrder($profile))
249
+ $amount += $profile->getInitAmount() ;
250
+
251
+ return $amount;
252
+ }
253
+
254
+ protected function isInitialProfileOrder(Mage_Sales_Model_Recurring_Profile $profile)
255
+ {
256
+ if(count($profile->getChildOrderIds()) && current($profile->getChildOrderIds()) == "-1")
257
+ return true;
258
+
259
+ return false;
260
+ }
261
+
262
+
263
+ /**
264
+ *
265
+ * @return Mage_Checkout_Model_Session
266
+ */
267
+ protected function getCheckout()
268
+ {
269
+ return Mage::getSingleton('checkout/session');
270
+ }
271
+ }
app/code/community/Allopass/Hipay/Helper/Data.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+
6
+ public function checkSignature($signature,$fromNotification = false)
7
+ {
8
+ $passphrase = Mage::getStoreConfig('hipay/hipay_api/secret_passphrase');
9
+ if(empty($passphrase) || empty($signature))
10
+ return true;
11
+
12
+ if($fromNotification)
13
+ {
14
+ $rawPostData = file_get_contents("php://input");
15
+ if($signature == sha1($rawPostData . $passphrase));
16
+ return true;
17
+
18
+ return false;
19
+ }
20
+
21
+
22
+ $parameters = $this->_getRequest()->getParams();
23
+ $string2compute = "";
24
+ unset($parameters['hash']);
25
+ ksort($parameters);
26
+ foreach ($parameters as $name => $value) {
27
+ if (!empty($value)) {
28
+ $string2compute .= $name . $value . $passphrase;
29
+ }
30
+ }
31
+
32
+ if(sha1($string2compute) == $signature)
33
+ return true;
34
+
35
+ return false;
36
+ }
37
+
38
+ public function checkIfCcExpDateIsValid($customer)
39
+ {
40
+ if(is_int($customer))
41
+ $customer = Mage::getModel('customer/customer')->load($customer);
42
+
43
+ $expDate = $customer->getHipayCcExpDate();
44
+ $alias = $customer->getHipayAliasOneclick();
45
+ if(!empty($expDate) && !empty($alias))
46
+ {
47
+ list($expMonth,$expYear) = explode("-", $expDate);
48
+ $today = new Zend_Date(Mage::app()->getLocale()->storeTimeStamp());
49
+
50
+ $currentYear = (int)$today->getYear()->toString("YY");
51
+ $currentMonth = (int)$today->getMonth()->toString("MM");
52
+
53
+ if($currentYear > (int)$expYear)
54
+ return false;
55
+
56
+ if($currentYear == (int)$expYear && $currentMonth > (int)$expMonth)
57
+ return false;
58
+
59
+ return true;
60
+
61
+ }
62
+
63
+ return false;
64
+ }
65
+
66
+ /**
67
+ *
68
+ * @param Mage_Customer_Model_Customer $customer
69
+ * @param Allopass_Hipay_Model_Api_Response_Gateway $response
70
+ */
71
+ public function responseToCustomer($customer,$response,$isRecurring = false)
72
+ {
73
+
74
+ $paymentMethod = $response->getPaymentMethod();
75
+ $token = isset($paymentMethod['token']) ? $paymentMethod['token'] : $response->getData('cardtoken');
76
+
77
+ if($isRecurring)
78
+ $customer->setHipayAliasRecurring($token);
79
+ else
80
+ $customer->setHipayAliasOneclick($token );
81
+
82
+ if(isset($paymentMethod['card_expiry_month']) && $paymentMethod['card_expiry_year'])
83
+ $customer->setHipayCcExpDate($paymentMethod['card_expiry_month'] . "-" . $paymentMethod['card_expiry_year'] );
84
+ else
85
+ $customer->setHipayCcExpDate(substr($response->getData('cardexpiry'), 4,2) . "-" . substr($response->getData('cardexpiry'), 0,4) );
86
+ $customer->setHipayCcNumberEnc(isset($paymentMethod['pan']) ? $paymentMethod['pan'] : $response->getData('cardpan'));
87
+ $customer->setHipayCcType(isset($paymentMethod['brand']) ? strtolower($paymentMethod['brand']) : strtolower($response->getData('cardbrand')));
88
+
89
+
90
+ $customer->getResource()->saveAttribute($customer, 'hipay_alias_oneclick');
91
+ $customer->getResource()->saveAttribute($customer, 'hipay_cc_exp_date');
92
+ $customer->getResource()->saveAttribute($customer, 'hipay_cc_number_enc');
93
+ $customer->getResource()->saveAttribute($customer, 'hipay_cc_type');
94
+
95
+ return $this;
96
+ }
97
+
98
+ public function reAddToCart($incrementId) {
99
+
100
+ $cart = Mage::getSingleton('checkout/cart');
101
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
102
+
103
+ if ($order->getId()) {
104
+ $items = $order->getItemsCollection();
105
+ foreach ($items as $item) {
106
+ try {
107
+ $cart->addOrderItem($item);
108
+ } catch (Mage_Core_Exception $e) {
109
+ if (Mage::getSingleton('checkout/session')->getUseNotice(true)) {
110
+ Mage::getSingleton('checkout/session')->addNotice($e->getMessage());
111
+ } else {
112
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
113
+ }
114
+ } catch (Exception $e) {
115
+ Mage::getSingleton('checkout/session')->addException($e, Mage::helper('checkout')->__('Cannot add the item to shopping cart.')
116
+ );
117
+ }
118
+ }
119
+ }
120
+
121
+ $cart->save();
122
+ }
123
+
124
+
125
+ /**
126
+ * Return message for gateway transaction request
127
+ *
128
+ * @param Mage_Payment_Model_Info $payment
129
+ * @param string $requestType
130
+ * @param string $lastTransactionId
131
+ * @param float $amount
132
+ * @param string $exception
133
+ * @return bool|string
134
+ */
135
+ public function getTransactionMessage($payment, $requestType, $lastTransactionId, $amount = false,
136
+ $exception = false,$additionalMessage = false
137
+ ) {
138
+ return $this->getExtendedTransactionMessage(
139
+ $payment, $requestType, $lastTransactionId, $amount, $exception,$additionalMessage
140
+ );
141
+ }
142
+
143
+ /**
144
+ * Return message for gateway transaction request
145
+ *
146
+ * @param Mage_Payment_Model_Info $payment
147
+ * @param string $requestType
148
+ * @param string $lastTransactionId
149
+ * @param float $amount
150
+ * @param string $exception
151
+ * @param string $additionalMessage Custom message, which will be added to the end of generated message
152
+ * @return bool|string
153
+ */
154
+ public function getExtendedTransactionMessage($payment, $requestType, $lastTransactionId, $amount = false,
155
+ $exception = false, $additionalMessage = false
156
+ ) {
157
+ $operation = 'Operation: ' . $requestType;// $this->_getOperation($requestType);
158
+
159
+ if (!$operation) {
160
+ return false;
161
+ }
162
+
163
+ if ($amount) {
164
+ $amount = $this->__('amount: %s', $this->_formatPrice($payment, $amount));
165
+ }
166
+
167
+ if ($exception) {
168
+ $result = $this->__('failed');
169
+ } else {
170
+ $result = $this->__('successful');
171
+ }
172
+
173
+ $card = $this->__('Credit Card: xxxx-%s', $payment->getCcLast4());
174
+
175
+ $pattern = '%s - %s. %s %s.';
176
+ $texts = array($operation,$result,$card, $amount);
177
+
178
+ if (!is_null($lastTransactionId)) {
179
+ $pattern .= ' %s.';
180
+ $texts[] = $this->__('Hipay Transaction ID %s', $lastTransactionId);
181
+ }
182
+
183
+ if ($additionalMessage) {
184
+ $pattern .= ' %s.';
185
+ $texts[] = $additionalMessage;
186
+ }
187
+ $pattern .= ' %s';
188
+ $texts[] = $exception;
189
+
190
+ return call_user_func_array(array($this, '__'), array_merge(array($pattern), $texts));
191
+ }
192
+
193
+ /**
194
+ * Format price with currency sign
195
+ * @param Mage_Payment_Model_Info $payment
196
+ * @param float $amount
197
+ * @return string
198
+ */
199
+ protected function _formatPrice($payment, $amount)
200
+ {
201
+ return $payment->getOrder()->getBaseCurrency()->formatTxt($amount);
202
+ }
203
+ }
app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Curl.php ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+ * @see Zend_Uri_Http
7
+ */
8
+ #require_once 'Zend/Uri/Http.php';
9
+
10
+ /**
11
+ * @see Zend_Http_Client_Adapter_Interface
12
+ */
13
+ #require_once 'Zend/Http/Client/Adapter/Interface.php';
14
+ /**
15
+ * @see Zend_Http_Client_Adapter_Stream
16
+ */
17
+ #require_once 'Zend/Http/Client/Adapter/Stream.php';
18
+
19
+ /**
20
+ * An adapter class for Zend_Http_Client based on the curl extension.
21
+ * Curl requires libcurl. See for full requirements the PHP manual: http://php.net/curl
22
+ *
23
+ */
24
+ class Allopass_Hipay_Model_Api_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interface, Allopass_Hipay_Model_Api_Http_Client_Adapter_Stream
25
+ {
26
+ /**
27
+ * Parameters array
28
+ *
29
+ * @var array
30
+ */
31
+ protected $_config = array();
32
+
33
+ /**
34
+ * What host/port are we connected to?
35
+ *
36
+ * @var array
37
+ */
38
+ protected $_connected_to = array(null, null);
39
+
40
+ /**
41
+ * The curl session handle
42
+ *
43
+ * @var resource|null
44
+ */
45
+ protected $_curl = null;
46
+
47
+ /**
48
+ * List of cURL options that should never be overwritten
49
+ *
50
+ * @var array
51
+ */
52
+ protected $_invalidOverwritableCurlOptions;
53
+
54
+ /**
55
+ * Response gotten from server
56
+ *
57
+ * @var string
58
+ */
59
+ protected $_response = null;
60
+
61
+ /**
62
+ * Stream for storing output
63
+ *
64
+ * @var resource
65
+ */
66
+ protected $out_stream;
67
+
68
+ /**
69
+ * Adapter constructor
70
+ *
71
+ * Config is set using setConfig()
72
+ *
73
+ * @return void
74
+ * @throws Zend_Http_Client_Adapter_Exception
75
+ */
76
+ public function __construct()
77
+ {
78
+ if (!extension_loaded('curl')) {
79
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
80
+ throw new Zend_Http_Client_Adapter_Exception('cURL extension has to be loaded to use this Zend_Http_Client adapter.');
81
+ }
82
+ $this->_invalidOverwritableCurlOptions = array(
83
+ CURLOPT_HTTPGET,
84
+ CURLOPT_POST,
85
+ CURLOPT_PUT,
86
+ CURLOPT_CUSTOMREQUEST,
87
+ CURLOPT_HEADER,
88
+ CURLOPT_RETURNTRANSFER,
89
+ CURLOPT_HTTPHEADER,
90
+ CURLOPT_POSTFIELDS,
91
+ CURLOPT_INFILE,
92
+ CURLOPT_INFILESIZE,
93
+ CURLOPT_PORT,
94
+ CURLOPT_MAXREDIRS,
95
+ CURLOPT_CONNECTTIMEOUT,
96
+ CURL_HTTP_VERSION_1_1,
97
+ CURL_HTTP_VERSION_1_0,
98
+ );
99
+ }
100
+
101
+ /**
102
+ * Set the configuration array for the adapter
103
+ *
104
+ * @throws Zend_Http_Client_Adapter_Exception
105
+ * @param Zend_Config | array $config
106
+ * @return Zend_Http_Client_Adapter_Curl
107
+ */
108
+ public function setConfig($config = array())
109
+ {
110
+ if ($config instanceof Zend_Config) {
111
+ $config = $config->toArray();
112
+
113
+ } elseif (! is_array($config)) {
114
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
115
+ throw new Zend_Http_Client_Adapter_Exception(
116
+ 'Array or Zend_Config object expected, got ' . gettype($config)
117
+ );
118
+ }
119
+
120
+ if(isset($config['proxy_user']) && isset($config['proxy_pass'])) {
121
+ $this->setCurlOption(CURLOPT_PROXYUSERPWD, $config['proxy_user'].":".$config['proxy_pass']);
122
+ unset($config['proxy_user'], $config['proxy_pass']);
123
+ }
124
+
125
+ foreach ($config as $k => $v) {
126
+ $option = strtolower($k);
127
+ switch($option) {
128
+ case 'proxy_host':
129
+ $this->setCurlOption(CURLOPT_PROXY, $v);
130
+ break;
131
+ case 'proxy_port':
132
+ $this->setCurlOption(CURLOPT_PROXYPORT, $v);
133
+ break;
134
+ default:
135
+ $this->_config[$option] = $v;
136
+ break;
137
+ }
138
+ }
139
+
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * Retrieve the array of all configuration options
145
+ *
146
+ * @return array
147
+ */
148
+ public function getConfig()
149
+ {
150
+ return $this->_config;
151
+ }
152
+
153
+ /**
154
+ * Direct setter for cURL adapter related options.
155
+ *
156
+ * @param string|int $option
157
+ * @param mixed $value
158
+ * @return Zend_Http_Adapter_Curl
159
+ */
160
+ public function setCurlOption($option, $value)
161
+ {
162
+ if (!isset($this->_config['curloptions'])) {
163
+ $this->_config['curloptions'] = array();
164
+ }
165
+ $this->_config['curloptions'][$option] = $value;
166
+ return $this;
167
+ }
168
+
169
+ /**
170
+ * Initialize curl
171
+ *
172
+ * @param string $host
173
+ * @param int $port
174
+ * @param boolean $secure
175
+ * @return void
176
+ * @throws Zend_Http_Client_Adapter_Exception if unable to connect
177
+ */
178
+ public function connect($host, $port = 80, $secure = false)
179
+ {
180
+ // If we're already connected, disconnect first
181
+ if ($this->_curl) {
182
+ $this->close();
183
+ }
184
+
185
+ // If we are connected to a different server or port, disconnect first
186
+ if ($this->_curl
187
+ && is_array($this->_connected_to)
188
+ && ($this->_connected_to[0] != $host
189
+ || $this->_connected_to[1] != $port)
190
+ ) {
191
+ $this->close();
192
+ }
193
+
194
+ // Do the actual connection
195
+ $this->_curl = curl_init();
196
+ if ($port != 80) {
197
+ curl_setopt($this->_curl, CURLOPT_PORT, intval($port));
198
+ }
199
+
200
+ // Set timeout
201
+ curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']);
202
+
203
+ // Set Max redirects
204
+ curl_setopt($this->_curl, CURLOPT_MAXREDIRS, $this->_config['maxredirects']);
205
+
206
+ if (!$this->_curl) {
207
+ $this->close();
208
+
209
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
210
+ throw new Zend_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port);
211
+ }
212
+
213
+ if ($secure !== false) {
214
+ // Behave the same like Zend_Http_Adapter_Socket on SSL options.
215
+ if (isset($this->_config['sslcert'])) {
216
+ curl_setopt($this->_curl, CURLOPT_SSLCERT, $this->_config['sslcert']);
217
+ }
218
+ if (isset($this->_config['sslpassphrase'])) {
219
+ curl_setopt($this->_curl, CURLOPT_SSLCERTPASSWD, $this->_config['sslpassphrase']);
220
+ }
221
+ }
222
+
223
+ // Update connected_to
224
+ $this->_connected_to = array($host, $port);
225
+ }
226
+
227
+ /**
228
+ * Send request to the remote server
229
+ *
230
+ * @param string $method
231
+ * @param Zend_Uri_Http $uri
232
+ * @param float $http_ver
233
+ * @param array $headers
234
+ * @param string $body
235
+ * @return string $request
236
+ * @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
237
+ */
238
+ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '')
239
+ {
240
+ // Make sure we're properly connected
241
+ if (!$this->_curl) {
242
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
243
+ throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
244
+ }
245
+
246
+ if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
247
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
248
+ throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
249
+ }
250
+
251
+ // set URL
252
+ curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());
253
+
254
+ // ensure correct curl call
255
+ $curlValue = true;
256
+ switch ($method) {
257
+ case Zend_Http_Client::GET:
258
+ $curlMethod = CURLOPT_HTTPGET;
259
+ break;
260
+
261
+ case Zend_Http_Client::POST:
262
+ $curlMethod = CURLOPT_POST;
263
+ break;
264
+
265
+ case Zend_Http_Client::PUT:
266
+ // There are two different types of PUT request, either a Raw Data string has been set
267
+ // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used.
268
+ if(is_resource($body)) {
269
+ $this->_config['curloptions'][CURLOPT_INFILE] = $body;
270
+ }
271
+ if (isset($this->_config['curloptions'][CURLOPT_INFILE])) {
272
+ // Now we will probably already have Content-Length set, so that we have to delete it
273
+ // from $headers at this point:
274
+ foreach ($headers AS $k => $header) {
275
+ if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) {
276
+ if(is_resource($body)) {
277
+ $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int)$m[1];
278
+ }
279
+ unset($headers[$k]);
280
+ }
281
+ }
282
+
283
+ if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
284
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
285
+ throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
286
+ }
287
+
288
+ if(is_resource($body)) {
289
+ $body = '';
290
+ }
291
+
292
+ $curlMethod = CURLOPT_PUT;
293
+ } else {
294
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
295
+ $curlValue = "PUT";
296
+ }
297
+ break;
298
+
299
+ case Zend_Http_Client::DELETE:
300
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
301
+ $curlValue = "DELETE";
302
+ break;
303
+
304
+ case Zend_Http_Client::OPTIONS:
305
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
306
+ $curlValue = "OPTIONS";
307
+ break;
308
+
309
+ case Zend_Http_Client::TRACE:
310
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
311
+ $curlValue = "TRACE";
312
+ break;
313
+
314
+ case Zend_Http_Client::HEAD:
315
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
316
+ $curlValue = "HEAD";
317
+ break;
318
+
319
+ default:
320
+ // For now, through an exception for unsupported request methods
321
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
322
+ throw new Zend_Http_Client_Adapter_Exception("Method currently not supported");
323
+ }
324
+
325
+ if(is_resource($body) && $curlMethod != CURLOPT_PUT) {
326
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
327
+ throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT");
328
+ }
329
+
330
+ // get http version to use
331
+ $curlHttp = ($httpVersion == 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
332
+
333
+ // mark as HTTP request and set HTTP method
334
+ curl_setopt($this->_curl, $curlHttp, true);
335
+ curl_setopt($this->_curl, $curlMethod, $curlValue);
336
+
337
+ if($this->out_stream) {
338
+ // headers will be read into the response
339
+ curl_setopt($this->_curl, CURLOPT_HEADER, false);
340
+ curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader"));
341
+ // and data will be written into the file
342
+ curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
343
+ } else {
344
+ // ensure headers are also returned
345
+ curl_setopt($this->_curl, CURLOPT_HEADER, true);
346
+
347
+ // ensure actual response is returned
348
+ curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
349
+ }
350
+
351
+ // set additional headers
352
+ $headers['Accept'] = '';
353
+ curl_setopt($this->_curl, CURLOPT_HTTPHEADER, $headers);
354
+
355
+ /**
356
+ * Make sure POSTFIELDS is set after $curlMethod is set:
357
+ * @link http://de2.php.net/manual/en/function.curl-setopt.php#81161
358
+ */
359
+ if ($method == Zend_Http_Client::POST) {
360
+ curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
361
+ } elseif ($curlMethod == CURLOPT_PUT) {
362
+ // this covers a PUT by file-handle:
363
+ // Make the setting of this options explicit (rather than setting it through the loop following a bit lower)
364
+ // to group common functionality together.
365
+ curl_setopt($this->_curl, CURLOPT_INFILE, $this->_config['curloptions'][CURLOPT_INFILE]);
366
+ curl_setopt($this->_curl, CURLOPT_INFILESIZE, $this->_config['curloptions'][CURLOPT_INFILESIZE]);
367
+ unset($this->_config['curloptions'][CURLOPT_INFILE]);
368
+ unset($this->_config['curloptions'][CURLOPT_INFILESIZE]);
369
+ } elseif ($method == Zend_Http_Client::PUT) {
370
+ // This is a PUT by a setRawData string, not by file-handle
371
+ curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
372
+ }
373
+
374
+ // set additional curl options
375
+ if (isset($this->_config['curloptions'])) {
376
+ foreach ((array)$this->_config['curloptions'] as $k => $v) {
377
+ if (!in_array($k, $this->_invalidOverwritableCurlOptions)) {
378
+ if (curl_setopt($this->_curl, $k, $v) == false) {
379
+ #require_once 'Zend/Http/Client/Exception.php';
380
+ throw new Zend_Http_Client_Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k));
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ // send the request
387
+ $response = curl_exec($this->_curl);
388
+
389
+ // if we used streaming, headers are already there
390
+ if(!is_resource($this->out_stream)) {
391
+ $this->_response = $response;
392
+ }
393
+
394
+ $request = curl_getinfo($this->_curl, CURLINFO_HEADER_OUT);
395
+ $request .= $body;
396
+
397
+ if (empty($this->_response)) {
398
+ #require_once 'Zend/Http/Client/Exception.php';
399
+ throw new Zend_Http_Client_Exception("Error in cURL request: " . curl_error($this->_curl));
400
+ }
401
+
402
+ // cURL automatically decodes chunked-messages, this means we have to disallow the Zend_Http_Response to do it again
403
+ if (stripos($this->_response, "Transfer-Encoding: chunked\r\n")) {
404
+ $this->_response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->_response);
405
+ }
406
+
407
+ // Eliminate multiple HTTP responses.
408
+ do {
409
+ $parts = preg_split('|(?:\r?\n){2}|m', $this->_response, 2);
410
+ $again = false;
411
+
412
+ if (isset($parts[1]) && preg_match("|^HTTP/1\.[01](.*?)\r\n|mi", $parts[1])) {
413
+ $this->_response = $parts[1];
414
+ $again = true;
415
+ }
416
+ } while ($again);
417
+
418
+ // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
419
+ if (stripos($this->_response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) {
420
+ $this->_response = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->_response);
421
+ }
422
+
423
+ return $request;
424
+ }
425
+
426
+ /**
427
+ * Return read response from server
428
+ *
429
+ * @return string
430
+ */
431
+ public function read()
432
+ {
433
+ return $this->_response;
434
+ }
435
+
436
+ /**
437
+ * Close the connection to the server
438
+ *
439
+ */
440
+ public function close()
441
+ {
442
+ if(is_resource($this->_curl)) {
443
+ curl_close($this->_curl);
444
+ }
445
+ $this->_curl = null;
446
+ $this->_connected_to = array(null, null);
447
+ }
448
+
449
+ /**
450
+ * Get cUrl Handle
451
+ *
452
+ * @return resource
453
+ */
454
+ public function getHandle()
455
+ {
456
+ return $this->_curl;
457
+ }
458
+
459
+ /**
460
+ * Set output stream for the response
461
+ *
462
+ * @param resource $stream
463
+ * @return Zend_Http_Client_Adapter_Socket
464
+ */
465
+ public function setOutputStream($stream)
466
+ {
467
+ $this->out_stream = $stream;
468
+ return $this;
469
+ }
470
+
471
+ /**
472
+ * Header reader function for CURL
473
+ *
474
+ * @param resource $curl
475
+ * @param string $header
476
+ * @return int
477
+ */
478
+ public function readHeader($curl, $header)
479
+ {
480
+ $this->_response .= $header;
481
+ return strlen($header);
482
+ }
483
+ }
app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Stream.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * An interface description for Zend_Http_Client_Adapter_Stream classes.
5
+ *
6
+ * This interface decribes Zend_Http_Client_Adapter which supports streaming.
7
+
8
+ */
9
+ interface Allopass_Hipay_Model_Api_Http_Client_Adapter_Stream
10
+ {
11
+ /**
12
+ * Set output stream
13
+ *
14
+ * This function sets output stream where the result will be stored.
15
+ *
16
+ * @param resource $stream Stream to write the output to
17
+ *
18
+ */
19
+ function setOutputStream($stream);
20
+ }
app/code/community/Allopass/Hipay/Model/Api/Request.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Api_Request
3
+ {
4
+
5
+ const VAULT_ACTION_CREATE = 'create';
6
+
7
+ const VAULT_ACTION_UPDATE = 'update';
8
+
9
+ const VAULT_ACTION_LOOKUP = '';
10
+
11
+ const GATEWAY_ACTION_ORDER = 'order';
12
+
13
+ const GATEWAY_ACTION_MAINTENANCE = 'maintenance/transaction/';
14
+
15
+ const GATEWAY_ACTION_HOSTED = "hpayment";
16
+
17
+ /**
18
+ *
19
+ * @var Zend_Http_Client
20
+ */
21
+ protected $_client = null;
22
+
23
+ protected $_methodInstance = null;
24
+
25
+ public function __construct( $methodInstance)
26
+ {
27
+ $this->_methodInstance = $methodInstance[0];
28
+ }
29
+
30
+ protected function getMethodInstance()
31
+ {
32
+ if(!$this->_methodInstance instanceof Mage_Payment_Model_Method_Abstract)
33
+ Mage::throwException("Method instance must be setted or must be type of Mage_Payment_Model_Method_Abstract");
34
+
35
+ return $this->_methodInstance;
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @param Mage_Payment_Model_Method_Abstract $methodInstance
41
+ */
42
+ protected function setMethodInstance($methodInstance)
43
+ {
44
+ $this->_methodInstance = $methodInstance;
45
+ }
46
+
47
+
48
+ protected function getApiUsername($storeId=null)
49
+ {
50
+ if($this->isTestMode())
51
+ return $this->getConfig()->getApiUsernameTest($storeId);
52
+
53
+ return $this->getConfig()->getApiUsername($storeId);
54
+ }
55
+
56
+ protected function getApiPassword($storeId=null)
57
+ {
58
+ if($this->isTestMode())
59
+ return $this->getConfig()->getApiPasswordTest($storeId);
60
+
61
+ return $this->getConfig()->getApiPassword($storeId);
62
+ }
63
+
64
+ protected function isTestMode()
65
+ {
66
+ return (bool)$this->getMethodInstance()->getConfigData('is_test_mode');
67
+ }
68
+
69
+
70
+
71
+ /**
72
+ *
73
+ * @return Allopass_Hipay_Model_Config $config
74
+ */
75
+ protected function getConfig()
76
+ {
77
+ return Mage::getSingleton('hipay/config');
78
+ }
79
+
80
+ /**
81
+ * Get client HTTP
82
+ * @return Zend_Http_Client
83
+ */
84
+ public function getClient($storeId=null)
85
+ {
86
+ if(is_null($this->_client))
87
+ {
88
+ //$credentials = $this->getApiUsername($storeId) . ':' . $this->getApiPassword($storeId);
89
+
90
+ //adapter options
91
+ $config = array('curloptions' => array(
92
+ //CURLOPT_USERPWD=>$credentials,
93
+ //CURLOPT_HTTPHEADER => array('Accept: application/json'),
94
+ CURLOPT_FAILONERROR => false,
95
+ CURLOPT_HEADER=>false,
96
+ CURLOPT_RETURNTRANSFER=>true),
97
+ );
98
+ try {
99
+
100
+ //innitialize http client and adapter curl
101
+ $adapter = Mage::getSingleton('hipay/api_http_client_adapter_curl');
102
+
103
+ $this->_client = new Zend_Http_Client();
104
+ //$adapter->setConfig($config);
105
+ $this->_client->setConfig($config);
106
+ $this->_client->setHeaders(array('Content-Type'=>'application/xml',
107
+ 'Accept'=>'application/json'));
108
+ $this->_client->setAuth($this->getApiUsername($storeId),
109
+ $this->getApiPassword($storeId),
110
+ Zend_Http_Client::AUTH_BASIC);
111
+ $this->_client->setAdapter($adapter);
112
+
113
+
114
+ } catch (Exception $e) {
115
+ Mage::throwException($e);
116
+ }
117
+ }
118
+
119
+ return $this->_client;
120
+ }
121
+
122
+ protected function _request($uri,$params=array(),$method=Zend_Http_Client::POST,$storeId=null)
123
+ {
124
+
125
+ if($method == Zend_Http_Client::POST)
126
+ $this->getClient()->setParameterPost($params);
127
+ else
128
+ $this->getClient()->setParameterGet($params);
129
+
130
+ $this->getClient()->setUri($uri);
131
+
132
+ /* @var $response Zend_Http_Response */
133
+ $response = $this->getClient()->request($method);
134
+
135
+ if($response->isSuccessful())
136
+ {
137
+ //$this->getClient()->getAdapter()->close();
138
+ return json_decode($response->getBody(),true);
139
+ }
140
+ else
141
+ {
142
+ /* @var $error Allopass_Hipay_Model_Api_Response_Error */
143
+ $error = Mage::getSingleton('hipay/api_response_error');
144
+ $error->setData(json_decode($response->getBody(),true));
145
+ $messageError = "Code: " . $error->getCode() . ". Message: " . $error->getMessage();
146
+ if($error->getDescription() != "")
147
+ $messageError .= ". Details: " . $error->getDescription();
148
+
149
+ Mage::throwException($messageError);
150
+ }
151
+
152
+
153
+ }
154
+
155
+ public function getMethodHttp($action)
156
+ {
157
+ if($action == self::VAULT_ACTION_LOOKUP)
158
+ return Zend_Http_Client::GET;
159
+
160
+ return Zend_Http_Client::POST;
161
+ }
162
+
163
+ /**
164
+ *
165
+ */
166
+ protected function getVaultApiEndpoint($storeId=null) {
167
+ if($this->isTestMode())
168
+ return $this->getConfig()->getVaultEndpointTest($storeId);
169
+
170
+ return $this->getConfig()->getVaultEndpoint($storeId);
171
+
172
+ }
173
+
174
+ /**
175
+ *
176
+ */
177
+ protected function getGatewayApiEndpoint($storeId=null) {
178
+ if($this->isTestMode())
179
+ return $this->getConfig()->getGatewayEndpointTest($storeId);
180
+
181
+ return $this->getConfig()->getGatewayEndpoint($storeId);
182
+
183
+ }
184
+
185
+
186
+ /**
187
+ *
188
+ * @param string $action
189
+ * @param array $params
190
+ * @param int $storeId
191
+ * @return Allopass_Hipay_Model_Response_Vault
192
+ */
193
+ public function vaultRequest($action,$params,$storeId=null)
194
+ {
195
+ $uri = $this->getVaultApiEndpoint($storeId) . $action . "/";
196
+
197
+ /* @var $response Allopass_Hipay_Model_Api_Response_Vault */
198
+ $response = Mage::getSingleton('hipay/api_response_vault', $this->_request($uri,$params,$this->getMethodHttp($action),$storeId));
199
+
200
+ return $response;
201
+ }
202
+
203
+ /**
204
+ *
205
+ * @param string $action
206
+ * @param array $params
207
+ * @param int $storeId
208
+ * @return Allopass_Hipay_Model_Response_Abstract
209
+ */
210
+ public function gatewayRequest($action,$params,$storeId=null)
211
+ {
212
+ $uri = $this->getGatewayApiEndpoint($storeId) . $action;
213
+
214
+ /* @var $response Allopass_Hipay_Model_Api_Response_Gateway */
215
+ $response = Mage::getSingleton('hipay/api_response_gateway',$this->_request($uri,$params,$this->getMethodHttp($action),$storeId));
216
+ return $response;
217
+ }
218
+
219
+ }
app/code/community/Allopass/Hipay/Model/Api/Response/Abstract.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @method string getToken() card token
5
+ * @method string getBrand() card type
6
+ * @method string getPan() card number masked
7
+ * @method string getCardHolder() Cardholder name
8
+ * @method int getCardExpiryMonth() card expiry month (2 digits)
9
+ * @method int getCardExpiryYear() card expiry year (4 digits)
10
+ * @method string getIssuer() card issuing bank name
11
+ * @method string getCountry() bank country code (ISO 3166-1, 2 letters)
12
+ *
13
+ */
14
+ abstract class Allopass_Hipay_Model_Api_Response_Abstract extends Varien_Object
15
+ {
16
+
17
+ }
app/code/community/Allopass/Hipay/Model/Api/Response/Error.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @method string getCode()
5
+ * @method string getMessage()
6
+ * @method string getDescription()
7
+ *
8
+ */
9
+ class Allopass_Hipay_Model_Api_Response_Error extends Varien_Object
10
+ {
11
+
12
+ }
app/code/community/Allopass/Hipay/Model/Api/Response/Gateway.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @method string getState() transaction state. completed,forwarding, pending, declined, error
5
+ * @method array getReason() optional element. Reason why transaction was declined.
6
+ * @method string getForwardUrl() optional element. Merchant must redirect the customer's browser to this URL.
7
+ * @method bool getTest() true if the transaction is a testing transaction, otherwise false
8
+ * @method int getMid() your merchant account number (issued to you by Allopass).
9
+ * @method int getAttemptId() attempt id of the payment.
10
+ * @method string getAuthorizationCode() an authorization code (up to 35 characters) generated for each approved or pending transaction by the acquiring provider.
11
+ * @method string getTransactionReference() the unique identifier of the transaction.
12
+ * @method DateTime getDateCreated() time when transaction was created.
13
+ * @method DateTime getDateUpdated() time when transaction was last updated.
14
+ * @method DateTime getDateAuthorized() time when transaction was authorized.
15
+ * @method string getStatus() transaction status.
16
+ * @method string getMessage() transaction message.
17
+ * @method string getAuthorizedAmount() the transaction amount.
18
+ * @method string getCapturedAmount() captured amount.
19
+ * @method string getRefundedAmount() refunded amount.
20
+ * @method string getDecimals() decimal precision of transaction amount..
21
+ * @method string getCurrency() base currency for this transaction.
22
+ * @method string getIpAddress() the IP address of the customer making the purchase.
23
+ * @method string getIpCountry() country code associated to the customer's IP address.
24
+ * @method string getEci() Electronic Commerce Indicator (ECI).
25
+ * @method string getPaymentProduct() payment product used to complete the transaction.
26
+ * @method string getPaymentMethod() base currency for this transaction.
27
+ * @method array getFraudScreening() Result of the fraud screening.
28
+ *
29
+ */
30
+ class Allopass_Hipay_Model_Api_Response_Gateway extends Allopass_Hipay_Model_Api_Response_Abstract
31
+ {
32
+ public function getForwardUrl()
33
+ {
34
+ return $this->getData('forwardUrl');
35
+ }
36
+
37
+ public function getAttemptId()
38
+ {
39
+ return $this->getData('attemptId');
40
+ }
41
+
42
+ public function getAuthorizationCode()
43
+ {
44
+ return $this->getData('authorizationCode');
45
+ }
46
+
47
+
48
+ public function getTransactionReference()
49
+ {
50
+ if($this->getData('transactionReference') == '')
51
+ return $this->getData('reference');
52
+
53
+ return $this->getData('transactionReference');
54
+ }
55
+
56
+
57
+ public function getDateCreated()
58
+ {
59
+ return $this->getData('dateCreated');
60
+ }
61
+
62
+
63
+ public function getDateUpdated()
64
+ {
65
+ return $this->getData('dateUpdated');
66
+ }
67
+
68
+
69
+ public function getDateAuthorized()
70
+ {
71
+ return $this->getData('dateAuthorized');
72
+ }
73
+
74
+ public function getAuthorizedAmount()
75
+ {
76
+ return $this->getData('authorizedAmount');
77
+ }
78
+
79
+ public function getCapturedAmount()
80
+ {
81
+ return $this->getData('capturedAmount');
82
+ }
83
+
84
+ public function getRefundedAmount()
85
+ {
86
+ return $this->getData('refundedAmount');
87
+ }
88
+
89
+ public function getIpAddress()
90
+ {
91
+ return $this->getData('ipAddress');
92
+ }
93
+
94
+ public function getIpCountry()
95
+ {
96
+ return $this->getData('ipCountry');
97
+ }
98
+
99
+ public function getPaymentProduct()
100
+ {
101
+ return $this->getData('paymentProduct');
102
+ }
103
+
104
+ public function getPaymentMethod()
105
+ {
106
+ return $this->getData('paymentMethod');
107
+ }
108
+
109
+ public function getFraudScreening()
110
+ {
111
+ return $this->getData('fraudScreening');
112
+ }
113
+
114
+ }
app/code/community/Allopass/Hipay/Model/Api/Response/Notification.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @method string getState() transaction state. completed,forwarding, pending, declined, error
5
+ * @method array getReason() optional element. Reason why transaction was declined.
6
+ * @method bool getTest() true if the transaction is a testing transaction, otherwise false
7
+ * @method int getMid() your merchant account number (issued to you by Allopass).
8
+ * @method int getAttemptId() attempt id of the payment.
9
+ * @method string getAuthorizationCode() an authorization code (up to 35 characters) generated for each approved or pending transaction by the acquiring provider.
10
+ * @method string getTransactionReference() the unique identifier of the transaction.
11
+ * @method DateTime getDateCreated() time when transaction was created.
12
+ * @method DateTime getDateUpdated() time when transaction was last updated.
13
+ * @method DateTime getDateAuthorized() time when transaction was authorized.
14
+ * @method string getStatus() transaction status.
15
+ * @method string getMessage() transaction message.
16
+ * @method string getAuthorizedAmount() the transaction amount.
17
+ * @method string getCapturedAmount() captured amount.
18
+ * @method string getRefundedAmount() refunded amount.
19
+ * @method string getDecimals() decimal precision of transaction amount..
20
+ * @method string getCurrency() base currency for this transaction.
21
+ * @method string getIpAddress() the IP address of the customer making the purchase.
22
+ * @method string getIpCountry() country code associated to the customer's IP address.
23
+ * @method string getEci() Electronic Commerce Indicator (ECI).
24
+ * @method string getPaymentProduct() payment product used to complete the transaction.
25
+ * @method string getPaymentMethod() base currency for this transaction.
26
+ * @method array getFraudScreening() Result of the fraud screening.
27
+ *
28
+ */
29
+ class Allopass_Hipay_Model_Api_Response_Notification extends Allopass_Hipay_Model_Api_Response_Abstract
30
+ {
31
+
32
+
33
+ }
app/code/community/Allopass/Hipay/Model/Api/Response/Vault.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @method string getRequestId() ...
4
+ *
5
+ */
6
+ class Allopass_Hipay_Model_Api_Response_Vault extends Allopass_Hipay_Model_Api_Response_Abstract
7
+ {
8
+
9
+ }
app/code/community/Allopass/Hipay/Model/Config.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Config extends Varien_Object
3
+ {
4
+ const API_USERNAME = 'api_username';
5
+
6
+ const API_PASSWORD = 'api_password';
7
+
8
+ const API_USERNAME_TEST = "api_username_test";
9
+
10
+ const API_PASSWORD_TEST = 'api_password_test';
11
+
12
+ const SECRET_PASSPHRASE = 'secret_passphrase';
13
+
14
+ const VAULT_ENDPOINT_TEST = 'vault_endpoint_stage';
15
+
16
+ const VAULT_ENDPOINT = 'vault_endpoint_production';
17
+
18
+ const GATEWAY_ENDPOINT_TEST = 'gateway_endpoint_stage';
19
+
20
+ const GATEWAY_ENDPOINT = 'gateway_endpoint_production';
21
+
22
+
23
+ /**
24
+ * Return config var
25
+ *
26
+ * @param string $key Var path key
27
+ * @param int $storeId Store View Id
28
+ * @return mixed
29
+ */
30
+ public function getConfigData($key, $storeId = null)
31
+ {
32
+
33
+ if (!$this->hasData($key)) {
34
+ $value = Mage::getStoreConfig('hipay/hipay_api/' . $key, $storeId);
35
+ $this->setData($key, $value);
36
+ }
37
+ return $this->getData($key);
38
+ }
39
+
40
+ /**
41
+ * Return config var
42
+ *
43
+ * @param string $key Var path key
44
+ * @param int $storeId Store View Id
45
+ * @return mixed
46
+ */
47
+ public function getConfigFlag($key, $storeId = null)
48
+ {
49
+
50
+ if (!$this->hasData($key)) {
51
+ $value = Mage::getStoreConfigFlag('hipay/hipay_api/' . $key, $storeId);
52
+ $this->setData($key, $value);
53
+ }
54
+ return $this->getData($key);
55
+ }
56
+
57
+ public function getSecretPassphrase($storeId =null)
58
+ {
59
+ return $this->getConfigData(self::SECRET_PASSPHRASE,$storeId);
60
+ }
61
+
62
+ public function getApiUsername($storeId =null)
63
+ {
64
+ return $this->getConfigData(self::API_USERNAME,$storeId);
65
+ }
66
+
67
+ public function getApiPassword($storeId=null)
68
+ {
69
+ return $this->getConfigData(self::API_PASSWORD,$storeId);
70
+ }
71
+
72
+ public function getApiUsernameTest($storeId =null)
73
+ {
74
+ return $this->getConfigData(self::API_USERNAME_TEST,$storeId);
75
+ }
76
+
77
+ public function getApiPasswordTest($storeId=null)
78
+ {
79
+ return $this->getConfigData(self::API_PASSWORD_TEST,$storeId);
80
+ }
81
+
82
+ public function getVaultEndpoint($storeId=null)
83
+ {
84
+ return $this->getConfigData(self::VAULT_ENDPOINT,$storeId);
85
+ }
86
+
87
+ public function getVaultEndpointTest($storeId=null)
88
+ {
89
+ return $this->getConfigData(self::VAULT_ENDPOINT_TEST,$storeId);
90
+ }
91
+
92
+ public function getGatewayEndpoint($storeId=null)
93
+ {
94
+ return $this->getConfigData(self::GATEWAY_ENDPOINT,$storeId);
95
+ }
96
+
97
+ public function getGatewayEndpointTest($storeId=null)
98
+ {
99
+ return $this->getConfigData(self::GATEWAY_ENDPOINT_TEST,$storeId);
100
+ }
101
+
102
+ /**
103
+ * Retrieve array of credit card types
104
+ *
105
+ * @return array
106
+ */
107
+ public function getCcTypes()
108
+ {
109
+ $_types = Mage::getConfig()->getNode('global/payment_hipay/cc/types')->asArray();
110
+
111
+ uasort($_types, array('Allopass_Hipay_Model_Config', 'compareCcTypes'));
112
+
113
+ $types = array();
114
+ foreach ($_types as $data) {
115
+ if (isset($data['code']) && isset($data['name'])) {
116
+ $types[$data['code']] = $data['name'];
117
+ }
118
+ }
119
+ return $types;
120
+ }
121
+
122
+ /**
123
+ * Retrieve array of credit card types to get code hipay equals to code Magento
124
+ *
125
+ * @return array
126
+ */
127
+ public function getCcTypesHipay()
128
+ {
129
+ $_types = Mage::getConfig()->getNode('global/payment_hipay/hosted/types')->asArray();
130
+
131
+ $types = array();
132
+ foreach ($_types as $data) {
133
+ if (isset($data['code']) && isset($data['code_hipay'])) {
134
+ $types[$data['code']] = $data['code_hipay'];
135
+ }
136
+ }
137
+ return $types;
138
+ }
139
+
140
+ /**
141
+ * Retrieve array of template types to display in hosted page
142
+ *
143
+ * @return array
144
+ */
145
+ public function getTemplateHosted()
146
+ {
147
+ $_templates = Mage::getConfig()->getNode('global/template_hipay/hosted')->asArray();
148
+
149
+ $templates = array();
150
+ foreach ($_templates as $data) {
151
+ if (isset($data['value']) && isset($data['label'])) {
152
+ $templates[$data['value']] = $data['label'];
153
+ }
154
+ }
155
+ return $templates;
156
+ }
157
+
158
+ /**
159
+ * Retrieve array of credit card types to get code hipay
160
+ *
161
+ * @return array
162
+ */
163
+ public function getCcTypesCodeHipay()
164
+ {
165
+ $_types = Mage::getConfig()->getNode('global/payment_hipay/hosted/types')->asArray();
166
+
167
+ $types = array();
168
+ foreach ($_types as $data) {
169
+ if (isset($data['code_hipay']) && isset($data['name'])) {
170
+ $types[$data['code_hipay']] = $data['name'];
171
+ }
172
+ }
173
+ return $types;
174
+ }
175
+
176
+ /**
177
+ * Retrieve list of months translation
178
+ *
179
+ * @return array
180
+ */
181
+ public function getMonths()
182
+ {
183
+ $data = Mage::app()->getLocale()->getTranslationList('month');
184
+ foreach ($data as $key => $value) {
185
+ $monthNum = ($key < 10) ? '0'.$key : $key;
186
+ $data[$key] = $monthNum . ' - ' . $value;
187
+ }
188
+ return $data;
189
+ }
190
+
191
+ /**
192
+ * Retrieve array of available years
193
+ *
194
+ * @return array
195
+ */
196
+ public function getYears()
197
+ {
198
+ $years = array();
199
+ $first = date("Y");
200
+
201
+ for ($index=0; $index <= 10; $index++) {
202
+ $year = $first + $index;
203
+ $years[$year] = $year;
204
+ }
205
+ return $years;
206
+ }
207
+
208
+ /**
209
+ * Statis Method for compare sort order of CC Types
210
+ *
211
+ * @param array $a
212
+ * @param array $b
213
+ * @return int
214
+ */
215
+ static function compareCcTypes($a, $b)
216
+ {
217
+ if (!isset($a['order'])) {
218
+ $a['order'] = 0;
219
+ }
220
+
221
+ if (!isset($b['order'])) {
222
+ $b['order'] = 0;
223
+ }
224
+
225
+ if ($a['order'] == $b['order']) {
226
+ return 0;
227
+ } else if ($a['order'] > $b['order']) {
228
+ return 1;
229
+ } else {
230
+ return -1;
231
+ }
232
+
233
+ }
234
+ }
app/code/community/Allopass/Hipay/Model/Log/Adapter.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Log Adapter
5
+ */
6
+ class Allopass_Hipay_Model_Log_Adapter
7
+ {
8
+
9
+ /**
10
+ * Store log file name
11
+ *
12
+ * @var string
13
+ */
14
+ protected $_logFileName = '';
15
+
16
+ /**
17
+ * Data to log
18
+ *
19
+ * @var array
20
+ */
21
+ protected $_data = array();
22
+
23
+ /**
24
+ * Fields that should be replaced in debug data with '***'
25
+ *
26
+ * @var array
27
+ */
28
+ protected $_debugReplacePrivateDataKeys = array();
29
+
30
+ /**
31
+ * Set log file name
32
+ *
33
+ * @param string $fileName
34
+ */
35
+ public function __construct($fileName)
36
+ {
37
+ $this->_logFileName = $fileName;
38
+ }
39
+
40
+ /**
41
+ * Perform forced log data to file
42
+ *
43
+ * @param mixed $data
44
+ * @return Mage_Core_Model_Log_Adapter
45
+ */
46
+ public function log($data = null)
47
+ {
48
+ if ($data === null) {
49
+ $data = $this->_data;
50
+ }
51
+ else {
52
+ if (!is_array($data)) {
53
+ $data = array($data);
54
+ }
55
+ }
56
+ $data = $this->_filterDebugData($data);
57
+ $data['__pid'] = getmypid();
58
+ Mage::log($data, null, $this->_logFileName, true);
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Log data setter
64
+ *
65
+ * @param string|array $key
66
+ * @param mixed $value
67
+ * @return Mage_Core_Model_Log_Adapter
68
+ * @todo replace whole data
69
+ */
70
+ public function setData($key, $value = null)
71
+ {
72
+ if(is_array($key)) {
73
+ $this->_data = $key;
74
+ }
75
+ else {
76
+ $this->_data[$key] = $value;
77
+ }
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Setter for private data keys, that should be replaced in debug data with '***'
83
+ *
84
+ * @param array $keys
85
+ * @return Mage_Core_Model_Log_Adapter
86
+ */
87
+ public function setFilterDataKeys($keys)
88
+ {
89
+ if (!is_array($keys)) {
90
+ $keys = array($keys);
91
+ }
92
+ $this->_debugReplacePrivateDataKeys = $keys;
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Recursive filter data by private conventions
98
+ *
99
+ * @param mixed $debugData
100
+ * @return mixed
101
+ */
102
+ protected function _filterDebugData($debugData)
103
+ {
104
+ if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) {
105
+ foreach ($debugData as $key => $value) {
106
+ if (in_array($key, $this->_debugReplacePrivateDataKeys)) {
107
+ $debugData[$key] = '****';
108
+ }
109
+ else {
110
+ if (is_array($debugData[$key])) {
111
+ $debugData[$key] = $this->_filterDebugData($debugData[$key]);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ return $debugData;
117
+ }
118
+ }
app/code/community/Allopass/Hipay/Model/Method/Abstract.php ADDED
@@ -0,0 +1,1003 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Allopass_Hipay_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+ const OPERATION_SALE = "Sale";
5
+ const OPERATION_AUTHORIZATION = "Authorization";
6
+ const OPERATION_MAINTENANCE_CAPTURE = "Capture";
7
+ const OPERATION_MAINTENANCE_REFUND = "Refund";
8
+
9
+
10
+ const STATE_COMPLETED = "completed";
11
+ const STATE_FORWARDING = "forwarding";
12
+ const STATE_PENDING = "pending";
13
+ const STATE_DECLINED = "declined";
14
+ const STATE_ERROR = "error";
15
+
16
+ //const STATUS_PENDING_CAPTURE = 'pending_capture';
17
+
18
+ /**
19
+ * Availability options
20
+ */
21
+ protected $_isGateway = true;
22
+ protected $_canAuthorize = true;
23
+ protected $_canCapture = true;
24
+ protected $_canCapturePartial = true;
25
+ protected $_canRefund = true;
26
+ protected $_canRefundInvoicePartial = true;
27
+ protected $_canVoid = true;
28
+ protected $_canUseInternal = false;
29
+ protected $_canUseCheckout = true;
30
+ protected $_canUseForMultishipping = false;
31
+ protected $_canSaveCc = false;
32
+ protected $_canReviewPayment = false;
33
+
34
+ //protected $_allowCurrencyCode = array('EUR');
35
+
36
+ /**
37
+ * Fields that should be replaced in debug with '***'
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_debugReplacePrivateDataKeys = array('token','cardtoken','card_number','cvc');
42
+
43
+
44
+ public function isInitializeNeeded()
45
+ {
46
+ return true;
47
+ }
48
+
49
+
50
+ protected function getOperation()
51
+ {
52
+ switch ($this->getConfigPaymentAction())
53
+ {
54
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
55
+ return self::OPERATION_AUTHORIZATION;
56
+ default:
57
+ return self::OPERATION_SALE;
58
+ }
59
+
60
+ return '';
61
+ }
62
+
63
+
64
+ public function authorize(Varien_Object $payment, $amount)
65
+ {
66
+ parent::authorize($payment, $amount);
67
+
68
+ $payment->setSkipTransactionCreation(true);
69
+ return $this;
70
+ }
71
+
72
+
73
+
74
+
75
+ /**
76
+ *
77
+ * @param Allopass_Hipay_Model_Api_Response_Gateway $gatewayResponse
78
+ * @param Mage_Sales_Model_Order_Payment $payment
79
+ * @param float $amount
80
+ */
81
+ public function processResponse($gatewayResponse,$payment,$amount)
82
+ {
83
+
84
+ $order = $payment->getOrder();
85
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
86
+
87
+ //$defaultExceptionMessage = Mage::helper('hipay')->__('Error in process response!');
88
+
89
+ switch ($this->getConfigPaymentAction()) {
90
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
91
+ $requestType = self::OPERATION_AUTHORIZATION;
92
+ $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
93
+ $defaultExceptionMessage = Mage::helper('hipay')->__('Payment authorization error.');
94
+ break;
95
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
96
+ $requestType = self::OPERATION_SALE;
97
+ $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
98
+ $defaultExceptionMessage = Mage::helper('hipay')->__('Payment capturing error.');
99
+ break;
100
+ }
101
+
102
+ switch ($gatewayResponse->getState())
103
+ {
104
+ case self::STATE_COMPLETED:
105
+ case self::STATE_PENDING:
106
+ switch ((int)$gatewayResponse->getStatus())
107
+ {
108
+ case 111: //denied
109
+
110
+ $this->addTransaction(
111
+ $payment,
112
+ $gatewayResponse->getTransactionReference(),
113
+ $newTransactionType,
114
+ array('is_transaction_closed' => 0),
115
+ array(),
116
+ Mage::helper('hipay')->getTransactionMessage(
117
+ $payment, $requestType, /*$gatewayResponse->getTransactionReference()*/null, $amount
118
+ )
119
+ );
120
+
121
+
122
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
123
+ $order->unhold();
124
+ }
125
+
126
+ if (!$status = $this->getConfigData('order_status_payment_refused')) {
127
+ $status = $order->getStatus();
128
+ }
129
+
130
+
131
+ if ($status == Mage_Sales_Model_Order::STATE_HOLDED && $order->canHold()) {
132
+ $order->hold();
133
+ } elseif ($status == Mage_Sales_Model_Order::STATE_CANCELED && $order->canCancel()) {
134
+ $order->cancel();
135
+ }
136
+
137
+ $order->addStatusToHistory($status, Mage::helper('hipay')->getTransactionMessage(
138
+ $payment, self::OPERATION_AUTHORIZATION, null, $amount,true,$gatewayResponse->getMessage()
139
+ ));
140
+
141
+ $order->save();
142
+
143
+
144
+ break;
145
+ case 112: //Authorized and pending
146
+
147
+
148
+ $this->addTransaction(
149
+ $payment,
150
+ $gatewayResponse->getTransactionReference(),
151
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
152
+ array('is_transaction_closed' => 0),
153
+ array(
154
+ $this->_realTransactionIdKey => $gatewayResponse->getTransactionReference(),
155
+ ),
156
+ Mage::helper('hipay')->getTransactionMessage(
157
+ $payment, self::OPERATION_AUTHORIZATION, $gatewayResponse->getTransactionReference(), $amount,true
158
+ )
159
+ );
160
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
161
+ if(defined('Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW'))
162
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
163
+ $status = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
164
+
165
+ if($fraudScreening = $gatewayResponse->getFraudScreening())
166
+ {
167
+
168
+ if(isset($fraudScreening['result'])
169
+ && ($fraudScreening['result'] == 'pending' || $fraudScreening['result'] == 'challenged') )
170
+ {
171
+ if(defined('Mage_Sales_Model_Order::STATUS_FRAUD'))
172
+ $status = Mage_Sales_Model_Order::STATUS_FRAUD;
173
+
174
+ }
175
+
176
+ }
177
+
178
+ $order->setState($state,$status,$gatewayResponse->getMessage());
179
+
180
+ $order->save();
181
+ break;
182
+
183
+ case 116: //Authorized
184
+
185
+ if($order->getStatus() == 'capture_requested' || $order->getStatus() == 'processing' )// for logic process
186
+ break;
187
+ if(!$this->isPreauthorizeCapture($payment))
188
+ $this->addTransaction(
189
+ $payment,
190
+ $gatewayResponse->getTransactionReference(),
191
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
192
+ array('is_transaction_closed' => 0),
193
+ array(),
194
+ Mage::helper('hipay')->getTransactionMessage(
195
+ $payment, self::OPERATION_AUTHORIZATION, /*$gatewayResponse->getTransactionReference()*/null, $amount
196
+ )
197
+ );
198
+
199
+ $order->setState(
200
+ Mage_Sales_Model_Order::STATE_PROCESSING,
201
+ 'pending_capture',
202
+ Mage::helper('hipay')
203
+ ->__("Waiting for capture transaction ID '%s' of amount %s",
204
+ $gatewayResponse->getTransactionReference(),
205
+ $order->getBaseCurrency()->formatTxt($order->getBaseTotalDue())),
206
+ $notified = true);
207
+
208
+ $order->save();
209
+ if (!$order->getEmailSent()) {
210
+ $order->sendNewOrderEmail();
211
+ }
212
+
213
+
214
+
215
+ break;
216
+ case 117: //Capture Requested
217
+
218
+ $this->addTransaction(
219
+ $payment,
220
+ $gatewayResponse->getTransactionReference(),
221
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
222
+ array('is_transaction_closed' => 0),
223
+ array(),
224
+ Mage::helper('hipay')->getTransactionMessage(
225
+ $payment, self::OPERATION_SALE, /*$gatewayResponse->getTransactionReference()*/null, $amount
226
+ )
227
+ );
228
+
229
+ $message = Mage::helper("hipay")->__('Capture Requested by Hipay.');
230
+
231
+ $order->setState(
232
+ Mage_Sales_Model_Order::STATE_PROCESSING, 'capture_requested', $message, null, false
233
+ );
234
+
235
+ if(((int)$this->getConfigData('hipay_status_validate_order') == 117) === false )
236
+ break;
237
+ else {
238
+ $order->save();
239
+ }
240
+
241
+ case 118: //Capture
242
+
243
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
244
+ $order->unhold();
245
+ }
246
+
247
+
248
+ if (!$status = $this->getConfigData('order_status_payment_accepted')) {
249
+ $status = $order->getStatus();
250
+ }
251
+
252
+ $message = Mage::helper("hipay")->__('Payment accepted by Hipay.');
253
+
254
+ if ($status == Mage_Sales_Model_Order::STATE_PROCESSING) {
255
+ $order->setState(
256
+ Mage_Sales_Model_Order::STATE_PROCESSING, $status, $message
257
+ );
258
+ } else if ($status == Mage_Sales_Model_Order::STATE_COMPLETE) {
259
+ $order->setState(
260
+ Mage_Sales_Model_Order::STATE_COMPLETE, $status, $message, null, false
261
+ );
262
+ } else {
263
+ $order->addStatusToHistory($status, $message, true);
264
+ }
265
+
266
+
267
+
268
+ // Create invoice
269
+ if ($this->getConfigData('invoice_create',$order->getStoreId()) && !$order->hasInvoices()) {
270
+
271
+ $invoice = $order->prepareInvoice();
272
+ $invoice->setTransactionId($gatewayResponse->getTransactionReference());
273
+ $invoice->register()->capture();
274
+ $invoice->setIsPaid(1);
275
+ Mage::getModel('core/resource_transaction')
276
+ ->addObject($invoice)->addObject($invoice->getOrder())
277
+ ->save();
278
+
279
+ }
280
+ elseif($order->hasInvoices())
281
+ {
282
+ foreach ($order->getInvoiceCollection() as $invoice)
283
+ {
284
+ if($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN && $invoice->getBaseGrandTotal() == $gatewayResponse->getCapturedAmount())
285
+ {
286
+ $invoice->pay();
287
+ Mage::getModel('core/resource_transaction')
288
+ ->addObject($invoice)->addObject($invoice->getOrder())
289
+ ->save();
290
+
291
+ }
292
+ }
293
+ }
294
+
295
+ if (!$order->getEmailSent()) {
296
+ $order->sendNewOrderEmail();
297
+ }
298
+
299
+ break;
300
+
301
+ case 124: //Refund Requested
302
+
303
+ $message = Mage::helper("hipay")->__('Refund Requested by Hipay.');
304
+
305
+ $order->setState(
306
+ Mage_Sales_Model_Order::STATE_PROCESSING, 'refund_requested', $message, null, false
307
+ );
308
+
309
+ break;
310
+ case 125: //Refund
311
+
312
+ if($order->hasCreditmemos())
313
+ {
314
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
315
+ foreach ($order->getCreditmemosCollection() as $creditmemo)
316
+ {
317
+ if($creditmemo->getState() == Mage_Sales_Model_Order_Creditmemo::STATE_OPEN
318
+ && $creditmemo->getGrandTotal() == $gatewayResponse->getRefundedAmount())
319
+ {
320
+ $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED);
321
+
322
+ $message = Mage::helper("hipay")->__('Refund accepted by Hipay.');
323
+
324
+ $order->addStatusToHistory($order->getStatus(), $message);
325
+
326
+ Mage::getModel('core/resource_transaction')
327
+ ->addObject($creditmemo)->addObject($creditmemo->getOrder())
328
+ ->save();
329
+
330
+ }
331
+ }
332
+ }
333
+ elseif($order->canCreditmemo())
334
+ {
335
+ $service = Mage::getModel('sales/service_order', $order);
336
+ $creditmemo = $service->prepareInvoiceCreditmemo($order->getInvoiceCollection()->getFirstItem());
337
+ foreach ($creditmemo->getAllItems() as $creditmemoItem) {
338
+ $creditmemoItem->setBackToStock(Mage::helper('cataloginventory')->isAutoReturnEnabled());
339
+ }
340
+ $creditmemo->setOfflineRequested(true);
341
+ $transactionSave = Mage::getModel('core/resource_transaction')
342
+ ->addObject($creditmemo)
343
+ ->addObject($creditmemo->getOrder());
344
+ if ($creditmemo->getInvoice()) {
345
+ $transactionSave->addObject($creditmemo->getInvoice());
346
+ }
347
+ $transactionSave->save();
348
+ }
349
+
350
+ break;
351
+ }
352
+
353
+
354
+ if(in_array($gatewayResponse->getPaymentProduct(), array('visa','american-express','mastercard','cb'))
355
+ && ((int)$gatewayResponse->getEci() == 9 || $payment->getAdditionalInformation('create_oneclick'))
356
+ && !$order->isNominal()) //Recurring E-commerce
357
+ {
358
+
359
+ if($customer->getId())
360
+ {
361
+ $this->responseToCustomer($customer,$gatewayResponse);
362
+
363
+ }
364
+ }
365
+ $order->save();
366
+ break;
367
+
368
+ case self::STATE_FORWARDING:
369
+ $this->addTransaction(
370
+ $payment,
371
+ $gatewayResponse->getTransactionReference(),
372
+ $newTransactionType,
373
+ array('is_transaction_closed' => 0),
374
+ array(),
375
+ Mage::helper('hipay')->getTransactionMessage(
376
+ $payment, $requestType, $gatewayResponse->getTransactionReference(), $amount
377
+ )
378
+ );
379
+
380
+ $payment->setIsTransactionPending(1);
381
+ $order->save();
382
+ break;
383
+
384
+ case self::STATE_DECLINED:
385
+
386
+ $reason = $gatewayResponse->getReason();
387
+ $this->addTransaction(
388
+ $payment,
389
+ $gatewayResponse->getTransactionReference(),
390
+ $newTransactionType,
391
+ array('is_transaction_closed' => 0),
392
+ array(
393
+ $this->_realTransactionIdKey => $gatewayResponse->getTransactionReference(),
394
+ $this->_isTransactionFraud => true
395
+ ),
396
+ Mage::helper('hipay')->getTransactionMessage(
397
+ $payment, $requestType, null, $amount,true,"Code: ".$reason['code']." " . Mage::helper('hipay')->__("Reason") . " : ".$reason['message']
398
+ )
399
+ );
400
+
401
+
402
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
403
+ $order->unhold();
404
+ }
405
+
406
+ if (!$status = $this->getConfigData('order_status_payment_refused')) {
407
+ $status = $order->getStatus();
408
+ }
409
+
410
+ if($fraudScreening = $gatewayResponse->getFraudScreening())
411
+ {
412
+
413
+ if(isset($fraudScreening['result']) && $fraudScreening['result'] == 'blocked' )
414
+ {
415
+ $payment->setIsFraudDetected(true);
416
+
417
+ if(defined('Mage_Sales_Model_Order::STATUS_FRAUD'))
418
+ $status = Mage_Sales_Model_Order::STATUS_FRAUD;
419
+
420
+ $order->addStatusToHistory($status, Mage::helper('hipay')->getTransactionMessage(
421
+ $payment, $this->getOperation(), null, $amount,true,$gatewayResponse->getMessage()
422
+ ));
423
+ }
424
+
425
+ }
426
+
427
+
428
+
429
+ if ($status == Mage_Sales_Model_Order::STATE_HOLDED && $order->canHold()) {
430
+ $order->hold();
431
+ } elseif ($status == Mage_Sales_Model_Order::STATE_CANCELED && $order->canCancel()) {
432
+ $order->cancel();
433
+ }
434
+
435
+
436
+ $order->addStatusToHistory($status, Mage::helper('hipay')->getTransactionMessage(
437
+ $payment, $this->getOperation(), null, $amount,true,$gatewayResponse->getMessage()
438
+ ));
439
+
440
+ $order->save();
441
+
442
+ break;
443
+
444
+ case self::STATE_ERROR:
445
+ default:
446
+ Mage::throwException($defaultExceptionMessage);
447
+ break;
448
+
449
+ }
450
+ }
451
+
452
+ /**
453
+ *
454
+ * @param Allopass_Hipay_Model_Api_Response_Gateway $gatewayResponse
455
+ * @param Mage_Sales_Model_Order_Payment $payment
456
+ * @param float $amount
457
+ */
458
+ public function processResponseToRedirect($gatewayResponse,$payment,$amount)
459
+ {
460
+
461
+ $order = $payment->getOrder();
462
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
463
+
464
+ switch ($this->getConfigPaymentAction()) {
465
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
466
+ $requestType = self::OPERATION_AUTHORIZATION;
467
+ $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
468
+ $defaultExceptionMessage = Mage::helper('hipay')->__('Payment authorization error.');
469
+ break;
470
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
471
+ $requestType = self::OPERATION_SALE;
472
+ $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
473
+ $defaultExceptionMessage = Mage::helper('hipay')->__('Payment capturing error.');
474
+ break;
475
+ }
476
+
477
+ switch ($gatewayResponse->getState())
478
+ {
479
+ case self::STATE_COMPLETED:
480
+ return Mage::getUrl('checkout/onepage/success');
481
+
482
+ case self::STATE_FORWARDING:
483
+ $payment->setIsTransactionPending(1);
484
+ $order->save();
485
+ return $gatewayResponse->getForwardUrl();
486
+
487
+ case self::STATE_PENDING:
488
+ if($this->getConfigData('re_add_to_cart'))
489
+ $this->getHelper()->reAddToCart($order->getIncrementId());
490
+
491
+ return Mage::getUrl($this->getConfigData('pending_redirect_page'));
492
+
493
+ case self::STATE_DECLINED:
494
+
495
+ if($this->getConfigData('re_add_to_cart'))
496
+ $this->getHelper()->reAddToCart($order->getIncrementId());
497
+
498
+ return Mage::getUrl('checkout/onepage/failure');
499
+
500
+ case self::STATE_ERROR:
501
+ default:
502
+
503
+ if($this->getConfigData('re_add_to_cart'))
504
+ $this->getHelper()->reAddToCart($order->getIncrementId());
505
+
506
+ $this->_getCheckout()->setErrorMessage($defaultExceptionMessage);
507
+ return Mage::getUrl('checkout/onepage/failure');
508
+
509
+ }
510
+ }
511
+
512
+ /**
513
+ *
514
+ * @return Allopass_Hipay_Helper_Data $helper
515
+ */
516
+ protected function getHelper()
517
+ {
518
+ return Mage::helper('hipay');
519
+ }
520
+
521
+
522
+ /**
523
+ *
524
+ * @param Mage_Customer_Model_Customer $customer
525
+ * @param Allopass_Hipay_Model_Api_Response_Gateway $response
526
+ */
527
+ protected function responseToCustomer($customer,$response)
528
+ {
529
+ $this->getHelper()->responseToCustomer($customer,$response);
530
+ return $this;
531
+ }
532
+
533
+ /**
534
+ *
535
+ * @param Mage_Sales_Model_Order_Payment $payment
536
+ * @param float $amount
537
+ * @return @return Mage_Payment_Model_Abstract
538
+ */
539
+ public function refund(Varien_Object $payment, $amount)
540
+ {
541
+ parent::refund($payment, $amount);
542
+
543
+ $transactionId = $payment->getLastTransId();
544
+
545
+ $gatewayParams = array('operation'=>'refund','amount'=>$amount);
546
+ /* @var $request Allopass_Hipay_Model_Api_Request */
547
+ $request = Mage::getModel('hipay/api_request',array($this));
548
+ $action = Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_MAINTENANCE . $transactionId;
549
+
550
+
551
+ $this->_debug($gatewayParams);
552
+
553
+ $gatewayResponse = $request->gatewayRequest($action,$gatewayParams);
554
+
555
+ $this->_debug($gatewayResponse->debug());
556
+
557
+
558
+ switch ($gatewayResponse->getStatus())
559
+ {
560
+ case "124":
561
+ case "125":
562
+
563
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
564
+ $creditmemo = $payment->getCreditmemo();
565
+ $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN);
566
+
567
+ break;
568
+ default:
569
+ Mage::throwException( $gatewayResponse->getStatus() . " ==> " .$gatewayResponse->getMessage());
570
+ break;
571
+ }
572
+
573
+ return $this;
574
+ }
575
+
576
+ /**
577
+ *
578
+ * @param Mage_Sales_Model_Order_Payment $payment
579
+ * @param float $amount
580
+ * @param string|null $token
581
+ * @return multitype:
582
+ */
583
+ public function getGatewayParams($payment,$amount,$token=null)
584
+ {
585
+
586
+ $params = array();
587
+
588
+ $params['orderid'] = $payment->getOrder()->getIncrementId();
589
+
590
+ $paymentProduct = null;
591
+
592
+ $params['description'] = Mage::helper('hipay')->__("Order %s by %s",$payment->getOrder()->getIncrementId(),$payment->getOrder()->getCustomerEmail());//MANDATORY
593
+ $params['long_description'] = "";// optional
594
+ $params['currency'] = $payment->getOrder()->getOrderCurrencyCode();
595
+ $params['amount'] = $amount;
596
+ $params['shipping'] = $payment->getOrder()->getShippingAmount();
597
+ $params['tax'] = $payment->getOrder()->getTaxAmount();
598
+ $params['cid'] = $payment->getOrder()->getCustomerId();//CUSTOMER ID
599
+ $params['ipaddr'] = $payment->getOrder()->getRemoteIp();
600
+
601
+ $params['http_accept'] = "*/*";
602
+ $params['http_user_agent'] = Mage::helper('core/http')->getHttpUserAgent();
603
+ $params['language'] = Mage::app()->getLocale()->getLocaleCode();//strpos(Mage::app()->getLocale()->getLocaleCode(), "fr") !== false ? "fr_FR" : 'en';
604
+
605
+ /**
606
+ * Parameters specific to the payment product
607
+ */
608
+ if(!is_null($token))
609
+ $params['cardtoken'] = $token;
610
+
611
+ $params['authentication_indicator'] = 0;
612
+
613
+ switch ((int)$this->getConfigData('use_3d_secure')) {
614
+ case 1:
615
+ $params['authentication_indicator'] = 1;
616
+ break;
617
+ case 2:
618
+ /* @var $rule Allopass_Hipay_Model_Rule */
619
+ $rule = Mage::getModel('hipay/rule')->load($this->getConfigData('config_3ds_rules'));
620
+ if($rule->getId())
621
+ $params['authentication_indicator'] = (int)$rule->validate($payment->getOrder());
622
+ break;
623
+ }
624
+
625
+
626
+ /**
627
+ * Electronic Commerce Indicator
628
+ */
629
+ if($payment->getAdditionalInformation('use_oneclick'))
630
+ $params['eci'] = 9; //Recurring E-commerce
631
+
632
+ /**
633
+ * Redirect urls
634
+ */
635
+ $params['accept_url'] = Mage::getUrl($this->getConfigData('accept_url'));
636
+ $params['decline_url'] = Mage::getUrl($this->getConfigData('decline_url'));
637
+ $params['pending_url'] = Mage::getUrl($this->getConfigData('pending_url'));
638
+ $params['exception_url'] = Mage::getUrl($this->getConfigData('exception_url'));
639
+ $params['cancel_url'] = Mage::getUrl($this->getConfigData('cancel_url'));
640
+
641
+ $params = $this->getCustomerParams($payment,$params);
642
+ $params = $this->getShippingParams($payment,$params);
643
+
644
+
645
+ return $params;
646
+ }
647
+
648
+ /**
649
+ *
650
+ * @param Mage_Sales_Model_Order_Payment $payment
651
+ * @param array $params
652
+ * @return array $params
653
+ */
654
+ protected function getCustomerParams($payment,$params=array())
655
+ {
656
+ $order = $payment->getOrder();
657
+ $params['email'] = $order->getCustomerEmail();
658
+ $params['phone'] = $order->getBillingAddress()->getTelephone();
659
+ if(($dob = $order->getCustomerDob()) != "")
660
+ {
661
+ $dob = new Zend_Date($dob);
662
+ $params['birthdate'] = $dob->toString('YYYYMMdd');
663
+ }
664
+
665
+ $gender = $order->getCustomerGender();
666
+
667
+ $customer = Mage::getModel('customer/customer');
668
+ $customer->setData('gender',$gender);
669
+ $attribute = $customer->getResource()->getAttribute('gender');
670
+ if($attribute)
671
+ {
672
+ $gender = $attribute->getFrontend()->getValue($customer);
673
+ $gender = strtoupper(substr($gender, 0,1));
674
+ }
675
+
676
+ if($gender != "M" && $gender != "F")
677
+ $gender = "U";
678
+
679
+
680
+ $params['gender'] =$gender ;
681
+ $params['firstname'] = $order->getCustomerFirstname();
682
+ $params['lastname'] = $order->getCustomerLastname();
683
+ $params['recipientinfo'] = $order->getBillingAddress()->getCompany();
684
+ $params['streetaddress'] = $order->getBillingAddress()->getStreet1();
685
+ $params['streetaddress2'] = $order->getBillingAddress()->getStreet2();
686
+ $params['city'] = $order->getBillingAddress()->getCity();
687
+ //$params['state'] = $order->getBillingAddress(); //TODO checck if country is US or Canada
688
+ $params['zipcode'] = $order->getBillingAddress()->getPostcode();
689
+ $params['country'] = $order->getBillingAddress()->getCountry();
690
+
691
+ return $params;
692
+ }
693
+
694
+ /**
695
+ *
696
+ * @param Mage_Sales_Model_Order_Payment $payment
697
+ * @param array $params
698
+ * @return array $params
699
+ */
700
+ protected function getShippingParams($payment,$params =array())
701
+ {
702
+ if($payment->getOrder()->getIsVirtual())
703
+ return $params;
704
+
705
+ $shippingAddress = $payment->getOrder()->getShippingAddress();
706
+ $params['shipto_firstname'] = $shippingAddress->getFirstname();
707
+ $params['shipto_lastname'] = $shippingAddress->getLastname();
708
+ $params['shipto_recipientinfo'] = $shippingAddress->getCompany();
709
+ $params['shipto_streetaddress'] = $shippingAddress->getStreet1();
710
+ $params['shipto_streetaddress2'] = $shippingAddress->getStreet2();
711
+ $params['shipto_city'] = $shippingAddress->getCity();
712
+ //$params['shipto_state'] = $shippingAddress; //TODO check if country is US or Canada
713
+ $params['shipto_zipcode'] = $shippingAddress->getPostcode();
714
+ $params['shipto_country'] = $shippingAddress->getCountry();
715
+
716
+ return $params;
717
+ }
718
+
719
+ /**
720
+ * Return true if there are authorized transactions
721
+ *
722
+ * @param Mage_Sales_Model_Order_Payment $payment
723
+ * @return bool
724
+ */
725
+ static function isPreauthorizeCapture($payment)
726
+ {
727
+ $lastTransaction = $payment->getTransaction($payment->getLastTransId());
728
+ if (!$lastTransaction
729
+ || $lastTransaction->getTxnType() != Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH
730
+ ) {
731
+ return false;
732
+ }
733
+
734
+ return true;
735
+ }
736
+
737
+ /**
738
+ *
739
+ * @param Mage_Sales_Model_Order_Payment $payment
740
+ * @param float $amount
741
+ */
742
+ protected function _preauthorizeCapture($payment,$amount)
743
+ {
744
+ $transactionId = $payment->getLastTransId();
745
+
746
+ $gatewayParams = array('operation'=>'capture','amount'=>$amount);
747
+ $this->_debug($gatewayParams);
748
+ /* @var $request Allopass_Hipay_Model_Api_Request */
749
+ $request = Mage::getModel('hipay/api_request',array($this));
750
+ $uri = Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_MAINTENANCE . $transactionId;
751
+
752
+ $gatewayResponse = $request->gatewayRequest($uri,$gatewayParams);
753
+
754
+ $this->_debug($gatewayResponse->debug());
755
+
756
+ switch ($gatewayResponse->getStatus())
757
+ {
758
+ case "117": //Capture requested
759
+ case "118": //Capture
760
+ case "119": //Partially Capture
761
+ $this->addTransaction(
762
+ $payment,
763
+ $gatewayResponse->getTransactionReference(),
764
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
765
+ array('is_transaction_closed' => 0),
766
+ array(),
767
+ Mage::helper('hipay')->getTransactionMessage(
768
+ $payment, self::OPERATION_MAINTENANCE_CAPTURE, $gatewayResponse->getTransactionReference(), $amount
769
+ )
770
+ );
771
+
772
+ $payment->setIsTransactionPending(true);
773
+ break;
774
+ default:
775
+ Mage::throwException( $gatewayResponse->getStatus() . " ==> " .$gatewayResponse->getMessage());
776
+ break;
777
+ }
778
+
779
+ return $this;
780
+ }
781
+
782
+
783
+ /**
784
+ * Add payment transaction
785
+ *
786
+ * @param Mage_Sales_Model_Order_Payment $payment
787
+ * @param string $transactionId
788
+ * @param string $transactionType
789
+ * @param array $transactionDetails
790
+ * @param array $transactionAdditionalInfo
791
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
792
+ */
793
+ public function addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType,
794
+ array $transactionDetails = array(), array $transactionAdditionalInfo = array(), $message = false
795
+ ) {
796
+ $payment->setTransactionId($transactionId);
797
+ if(method_exists($payment, "resetTransactionAdditionalInfo"))
798
+ $payment->resetTransactionAdditionalInfo();
799
+ foreach ($transactionDetails as $key => $value) {
800
+ $payment->setData($key, $value);
801
+ }
802
+ foreach ($transactionAdditionalInfo as $key => $value) {
803
+ $payment->setTransactionAdditionalInfo($key, $value);
804
+ }
805
+
806
+ if(!class_exists("Mage_Sales_Model_Order_Payment_Transaction"))
807
+ return null;
808
+
809
+ if(method_exists($payment, "addTransaction"))
810
+ $transaction = $payment->addTransaction($transactionType, null, false , $message);
811
+ else
812
+ $transaction = $this->_addTransaction($payment, $transactionType,null,false);
813
+
814
+ /**
815
+ * It for self using
816
+ */
817
+ $transaction->setMessage($message);
818
+
819
+ return $transaction;
820
+ }
821
+
822
+ /**
823
+ * Create transaction, prepare its insertion into hierarchy and add its information to payment and comments
824
+ *
825
+ * To add transactions and related information, the following information should be set to payment before processing:
826
+ * - transaction_id
827
+ * - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
828
+ * - parent_transaction_id (optional)
829
+ * - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
830
+ *
831
+ * If the sales document is specified, it will be linked to the transaction as related for future usage.
832
+ * Currently transaction ID is set into the sales object
833
+ * This method writes the added transaction ID into last_trans_id field of the payment object
834
+ *
835
+ * To make sure transaction object won't cause trouble before saving, use $failsafe = true
836
+ *
837
+ * @param Mage_Sales_Model_Order_Payment
838
+ * @param string $type
839
+ * @param Mage_Sales_Model_Abstract $salesDocument
840
+ * @param bool $failsafe
841
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
842
+ */
843
+ protected function _addTransaction($payment,$type, $salesDocument = null, $failsafe = false)
844
+ {
845
+ // look for set transaction ids
846
+ $transactionId = $payment->getTransactionId();
847
+ if (null !== $transactionId) {
848
+ // set transaction parameters
849
+ /*$transaction = Mage::getModel('sales/order_payment_transaction')
850
+ ->setOrderPaymentObject($payment)
851
+ ->setTxnType($type)
852
+ ->setTxnId($transactionId)
853
+ ->isFailsafe($failsafe)
854
+ ;*/
855
+
856
+ // set transaction parameters
857
+ //$transaction = false;
858
+ $transaction = $this->_lookupTransaction($payment,$transactionId);
859
+
860
+ if (!$transaction) {
861
+ $transaction = Mage::getModel('sales/order_payment_transaction')->setTxnId($transactionId);
862
+ }
863
+
864
+ $transaction
865
+ ->setOrderPaymentObject($payment)
866
+ ->setTxnType($type)
867
+ ->isFailsafe($failsafe);
868
+
869
+ if ($payment->hasIsTransactionClosed()) {
870
+ $transaction->setIsClosed((int)$payment->getIsTransactionClosed());
871
+ }
872
+
873
+ //set transaction addition information
874
+ /*if ($payment->_transactionAdditionalInfo) {
875
+ foreach ($payment->_transactionAdditionalInfo as $key => $value) {
876
+ $transaction->setAdditionalInformation($key, $value);
877
+ }
878
+ }*/
879
+
880
+ // link with sales entities
881
+ $payment->setLastTransId($transactionId);
882
+ $payment->setCreatedTransaction($transaction);
883
+ $payment->getOrder()->addRelatedObject($transaction);
884
+ if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
885
+ $salesDocument->setTransactionId($transactionId);
886
+ // TODO: linking transaction with the sales document
887
+ }
888
+
889
+ // link with parent transaction Not used because transaction Id is the same
890
+ $parentTransactionId = $payment->getParentTransactionId();
891
+
892
+ if ($parentTransactionId) {
893
+ $transaction->setParentTxnId($parentTransactionId);
894
+ if ($payment->getShouldCloseParentTransaction()) {
895
+ $parentTransaction = $this->_lookupTransaction($payment,$parentTransactionId);//
896
+ if ($parentTransaction) {
897
+ $parentTransaction->isFailsafe($failsafe)->close(false);
898
+ $payment->getOrder()->addRelatedObject($parentTransaction);
899
+ }
900
+ }
901
+ }
902
+ return $transaction;
903
+ }
904
+ }
905
+
906
+ /**
907
+ * Find one transaction by ID or type
908
+ * @param Mage_Sales_Model_Order_Payment
909
+ * @param string $txnId
910
+ * @param string $txnType
911
+ * @return Mage_Sales_Model_Order_Payment_Transaction|false
912
+ */
913
+ protected function _lookupTransaction($payment,$txnId, $txnType = false)
914
+ {
915
+ $_transactionsLookup = array();
916
+ if (!$txnId) {
917
+ if ($txnType && $payment->getId()) {
918
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
919
+ ->addPaymentIdFilter($payment->getId())
920
+ ->addTxnTypeFilter($txnType);
921
+ foreach ($collection as $txn) {
922
+ $txn->setOrderPaymentObject($payment);
923
+ $_transactionsLookup[$txn->getTxnId()] = $txn;
924
+ return $txn;
925
+ }
926
+ }
927
+ return false;
928
+ }
929
+ if (isset($_transactionsLookup[$txnId])) {
930
+ return $_transactionsLookup[$txnId];
931
+ }
932
+ $txn = Mage::getModel('sales/order_payment_transaction')
933
+ ->setOrderPaymentObject($payment)
934
+ ->loadByTxnId($txnId);
935
+ if ($txn->getId()) {
936
+ $_transactionsLookup[$txnId] = $txn;
937
+ } else {
938
+ $_transactionsLookup[$txnId] = false;
939
+ }
940
+ return $_transactionsLookup[$txnId];
941
+ }
942
+
943
+ /**
944
+ * Check method for processing with base currency
945
+ *
946
+ * @param string $currencyCode
947
+ * @return boolean
948
+ */
949
+ public function canUseForCurrency($currencyCode)
950
+ {
951
+ /* if (!in_array($currencyCode, $this->_allowCurrencyCode)) {
952
+ return false;
953
+ }*/
954
+ return true;
955
+ }
956
+
957
+
958
+ /**
959
+ *
960
+ * @return Mage_Checkout_Model_Session $checkout
961
+ */
962
+ protected function _getCheckout()
963
+ {
964
+ return Mage::getSingleton('checkout/session');
965
+ }
966
+
967
+ /**
968
+ * Log debug data to file
969
+ *
970
+ * @param mixed $debugData
971
+ */
972
+ protected function _debug($debugData)
973
+ {
974
+ if ($this->getDebugFlag()) {
975
+ Mage::getModel('hipay/log_adapter', 'payment_' . $this->getCode() . '.log')
976
+ ->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
977
+ ->log($debugData);
978
+ }
979
+ }
980
+
981
+ /**
982
+ * Define if debugging is enabled
983
+ *
984
+ * @return bool
985
+ */
986
+ public function getDebugFlag()
987
+ {
988
+ return $this->getConfigData('debug');
989
+ }
990
+
991
+ /**
992
+ * Used to call debug method from not Payment Method context
993
+ *
994
+ * @param mixed $debugData
995
+ */
996
+ public function debugData($debugData)
997
+ {
998
+ $this->_debug($debugData);
999
+ }
1000
+
1001
+
1002
+
1003
+ }
app/code/community/Allopass/Hipay/Model/Method/Cbc.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Cbc extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_cbc';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Cc.php ADDED
@@ -0,0 +1,517 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Cc extends Allopass_Hipay_Model_Method_Abstract
3
+ {
4
+
5
+ const STATUS_PENDING_CAPTURE = 'pending_capture';
6
+
7
+ protected $_code = 'hipay_cc';
8
+
9
+ protected $_formBlockType = 'hipay/form_cc';
10
+ protected $_infoBlockType = 'hipay/info_cc';
11
+
12
+
13
+ /**
14
+ * Assign data to info model instance
15
+ *
16
+ * @param mixed $data
17
+ * @return Mage_Payment_Model_Info
18
+ */
19
+ public function assignData($data)
20
+ {
21
+ if (!($data instanceof Varien_Object)) {
22
+ $data = new Varien_Object($data);
23
+ }
24
+ $info = $this->getInfoInstance();
25
+ $info->setCcType($data->getCcType())
26
+ ->setCcOwner($data->getCcOwner())
27
+ ->setCcLast4(substr($data->getCcNumber(), -4))
28
+ ->setCcNumber($data->getCcNumber())
29
+ ->setCcCid($data->getCcCid())
30
+ ->setCcExpMonth($data->getCcExpMonth())
31
+ ->setCcExpYear($data->getCcExpYear())
32
+ ->setCcSsIssue($data->getCcSsIssue())
33
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
34
+ ->setCcSsStartYear($data->getCcSsStartYear())
35
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
36
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
37
+ ;
38
+
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Prepare info instance for save
44
+ *
45
+ * @return Mage_Payment_Model_Abstract
46
+ */
47
+ public function prepareSave()
48
+ {
49
+ $info = $this->getInfoInstance();
50
+ if ($this->_canSaveCc) {
51
+ $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
52
+ }
53
+ //$info->setCcCidEnc($info->encrypt($info->getCcCid()));
54
+ $info->setCcNumber(null)
55
+ ->setCcCid(null);
56
+ return $this;
57
+ }
58
+
59
+
60
+ /**
61
+ * Retrieve payment iformation model object
62
+ *
63
+ * @return Mage_Payment_Model_Info
64
+ */
65
+ public function getInfoInstance()
66
+ {
67
+ $instance = $this->getData('info_instance');
68
+ if (!($instance instanceof Mage_Payment_Model_Info)) {
69
+ Mage::throwException(Mage::helper('payment')->__('Cannot retrieve the payment information object instance.'));
70
+ }
71
+ return $instance;
72
+ }
73
+
74
+
75
+ protected function getVaultParams($payment)
76
+ {
77
+ $params = array();
78
+ $params['card_number'] = $payment->getCcNumber();
79
+ $params['card_expiry_month'] = ($payment->getCcExpMonth() < 10) ? '0'.$payment->getCcExpMonth() : $payment->getCcExpMonth();
80
+ $params['card_expiry_year'] = $payment->getCcExpYear();
81
+ $params['cvc'] = $payment->getCcCid();
82
+ $params['multi_use'] = 1;
83
+
84
+ $this->_debug($params);
85
+
86
+ return $params;
87
+ }
88
+
89
+
90
+ public function getOrderPlaceRedirectUrl()
91
+ {
92
+
93
+ return Mage::getUrl('hipay/cc/sendRequest',array('_secure' => true));
94
+
95
+ }
96
+
97
+
98
+ public function initialize($paymentAction, $stateObject)
99
+ {
100
+ /* @var $payment Mage_Sales_Model_Order_Payment */
101
+ $payment = $this->getInfoInstance();
102
+ $order = $payment->getOrder();
103
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
104
+
105
+
106
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
107
+ {
108
+ $token = $customer->getHipayAliasOneclick();
109
+ }
110
+ else
111
+ {
112
+ $request = Mage::getModel('hipay/api_request',array($this));
113
+ /* @var $request Allopass_Hipay_Model_Api_Request */
114
+ $vaultResponse = $request->vaultRequest(Allopass_Hipay_Model_Api_Request::VAULT_ACTION_CREATE, $this->getVaultParams($payment));
115
+ $this->_debug($vaultResponse->debug());
116
+ $token = $vaultResponse->getToken();
117
+ }
118
+ $payment->setAdditionalInformation('token',$token);
119
+
120
+ return $this;
121
+
122
+ }
123
+
124
+
125
+ /**
126
+ * (non-PHPdoc)
127
+ * @see Mage_Payment_Model_Method_Abstract::capture()
128
+ */
129
+ public function capture(Varien_Object $payment, $amount)
130
+ {
131
+ parent::capture($payment, $amount);
132
+
133
+ if (self::isPreauthorizeCapture($payment))
134
+ $this->_preauthorizeCapture($payment, $amount);
135
+
136
+ $payment->setSkipTransactionCreation(true);
137
+ return $this;
138
+ }
139
+
140
+
141
+
142
+
143
+ public function place($payment, $amount)
144
+ {
145
+
146
+ $order = $payment->getOrder();
147
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
148
+
149
+ $request = Mage::getModel('hipay/api_request',array($this));
150
+
151
+
152
+ $payment->setAmount($amount);
153
+
154
+ $token = $payment->getAdditionalInformation('token');
155
+ $gatewayParams = $this->getGatewayParams($payment, $amount,$token);
156
+
157
+ $gatewayParams['operation'] =$this->getOperation();
158
+
159
+ $paymentProduct = null;
160
+ if($payment->getAdditionalInformation('use_oneclick'))
161
+ $paymentProduct = Mage::getSingleton('customer/session')->getCustomer()->getHipayCcType();
162
+ else
163
+ $paymentProduct = $this->getCcTypeHipay($payment->getCcType());
164
+
165
+ $gatewayParams['payment_product'] = $paymentProduct ;
166
+ $this->_debug($gatewayParams);
167
+
168
+
169
+ $gatewayResponse = $request->gatewayRequest(Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_ORDER,$gatewayParams);
170
+
171
+ $this->_debug($gatewayResponse->debug());
172
+
173
+ $redirectUrl = $this->processResponseToRedirect($gatewayResponse, $payment, $amount);
174
+
175
+ return $redirectUrl;
176
+
177
+ }
178
+
179
+ protected function getCcTypeHipay($ccTypeMagento)
180
+ {
181
+ $ccTypes = Mage::getSingleton('hipay/config')->getCcTypesHipay();
182
+
183
+ if(isset($ccTypes[$ccTypeMagento]))
184
+ return $ccTypes[$ccTypeMagento];
185
+
186
+ Mage::throwException(Mage::helper('hipay')->__("Code Credit Card Type Hipay not found!"));
187
+ }
188
+
189
+
190
+
191
+ /**
192
+ * Validate payment method information object
193
+ *
194
+ * @param Mage_Payment_Model_Info $info
195
+ * @return Mage_Payment_Model_Abstract
196
+ */
197
+ public function validate()
198
+ {
199
+ /*
200
+ * calling parent validate function
201
+ */
202
+ parent::validate();
203
+
204
+ $info = $this->getInfoInstance();
205
+
206
+ if($info->getAdditionalInformation('use_oneclick'))
207
+ {
208
+ return $this;
209
+ }
210
+
211
+ $errorMsg = false;
212
+ $availableTypes = explode(',',$this->getConfigData('cctypes'));
213
+
214
+ $ccNumber = $info->getCcNumber();
215
+
216
+ // remove credit card number delimiters such as "-" and space
217
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
218
+ $info->setCcNumber($ccNumber);
219
+
220
+ $ccType = '';
221
+
222
+ if (in_array($info->getCcType(), $availableTypes)){
223
+ if ($this->validateCcNum($ccNumber)
224
+ // Other credit card type number validation
225
+ || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
226
+
227
+ $ccType = 'OT';
228
+ $ccTypeRegExpList = array(
229
+ //Solo, Switch or Maestro. International safe
230
+ /*
231
+ // Maestro / Solo
232
+ 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})'
233
+ . '|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})'
234
+ . '|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/',
235
+ */
236
+ // Solo only
237
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
238
+ //Bancontact / mister cash
239
+ 'BCMC' => '/^[0-9]{17}$/',
240
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)'
241
+ . '|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)'
242
+ . '|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))'
243
+ . '|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))'
244
+ . '|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
245
+ // Visa
246
+ 'VI' => '/^4[0-9]{12}([0-9]{3})?$/',
247
+ // Master Card
248
+ 'MC' => '/^5[1-5][0-9]{14}$/',
249
+ // American Express
250
+ 'AE' => '/^3[47][0-9]{13}$/',
251
+ // Discovery
252
+ 'DI' => '/^6011[0-9]{12}$/',
253
+ // JCB
254
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/',
255
+ );
256
+
257
+ foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
258
+ if (preg_match($ccTypeRegExp, $ccNumber)) {
259
+ $ccType = $ccTypeMatch;
260
+ break;
261
+ }
262
+ }
263
+ if (!$this->OtherCcType($info->getCcType()) && $ccType!=$info->getCcType()) {
264
+ $errorMsg = Mage::helper('payment')->__('Credit card number mismatch with credit card type.');
265
+ }
266
+ }
267
+ else {
268
+ $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
269
+ }
270
+
271
+ }
272
+ else {
273
+ $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
274
+ }
275
+
276
+ //validate credit card verification number
277
+ if ($errorMsg === false && $this->hasVerification() && $info->getCcType() != 'BCMC') {
278
+ $verifcationRegEx = $this->getVerificationRegEx();
279
+ $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
280
+ if (!$info->getCcCid() || !$regExp || !preg_match($regExp ,$info->getCcCid())){
281
+ $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
282
+ }
283
+ }
284
+
285
+ if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
286
+ $errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
287
+ }
288
+
289
+ if($errorMsg){
290
+ Mage::throwException($errorMsg);
291
+ }
292
+
293
+ //This must be after all validation conditions
294
+ if ($this->getIsCentinelValidationEnabled()) {
295
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
296
+ }
297
+
298
+ return $this;
299
+ }
300
+
301
+ public function hasVerification()
302
+ {
303
+ $configData = $this->getConfigData('useccv');
304
+ if(is_null($configData)){
305
+ return true;
306
+ }
307
+ return (bool) $configData;
308
+ }
309
+
310
+ public function getVerificationRegEx()
311
+ {
312
+ $verificationExpList = array(
313
+ 'VI' => '/^[0-9]{3}$/', // Visa
314
+ 'MC' => '/^[0-9]{3}$/', // Master Card
315
+ 'AE' => '/^[0-9]{4}$/', // American Express
316
+ 'DI' => '/^[0-9]{3}$/', // Discovery
317
+ 'SS' => '/^[0-9]{3,4}$/',
318
+ 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
319
+ 'SO' => '/^[0-9]{3,4}$/', // Solo
320
+ 'OT' => '/^[0-9]{3,4}$/',
321
+ 'JCB' => '/^[0-9]{3,4}$/' //JCB
322
+ );
323
+ return $verificationExpList;
324
+ }
325
+
326
+ protected function _validateExpDate($expYear, $expMonth)
327
+ {
328
+ $date = Mage::app()->getLocale()->date();
329
+ if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
330
+ || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
331
+ ) {
332
+ return false;
333
+ }
334
+ return true;
335
+ }
336
+
337
+ public function OtherCcType($type)
338
+ {
339
+ return $type=='OT';
340
+ }
341
+
342
+ /**
343
+ * Validate credit card number
344
+ *
345
+ * @param string $cc_number
346
+ * @return bool
347
+ */
348
+ public function validateCcNum($ccNumber)
349
+ {
350
+ $cardNumber = strrev($ccNumber);
351
+ $numSum = 0;
352
+
353
+ for ($i=0; $i<strlen($cardNumber); $i++) {
354
+ $currentNum = substr($cardNumber, $i, 1);
355
+
356
+ /**
357
+ * Double every second digit
358
+ */
359
+ if ($i % 2 == 1) {
360
+ $currentNum *= 2;
361
+ }
362
+
363
+ /**
364
+ * Add digits of 2-digit numbers together
365
+ */
366
+ if ($currentNum > 9) {
367
+ $firstNum = $currentNum % 10;
368
+ $secondNum = ($currentNum - $firstNum) / 10;
369
+ $currentNum = $firstNum + $secondNum;
370
+ }
371
+
372
+ $numSum += $currentNum;
373
+ }
374
+
375
+ /**
376
+ * If the total has no remainder it's OK
377
+ */
378
+ return ($numSum % 10 == 0);
379
+ }
380
+
381
+ /**
382
+ * Other credit cart type number validation
383
+ *
384
+ * @param string $ccNumber
385
+ * @return boolean
386
+ */
387
+ public function validateCcNumOther($ccNumber)
388
+ {
389
+ return preg_match('/^\\d+$/', $ccNumber);
390
+ }
391
+
392
+ /**
393
+ * Check whether there are CC types set in configuration
394
+ *
395
+ * @param Mage_Sales_Model_Quote|null $quote
396
+ * @return bool
397
+ */
398
+ public function isAvailable($quote = null)
399
+ {
400
+ return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
401
+ && parent::isAvailable($quote);
402
+ }
403
+
404
+ /**
405
+ * Whether centinel service is enabled
406
+ *
407
+ * @return bool
408
+ */
409
+ public function getIsCentinelValidationEnabled()
410
+ {
411
+ return false !== Mage::getConfig()->getNode('modules/Mage_Centinel') && 1 == $this->getConfigData('centinel');
412
+ }
413
+
414
+ /**
415
+ * Instantiate centinel validator model
416
+ *
417
+ * @return Mage_Centinel_Model_Service
418
+ */
419
+ public function getCentinelValidator()
420
+ {
421
+ $validator = Mage::getSingleton('centinel/service');
422
+ $validator
423
+ ->setIsModeStrict($this->getConfigData('centinel_is_mode_strict'))
424
+ ->setCustomApiEndpointUrl($this->getConfigData('centinel_api_url'))
425
+ ->setStore($this->getStore())
426
+ ->setIsPlaceOrder($this->_isPlaceOrder());
427
+ return $validator;
428
+ }
429
+
430
+ /**
431
+ * Return data for Centinel validation
432
+ *
433
+ * @return Varien_Object
434
+ */
435
+ public function getCentinelValidationData()
436
+ {
437
+ $info = $this->getInfoInstance();
438
+ $params = new Varien_Object();
439
+ $params
440
+ ->setPaymentMethodCode($this->getCode())
441
+ ->setCardType($info->getCcType())
442
+ ->setCardNumber($info->getCcNumber())
443
+ ->setCardExpMonth($info->getCcExpMonth())
444
+ ->setCardExpYear($info->getCcExpYear())
445
+ ->setAmount($this->_getAmount())
446
+ ->setCurrencyCode($this->_getCurrencyCode())
447
+ ->setOrderNumber($this->_getOrderId());
448
+ return $params;
449
+ }
450
+
451
+ /**
452
+ * Order increment ID getter (either real from order or a reserved from quote)
453
+ *
454
+ * @return string
455
+ */
456
+ private function _getOrderId()
457
+ {
458
+ $info = $this->getInfoInstance();
459
+
460
+ if ($this->_isPlaceOrder()) {
461
+ return $info->getOrder()->getIncrementId();
462
+ } else {
463
+ if (!$info->getQuote()->getReservedOrderId()) {
464
+ $info->getQuote()->reserveOrderId();
465
+ }
466
+ return $info->getQuote()->getReservedOrderId();
467
+ }
468
+ }
469
+
470
+ /**
471
+ * Grand total getter
472
+ *
473
+ * @return string
474
+ */
475
+ private function _getAmount()
476
+ {
477
+ $info = $this->getInfoInstance();
478
+ if ($this->_isPlaceOrder()) {
479
+ return (double)$info->getOrder()->getQuoteBaseGrandTotal();
480
+ } else {
481
+ return (double)$info->getQuote()->getBaseGrandTotal();
482
+ }
483
+ }
484
+
485
+ /**
486
+ * Currency code getter
487
+ *
488
+ * @return string
489
+ */
490
+ private function _getCurrencyCode()
491
+ {
492
+ $info = $this->getInfoInstance();
493
+
494
+ if ($this->_isPlaceOrder()) {
495
+ return $info->getOrder()->getBaseCurrencyCode();
496
+ } else {
497
+ return $info->getQuote()->getBaseCurrencyCode();
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Whether current operation is order placement
503
+ *
504
+ * @return bool
505
+ */
506
+ private function _isPlaceOrder()
507
+ {
508
+ $info = $this->getInfoInstance();
509
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
510
+ return false;
511
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
512
+ return true;
513
+ }
514
+ }
515
+
516
+
517
+ }
app/code/community/Allopass/Hipay/Model/Method/Dexia.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Dexia extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_dexia';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Giropay.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Giropay extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_giropay';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Hosted.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Hosted extends Allopass_Hipay_Model_Method_Abstract
3
+ {
4
+
5
+ protected $_code = 'hipay_hosted';
6
+
7
+ protected $_formBlockType = 'hipay/form_hosted';
8
+ protected $_infoBlockType = 'hipay/info_hosted';
9
+
10
+
11
+ public function getOrderPlaceRedirectUrl()
12
+ {
13
+
14
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
15
+ }
16
+
17
+ /**
18
+ * Assign data to info model instance
19
+ *
20
+ * @param mixed $data
21
+ * @return Mage_Payment_Model_Info
22
+ */
23
+ public function assignData($data)
24
+ {
25
+ if (!($data instanceof Varien_Object)) {
26
+ $data = new Varien_Object($data);
27
+ }
28
+ $info = $this->getInfoInstance();
29
+ $info->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+
37
+
38
+ /**
39
+ * (non-PHPdoc)
40
+ * @see Mage_Payment_Model_Method_Abstract::capture()
41
+ */
42
+ public function capture(Varien_Object $payment, $amount)
43
+ {
44
+ parent::capture($payment, $amount);
45
+
46
+ if (self::isPreauthorizeCapture($payment))
47
+ $this->_preauthorizeCapture($payment, $amount);
48
+
49
+ $payment->setSkipTransactionCreation(true);
50
+ return $this;
51
+ }
52
+
53
+
54
+ public function place($payment, $amount)
55
+ {
56
+ $order = $payment->getOrder();
57
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
58
+
59
+ $request = Mage::getModel('hipay/api_request',array($this));
60
+
61
+ $payment->setAmount($amount);
62
+
63
+ $token = null;
64
+ if($payment->getAdditionalInformation('use_oneclick'))
65
+ {
66
+ $token = Mage::getSingleton('customer/session')->getCustomer()->getHipayAliasOneclick();
67
+ }
68
+
69
+ $gatewayParams = $this->getGatewayParams($payment, $amount,$token);
70
+
71
+ if(is_null($token))
72
+ {
73
+
74
+ $gatewayParams['payment_product'] = 'cb' ;
75
+ $gatewayParams['operation'] = $this->getOperation();
76
+ $gatewayParams['css'] = $this->getConfigData('css_url');
77
+ $gatewayParams['template'] = $this->getConfigData('display_iframe') ? 'iframe' : $this->getConfigData('template');
78
+ if ($this->getConfigData('template') == 'basic-js' && $gatewayParams['template'] == 'iframe') $gatewayParams['template'] .= '-js';
79
+ $gatewayParams['display_selector'] = $this->getConfigData('display_selector');
80
+ //$gatewayParams['payment_product_list'] = $this->getConfigData('cctypes');
81
+
82
+ if ($gatewayParams['country'] == 'BE')
83
+ $gatewayParams['payment_product_list'] = $this->getConfigData('cctypes');
84
+ else
85
+ $gatewayParams['payment_product_list'] = str_replace('bcmc', '', $this->getConfigData('cctypes'));
86
+
87
+
88
+ $gatewayParams['payment_product_category_list'] = "credit-card";
89
+
90
+ if(Mage::getStoreConfig('general/store_information/name') != "")
91
+ $gatewayParams['merchant_display_name'] = Mage::getStoreConfig('general/store_information/name');
92
+
93
+ $this->_debug($gatewayParams);
94
+
95
+ $gatewayResponse = $request->gatewayRequest(Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_HOSTED,$gatewayParams);
96
+
97
+ $this->_debug($gatewayResponse->debug());
98
+
99
+ return $gatewayResponse->getForwardUrl();
100
+ }
101
+ else
102
+ {
103
+ $gatewayParams['operation'] = $this->getOperation();
104
+ $gatewayParams['payment_product'] = Mage::getSingleton('customer/session')->getCustomer()->getHipayCcType();
105
+
106
+ $this->_debug($gatewayParams);
107
+
108
+ $gatewayResponse = $request->gatewayRequest(Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_ORDER,$gatewayParams);
109
+
110
+ $this->_debug($gatewayResponse->debug());
111
+
112
+ $redirectUrl = $this->processResponseToRedirect($gatewayResponse, $payment, $amount);
113
+
114
+ return $redirectUrl;
115
+ }
116
+
117
+ }
118
+ }
app/code/community/Allopass/Hipay/Model/Method/Ideal.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Ideal extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_ideal';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Ing.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Ing extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_ing';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Kbc.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Kbc extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_kbc';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Przelewy24.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Przelewy24 extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_przelewy24';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Przelewy24Api.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Przelewy24Api extends Allopass_Hipay_Model_Method_Cc
3
+ {
4
+ protected $_code = 'hipay_przelewy24api';
5
+
6
+ protected $_formBlockType = 'hipay/form_hosted';
7
+ protected $_infoBlockType = 'hipay/info_hosted';
8
+
9
+
10
+ public function getOrderPlaceRedirectUrl()
11
+ {
12
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
13
+ }
14
+
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Mage_Payment_Model_Info
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+ $info = $this->getInfoInstance();
28
+ $info->setCcType($this->getConfigData('cctypes'))
29
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function initialize($paymentAction, $stateObject)
37
+ {
38
+ /* @var $payment Mage_Sales_Model_Order_Payment */
39
+ $payment = $this->getInfoInstance();
40
+ $order = $payment->getOrder();
41
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
42
+
43
+
44
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
45
+ {
46
+ $token = $customer->getHipayAliasOneclick();
47
+ $payment->setAdditionalInformation('token',$token);
48
+ }
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ protected function getCcTypeHipay($ccTypeMagento)
56
+ {
57
+ return $ccTypeMagento;
58
+ }
59
+
60
+ /**
61
+ * Validate payment method information object
62
+ *
63
+ * @param Mage_Payment_Model_Info $info
64
+ * @return Mage_Payment_Model_Abstract
65
+ */
66
+ public function validate()
67
+ {
68
+ /**
69
+ * to validate payment method is allowed for billing country or not
70
+ */
71
+ $paymentInfo = $this->getInfoInstance();
72
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
73
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
74
+ } else {
75
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
76
+ }
77
+ if (!$this->canUseForCountry($billingCountry)) {
78
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ }
app/code/community/Allopass/Hipay/Model/Method/Qiwi.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Qiwi extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_qiwi';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/Sisal.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Sisal extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_sisal';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/SisalApi.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_SisalApi extends Allopass_Hipay_Model_Method_Cc
3
+ {
4
+ protected $_code = 'hipay_sisalapi';
5
+
6
+ protected $_formBlockType = 'hipay/form_hosted';
7
+ protected $_infoBlockType = 'hipay/info_hosted';
8
+
9
+
10
+ public function getOrderPlaceRedirectUrl()
11
+ {
12
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
13
+ }
14
+
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Mage_Payment_Model_Info
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+ $info = $this->getInfoInstance();
28
+ $info->setCcType($this->getConfigData('cctypes'))
29
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function initialize($paymentAction, $stateObject)
37
+ {
38
+ /* @var $payment Mage_Sales_Model_Order_Payment */
39
+ $payment = $this->getInfoInstance();
40
+ $order = $payment->getOrder();
41
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
42
+
43
+
44
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
45
+ {
46
+ $token = $customer->getHipayAliasOneclick();
47
+ $payment->setAdditionalInformation('token',$token);
48
+ }
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ protected function getCcTypeHipay($ccTypeMagento)
56
+ {
57
+ return $ccTypeMagento;
58
+ }
59
+
60
+ /**
61
+ * Validate payment method information object
62
+ *
63
+ * @param Mage_Payment_Model_Info $info
64
+ * @return Mage_Payment_Model_Abstract
65
+ */
66
+ public function validate()
67
+ {
68
+ /**
69
+ * to validate payment method is allowed for billing country or not
70
+ */
71
+ $paymentInfo = $this->getInfoInstance();
72
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
73
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
74
+ } else {
75
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
76
+ }
77
+ if (!$this->canUseForCountry($billingCountry)) {
78
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ }
app/code/community/Allopass/Hipay/Model/Method/Sofort.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Sofort extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_sofort';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/SofortApi.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_SofortApi extends Allopass_Hipay_Model_Method_Cc
3
+ {
4
+ protected $_code = 'hipay_sofortapi';
5
+
6
+ protected $_formBlockType = 'hipay/form_hosted';
7
+ protected $_infoBlockType = 'hipay/info_hosted';
8
+
9
+
10
+ public function getOrderPlaceRedirectUrl()
11
+ {
12
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
13
+ }
14
+
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Mage_Payment_Model_Info
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+ $info = $this->getInfoInstance();
28
+ $info->setCcType($this->getConfigData('cctypes'))
29
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function initialize($paymentAction, $stateObject)
37
+ {
38
+ /* @var $payment Mage_Sales_Model_Order_Payment */
39
+ $payment = $this->getInfoInstance();
40
+ $order = $payment->getOrder();
41
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
42
+
43
+
44
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
45
+ {
46
+ $token = $customer->getHipayAliasOneclick();
47
+ $payment->setAdditionalInformation('token',$token);
48
+ }
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ protected function getCcTypeHipay($ccTypeMagento)
56
+ {
57
+ return $ccTypeMagento;
58
+ }
59
+
60
+ /**
61
+ * Validate payment method information object
62
+ *
63
+ * @param Mage_Payment_Model_Info $info
64
+ * @return Mage_Payment_Model_Abstract
65
+ */
66
+ public function validate()
67
+ {
68
+ /**
69
+ * to validate payment method is allowed for billing country or not
70
+ */
71
+ $paymentInfo = $this->getInfoInstance();
72
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
73
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
74
+ } else {
75
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
76
+ }
77
+ if (!$this->canUseForCountry($billingCountry)) {
78
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ }
app/code/community/Allopass/Hipay/Model/Method/Webmoney.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Webmoney extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_webmoney';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/WebmoneyApi.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_WebmoneyApi extends Allopass_Hipay_Model_Method_Cc
3
+ {
4
+ protected $_code = 'hipay_webmoneyapi';
5
+
6
+ protected $_formBlockType = 'hipay/form_hosted';
7
+ protected $_infoBlockType = 'hipay/info_hosted';
8
+
9
+
10
+ public function getOrderPlaceRedirectUrl()
11
+ {
12
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
13
+ }
14
+
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Mage_Payment_Model_Info
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+ $info = $this->getInfoInstance();
28
+ $info->setCcType($this->getConfigData('cctypes'))
29
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function initialize($paymentAction, $stateObject)
37
+ {
38
+ /* @var $payment Mage_Sales_Model_Order_Payment */
39
+ $payment = $this->getInfoInstance();
40
+ $order = $payment->getOrder();
41
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
42
+
43
+
44
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
45
+ {
46
+ $token = $customer->getHipayAliasOneclick();
47
+ $payment->setAdditionalInformation('token',$token);
48
+ }
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ protected function getCcTypeHipay($ccTypeMagento)
56
+ {
57
+ return $ccTypeMagento;
58
+ }
59
+
60
+ /**
61
+ * Validate payment method information object
62
+ *
63
+ * @param Mage_Payment_Model_Info $info
64
+ * @return Mage_Payment_Model_Abstract
65
+ */
66
+ public function validate()
67
+ {
68
+ /**
69
+ * to validate payment method is allowed for billing country or not
70
+ */
71
+ $paymentInfo = $this->getInfoInstance();
72
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
73
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
74
+ } else {
75
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
76
+ }
77
+ if (!$this->canUseForCountry($billingCountry)) {
78
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ }
app/code/community/Allopass/Hipay/Model/Method/Yandex.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_Yandex extends Allopass_Hipay_Model_Method_Hosted
3
+ {
4
+ protected $_code = 'hipay_yandex';
5
+ }
app/code/community/Allopass/Hipay/Model/Method/YandexApi.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Method_YandexApi extends Allopass_Hipay_Model_Method_Cc
3
+ {
4
+ protected $_code = 'hipay_yandexapi';
5
+
6
+ protected $_formBlockType = 'hipay/form_hosted';
7
+ protected $_infoBlockType = 'hipay/info_hosted';
8
+
9
+
10
+ public function getOrderPlaceRedirectUrl()
11
+ {
12
+ return Mage::getUrl(str_replace("_", "/", $this->getCode()).'/sendRequest',array('_secure' => true));
13
+ }
14
+
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Mage_Payment_Model_Info
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+ $info = $this->getInfoInstance();
28
+ $info->setCcType($this->getConfigData('cctypes'))
29
+ ->setAdditionalInformation('create_oneclick',$data->getOneclick() == "create_oneclick" ? 1 : 0)
30
+ ->setAdditionalInformation('use_oneclick',$data->getOneclick() == "use_oneclick" ? 1 : 0)
31
+ ;
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function initialize($paymentAction, $stateObject)
37
+ {
38
+ /* @var $payment Mage_Sales_Model_Order_Payment */
39
+ $payment = $this->getInfoInstance();
40
+ $order = $payment->getOrder();
41
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
42
+
43
+
44
+ if($payment->getAdditionalInformation('use_oneclick') && $customer->getId())
45
+ {
46
+ $token = $customer->getHipayAliasOneclick();
47
+ $payment->setAdditionalInformation('token',$token);
48
+ }
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ protected function getCcTypeHipay($ccTypeMagento)
56
+ {
57
+ return $ccTypeMagento;
58
+ }
59
+
60
+ /**
61
+ * Validate payment method information object
62
+ *
63
+ * @param Mage_Payment_Model_Info $info
64
+ * @return Mage_Payment_Model_Abstract
65
+ */
66
+ public function validate()
67
+ {
68
+ /**
69
+ * to validate payment method is allowed for billing country or not
70
+ */
71
+ $paymentInfo = $this->getInfoInstance();
72
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
73
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
74
+ } else {
75
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
76
+ }
77
+ if (!$this->canUseForCountry($billingCountry)) {
78
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
79
+ }
80
+ return $this;
81
+ }
82
+
83
+ }
app/code/community/Allopass/Hipay/Model/Observer.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Observer
3
+ {
4
+ /**
5
+ * Cancel orders stayed in pending because customer not validated payment form
6
+ */
7
+ public function cancelOrdersInPending()
8
+ {
9
+
10
+ $methodCodes = array('hipay_cc'=>'hipay/method_cc','hipay_hosted'=>'hipay/method_hosted');
11
+ foreach ($methodCodes as $methodCode=>$model)
12
+ {
13
+ if(!Mage::getStoreConfig('payment/'.$methodCode."/cancel_pending_order"))
14
+ continue;
15
+
16
+ $limitedTime = 30;
17
+
18
+ $date = new Zend_Date();//Mage::app()->getLocale()->date();
19
+
20
+ /* @var $collection Mage_Sales_Model_Resource_Order_Collection */
21
+ $collection = Mage::getResourceModel('sales/order_collection');
22
+ $collection->addFieldToSelect(array('entity_id','state'))
23
+
24
+ ->addAttributeToFilter('created_at', array('to' => ($date->subMinute($limitedTime)->toString('Y-MM-dd HH:mm:ss'))))
25
+ ;
26
+
27
+
28
+ /* @var $order Mage_Sales_Model_Order */
29
+ foreach ($collection as $order)
30
+ {
31
+
32
+ if($order->getPayment()->getMethod() == $methodCode)
33
+ {
34
+ if($order->canCancel() && $order->getState() == Mage_Sales_Model_Order::STATE_NEW)
35
+ {
36
+ try {
37
+ $order->cancel();
38
+ $order
39
+ ->addStatusToHistory($order->getStatus(),
40
+ // keep order status/state
41
+ Mage::helper('hipay')->__("Order canceled automatically by cron because order is pending since %d minutes",$limitedTime));
42
+
43
+ $order->save();
44
+ } catch (Exception $e) {
45
+ Mage::logException($e);
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ return $this;
52
+ }
53
+
54
+ public function manageOrdersInPendingCapture()
55
+ {
56
+ $methods = array('hipay_cc','hipay_hosted');
57
+ /* @var $collection Mage_Sales_Model_Resource_Order_Collection */
58
+ $collection = Mage::getResourceModel('sales/order_collection');
59
+ $collection->addFieldToFilter('status','pending_capture');
60
+
61
+ /* @var $order Mage_Sales_Model_Order */
62
+ foreach ($collection as $order)
63
+ {
64
+ if(!in_array($order->getPayment()->getMethod(), $methods))
65
+ continue;
66
+
67
+ $orderDate = "";
68
+ }
69
+
70
+ }
71
+
72
+ public function displaySectionCheckoutIframe($observer)
73
+ {
74
+ $payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
75
+ if($payment->getAdditionalInformation('use_oneclick'))
76
+ return $this;
77
+ /* @var $controller Mage_Checkout_OnepageController */
78
+ $controller = $observer->getControllerAction();
79
+
80
+ $result = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
81
+
82
+ //TODO check if payment method is hosted and iframe active and is success
83
+ $methodInstance = $payment->getMethodInstance();
84
+ if($result['success']
85
+ && $methodInstance->getCode() == 'hipay_hosted'
86
+ && $methodInstance->getConfigData('display_iframe'))
87
+ {
88
+ $result['iframeUrl'] = $result['redirect'];
89
+ }
90
+
91
+ $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
92
+
93
+ return $this;
94
+
95
+ }
96
+ }
app/code/community/Allopass/Hipay/Model/Resource/Rule.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+ * Hipay Rule resource model
7
+ */
8
+ class Allopass_Hipay_Model_Resource_Rule extends Mage_Rule_Model_Mysql4_Rule
9
+ {
10
+
11
+ /**
12
+ * Initialize main table and table id field
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->_init('hipay/rule', 'rule_id');
17
+ }
18
+
19
+ }
app/code/community/Allopass/Hipay/Model/Resource/Rule/Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Hipay resource collection model
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Resource_Rule_Collection extends Mage_Rule_Model_Mysql4_Rule_Collection
9
+ {
10
+
11
+ /**
12
+ * Set resource model and determine field mapping
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->_init('hipay/rule');
17
+ $this->_map['fields']['rule_id'] = 'main_table.rule_id';
18
+ }
19
+
20
+ }
app/code/community/Allopass/Hipay/Model/Rule.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Rule extends Mage_Rule_Model_Rule
3
+ {
4
+
5
+ /**
6
+ * Init resource model and id field
7
+ */
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('hipay/rule');
12
+ $this->setIdFieldName('rule_id');
13
+ }
14
+
15
+ /**
16
+ * Getter for rule conditions collection
17
+ *
18
+ * @return Mage_CatalogRule_Model_Rule_Condition_Combine
19
+ */
20
+ public function getConditionsInstance()
21
+ {
22
+ return Mage::getModel('hipay/rule_condition_combine')->setPaymentMethodCode($this->getMethodCode());
23
+ }
24
+
25
+ /**
26
+ * Get rule condition product combine model instance
27
+ *
28
+ * @return Mage_SalesRule_Model_Rule_Condition_Product_Combine
29
+ */
30
+ public function getActionsInstance()
31
+ {
32
+ return Mage::getModel('hipay/rule_condition_product_combine');
33
+ }
34
+
35
+ public function getConditions()
36
+ {
37
+ parent::getConditions();
38
+
39
+ $this->_conditions->setPaymentMethodCode($this->getMethodCode());
40
+
41
+ return $this->_conditions;
42
+ }
43
+
44
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Address.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Allopass_Hipay_Model_Rule_Condition_Address extends Mage_Rule_Model_Condition_Abstract
5
+ {
6
+ public function loadAttributeOptions()
7
+ {
8
+ $attributes = array(
9
+ 'base_subtotal' => Mage::helper('sales')->__('Subtotal'),
10
+ 'base_grand_total' => Mage::helper('sales')->__('Grand Total'),
11
+ 'base_currency_code' => Mage::helper('adminhtml')->__('Currency'),
12
+ 'items_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
13
+ 'weight' => Mage::helper('salesrule')->__('Total Weight'),
14
+ 'created_at' => Mage::helper('hipay')->__("Order's time"),
15
+ 'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
16
+ 'billing_postcode' => Mage::helper('hipay')->__('Billing Postcode'),
17
+ 'billing_region' => Mage::helper('hipay')->__('Billing Region'),
18
+ 'billing_region_id' => Mage::helper('hipay')->__('Billing State/Province'),
19
+ 'billing_country_id' => Mage::helper('hipay')->__('Billing Country'),
20
+ );
21
+
22
+ $this->setAttributeOption($attributes);
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function getInputType()
28
+ {
29
+ switch ($this->getAttribute()) {
30
+ case 'base_subtotal': case 'weight': case 'total_qty': case 'base_grandtotal':
31
+ return 'numeric';
32
+ case 'shipping_method': case 'billing_country_id': case 'billing_region_id': case 'base_currency_code':
33
+ return 'select';
34
+ case 'created_at':
35
+ return 'boolean' ;
36
+ }
37
+ return 'string';
38
+ }
39
+
40
+ public function getValueElementType()
41
+ {
42
+ switch ($this->getAttribute()) {
43
+ case 'shipping_method': case 'billing_country_id': case 'billing_region_id': case 'base_currency_code': case 'created_at':
44
+ return 'select';
45
+ }
46
+ return 'text';
47
+ }
48
+
49
+
50
+
51
+
52
+ public function getValueSelectOptions()
53
+ {
54
+ if (!$this->hasData('value_select_options')) {
55
+ switch ($this->getAttribute()) {
56
+ case 'billing_country_id':
57
+ $options = Mage::getModel('adminhtml/system_config_source_country')
58
+ ->toOptionArray();
59
+ break;
60
+
61
+ case 'billing_region_id':
62
+ $options = Mage::getModel('adminhtml/system_config_source_allregion')
63
+ ->toOptionArray();
64
+ break;
65
+
66
+ case 'shipping_method':
67
+ $options = Mage::getModel('adminhtml/system_config_source_shipping_allmethods')
68
+ ->toOptionArray();
69
+ break;
70
+
71
+ case 'base_currency_code':
72
+ $options = Mage::getModel('adminhtml/system_config_source_currency')
73
+ ->toOptionArray(false);
74
+ break;
75
+ case 'created_at':
76
+ $options = array(
77
+ array("value"=>"00::8","label"=>Mage::helper('hipay')->__("Midnight - 8:00 a.m.")),
78
+ array("value"=>"8::15","label"=>Mage::helper('hipay')->__("8:00 a.m. - 3:00 p.m.")),
79
+ array("value"=>"15::20","label"=>Mage::helper('hipay')->__("3:00 pm. - 8:00 p.m.")),
80
+ array("value"=>"20::23","label"=>Mage::helper('hipay')->__("8:00 p.m. - 11:59 p.m.")),
81
+ );
82
+ break;
83
+
84
+ default:
85
+ $options = array();
86
+ }
87
+ $this->setData('value_select_options', $options);
88
+ }
89
+ return $this->getData('value_select_options');
90
+ }
91
+
92
+ /**
93
+ * Validate Address Rule Condition
94
+ *
95
+ * @param Varien_Object $object
96
+ * @return bool
97
+ */
98
+ public function validate(Varien_Object $object)
99
+ {
100
+ $quote = Mage::getModel('sales/quote')->load($object->getQuoteId());
101
+ $address = $quote->getBillingAddress();
102
+
103
+ //Get infos from billing address
104
+ $toValidate = new Varien_Object();
105
+ $toValidate->setBillingPostcode($address->getPostcode());
106
+ $toValidate->setBillingRegion($address->getRegion());
107
+ $toValidate->setBillingRegionId($address->getRegionId());
108
+ $toValidate->setBillingCountryId($address->getCountryId());
109
+
110
+ if(!$quote->isVirtual()){//Get infos from shipping address
111
+ $address = $quote->getShippingAddress();
112
+ }
113
+
114
+ $toValidate->setBaseSubtotal($address->getBaseSubtotal());
115
+ $toValidate->setBaseGrandTotal($address->getBaseGrandTotal());
116
+ $toValidate->setWeight($address->getWeight());
117
+ $toValidate->setShippingMethod($address->getShippingMethod());
118
+
119
+ $toValidate->setTotalQty($quote->getItemsQty());
120
+ $toValidate->setBaseCurrencyCode($quote->getBaseCurrencyCode());
121
+
122
+ $toValidate->setCreatedAt($this->_getFormatCreatedAt($object));
123
+
124
+ return parent::validate($toValidate);
125
+
126
+ }
127
+
128
+ protected function _getFormatCreatedAt($object)
129
+ {
130
+ $created_at = $object->getCreatedAt();
131
+
132
+ if(!$created_at instanceof Zend_Date)
133
+ $created_at = Mage::app()->getLocale()->storeDate($object->getStoreId(),$created_at,true);
134
+
135
+ $hour = (int)$created_at->toString("H");
136
+
137
+ switch (true) {
138
+ case ($hour >= 0 && $hour <= 8):
139
+ return '00::8';
140
+ case ($hour > 8 && $hour <= 15):
141
+ return '8::15';
142
+ case ($hour > 15 && $hour <= 20):
143
+ return '15::20';
144
+ case ($hour > 20 && $hour <= 23):
145
+ return '20::23';
146
+
147
+ }
148
+
149
+ return '';
150
+ }
151
+
152
+ public function getTypeElement()
153
+ {
154
+ return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() .'_'. $this->getPaymentMethodCode() . '__type', 'hidden', array(
155
+ //'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId().'_'. $this->getPaymentMethodCode() . '][type]',
156
+ 'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId() . '][type]',
157
+ 'value' => $this->getType(),
158
+ 'no_span' => true,
159
+ 'class' => 'hidden',
160
+ ));
161
+ }
162
+
163
+ public function getAttributeElement()
164
+ {
165
+ if (is_null($this->getAttribute())) {
166
+ foreach ($this->getAttributeOption() as $k => $v) {
167
+ $this->setAttribute($k);
168
+ break;
169
+ }
170
+ }
171
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__attribute', 'select', array(
172
+ //'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][attribute]',
173
+ 'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'][attribute]',
174
+ 'values'=>$this->getAttributeSelectOptions(),
175
+ 'value'=>$this->getAttribute(),
176
+ 'value_name'=>$this->getAttributeName(),
177
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
178
+ }
179
+
180
+ /**
181
+ * Retrieve Condition Operator element Instance
182
+ * If the operator value is empty - define first available operator value as default
183
+ *
184
+ * @return Varien_Data_Form_Element_Select
185
+ */
186
+ public function getOperatorElement()
187
+ {
188
+ $options = $this->getOperatorSelectOptions();
189
+ if (is_null($this->getOperator())) {
190
+ foreach ($options as $option) {
191
+ $this->setOperator($option['value']);
192
+ break;
193
+ }
194
+ }
195
+
196
+ $elementId = sprintf('%s__%s__operator', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
197
+ //$elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
198
+ $elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId());
199
+ $element = $this->getForm()->addField($elementId, 'select', array(
200
+ 'name' => $elementName,
201
+ 'values' => $options,
202
+ 'value' => $this->getOperator(),
203
+ 'value_name' => $this->getOperatorName(),
204
+ ));
205
+ $element->setRenderer(Mage::getBlockSingleton('rule/editable'));
206
+
207
+ return $element;
208
+ }
209
+
210
+ public function getValueElement()
211
+ {
212
+ $elementParams = array(
213
+ //'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][value]',
214
+ 'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][value]',
215
+ 'value' => $this->getValue(),
216
+ 'values' => $this->getValueSelectOptions(),
217
+ 'value_name' => $this->getValueName(),
218
+ 'after_element_html' => $this->getValueAfterElementHtml(),
219
+ 'explicit_apply' => $this->getExplicitApply(),
220
+ );
221
+ if ($this->getInputType()=='date') {
222
+ // date format intentionally hard-coded
223
+ $elementParams['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
224
+ $elementParams['format'] = Varien_Date::DATE_INTERNAL_FORMAT;
225
+ }
226
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__value',
227
+ $this->getValueElementType(),
228
+ $elementParams
229
+ )->setRenderer($this->getValueElementRenderer());
230
+ }
231
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Combine.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Hipay Rule Combine Condition data model
5
+ */
6
+ class Allopass_Hipay_Model_Rule_Condition_Combine extends Mage_Rule_Model_Condition_Combine
7
+ {
8
+ protected $_paymentMethodCode = null;
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setType('hipay/rule_condition_combine');
14
+ }
15
+
16
+
17
+
18
+ public function getNewChildSelectOptions()
19
+ {
20
+ $addressCondition = Mage::getModel('hipay/rule_condition_address');
21
+ $addressAttributes = $addressCondition->loadAttributeOptions()->getAttributeOption();
22
+ $attributes = array();
23
+ foreach ($addressAttributes as $code=>$label) {
24
+ $attributes[] = array('value'=>'hipay/rule_condition_address|'.$code.'|'.$this->getPaymentMethodCode(), 'label'=>$label);
25
+ }
26
+
27
+ $customerCondition = Mage::getModel('hipay/rule_condition_customer');
28
+ $customerAttributes = $customerCondition->loadAttributeOptions()->getAttributeOption();
29
+ $cAttributes = array();
30
+ foreach ($customerAttributes as $code=>$label) {
31
+ $cAttributes[] = array('value'=>'hipay/rule_condition_customer|'.$code.'|'.$this->getPaymentMethodCode(), 'label'=>$label);
32
+ }
33
+
34
+ $conditions = parent::getNewChildSelectOptions();
35
+ $conditions = array_merge_recursive($conditions, array(
36
+ array('value'=>'hipay/rule_condition_product_found||'.$this->getPaymentMethodCode(), 'label'=>Mage::helper('salesrule')->__('Product attribute combination')),
37
+ array('value'=>'hipay/rule_condition_product_subselect||'.$this->getPaymentMethodCode(), 'label'=>Mage::helper('salesrule')->__('Products subselection')),
38
+ array('value'=>'hipay/rule_condition_combine||'.$this->getPaymentMethodCode(), 'label'=>Mage::helper('salesrule')->__('Conditions combination')),
39
+ array('label'=>Mage::helper('hipay')->__('Order Attribute'), 'value'=>$attributes),
40
+ array('label'=>Mage::helper('hipay')->__('Customer Attribute'), 'value'=>$cAttributes),
41
+ ));
42
+
43
+ $additional = new Varien_Object();
44
+ Mage::dispatchEvent('hipay_rule_condition_combine', array('additional' => $additional));
45
+ if ($additionalConditions = $additional->getConditions()) {
46
+ $conditions = array_merge_recursive($conditions, $additionalConditions);
47
+ }
48
+
49
+ return $conditions;
50
+ }
51
+
52
+ public function getTypeElement()
53
+ {
54
+ return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() .'_'. $this->getPaymentMethodCode() . '__type', 'hidden', array(
55
+ //'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId().'_'. $this->getPaymentMethodCode() . '][type]',
56
+ 'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId() . '][type]',
57
+ 'value' => $this->getType(),
58
+ 'no_span' => true,
59
+ 'class' => 'hidden',
60
+ ));
61
+ }
62
+
63
+ public function getAttributeElement()
64
+ {
65
+ if (is_null($this->getAttribute())) {
66
+ foreach ($this->getAttributeOption() as $k => $v) {
67
+ $this->setAttribute($k);
68
+ break;
69
+ }
70
+ }
71
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__attribute', 'select', array(
72
+ //'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][attribute]',
73
+ 'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'][attribute]',
74
+ 'values'=>$this->getAttributeSelectOptions(),
75
+ 'value'=>$this->getAttribute(),
76
+ 'value_name'=>$this->getAttributeName(),
77
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
78
+ }
79
+
80
+ /**
81
+ * Retrieve Condition Operator element Instance
82
+ * If the operator value is empty - define first available operator value as default
83
+ *
84
+ * @return Varien_Data_Form_Element_Select
85
+ */
86
+ public function getOperatorElement()
87
+ {
88
+ $options = $this->getOperatorSelectOptions();
89
+ if (is_null($this->getOperator())) {
90
+ foreach ($options as $option) {
91
+ $this->setOperator($option['value']);
92
+ break;
93
+ }
94
+ }
95
+
96
+ $elementId = sprintf('%s__%s__operator', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
97
+ //$elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
98
+ $elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId());
99
+ $element = $this->getForm()->addField($elementId, 'select', array(
100
+ 'name' => $elementName,
101
+ 'values' => $options,
102
+ 'value' => $this->getOperator(),
103
+ 'value_name' => $this->getOperatorName(),
104
+ ));
105
+ $element->setRenderer(Mage::getBlockSingleton('rule/editable'));
106
+
107
+ return $element;
108
+ }
109
+
110
+ public function getValueElement()
111
+ {
112
+ $elementParams = array(
113
+ //'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][value]',
114
+ 'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][value]',
115
+ 'value' => $this->getValue(),
116
+ 'values' => $this->getValueSelectOptions(),
117
+ 'value_name' => $this->getValueName(),
118
+ 'after_element_html' => $this->getValueAfterElementHtml(),
119
+ 'explicit_apply' => $this->getExplicitApply(),
120
+ );
121
+ if ($this->getInputType()=='date') {
122
+ // date format intentionally hard-coded
123
+ $elementParams['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
124
+ $elementParams['format'] = Varien_Date::DATE_INTERNAL_FORMAT;
125
+ }
126
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__value',
127
+ $this->getValueElementType(),
128
+ $elementParams
129
+ )->setRenderer($this->getValueElementRenderer());
130
+ }
131
+
132
+ public function getNewChildElement()
133
+ {
134
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__new_child', 'select', array(
135
+ //'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][new_child]',
136
+ 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][new_child]',
137
+ 'values'=>$this->getNewChildSelectOptions(),
138
+ 'value_name'=>$this->getNewChildName(),
139
+ ))->setRenderer(Mage::getBlockSingleton('rule/newchild'));
140
+ }
141
+
142
+ public function getAggregatorElement()
143
+ {
144
+ if (is_null($this->getAggregator())) {
145
+ foreach ($this->getAggregatorOption() as $k=>$v) {
146
+ $this->setAggregator($k);
147
+ break;
148
+ }
149
+ }
150
+
151
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__aggregator', 'select', array(
152
+ // 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][aggregator]',
153
+ 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][aggregator]',
154
+ 'values'=>$this->getAggregatorSelectOptions(),
155
+ 'value'=>$this->getAggregator(),
156
+ 'value_name'=>$this->getAggregatorName(),
157
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
158
+ }
159
+
160
+ public function asHtmlRecursive()
161
+ {
162
+ $html = $this->asHtml().'<ul id="'.$this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__children" class="rule-param-children">';
163
+ foreach ($this->getConditions() as $cond) {
164
+ $cond->setPaymentMethodCode($this->getPaymentMethodCode());
165
+ $html .= '<li>'.$cond->asHtmlRecursive().'</li>';
166
+ }
167
+ $html .= '<li>'.$this->getNewChildElement()->getHtml().'</li></ul>';
168
+ return $html;
169
+ }
170
+
171
+
172
+ public function getPaymentMethodCode()
173
+ {
174
+
175
+ return $this->_paymentMethodCode;
176
+ }
177
+
178
+ public function setPaymentMethodCode($methodCode)
179
+ {
180
+ $this->_paymentMethodCode = $methodCode;
181
+ return $this;
182
+ }
183
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Customer.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Rule_Condition_Customer extends Mage_Rule_Model_Condition_Abstract
3
+ {
4
+ public function loadAttributeOptions()
5
+ {
6
+ $attributes = array(
7
+ 'orders_count' => Mage::helper('hipay')->__('Orders count'),
8
+ 'customer_is_guest' => Mage::helper('sales')->__('Customer is guest'),
9
+ 'diff_addresses' => Mage::helper('hipay')->__('Billing and shipping addresses are differents'),
10
+ );
11
+
12
+ $this->setAttributeOption($attributes);
13
+
14
+ return $this;
15
+ }
16
+
17
+ public function getInputType()
18
+ {
19
+ switch ($this->getAttribute()) {
20
+ case 'orders_count':
21
+ return 'numeric';
22
+ case 'customer_is_guest': case 'diff_addresses':
23
+ return 'boolean';
24
+ }
25
+ return 'string';
26
+ }
27
+
28
+ public function getValueElementType()
29
+ {
30
+ switch ($this->getAttribute()) {
31
+ case 'customer_is_guest': case 'diff_addresses':
32
+ return 'select';
33
+ }
34
+ return 'text';
35
+ }
36
+
37
+ public function getValueSelectOptions()
38
+ {
39
+ if (!$this->hasData('value_select_options')) {
40
+ switch ($this->getAttribute()) {
41
+ case 'customer_is_guest':
42
+ case 'diff_addresses':
43
+ $options = Mage::getModel('adminhtml/system_config_source_yesno')
44
+ ->toOptionArray();
45
+ break;
46
+ default:
47
+ $options = array();
48
+ }
49
+ $this->setData('value_select_options', $options);
50
+ }
51
+ return $this->getData('value_select_options');
52
+ }
53
+
54
+ /**
55
+ * Validate Address Rule Condition
56
+ *
57
+ * @param Varien_Object $object
58
+ * @return bool
59
+ */
60
+ public function validate(Varien_Object $object)
61
+ {
62
+ /* @var $order Mage_Sales_Model_Order */
63
+ $order = $object;
64
+
65
+ //Get infos from billing address
66
+ $toValidate = new Varien_Object();
67
+
68
+ $customer_id = $object->getCustomerId();
69
+ $orders_count = $order->getCollection()->addAttributeToFilter('customer_id',$customer_id)->count();
70
+ $toValidate->setOrdersCount($orders_count);
71
+ $toValidate->setCustomerIsGuest(is_null($order->getCustomerIsGuest()) ? 0 : $order->getCustomerIsGuest());
72
+ $toValidate->setDiffAddresses($this->_addressesesAreDifferent($order));
73
+
74
+ return parent::validate($toValidate);
75
+
76
+ }
77
+
78
+ /**
79
+ * @param Mage_Sales_Model_Order $order
80
+ * @return boolean $isDifferent
81
+ */
82
+ protected function _addressesesAreDifferent($order)
83
+ {
84
+ $isDifferent = false;
85
+ if($order->getIsVirtual())
86
+ return $isDifferent;
87
+
88
+
89
+ $billingAddress = $order->getBillingAddress();
90
+ $shippingAddress = $order->getShippingAddress();
91
+ $methods = array('getStreetFull','getCity','getCountryId','getPostcode','getRegionId');
92
+
93
+ foreach($methods as $method_name)
94
+ {
95
+ $billingValue = call_user_func(array($billingAddress, $method_name));
96
+ $shippingValue = call_user_func(array($shippingAddress,$method_name));
97
+ if($billingValue != $shippingValue)
98
+ {
99
+ $isDifferent = true;
100
+ break;
101
+ }
102
+ }
103
+
104
+ return $isDifferent;
105
+ }
106
+
107
+ public function getTypeElement()
108
+ {
109
+ return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() .'_'. $this->getPaymentMethodCode() . '__type', 'hidden', array(
110
+ //'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId().'_'. $this->getPaymentMethodCode() . '][type]',
111
+ 'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId() . '][type]',
112
+ 'value' => $this->getType(),
113
+ 'no_span' => true,
114
+ 'class' => 'hidden',
115
+ ));
116
+ }
117
+
118
+ public function getAttributeElement()
119
+ {
120
+ if (is_null($this->getAttribute())) {
121
+ foreach ($this->getAttributeOption() as $k => $v) {
122
+ $this->setAttribute($k);
123
+ break;
124
+ }
125
+ }
126
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__attribute', 'select', array(
127
+ //'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][attribute]',
128
+ 'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'][attribute]',
129
+ 'values'=>$this->getAttributeSelectOptions(),
130
+ 'value'=>$this->getAttribute(),
131
+ 'value_name'=>$this->getAttributeName(),
132
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
133
+ }
134
+
135
+ /**
136
+ * Retrieve Condition Operator element Instance
137
+ * If the operator value is empty - define first available operator value as default
138
+ *
139
+ * @return Varien_Data_Form_Element_Select
140
+ */
141
+ public function getOperatorElement()
142
+ {
143
+ $options = $this->getOperatorSelectOptions();
144
+ if (is_null($this->getOperator())) {
145
+ foreach ($options as $option) {
146
+ $this->setOperator($option['value']);
147
+ break;
148
+ }
149
+ }
150
+
151
+ $elementId = sprintf('%s__%s__operator', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
152
+ //$elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
153
+ $elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId());
154
+ $element = $this->getForm()->addField($elementId, 'select', array(
155
+ 'name' => $elementName,
156
+ 'values' => $options,
157
+ 'value' => $this->getOperator(),
158
+ 'value_name' => $this->getOperatorName(),
159
+ ));
160
+ $element->setRenderer(Mage::getBlockSingleton('rule/editable'));
161
+
162
+ return $element;
163
+ }
164
+
165
+ public function getValueElement()
166
+ {
167
+ $elementParams = array(
168
+ //'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][value]',
169
+ 'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][value]',
170
+ 'value' => $this->getValue(),
171
+ 'values' => $this->getValueSelectOptions(),
172
+ 'value_name' => $this->getValueName(),
173
+ 'after_element_html' => $this->getValueAfterElementHtml(),
174
+ 'explicit_apply' => $this->getExplicitApply(),
175
+ );
176
+ if ($this->getInputType()=='date') {
177
+ // date format intentionally hard-coded
178
+ $elementParams['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
179
+ $elementParams['format'] = Varien_Date::DATE_INTERNAL_FORMAT;
180
+ }
181
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__value',
182
+ $this->getValueElementType(),
183
+ $elementParams
184
+ )->setRenderer($this->getValueElementRenderer());
185
+ }
186
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Product.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * 3ds Rule Product Condition data model
5
+ */
6
+ class Allopass_Hipay_Model_Rule_Condition_Product extends Mage_CatalogRule_Model_Rule_Condition_Product
7
+ {
8
+
9
+
10
+ /**
11
+ * Add special attributes
12
+ *
13
+ * @param array $attributes
14
+ */
15
+ protected function _addSpecialAttributes(array &$attributes)
16
+ {
17
+ parent::_addSpecialAttributes($attributes);
18
+ $attributes['order_item_qty'] = Mage::helper('salesrule')->__('Quantity in order');
19
+ $attributes['order_item_price'] = Mage::helper('salesrule')->__('Price in order');
20
+ $attributes['order_item_row_total'] = Mage::helper('salesrule')->__('Row total in order');
21
+ }
22
+
23
+ /**
24
+ * Validate Product Rule Condition
25
+ *
26
+ * @param Varien_Object $object
27
+ *
28
+ * @return bool
29
+ */
30
+ public function validate(Varien_Object $object)
31
+ {
32
+ $product = false;
33
+ if ($object->getProduct() instanceof Mage_Catalog_Model_Product) {
34
+ $product = $object->getProduct();
35
+ } else {
36
+ $product = Mage::getModel('catalog/product')
37
+ ->load($object->getProductId());
38
+ }
39
+
40
+ $product
41
+ ->setOrderItemQty($object->getQtyOrdered())
42
+ ->setOrderItemPrice($object->getPrice()) // possible bug: need to use $object->getBasePrice()
43
+ ->setOrderItemRowTotal($object->getBaseRowTotal());
44
+
45
+ return parent::validate($product);
46
+ }
47
+
48
+ public function getTypeElement()
49
+ {
50
+ return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() .'_'. $this->getPaymentMethodCode() . '__type', 'hidden', array(
51
+ //'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId().'_'. $this->getPaymentMethodCode() . '][type]',
52
+ 'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId() . '][type]',
53
+ 'value' => $this->getType(),
54
+ 'no_span' => true,
55
+ 'class' => 'hidden',
56
+ ));
57
+ }
58
+
59
+ public function getAttributeElement()
60
+ {
61
+ if (is_null($this->getAttribute())) {
62
+ foreach ($this->getAttributeOption() as $k => $v) {
63
+ $this->setAttribute($k);
64
+ break;
65
+ }
66
+ }
67
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__attribute', 'select', array(
68
+ //'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][attribute]',
69
+ 'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'][attribute]',
70
+ 'values'=>$this->getAttributeSelectOptions(),
71
+ 'value'=>$this->getAttribute(),
72
+ 'value_name'=>$this->getAttributeName(),
73
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
74
+ }
75
+
76
+ /**
77
+ * Retrieve Condition Operator element Instance
78
+ * If the operator value is empty - define first available operator value as default
79
+ *
80
+ * @return Varien_Data_Form_Element_Select
81
+ */
82
+ public function getOperatorElement()
83
+ {
84
+ $options = $this->getOperatorSelectOptions();
85
+ if (is_null($this->getOperator())) {
86
+ foreach ($options as $option) {
87
+ $this->setOperator($option['value']);
88
+ break;
89
+ }
90
+ }
91
+
92
+ $elementId = sprintf('%s__%s__operator', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
93
+ //$elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
94
+ $elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId());
95
+ $element = $this->getForm()->addField($elementId, 'select', array(
96
+ 'name' => $elementName,
97
+ 'values' => $options,
98
+ 'value' => $this->getOperator(),
99
+ 'value_name' => $this->getOperatorName(),
100
+ ));
101
+ $element->setRenderer(Mage::getBlockSingleton('rule/editable'));
102
+
103
+ return $element;
104
+ }
105
+
106
+ public function getValueElement()
107
+ {
108
+ $elementParams = array(
109
+ //'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][value]',
110
+ 'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][value]',
111
+ 'value' => $this->getValue(),
112
+ 'values' => $this->getValueSelectOptions(),
113
+ 'value_name' => $this->getValueName(),
114
+ 'after_element_html' => $this->getValueAfterElementHtml(),
115
+ 'explicit_apply' => $this->getExplicitApply(),
116
+ );
117
+ if ($this->getInputType()=='date') {
118
+ // date format intentionally hard-coded
119
+ $elementParams['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
120
+ $elementParams['format'] = Varien_Date::DATE_INTERNAL_FORMAT;
121
+ }
122
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__value',
123
+ $this->getValueElementType(),
124
+ $elementParams
125
+ )->setRenderer($this->getValueElementRenderer());
126
+ }
127
+
128
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Combine.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Rule_Condition_Product_Combine extends Mage_Rule_Model_Condition_Combine
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setType('hipay/rule_condition_product_combine');
9
+ }
10
+
11
+ public function getNewChildSelectOptions()
12
+ {
13
+ $productCondition = Mage::getModel('hipay/rule_condition_product');
14
+ $productAttributes = $productCondition->loadAttributeOptions()->getAttributeOption();
15
+ $pAttributes = array();
16
+ $iAttributes = array();
17
+ foreach ($productAttributes as $code=>$label) {
18
+ if (strpos($code, 'order_item_')===0) {
19
+ $iAttributes[] = array('value'=>'hipay/rule_condition_product|'.$code.'|'.$this->getPaymentMethodCode(), 'label'=>$label);
20
+ } else {
21
+ $pAttributes[] = array('value'=>'hipay/rule_condition_product|'.$code.'|'.$this->getPaymentMethodCode(), 'label'=>$label);
22
+ }
23
+ }
24
+
25
+ $conditions = parent::getNewChildSelectOptions();
26
+ $conditions = array_merge_recursive($conditions, array(
27
+ array('value'=>'hipay/rule_condition_product_combine||'.$this->getPaymentMethodCode(), 'label'=>Mage::helper('catalog')->__('Conditions Combination')),
28
+ array('label'=>Mage::helper('hipay')->__('Order Attribute'), 'value'=>$iAttributes),
29
+ array('label'=>Mage::helper('catalog')->__('Product Attribute'), 'value'=>$pAttributes),
30
+ ));
31
+ return $conditions;
32
+ }
33
+
34
+ public function collectValidatedAttributes($productCollection)
35
+ {
36
+ foreach ($this->getConditions() as $condition) {
37
+ $condition->collectValidatedAttributes($productCollection);
38
+ }
39
+ return $this;
40
+ }
41
+
42
+ public function getTypeElement()
43
+ {
44
+ return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() .'_'. $this->getPaymentMethodCode() . '__type', 'hidden', array(
45
+ //'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId().'_'. $this->getPaymentMethodCode() . '][type]',
46
+ 'name' => 'rule_' . $this->getPaymentMethodCode() . '[' . $this->getPrefix() . '][' . $this->getId() . '][type]',
47
+ 'value' => $this->getType(),
48
+ 'no_span' => true,
49
+ 'class' => 'hidden',
50
+ ));
51
+ }
52
+
53
+ public function getAttributeElement()
54
+ {
55
+ if (is_null($this->getAttribute())) {
56
+ foreach ($this->getAttributeOption() as $k => $v) {
57
+ $this->setAttribute($k);
58
+ break;
59
+ }
60
+ }
61
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__attribute', 'select', array(
62
+ //'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][attribute]',
63
+ 'name'=>'rule_' . $this->getPaymentMethodCode() . '['.$this->getPrefix().']['.$this->getId().'][attribute]',
64
+ 'values'=>$this->getAttributeSelectOptions(),
65
+ 'value'=>$this->getAttribute(),
66
+ 'value_name'=>$this->getAttributeName(),
67
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
68
+ }
69
+
70
+ /**
71
+ * Retrieve Condition Operator element Instance
72
+ * If the operator value is empty - define first available operator value as default
73
+ *
74
+ * @return Varien_Data_Form_Element_Select
75
+ */
76
+ public function getOperatorElement()
77
+ {
78
+ $options = $this->getOperatorSelectOptions();
79
+ if (is_null($this->getOperator())) {
80
+ foreach ($options as $option) {
81
+ $this->setOperator($option['value']);
82
+ break;
83
+ }
84
+ }
85
+
86
+ $elementId = sprintf('%s__%s__operator', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
87
+ //$elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId().'_'. $this->getPaymentMethodCode());
88
+ $elementName = sprintf('rule_'.$this->getPaymentMethodCode().'[%s][%s][operator]', $this->getPrefix(), $this->getId());
89
+ $element = $this->getForm()->addField($elementId, 'select', array(
90
+ 'name' => $elementName,
91
+ 'values' => $options,
92
+ 'value' => $this->getOperator(),
93
+ 'value_name' => $this->getOperatorName(),
94
+ ));
95
+ $element->setRenderer(Mage::getBlockSingleton('rule/editable'));
96
+
97
+ return $element;
98
+ }
99
+
100
+ public function getValueElement()
101
+ {
102
+ $elementParams = array(
103
+ //'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][value]',
104
+ 'name' => 'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][value]',
105
+ 'value' => $this->getValue(),
106
+ 'values' => $this->getValueSelectOptions(),
107
+ 'value_name' => $this->getValueName(),
108
+ 'after_element_html' => $this->getValueAfterElementHtml(),
109
+ 'explicit_apply' => $this->getExplicitApply(),
110
+ );
111
+ if ($this->getInputType()=='date') {
112
+ // date format intentionally hard-coded
113
+ $elementParams['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
114
+ $elementParams['format'] = Varien_Date::DATE_INTERNAL_FORMAT;
115
+ }
116
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__value',
117
+ $this->getValueElementType(),
118
+ $elementParams
119
+ )->setRenderer($this->getValueElementRenderer());
120
+ }
121
+
122
+ public function getNewChildElement()
123
+ {
124
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__new_child', 'select', array(
125
+ //'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][new_child]',
126
+ 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][new_child]',
127
+ 'values'=>$this->getNewChildSelectOptions(),
128
+ 'value_name'=>$this->getNewChildName(),
129
+ ))->setRenderer(Mage::getBlockSingleton('rule/newchild'));
130
+ }
131
+
132
+ public function getAggregatorElement()
133
+ {
134
+ if (is_null($this->getAggregator())) {
135
+ foreach ($this->getAggregatorOption() as $k=>$v) {
136
+ $this->setAggregator($k);
137
+ break;
138
+ }
139
+ }
140
+
141
+ return $this->getForm()->addField($this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__aggregator', 'select', array(
142
+ // 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'_'. $this->getPaymentMethodCode().'][aggregator]',
143
+ 'name'=>'rule_'.$this->getPaymentMethodCode().'['.$this->getPrefix().']['.$this->getId().'][aggregator]',
144
+ 'values'=>$this->getAggregatorSelectOptions(),
145
+ 'value'=>$this->getAggregator(),
146
+ 'value_name'=>$this->getAggregatorName(),
147
+ ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
148
+ }
149
+
150
+ public function asHtmlRecursive()
151
+ {
152
+ $html = $this->asHtml().'<ul id="'.$this->getPrefix().'__'.$this->getId().'_'. $this->getPaymentMethodCode().'__children" class="rule-param-children">';
153
+ foreach ($this->getConditions() as $cond) {
154
+ $cond->setPaymentMethodCode($this->getPaymentMethodCode());
155
+ $html .= '<li>'.$cond->asHtmlRecursive().'</li>';
156
+ }
157
+ $html .= '<li>'.$this->getNewChildElement()->getHtml().'</li></ul>';
158
+ return $html;
159
+ }
160
+
161
+
162
+ public function getPaymentMethodCode()
163
+ {
164
+ return $this->_paymentMethodCode;
165
+ }
166
+
167
+ public function setPaymentMethodCode($methodCode)
168
+ {
169
+ $this->_paymentMethodCode = $methodCode;
170
+ return $this;
171
+ }
172
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Found.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Allopass_Hipay_Model_Rule_Condition_Product_Found
5
+ extends Allopass_Hipay_Model_Rule_Condition_Product_Combine
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setType('hipay/rule_condition_product_found');
11
+ }
12
+
13
+ /**
14
+ * Load value options
15
+ *
16
+ * @return Mage_SalesRule_Model_Rule_Condition_Product_Found
17
+ */
18
+ public function loadValueOptions()
19
+ {
20
+ $this->setValueOption(array(
21
+ 1 => Mage::helper('salesrule')->__('FOUND'),
22
+ 0 => Mage::helper('salesrule')->__('NOT FOUND')
23
+ ));
24
+ return $this;
25
+ }
26
+
27
+ public function asHtml()
28
+ {
29
+ $html = $this->getTypeElement()->getHtml() . Mage::helper('salesrule')->__("If an item is %s in the cart with %s of these conditions true:", $this->getValueElement()->getHtml(), $this->getAggregatorElement()->getHtml());
30
+ if ($this->getId() != '1') {
31
+ $html.= $this->getRemoveLinkHtml();
32
+ }
33
+ return $html;
34
+ }
35
+
36
+ /**
37
+ * validate
38
+ *
39
+ * @param Varien_Object $object Quote
40
+ * @return boolean
41
+ */
42
+ public function validate(Varien_Object $object)
43
+ {
44
+ $all = $this->getAggregator()==='all';
45
+ $true = (bool)$this->getValue();
46
+ $found = false;
47
+ foreach ($object->getAllItems() as $item) {
48
+ $found = $all;
49
+ foreach ($this->getConditions() as $cond) {
50
+ $validated = $cond->validate($item);
51
+ if (($all && !$validated) || (!$all && $validated)) {
52
+ $found = $validated;
53
+ break;
54
+ }
55
+ }
56
+ if (($found && $true) || (!$true && $found)) {
57
+ break;
58
+ }
59
+ }
60
+ // found an item and we're looking for existing one
61
+ if ($found && $true) {
62
+ return true;
63
+ }
64
+ // not found and we're making sure it doesn't exist
65
+ elseif (!$found && !$true) {
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+ }
app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Subselect.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Allopass_Hipay_Model_Rule_Condition_Product_Subselect
5
+ extends Allopass_Hipay_Model_Rule_Condition_Product_Combine
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setType('hipay/rule_condition_product_subselect')
11
+ ->setValue(null);
12
+ }
13
+
14
+ public function loadArray($arr, $key='conditions')
15
+ {
16
+ $this->setAttribute($arr['attribute']);
17
+ $this->setOperator($arr['operator']);
18
+ parent::loadArray($arr, $key);
19
+ return $this;
20
+ }
21
+
22
+ public function asXml($containerKey='conditions', $itemKey='condition')
23
+ {
24
+ $xml = '<attribute>'.$this->getAttribute().'</attribute>'
25
+ . '<operator>'.$this->getOperator().'</operator>'
26
+ . parent::asXml($containerKey, $itemKey);
27
+ return $xml;
28
+ }
29
+
30
+ public function loadAttributeOptions()
31
+ {
32
+ $this->setAttributeOption(array(
33
+ 'qty' => Mage::helper('salesrule')->__('total quantity'),
34
+ 'base_row_total' => Mage::helper('salesrule')->__('total amount'),
35
+ ));
36
+ return $this;
37
+ }
38
+
39
+ public function loadValueOptions()
40
+ {
41
+ return $this;
42
+ }
43
+
44
+ public function loadOperatorOptions()
45
+ {
46
+ $this->setOperatorOption(array(
47
+ '==' => Mage::helper('rule')->__('is'),
48
+ '!=' => Mage::helper('rule')->__('is not'),
49
+ '>=' => Mage::helper('rule')->__('equals or greater than'),
50
+ '<=' => Mage::helper('rule')->__('equals or less than'),
51
+ '>' => Mage::helper('rule')->__('greater than'),
52
+ '<' => Mage::helper('rule')->__('less than'),
53
+ '()' => Mage::helper('rule')->__('is one of'),
54
+ '!()' => Mage::helper('rule')->__('is not one of'),
55
+ ));
56
+ return $this;
57
+ }
58
+
59
+ public function getValueElementType()
60
+ {
61
+ return 'text';
62
+ }
63
+
64
+ public function asHtml()
65
+ {
66
+ $html = $this->getTypeElement()->getHtml().
67
+ Mage::helper('salesrule')->__("If %s %s %s for a subselection of items in cart matching %s of these conditions:", $this->getAttributeElement()->getHtml(), $this->getOperatorElement()->getHtml(), $this->getValueElement()->getHtml(), $this->getAggregatorElement()->getHtml());
68
+ if ($this->getId() != '1') {
69
+ $html .= $this->getRemoveLinkHtml();
70
+ }
71
+ return $html;
72
+ }
73
+
74
+ /**
75
+ * validate
76
+ *
77
+ * @param Varien_Object $object Quote
78
+ * @return boolean
79
+ */
80
+ public function validate(Varien_Object $object)
81
+ {
82
+ if (!$this->getConditions()) {
83
+ return false;
84
+ }
85
+
86
+
87
+ // $value = $this->getValue();
88
+ // $aggregatorArr = explode('/', $this->getAggregator());
89
+ // $this->setValue((int)$aggregatorArr[0])->setAggregator($aggregatorArr[1]);
90
+
91
+ $attr = $this->getAttribute();
92
+ $total = 0;
93
+ foreach ($object->getQuote()->getAllItems() as $item) {
94
+ if (parent::validate($item)) {
95
+ $total += $item->getData($attr);
96
+ }
97
+ }
98
+ // $this->setAggregator(join('/', $aggregatorArr))->setValue($value);
99
+
100
+ return $this->validateAttribute($total);
101
+ }
102
+ }
app/code/community/Allopass/Hipay/Model/Rule/Config.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Model_Rule_Config extends Mage_Core_Model_Config_Data
3
+ {
4
+
5
+ protected $_rule = null;
6
+ protected $_ruleData = null;
7
+
8
+ /**
9
+ * @return Allopass_Hipay_Model_Rule
10
+ */
11
+ public function getRule()
12
+ {
13
+ if(is_null($this->_rule))
14
+ {
15
+ $this->_rule = Mage::getModel('hipay/rule');
16
+ }
17
+
18
+ return $this->_rule;
19
+ }
20
+
21
+ public function setRule($rule)
22
+ {
23
+ $this->_rule = $rule;
24
+ }
25
+
26
+ protected function _afterload()
27
+ {
28
+
29
+ parent::_afterload();
30
+ $rule = Mage::getModel('hipay/rule');
31
+ $rule->setMethodCode($this->_getMethodCode());
32
+
33
+ if($this->getValue())
34
+ $rule->load($this->getValue());
35
+
36
+ $this->setRule($rule);
37
+
38
+ return $this;
39
+
40
+ }
41
+
42
+ protected function _beforeSave()
43
+ {
44
+ $rule = Mage::getModel('hipay/rule')->load($this->getValue());
45
+
46
+ $validateResult = $rule->validateData(new Varien_Object($this->_getRuleData()));
47
+ if ($validateResult !== true) {
48
+ $errors = array();
49
+ foreach($validateResult as $errorMessage) {
50
+ $errors[] = $errorMessage;
51
+ }
52
+ Mage::throwException(new Exception(print_r($errors,true)));
53
+
54
+ }
55
+
56
+ $rule->setMethodCode($this->_getMethodCode());
57
+ $rule->loadPost($this->_getRuleData());
58
+
59
+ try{
60
+
61
+ $rule->save();
62
+ }
63
+ catch (Exception $e)
64
+ {
65
+ Mage::logException($e);
66
+ }
67
+ $this->setRule($rule);
68
+
69
+ $this->setValue($rule->getId());
70
+
71
+ parent::_beforeSave();
72
+ return $this;
73
+ }
74
+
75
+ protected function _getMethodCode()
76
+ {
77
+ list($section,$group,$field) = explode("/", $this->getData('path'));
78
+ return $group;
79
+ }
80
+
81
+ protected function _getRuleData()
82
+ {
83
+ if(is_null($this->_ruleData))
84
+ {
85
+ $post = Mage::app()->getRequest()->getPost();
86
+ $this->_ruleData = array();
87
+ if(isset($post['rule_' . $this->_getMethodCode()]['conditions']))
88
+ $this->_ruleData['conditions'] = $post['rule_' . $this->_getMethodCode()]['conditions'];
89
+ }
90
+
91
+ return $this->_ruleData;
92
+ }
93
+ }
app/code/community/Allopass/Hipay/Model/Source/3ds.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay Activate 3DS
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_3ds
9
+ {
10
+ /**
11
+ * Options getter
12
+ *
13
+ * @return array
14
+ */
15
+ public function toOptionArray()
16
+ {
17
+ return array(
18
+ array('value' => 1, 'label'=>Mage::helper('hipay')->__('Enable for all transactions')),
19
+ array('value' => 2, 'label'=>Mage::helper('hipay')->__('Enable for configured 3ds rules')),
20
+ array('value' => 0, 'label'=>Mage::helper('hipay')->__('Disabled')),
21
+
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Get options in "key-value" format
27
+ *
28
+ * @return array
29
+ */
30
+ public function toArray()
31
+ {
32
+ return array(
33
+ 0 => Mage::helper('hipay')->__('Disabled'),
34
+ 1 => Mage::helper('hipay')->__('Enable for all transactions'),
35
+ 2 => Mage::helper('hipay')->__('Enable for configured 3ds rules'),
36
+ );
37
+ }
38
+
39
+ }
app/code/community/Allopass/Hipay/Model/Source/CcType.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay Credit cards types
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_CcType
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+
13
+ $options = array();
14
+
15
+ foreach (Mage::getSingleton('hipay/config')->getCcTypes() as $code => $name) {
16
+ $options[] = array(
17
+ 'value' => $code,
18
+ 'label' => $name
19
+ );
20
+ }
21
+
22
+ return $options;
23
+ }
24
+ }
app/code/community/Allopass/Hipay/Model/Source/CcTypeHosted.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay Credit cards types
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_CcTypeHosted
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+
13
+ $options = array();
14
+
15
+ foreach (Mage::getSingleton('hipay/config')->getCcTypesCodeHipay() as $code => $name) {
16
+ $options[] = array(
17
+ 'value' => $code,
18
+ 'label' => $name
19
+ );
20
+ }
21
+
22
+ return $options;
23
+ }
24
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/HipayStatusValidate.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_HipayStatusValidate
4
+ {
5
+ public function toOptionArray() {
6
+ $options = array();
7
+
8
+ $options[] = array(
9
+ 'value' => 117,
10
+ 'label' => Mage::helper('hipay')->__('Capture Requested')
11
+ );
12
+
13
+ $options[] = array(
14
+ 'value' => 118,
15
+ 'label' => Mage::helper('hipay')->__('Capture')
16
+ );
17
+
18
+ return $options;
19
+ }
20
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/Status.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_Status {
4
+
5
+ // set null to enable all possible
6
+ protected $_stateStatuses = array();
7
+
8
+ public function toOptionArray() {
9
+ if ($this->_stateStatuses) {
10
+ $statuses = Mage::getSingleton('sales/order_config')->getStateStatuses($this->_stateStatuses);
11
+ } else {
12
+ $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
13
+ }
14
+ $options = array();
15
+ $options[] = array(
16
+ 'value' => '',
17
+ 'label' => Mage::helper('adminhtml')->__('-- Please Select --')
18
+ );
19
+ foreach ($statuses as $code => $label) {
20
+ $options[] = array(
21
+ 'value' => $code,
22
+ 'label' => $label
23
+ );
24
+ }
25
+ return $options;
26
+ }
27
+
28
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/Status/Accepted.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_Status_Accepted extends Allopass_Hipay_Model_Source_Order_Status {
4
+
5
+ // set null to enable all possible
6
+ protected $_stateStatuses = array(
7
+ Mage_Sales_Model_Order::STATE_NEW,
8
+ Mage_Sales_Model_Order::STATE_PROCESSING,
9
+ Mage_Sales_Model_Order::STATE_COMPLETE
10
+ );
11
+
12
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/Status/Canceled.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_Status_Canceled extends Allopass_Hipay_Model_Source_Order_Status {
4
+
5
+ // set null to enable all possible
6
+ protected $_stateStatuses = array(
7
+ Mage_Sales_Model_Order::STATE_HOLDED,
8
+ Mage_Sales_Model_Order::STATE_CANCELED
9
+ );
10
+
11
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/Status/New.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_Status_New extends Allopass_Hipay_Model_Source_Order_Status {
4
+
5
+ // set null to enable all possible
6
+ protected $_stateStatuses = array(
7
+ Mage_Sales_Model_Order::STATE_NEW,
8
+ Mage_Sales_Model_Order::STATE_PROCESSING
9
+ );
10
+
11
+ }
app/code/community/Allopass/Hipay/Model/Source/Order/Status/Refused.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Model_Source_Order_Status_Refused extends Allopass_Hipay_Model_Source_Order_Status {
4
+
5
+ // set null to enable all possible
6
+ protected $_stateStatuses = array(
7
+ Mage_Sales_Model_Order::STATE_HOLDED,
8
+ Mage_Sales_Model_Order::STATE_CANCELED,
9
+ Mage_Sales_Model_Order::STATE_CLOSED
10
+ );
11
+
12
+ }
app/code/community/Allopass/Hipay/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay Payment Action Dropdown source
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_PaymentAction
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('hipay')->__('Authorization')),
14
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('hipay')->__('Sale')),
15
+ );
16
+ }
17
+ }
app/code/community/Allopass/Hipay/Model/Source/Pendingredirect.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay redirect url for pending
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_Pendingredirect
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+
13
+ return array(
14
+ array('value' => 'hipay/checkout/pending', 'label' => Mage::helper('hipay')->__('Pending page')),
15
+ array('value' => 'checkout/onepage/success', 'label' => Mage::helper('hipay')->__('Success page')),
16
+ array('value' => 'checkout/onepage/failure', 'label' => Mage::helper('hipay')->__('Failure page')),
17
+ );
18
+ }
19
+ }
app/code/community/Allopass/Hipay/Model/Source/Template.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Allopass Hipay templates types
6
+ *
7
+ */
8
+ class Allopass_Hipay_Model_Source_Template
9
+ {
10
+ /*public function toOptionArray()
11
+ {
12
+
13
+ return array(
14
+ array('value' => 'basic', 'label' => Mage::helper('hipay')->__('basic')),
15
+ array('value' => 'basic2', 'label' => Mage::helper('hipay')->__('basic2')),
16
+ array('value' => 'basic3', 'label' => Mage::helper('hipay')->__('basic3')),
17
+ array('value' => 'basic4', 'label' => Mage::helper('hipay')->__('basic4')),
18
+ );
19
+ }*/
20
+
21
+ public function toOptionArray()
22
+ {
23
+
24
+ $options = array();
25
+
26
+ foreach (Mage::getSingleton('hipay/config')->getTemplateHosted() as $value => $label) {
27
+ $options[] = array(
28
+ 'value' => $value,
29
+ 'label' => $label
30
+ );
31
+ }
32
+
33
+ return $options;
34
+ }
35
+ }
app/code/community/Allopass/Hipay/controllers/Adminhtml/RuleController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Allopass_Hipay_Adminhtml_RuleController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+
7
+ public function newConditionHtmlAction()
8
+ {
9
+ $id = $this->getRequest()->getParam('id');
10
+ $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
11
+ $type = $typeArr[0];
12
+ $method_code = $typeArr[2];
13
+ $id = str_replace("_".$method_code, "", $id);
14
+ $model = Mage::getModel($type)
15
+ ->setId($id)
16
+ ->setType($type)
17
+ ->setRule(Mage::getModel('hipay/rule'))
18
+ ->setPrefix('conditions')
19
+ ->setPaymentMethodCode($method_code);
20
+ if (!empty($typeArr[1])) {
21
+ $model->setAttribute($typeArr[1]);
22
+ }
23
+
24
+ if ($model instanceof Mage_Rule_Model_Condition_Abstract) {
25
+ $model->setJsFormObject($this->getRequest()->getParam('form'));
26
+ $html = $model->asHtmlRecursive();
27
+ } else {
28
+ $html = '';
29
+ }
30
+ $this->getResponse()->setBody($html);
31
+ }
32
+
33
+
34
+
35
+
36
+
37
+ }
app/code/community/Allopass/Hipay/controllers/CbcController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_CbcController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_cbc');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/CcController.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_CcController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+
5
+
6
+ /**
7
+ *
8
+ * @return Allopass_Hipay_Model_Method_Cc $methodInstance
9
+ */
10
+ protected function _getMethodInstance()
11
+ {
12
+ return Mage::getSingleton('hipay/method_cc'); ;
13
+ }
14
+
15
+ }
app/code/community/Allopass/Hipay/controllers/CheckoutController.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_CheckoutController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+
6
+
7
+ /**
8
+ * @return Mage_Core_Controller_Front_Action
9
+ */
10
+ public function preDispatch() {
11
+ parent::preDispatch();
12
+ //Mage::log($this->getRequest()->getParams(),null,$this->getRequest()->getActionName() . ".log");
13
+ }
14
+
15
+
16
+ public function pendingAction()
17
+ {
18
+
19
+ $lastQuoteId = $this->getOnepage()->getCheckout()->getLastQuoteId();
20
+ $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
21
+ $this->getOnepage()->getCheckout()->setErrorMessage("");
22
+ if (!$lastQuoteId || !$lastOrderId) {
23
+ $this->_redirect('checkout/cart');
24
+ return;
25
+ }
26
+
27
+ $this->loadLayout();
28
+ $this->renderLayout();
29
+ }
30
+
31
+ /**
32
+ * Get one page checkout model
33
+ *
34
+ * @return Mage_Checkout_Model_Type_Onepage
35
+ */
36
+ public function getOnepage()
37
+ {
38
+ return Mage::getSingleton('checkout/type_onepage');
39
+ }
40
+ }
app/code/community/Allopass/Hipay/controllers/DexiaController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_DexiaController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_dexia');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/GiropayController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_GiropayController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_giropay');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/HostedController.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_HostedController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+
5
+
6
+ protected function _getMethodInstance()
7
+ {
8
+ return Mage::getSingleton('hipay/method_hosted'); ;
9
+ }
10
+
11
+
12
+ }
app/code/community/Allopass/Hipay/controllers/IdealController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_IdealController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_ideal');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/IngController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_IngController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_ing');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/KbcController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_KbcController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_kbc');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/NotifyController.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_NotifyController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ /**
5
+ *
6
+ * @var Mage_Sales_Model_Order $order
7
+ */
8
+ protected $_order = null;
9
+
10
+
11
+ /**
12
+ * @return Mage_Core_Controller_Front_Action
13
+ */
14
+ public function preDispatch() {
15
+ parent::preDispatch();
16
+
17
+ //Mage::log($this->getRequest()->getParams(),null,$this->getRequest()->getActionName() . ".log");
18
+ if (!$this->_validateSignature()) {
19
+ $this->getResponse()->setBody("NOK. Wrong Signature!");
20
+ $this->setFlag('', 'no-dispatch', true);
21
+ }
22
+ }
23
+
24
+ protected function _validateSignature()
25
+ {
26
+ /* @var $_helper Allopass_Hipay_Helper_Data */
27
+ $_helper = Mage::helper('hipay');
28
+
29
+
30
+ $signature = $this->getRequest()->getServer('HTTP_X_ALLOPASS_SIGNATURE');
31
+ return $_helper->checkSignature($signature,true);
32
+ }
33
+
34
+
35
+
36
+ public function indexAction()
37
+ {
38
+ /* @var $response Allopass_Hipay_Model_Api_Response_Notification */
39
+ $response = Mage::getSingleton('hipay/api_response_notification',$this->getRequest()->getParams());
40
+ $orderArr = $response->getOrder();
41
+
42
+ /* @var $order Mage_Sales_Model_Order */
43
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderArr['id']);
44
+
45
+ if(!$order->getId() && strpos($orderArr['id'], 'recurring') === false)
46
+ Mage::throwException("Order not found in notification");
47
+
48
+ if(strpos($orderArr['id'], 'recurring') !== false)
49
+ {
50
+ //return $this;
51
+
52
+ list($action,$type,$profileId) = explode("-", $orderArr['id']);
53
+
54
+ if($profileId)
55
+ {
56
+ /* @var $profile Mage_Sales_Model_Recurring_Profile */
57
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
58
+ if($profile->getId())
59
+ {
60
+
61
+
62
+ if($action == 'create' || $action == "payment")
63
+ {
64
+ //$order = $this->createProfileOrder($profile, $response);
65
+ }
66
+
67
+ //return $this;
68
+
69
+ }
70
+ else
71
+ Mage::throwException(Mage::helper('hipay')->__("Profile for ID: %d doesn't exists (Recurring).",$profileId));
72
+ }
73
+ else
74
+ Mage::throwException(Mage::helper('hipay')->__("Order Id not present (Recurring)."));
75
+
76
+ }
77
+
78
+ $payment = $order->getPayment();
79
+ /* @var $methodInstance Allopass_Hipay_Model_Method_Abstract */
80
+ $methodInstance = $payment->getMethodInstance();
81
+ $methodInstance->debugData($response->debug());
82
+ $amount = 0;
83
+ if((int)$response->getRefundedAmount() == 0 && (int)$response->getCapturedAmount() == 0)
84
+ $amount = $response->getAuthorizedAmount();
85
+ elseif((int)$response->getRefundedAmount() == 0 && (int)$response->getCapturedAmount() > 0 )
86
+ $amount = $response->getCapturedAmount();
87
+ else
88
+ $amount = $response->getRefundedAmount();
89
+
90
+ $transactionId = $response->getTransactionReference();
91
+
92
+
93
+ $methodInstance->processResponse($response, $payment, $amount);
94
+
95
+
96
+ $message = Mage::helper('hipay')->__("Notification from Hipay:") . " " . Mage::helper('hipay')->__("status") . ": ". $response->getStatus(). " Message: " .$response->getMessage()." ".Mage::helper('hipay')->__('amount: %s',(string)$amount);
97
+ //
98
+ $order->addStatusToHistory($order->getStatus(), $message);
99
+ $order->save();
100
+
101
+ return $this;
102
+
103
+
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param Mage_Sales_Model_Recurring_Profile $profile
109
+ * @param Allopass_Hipay_Model_Api_Response_Notification $response
110
+ * @return Mage_Sales_Model_Order
111
+ */
112
+ protected function createProfileOrder(Mage_Sales_Model_Recurring_Profile $profile,Allopass_Hipay_Model_Api_Response_Notification $response)
113
+ {
114
+
115
+ $amount = $this->getAmountFromProfile($profile);
116
+
117
+ $productItemInfo = new Varien_Object;
118
+ $type = "Regular";
119
+ if ($type == 'Trial') {
120
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
121
+ } elseif ($type == 'Regular') {
122
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
123
+ }
124
+
125
+ if($this->isInitialProfileOrder($profile))// because is not additonned in prodile obj
126
+ $productItemInfo->setPrice($profile->getBillingAmount() + $profile->getInitAmount());
127
+
128
+ /* @var $order Mage_Sales_Model_Order */
129
+ $order = $profile->createOrder($productItemInfo);
130
+
131
+ //$this->responseToPayment($order->getPayment(),$response);
132
+ $additionalInfo = $profile->getAdditionalInfo();
133
+
134
+ $order->getPayment()->setCcType($additionalInfo['ccType']);
135
+ $order->getPayment()->setCcExpMonth($additionalInfo['ccExpMonth']);
136
+ $order->getPayment()->setCcExpYear($additionalInfo['ccExpYear']);
137
+ $order->getPayment()->setAdditionalInformation('token',$additionalInfo['token']);
138
+ $order->getPayment()->setAdditionalInformation('create_oneclick',$additionalInfo['create_oneclick']);
139
+ $order->getPayment()->setAdditionalInformation('use_oneclick',$additionalInfo['use_oneclick']);
140
+
141
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW,'pending',Mage::helper('hipay')->__("New Order Recurring!"));
142
+
143
+ $order->save();
144
+
145
+ $profile->addOrderRelation($order->getId());
146
+ $profile->save();
147
+
148
+ return $order;
149
+
150
+
151
+ $order->getPayment()->registerCaptureNotification($amount);
152
+ $order->save();
153
+
154
+ // notify customer
155
+ if ($invoice = $order->getPayment()->getCreatedInvoice()) {
156
+ $message = Mage::helper('hipay')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
157
+ $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
158
+ ->setIsCustomerNotified(true)
159
+ ->save();
160
+
161
+ /* Add this to send invoice to customer */
162
+ $invoice->setEmailSent(true);
163
+ $invoice->save();
164
+ $invoice->sendEmail();
165
+ }
166
+
167
+ return $order;
168
+
169
+ }
170
+
171
+ /**
172
+ * Add method to calculate amount from recurring profile
173
+ * @param Mage_Sales_Model_Recurring_Profile $profile
174
+ * @return int $amount
175
+ **/
176
+ public function getAmountFromProfile(Mage_Sales_Model_Recurring_Profile $profile) {
177
+ $amount = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
178
+
179
+ if($this->isInitialProfileOrder($profile))
180
+ $amount += $profile->getInitAmount() ;
181
+
182
+ return $amount;
183
+ }
184
+
185
+ protected function isInitialProfileOrder(Mage_Sales_Model_Recurring_Profile $profile)
186
+ {
187
+ if(count($profile->getChildOrderIds()) && current($profile->getChildOrderIds()) == "-1")
188
+ return true;
189
+
190
+ return false;
191
+ }
192
+
193
+ }
app/code/community/Allopass/Hipay/controllers/Przelewy24Controller.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Przelewy24Controller extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_przelewy24');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/Przelewy24apiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_Przelewy24apiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_przelewy24Api');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/QiwiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_QiwiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_qiwi');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/SisalController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_SisalController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_sisal');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/SisalapiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_SisalapiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_sisalApi');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/SofortController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_SofortController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_sofort');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/SofortapiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_SofortapiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_sofortApi');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/WebmoneyController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_WebmoneyController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_webmoney');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/WebmoneyapiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_WebmoneyapiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_webmoneyApi');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/YandexController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_YandexController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_yandex');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/controllers/YandexapiController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Allopass_Hipay_YandexapiController extends Allopass_Hipay_Controller_Payment
3
+ {
4
+ protected function _getMethodInstance()
5
+ {
6
+ return Mage::getSingleton('hipay/method_yandexApi');
7
+ }
8
+ }
app/code/community/Allopass/Hipay/etc/config.xml ADDED
@@ -0,0 +1,637 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Allopass_Hipay>
5
+ <version>1.0.0</version>
6
+ </Allopass_Hipay>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <hipay>
11
+ <class>Allopass_Hipay_Block</class>
12
+ </hipay>
13
+ </blocks>
14
+ <helpers>
15
+ <hipay>
16
+ <class>Allopass_Hipay_Helper</class>
17
+ </hipay>
18
+ </helpers>
19
+ <models>
20
+ <hipay>
21
+ <class>Allopass_Hipay_Model</class>
22
+ <resourceModel>hipay_resource</resourceModel>
23
+ </hipay>
24
+ <hipay_resource>
25
+ <class>Allopass_Hipay_Model_Resource</class>
26
+ <!-- <deprecatedNode>hipay_mysql4</deprecatedNode> -->
27
+ <entities>
28
+ <rule>
29
+ <table>hipay_rule</table>
30
+ </rule>
31
+ </entities>
32
+ </hipay_resource>
33
+ </models>
34
+ <resources>
35
+ <allopass_hipay_setup>
36
+ <setup>
37
+ <module>Allopass_Hipay</module>
38
+ </setup>
39
+ </allopass_hipay_setup>
40
+ </resources>
41
+ <template_hipay>
42
+ <hosted>
43
+ <basic>
44
+ <label>Basic</label>
45
+ <value>basic</value>
46
+ </basic>
47
+ <basicjs>
48
+ <label>Basic-js</label>
49
+ <value>basic-js</value>
50
+ </basicjs>
51
+ </hosted>
52
+ </template_hipay>
53
+ <payment_hipay>
54
+ <cc>
55
+ <types>
56
+ <AE>
57
+ <code>AE</code>
58
+ <code_hipay>american-express</code_hipay>
59
+ <name>American Express</name>
60
+ <order>0</order>
61
+ </AE>
62
+ <VI>
63
+ <code>VI</code>
64
+ <code_hipay>visa</code_hipay>
65
+ <name>Visa</name>
66
+ <order>10</order>
67
+ </VI>
68
+ <MC>
69
+ <code>MC</code>
70
+ <code_hipay>mastercard</code_hipay>
71
+ <name>MasterCard</name>
72
+ <order>20</order>
73
+ </MC>
74
+ <SM>
75
+ <code>SM</code>
76
+ <code_hipay>maestro</code_hipay>
77
+ <name>Maestro</name>
78
+ <order>40</order>
79
+ </SM>
80
+ <BCMC>
81
+ <code>BCMC</code>
82
+ <code_hipay>bcmc</code_hipay>
83
+ <name>Bancontact / Mister Cash</name>
84
+ <order>60</order>
85
+ </BCMC>
86
+ </types>
87
+ </cc>
88
+ <hosted>
89
+ <types>
90
+ <AE>
91
+ <code>AE</code>
92
+ <code_hipay>american-express</code_hipay>
93
+ <name>American Express</name>
94
+ <order>0</order>
95
+ </AE>
96
+ <VI>
97
+ <code>VI</code>
98
+ <code_hipay>visa</code_hipay>
99
+ <name>Visa</name>
100
+ <order>10</order>
101
+ </VI>
102
+ <MC>
103
+ <code>MC</code>
104
+ <code_hipay>mastercard</code_hipay>
105
+ <name>MasterCard</name>
106
+ <order>20</order>
107
+ </MC>
108
+ <SM>
109
+ <code>SM</code>
110
+ <code_hipay>maestro</code_hipay>
111
+ <name>Maestro</name>
112
+ <order>30</order>
113
+ </SM>
114
+ <BCMC>
115
+ <code>BCMC</code>
116
+ <code_hipay>bcmc</code_hipay>
117
+ <name>Bancontact / Mister Cash</name>
118
+ <order>60</order>
119
+ </BCMC>
120
+ </types>
121
+ </hosted>
122
+ </payment_hipay>
123
+ <sales>
124
+ <order>
125
+ <statuses>
126
+ <!-- retained for backwards compatibility, not used after version 1.4.2 -->
127
+ <pending_capture translate="label"><label>Pending Capture</label></pending_capture>
128
+ <capture_requested translate="label"><label>Capture Requested</label></capture_requested>
129
+ <refund_requested translate="label"><label>Refund Requested</label></refund_requested>
130
+ </statuses>
131
+ </order>
132
+ </sales>
133
+ </global>
134
+ <frontend>
135
+ <secure_url>
136
+ <hipay_payment>/hipay/payment</hipay_payment>
137
+ </secure_url>
138
+ <routers>
139
+ <hipay>
140
+ <use>standard</use>
141
+ <args>
142
+ <module>Allopass_Hipay</module>
143
+ <frontName>hipay</frontName>
144
+ </args>
145
+ </hipay>
146
+ </routers>
147
+ <translate>
148
+ <modules>
149
+ <Allopass_Hipay>
150
+ <files>
151
+ <default>Allopass_Hipay.csv</default>
152
+ </files>
153
+ </Allopass_Hipay>
154
+ </modules>
155
+ </translate>
156
+ <layout>
157
+ <updates>
158
+ <hipay>
159
+ <file>hipay.xml</file>
160
+ </hipay>
161
+ </updates>
162
+ </layout>
163
+ <events>
164
+ <controller_action_postdispatch_checkout_onepage_saveOrder>
165
+ <observers>
166
+ <displaySectionCheckoutIframe>
167
+ <class>hipay/observer</class>
168
+ <method>displaySectionCheckoutIframe</method>
169
+ </displaySectionCheckoutIframe>
170
+ </observers>
171
+ </controller_action_postdispatch_checkout_onepage_saveOrder>
172
+ </events>
173
+ </frontend>
174
+ <adminhtml>
175
+ <routers>
176
+ <hipay>
177
+ <use>admin</use>
178
+ <args>
179
+ <module>Allopass_Hipay</module>
180
+ <frontName>hipay</frontName>
181
+ </args>
182
+ </hipay>
183
+ </routers>
184
+ <translate>
185
+ <modules>
186
+ <Allopass_Hipay>
187
+ <files>
188
+ <default>Allopass_Hipay.csv</default>
189
+ </files>
190
+ </Allopass_Hipay>
191
+ </modules>
192
+ </translate>
193
+ <acl>
194
+ <resources>
195
+ <admin>
196
+ <children>
197
+ <system>
198
+ <children>
199
+ <config>
200
+ <children>
201
+ <hipay>
202
+ <title>Hipay API Configuration</title>
203
+ </hipay>
204
+ <payment>
205
+ <children>
206
+ <hipay_cc translate="title">
207
+ <title>Hipay Credit Card</title>
208
+ </hipay_cc>
209
+ </children>
210
+ </payment>
211
+ </children>
212
+ </config>
213
+ </children>
214
+ </system>
215
+ </children>
216
+ </admin>
217
+ </resources>
218
+ </acl>
219
+ <layout>
220
+ <updates>
221
+ <hipay>
222
+ <file>hipay.xml</file>
223
+ </hipay>
224
+ </updates>
225
+ </layout>
226
+ </adminhtml>
227
+ <default>
228
+ <hipay>
229
+ <hipay_api>
230
+ <api_password backend_model="adminhtml/system_config_backend_encrypted"/>
231
+ <api_password_test backend_model="adminhtml/system_config_backend_encrypted"/>
232
+ <secret_passphrase backend_model="adminhtml/system_config_backend_encrypted"/>
233
+ <vault_endpoint_stage>https://stage-secure-vault.allopass.com/rest/v1/token/</vault_endpoint_stage>
234
+ <vault_endpoint_production>https://secure-vault.allopass.com/rest/v1/token/</vault_endpoint_production>
235
+ <gateway_endpoint_stage>https://stage-secure-gateway.allopass.com/rest/v1/</gateway_endpoint_stage>
236
+ <gateway_endpoint_production>https://secure-gateway.allopass.com/rest/v1/</gateway_endpoint_production>
237
+ </hipay_api>
238
+ </hipay>
239
+ <payment>
240
+ <hipay_cc>
241
+ <active>0</active>
242
+ <title>HiPay Credit Card</title>
243
+ <payment_action>authorize_capture</payment_action>
244
+ <cctypes>AE,VI,MC</cctypes>
245
+ <useccv>1</useccv>
246
+ <order_status_payment_accepted>processing</order_status_payment_accepted>
247
+ <order_status_payment_refused>canceled</order_status_payment_refused>
248
+ <order_status_payment_canceled>canceled</order_status_payment_canceled>
249
+ <hipay_status_validate_order>118</hipay_status_validate_order>
250
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page>
251
+ <allow_use_oneclick>0</allow_use_oneclick>
252
+ <invoice_create>1</invoice_create>
253
+ <re_add_to_cart>0</re_add_to_cart>
254
+ <cancel_pending_order>1</cancel_pending_order>
255
+ <is_test_mode>0</is_test_mode>
256
+ <debug>0</debug>
257
+ <model>hipay/method_cc</model>
258
+ <accept_url>hipay/cc/accept</accept_url>
259
+ <pending_url>hipay/cc/pending</pending_url>
260
+ <decline_url>hipay/cc/decline</decline_url>
261
+ <exception_url>hipay/cc/exception</exception_url>
262
+ <cancel_url>hipay/cc/cancel</cancel_url>
263
+ <use_3d_secure>1</use_3d_secure>
264
+ </hipay_cc>
265
+ <hipay_hosted>
266
+ <active>0</active>
267
+ <title>HiPay Hosted</title>
268
+ <payment_action>authorize_capture</payment_action>
269
+ <cctypes>american-express,visa,mastercard</cctypes>
270
+ <order_status_payment_accepted>processing</order_status_payment_accepted>
271
+ <order_status_payment_refused>canceled</order_status_payment_refused>
272
+ <order_status_payment_canceled>canceled</order_status_payment_canceled>
273
+ <hipay_status_validate_order>118</hipay_status_validate_order>
274
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page>
275
+ <display_selector>1</display_selector>
276
+ <template>basic</template>
277
+ <allow_use_oneclick>0</allow_use_oneclick>
278
+ <invoice_create>1</invoice_create>
279
+ <re_add_to_cart>0</re_add_to_cart>
280
+ <cancel_pending_order>1</cancel_pending_order>
281
+ <display_iframe>0</display_iframe>
282
+ <iframe_width>450</iframe_width>
283
+ <iframe_height>670</iframe_height>
284
+ <iframe_style>border:1px solid #CCC;border-radius:15px;padding:10px;max-width:500px;</iframe_style>
285
+ <is_test_mode>0</is_test_mode>
286
+ <debug>0</debug>
287
+ <model>hipay/method_hosted</model>
288
+ <accept_url>hipay/hosted/accept</accept_url>
289
+ <pending_url>hipay/hosted/pending</pending_url>
290
+ <decline_url>hipay/hosted/decline</decline_url>
291
+ <exception_url>hipay/hosted/exception</exception_url>
292
+ <cancel_url>hipay/hosted/cancel</cancel_url>
293
+ <use_3d_secure>1</use_3d_secure>
294
+ </hipay_hosted>
295
+ <hipay_sofortapi>
296
+ <active>0</active> <!-- Activé ou non -->
297
+ <title>HiPay Sofort</title> <!-- Titre par défaut modifiable en admin -->
298
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
299
+ <cctypes>sofort-uberweisung</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
300
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
301
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
302
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
303
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
304
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
305
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
306
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
307
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
308
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
309
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
310
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
311
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
312
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
313
+ <model>hipay/method_sofortApi</model><!-- Classe model de la méthode -->
314
+ <accept_url>hipay/sofortapi/accept</accept_url><!-- Url accept de la méthode -->
315
+ <pending_url>hipay/sofortapi/pending</pending_url><!-- Url pending de la méthode -->
316
+ <decline_url>hipay/sofortapi/decline</decline_url><!-- Url decline de la méthode -->
317
+ <exception_url>hipay/sofortapi/exception</exception_url><!-- Url execption de la méthode -->
318
+ <cancel_url>hipay/sofortapi/cancel</cancel_url><!-- Url cancel de la méthode -->
319
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
320
+ </hipay_sofortapi>
321
+ <hipay_ideal>
322
+ <active>0</active> <!-- Activé ou non -->
323
+ <title>HiPay iDeal</title> <!-- Titre par défaut modifiable en admin -->
324
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
325
+ <cctypes>ideal</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
326
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
327
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
328
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
329
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
330
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
331
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
332
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
333
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
334
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
335
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
336
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
337
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
338
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
339
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
340
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
341
+ <model>hipay/method_ideal</model><!-- Classe model de la méthode -->
342
+ <accept_url>hipay/ideal/accept</accept_url><!-- Url accept de la méthode -->
343
+ <pending_url>hipay/ideal/pending</pending_url><!-- Url pending de la méthode -->
344
+ <decline_url>hipay/ideal/decline</decline_url><!-- Url decline de la méthode -->
345
+ <exception_url>hipay/ideal/exception</exception_url><!-- Url execption de la méthode -->
346
+ <cancel_url>hipay/ideal/cancel</cancel_url><!-- Url cancel de la méthode -->
347
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
348
+ </hipay_ideal>
349
+ <hipay_ing>
350
+ <active>0</active> <!-- Activé ou non -->
351
+ <title>HiPay ING Home'Pay</title> <!-- Titre par défaut modifiable en admin -->
352
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
353
+ <cctypes>ing-homepay</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
354
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
355
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
356
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
357
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
358
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
359
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
360
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
361
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
362
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
363
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
364
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
365
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
366
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
367
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
368
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
369
+ <model>hipay/method_ing</model><!-- Classe model de la méthode -->
370
+ <accept_url>hipay/ing/accept</accept_url><!-- Url accept de la méthode -->
371
+ <pending_url>hipay/ing/pending</pending_url><!-- Url pending de la méthode -->
372
+ <decline_url>hipay/ing/decline</decline_url><!-- Url decline de la méthode -->
373
+ <exception_url>hipay/ing/exception</exception_url><!-- Url execption de la méthode -->
374
+ <cancel_url>hipay/ing/cancel</cancel_url><!-- Url cancel de la méthode -->
375
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
376
+ </hipay_ing>
377
+ <hipay_dexia>
378
+ <active>0</active> <!-- Activé ou non -->
379
+ <title>HiPay Belfius / Dexia Direct Net</title> <!-- Titre par défaut modifiable en admin -->
380
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
381
+ <cctypes>dexia-directnet</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
382
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
383
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
384
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
385
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
386
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
387
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
388
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
389
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
390
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
391
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
392
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
393
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
394
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
395
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
396
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
397
+ <model>hipay/method_dexia</model><!-- Classe model de la méthode -->
398
+ <accept_url>hipay/dexia/accept</accept_url><!-- Url accept de la méthode -->
399
+ <pending_url>hipay/dexia/pending</pending_url><!-- Url pending de la méthode -->
400
+ <decline_url>hipay/dexia/decline</decline_url><!-- Url decline de la méthode -->
401
+ <exception_url>hipay/dexia/exception</exception_url><!-- Url execption de la méthode -->
402
+ <cancel_url>hipay/dexia/cancel</cancel_url><!-- Url cancel de la méthode -->
403
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
404
+ </hipay_dexia>
405
+ <hipay_cbc>
406
+ <active>0</active> <!-- Activé ou non -->
407
+ <title>HiPay CBC Online</title> <!-- Titre par défaut modifiable en admin -->
408
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
409
+ <cctypes>cbc-online</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
410
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
411
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
412
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
413
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
414
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
415
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
416
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
417
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
418
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
419
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
420
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
421
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
422
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
423
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
424
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
425
+ <model>hipay/method_cbc</model><!-- Classe model de la méthode -->
426
+ <accept_url>hipay/cbc/accept</accept_url><!-- Url accept de la méthode -->
427
+ <pending_url>hipay/cbc/pending</pending_url><!-- Url pending de la méthode -->
428
+ <decline_url>hipay/cbc/decline</decline_url><!-- Url decline de la méthode -->
429
+ <exception_url>hipay/cbc/exception</exception_url><!-- Url execption de la méthode -->
430
+ <cancel_url>hipay/cbc/cancel</cancel_url><!-- Url cancel de la méthode -->
431
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
432
+ </hipay_cbc>
433
+ <hipay_kbc>
434
+ <active>0</active> <!-- Activé ou non -->
435
+ <title>HiPay KBC Online</title> <!-- Titre par défaut modifiable en admin -->
436
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
437
+ <cctypes>kbc-online</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
438
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
439
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
440
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
441
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
442
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
443
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
444
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
445
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
446
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
447
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
448
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
449
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
450
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
451
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
452
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
453
+ <model>hipay/method_kbc</model><!-- Classe model de la méthode -->
454
+ <accept_url>hipay/kbc/accept</accept_url><!-- Url accept de la méthode -->
455
+ <pending_url>hipay/kbc/pending</pending_url><!-- Url pending de la méthode -->
456
+ <decline_url>hipay/kbc/decline</decline_url><!-- Url decline de la méthode -->
457
+ <exception_url>hipay/kbc/exception</exception_url><!-- Url execption de la méthode -->
458
+ <cancel_url>hipay/kbc/cancel</cancel_url><!-- Url cancel de la méthode -->
459
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
460
+ </hipay_kbc>
461
+ <hipay_giropay>
462
+ <active>0</active> <!-- Activé ou non -->
463
+ <title>HiPay Giropay</title> <!-- Titre par défaut modifiable en admin -->
464
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
465
+ <cctypes>giropay</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
466
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
467
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
468
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
469
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
470
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
471
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
472
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
473
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
474
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
475
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
476
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
477
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
478
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
479
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
480
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
481
+ <model>hipay/method_giropay</model><!-- Classe model de la méthode -->
482
+ <accept_url>hipay/giropay/accept</accept_url><!-- Url accept de la méthode -->
483
+ <pending_url>hipay/giropay/pending</pending_url><!-- Url pending de la méthode -->
484
+ <decline_url>hipay/giropay/decline</decline_url><!-- Url decline de la méthode -->
485
+ <exception_url>hipay/giropay/exception</exception_url><!-- Url execption de la méthode -->
486
+ <cancel_url>hipay/giropay/cancel</cancel_url><!-- Url cancel de la méthode -->
487
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
488
+ </hipay_giropay>
489
+ <hipay_przelewy24api>
490
+ <active>0</active> <!-- Activé ou non -->
491
+ <title>HiPay Przelewy24</title> <!-- Titre par défaut modifiable en admin -->
492
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
493
+ <cctypes>przelewy24</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
494
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
495
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
496
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
497
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
498
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
499
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
500
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
501
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
502
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
503
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
504
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
505
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
506
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
507
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
508
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
509
+ <model>hipay/method_przelewy24Api</model><!-- Classe model de la méthode -->
510
+ <accept_url>hipay/przelewy24api/accept</accept_url><!-- Url accept de la méthode -->
511
+ <pending_url>hipay/przelewy24api/pending</pending_url><!-- Url pending de la méthode -->
512
+ <decline_url>hipay/przelewy24api/decline</decline_url><!-- Url decline de la méthode -->
513
+ <exception_url>hipay/przelewy24api/exception</exception_url><!-- Url execption de la méthode -->
514
+ <cancel_url>hipay/przelewy24api/cancel</cancel_url><!-- Url cancel de la méthode -->
515
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
516
+ </hipay_przelewy24api>
517
+ <hipay_sisalapi>
518
+ <active>0</active> <!-- Activé ou non -->
519
+ <title>HiPay Sisal</title> <!-- Titre par défaut modifiable en admin -->
520
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
521
+ <cctypes>sisal</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
522
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
523
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
524
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
525
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
526
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
527
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
528
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
529
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
530
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
531
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
532
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
533
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
534
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
535
+ <model>hipay/method_sisalApi</model><!-- Classe model de la méthode -->
536
+ <accept_url>hipay/sisalapi/accept</accept_url><!-- Url accept de la méthode -->
537
+ <pending_url>hipay/sisalapi/pending</pending_url><!-- Url pending de la méthode -->
538
+ <decline_url>hipay/sisalapi/decline</decline_url><!-- Url decline de la méthode -->
539
+ <exception_url>hipay/sisalapi/exception</exception_url><!-- Url execption de la méthode -->
540
+ <cancel_url>hipay/sisalapi/cancel</cancel_url><!-- Url cancel de la méthode -->
541
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
542
+ </hipay_sisalapi>
543
+ <hipay_qiwi>
544
+ <active>0</active> <!-- Activé ou non -->
545
+ <title>HiPay Visa Qiwi Wallet</title> <!-- Titre par défaut modifiable en admin -->
546
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
547
+ <cctypes>qiwi-wallet</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
548
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
549
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
550
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
551
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
552
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
553
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
554
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
555
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
556
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
557
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
558
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
559
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
560
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
561
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
562
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
563
+ <model>hipay/method_qiwi</model><!-- Classe model de la méthode -->
564
+ <accept_url>hipay/qiwi/accept</accept_url><!-- Url accept de la méthode -->
565
+ <pending_url>hipay/qiwi/pending</pending_url><!-- Url pending de la méthode -->
566
+ <decline_url>hipay/qiwi/decline</decline_url><!-- Url decline de la méthode -->
567
+ <exception_url>hipay/qiwi/exception</exception_url><!-- Url execption de la méthode -->
568
+ <cancel_url>hipay/qiwi/cancel</cancel_url><!-- Url cancel de la méthode -->
569
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
570
+ </hipay_qiwi>
571
+ <hipay_webmoneyapi>
572
+ <active>0</active> <!-- Activé ou non -->
573
+ <title>HiPay WebMoney Transfer</title> <!-- Titre par défaut modifiable en admin -->
574
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
575
+ <cctypes>webmoney-transfer</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
576
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
577
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
578
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
579
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
580
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
581
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
582
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
583
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
584
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
585
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
586
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
587
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
588
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
589
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
590
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
591
+ <model>hipay/method_webmoneyApi</model><!-- Classe model de la méthode -->
592
+ <accept_url>hipay/webmoneyapi/accept</accept_url><!-- Url accept de la méthode -->
593
+ <pending_url>hipay/webmoneyapi/pending</pending_url><!-- Url pending de la méthode -->
594
+ <decline_url>hipay/webmoneyapi/decline</decline_url><!-- Url decline de la méthode -->
595
+ <exception_url>hipay/webmoneyapi/exception</exception_url><!-- Url execption de la méthode -->
596
+ <cancel_url>hipay/webmoneyapi/cancel</cancel_url><!-- Url cancel de la méthode -->
597
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
598
+ </hipay_webmoneyapi>
599
+ <hipay_yandexapi>
600
+ <active>0</active> <!-- Activé ou non -->
601
+ <title>HiPay Yandex.Money</title> <!-- Titre par défaut modifiable en admin -->
602
+ <payment_action>authorize_capture</payment_action> <!-- Type d'action de paiement (authorize_capture ou authorize) -->
603
+ <cctypes>yandex</cctypes> <!-- Types de carte disponibles (valeur Hipay pour le mode hosted, valeur Magento pour le mode API) -->
604
+ <!-- <useccv>1</useccv> --> <!-- permet de rendre obligatoire la saisie du CCV (uniquement en mode API) -->
605
+ <order_status_payment_accepted>processing</order_status_payment_accepted><!-- valeur par défaut du statut quand le paiement est accepté -->
606
+ <order_status_payment_refused>canceled</order_status_payment_refused><!-- valeur par défaut du statut quand le paiement est refusé -->
607
+ <order_status_payment_canceled>canceled</order_status_payment_canceled><!-- valeur par défaut du statut quand le paiement est annulé -->
608
+ <hipay_status_validate_order>118</hipay_status_validate_order><!-- valeur par défaut du statut hipay qui valide la commande (118 ou 117)-->
609
+ <pending_redirect_page>hipay/checkout/pending</pending_redirect_page><!-- valeur par défaut pour la page de redirection en cas de state "pending"-->
610
+ <display_selector>0</display_selector><!-- valeur par défaut l'affichage du selecteur de carte (uniquement en mode Hosted)-->
611
+ <template>basic</template><!-- valeur par défaut du template de la page hénergé (uniquement en mode Hosted)-->
612
+ <allow_use_oneclick>0</allow_use_oneclick><!-- valeur par défaut de l'utilisation du oneclick -->
613
+ <invoice_create>1</invoice_create><!-- valeur par défaut de la création de la facture -->
614
+ <re_add_to_cart>0</re_add_to_cart><!-- valeur par défaut du re-remplissage du panier -->
615
+ <cancel_pending_order>1</cancel_pending_order><!-- valeur par défaut des annulation de commande "en attente" depuis 30 minutes -->
616
+ <display_iframe>0</display_iframe><!-- valeur par défaut mode Iframe (uniquement en mode Hosted)-->
617
+ <is_test_mode>0</is_test_mode><!-- valeur par défaut du mode test -->
618
+ <debug>0</debug><!-- valeur par défaut du mode debug -->
619
+ <model>hipay/method_yandexApi</model><!-- Classe model de la méthode -->
620
+ <accept_url>hipay/yandexapi/accept</accept_url><!-- Url accept de la méthode -->
621
+ <pending_url>hipay/yandexapi/pending</pending_url><!-- Url pending de la méthode -->
622
+ <decline_url>hipay/yandexapi/decline</decline_url><!-- Url decline de la méthode -->
623
+ <exception_url>hipay/yandexapi/exception</exception_url><!-- Url execption de la méthode -->
624
+ <cancel_url>hipay/yandexapi/cancel</cancel_url><!-- Url cancel de la méthode -->
625
+ <use_3d_secure>0</use_3d_secure><!-- valeur par défaut pour activer le 3ds -->
626
+ </hipay_yandexapi>
627
+ </payment>
628
+ </default>
629
+ <crontab>
630
+ <jobs>
631
+ <clean_orders_hipay_in_pending>
632
+ <schedule><cron_expr>*/15 * * * *</cron_expr></schedule>
633
+ <run><model>hipay/observer::cancelOrdersInPending</model></run>
634
+ </clean_orders_hipay_in_pending>
635
+ </jobs>
636
+ </crontab>
637
+ </config>
app/code/community/Allopass/Hipay/etc/system.xml ADDED
@@ -0,0 +1,2586 @@