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
- app/code/community/Allopass/Hipay/.DS_Store +0 -0
- app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/3dsRule.php +44 -0
- app/code/community/Allopass/Hipay/Block/Checkout/Pending.php +30 -0
- app/code/community/Allopass/Hipay/Block/Form/Abstract.php +74 -0
- app/code/community/Allopass/Hipay/Block/Form/Cc.php +113 -0
- app/code/community/Allopass/Hipay/Block/Form/Hosted.php +10 -0
- app/code/community/Allopass/Hipay/Block/Info/Cc.php +103 -0
- app/code/community/Allopass/Hipay/Block/Info/Hosted.php +9 -0
- app/code/community/Allopass/Hipay/Controller/Payment.php +271 -0
- app/code/community/Allopass/Hipay/Helper/Data.php +203 -0
- app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Curl.php +483 -0
- app/code/community/Allopass/Hipay/Model/Api/Http/Client/Adapter/Stream.php +20 -0
- app/code/community/Allopass/Hipay/Model/Api/Request.php +219 -0
- app/code/community/Allopass/Hipay/Model/Api/Response/Abstract.php +17 -0
- app/code/community/Allopass/Hipay/Model/Api/Response/Error.php +12 -0
- app/code/community/Allopass/Hipay/Model/Api/Response/Gateway.php +114 -0
- app/code/community/Allopass/Hipay/Model/Api/Response/Notification.php +33 -0
- app/code/community/Allopass/Hipay/Model/Api/Response/Vault.php +9 -0
- app/code/community/Allopass/Hipay/Model/Config.php +234 -0
- app/code/community/Allopass/Hipay/Model/Log/Adapter.php +118 -0
- app/code/community/Allopass/Hipay/Model/Method/Abstract.php +1003 -0
- app/code/community/Allopass/Hipay/Model/Method/Cbc.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Cc.php +517 -0
- app/code/community/Allopass/Hipay/Model/Method/Dexia.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Giropay.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Hosted.php +118 -0
- app/code/community/Allopass/Hipay/Model/Method/Ideal.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Ing.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Kbc.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Przelewy24.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Przelewy24Api.php +83 -0
- app/code/community/Allopass/Hipay/Model/Method/Qiwi.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/Sisal.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/SisalApi.php +83 -0
- app/code/community/Allopass/Hipay/Model/Method/Sofort.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/SofortApi.php +83 -0
- app/code/community/Allopass/Hipay/Model/Method/Webmoney.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/WebmoneyApi.php +83 -0
- app/code/community/Allopass/Hipay/Model/Method/Yandex.php +5 -0
- app/code/community/Allopass/Hipay/Model/Method/YandexApi.php +83 -0
- app/code/community/Allopass/Hipay/Model/Observer.php +96 -0
- app/code/community/Allopass/Hipay/Model/Resource/Rule.php +19 -0
- app/code/community/Allopass/Hipay/Model/Resource/Rule/Collection.php +20 -0
- app/code/community/Allopass/Hipay/Model/Rule.php +44 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Address.php +231 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Combine.php +183 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Customer.php +186 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Product.php +128 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Combine.php +172 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Found.php +70 -0
- app/code/community/Allopass/Hipay/Model/Rule/Condition/Product/Subselect.php +102 -0
- app/code/community/Allopass/Hipay/Model/Rule/Config.php +93 -0
- app/code/community/Allopass/Hipay/Model/Source/3ds.php +39 -0
- app/code/community/Allopass/Hipay/Model/Source/CcType.php +24 -0
- app/code/community/Allopass/Hipay/Model/Source/CcTypeHosted.php +24 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/HipayStatusValidate.php +20 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/Status.php +28 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/Status/Accepted.php +12 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/Status/Canceled.php +11 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/Status/New.php +11 -0
- app/code/community/Allopass/Hipay/Model/Source/Order/Status/Refused.php +12 -0
- app/code/community/Allopass/Hipay/Model/Source/PaymentAction.php +17 -0
- app/code/community/Allopass/Hipay/Model/Source/Pendingredirect.php +19 -0
- app/code/community/Allopass/Hipay/Model/Source/Template.php +35 -0
- app/code/community/Allopass/Hipay/controllers/Adminhtml/RuleController.php +37 -0
- app/code/community/Allopass/Hipay/controllers/CbcController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/CcController.php +15 -0
- app/code/community/Allopass/Hipay/controllers/CheckoutController.php +40 -0
- app/code/community/Allopass/Hipay/controllers/DexiaController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/GiropayController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/HostedController.php +12 -0
- app/code/community/Allopass/Hipay/controllers/IdealController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/IngController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/KbcController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/NotifyController.php +193 -0
- app/code/community/Allopass/Hipay/controllers/Przelewy24Controller.php +8 -0
- app/code/community/Allopass/Hipay/controllers/Przelewy24apiController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/QiwiController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/SisalController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/SisalapiController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/SofortController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/SofortapiController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/WebmoneyController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/WebmoneyapiController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/YandexController.php +8 -0
- app/code/community/Allopass/Hipay/controllers/YandexapiController.php +8 -0
- app/code/community/Allopass/Hipay/etc/config.xml +637 -0
- app/code/community/Allopass/Hipay/etc/system.xml +2586 -0
- app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-install-0.1.0.php +45 -0
- app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.0-0.1.1.php +123 -0
- app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.1-0.1.2.php +38 -0
- app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.2-0.1.3.php +72 -0
- app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-0.1.4-0.1.5.php +24 -0
- app/design/adminhtml/default/default/layout/hipay.xml +12 -0
- app/design/adminhtml/default/default/template/hipay/system/config/form/field/rules.phtml +17 -0
- app/design/frontend/default/default/layout/hipay.xml +12 -0
- app/design/frontend/default/default/template/hipay/checkout/pending.phtml +8 -0
- app/design/frontend/default/default/template/hipay/form/cc.phtml +144 -0
- app/design/frontend/default/default/template/hipay/form/hosted.phtml +134 -0
- app/etc/modules/Allopass_Hipay.xml +9 -0
- app/locale/en_US/Allopass_Hipay.csv +107 -0
- app/locale/fr_FR/Allopass_Hipay.csv +107 -0
- package.xml +18 -0
- 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 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|