Version Notes
ServerResult action exception message included in the Message response variable
Download this release
Release Info
Developer | Magento Core Team |
Extension | Cardsave_Cardsaveonlinepayments |
Version | 1.7.2 |
Comparing to | |
See all releases |
Version 1.7.2
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Error.php +6 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Form.php +127 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Info.php +36 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Redirect.php +267 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Threedsecure.php +37 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Helper/Data.php +6 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php +881 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Request.php +22 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php +33 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/OrderStatus.php +15 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentAction.php +15 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentMode.php +28 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/ResultDeliveryMethod.php +23 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/GlobalErrors.php +24 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ISOCountries.php +265 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ISOCurrencies.php +199 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/PaymentFormHelper.php +447 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/PaymentSystem.php +2400 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/SOAP.php +968 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/TPG_Common.php +882 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/controllers/PaymentController.php +488 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/etc/config.xml +102 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/etc/system.xml +226 -0
- app/code/local/Cardsave/Checkout/Block/Onepage/Payment/Methods.php +38 -0
- app/code/local/Cardsave/Checkout/Model/Type/Onepage.php +563 -0
- app/code/local/Cardsave/Checkout/etc/config.xml +24 -0
- app/code/local/Cardsave/Sales/Model/Order.php +32 -0
- app/code/local/Cardsave/Sales/Model/Order/Invoice.php +20 -0
- app/code/local/Cardsave/Sales/etc/config.xml +18 -0
- app/design/adminhtml/default/default/template/cardsaveonlinepayments/form.phtml +86 -0
- app/design/adminhtml/default/default/template/cardsaveonlinepayments/info.phtml +18 -0
- app/design/frontend/default/default/template/cardsaveonlinepayments/form.phtml +92 -0
- app/design/frontend/default/default/template/cardsaveonlinepayments/info.phtml +17 -0
- app/etc/modules/Cardsave_All.xml +19 -0
- package.xml +18 -0
- skin/frontend/default/default/images/cardsave_online.jpg +0 -0
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Error.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Block_Error extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Form.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Cardsave_Cardsaveonlinepayments_Block_Form extends Mage_Payment_Block_Form
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('cardsaveonlinepayments/form.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
protected function _getConfig()
|
11 |
+
{
|
12 |
+
return Mage::getSingleton('payment/config');
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Returns an array of credit card expiry months
|
17 |
+
*
|
18 |
+
* @return unknown
|
19 |
+
*/
|
20 |
+
public function getCcMonths()
|
21 |
+
{
|
22 |
+
$months = $this->getData('cc_months');
|
23 |
+
|
24 |
+
if (is_null($months))
|
25 |
+
{
|
26 |
+
$months = array();
|
27 |
+
$monthList = $this->_getConfig()->getMonths();
|
28 |
+
|
29 |
+
$months[0] = $this->__('Month');
|
30 |
+
for ($nCount = 1; $nCount <= sizeof($monthList); $nCount++)
|
31 |
+
{
|
32 |
+
$value = $nCount;
|
33 |
+
if($value < 10)
|
34 |
+
{
|
35 |
+
$value = '0'.$value;
|
36 |
+
}
|
37 |
+
$months[$value] = $monthList[$nCount];
|
38 |
+
}
|
39 |
+
|
40 |
+
$this->setData('cc_months', $months);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $months;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Returns an array of credit card expiry years
|
48 |
+
*
|
49 |
+
* @return unknown
|
50 |
+
*/
|
51 |
+
public function getCcYears()
|
52 |
+
{
|
53 |
+
$years = $this->getData('cc_years');
|
54 |
+
|
55 |
+
if (is_null($years))
|
56 |
+
{
|
57 |
+
$years = array();
|
58 |
+
$first = date("Y");
|
59 |
+
|
60 |
+
$years = array($this->__('Year'));
|
61 |
+
for ($index = 0; $index < 10; $index++)
|
62 |
+
{
|
63 |
+
$year = $first + $index;
|
64 |
+
$yearPartial = substr($year, 2);
|
65 |
+
$years[$yearPartial] = $year;
|
66 |
+
}
|
67 |
+
$this->setData('cc_years', $years);
|
68 |
+
}
|
69 |
+
|
70 |
+
return $years;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Returns an array credit card start months
|
75 |
+
*
|
76 |
+
* @return unknown
|
77 |
+
*/
|
78 |
+
public function getCcStartMonths()
|
79 |
+
{
|
80 |
+
$months = $this->getData('cc_ss_start_month');
|
81 |
+
|
82 |
+
if (is_null($months))
|
83 |
+
{
|
84 |
+
$months = array();
|
85 |
+
$monthList = $this->_getConfig()->getMonths();
|
86 |
+
|
87 |
+
for ($nCount = 1; $nCount <= sizeof($monthList); $nCount++)
|
88 |
+
{
|
89 |
+
$value = $nCount;
|
90 |
+
if($value < 10)
|
91 |
+
{
|
92 |
+
$value = '0'.$value;
|
93 |
+
}
|
94 |
+
$months[$value] = $monthList[$nCount];
|
95 |
+
}
|
96 |
+
$this->setData('cc_ss_start_month', $months);
|
97 |
+
}
|
98 |
+
|
99 |
+
return $months;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Returns an array of credit card start years
|
104 |
+
*
|
105 |
+
* @return unknown
|
106 |
+
*/
|
107 |
+
public function getCcStartYears()
|
108 |
+
{
|
109 |
+
$years = $this->getData('cc_start_years');
|
110 |
+
|
111 |
+
if(is_null($years))
|
112 |
+
{
|
113 |
+
$years = array();
|
114 |
+
$first = date("Y");
|
115 |
+
|
116 |
+
for ($index = 0; $index < 10; $index++)
|
117 |
+
{
|
118 |
+
$year = $first - $index;
|
119 |
+
$yearPartial = substr($year, 2);
|
120 |
+
$years[$yearPartial] = $year;
|
121 |
+
}
|
122 |
+
$this->setData('cc_start_years', $years);
|
123 |
+
}
|
124 |
+
|
125 |
+
return $years;
|
126 |
+
}
|
127 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Info.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Block_Info extends Mage_Payment_Block_Info
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Init default template for block
|
7 |
+
*/
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
parent::_construct();
|
11 |
+
$this->setTemplate('cardsaveonlinepayments/info.phtml');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getCcNumber()
|
15 |
+
{
|
16 |
+
return $this->getInfo()->decrypt($this->getInfo()->getCcNumberEnc());
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getCcCid()
|
20 |
+
{
|
21 |
+
return $this->getInfo()->decrypt($this->getInfo()->getCcCidEnc());
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Retrieve CC expiration date
|
26 |
+
*
|
27 |
+
* @return Zend_Date
|
28 |
+
*/
|
29 |
+
public function getCcExpDate()
|
30 |
+
{
|
31 |
+
$date = Mage::app()->getLocale()->date(0);
|
32 |
+
$date->setYear($this->getInfo()->getCcExpYear());
|
33 |
+
$date->setMonth($this->getInfo()->getCcExpMonth());
|
34 |
+
return $date;
|
35 |
+
}
|
36 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Redirect.php
ADDED
@@ -0,0 +1,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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Block_Redirect extends Mage_Core_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Build the redirect form to be submitted to the hosted payment form or the transparent redirect page
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _toHtml()
|
10 |
+
{
|
11 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
12 |
+
$pmPaymentMode = $model->getConfigData('mode');
|
13 |
+
|
14 |
+
switch ($pmPaymentMode)
|
15 |
+
{
|
16 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
|
17 |
+
$html = self::_redirectToHostedPaymentForm();
|
18 |
+
break;
|
19 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
|
20 |
+
$html = self::_redirectToTransparentRedirect();
|
21 |
+
break;
|
22 |
+
}
|
23 |
+
|
24 |
+
return $html;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Build the redirect form for the Hosted Payment Form payment type
|
29 |
+
*
|
30 |
+
* @return unknown
|
31 |
+
*/
|
32 |
+
private function _redirectToHostedPaymentForm()
|
33 |
+
{
|
34 |
+
$html = '';
|
35 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
36 |
+
$szActionURL = $model->getConfigData('hostedpaymentactionurl');
|
37 |
+
$cookies = Mage::getSingleton('core/cookie')->get();
|
38 |
+
$szServerResultURLCookieVariables;
|
39 |
+
$szServerResultURLFormVariables = '';
|
40 |
+
$szServerResultURLQueryStringVariables = '';
|
41 |
+
|
42 |
+
// create a Magento form
|
43 |
+
$form = new Varien_Data_Form();
|
44 |
+
$form->setAction($szActionURL)
|
45 |
+
->setId('HostedPaymentForm')
|
46 |
+
->setName('HostedPaymentForm')
|
47 |
+
->setMethod('POST')
|
48 |
+
->setUseContainer(true);
|
49 |
+
|
50 |
+
$form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
|
51 |
+
$form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
|
52 |
+
$form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
|
53 |
+
$form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
|
54 |
+
$form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
|
55 |
+
$form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
|
56 |
+
$form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
|
57 |
+
$form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
|
58 |
+
$form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
|
59 |
+
$form->addField("CustomerName", 'hidden', array('name'=>"CustomerName", 'value'=>Mage::getSingleton('checkout/session')->getCustomername()));
|
60 |
+
$form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
|
61 |
+
$form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
|
62 |
+
$form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
|
63 |
+
$form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
|
64 |
+
$form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
|
65 |
+
$form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
|
66 |
+
$form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
|
67 |
+
$form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
|
68 |
+
$form->addField("CV2Mandatory", 'hidden', array('name'=>"CV2Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getCv2mandatory()));
|
69 |
+
$form->addField("Address1Mandatory", 'hidden', array('name'=>"Address1Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getAddress1mandatory()));
|
70 |
+
$form->addField("CityMandatory", 'hidden', array('name'=>"CityMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCitymandatory()));
|
71 |
+
$form->addField("PostCodeMandatory", 'hidden', array('name'=>"PostCodeMandatory", 'value'=>Mage::getSingleton('checkout/session')->getPostcodemandatory()));
|
72 |
+
$form->addField("StateMandatory", 'hidden', array('name'=>"StateMandatory", 'value'=>Mage::getSingleton('checkout/session')->getStatemandatory()));
|
73 |
+
$form->addField("CountryMandatory", 'hidden', array('name'=>"CountryMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCountrymandatory()));
|
74 |
+
$form->addField("ResultDeliveryMethod", 'hidden', array('name'=>"ResultDeliveryMethod", 'value'=>Mage::getSingleton('checkout/session')->getResultdeliverymethod()));
|
75 |
+
$form->addField("ServerResultURL", 'hidden', array('name'=>"ServerResultURL", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturl()));
|
76 |
+
$form->addField("PaymentFormDisplaysResult", 'hidden', array('name'=>"PaymentFormDisplaysResult", 'value'=>Mage::getSingleton('checkout/session')->getPaymentformdisplaysresult()));
|
77 |
+
$form->addField("ServerResultURLCookieVariables", 'hidden', array('name'=>"ServerResultURLCookieVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlcookievariables()));
|
78 |
+
$form->addField("ServerResultURLFormVariables", 'hidden', array('name'=>"ServerResultURLFormVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlformvariables()));
|
79 |
+
$form->addField("ServerResultURLQueryStringVariables", 'hidden', array('name'=>"ServerResultURLQueryStringVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlquerystringvariables()));
|
80 |
+
|
81 |
+
// reset the session items
|
82 |
+
Mage::getSingleton('checkout/session')->setHashdigest(null)
|
83 |
+
->setMerchantid(null)
|
84 |
+
->setAmount(null)
|
85 |
+
->setCurrencycode(null)
|
86 |
+
->setOrderid(null)
|
87 |
+
->setTransactiontype(null)
|
88 |
+
->setTransactiondatetime(null)
|
89 |
+
->setCallbackurl(null)
|
90 |
+
->setOrderdescription(null)
|
91 |
+
->setCustomername(null)
|
92 |
+
->setAddress1(null)
|
93 |
+
->setAddress2(null)
|
94 |
+
->setAddress3(null)
|
95 |
+
->setAddress4(null)
|
96 |
+
->setCity(null)
|
97 |
+
->setState(null)
|
98 |
+
->setPostcode(null)
|
99 |
+
->setCountrycode(null)
|
100 |
+
->setCv2mandatory(null)
|
101 |
+
->setAddress1mandatory(null)
|
102 |
+
->setCitymandatory(null)
|
103 |
+
->setPostcodemandatory(null)
|
104 |
+
->setStatemandatory(null)
|
105 |
+
->setCountrymandatory(null)
|
106 |
+
->setResultdeliverymethod(null)
|
107 |
+
->setServerresulturl(null)
|
108 |
+
->setPaymentformdisplaysresult(null)
|
109 |
+
->setServerresulturlcookievariables(null)
|
110 |
+
->setServerresulturlformvariables(null)
|
111 |
+
->setServerresulturlquerystringvariables(null);
|
112 |
+
|
113 |
+
$html = '<html><body>';
|
114 |
+
$html.= $this->__('You will be redirected to a secure payment page in a few seconds.');
|
115 |
+
$html.= $form->toHtml();
|
116 |
+
$html.= '<script type="text/javascript">document.getElementById("HostedPaymentForm").submit();</script>';
|
117 |
+
$html.= '</body></html>';
|
118 |
+
|
119 |
+
return $html;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Build the redirect form for the Transparent Redirect payment type
|
124 |
+
*
|
125 |
+
* @return unknown
|
126 |
+
*/
|
127 |
+
private function _redirectToTransparentRedirect()
|
128 |
+
{
|
129 |
+
$html;
|
130 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
131 |
+
$szActionURL = $model->getConfigData('transparentredirectactionurl');
|
132 |
+
$szPaRes = Mage::getSingleton('checkout/session')->getPares();
|
133 |
+
|
134 |
+
if(isset($szPaRes))
|
135 |
+
{
|
136 |
+
$html = self::_submitPaRes($szActionURL);
|
137 |
+
}
|
138 |
+
else
|
139 |
+
{
|
140 |
+
$html = self::_submitTransaction($szActionURL);
|
141 |
+
}
|
142 |
+
|
143 |
+
return $html;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Build the submit form for Transparent redirect payment type
|
148 |
+
*
|
149 |
+
* @param unknown_type $szActionURL
|
150 |
+
* @return unknown
|
151 |
+
*/
|
152 |
+
private function _submitTransaction($szActionURL)
|
153 |
+
{
|
154 |
+
$html = '';
|
155 |
+
|
156 |
+
// create a Magento form
|
157 |
+
$form = new Varien_Data_Form();
|
158 |
+
$form->setAction($szActionURL)
|
159 |
+
->setId('TransparentRedirectForm')
|
160 |
+
->setName('TransparentRedirectForm')
|
161 |
+
->setMethod('POST')
|
162 |
+
->setUseContainer(true);
|
163 |
+
|
164 |
+
$form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
|
165 |
+
$form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
|
166 |
+
$form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
|
167 |
+
$form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
|
168 |
+
$form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
|
169 |
+
$form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
|
170 |
+
$form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
|
171 |
+
$form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
|
172 |
+
$form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
|
173 |
+
$form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
|
174 |
+
$form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
|
175 |
+
$form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
|
176 |
+
$form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
|
177 |
+
$form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
|
178 |
+
$form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
|
179 |
+
$form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
|
180 |
+
$form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
|
181 |
+
$form->addField("CardName", 'hidden', array('name'=>"CardName", 'value'=>Mage::getSingleton('checkout/session')->getCardname()));
|
182 |
+
$form->addField("CardNumber", 'hidden', array('name'=>"CardNumber", 'value'=>Mage::getSingleton('checkout/session')->getCardnumber()));
|
183 |
+
$form->addField("ExpiryDateMonth", 'hidden', array('name'=>"ExpiryDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getExpirydatemonth()));
|
184 |
+
$form->addField("ExpiryDateYear", 'hidden', array('name'=>"ExpiryDateYear", 'value'=>Mage::getSingleton('checkout/session')->getExpirydateyear()));
|
185 |
+
$form->addField("StartDateMonth", 'hidden', array('name'=>"StartDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getStartdatemonth()));
|
186 |
+
$form->addField("StartDateYear", 'hidden', array('name'=>"StartDateYear", 'value'=>Mage::getSingleton('checkout/session')->getStartdateyear()));
|
187 |
+
$form->addField("IssueNumber", 'hidden', array('name'=>"IssueNumber", 'value'=>Mage::getSingleton('checkout/session')->getIssuenumber()));
|
188 |
+
$form->addField("CV2", 'hidden', array('name'=>"CV2", 'value'=>Mage::getSingleton('checkout/session')->getCv2()));
|
189 |
+
|
190 |
+
// reset the session items
|
191 |
+
Mage::getSingleton('checkout/session')->setHashdigest(null)
|
192 |
+
->setMerchantid(null)
|
193 |
+
->setAmount(null)
|
194 |
+
->setCurrencycode(null)
|
195 |
+
->setOrderid(null)
|
196 |
+
->setTransactiontype(null)
|
197 |
+
->setTransactiondatetime(null)
|
198 |
+
->setCallbackurl(null)
|
199 |
+
->setOrderdescription(null)
|
200 |
+
->setAddress1(null)
|
201 |
+
->setAddress2(null)
|
202 |
+
->setAddress3(null)
|
203 |
+
->setAddress4(null)
|
204 |
+
->setCity(null)
|
205 |
+
->setState(null)
|
206 |
+
->setPostcode(null)
|
207 |
+
->setCountrycode(null)
|
208 |
+
->setCardname(null)
|
209 |
+
->setCardnumber(null)
|
210 |
+
->setExpirydatemonth(null)
|
211 |
+
->setExpirydateyear(null)
|
212 |
+
->setStartdatemonth(null)
|
213 |
+
->setStartdateyear(null)
|
214 |
+
->setIssuenumber(null)
|
215 |
+
->setCv2(null);
|
216 |
+
|
217 |
+
|
218 |
+
$html = '<html><body>';
|
219 |
+
$html.= $form->toHtml();
|
220 |
+
$html.= '<script type="text/javascript">document.getElementById("TransparentRedirectForm").submit();</script>';
|
221 |
+
$html.= '</body></html>';
|
222 |
+
|
223 |
+
return $html;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Build the form for the Transparent Redirect 3DSecure authentication payment
|
228 |
+
*
|
229 |
+
* @param unknown_type $szActionURL
|
230 |
+
* @return unknown
|
231 |
+
*/
|
232 |
+
private function _submitPaRes($szActionURL)
|
233 |
+
{
|
234 |
+
$html = '';
|
235 |
+
|
236 |
+
// create a Magento form
|
237 |
+
$form = new Varien_Data_Form();
|
238 |
+
$form->setAction($szActionURL)
|
239 |
+
->setId('SubmitPaResForm')
|
240 |
+
->setName('SubmitPaResForm')
|
241 |
+
->setMethod('POST')
|
242 |
+
->setUseContainer(true);
|
243 |
+
|
244 |
+
$form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
|
245 |
+
$form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
|
246 |
+
$form->addField("CrossReference", 'hidden', array('name'=>"CrossReference", 'value'=>Mage::getSingleton('checkout/session')->getCrossreference()));
|
247 |
+
$form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
|
248 |
+
$form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
|
249 |
+
$form->addField("PaRES", 'hidden', array('name'=>"PaRES", 'value'=>Mage::getSingleton('checkout/session')->getPares()));
|
250 |
+
|
251 |
+
// reset the session items
|
252 |
+
Mage::getSingleton('checkout/session')->setHashdigest(null)
|
253 |
+
->setMerchantid(null)
|
254 |
+
->setCrossreference(null)
|
255 |
+
->setTransactiondatetime(null)
|
256 |
+
->setCallbackurl(null)
|
257 |
+
->setPares(null);
|
258 |
+
|
259 |
+
|
260 |
+
$html = '<html><body>';
|
261 |
+
$html.= $form->toHtml();
|
262 |
+
$html.= '<script type="text/javascript">document.getElementById("SubmitPaResForm").submit();</script>';
|
263 |
+
$html.= '</body></html>';
|
264 |
+
|
265 |
+
return $html;
|
266 |
+
}
|
267 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Threedsecure.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Block_Threedsecure extends Mage_Core_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Build the 3D Secure form to be submitted to the redirect 3D Secure authorization page
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _toHtml()
|
10 |
+
{
|
11 |
+
$szTermURL = 'cardsaveonlinepayments/payment/callback3d';
|
12 |
+
|
13 |
+
$form = new Varien_Data_Form();
|
14 |
+
$form->setAction(Mage::getSingleton('checkout/session')->getAcsurl())
|
15 |
+
->setId('ThreeDSecureForm')
|
16 |
+
->setName('ThreeDSecureForm')
|
17 |
+
->setMethod('POST')
|
18 |
+
->setUseContainer(true);
|
19 |
+
|
20 |
+
$form->addField("PaReq", 'hidden', array('name'=>"PaReq", 'value'=>Mage::getSingleton('checkout/session')->getPareq()));
|
21 |
+
$form->addField("MD", 'hidden', array('name'=>"MD", 'value'=>Mage::getSingleton('checkout/session')->getMd()));
|
22 |
+
$form->addField("TermUrl", 'hidden', array('name'=>"TermUrl", 'value'=>Mage::getUrl($szTermURL)));
|
23 |
+
|
24 |
+
$html = '<html><body>';
|
25 |
+
$html.= $this->__('You will be redirected to a 3D secure form in a few seconds.');
|
26 |
+
$html.= $form->toHtml();
|
27 |
+
$html.= '<script type="text/javascript">document.getElementById("ThreeDSecureForm").submit();</script>';
|
28 |
+
$html.= '</body></html>';
|
29 |
+
|
30 |
+
// reset the 3DS session values
|
31 |
+
Mage::getSingleton('checkout/session')->setMd(null)
|
32 |
+
->setAcsurl(null)
|
33 |
+
->setPareq(null);
|
34 |
+
|
35 |
+
return $html;
|
36 |
+
}
|
37 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php
ADDED
@@ -0,0 +1,881 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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include ("Tpg/ISOCurrencies.php");
|
6 |
+
include ("Tpg/ISOCountries.php");
|
7 |
+
|
8 |
+
class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* unique internal payment method identifier
|
12 |
+
*
|
13 |
+
* @var string [a-z0-9_]
|
14 |
+
*/
|
15 |
+
protected $_code = 'cardsaveonlinepayments';
|
16 |
+
protected $_formBlockType = 'cardsaveonlinepayments/form';
|
17 |
+
protected $_infoBlockType = 'cardsaveonlinepayments/info';
|
18 |
+
|
19 |
+
protected $_isGateway = true;
|
20 |
+
protected $_canAuthorize = true;
|
21 |
+
protected $_canCapture = true;
|
22 |
+
protected $_canCapturePartial = true;
|
23 |
+
protected $_canRefund = false;
|
24 |
+
protected $_canVoid = false;
|
25 |
+
protected $_canUseInternal = true;
|
26 |
+
protected $_canUseCheckout = true;
|
27 |
+
protected $_canUseForMultishipping = true;
|
28 |
+
protected $_canSaveCc = false;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Assign data to info model instance
|
32 |
+
*
|
33 |
+
* @param mixed $data
|
34 |
+
* @return Mage_Payment_Model_Info
|
35 |
+
*/
|
36 |
+
public function assignData($data)
|
37 |
+
{
|
38 |
+
if (!($data instanceof Varien_Object))
|
39 |
+
{
|
40 |
+
$data = new Varien_Object($data);
|
41 |
+
}
|
42 |
+
|
43 |
+
$info = $this->getInfoInstance();
|
44 |
+
|
45 |
+
$info->setCcOwner($data->getCcOwner())
|
46 |
+
->setCcLast4(substr($data->getCcNumber(), -4))
|
47 |
+
->setCcNumber($data->getCcNumber())
|
48 |
+
->setCcCid($data->getCcCid())
|
49 |
+
->setCcExpMonth($data->getCcExpMonth())
|
50 |
+
->setCcExpYear($data->getCcExpYear())
|
51 |
+
->setCcSsStartMonth($data->getCcSsStartMonth())
|
52 |
+
->setCcSsStartYear($data->getCcSsStartYear())
|
53 |
+
->setCcSsIssue($data->getCcSsIssue());
|
54 |
+
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Validate payment method information object
|
60 |
+
*
|
61 |
+
* @param Mage_Payment_Model_Info $info
|
62 |
+
* @return Mage_Payment_Model_Abstract
|
63 |
+
*/
|
64 |
+
public function validate()
|
65 |
+
{
|
66 |
+
// NOTE : cancel out the core Magento validator functionality, the payment gateway will overtake this task
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Authorize - core Mage pre-authorization functionality
|
73 |
+
*
|
74 |
+
* @param Varien_Object $orderPayment
|
75 |
+
* @return Mage_Payment_Model_Abstract
|
76 |
+
*/
|
77 |
+
public function authorize(Varien_Object $payment, $amount)
|
78 |
+
{
|
79 |
+
$error = false;
|
80 |
+
|
81 |
+
Mage::throwException('This payment module only allow capture payments.');
|
82 |
+
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Capture payment - immediate settlement payments
|
88 |
+
*
|
89 |
+
* @param Varien_Object $payment
|
90 |
+
* @return Mage_Payment_Model_Abstract
|
91 |
+
*/
|
92 |
+
public function capture(Varien_Object $payment, $amount)
|
93 |
+
{
|
94 |
+
$error = false;
|
95 |
+
$session = Mage::getSingleton('checkout/session');
|
96 |
+
$mode = $this->getConfigData('mode');
|
97 |
+
|
98 |
+
if($amount <= 0)
|
99 |
+
{
|
100 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
|
101 |
+
}
|
102 |
+
else
|
103 |
+
{
|
104 |
+
if($session->getThreedsecurerequired())
|
105 |
+
{
|
106 |
+
$md = $session->getMd();
|
107 |
+
$pares = $session->getPares();
|
108 |
+
|
109 |
+
$session->setThreedsecurerequired(null);
|
110 |
+
$this->_run3DSecureTransaction($payment, $pares, $md);
|
111 |
+
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
if($session->getRedirectedpayment())
|
115 |
+
{
|
116 |
+
$szStatusCode = $session->getStatuscode();
|
117 |
+
$szMessage = $session->getMessage();
|
118 |
+
$szPreviousStatusCode = $session->getPreviousstatuscode();
|
119 |
+
$szPreviousMessage = $session->getPreviousmessage();
|
120 |
+
$szOrderID = $session->getOrderid();
|
121 |
+
// check whether it is a hosted payment or a transparent redirect action
|
122 |
+
$boIsHostedPaymentAction = $session->getIshostedpayment();
|
123 |
+
|
124 |
+
$session->setRedirectedpayment(null);
|
125 |
+
$session->setIshostedpayment(null);
|
126 |
+
$this->_runRedirectedPaymentComplete($payment, $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID);
|
127 |
+
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
|
131 |
+
// fresh payment request
|
132 |
+
$session->setThreedsecurerequired(null)
|
133 |
+
->setRedirectedpayment(null)
|
134 |
+
->setIshostedpayment(null)
|
135 |
+
->setHostedPayment(null)
|
136 |
+
->setMd(null)
|
137 |
+
->setPareq(null)
|
138 |
+
->setAcsurl(null)
|
139 |
+
->setPaymentprocessorresponse(null);
|
140 |
+
|
141 |
+
$payment->setAmount($amount);
|
142 |
+
|
143 |
+
switch ($mode)
|
144 |
+
{
|
145 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API:
|
146 |
+
$error = $this->_runTransaction($payment, $amount);
|
147 |
+
break;
|
148 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
|
149 |
+
$error = $this->_runHostedPaymentTransaction($payment, $amount);
|
150 |
+
break;
|
151 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
|
152 |
+
$error = $this->_runTransparentRedirectTransaction($payment, $amount);
|
153 |
+
break;
|
154 |
+
default:
|
155 |
+
Mage::throwException('Invalid payment type: '.$this->getConfigData('mode'));
|
156 |
+
break;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
if($error)
|
161 |
+
{
|
162 |
+
Mage::throwException($error);
|
163 |
+
}
|
164 |
+
|
165 |
+
return $this;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Processing the transaction using the direct integration
|
170 |
+
*
|
171 |
+
* @param Varien_Object $orderPayment
|
172 |
+
* @param $amount
|
173 |
+
* @return void
|
174 |
+
*/
|
175 |
+
public function _runTransaction(Varien_Object $payment, $amount)
|
176 |
+
{
|
177 |
+
$error = '';
|
178 |
+
$session = Mage::getSingleton('checkout/session');
|
179 |
+
|
180 |
+
$MerchantID = $this->getConfigData('merchantid');
|
181 |
+
$Password = $this->getConfigData('password');
|
182 |
+
$SecretKey = $this->getConfigData('secretkey');
|
183 |
+
// assign payment form field values to variables
|
184 |
+
$order = $payment->getOrder();
|
185 |
+
$szOrderID = $payment->getOrder()->increment_id;
|
186 |
+
$szOrderDescription = '';
|
187 |
+
$szCardName = $payment->getCcOwner();
|
188 |
+
$szCardNumber = $payment->getCcNumber();
|
189 |
+
$szIssueNumber = $payment->getCcSsIssue();
|
190 |
+
$szCV2 = $payment->getCcCid();
|
191 |
+
$nCurrencyCode;
|
192 |
+
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
193 |
+
// address details
|
194 |
+
$billingAddress = $order->getBillingAddress();
|
195 |
+
$szAddress1 = $billingAddress->getStreet1();
|
196 |
+
$szAddress2 = $billingAddress->getStreet2();
|
197 |
+
$szAddress3 = $billingAddress->getStreet3();
|
198 |
+
$szAddress4 = $billingAddress->getStreet4();
|
199 |
+
$szCity = $billingAddress->getCity();
|
200 |
+
$szState = $billingAddress->getRegion();
|
201 |
+
$szPostCode = $billingAddress->getPostcode();
|
202 |
+
$szISO2CountryCode = $billingAddress->getCountry();
|
203 |
+
$nCountryCode;
|
204 |
+
$szEmailAddress = $billingAddress->getCustomerEmail();
|
205 |
+
$szPhoneNumber = $billingAddress->getTelephone();
|
206 |
+
$nDecimalAmount;
|
207 |
+
|
208 |
+
$PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
|
209 |
+
|
210 |
+
$rgeplRequestGatewayEntryPointList = new CSV_RequestGatewayEntryPointList();
|
211 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
|
212 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
|
213 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
|
214 |
+
|
215 |
+
$maMerchantAuthentication = new CSV_MerchantAuthentication($MerchantID, $Password);
|
216 |
+
|
217 |
+
$mdMessageDetails = new CSV_MessageDetails("SALE");
|
218 |
+
|
219 |
+
$boEchoCardType = new CSV_NullableBool(true);
|
220 |
+
$boEchoAmountReceived = new CSV_NullableBool(true);
|
221 |
+
$boEchoAVSCheckResult = new CSV_NullableBool(true);
|
222 |
+
$boEchoCV2CheckResult = new CSV_NullableBool(true);
|
223 |
+
$boThreeDSecureOverridePolicy = new CSV_NullableBool(true);
|
224 |
+
$nDuplicateDelay = new CSV_NullableInt(60);
|
225 |
+
$tcTransactionControl = new CSV_TransactionControl($boEchoCardType, $boEchoAVSCheckResult, $boEchoCV2CheckResult, $boEchoAmountReceived, $nDuplicateDelay, "", "", $boThreeDSecureOverridePolicy, "", null, null);
|
226 |
+
|
227 |
+
$iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
|
228 |
+
|
229 |
+
if ($szCurrencyShort != '' &&
|
230 |
+
$iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
231 |
+
{
|
232 |
+
$nCurrencyCode = new CSV_NullableInt($icISOCurrency->getISOCode());
|
233 |
+
}
|
234 |
+
|
235 |
+
$power = pow(10, $icISOCurrency->getExponent());
|
236 |
+
$nDecimalAmount = $amount * $power;
|
237 |
+
$nAmount = new CSV_NullableInt($nDecimalAmount);
|
238 |
+
|
239 |
+
$nDeviceCategory = new CSV_NullableInt(0);
|
240 |
+
$tdsbdThreeDSecureBrowserDetails = new CSV_ThreeDSecureBrowserDetails($nDeviceCategory, "*/*", $_SERVER["HTTP_USER_AGENT"]);;
|
241 |
+
$tdTransactionDetails = new CSV_TransactionDetails($mdMessageDetails, $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
|
242 |
+
|
243 |
+
$nExpiryDateMonth = null;
|
244 |
+
if($payment->getCcExpMonth() != '')
|
245 |
+
{
|
246 |
+
$nExpiryDateMonth = new CSV_NullableInt($payment->getCcExpMonth());
|
247 |
+
}
|
248 |
+
|
249 |
+
$nExpiryDateYear = null;
|
250 |
+
if($payment->getCcExpYear() != '')
|
251 |
+
{
|
252 |
+
$nExpiryDateYear = new CSV_NullableInt($payment->getCcExpYear());
|
253 |
+
}
|
254 |
+
|
255 |
+
$nStartDateMonth = null;
|
256 |
+
if($payment->getCcSsStartMonth() != '')
|
257 |
+
{
|
258 |
+
$nStartDateMonth = new CSV_NullableInt($payment->getCcSsStartMonth());
|
259 |
+
}
|
260 |
+
|
261 |
+
$nStartDateYear = null;
|
262 |
+
if($payment->getCcSsStartYear() != '')
|
263 |
+
{
|
264 |
+
$nStartDateYear = new CSV_NullableInt($payment->getCcSsStartYear());
|
265 |
+
}
|
266 |
+
|
267 |
+
$edExpiryDate = new CSV_ExpiryDate($nExpiryDateMonth, $nExpiryDateYear);
|
268 |
+
$sdStartDate = new CSV_StartDate($nStartDateMonth, $nStartDateYear);
|
269 |
+
$cdCardDetails = new CSV_CardDetails($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $szIssueNumber, $szCV2);
|
270 |
+
|
271 |
+
$nCountryCode = null;
|
272 |
+
$iclISOCountryList = CSV_ISOCountries::getISOCountryList();
|
273 |
+
$szCountryShort = $this->_getISO3Code($szISO2CountryCode);
|
274 |
+
if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
|
275 |
+
{
|
276 |
+
$nCountryCode = new CSV_NullableInt($icISOCountry->getISOCode());
|
277 |
+
}
|
278 |
+
|
279 |
+
if($szAddress1 == null)
|
280 |
+
{
|
281 |
+
$szAddress1 = '';
|
282 |
+
}
|
283 |
+
if($szAddress2 == null)
|
284 |
+
{
|
285 |
+
$szAddress2 = '';
|
286 |
+
}
|
287 |
+
if($szAddress2 == null)
|
288 |
+
{
|
289 |
+
$szAddress2 = '';
|
290 |
+
}
|
291 |
+
if($szAddress2 == null)
|
292 |
+
{
|
293 |
+
$szAddress2 = '';
|
294 |
+
}
|
295 |
+
|
296 |
+
$adBillingAddress = new CSV_AddressDetails($szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode);
|
297 |
+
$cdCustomerDetails = new CSV_CustomerDetails($adBillingAddress, $szEmailAddress, $szPhoneNumber, $_SERVER["REMOTE_ADDR"]);
|
298 |
+
$cdtCardDetailsTransaction = new CSV_CardDetailsTransaction($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdTransactionDetails, $cdCardDetails, $cdCustomerDetails, "Some data to be passed out");
|
299 |
+
$boTransactionProcessed = $cdtCardDetailsTransaction->processTransaction($cdtrCardDetailsTransactionResult, $todTransactionOutputData);
|
300 |
+
|
301 |
+
if ($boTransactionProcessed == false)
|
302 |
+
{
|
303 |
+
// could not communicate with the payment gateway
|
304 |
+
$error = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_261;
|
305 |
+
|
306 |
+
$szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
|
307 |
+
Mage::log($szLogMessage);
|
308 |
+
}
|
309 |
+
else
|
310 |
+
{
|
311 |
+
$szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Result details: ";
|
312 |
+
$szNotificationMessage = 'Payment Processor Response: '.$cdtrCardDetailsTransactionResult->getMessage();
|
313 |
+
|
314 |
+
switch ($cdtrCardDetailsTransactionResult->getStatusCode())
|
315 |
+
{
|
316 |
+
case 0:
|
317 |
+
// status code of 0 - means transaction successful
|
318 |
+
$szLogMessage = "Transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
|
319 |
+
Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
|
320 |
+
break;
|
321 |
+
case 3:
|
322 |
+
// status code of 3 - means 3D Secure authentication required
|
323 |
+
$szLogMessage = "3D Secure Authentication required for OrderID: ".$szOrderID.". Result object details: ";
|
324 |
+
$szNotificationMessage = '';
|
325 |
+
|
326 |
+
$szPaReq = $todTransactionOutputData->getThreeDSecureOutputData()->getPaREQ();
|
327 |
+
$szCrossReference = $todTransactionOutputData->getCrossReference();
|
328 |
+
$szACSURL = $todTransactionOutputData->getThreeDSecureOutputData()->getACSURL();
|
329 |
+
|
330 |
+
Mage::getSingleton('checkout/session')->setMd($szCrossReference)
|
331 |
+
->setAcsurl($szACSURL)
|
332 |
+
->setPareq($szPaReq);
|
333 |
+
break;
|
334 |
+
case 5:
|
335 |
+
// status code of 5 - means transaction declined
|
336 |
+
$error = $szNotificationMessage;
|
337 |
+
break;
|
338 |
+
case 20:
|
339 |
+
// status code of 20 - means duplicate transaction
|
340 |
+
$szPreviousTransactionMessage = $cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getMessage();
|
341 |
+
$szLogMessage = "Duplicate transaction for OrderID: ".$szOrderID.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction: ".$szPreviousTransactionMessage.". Result object details: ";
|
342 |
+
$szNotificationMessage = $szNotificationMessage.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction - Previous Transaction Response: ".$szPreviousTransactionMessage;
|
343 |
+
|
344 |
+
if ($cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getStatusCode()->getValue() != 0)
|
345 |
+
{
|
346 |
+
$error = $szNotificationMessage;
|
347 |
+
}
|
348 |
+
else
|
349 |
+
{
|
350 |
+
Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
|
351 |
+
}
|
352 |
+
break;
|
353 |
+
case 30:
|
354 |
+
// status code of 30 - means an error occurred
|
355 |
+
$error = $szNotificationMessage;
|
356 |
+
$szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$cdtrCardDetailsTransactionResult->getMessage();
|
357 |
+
if ($cdtrCardDetailsTransactionResult->getErrorMessages()->getCount() > 0)
|
358 |
+
{
|
359 |
+
$szLogMessage = $szLogMessage.".";
|
360 |
+
|
361 |
+
for ($LoopIndex = 0; $LoopIndex < $cdtrCardDetailsTransactionResult->getErrorMessages()->getCount(); $LoopIndex++)
|
362 |
+
{
|
363 |
+
$szLogMessage = $szLogMessage.$cdtrCardDetailsTransactionResult->getErrorMessages()->getAt($LoopIndex).";";
|
364 |
+
}
|
365 |
+
$szLogMessage = $szLogMessage." ";
|
366 |
+
}
|
367 |
+
$szLogMessage = $szLogMessage.' Result object details: ';
|
368 |
+
break;
|
369 |
+
default:
|
370 |
+
// unhandled status code
|
371 |
+
$error = $szNotificationMessage;
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
|
375 |
+
$szLogMessage = $szLogMessage.print_r($cdtrCardDetailsTransactionResult, 1);
|
376 |
+
Mage::log($szLogMessage);
|
377 |
+
}
|
378 |
+
|
379 |
+
if($error)
|
380 |
+
{
|
381 |
+
$payment->setStatus('FAIL')
|
382 |
+
->setCcApproval('FAIL')
|
383 |
+
->setAdditionalData($cdtrCardDetailsTransactionResult->getMessage());
|
384 |
+
}
|
385 |
+
|
386 |
+
return $error;
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Processing the transaction using the hosted payment form integration
|
391 |
+
*
|
392 |
+
* @param Varien_Object $payment
|
393 |
+
* @param unknown_type $amount
|
394 |
+
*/
|
395 |
+
public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
|
396 |
+
{
|
397 |
+
$session = Mage::getSingleton('checkout/session');
|
398 |
+
|
399 |
+
$szMerchantID = $this->getConfigData('merchantid');
|
400 |
+
$szPassword = $this->getConfigData('password');
|
401 |
+
$szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbackhostedpayment');
|
402 |
+
$szPreSharedKey = $this->getConfigData('presharedkey');
|
403 |
+
$hmHashMethod = $this->getConfigData('hashmethod');
|
404 |
+
$boCV2Mandatory = 'false';
|
405 |
+
$boAddress1Mandatory = 'false';
|
406 |
+
$boCityMandatory = 'false';
|
407 |
+
$boPostCodeMandatory = 'false';
|
408 |
+
$boStateMandatory = 'false';
|
409 |
+
$boCountryMandatory = 'false';
|
410 |
+
$rdmResultdeliveryMethod = $this->getConfigData('resultdeliverymethod');
|
411 |
+
$szServerResultURL = Mage::getUrl('cardsaveonlinepayments/payment/serverresult');
|
412 |
+
// set to always true to display the result on the Hosted Payment Form
|
413 |
+
$boPaymentFormDisplaysResult = 'true';
|
414 |
+
|
415 |
+
$order = $payment->getOrder();
|
416 |
+
$billingAddress = $order->getBillingAddress();
|
417 |
+
$iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
|
418 |
+
$iclISOCountryList = CSV_ISOCountries::getISOCountryList();
|
419 |
+
$cookie = Mage::getSingleton('core/cookie');
|
420 |
+
$arCookieArray = $cookie->get();
|
421 |
+
$arCookieKeysArray = array_keys($arCookieArray);
|
422 |
+
$nKeysArrayLength = count($arCookieKeysArray);
|
423 |
+
$szCookiePath = $cookie->getPath();
|
424 |
+
$szCookieDomain = $cookie->getDomain();
|
425 |
+
$szServerResultURLCookieVariables = '';
|
426 |
+
$szServerResultURLFormVariables = '';
|
427 |
+
$szServerResultURLQueryStringVariables = '';
|
428 |
+
//ServerResutlURLCookieVariables string format: cookie1=123&path=/&domain=www.domain.com@@cookie2=456&path=/&domain=www.domain.com
|
429 |
+
|
430 |
+
for($nCount = 0; $nCount < $nKeysArrayLength; $nCount++)
|
431 |
+
{
|
432 |
+
$szEncodedCookieValue = urlencode($arCookieArray[$arCookieKeysArray[$nCount]]);
|
433 |
+
$szServerResultURLCookieVariables .= $arCookieKeysArray[$nCount]."=".$szEncodedCookieValue."&path=".$szCookiePath."&domain=".$szCookieDomain;
|
434 |
+
if($nCount < $nKeysArrayLength - 1)
|
435 |
+
{
|
436 |
+
$szServerResultURLCookieVariables .= "@@";
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
441 |
+
if ($szCurrencyShort != '' &&
|
442 |
+
$iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
443 |
+
{
|
444 |
+
$nCurrencyCode = $icISOCurrency->getISOCode();
|
445 |
+
}
|
446 |
+
|
447 |
+
$power = pow(10, $icISOCurrency->getExponent());
|
448 |
+
$nAmount = $amount * $power;
|
449 |
+
|
450 |
+
$szISO2CountryCode = $billingAddress->getCountry();
|
451 |
+
$szCountryShort = $this->_getISO3Code($szISO2CountryCode);
|
452 |
+
if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
|
453 |
+
{
|
454 |
+
$nCountryCode = $icISOCountry->getISOCode();
|
455 |
+
}
|
456 |
+
|
457 |
+
$szOrderID = $payment->getOrder()->increment_id;
|
458 |
+
$szTransactionType = 'SALE';
|
459 |
+
//date time with 2008-12-01 14:12:00 +01:00 format
|
460 |
+
$szTransactionDateTime = date('Y-m-d H:i:s P');
|
461 |
+
$szOrderDescription = '';
|
462 |
+
|
463 |
+
$szCustomerName = $billingAddress->getfirstname();
|
464 |
+
if($billingAddress->getfirstname())
|
465 |
+
{
|
466 |
+
$szCustomerName = $szCustomerName.' '.$billingAddress->getlastname();
|
467 |
+
}
|
468 |
+
$szAddress1 = $billingAddress->getStreet1();
|
469 |
+
$szAddress2 = $billingAddress->getStreet2();
|
470 |
+
$szAddress3 = $billingAddress->getStreet3();
|
471 |
+
$szAddress4 = $billingAddress->getStreet4();
|
472 |
+
$szCity = $billingAddress->getCity();
|
473 |
+
$szState = $billingAddress->getRegion();
|
474 |
+
$szPostCode = $billingAddress->getPostcode();
|
475 |
+
|
476 |
+
if($this->getConfigData('cv2mandatory'))
|
477 |
+
{
|
478 |
+
$boCV2Mandatory = 'true';
|
479 |
+
}
|
480 |
+
if($this->getConfigData('address1mandatory'))
|
481 |
+
{
|
482 |
+
$boAddress1Mandatory = 'true';
|
483 |
+
}
|
484 |
+
if($this->getConfigData('citymandatory'))
|
485 |
+
{
|
486 |
+
$boCityMandatory = 'true';
|
487 |
+
}
|
488 |
+
if($this->getConfigData('postcodemandatory'))
|
489 |
+
{
|
490 |
+
$boPostCodeMandatory = 'true';
|
491 |
+
}
|
492 |
+
if($this->getConfigData('statemandatory'))
|
493 |
+
{
|
494 |
+
$boStateMandatory = 'true';
|
495 |
+
}
|
496 |
+
if($this->getConfigData('countrymandatory'))
|
497 |
+
{
|
498 |
+
$boCountryMandatory = 'true';
|
499 |
+
}
|
500 |
+
if($this->getConfigData('paymentformdisplaysresult'))
|
501 |
+
{
|
502 |
+
$boPaymentFormDisplaysResult = 'true';
|
503 |
+
}
|
504 |
+
|
505 |
+
$szHashDigest = CSV_PaymentFormHelper::calculateHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription, $szCustomerName, $szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode, $boCV2Mandatory, $boAddress1Mandatory, $boCityMandatory, $boPostCodeMandatory, $boStateMandatory, $boCountryMandatory, $rdmResultdeliveryMethod, $szServerResultURL, $boPaymentFormDisplaysResult, $szServerResultURLCookieVariables, $szServerResultURLFormVariables, $szServerResultURLQueryStringVariables);
|
506 |
+
|
507 |
+
$session->setHashdigest($szHashDigest)
|
508 |
+
->setMerchantid($szMerchantID)
|
509 |
+
->setAmount($nAmount)
|
510 |
+
->setCurrencycode($nCurrencyCode)
|
511 |
+
->setOrderid($szOrderID)
|
512 |
+
->setTransactiontype($szTransactionType)
|
513 |
+
->setTransactiondatetime($szTransactionDateTime)
|
514 |
+
->setCallbackurl($szCallbackURL)
|
515 |
+
->setOrderdescription($szOrderDescription)
|
516 |
+
->setCustomername($szCustomerName)
|
517 |
+
->setAddress1($szAddress1)
|
518 |
+
->setAddress2($szAddress2)
|
519 |
+
->setAddress3($szAddress3)
|
520 |
+
->setAddress4($szAddress4)
|
521 |
+
->setCity($szCity)
|
522 |
+
->setState($szState)
|
523 |
+
->setPostcode($szPostCode)
|
524 |
+
->setCountrycode($nCountryCode)
|
525 |
+
->setCv2mandatory($boCV2Mandatory)
|
526 |
+
->setAddress1mandatory($boAddress1Mandatory)
|
527 |
+
->setCitymandatory($boCityMandatory)
|
528 |
+
->setPostcodemandatory($boPostCodeMandatory)
|
529 |
+
->setStatemandatory($boStateMandatory)
|
530 |
+
->setCountrymandatory($boCountryMandatory)
|
531 |
+
->setResultdeliverymethod($rdmResultdeliveryMethod)
|
532 |
+
->setServerresulturl($szServerResultURL)
|
533 |
+
->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
|
534 |
+
->setServerresulturlcookievariables($szServerResultURLCookieVariables)
|
535 |
+
->setServerresulturlformvariables($szServerResultURLFormVariables)
|
536 |
+
->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables);
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Processing the transaction using the transparent redirect integration
|
541 |
+
*
|
542 |
+
* @param Varien_Object $payment
|
543 |
+
* @param unknown_type $amount
|
544 |
+
*/
|
545 |
+
public function _runTransparentRedirectTransaction(Varien_Object $payment, $amount)
|
546 |
+
{
|
547 |
+
$GLOBALS['m_boPayInvoice'] = false;
|
548 |
+
$payment->setIsTransactionPending(true);
|
549 |
+
|
550 |
+
$szMerchantID = $this->getConfigData('merchantid');
|
551 |
+
$szPassword = $this->getConfigData('password');
|
552 |
+
$szPreSharedKey = $this->getConfigData('presharedkey');
|
553 |
+
$hmHashMethod = $this->getConfigData('hashmethod');
|
554 |
+
$szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbacktransparentredirect');
|
555 |
+
$order = $payment->getOrder();
|
556 |
+
$billingAddress = $order->getBillingAddress();
|
557 |
+
$iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
|
558 |
+
$iclISOCountryList = CSV_ISOCountries::getISOCountryList();
|
559 |
+
$szStartDateMonth = '';
|
560 |
+
$szStartDateYear = '';
|
561 |
+
|
562 |
+
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
563 |
+
if ($szCurrencyShort != '' &&
|
564 |
+
$iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
565 |
+
{
|
566 |
+
$nCurrencyCode = $icISOCurrency->getISOCode();
|
567 |
+
}
|
568 |
+
|
569 |
+
$power = pow(10, $icISOCurrency->getExponent());
|
570 |
+
$nAmount = $amount * $power;
|
571 |
+
|
572 |
+
$szOrderID = $payment->getOrder()->increment_id;
|
573 |
+
$szTransactionType = 'SALE';
|
574 |
+
//date time with 2008-12-01 14:12:00 +01:00 format
|
575 |
+
$szTransactionDateTime = date('Y-m-d H:i:s P');
|
576 |
+
$szOrderDescription = '';
|
577 |
+
|
578 |
+
$szAddress1 = $billingAddress->getStreet1();
|
579 |
+
$szAddress2 = $billingAddress->getStreet2();
|
580 |
+
$szAddress3 = $billingAddress->getStreet3();
|
581 |
+
$szAddress4 = $billingAddress->getStreet4();
|
582 |
+
$szCity = $billingAddress->getCity();
|
583 |
+
$szState = $billingAddress->getRegion();
|
584 |
+
$szPostCode = $billingAddress->getPostcode();
|
585 |
+
$szISO2CountryCode = $billingAddress->getCountry();
|
586 |
+
$szCountryShort = $this->_getISO3Code($szISO2CountryCode);
|
587 |
+
if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
|
588 |
+
{
|
589 |
+
$nCountryCode = $icISOCountry->getISOCode();
|
590 |
+
}
|
591 |
+
|
592 |
+
$szCardName = $payment->getCcOwner();
|
593 |
+
$szCardNumber = $payment->getCcNumber();
|
594 |
+
$szExpiryDateMonth = $payment->getCcExpMonth();
|
595 |
+
$szExpiryDateYear = $payment->getCcExpYear();
|
596 |
+
if($payment->getCcSsStartMonth() != '')
|
597 |
+
{
|
598 |
+
$szStartDateMonth = $payment->getCcSsStartMonth();
|
599 |
+
}
|
600 |
+
if($payment->getCcSsStartYear() != '')
|
601 |
+
{
|
602 |
+
$szStartDateYear = $payment->getCcSsStartYear();
|
603 |
+
}
|
604 |
+
$szIssueNumber = $payment->getCcSsIssue();
|
605 |
+
$szCV2 = $payment->getCcCid();
|
606 |
+
|
607 |
+
$szHashDigest = CSV_PaymentFormHelper::calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription);
|
608 |
+
|
609 |
+
Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
|
610 |
+
->setMerchantid($szMerchantID)
|
611 |
+
->setAmount($nAmount)
|
612 |
+
->setCurrencycode($nCurrencyCode)
|
613 |
+
->setOrderid($szOrderID)
|
614 |
+
->setTransactiontype($szTransactionType)
|
615 |
+
->setTransactiondatetime($szTransactionDateTime)
|
616 |
+
->setCallbackurl($szCallbackURL)
|
617 |
+
->setOrderdescription($szOrderDescription)
|
618 |
+
->setAddress1($szAddress1)
|
619 |
+
->setAddress2($szAddress2)
|
620 |
+
->setAddress3($szAddress3)
|
621 |
+
->setAddress4($szAddress4)
|
622 |
+
->setCity($szCity)
|
623 |
+
->setState($szState)
|
624 |
+
->setPostcode($szPostCode)
|
625 |
+
->setCountrycode($nCountryCode)
|
626 |
+
->setCardname($szCardName)
|
627 |
+
->setCardnumber($szCardNumber)
|
628 |
+
->setExpirydatemonth($szExpiryDateMonth)
|
629 |
+
->setExpirydateyear($szExpiryDateYear)
|
630 |
+
->setStartdatemonth($szStartDateMonth)
|
631 |
+
->setStartdateyear($szStartDateYear)
|
632 |
+
->setIssuenumber($szIssueNumber)
|
633 |
+
->setCv2($szCV2);
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Processing the 3D Secure transaction
|
638 |
+
*
|
639 |
+
* @param Varien_Object $payment
|
640 |
+
* @param int $amount
|
641 |
+
* @param string $szPaRes
|
642 |
+
* @param string $szMD
|
643 |
+
*/
|
644 |
+
public function _run3DSecureTransaction(Varien_Object $payment, $szPaRes, $szMD)
|
645 |
+
{
|
646 |
+
$error = false;
|
647 |
+
$message = '';
|
648 |
+
$order = $payment->getOrder();
|
649 |
+
$szOrderID = $payment->getOrder()->increment_id;
|
650 |
+
$session = Mage::getSingleton('checkout/session');
|
651 |
+
|
652 |
+
$MerchantID = $this->getConfigData('merchantid');
|
653 |
+
$Password = $this->getConfigData('password');
|
654 |
+
$SecretKey = $this->getConfigData('secretkey');
|
655 |
+
|
656 |
+
$PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
|
657 |
+
$rgeplRequestGatewayEntryPointList = new CSV_RequestGatewayEntryPointList();
|
658 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
|
659 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
|
660 |
+
$rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
|
661 |
+
|
662 |
+
$maMerchantAuthentication = new CSV_MerchantAuthentication($MerchantID, $Password);
|
663 |
+
$tdsidThreeDSecureInputData = new CSV_ThreeDSecureInputData($szMD, $szPaRes);
|
664 |
+
|
665 |
+
$tdsaThreeDSecureAuthentication = new CSV_ThreeDSecureAuthentication($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdsidThreeDSecureInputData, "Some data to be passed out");
|
666 |
+
$boTransactionProcessed = $tdsaThreeDSecureAuthentication->processTransaction($tdsarThreeDSecureAuthenticationResult, $todTransactionOutputData);
|
667 |
+
|
668 |
+
if ($boTransactionProcessed == false)
|
669 |
+
{
|
670 |
+
// could not communicate with the payment gateway
|
671 |
+
$szLogMessage = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_431;
|
672 |
+
$message = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_431;
|
673 |
+
Mage::log($szLogMessage);
|
674 |
+
}
|
675 |
+
else
|
676 |
+
{
|
677 |
+
$message = "Payment Processor Response: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
|
678 |
+
$szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Result object details: ";
|
679 |
+
|
680 |
+
switch ($tdsarThreeDSecureAuthenticationResult->getStatusCode())
|
681 |
+
{
|
682 |
+
case 0:
|
683 |
+
// status code of 0 - means transaction successful
|
684 |
+
$szLogMessage = "3D Secure transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
|
685 |
+
break;
|
686 |
+
case 5:
|
687 |
+
// status code of 5 - means transaction declined
|
688 |
+
$error = true;
|
689 |
+
break;
|
690 |
+
case 20:
|
691 |
+
// status code of 20 - means duplicate transaction
|
692 |
+
$szPreviousTransactionMessage = $tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getMessage();
|
693 |
+
$szLogMessage = "Duplicate transaction for OrderID: ".$szOrderID.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction: ".$szPreviousTransactionMessage.". Result object details: ";
|
694 |
+
|
695 |
+
if ($tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getStatusCode()->getValue() == 0)
|
696 |
+
{
|
697 |
+
$message = $message.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction are - ".$szPreviousTransactionMessage;
|
698 |
+
}
|
699 |
+
else
|
700 |
+
{
|
701 |
+
$error = true;
|
702 |
+
}
|
703 |
+
break;
|
704 |
+
case 30:
|
705 |
+
$error = true;
|
706 |
+
// status code of 30 - means an error occurred
|
707 |
+
$szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
|
708 |
+
if ($tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount() > 0)
|
709 |
+
{
|
710 |
+
$szLogMessage = $szLogMessage.".";
|
711 |
+
$message =$message.".";
|
712 |
+
|
713 |
+
for ($LoopIndex = 0; $LoopIndex < $tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount(); $LoopIndex++)
|
714 |
+
{
|
715 |
+
$szLogMessage = $szLogMessage.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
|
716 |
+
$message = $message.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
|
717 |
+
}
|
718 |
+
$szLogMessage = $szLogMessage." ";
|
719 |
+
$message = $message." ";
|
720 |
+
}
|
721 |
+
break;
|
722 |
+
default:
|
723 |
+
// unhandled status code
|
724 |
+
$error = true;
|
725 |
+
break;
|
726 |
+
}
|
727 |
+
|
728 |
+
// log 3DS payment result
|
729 |
+
$szLogMessage = $szLogMessage.print_r($tdsarThreeDSecureAuthenticationResult, 1);
|
730 |
+
Mage::log($szLogMessage);
|
731 |
+
}
|
732 |
+
|
733 |
+
$session->setPaymentprocessorresponse($message);
|
734 |
+
if($error == true)
|
735 |
+
{
|
736 |
+
$message = Mage::helper('cardsaveonlinepayments')->__($message);
|
737 |
+
Mage::throwException($message);
|
738 |
+
}
|
739 |
+
else
|
740 |
+
{
|
741 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
742 |
+
->setAdditionalData($message);
|
743 |
+
}
|
744 |
+
|
745 |
+
return $this;
|
746 |
+
}
|
747 |
+
|
748 |
+
public function _runRedirectedPaymentComplete(Varien_Object $payment, $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
|
749 |
+
{
|
750 |
+
$error = false;
|
751 |
+
$message;
|
752 |
+
$session = Mage::getSingleton('checkout/session');
|
753 |
+
|
754 |
+
if($boIsHostedPaymentAction == true)
|
755 |
+
{
|
756 |
+
$szWording = "Hosted Payment Form ";
|
757 |
+
}
|
758 |
+
else
|
759 |
+
{
|
760 |
+
$szWording = "Transparent Redirect ";
|
761 |
+
}
|
762 |
+
|
763 |
+
$message = "Payment Processor Response: ".$szMessage;
|
764 |
+
switch ($szStatusCode)
|
765 |
+
{
|
766 |
+
case "0":
|
767 |
+
Mage::log($szWording."transaction successfully completed. ".$message);
|
768 |
+
break;
|
769 |
+
case "20":
|
770 |
+
Mage::log("Duplicate ".$szWording."transaction. ".$message);
|
771 |
+
$message = $message.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction - Previous Transaction Response: ".szPreviousMessage;
|
772 |
+
if($szPreviousStatusCode != "0")
|
773 |
+
{
|
774 |
+
$error = true;
|
775 |
+
}
|
776 |
+
break;
|
777 |
+
case "5":
|
778 |
+
case "30":
|
779 |
+
default:
|
780 |
+
Mage::log($szWording."transaction couldn't be completed. ".$message);
|
781 |
+
$error = true;
|
782 |
+
break;
|
783 |
+
}
|
784 |
+
|
785 |
+
$session->setPaymentprocessorresponse($message);
|
786 |
+
if($error == true)
|
787 |
+
{
|
788 |
+
$message = Mage::helper('cardsaveonlinepayments')->__($message);
|
789 |
+
Mage::throwException($message);
|
790 |
+
}
|
791 |
+
else
|
792 |
+
{
|
793 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
794 |
+
->setAdditionalData($message);
|
795 |
+
}
|
796 |
+
|
797 |
+
return $this;
|
798 |
+
}
|
799 |
+
|
800 |
+
/**
|
801 |
+
* Override the core Mage function to get the URL to be redirected from the Onepage
|
802 |
+
*
|
803 |
+
* @return string
|
804 |
+
*/
|
805 |
+
public function getOrderPlaceRedirectUrl()
|
806 |
+
{
|
807 |
+
$result = false;
|
808 |
+
$session = Mage::getSingleton('checkout/session');
|
809 |
+
|
810 |
+
if($session->getMd() &&
|
811 |
+
$session->getAcsurl() &&
|
812 |
+
$session->getPareq())
|
813 |
+
{
|
814 |
+
// Direct (API) for 3D Secure payments
|
815 |
+
$result = Mage::getUrl('cardsaveonlinepayments/payment/threedsecure');
|
816 |
+
}
|
817 |
+
if($session->getHashdigest())
|
818 |
+
{
|
819 |
+
// Hosted Payment Form and Transparent Redirect payments
|
820 |
+
$result = Mage::getUrl('cardsaveonlinepayments/payment/redirect');
|
821 |
+
}
|
822 |
+
|
823 |
+
return $result;
|
824 |
+
}
|
825 |
+
|
826 |
+
/**
|
827 |
+
* Get the correct payment processor domain
|
828 |
+
*
|
829 |
+
* @return string
|
830 |
+
*/
|
831 |
+
private function _getPaymentProcessorFullDomain()
|
832 |
+
{
|
833 |
+
$szPaymentProcessorFullDomain;
|
834 |
+
|
835 |
+
// get the stored config setting
|
836 |
+
$szPaymentProcessorDomain = $this->getConfigData('paymentprocessordomain');
|
837 |
+
$szPaymentProcessorPort = $this->getConfigData('paymentprocessorport');
|
838 |
+
|
839 |
+
if ($szPaymentProcessorPort == '443')
|
840 |
+
{
|
841 |
+
$szPaymentProcessorFullDomain = $szPaymentProcessorDomain."/";
|
842 |
+
}
|
843 |
+
else
|
844 |
+
{
|
845 |
+
$szPaymentProcessorFullDomain = $szPaymentProcessorDomain.":".$szPaymentProcessorPort."/";
|
846 |
+
}
|
847 |
+
|
848 |
+
return $szPaymentProcessorFullDomain;
|
849 |
+
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Get the country ISO3 code from the ISO2 code
|
853 |
+
*
|
854 |
+
* @param ISO2Code
|
855 |
+
* @return string
|
856 |
+
*/
|
857 |
+
private function _getISO3Code($szISO2Code)
|
858 |
+
{
|
859 |
+
$szISO3Code;
|
860 |
+
$collection;
|
861 |
+
$boFound = false;
|
862 |
+
$nCount = 1;
|
863 |
+
$item;
|
864 |
+
|
865 |
+
$collection = Mage::getModel('directory/country_api')->items();
|
866 |
+
|
867 |
+
while ($boFound == false &&
|
868 |
+
$nCount < count($collection))
|
869 |
+
{
|
870 |
+
$item = $collection[$nCount];
|
871 |
+
if($item['iso2_code'] == $szISO2Code)
|
872 |
+
{
|
873 |
+
$boFound = true;
|
874 |
+
$szISO3Code = $item['iso3_code'];
|
875 |
+
}
|
876 |
+
$nCount++;
|
877 |
+
}
|
878 |
+
|
879 |
+
return $szISO3Code;
|
880 |
+
}
|
881 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Request.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Request extends Varien_Object
|
4 |
+
{
|
5 |
+
public function __call($method, $args)
|
6 |
+
{
|
7 |
+
switch (substr($method, 0, 3))
|
8 |
+
{
|
9 |
+
case 'get' :
|
10 |
+
$key = substr($method,3);
|
11 |
+
$data = $this->getData($key, isset($args[0]) ? $args[0] : null);
|
12 |
+
return $data;
|
13 |
+
case 'set' :
|
14 |
+
$key = substr($method,3);
|
15 |
+
$result = $this->setData($key, isset($args[0]) ? $args[0] : null);
|
16 |
+
return $result;
|
17 |
+
default:
|
18 |
+
return parent::__call($method, $args);
|
19 |
+
}
|
20 |
+
throw new Varien_Exception("Invalid method ".get_class($this)."::".$method."(".print_r($args,1).")");
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod
|
4 |
+
{
|
5 |
+
// public enum for the payment types
|
6 |
+
const HASH_METHOD_MD5 = 'md5';
|
7 |
+
const HASH_METHOD_SHA1 = 'sha1';
|
8 |
+
const HASH_METHOD_HMACMD5 = 'hmacmd5';
|
9 |
+
const HASH_METHOD_HMACSHA1 = 'hmacsha1';
|
10 |
+
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
return array
|
14 |
+
(
|
15 |
+
array(
|
16 |
+
'value' => self::HASH_METHOD_MD5,
|
17 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('MD5')
|
18 |
+
),
|
19 |
+
array(
|
20 |
+
'value' => self::HASH_METHOD_SHA1,
|
21 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('SHA1')
|
22 |
+
),
|
23 |
+
array(
|
24 |
+
'value' => self::HASH_METHOD_HMACMD5,
|
25 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('HMACMD5')
|
26 |
+
),
|
27 |
+
array(
|
28 |
+
'value' => self::HASH_METHOD_HMACSHA1,
|
29 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('HMACSHA1')
|
30 |
+
)
|
31 |
+
);
|
32 |
+
}
|
33 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/OrderStatus.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Source_OrderStatus
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
// override the order status and ONLY offer "pending" by default
|
9 |
+
array(
|
10 |
+
'value' => 'processing',
|
11 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Processing')
|
12 |
+
),
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentAction.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Source_PaymentAction extends Mage_Paygate_Model_Authorizenet_Source_PaymentAction
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
// override the core class to ONLy allow capture transactions (immediate settlement)
|
9 |
+
array(
|
10 |
+
'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE,
|
11 |
+
'label' => Mage::helper('paygate')->__('Authorize and Capture')
|
12 |
+
),
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentMode.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode
|
4 |
+
{
|
5 |
+
// public enum for the payment types
|
6 |
+
const PAYMENT_MODE_DIRECT_API = 'direct';
|
7 |
+
const PAYMENT_MODE_HOSTED_PAYMENT_FORM = 'hosted';
|
8 |
+
const PAYMENT_MODE_TRANSPARENT_REDIRECT = 'transparent';
|
9 |
+
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
return array
|
13 |
+
(
|
14 |
+
array(
|
15 |
+
'value' => self::PAYMENT_MODE_DIRECT_API,
|
16 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Direct (API)')
|
17 |
+
),
|
18 |
+
array(
|
19 |
+
'value' => self::PAYMENT_MODE_HOSTED_PAYMENT_FORM,
|
20 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Form')
|
21 |
+
),
|
22 |
+
array(
|
23 |
+
'value' => self::PAYMENT_MODE_TRANSPARENT_REDIRECT,
|
24 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Transparent Redirect')
|
25 |
+
),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/ResultDeliveryMethod.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Source_ResultDeliveryMethod
|
4 |
+
{
|
5 |
+
// public enum for the payment types
|
6 |
+
const RESULT_DELIVERY_METHOD_POST = 'POST';
|
7 |
+
const RESULT_DELIVERY_METHOD_SERVER = 'SERVER';
|
8 |
+
|
9 |
+
public function toOptionArray()
|
10 |
+
{
|
11 |
+
return array
|
12 |
+
(
|
13 |
+
array(
|
14 |
+
'value' => self::RESULT_DELIVERY_METHOD_POST,
|
15 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Post')
|
16 |
+
),
|
17 |
+
array(
|
18 |
+
'value' => self::RESULT_DELIVERY_METHOD_SERVER,
|
19 |
+
'label' => Mage::helper('cardsaveonlinepayments')->__('Server')
|
20 |
+
),
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/GlobalErrors.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* failure - probably a wrong card details entered in
|
7 |
+
* error - payment gateway communication and hashing related issues
|
8 |
+
*/
|
9 |
+
// failure - occurred in the processing of the final callback from the hosted payment form/transparent redirect
|
10 |
+
const ERROR_183 = "The payment was not successful and checkout was cancelled.<br/>Please check your credit card details and try again.";
|
11 |
+
|
12 |
+
// error - occurred during the partial processing of the callback from the transparent redirect page
|
13 |
+
const ERROR_260 = "ERROR 260: The payment result couldn't be verified.";
|
14 |
+
|
15 |
+
// error - direct integration transaction cannot be completed - problem in the communication with the payment gateway
|
16 |
+
const ERROR_261 = "ERROR 261: Couldn't communicate with payment gateway.";
|
17 |
+
|
18 |
+
// error - direct integration 3D Secure transaction couldn't be processed - problem in the communication with the paymwent gateway
|
19 |
+
const ERROR_431 = "ERROR 431: Couldn't communicate with payment gateway to complete the 3D Secure authentication.";
|
20 |
+
|
21 |
+
// failure - occurred during the processing of the data in the callback from the 3D Secure Authentication page
|
22 |
+
const ERROR_7655 = "3D Secure payment was not successfull and checkout was cancelled.<br/>Please check your credit card details and try again.";
|
23 |
+
}
|
24 |
+
?>
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ISOCountries.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include_once ("ThePaymentGateway/TPG_Common.php");
|
4 |
+
|
5 |
+
class CSV_ISOCountries
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Get the list of ISO Countries
|
9 |
+
*
|
10 |
+
* @return ISOCountryList
|
11 |
+
*/
|
12 |
+
public static function getISOCountryList()
|
13 |
+
{
|
14 |
+
$iclISOCountryList = new CSV_ISOCountryList();
|
15 |
+
|
16 |
+
$iclISOCountryList->add(826,"United Kingdom","GBR",3);
|
17 |
+
$iclISOCountryList->add(840,"United States","USA",2);
|
18 |
+
$iclISOCountryList->add(36,"Australia","AUS",1);
|
19 |
+
$iclISOCountryList->add(124,"Canada","CAN",1);
|
20 |
+
$iclISOCountryList->add(250,"France","FRA",1);
|
21 |
+
$iclISOCountryList->add(276,"Germany","DEU",1);
|
22 |
+
$iclISOCountryList->add(4,"Afghanistan","AFG",0);
|
23 |
+
$iclISOCountryList->add(248,"�land Islands","ALA",0);
|
24 |
+
$iclISOCountryList->add(8,"Albania","ALB",0);
|
25 |
+
$iclISOCountryList->add(12,"Algeria","DZA",0);
|
26 |
+
$iclISOCountryList->add(16,"American Samoa","ASM",0);
|
27 |
+
$iclISOCountryList->add(20,"Andorra","AND",0);
|
28 |
+
$iclISOCountryList->add(24,"Angola","AGO",0);
|
29 |
+
$iclISOCountryList->add(660,"Anguilla","AIA",0);
|
30 |
+
$iclISOCountryList->add(10,"Antarctica","ATA",0);
|
31 |
+
$iclISOCountryList->add(28,"Antigua and Barbuda","ATG",0);
|
32 |
+
$iclISOCountryList->add(32,"Argentina","ARG",0);
|
33 |
+
$iclISOCountryList->add(51,"Armenia","ARM",0);
|
34 |
+
$iclISOCountryList->add(533,"Aruba","ABW",0);
|
35 |
+
$iclISOCountryList->add(40,"Austria","AUT",0);
|
36 |
+
$iclISOCountryList->add(31,"Azerbaijan","AZE",0);
|
37 |
+
$iclISOCountryList->add(44,"Bahamas","BHS",0);
|
38 |
+
$iclISOCountryList->add(48,"Bahrain","BHR",0);
|
39 |
+
$iclISOCountryList->add(50,"Bangladesh","BGD",0);
|
40 |
+
$iclISOCountryList->add(52,"Barbados","BRB",0);
|
41 |
+
$iclISOCountryList->add(112,"Belarus","BLR",0);
|
42 |
+
$iclISOCountryList->add(56,"Belgium","BEL",0);
|
43 |
+
$iclISOCountryList->add(84,"Belize","BLZ",0);
|
44 |
+
$iclISOCountryList->add(204,"Benin","BEN",0);
|
45 |
+
$iclISOCountryList->add(60,"Bermuda","BMU",0);
|
46 |
+
$iclISOCountryList->add(64,"Bhutan","BTN",0);
|
47 |
+
$iclISOCountryList->add(68,"Bolivia","BOL",0);
|
48 |
+
$iclISOCountryList->add(70,"Bosnia and Herzegovina","BIH",0);
|
49 |
+
$iclISOCountryList->add(72,"Botswana","BWA",0);
|
50 |
+
$iclISOCountryList->add(74,"Bouvet Island","BVT",0);
|
51 |
+
$iclISOCountryList->add(76,"Brazil Federative","BRA",0);
|
52 |
+
$iclISOCountryList->add(86,"British Indian Ocean Territory","IOT",0);
|
53 |
+
$iclISOCountryList->add(96,"Brunei","BRN",0);
|
54 |
+
$iclISOCountryList->add(100,"Bulgaria","BGR",0);
|
55 |
+
$iclISOCountryList->add(854,"Burkina Faso","BFA",0);
|
56 |
+
$iclISOCountryList->add(108,"Burundi","BDI",0);
|
57 |
+
$iclISOCountryList->add(116,"Cambodia","KHM",0);
|
58 |
+
$iclISOCountryList->add(120,"Cameroon","CMR",0);
|
59 |
+
$iclISOCountryList->add(132,"Cape Verde","CPV",0);
|
60 |
+
$iclISOCountryList->add(136,"Cayman Islands","CYM",0);
|
61 |
+
$iclISOCountryList->add(140,"Central African Republic","CAF",0);
|
62 |
+
$iclISOCountryList->add(148,"Chad","TCD",0);
|
63 |
+
$iclISOCountryList->add(152,"Chile","CHL",0);
|
64 |
+
$iclISOCountryList->add(156,"China","CHN",0);
|
65 |
+
$iclISOCountryList->add(162,"Christmas Island","CXR",0);
|
66 |
+
$iclISOCountryList->add(166,"Cocos (Keeling) Islands","CCK",0);
|
67 |
+
$iclISOCountryList->add(170,"Colombia","COL",0);
|
68 |
+
$iclISOCountryList->add(174,"Comoros","COM",0);
|
69 |
+
$iclISOCountryList->add(180,"Congo","COD",0);
|
70 |
+
$iclISOCountryList->add(178,"Congo","COG",0);
|
71 |
+
$iclISOCountryList->add(184,"Cook Islands","COK",0);
|
72 |
+
$iclISOCountryList->add(188,"Costa Rica","CRI",0);
|
73 |
+
$iclISOCountryList->add(384,"C�te d'Ivoire","CIV",0);
|
74 |
+
$iclISOCountryList->add(191,"Croatia","HRV",0);
|
75 |
+
$iclISOCountryList->add(192,"Cuba","CUB",0);
|
76 |
+
$iclISOCountryList->add(196,"Cyprus","CYP",0);
|
77 |
+
$iclISOCountryList->add(203,"Czech Republic","CZE",0);
|
78 |
+
$iclISOCountryList->add(208,"Denmark","DNK",0);
|
79 |
+
$iclISOCountryList->add(262,"Djibouti","DJI",0);
|
80 |
+
$iclISOCountryList->add(212,"Dominica","DMA",0);
|
81 |
+
$iclISOCountryList->add(214,"Dominican Republic","DOM",0);
|
82 |
+
$iclISOCountryList->add(626,"East Timor","TMP",0);
|
83 |
+
$iclISOCountryList->add(218,"Ecuador","ECU",0);
|
84 |
+
$iclISOCountryList->add(818,"Egypt","EGY",0);
|
85 |
+
$iclISOCountryList->add(222,"El Salvador","SLV",0);
|
86 |
+
$iclISOCountryList->add(226,"Equatorial Guinea","GNQ",0);
|
87 |
+
$iclISOCountryList->add(232,"Eritrea","ERI",0);
|
88 |
+
$iclISOCountryList->add(233,"Estonia","EST",0);
|
89 |
+
$iclISOCountryList->add(231,"Ethiopia","ETH",0);
|
90 |
+
$iclISOCountryList->add(238,"Falkland Islands (Malvinas)","FLK",0);
|
91 |
+
$iclISOCountryList->add(234,"Faroe Islands","FRO",0);
|
92 |
+
$iclISOCountryList->add(242,"Fiji","FJI",0);
|
93 |
+
$iclISOCountryList->add(246,"Finland","FIN",0);
|
94 |
+
$iclISOCountryList->add(254,"French Guiana","GUF",0);
|
95 |
+
$iclISOCountryList->add(258,"French Polynesia","PYF",0);
|
96 |
+
$iclISOCountryList->add(260,"French Southern Territories","ATF",0);
|
97 |
+
$iclISOCountryList->add(266,"Gabon","GAB",0);
|
98 |
+
$iclISOCountryList->add(270,"Gambia","GMB",0);
|
99 |
+
$iclISOCountryList->add(268,"Georgia","GEO",0);
|
100 |
+
$iclISOCountryList->add(288,"Ghana","GHA",0);
|
101 |
+
$iclISOCountryList->add(292,"Gibraltar","GIB",0);
|
102 |
+
$iclISOCountryList->add(300,"Greece","GRC",0);
|
103 |
+
$iclISOCountryList->add(304,"Greenland","GRL",0);
|
104 |
+
$iclISOCountryList->add(308,"Grenada","GRD",0);
|
105 |
+
$iclISOCountryList->add(312,"Guadaloupe","GLP",0);
|
106 |
+
$iclISOCountryList->add(316,"Guam","GUM",0);
|
107 |
+
$iclISOCountryList->add(320,"Guatemala","GTM",0);
|
108 |
+
$iclISOCountryList->add(831,"Guernsey","GGY",0);
|
109 |
+
$iclISOCountryList->add(324,"Guinea","GIN",0);
|
110 |
+
$iclISOCountryList->add(624,"Guinea-Bissau","GNB",0);
|
111 |
+
$iclISOCountryList->add(328,"Guyana","GUY",0);
|
112 |
+
$iclISOCountryList->add(332,"Haiti","HTI",0);
|
113 |
+
$iclISOCountryList->add(334,"Heard Island and McDonald Islands","HMD",0);
|
114 |
+
$iclISOCountryList->add(340,"Honduras","HND",0);
|
115 |
+
$iclISOCountryList->add(344,"Hong Kong","HKG",0);
|
116 |
+
$iclISOCountryList->add(348,"Hungary","HUN",0);
|
117 |
+
$iclISOCountryList->add(352,"Iceland","ISL",0);
|
118 |
+
$iclISOCountryList->add(356,"India","IND",0);
|
119 |
+
$iclISOCountryList->add(360,"Indonesia","IDN",0);
|
120 |
+
$iclISOCountryList->add(364,"Iran","IRN",0);
|
121 |
+
$iclISOCountryList->add(368,"Iraq","IRQ",0);
|
122 |
+
$iclISOCountryList->add(372,"Ireland","IRL",0);
|
123 |
+
$iclISOCountryList->add(833,"Isle of Man","IMN",0);
|
124 |
+
$iclISOCountryList->add(376,"Israel","ISR",0);
|
125 |
+
$iclISOCountryList->add(380,"Italy","ITA",0);
|
126 |
+
$iclISOCountryList->add(388,"Jamaica","JAM",0);
|
127 |
+
$iclISOCountryList->add(392,"Japan","JPN",0);
|
128 |
+
$iclISOCountryList->add(832,"Jersey","JEY",0);
|
129 |
+
$iclISOCountryList->add(400,"Jordan","JOR",0);
|
130 |
+
$iclISOCountryList->add(398,"Kazakhstan","KAZ",0);
|
131 |
+
$iclISOCountryList->add(404,"Kenya","KEN",0);
|
132 |
+
$iclISOCountryList->add(296,"Kiribati","KIR",0);
|
133 |
+
$iclISOCountryList->add(410,"Korea","KOR",0);
|
134 |
+
$iclISOCountryList->add(408,"Korea","PRK",0);
|
135 |
+
$iclISOCountryList->add(414,"Kuwait","KWT",0);
|
136 |
+
$iclISOCountryList->add(417,"Kyrgyzstan","KGZ",0);
|
137 |
+
$iclISOCountryList->add(418,"Lao","LAO",0);
|
138 |
+
$iclISOCountryList->add(428,"Latvia","LVA",0);
|
139 |
+
$iclISOCountryList->add(422,"Lebanon","LBN",0);
|
140 |
+
$iclISOCountryList->add(426,"Lesotho","LSO",0);
|
141 |
+
$iclISOCountryList->add(430,"Liberia","LBR",0);
|
142 |
+
$iclISOCountryList->add(434,"Libyan Arab Jamahiriya","LBY",0);
|
143 |
+
$iclISOCountryList->add(438,"Liechtenstein","LIE",0);
|
144 |
+
$iclISOCountryList->add(440,"Lithuania","LTU",0);
|
145 |
+
$iclISOCountryList->add(442,"Luxembourg","LUX",0);
|
146 |
+
$iclISOCountryList->add(446,"Macau","MAC",0);
|
147 |
+
$iclISOCountryList->add(807,"Macedonia","MKD",0);
|
148 |
+
$iclISOCountryList->add(450,"Madagascar","MDG",0);
|
149 |
+
$iclISOCountryList->add(454,"Malawi","MWI",0);
|
150 |
+
$iclISOCountryList->add(458,"Malaysia","MYS",0);
|
151 |
+
$iclISOCountryList->add(462,"Maldives","MDV",0);
|
152 |
+
$iclISOCountryList->add(466,"Mali","MLI",0);
|
153 |
+
$iclISOCountryList->add(470,"Malta","MLT",0);
|
154 |
+
$iclISOCountryList->add(584,"Marshall Islands","MHL",0);
|
155 |
+
$iclISOCountryList->add(474,"Martinique","MTQ",0);
|
156 |
+
$iclISOCountryList->add(478,"Mauritania Islamic","MRT",0);
|
157 |
+
$iclISOCountryList->add(480,"Mauritius","MUS",0);
|
158 |
+
$iclISOCountryList->add(175,"Mayotte","MYT",0);
|
159 |
+
$iclISOCountryList->add(484,"Mexico","MEX",0);
|
160 |
+
$iclISOCountryList->add(583,"Micronesia","FSM",0);
|
161 |
+
$iclISOCountryList->add(498,"Moldova","MDA",0);
|
162 |
+
$iclISOCountryList->add(492,"Monaco","MCO",0);
|
163 |
+
$iclISOCountryList->add(496,"Mongolia","MNG",0);
|
164 |
+
$iclISOCountryList->add(499,"Montenegro","MNE",0);
|
165 |
+
$iclISOCountryList->add(500,"Montserrat","MSR",0);
|
166 |
+
$iclISOCountryList->add(504,"Morocco","MAR",0);
|
167 |
+
$iclISOCountryList->add(508,"Mozambique","MOZ",0);
|
168 |
+
$iclISOCountryList->add(104,"Myanmar","MMR",0);
|
169 |
+
$iclISOCountryList->add(516,"Namibia","NAM",0);
|
170 |
+
$iclISOCountryList->add(520,"Nauru","NRU",0);
|
171 |
+
$iclISOCountryList->add(524,"Nepal","NPL",0);
|
172 |
+
$iclISOCountryList->add(528,"Netherlands","NLD",0);
|
173 |
+
$iclISOCountryList->add(530,"Netherlands Antilles","ANT",0);
|
174 |
+
$iclISOCountryList->add(540,"New Caledonia","NCL",0);
|
175 |
+
$iclISOCountryList->add(554,"New Zealand","NZL",0);
|
176 |
+
$iclISOCountryList->add(558,"Nicaragua","NIC",0);
|
177 |
+
$iclISOCountryList->add(562,"Niger","NER",0);
|
178 |
+
$iclISOCountryList->add(566,"Nigeria","NGA",0);
|
179 |
+
$iclISOCountryList->add(570,"Niue","NIU",0);
|
180 |
+
$iclISOCountryList->add(574,"Norfolk Island","NFK",0);
|
181 |
+
$iclISOCountryList->add(580,"Northern Mariana Islands","MNP",0);
|
182 |
+
$iclISOCountryList->add(578,"Norway","NOR",0);
|
183 |
+
$iclISOCountryList->add(512,"Oman","OMN",0);
|
184 |
+
$iclISOCountryList->add(586,"Pakistan","PAK",0);
|
185 |
+
$iclISOCountryList->add(585,"Palau","PLW",0);
|
186 |
+
$iclISOCountryList->add(275,"Palestine","PSE",0);
|
187 |
+
$iclISOCountryList->add(591,"Panama","PAN",0);
|
188 |
+
$iclISOCountryList->add(598,"Papua New Guinea","PNG",0);
|
189 |
+
$iclISOCountryList->add(600,"Paraguay","PRY",0);
|
190 |
+
$iclISOCountryList->add(604,"Peru","PER",0);
|
191 |
+
$iclISOCountryList->add(608,"Philippines","PHL",0);
|
192 |
+
$iclISOCountryList->add(612,"Pitcairn","PCN",0);
|
193 |
+
$iclISOCountryList->add(616,"Poland","POL",0);
|
194 |
+
$iclISOCountryList->add(620,"Portugal","PRT",0);
|
195 |
+
$iclISOCountryList->add(630,"Puerto Rico","PRI",0);
|
196 |
+
$iclISOCountryList->add(634,"Qatar","QAT",0);
|
197 |
+
$iclISOCountryList->add(638,"R�union","REU",0);
|
198 |
+
$iclISOCountryList->add(642,"Romania","ROM",0);
|
199 |
+
$iclISOCountryList->add(643,"Russian Federation","RUS",0);
|
200 |
+
$iclISOCountryList->add(646,"Rwanda","RWA",0);
|
201 |
+
$iclISOCountryList->add(652,"Saint Barth�lemy","BLM",0);
|
202 |
+
$iclISOCountryList->add(654,"Saint Helena","SHN",0);
|
203 |
+
$iclISOCountryList->add(659,"Saint Kitts and Nevis","KNA",0);
|
204 |
+
$iclISOCountryList->add(662,"Saint Lucia","LCA",0);
|
205 |
+
$iclISOCountryList->add(663,"Saint Martin (French part)","MAF",0);
|
206 |
+
$iclISOCountryList->add(666,"Saint Pierre and Miquelon","SPM",0);
|
207 |
+
$iclISOCountryList->add(670,"Saint Vincent and the Grenadines","VCT",0);
|
208 |
+
$iclISOCountryList->add(882,"Samoa","WSM",0);
|
209 |
+
$iclISOCountryList->add(674,"San Marino","SMR",0);
|
210 |
+
$iclISOCountryList->add(678,"S�o Tom� and Pr�ncipe Democratic","STP",0);
|
211 |
+
$iclISOCountryList->add(682,"Saudi Arabia","SAU",0);
|
212 |
+
$iclISOCountryList->add(686,"Senegal","SEN",0);
|
213 |
+
$iclISOCountryList->add(688,"Serbia","SRB",0);
|
214 |
+
$iclISOCountryList->add(690,"Seychelles","SYC",0);
|
215 |
+
$iclISOCountryList->add(694,"Sierra Leone","SLE",0);
|
216 |
+
$iclISOCountryList->add(702,"Singapore","SGP",0);
|
217 |
+
$iclISOCountryList->add(703,"Slovakia","SVK",0);
|
218 |
+
$iclISOCountryList->add(705,"Slovenia","SVN",0);
|
219 |
+
$iclISOCountryList->add(90,"Solomon Islands","SLB",0);
|
220 |
+
$iclISOCountryList->add(706,"Somalia","SOM",0);
|
221 |
+
$iclISOCountryList->add(710,"South Africa","ZAF",0);
|
222 |
+
$iclISOCountryList->add(239,"South Georgia and the South Sandwich Islands","SGS",0);
|
223 |
+
$iclISOCountryList->add(724,"Spain","ESP",0);
|
224 |
+
$iclISOCountryList->add(144,"Sri Lanka","LKA",0);
|
225 |
+
$iclISOCountryList->add(736,"Sudan","SDN",0);
|
226 |
+
$iclISOCountryList->add(740,"Suriname","SUR",0);
|
227 |
+
$iclISOCountryList->add(744,"Svalbard and Jan Mayen","SJM",0);
|
228 |
+
$iclISOCountryList->add(748,"Swaziland","SWZ",0);
|
229 |
+
$iclISOCountryList->add(752,"Sweden","SWE",0);
|
230 |
+
$iclISOCountryList->add(756,"Switzerland","CHE",0);
|
231 |
+
$iclISOCountryList->add(760,"Syrian Arab Republic","SYR",0);
|
232 |
+
$iclISOCountryList->add(158,"Taiwan,","TWN",0);
|
233 |
+
$iclISOCountryList->add(762,"Tajikistan","TJK",0);
|
234 |
+
$iclISOCountryList->add(834,"Tanzania","TZA",0);
|
235 |
+
$iclISOCountryList->add(764,"Thailand","THA",0);
|
236 |
+
$iclISOCountryList->add(768,"Togo","TGO",0);
|
237 |
+
$iclISOCountryList->add(772,"Tokelau","TKL",0);
|
238 |
+
$iclISOCountryList->add(776,"Tonga","TON",0);
|
239 |
+
$iclISOCountryList->add(780,"Trinidad and Tobago","TTO",0);
|
240 |
+
$iclISOCountryList->add(788,"Tunisia","TUN",0);
|
241 |
+
$iclISOCountryList->add(792,"Turkey","TUR",0);
|
242 |
+
$iclISOCountryList->add(795,"Turkmenistan","TKM",0);
|
243 |
+
$iclISOCountryList->add(796,"Turks and Caicos Islands","TCA",0);
|
244 |
+
$iclISOCountryList->add(798,"Tuvalu","TUV",0);
|
245 |
+
$iclISOCountryList->add(800,"Uganda","UGA",0);
|
246 |
+
$iclISOCountryList->add(804,"Ukraine","UKR",0);
|
247 |
+
$iclISOCountryList->add(784,"United Arab Emirates","ARE",0);
|
248 |
+
$iclISOCountryList->add(581,"United States Minor Outlying Islands","UMI",0);
|
249 |
+
$iclISOCountryList->add(858,"Uruguay Eastern","URY",0);
|
250 |
+
$iclISOCountryList->add(860,"Uzbekistan","UZB",0);
|
251 |
+
$iclISOCountryList->add(548,"Vanuatu","VUT",0);
|
252 |
+
$iclISOCountryList->add(336,"Vatican City State","VAT",0);
|
253 |
+
$iclISOCountryList->add(862,"Venezuela","VEN",0);
|
254 |
+
$iclISOCountryList->add(704,"Vietnam","VNM",0);
|
255 |
+
$iclISOCountryList->add(92,"Virgin Islands, British","VGB",0);
|
256 |
+
$iclISOCountryList->add(850,"Virgin Islands, U.S.","VIR",0);
|
257 |
+
$iclISOCountryList->add(876,"Wallis and Futuna","WLF",0);
|
258 |
+
$iclISOCountryList->add(732,"Western Sahara","ESH",0);
|
259 |
+
$iclISOCountryList->add(887,"Yemen","YEM",0);
|
260 |
+
$iclISOCountryList->add(894,"Zambia","ZMB",0);
|
261 |
+
$iclISOCountryList->add(716,"Zimbabwe","ZWE",0);
|
262 |
+
|
263 |
+
return $iclISOCountryList;
|
264 |
+
}
|
265 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ISOCurrencies.php
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include_once ("ThePaymentGateway/TPG_Common.php");
|
4 |
+
|
5 |
+
class CSV_ISOCurrencies
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Get the list of ISO Currencies
|
9 |
+
*
|
10 |
+
* @return ISOCurrencyList
|
11 |
+
*/
|
12 |
+
public static function getISOCurrencyList()
|
13 |
+
{
|
14 |
+
$iclISOCurrencyList = new CSV_ISOCurrencyList();
|
15 |
+
|
16 |
+
$iclISOCurrencyList->add(634, "Qatari Rial","QAR", 2);
|
17 |
+
$iclISOCurrencyList->add(566, "Naira", "NGN", 2);
|
18 |
+
$iclISOCurrencyList->add(678, "Dobra", "STD", 2);
|
19 |
+
$iclISOCurrencyList->add(943, "Metical", "MZN", 2);
|
20 |
+
$iclISOCurrencyList->add(826, "Pound Sterling", "GBP", 2);
|
21 |
+
$iclISOCurrencyList->add(654, "Saint Helena Pound", "SHP", 2);
|
22 |
+
$iclISOCurrencyList->add(704, "Vietnamese ??ng", "VND", 2);
|
23 |
+
$iclISOCurrencyList->add(952, "CFA Franc BCEAO", "XOF", 0);
|
24 |
+
$iclISOCurrencyList->add(356, "Indian Rupee", "INR", 2);
|
25 |
+
$iclISOCurrencyList->add(807, "Denar", "MKD", 2);
|
26 |
+
$iclISOCurrencyList->add(959, "Gold (one Troy ounce)", "XAU", 0);
|
27 |
+
$iclISOCurrencyList->add(410, "South Korean Won", "KRW", 0);
|
28 |
+
$iclISOCurrencyList->add(946, "Romanian New Leu", "RON", 2);
|
29 |
+
$iclISOCurrencyList->add(949, "New Turkish Lira", "TRY", 2);
|
30 |
+
$iclISOCurrencyList->add(532, "Netherlands Antillian Guilder", "ANG", 2);
|
31 |
+
$iclISOCurrencyList->add(788, "Tunisian Dinar", "TND", 3);
|
32 |
+
$iclISOCurrencyList->add(646, "Rwanda Franc", "RWF", 0);
|
33 |
+
$iclISOCurrencyList->add(504, "Moroccan Dirham", "MAD", 2);
|
34 |
+
$iclISOCurrencyList->add(174, "Comoro Franc", "KMF", 0);
|
35 |
+
$iclISOCurrencyList->add(484, "Mexican Peso", "MXN", 2);
|
36 |
+
$iclISOCurrencyList->add(478, "Ouguiya", "MRO", 2);
|
37 |
+
$iclISOCurrencyList->add(233, "Kroon", "EEK", 2);
|
38 |
+
$iclISOCurrencyList->add(400, "Jordanian Dinar", "JOD", 3);
|
39 |
+
$iclISOCurrencyList->add(292, "Gibraltar pound", "GIP", 2);
|
40 |
+
$iclISOCurrencyList->add(690, "Seychelles Rupee", "SCR", 2);
|
41 |
+
$iclISOCurrencyList->add(422, "Lebanese Pound", "LBP", 2);
|
42 |
+
$iclISOCurrencyList->add(232, "Nakfa", "ERN", 2);
|
43 |
+
$iclISOCurrencyList->add(496, "Tugrik", "MNT", 2);
|
44 |
+
$iclISOCurrencyList->add(328, "Guyana Dollar", "GYD", 2);
|
45 |
+
$iclISOCurrencyList->add(970, "Unidad de Valor Real", "COU", 2);
|
46 |
+
$iclISOCurrencyList->add(974, "Belarusian Ruble", "BYR", 0);
|
47 |
+
$iclISOCurrencyList->add(608, "Philippine Peso", "PHP", 2);
|
48 |
+
$iclISOCurrencyList->add(598, "Kina", "PGK", 2);
|
49 |
+
$iclISOCurrencyList->add(951, "East Caribbean Dollar", "XCD", 2);
|
50 |
+
$iclISOCurrencyList->add(52, "Barbados Dollar", "BBD", 2);
|
51 |
+
$iclISOCurrencyList->add(944, "Azerbaijanian Manat", "AZN", 2);
|
52 |
+
$iclISOCurrencyList->add(434, "Libyan Dinar", "LYD", 3);
|
53 |
+
$iclISOCurrencyList->add(706, "Somali Shilling", "SOS", 2);
|
54 |
+
$iclISOCurrencyList->add(950, "CFA Franc BEAC", "XAF", 0);
|
55 |
+
$iclISOCurrencyList->add(840, "US Dollar", "USD", 2);
|
56 |
+
$iclISOCurrencyList->add(68, "Boliviano", "BOB", 2);
|
57 |
+
$iclISOCurrencyList->add(214, "Dominican Peso", "DOP", 2);
|
58 |
+
$iclISOCurrencyList->add(818, "Egyptian Pound", "EGP", 2);
|
59 |
+
$iclISOCurrencyList->add(170, "Colombian Peso", "COP", 2);
|
60 |
+
$iclISOCurrencyList->add(986, "Brazilian Real", "BRL", 2);
|
61 |
+
$iclISOCurrencyList->add(961, "Silver (one Troy ounce)", "XAG", 0);
|
62 |
+
$iclISOCurrencyList->add(973, "Kwanza", "AOA", 2);
|
63 |
+
$iclISOCurrencyList->add(962, "Platinum (one Troy ounce)", "XPT", 0);
|
64 |
+
$iclISOCurrencyList->add(414, "Kuwaiti Dinar", "KWD", 3);
|
65 |
+
$iclISOCurrencyList->add(604, "Nuevo Sol", "PEN", 2);
|
66 |
+
$iclISOCurrencyList->add(702, "Singapore Dollar", "SGD", 2);
|
67 |
+
$iclISOCurrencyList->add(862, "Venezuelan bol�var", "VEB", 2);
|
68 |
+
$iclISOCurrencyList->add(953, "CFP franc", "XPF", 0);
|
69 |
+
$iclISOCurrencyList->add(558, "Cordoba Oro", "NIO", 2);
|
70 |
+
$iclISOCurrencyList->add(348, "Forint", "HUF", 2);
|
71 |
+
$iclISOCurrencyList->add(948, "WIR Franc ", "CHW", 2);
|
72 |
+
$iclISOCurrencyList->add(116, "Riel", "KHR", 2);
|
73 |
+
$iclISOCurrencyList->add(956, "European Monetary Unit", "XBB", 0);
|
74 |
+
$iclISOCurrencyList->add(156, "Yuan Renminbi", "CNY", 2);
|
75 |
+
$iclISOCurrencyList->add(834, "Tanzanian Shilling", "TZS", 2);
|
76 |
+
$iclISOCurrencyList->add(997, "", "USN", 2);
|
77 |
+
$iclISOCurrencyList->add(981, "Lari", "GEL", 2);
|
78 |
+
$iclISOCurrencyList->add(242, "Fiji Dollar", "FJD", 2);
|
79 |
+
$iclISOCurrencyList->add(941, "Serbian Dinar", "RSD", 2);
|
80 |
+
$iclISOCurrencyList->add(104, "Kyat", "MMK", 2);
|
81 |
+
$iclISOCurrencyList->add(84, " Belize Dollar", "BZD", 2);
|
82 |
+
$iclISOCurrencyList->add(710, "South African Rand", "ZAR", 2);
|
83 |
+
$iclISOCurrencyList->add(760, "Syrian Pound", "SYP", 2);
|
84 |
+
$iclISOCurrencyList->add(512, "Rial Omani", "OMR", 3);
|
85 |
+
$iclISOCurrencyList->add(324, "Guinea Franc", "GNF", 0);
|
86 |
+
$iclISOCurrencyList->add(196, "Cyprus Pound", "CYP", 2);
|
87 |
+
$iclISOCurrencyList->add(960, "Special Drawing Rights", "XDR", 0);
|
88 |
+
$iclISOCurrencyList->add(716, "Zimbabwe Dollar", "ZWD", 2);
|
89 |
+
$iclISOCurrencyList->add(972, "Somoni", "TJS", 2);
|
90 |
+
$iclISOCurrencyList->add(462, "Rufiyaa", "MVR", 2);
|
91 |
+
$iclISOCurrencyList->add(979, "Mexican Unidad de Inversion (UDI)", "MXV", 2);
|
92 |
+
$iclISOCurrencyList->add(860, "Uzbekistan Som", "UZS", 2);
|
93 |
+
$iclISOCurrencyList->add(12, "Algerian Dinar", "DZD", 2);
|
94 |
+
$iclISOCurrencyList->add(332, "Haiti Gourde", "HTG", 2);
|
95 |
+
$iclISOCurrencyList->add(963, "Code reserved for testing purposes", "XTS", 0);
|
96 |
+
$iclISOCurrencyList->add(32, "Argentine Peso", "ARS", 2);
|
97 |
+
$iclISOCurrencyList->add(642, "Romanian Leu", "ROL", 2);
|
98 |
+
$iclISOCurrencyList->add(984, "Bolivian Mvdol (Funds code)", "BOV", 2);
|
99 |
+
$iclISOCurrencyList->add(440, "Lithuanian Litas", "LTL", 2);
|
100 |
+
$iclISOCurrencyList->add(480, "Mauritius Rupee", "MUR", 2);
|
101 |
+
$iclISOCurrencyList->add(426, "Loti", "LSL", 2);
|
102 |
+
$iclISOCurrencyList->add(262, "Djibouti Franc", "DJF", 0);
|
103 |
+
$iclISOCurrencyList->add(886, "Yemeni Rial", "YER", 2);
|
104 |
+
$iclISOCurrencyList->add(748, "Lilangeni", "SZL", 2);
|
105 |
+
$iclISOCurrencyList->add(192, "Cuban Peso", "CUP", 2);
|
106 |
+
$iclISOCurrencyList->add(548, "Vatu", "VUV", 0);
|
107 |
+
$iclISOCurrencyList->add(360, "Rupiah", "IDR", 2);
|
108 |
+
$iclISOCurrencyList->add(51, "Armenian Dram", "AMD", 2);
|
109 |
+
$iclISOCurrencyList->add(894, "Kwacha", "ZMK", 2);
|
110 |
+
$iclISOCurrencyList->add(90, "Solomon Islands Dollar", "SBD", 2);
|
111 |
+
$iclISOCurrencyList->add(132, "Cape Verde Escudo", "CVE", 2);
|
112 |
+
$iclISOCurrencyList->add(999, "No currency", "XXX", 0);
|
113 |
+
$iclISOCurrencyList->add(524, "Nepalese Rupee", "NPR", 2);
|
114 |
+
$iclISOCurrencyList->add(203, "Czech Koruna", "CZK", 2);
|
115 |
+
$iclISOCurrencyList->add(44, "Bahamian Dollar", "BSD", 2);
|
116 |
+
$iclISOCurrencyList->add(96, "Brunei Dollar", "BND", 2);
|
117 |
+
$iclISOCurrencyList->add(50, "Bangladeshi Taka", "BDT", 2);
|
118 |
+
$iclISOCurrencyList->add(404, "Kenyan Shilling", "KES", 2);
|
119 |
+
$iclISOCurrencyList->add(947, "WIR Euro ", "CHE", 2);
|
120 |
+
$iclISOCurrencyList->add(964, "Palladium (one Troy ounce)", "XPD", 0);
|
121 |
+
$iclISOCurrencyList->add(398, "Tenge", "KZT", 2);
|
122 |
+
$iclISOCurrencyList->add(352, "Iceland Krona", "ISK", 2);
|
123 |
+
$iclISOCurrencyList->add(64, "Ngultrum", "BTN", 2);
|
124 |
+
$iclISOCurrencyList->add(533, "Aruban Guilder", "AWG", 2);
|
125 |
+
$iclISOCurrencyList->add(230, "Ethiopian Birr", "ETB", 2);
|
126 |
+
$iclISOCurrencyList->add(800, "Uganda Shilling", "UGX", 2);
|
127 |
+
$iclISOCurrencyList->add(968, "Surinam Dollar", "SRD", 2);
|
128 |
+
$iclISOCurrencyList->add(882, "Samoan Tala", "WST", 2);
|
129 |
+
$iclISOCurrencyList->add(454, "Kwacha", "MWK", 2);
|
130 |
+
$iclISOCurrencyList->add(985, "Zloty", "PLN", 2);
|
131 |
+
$iclISOCurrencyList->add(124, "Canadian Dollar", "CAD", 2);
|
132 |
+
$iclISOCurrencyList->add(776, "Pa'anga", "TOP", 2);
|
133 |
+
$iclISOCurrencyList->add(208, "Danish Krone", "DKK", 2);
|
134 |
+
$iclISOCurrencyList->add(108, "Burundian Franc", "BIF", 0);
|
135 |
+
$iclISOCurrencyList->add(764, "Baht", "THB", 2);
|
136 |
+
$iclISOCurrencyList->add(458, "Malaysian Ringgit", "MYR", 2);
|
137 |
+
$iclISOCurrencyList->add(364, "Iranian Rial", "IRR", 2);
|
138 |
+
$iclISOCurrencyList->add(600, "Guarani", "PYG", 0);
|
139 |
+
$iclISOCurrencyList->add(977, "Convertible Marks", "BAM", 2);
|
140 |
+
$iclISOCurrencyList->add(446, "Pataca", "MOP", 2);
|
141 |
+
$iclISOCurrencyList->add(780, "Trinidad and Tobago Dollar", "TTD", 2);
|
142 |
+
$iclISOCurrencyList->add(703, "Slovak Koruna", "SKK", 2);
|
143 |
+
$iclISOCurrencyList->add(958, "European Unit of Account 17 (E.U.A.-17)", "XBD", 0);
|
144 |
+
$iclISOCurrencyList->add(430, "Liberian Dollar", "LRD", 2);
|
145 |
+
$iclISOCurrencyList->add(191, "Croatian Kuna", "HRK", 2);
|
146 |
+
$iclISOCurrencyList->add(694, "Leone", "SLL", 2);
|
147 |
+
$iclISOCurrencyList->add(756, "Swiss Franc", "CHF", 2);
|
148 |
+
$iclISOCurrencyList->add(969, "Malagasy Ariary", "MGA", 0);
|
149 |
+
$iclISOCurrencyList->add(270, "Dalasi", "GMD", 2);
|
150 |
+
$iclISOCurrencyList->add(418, "Kip", "LAK", 2);
|
151 |
+
$iclISOCurrencyList->add(516, "Namibian Dollar", "NAD", 2);
|
152 |
+
$iclISOCurrencyList->add(392, "Japanese yen", "JPY", 0);
|
153 |
+
$iclISOCurrencyList->add(320, "Quetzal", "GTQ", 2);
|
154 |
+
$iclISOCurrencyList->add(554, "New Zealand Dollar", "NZD", 2);
|
155 |
+
$iclISOCurrencyList->add(578, "Norwegian Krone", "NOK", 2);
|
156 |
+
$iclISOCurrencyList->add(376, "New Israeli Shekel", "ILS", 2);
|
157 |
+
$iclISOCurrencyList->add(957, "European Unit of Account 9 (E.U.A.-9)", "XBC", 0);
|
158 |
+
$iclISOCurrencyList->add(498, "Moldovan Leu", "MDL", 2);
|
159 |
+
$iclISOCurrencyList->add(998, "", "USS", 2);
|
160 |
+
$iclISOCurrencyList->add(955, "European Composite Unit (EURCO)", "XBA", 0);
|
161 |
+
$iclISOCurrencyList->add(344, "Hong Kong Dollar", "HKD", 2);
|
162 |
+
$iclISOCurrencyList->add(417, "Som", "KGS", 2);
|
163 |
+
$iclISOCurrencyList->add(858, "Peso Uruguayo", "UYU", 2);
|
164 |
+
$iclISOCurrencyList->add(60, "Bermudian Dollar ", "BMD", 2);
|
165 |
+
$iclISOCurrencyList->add(682, "Saudi Riyal", "SAR", 2);
|
166 |
+
$iclISOCurrencyList->add(643, "Russian Ruble", "RUB", 2);
|
167 |
+
$iclISOCurrencyList->add(470, "Maltese Lira", "MTL", 2);
|
168 |
+
$iclISOCurrencyList->add(340, "Lempira", "HNL", 2);
|
169 |
+
$iclISOCurrencyList->add(72, "Pula", "BWP", 2);
|
170 |
+
$iclISOCurrencyList->add(368, "Iraqi Dinar", "IQD", 3);
|
171 |
+
$iclISOCurrencyList->add(188, "Costa Rican Colon", "CRC", 2);
|
172 |
+
$iclISOCurrencyList->add(144, "Sri Lanka Rupee", "LKR", 2);
|
173 |
+
$iclISOCurrencyList->add(752, "Swedish Krona", "SEK", 2);
|
174 |
+
$iclISOCurrencyList->add(136, "Cayman Islands Dollar", "KYD", 2);
|
175 |
+
$iclISOCurrencyList->add(8, "Lek", "ALL", 2);
|
176 |
+
$iclISOCurrencyList->add(48, "Bahraini Dinar", "BHD", 3);
|
177 |
+
$iclISOCurrencyList->add(795, "Manat", "TMM", 2);
|
178 |
+
$iclISOCurrencyList->add(938, "Sudanese Pound", "SDG", 2);
|
179 |
+
$iclISOCurrencyList->add(590, "Balboa", "PAB", 2);
|
180 |
+
$iclISOCurrencyList->add(152, "Chilean Peso", "CLP", 0);
|
181 |
+
$iclISOCurrencyList->add(980, "Hryvnia", "UAH", 2);
|
182 |
+
$iclISOCurrencyList->add(428, "Latvian Lats", "LVL", 2);
|
183 |
+
$iclISOCurrencyList->add(288, "Cedi", "GHS", 2);
|
184 |
+
$iclISOCurrencyList->add(978, "Euro", "EUR", 2);
|
185 |
+
$iclISOCurrencyList->add(976, "Franc Congolais", "CDF", 2);
|
186 |
+
$iclISOCurrencyList->add(586, "Pakistan Rupee", "PKR", 2);
|
187 |
+
$iclISOCurrencyList->add(408, "North Korean Won", "KPW", 2);
|
188 |
+
$iclISOCurrencyList->add(388, "Jamaican Dollar", "JMD", 2);
|
189 |
+
$iclISOCurrencyList->add(990, "Unidades de formento", "CLF", 0);
|
190 |
+
$iclISOCurrencyList->add(971, "Afghani", "AFN", 2);
|
191 |
+
$iclISOCurrencyList->add(975, "Bulgarian Lev", "BGN", 2);
|
192 |
+
$iclISOCurrencyList->add(36, "Australian Dollar", "AUD", 2);
|
193 |
+
$iclISOCurrencyList->add(238, "Falkland Islands Pound", "FKP", 2);
|
194 |
+
$iclISOCurrencyList->add(901, "New Taiwan Dollar", "TWD", 2);
|
195 |
+
$iclISOCurrencyList->add(784, "United Arab Emirates dirham", "AED", 2);
|
196 |
+
|
197 |
+
return $iclISOCurrencyList;
|
198 |
+
}
|
199 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/PaymentFormHelper.php
ADDED
@@ -0,0 +1,447 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once "app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php";
|
4 |
+
|
5 |
+
class CSV_ListItemList
|
6 |
+
{
|
7 |
+
private $m_lilListItemList;
|
8 |
+
|
9 |
+
public function getCount()
|
10 |
+
{
|
11 |
+
return count($this->m_lilListItemList);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getAt($nIndex)
|
15 |
+
{
|
16 |
+
if ($nIndex < 0 ||
|
17 |
+
$nIndex >= count($this->m_lilListItemList))
|
18 |
+
{
|
19 |
+
throw new Exception('Array index out of bounds');
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->m_lilListItemList[$nIndex];
|
23 |
+
}
|
24 |
+
|
25 |
+
public function add($szName, $szValue, $boIsSelected)
|
26 |
+
{
|
27 |
+
$liListItem = new CSV_ListItem($szName, $szValue, $boIsSelected);
|
28 |
+
|
29 |
+
$this->m_lilListItemList[] = $liListItem;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function toString()
|
33 |
+
{
|
34 |
+
$szReturnString = "";
|
35 |
+
|
36 |
+
for ($nCount = 0; $nCount < count($this->m_lilListItemList); $nCount++)
|
37 |
+
{
|
38 |
+
$liListItem = $this->m_lilListItemList[$nCount];
|
39 |
+
|
40 |
+
$szReturnString = $szReturnString."<option";
|
41 |
+
|
42 |
+
if ($liListItem->getValue() != null &&
|
43 |
+
$liListItem->getValue() != "")
|
44 |
+
{
|
45 |
+
$szReturnString = $szReturnString." value=\"".$liListItem->getValue()."\"";
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($liListItem->getIsSelected() == true)
|
49 |
+
{
|
50 |
+
$szReturnString = $szReturnString." selected=\"selected\"";
|
51 |
+
}
|
52 |
+
|
53 |
+
$szReturnString = $szReturnString.">".$liListItem->getName()."</option>\n";
|
54 |
+
}
|
55 |
+
|
56 |
+
return ($szReturnString);
|
57 |
+
}
|
58 |
+
|
59 |
+
//constructor
|
60 |
+
public function __construct()
|
61 |
+
{
|
62 |
+
$this->m_lilListItemList = array();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
class CSV_ListItem
|
67 |
+
{
|
68 |
+
private $m_szName;
|
69 |
+
private $m_szValue;
|
70 |
+
private $m_boIsSelected;
|
71 |
+
|
72 |
+
//public properties
|
73 |
+
public function getName()
|
74 |
+
{
|
75 |
+
return $this->m_szName;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getValue()
|
79 |
+
{
|
80 |
+
return $this->m_szValue;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getIsSelected()
|
84 |
+
{
|
85 |
+
return $this->m_boIsSelected;
|
86 |
+
}
|
87 |
+
|
88 |
+
//constructor
|
89 |
+
public function __construct($szName, $szValue, $boIsSelected)
|
90 |
+
{
|
91 |
+
$this->m_szName = $szName;
|
92 |
+
$this->m_szValue = $szValue;
|
93 |
+
$this->m_boIsSelected = $boIsSelected;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
class CSV_PaymentFormHelper
|
98 |
+
{
|
99 |
+
/**
|
100 |
+
* Hash mechanism for hosted payment form trasaction
|
101 |
+
*
|
102 |
+
* @param unknown_type $szMerchantID
|
103 |
+
* @param unknown_type $szPassword
|
104 |
+
* @param unknown_type $hmHashMethod
|
105 |
+
* @param unknown_type $szPreSharedKey
|
106 |
+
* @param unknown_type $nAmount
|
107 |
+
* @param unknown_type $nCurrencyCode
|
108 |
+
* @param unknown_type $szOrderID
|
109 |
+
* @param unknown_type $szTransactionType
|
110 |
+
* @param unknown_type $szTransactionDateTime
|
111 |
+
* @param unknown_type $szCallbackURL
|
112 |
+
* @param unknown_type $szOrderDescription
|
113 |
+
* @param unknown_type $szCustomerName
|
114 |
+
* @param unknown_type $szAddress1
|
115 |
+
* @param unknown_type $szAddress2
|
116 |
+
* @param unknown_type $szAddress3
|
117 |
+
* @param unknown_type $szAddress4
|
118 |
+
* @param unknown_type $szCity
|
119 |
+
* @param unknown_type $szState
|
120 |
+
* @param unknown_type $szPostCode
|
121 |
+
* @param unknown_type $nCountryCode
|
122 |
+
* @param unknown_type $boCV2Mandatory
|
123 |
+
* @param unknown_type $boAddress1Mandatory
|
124 |
+
* @param unknown_type $boCityMandatory
|
125 |
+
* @param unknown_type $boPostCodeMandatory
|
126 |
+
* @param unknown_type $boStateMandatory
|
127 |
+
* @param unknown_type $boCountryMandatory
|
128 |
+
* @param unknown_type $rdmResultdeliveryMethod
|
129 |
+
* @param unknown_type $szServerResultURL
|
130 |
+
* @param unknown_type $boPaymentFormDisplaysResult
|
131 |
+
* @return unknown
|
132 |
+
*/
|
133 |
+
public static function calculateHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription, $szCustomerName, $szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode, $boCV2Mandatory, $boAddress1Mandatory, $boCityMandatory, $boPostCodeMandatory, $boStateMandatory, $boCountryMandatory, $rdmResultdeliveryMethod, $szServerResultURL, $boPaymentFormDisplaysResult, $szServerResultURLCookieVariables, $szServerResultURLFormVariables, $szServerResultURLQueryStringVariables)
|
134 |
+
{
|
135 |
+
$szHashDigest = '';
|
136 |
+
$szStringBeforeHash;
|
137 |
+
|
138 |
+
$szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
|
139 |
+
'Password='.$szPassword.'&'.
|
140 |
+
'Amount='.$nAmount.'&'.
|
141 |
+
'CurrencyCode='.$nCurrencyCode.'&'.
|
142 |
+
'OrderID='.$szOrderID.'&'.
|
143 |
+
'TransactionType='.$szTransactionType.'&'.
|
144 |
+
'TransactionDateTime='.$szTransactionDateTime.'&'.
|
145 |
+
'CallbackURL='.$szCallbackURL.'&'.
|
146 |
+
'OrderDescription='.$szOrderDescription.'&'.
|
147 |
+
'CustomerName='.$szCustomerName.'&'.
|
148 |
+
'Address1='.$szAddress1.'&'.
|
149 |
+
'Address2='.$szAddress2.'&'.
|
150 |
+
'Address3='.$szAddress3.'&'.
|
151 |
+
'Address4='.$szAddress4.'&'.
|
152 |
+
'City='.$szCity.'&'.
|
153 |
+
'State='.$szState.'&'.
|
154 |
+
'PostCode='.$szPostCode.'&'.
|
155 |
+
'CountryCode='.$nCountryCode.'&'.
|
156 |
+
'CV2Mandatory='.$boCV2Mandatory.'&'.
|
157 |
+
'Address1Mandatory='.$boAddress1Mandatory.'&'.
|
158 |
+
'CityMandatory='.$boCityMandatory.'&'.
|
159 |
+
'PostCodeMandatory='.$boPostCodeMandatory.'&'.
|
160 |
+
'StateMandatory='.$boStateMandatory.'&'.
|
161 |
+
'CountryMandatory='.$boCountryMandatory.'&'.
|
162 |
+
'ResultDeliveryMethod='.$rdmResultdeliveryMethod.'&'.
|
163 |
+
'ServerResultURL='.$szServerResultURL.'&'.
|
164 |
+
'PaymentFormDisplaysResult='.$boPaymentFormDisplaysResult.'&'.
|
165 |
+
'ServerResultURLCookieVariables='.$szServerResultURLCookieVariables.'&'.
|
166 |
+
'ServerResultURLFormVariables='.$szServerResultURLFormVariables.'&'.
|
167 |
+
'ServerResultURLQueryStringVariables='.$szServerResultURLQueryStringVariables;
|
168 |
+
|
169 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
170 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
171 |
+
{
|
172 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
173 |
+
}
|
174 |
+
|
175 |
+
$szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
176 |
+
|
177 |
+
return $szHashDigest;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Hash mechanism for transparent redirect trasaction
|
182 |
+
*
|
183 |
+
* @param unknown_type $szMerchantID
|
184 |
+
* @param unknown_type $szPassword
|
185 |
+
* @param unknown_type $hmHashMethod
|
186 |
+
* @param unknown_type $szPreSharedKey
|
187 |
+
* @param unknown_type $nAmount
|
188 |
+
* @param unknown_type $nCurrencyCode
|
189 |
+
* @param unknown_type $szOrderID
|
190 |
+
* @param unknown_type $szTransactionType
|
191 |
+
* @param unknown_type $szTransactionDateTime
|
192 |
+
* @param unknown_type $szCallbackURL
|
193 |
+
* @param unknown_type $szOrderDescription
|
194 |
+
* @return unknown
|
195 |
+
*/
|
196 |
+
public static function calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription)
|
197 |
+
{
|
198 |
+
$szHashDigest = '';
|
199 |
+
$szStringBeforeHash;
|
200 |
+
|
201 |
+
$szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
|
202 |
+
'Password='.$szPassword.'&'.
|
203 |
+
'Amount='.$nAmount.'&'.
|
204 |
+
'CurrencyCode='.$nCurrencyCode.'&'.
|
205 |
+
'OrderID='.$szOrderID.'&'.
|
206 |
+
'TransactionType='.$szTransactionType.'&'.
|
207 |
+
'TransactionDateTime='.$szTransactionDateTime.'&'.
|
208 |
+
'CallbackURL='.$szCallbackURL.'&'.
|
209 |
+
'OrderDescription='.$szOrderDescription;
|
210 |
+
|
211 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
212 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
213 |
+
{
|
214 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
215 |
+
}
|
216 |
+
|
217 |
+
$szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
218 |
+
|
219 |
+
return $szHashDigest;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Hash mechanism for calculating the hash digest for the post 3D Secure Authentication in the transparent redirect payment mode
|
224 |
+
*
|
225 |
+
* @param unknown_type $szMerchantID
|
226 |
+
* @param unknown_type $szPassword
|
227 |
+
* @param unknown_type $hmHashMethod
|
228 |
+
* @param unknown_type $szPreSharedKey
|
229 |
+
* @param unknown_type $szPaRES
|
230 |
+
* @param unknown_type $szCrossReference
|
231 |
+
* @param unknown_type $szTransactionDateTime
|
232 |
+
* @param unknown_type $szCallbackURL
|
233 |
+
* @return unknown
|
234 |
+
*/
|
235 |
+
public static function calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL)
|
236 |
+
{
|
237 |
+
$szHashDigest = '';
|
238 |
+
$szStringBeforeHash;
|
239 |
+
|
240 |
+
$szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
|
241 |
+
'Password='.$szPassword.'&'.
|
242 |
+
'CrossReference='.$szCrossReference.'&'.
|
243 |
+
'TransactionDateTime='.$szTransactionDateTime.'&'.
|
244 |
+
'CallbackURL='.$szCallbackURL.'&'.
|
245 |
+
'PaRES='.$szPaRES;
|
246 |
+
|
247 |
+
|
248 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
249 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
250 |
+
{
|
251 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
252 |
+
}
|
253 |
+
|
254 |
+
$szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
255 |
+
|
256 |
+
return $szHashDigest;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Private hash calculator for hashing the raw string
|
261 |
+
*
|
262 |
+
* @param unknown_type $hmHashMethod
|
263 |
+
* @param unknown_type $szPreSharedKey
|
264 |
+
* @param unknown_type $szStringBeforeHash
|
265 |
+
* @return unknown
|
266 |
+
*/
|
267 |
+
private static function _hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash)
|
268 |
+
{
|
269 |
+
$szHashDigest = '';
|
270 |
+
|
271 |
+
switch ($hmHashMethod)
|
272 |
+
{
|
273 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5:
|
274 |
+
$szHashDigest = md5($szStringBeforeHash);
|
275 |
+
break;
|
276 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1:
|
277 |
+
$szHashDigest = sha1($szStringBeforeHash);
|
278 |
+
break;
|
279 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_HMACMD5:
|
280 |
+
$szHashDigest = hash_hmac('md5', $szStringBeforeHash, $szPreSharedKey);
|
281 |
+
break;
|
282 |
+
case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_HMACSHA1:
|
283 |
+
$szHashDigest = hash_hmac('sha1', $szStringBeforeHash, $szPreSharedKey);
|
284 |
+
break;
|
285 |
+
default:
|
286 |
+
throw new Exception('Invalid hash method used for hash digest calculation: '.$hmHashMethod);
|
287 |
+
break;
|
288 |
+
}
|
289 |
+
|
290 |
+
//$szHashDigest = strtoupper($szHashDigest);
|
291 |
+
|
292 |
+
return $szHashDigest;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Hash validator mechanism for hosted payment form transaction
|
297 |
+
*
|
298 |
+
* @param unknown_type $szHashDigest
|
299 |
+
* @param unknown_type $szMerchantID
|
300 |
+
* @param unknown_type $szStatusCode
|
301 |
+
* @param unknown_type $szMessage
|
302 |
+
* @param unknown_type $szPreviousStatusCode
|
303 |
+
* @param unknown_type $szPreviousMessage
|
304 |
+
* @param unknown_type $szCrossReference
|
305 |
+
* @param unknown_type $szAmount
|
306 |
+
* @param unknown_type $szCurrencyCode
|
307 |
+
* @param unknown_type $szOrderID
|
308 |
+
* @param unknown_type $szTransactionType
|
309 |
+
* @param unknown_type $szTransactionDateTime
|
310 |
+
* @param unknown_type $szOrderDescription
|
311 |
+
* @param unknown_type $szCustomerName
|
312 |
+
* @param unknown_type $szAddress1
|
313 |
+
* @param unknown_type $szAddress2
|
314 |
+
* @param unknown_type $szAddress3
|
315 |
+
* @param unknown_type $szAddress4
|
316 |
+
* @param unknown_type $szCity
|
317 |
+
* @param unknown_type $szState
|
318 |
+
* @param unknown_type $szPostCode
|
319 |
+
* @param unknown_type $szCountryCode
|
320 |
+
* @return unknown
|
321 |
+
*/
|
322 |
+
public static function compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
|
323 |
+
{
|
324 |
+
$boMatch = false;
|
325 |
+
$szCalculatedHashDigest;
|
326 |
+
$szStringBeforeHash;
|
327 |
+
|
328 |
+
$szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
|
329 |
+
'Password='.$szPassword.'&'.
|
330 |
+
'StatusCode='.$formVariables['StatusCode'].'&'.
|
331 |
+
'Message='.$formVariables['Message'].'&'.
|
332 |
+
'PreviousStatusCode='.$formVariables['PreviousStatusCode'].'&'.
|
333 |
+
'PreviousMessage='.$formVariables['PreviousMessage'].'&'.
|
334 |
+
'CrossReference='.$formVariables['CrossReference'].'&'.
|
335 |
+
'Amount='.$formVariables['Amount'].'&'.
|
336 |
+
'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
|
337 |
+
'OrderID='.$formVariables['OrderID'].'&'.
|
338 |
+
'TransactionType='.$formVariables['TransactionType'].'&'.
|
339 |
+
'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
|
340 |
+
'OrderDescription='.$formVariables['OrderDescription'].'&'.
|
341 |
+
'CustomerName='.$formVariables['CustomerName'].'&'.
|
342 |
+
'Address1='.$formVariables['Address1'].'&'.
|
343 |
+
'Address2='.$formVariables['Address2'].'&'.
|
344 |
+
'Address3='.$formVariables['Address3'].'&'.
|
345 |
+
'Address4='.$formVariables['Address4'].'&'.
|
346 |
+
'City='.$formVariables['City'].'&'.
|
347 |
+
'State='.$formVariables['State'].'&'.
|
348 |
+
'PostCode='.$formVariables['PostCode'].'&'.
|
349 |
+
'CountryCode='.$formVariables['CountryCode'];
|
350 |
+
|
351 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
352 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
353 |
+
{
|
354 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
355 |
+
}
|
356 |
+
|
357 |
+
$szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
358 |
+
if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
|
359 |
+
{
|
360 |
+
$boMatch = true;
|
361 |
+
}
|
362 |
+
|
363 |
+
return $boMatch;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Hash validator mechanism for the incoming payment complete hash in transparent redirect payment mode
|
368 |
+
*
|
369 |
+
* @param unknown_type $formVariables
|
370 |
+
* @param unknown_type $szPassword
|
371 |
+
* @param unknown_type $hmHashMethod
|
372 |
+
* @param unknown_type $szPreSharedKey
|
373 |
+
* @return unknown
|
374 |
+
*/
|
375 |
+
public static function comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
|
376 |
+
{
|
377 |
+
$boMatch = false;
|
378 |
+
$szCalculatedHashDigest;
|
379 |
+
$szStringBeforeHash;
|
380 |
+
|
381 |
+
$szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
|
382 |
+
'Password='.$szPassword.'&'.
|
383 |
+
'Amount='.$formVariables['Amount'].'&'.
|
384 |
+
'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
|
385 |
+
'OrderID='.$formVariables['OrderID'].'&'.
|
386 |
+
'TransactionType='.$formVariables['TransactionType'].'&'.
|
387 |
+
'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
|
388 |
+
'OrderDescription='.$formVariables['OrderDescription'];
|
389 |
+
|
390 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
391 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
392 |
+
{
|
393 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
394 |
+
}
|
395 |
+
|
396 |
+
$szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
397 |
+
if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
|
398 |
+
{
|
399 |
+
$boMatch = true;
|
400 |
+
}
|
401 |
+
|
402 |
+
return $boMatch;
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Hash validator mechanism for the 3D Secure Authentication required hash in the transparent redirect payment mode
|
407 |
+
*
|
408 |
+
* @param unknown_type $formVariables
|
409 |
+
* @param unknown_type $szPassword
|
410 |
+
* @param unknown_type $hmHashMethod
|
411 |
+
* @param unknown_type $szPreSharedKey
|
412 |
+
* @return unknown
|
413 |
+
*/
|
414 |
+
public static function compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
|
415 |
+
{
|
416 |
+
$boMatch = false;
|
417 |
+
$szCalculatedHashDigest;
|
418 |
+
$szStringBeforeHash;
|
419 |
+
|
420 |
+
$szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
|
421 |
+
'Password='.$szPassword.'&'.
|
422 |
+
'StatusCode='.$formVariables['StatusCode'].'&'.
|
423 |
+
'Message='.$formVariables['Message'].'&'.
|
424 |
+
'CrossReference='.$formVariables['CrossReference'].'&'.
|
425 |
+
'OrderID='.$formVariables['OrderID'].'&'.
|
426 |
+
'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
|
427 |
+
'ACSURL='.$formVariables['ACSURL'].'&'.
|
428 |
+
'PaREQ='.$formVariables['PaREQ'];
|
429 |
+
|
430 |
+
if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
|
431 |
+
$hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
|
432 |
+
{
|
433 |
+
$szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
|
434 |
+
}
|
435 |
+
|
436 |
+
$szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
|
437 |
+
if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
|
438 |
+
{
|
439 |
+
$boMatch = true;
|
440 |
+
}
|
441 |
+
|
442 |
+
return $boMatch;
|
443 |
+
}
|
444 |
+
|
445 |
+
|
446 |
+
}
|
447 |
+
?>
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/PaymentSystem.php
ADDED
@@ -0,0 +1,2400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once('TPG_Common.php');
|
3 |
+
require_once('SOAP.php');
|
4 |
+
|
5 |
+
/*****************/
|
6 |
+
/* Input classes */
|
7 |
+
/*****************/
|
8 |
+
class CSV_RequestGatewayEntryPoint extends CSV_GatewayEntryPoint
|
9 |
+
{
|
10 |
+
private $m_nRetryAttempts;
|
11 |
+
|
12 |
+
public function getRetryAttempts()
|
13 |
+
{
|
14 |
+
return $this->m_nRetryAttempts;
|
15 |
+
}
|
16 |
+
|
17 |
+
//constructor
|
18 |
+
public function __construct($szEntryPointURL, $nMetric, $nRetryAttempts)
|
19 |
+
{
|
20 |
+
//do NOT forget to call the parent constructor too
|
21 |
+
//parent::GatewayEntryPoint($szEntryPointURL, $nMetric);
|
22 |
+
CSV_GatewayEntryPoint::__construct($szEntryPointURL, $nMetric);
|
23 |
+
|
24 |
+
$this->m_nRetryAttempts = $nRetryAttempts;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
class CSV_RequestGatewayEntryPointList
|
29 |
+
{
|
30 |
+
private $m_lrgepRequestGatewayEntryPoint;
|
31 |
+
|
32 |
+
public function getAt($nIndex)
|
33 |
+
{
|
34 |
+
if ($nIndex < 0 ||
|
35 |
+
$nIndex >= count($this->m_lrgepRequestGatewayEntryPoint))
|
36 |
+
{
|
37 |
+
throw new Exception("Array index out of bounds");
|
38 |
+
}
|
39 |
+
|
40 |
+
return $this->m_lrgepRequestGatewayEntryPoint[$nIndex];
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getCount()
|
44 |
+
{
|
45 |
+
return count($this->m_lrgepRequestGatewayEntryPoint);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function sort($ComparerClassName, $ComparerMethodName)
|
49 |
+
{
|
50 |
+
usort($this->m_lrgepRequestGatewayEntryPoint, array("$ComparerClassName","$ComparerMethodName"));
|
51 |
+
}
|
52 |
+
|
53 |
+
public function add($EntryPointURL, $nMetric, $nRetryAttempts)
|
54 |
+
{
|
55 |
+
return array_push($this->m_lrgepRequestGatewayEntryPoint, new CSV_RequestGatewayEntryPoint($EntryPointURL, $nMetric, $nRetryAttempts));
|
56 |
+
}
|
57 |
+
|
58 |
+
//constructor
|
59 |
+
public function __construct()
|
60 |
+
{
|
61 |
+
$this->m_lrgepRequestGatewayEntryPoint = array();
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
class CSV_GenericVariable
|
66 |
+
{
|
67 |
+
private $m_szName;
|
68 |
+
private $m_szValue;
|
69 |
+
|
70 |
+
public function getName()
|
71 |
+
{
|
72 |
+
return $this->m_szName;
|
73 |
+
}
|
74 |
+
public function getValue()
|
75 |
+
{
|
76 |
+
return $this->m_szValue;
|
77 |
+
}
|
78 |
+
|
79 |
+
//constructor
|
80 |
+
public function __construct($szName, $szValue)
|
81 |
+
{
|
82 |
+
$this->m_szName = $szName;
|
83 |
+
$this->m_szValue = $szValue;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
class CSV_GenericVariableList
|
88 |
+
{
|
89 |
+
private $m_lgvGenericVariableList;
|
90 |
+
|
91 |
+
public function getAt($intOrStringValue)
|
92 |
+
{
|
93 |
+
$nCount = 0;
|
94 |
+
$boFound = false;
|
95 |
+
$gvGenericVariable = null;
|
96 |
+
|
97 |
+
if (is_int($intOrStringValue))
|
98 |
+
{
|
99 |
+
if ($intOrStringValue < 0 ||
|
100 |
+
$intOrStringValue >= count($this->m_lgvGenericVariableList))
|
101 |
+
{
|
102 |
+
throw new Exception("Array index out of bounds");
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this->m_lgvGenericVariableList[$intOrStringValue];
|
106 |
+
}
|
107 |
+
elseif (is_string($intOrStringValue))
|
108 |
+
{
|
109 |
+
if ($intOrStringValue == null ||
|
110 |
+
$intOrStringValue == '')
|
111 |
+
{
|
112 |
+
return (null);
|
113 |
+
}
|
114 |
+
|
115 |
+
while (!$boFound &&
|
116 |
+
$nCount < count($this->m_lgvGenericVariableList))
|
117 |
+
{
|
118 |
+
if (strtoupper($this->m_lgvGenericVariableList[$nCount]->getName()) ==
|
119 |
+
strtoupper($intOrStringValue))
|
120 |
+
{
|
121 |
+
$gvGenericVariable = $this->m_lgvGenericVariableList[$nCount];
|
122 |
+
$boFound = true;
|
123 |
+
}
|
124 |
+
$nCount++;
|
125 |
+
}
|
126 |
+
|
127 |
+
return $gvGenericVariable;
|
128 |
+
}
|
129 |
+
else
|
130 |
+
{
|
131 |
+
throw new Exception('Invalid parameter type:$intOrStringValue');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
public function getCount()
|
136 |
+
{
|
137 |
+
return count($this->m_lgvGenericVariableList);
|
138 |
+
}
|
139 |
+
|
140 |
+
public function add($Name, $szValue)
|
141 |
+
{
|
142 |
+
$nReturnValue = -1;
|
143 |
+
|
144 |
+
if ($Name != null &&
|
145 |
+
$Name != "")
|
146 |
+
{
|
147 |
+
$nReturnValue = array_push($this->m_lgvGenericVariableList, new CSV_GenericVariable($Name, $szValue));
|
148 |
+
}
|
149 |
+
|
150 |
+
return ($nReturnValue);
|
151 |
+
}
|
152 |
+
|
153 |
+
//constructor
|
154 |
+
public function __construct()
|
155 |
+
{
|
156 |
+
$this->m_lgvGenericVariableList = array();
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
class CSV_CustomerDetails
|
161 |
+
{
|
162 |
+
private $m_adBillingAddress;
|
163 |
+
private $m_szEmailAddress;
|
164 |
+
private $m_szPhoneNumber;
|
165 |
+
private $m_szCustomerIPAddress;
|
166 |
+
|
167 |
+
public function getBillingAddress()
|
168 |
+
{
|
169 |
+
return $this->m_adBillingAddress;
|
170 |
+
}
|
171 |
+
public function getEmailAddress()
|
172 |
+
{
|
173 |
+
return $this->m_szEmailAddress;
|
174 |
+
}
|
175 |
+
public function getPhoneNumber()
|
176 |
+
{
|
177 |
+
return $this->m_szPhoneNumber;
|
178 |
+
}
|
179 |
+
public function getCustomerIPAddress()
|
180 |
+
{
|
181 |
+
return $this->m_szCustomerIPAddress;
|
182 |
+
}
|
183 |
+
|
184 |
+
//constructor
|
185 |
+
public function __construct($adBillingAddress = null, $szEmailAddress, $szPhoneNumber, $szCustomerIPAddress)
|
186 |
+
{
|
187 |
+
$this->m_adBillingAddress = $adBillingAddress;
|
188 |
+
$this->m_szEmailAddress = $szEmailAddress;
|
189 |
+
$this->m_szPhoneNumber = $szPhoneNumber;
|
190 |
+
$this->m_szCustomerIPAddress = $szCustomerIPAddress;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
class CSV_AddressDetails
|
195 |
+
{
|
196 |
+
private $m_szAddress1;
|
197 |
+
private $m_szAddress2;
|
198 |
+
private $m_szAddress3;
|
199 |
+
private $m_szAddress4;
|
200 |
+
private $m_szCity;
|
201 |
+
private $m_szState;
|
202 |
+
private $m_szPostCode;
|
203 |
+
private $m_nCountryCode;
|
204 |
+
|
205 |
+
public function getAddress1()
|
206 |
+
{
|
207 |
+
return $this->m_szAddress1;
|
208 |
+
}
|
209 |
+
public function getAddress2()
|
210 |
+
{
|
211 |
+
return $this->m_szAddress2;
|
212 |
+
}
|
213 |
+
public function getAddress3()
|
214 |
+
{
|
215 |
+
return $this->m_szAddress3;
|
216 |
+
}
|
217 |
+
public function getAddress4()
|
218 |
+
{
|
219 |
+
return $this->m_szAddress4;
|
220 |
+
}
|
221 |
+
public function getCity()
|
222 |
+
{
|
223 |
+
return $this->m_szCity;
|
224 |
+
}
|
225 |
+
public function getState()
|
226 |
+
{
|
227 |
+
return $this->m_szState;
|
228 |
+
}
|
229 |
+
public function getPostCode()
|
230 |
+
{
|
231 |
+
return $this->m_szPostCode;
|
232 |
+
}
|
233 |
+
public function getCountryCode()
|
234 |
+
{
|
235 |
+
return $this->m_nCountryCode;
|
236 |
+
}
|
237 |
+
|
238 |
+
//constructor
|
239 |
+
public function __construct($szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, CSV_NullableInt $nCountryCode = null)
|
240 |
+
{
|
241 |
+
$this->m_szAddress1 = $szAddress1;
|
242 |
+
$this->m_szAddress2 = $szAddress2;
|
243 |
+
$this->m_szAddress3 = $szAddress3;
|
244 |
+
$this->m_szAddress4 = $szAddress4;
|
245 |
+
$this->m_szCity = $szCity;
|
246 |
+
$this->m_szState = $szState;
|
247 |
+
$this->m_szPostCode = $szPostCode;
|
248 |
+
$this->m_nCountryCode = $nCountryCode;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
abstract class CSV_CreditCardDate
|
253 |
+
{
|
254 |
+
private $m_nMonth;
|
255 |
+
private $m_nYear;
|
256 |
+
|
257 |
+
public function getMonth()
|
258 |
+
{
|
259 |
+
return $this->m_nMonth;
|
260 |
+
}
|
261 |
+
public function getYear()
|
262 |
+
{
|
263 |
+
return $this->m_nYear;
|
264 |
+
}
|
265 |
+
|
266 |
+
//constructor
|
267 |
+
public function __construct(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
|
268 |
+
{
|
269 |
+
$this->m_nMonth = $nMonth;
|
270 |
+
$this->m_nYear = $nYear;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
class CSV_ExpiryDate extends CSV_CreditCardDate
|
275 |
+
{
|
276 |
+
public function __construct(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
|
277 |
+
{
|
278 |
+
parent::__construct($nMonth, $nYear);
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
class CSV_StartDate extends CSV_CreditCardDate
|
283 |
+
{
|
284 |
+
public function __construct(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
|
285 |
+
{
|
286 |
+
parent::__construct($nMonth, $nYear);
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
class CSV_CardDetails
|
291 |
+
{
|
292 |
+
private $m_szCardName;
|
293 |
+
private $m_szCardNumber;
|
294 |
+
private $m_edExpiryDate;
|
295 |
+
private $m_sdStartDate;
|
296 |
+
private $m_szIssueNumber;
|
297 |
+
private $m_szCV2;
|
298 |
+
|
299 |
+
public function getCardName()
|
300 |
+
{
|
301 |
+
return $this->m_szCardName;
|
302 |
+
}
|
303 |
+
public function getCardNumber()
|
304 |
+
{
|
305 |
+
return $this->m_szCardNumber;
|
306 |
+
}
|
307 |
+
|
308 |
+
public function getExpiryDate()
|
309 |
+
{
|
310 |
+
return $this->m_edExpiryDate;
|
311 |
+
}
|
312 |
+
|
313 |
+
public function getStartDate()
|
314 |
+
{
|
315 |
+
return $this->m_sdStartDate;
|
316 |
+
}
|
317 |
+
|
318 |
+
public function getIssueNumber()
|
319 |
+
{
|
320 |
+
return $this->m_szIssueNumber;
|
321 |
+
}
|
322 |
+
|
323 |
+
public function getCV2()
|
324 |
+
{
|
325 |
+
return $this->m_szCV2;
|
326 |
+
}
|
327 |
+
|
328 |
+
//constructor
|
329 |
+
public function __construct($szCardName, $szCardNumber, CSV_ExpiryDate $edExpiryDate = null, CSV_StartDate $sdStartDate = null, $IssueNumber, $CV2)
|
330 |
+
{
|
331 |
+
$this->m_szCardName = $szCardName;
|
332 |
+
$this->m_szCardNumber = $szCardNumber;
|
333 |
+
$this->m_edExpiryDate = $edExpiryDate;
|
334 |
+
$this->m_sdStartDate = $sdStartDate;
|
335 |
+
$this->m_szIssueNumber = $IssueNumber;
|
336 |
+
$this->m_szCV2 = $CV2;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
class CSV_OverrideCardDetails extends CSV_CardDetails
|
341 |
+
{
|
342 |
+
public function __construct($szCardName, $szCardNumber, CSV_ExpiryDate $edExpiryDate = null, CSV_StartDate $sdStartDate = null, $IssueNumber, $CV2)
|
343 |
+
{
|
344 |
+
parent::__construct($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $IssueNumber, $CV2);
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
class CSV_MerchantAuthentication
|
349 |
+
{
|
350 |
+
private $m_szMerchantID;
|
351 |
+
private $m_szPassword;
|
352 |
+
|
353 |
+
public function getMerchantID()
|
354 |
+
{
|
355 |
+
return $this->m_szMerchantID;
|
356 |
+
}
|
357 |
+
public function getPassword()
|
358 |
+
{
|
359 |
+
return $this->m_szPassword;
|
360 |
+
}
|
361 |
+
|
362 |
+
//constructor
|
363 |
+
public function __construct($szMerchantID, $szPassword)
|
364 |
+
{
|
365 |
+
$this->m_szMerchantID = $szMerchantID;
|
366 |
+
$this->m_szPassword = $szPassword;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
class CSV_MessageDetails
|
371 |
+
{
|
372 |
+
private $m_szTransactionType;
|
373 |
+
private $m_boNewTransaction;
|
374 |
+
private $m_szCrossReference;
|
375 |
+
|
376 |
+
public function getTransactionType()
|
377 |
+
{
|
378 |
+
return $this->m_szTransactionType;
|
379 |
+
}
|
380 |
+
public function getNewTransaction()
|
381 |
+
{
|
382 |
+
return $this->m_boNewTransaction;
|
383 |
+
}
|
384 |
+
public function getCrossReference()
|
385 |
+
{
|
386 |
+
return $this->m_szCrossReference;
|
387 |
+
}
|
388 |
+
|
389 |
+
//constructor
|
390 |
+
public function __construct($szTransactionType, $szCrossReference = null, CSV_NullableBool $boNewTransaction = null)
|
391 |
+
{
|
392 |
+
$this->m_szTransactionType = $szTransactionType;
|
393 |
+
|
394 |
+
if ($szCrossReference != null)
|
395 |
+
{
|
396 |
+
$this->m_szCrossReference = $szCrossReference;
|
397 |
+
}
|
398 |
+
if ($boNewTransaction != null)
|
399 |
+
{
|
400 |
+
$this->m_boNewTransaction = $boNewTransaction;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
class CSV_TransactionDetails
|
406 |
+
{
|
407 |
+
private $m_mdMessageDetails;
|
408 |
+
private $m_nAmount;
|
409 |
+
private $m_nCurrencyCode;
|
410 |
+
private $m_szOrderID;
|
411 |
+
private $m_szOrderDescription;
|
412 |
+
private $m_tcTransactionControl;
|
413 |
+
private $m_tdsbdThreeDSecureBrowserDetails;
|
414 |
+
|
415 |
+
public function getMessageDetails()
|
416 |
+
{
|
417 |
+
return $this->m_mdMessageDetails;
|
418 |
+
}
|
419 |
+
public function getAmount()
|
420 |
+
{
|
421 |
+
return $this->m_nAmount;
|
422 |
+
}
|
423 |
+
public function getCurrencyCode()
|
424 |
+
{
|
425 |
+
return $this->m_nCurrencyCode;
|
426 |
+
}
|
427 |
+
public function getOrderID()
|
428 |
+
{
|
429 |
+
return $this->m_szOrderID;
|
430 |
+
}
|
431 |
+
public function getOrderDescription()
|
432 |
+
{
|
433 |
+
return $this->m_szOrderDescription;
|
434 |
+
}
|
435 |
+
public function getTransactionControl()
|
436 |
+
{
|
437 |
+
return $this->m_tcTransactionControl;
|
438 |
+
}
|
439 |
+
public function getThreeDSecureBrowserDetails()
|
440 |
+
{
|
441 |
+
return $this->m_tdsbdThreeDSecureBrowserDetails;
|
442 |
+
}
|
443 |
+
|
444 |
+
//constructor
|
445 |
+
public function __construct($TransactionTypeOrMessageDetails, CSV_NullableInt $nAmount = null, CSV_NullableInt $nCurrencyCode = null, $szOrderID, $szOrderDescription, CSV_TransactionControl $tcTransactionControl = null, CSV_ThreeDSecureBrowserDetails $tdsbdThreeDSecureBrowserDetails = null)
|
446 |
+
{
|
447 |
+
if ($TransactionTypeOrMessageDetails instanceof CSV_MessageDetails)
|
448 |
+
{
|
449 |
+
$this->m_mdMessageDetails = $TransactionTypeOrMessageDetails;
|
450 |
+
$this->m_nAmount = $nAmount;
|
451 |
+
$this->m_nCurrencyCode = $nCurrencyCode;
|
452 |
+
$this->m_szOrderID = $szOrderID;
|
453 |
+
$this->m_szOrderDescription = $szOrderDescription;
|
454 |
+
$this->m_tcTransactionControl = $tcTransactionControl;
|
455 |
+
$this->m_tdsbdThreeDSecureBrowserDetails = $tdsbdThreeDSecureBrowserDetails;
|
456 |
+
}
|
457 |
+
else
|
458 |
+
{
|
459 |
+
$this->__construct(new CSV_MessageDetails($TransactionTypeOrMessageDetails), $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
class CSV_ThreeDSecureBrowserDetails
|
465 |
+
{
|
466 |
+
private $m_nDeviceCategory;
|
467 |
+
private $m_szAcceptHeaders;
|
468 |
+
private $m_szUserAgent;
|
469 |
+
|
470 |
+
public function getDeviceCategory()
|
471 |
+
{
|
472 |
+
return $this->m_nDeviceCategory;
|
473 |
+
}
|
474 |
+
|
475 |
+
public function getAcceptHeaders()
|
476 |
+
{
|
477 |
+
return $this->m_szAcceptHeaders;
|
478 |
+
}
|
479 |
+
|
480 |
+
public function getUserAgent()
|
481 |
+
{
|
482 |
+
return $this->m_szUserAgent;
|
483 |
+
}
|
484 |
+
|
485 |
+
//constructor
|
486 |
+
public function __construct(CSV_NullableInt $nDeviceCategory = null, $szAcceptHeaders, $szUserAgent)
|
487 |
+
{
|
488 |
+
$this->m_nDeviceCategory = $nDeviceCategory;
|
489 |
+
$this->m_szAcceptHeaders = $szAcceptHeaders;
|
490 |
+
$this->m_szUserAgent = $szUserAgent;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
class CSV_TransactionControl
|
495 |
+
{
|
496 |
+
private $m_boEchoCardType;
|
497 |
+
private $m_boEchoAVSCheckResult;
|
498 |
+
private $m_boEchoCV2CheckResult;
|
499 |
+
private $m_boEchoAmountReceived;
|
500 |
+
private $m_nDuplicateDelay;
|
501 |
+
private $m_szAVSOverridePolicy;
|
502 |
+
private $m_szCV2OverridePolicy;
|
503 |
+
private $m_boThreeDSecureOverridePolicy;
|
504 |
+
private $m_szAuthCode;
|
505 |
+
private $m_tdsptThreeDSecurePassthroughData;
|
506 |
+
private $m_lgvCustomVariables;
|
507 |
+
|
508 |
+
public function getEchoCardType()
|
509 |
+
{
|
510 |
+
return $this->m_boEchoCardType;
|
511 |
+
}
|
512 |
+
|
513 |
+
public function getEchoAVSCheckResult()
|
514 |
+
{
|
515 |
+
return $this->m_boEchoAVSCheckResult;
|
516 |
+
}
|
517 |
+
|
518 |
+
public function getEchoCV2CheckResult()
|
519 |
+
{
|
520 |
+
return $this->m_boEchoCV2CheckResult;
|
521 |
+
}
|
522 |
+
|
523 |
+
public function getEchoAmountReceived()
|
524 |
+
{
|
525 |
+
return $this->m_boEchoAmountReceived;
|
526 |
+
}
|
527 |
+
|
528 |
+
public function getDuplicateDelay()
|
529 |
+
{
|
530 |
+
return $this->m_nDuplicateDelay;
|
531 |
+
}
|
532 |
+
|
533 |
+
public function getAVSOverridePolicy()
|
534 |
+
{
|
535 |
+
return $this->m_szAVSOverridePolicy;
|
536 |
+
}
|
537 |
+
|
538 |
+
public function getCV2OverridePolicy()
|
539 |
+
{
|
540 |
+
return $this->m_szCV2OverridePolicy;
|
541 |
+
}
|
542 |
+
|
543 |
+
public function getThreeDSecureOverridePolicy()
|
544 |
+
{
|
545 |
+
return $this->m_boThreeDSecureOverridePolicy;
|
546 |
+
}
|
547 |
+
|
548 |
+
public function getAuthCode()
|
549 |
+
{
|
550 |
+
return $this->m_szAuthCode;
|
551 |
+
}
|
552 |
+
|
553 |
+
function getThreeDSecurePassthroughData()
|
554 |
+
{
|
555 |
+
return $this->m_tdsptThreeDSecurePassthroughData;
|
556 |
+
}
|
557 |
+
|
558 |
+
public function getCustomVariables()
|
559 |
+
{
|
560 |
+
return $this->m_lgvCustomVariables;
|
561 |
+
}
|
562 |
+
|
563 |
+
//constructor
|
564 |
+
public function __construct(CSV_NullableBool $boEchoCardType = null, CSV_NullableBool $boEchoAVSCheckResult = null, CSV_NullableBool $boEchoCV2CheckResult = null, CSV_NullableBool $boEchoAmountReceived = null, CSV_NullableInt $nDuplicateDelay = null, $szAVSOverridePolicy, $szCV2OverridePolicy, CSV_NullableBool $boThreeDSecureOverridePolicy = null, $szAuthCode, CSV_ThreeDSecurePassthroughData $tdsptThreeDSecurePassthroughData = null, CSV_GenericVariableList $lgvCustomVariables = null)
|
565 |
+
{
|
566 |
+
$this->m_boEchoCardType = $boEchoCardType;
|
567 |
+
$this->m_boEchoAVSCheckResult = $boEchoAVSCheckResult;
|
568 |
+
$this->m_boEchoCV2CheckResult = $boEchoCV2CheckResult;
|
569 |
+
$this->m_boEchoAmountReceived = $boEchoAmountReceived;
|
570 |
+
$this->m_nDuplicateDelay = $nDuplicateDelay;
|
571 |
+
$this->m_szAVSOverridePolicy = $szAVSOverridePolicy;
|
572 |
+
$this->m_szCV2OverridePolicy = $szCV2OverridePolicy;
|
573 |
+
$this->m_boThreeDSecureOverridePolicy = $boThreeDSecureOverridePolicy;
|
574 |
+
$this->m_szAuthCode = $szAuthCode;
|
575 |
+
$this->m_tdsptThreeDSecurePassthroughData = $tdsptThreeDSecurePassthroughData;
|
576 |
+
$this->m_lgvCustomVariables = $lgvCustomVariables;
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
class CSV_ThreeDSecureInputData
|
581 |
+
{
|
582 |
+
private $m_szCrossReference;
|
583 |
+
private $m_szPaRES;
|
584 |
+
|
585 |
+
public function getCrossReference()
|
586 |
+
{
|
587 |
+
return $this->m_szCrossReference;
|
588 |
+
}
|
589 |
+
|
590 |
+
public function getPaRES()
|
591 |
+
{
|
592 |
+
return $this->m_szPaRES;
|
593 |
+
}
|
594 |
+
|
595 |
+
//constructor
|
596 |
+
public function __construct($szCrossReference, $szPaRES)
|
597 |
+
{
|
598 |
+
$this->m_szCrossReference = $szCrossReference;
|
599 |
+
$this->m_szPaRES = $szPaRES;
|
600 |
+
}
|
601 |
+
}
|
602 |
+
|
603 |
+
class CSV_ThreeDSecurePassthroughData
|
604 |
+
{
|
605 |
+
private $m_szEnrolmentStatus;
|
606 |
+
private $m_szAuthenticationStatus;
|
607 |
+
private $m_szElectronicCommerceIndicator;
|
608 |
+
private $m_szAuthenticationValue;
|
609 |
+
private $m_szTransactionIdentifier;
|
610 |
+
|
611 |
+
function getEnrolmentStatus()
|
612 |
+
{
|
613 |
+
return $this->m_szEnrolmentStatus;
|
614 |
+
}
|
615 |
+
|
616 |
+
function getAuthenticationStatus()
|
617 |
+
{
|
618 |
+
return $this->m_szAuthenticationStatus;
|
619 |
+
}
|
620 |
+
|
621 |
+
function getElectronicCommerceIndicator()
|
622 |
+
{
|
623 |
+
return $this->m_szElectronicCommerceIndicator;
|
624 |
+
}
|
625 |
+
|
626 |
+
function getAuthenticationValue()
|
627 |
+
{
|
628 |
+
return $this->m_szAuthenticationValue;
|
629 |
+
}
|
630 |
+
|
631 |
+
function getTransactionIdentifier()
|
632 |
+
{
|
633 |
+
return $this->m_szTransactionIdentifier;
|
634 |
+
}
|
635 |
+
|
636 |
+
//constructor
|
637 |
+
function __construct($szEnrolmentStatus,
|
638 |
+
$szAuthenticationStatus,
|
639 |
+
$szElectronicCommerceIndicator,
|
640 |
+
$szAuthenticationValue,
|
641 |
+
$szTransactionIdentifier)
|
642 |
+
{
|
643 |
+
$this->m_szEnrolmentStatus = $szEnrolmentStatus;
|
644 |
+
$this->m_szAuthenticationStatus = $szAuthenticationStatus;
|
645 |
+
$this->m_szElectronicCommerceIndicator = $szElectronicCommerceIndicator;
|
646 |
+
$this->m_szAuthenticationValue = $szAuthenticationValue;
|
647 |
+
$this->m_szTransactionIdentifier = $szTransactionIdentifier;
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
|
652 |
+
/******************/
|
653 |
+
/* Output classes */
|
654 |
+
/******************/
|
655 |
+
class CSV_Issuer
|
656 |
+
{
|
657 |
+
private $m_szIssuer;
|
658 |
+
private $m_nISOCode;
|
659 |
+
|
660 |
+
public function getValue()
|
661 |
+
{
|
662 |
+
return $this->m_szIssuer;
|
663 |
+
}
|
664 |
+
|
665 |
+
public function getISOCode()
|
666 |
+
{
|
667 |
+
return $this->m_nISOCode;
|
668 |
+
}
|
669 |
+
|
670 |
+
//constructor
|
671 |
+
public function __construct($szIssuer, $nISOCode)
|
672 |
+
{
|
673 |
+
$this->m_szIssuer = $szIssuer;
|
674 |
+
$this->m_nISOCode = $nISOCode;
|
675 |
+
}
|
676 |
+
}
|
677 |
+
|
678 |
+
class CSV_CardTypeData
|
679 |
+
{
|
680 |
+
private $m_szCardType;
|
681 |
+
private $m_iIssuer;
|
682 |
+
private $m_boLuhnCheckRequired;
|
683 |
+
private $m_szIssueNumberStatus;
|
684 |
+
private $m_szStartDateStatus;
|
685 |
+
|
686 |
+
public function getCardType()
|
687 |
+
{
|
688 |
+
return $this->m_szCardType;
|
689 |
+
}
|
690 |
+
|
691 |
+
public function getIssuer()
|
692 |
+
{
|
693 |
+
return $this->m_iIssuer;
|
694 |
+
}
|
695 |
+
|
696 |
+
public function getLuhnCheckRequired()
|
697 |
+
{
|
698 |
+
return $this->m_boLuhnCheckRequired;
|
699 |
+
}
|
700 |
+
|
701 |
+
public function getIssueNumberStatus()
|
702 |
+
{
|
703 |
+
return $this->m_szIssueNumberStatus;
|
704 |
+
}
|
705 |
+
|
706 |
+
public function getStartDateStatus()
|
707 |
+
{
|
708 |
+
return $this->m_szStartDateStatus;
|
709 |
+
}
|
710 |
+
|
711 |
+
//constructor
|
712 |
+
public function __construct($szCardType, $iIssuer, CSV_NullableBool $boLuhnCheckRequired = null, $szIssueNumberStatus, $szStartDateStatus)
|
713 |
+
{
|
714 |
+
$this->m_szCardType = $szCardType;
|
715 |
+
//$this->m_szIssuer = $szIssuer;
|
716 |
+
$this->m_iIssuer = $iIssuer;
|
717 |
+
$this->m_boLuhnCheckRequired = $boLuhnCheckRequired;
|
718 |
+
$this->m_szIssueNumberStatus = $szIssueNumberStatus;
|
719 |
+
$this->m_szStartDateStatus = $szStartDateStatus;
|
720 |
+
}
|
721 |
+
}
|
722 |
+
|
723 |
+
class CSV_GatewayEntryPoint
|
724 |
+
{
|
725 |
+
private $m_szEntryPointURL;
|
726 |
+
private $m_nMetric;
|
727 |
+
|
728 |
+
public function getEntryPointURL()
|
729 |
+
{
|
730 |
+
return $this->m_szEntryPointURL;
|
731 |
+
}
|
732 |
+
|
733 |
+
public function getMetric()
|
734 |
+
{
|
735 |
+
return $this->m_nMetric;
|
736 |
+
}
|
737 |
+
|
738 |
+
//constructor
|
739 |
+
public function __construct($szEntryPointURL, $nMetric)
|
740 |
+
{
|
741 |
+
$this->m_szEntryPointURL = $szEntryPointURL;
|
742 |
+
$this->m_nMetric = $nMetric;
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
class CSV_GatewayEntryPointList
|
747 |
+
{
|
748 |
+
private $m_lgepGatewayEntryPoint;
|
749 |
+
|
750 |
+
public function getAt($nIndex)
|
751 |
+
{
|
752 |
+
if ($nIndex < 0 ||
|
753 |
+
$nIndex >= count($this->m_lgepGatewayEntryPoint))
|
754 |
+
{
|
755 |
+
throw new Exception("Array index out of bounds");
|
756 |
+
}
|
757 |
+
|
758 |
+
return $this->m_lgepGatewayEntryPoint[$nIndex];
|
759 |
+
}
|
760 |
+
|
761 |
+
public function getCount()
|
762 |
+
{
|
763 |
+
return count($this->m_lgepGatewayEntryPoint);
|
764 |
+
}
|
765 |
+
|
766 |
+
public function add($GatewayEntrypointOrEntrypointURL, $nMetric)
|
767 |
+
{
|
768 |
+
return array_push($this->m_lgepGatewayEntryPoint, new CSV_GatewayEntryPoint($GatewayEntrypointOrEntrypointURL, $nMetric));
|
769 |
+
}
|
770 |
+
|
771 |
+
//constructor
|
772 |
+
public function __construct()
|
773 |
+
{
|
774 |
+
$this->m_lgepGatewayEntryPoint = array();
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
class CSV_PreviousTransactionResult
|
779 |
+
{
|
780 |
+
private $m_nStatusCode;
|
781 |
+
private $m_szMessage;
|
782 |
+
|
783 |
+
function getStatusCode()
|
784 |
+
{
|
785 |
+
return $this->m_nStatusCode;
|
786 |
+
}
|
787 |
+
|
788 |
+
function getMessage()
|
789 |
+
{
|
790 |
+
return $this->m_szMessage;
|
791 |
+
}
|
792 |
+
|
793 |
+
function __construct(CSV_NullableInt $nStatusCode = null,
|
794 |
+
$szMessage)
|
795 |
+
{
|
796 |
+
$this->m_nStatusCode = $nStatusCode;
|
797 |
+
$this->m_szMessage = $szMessage;
|
798 |
+
}
|
799 |
+
}
|
800 |
+
|
801 |
+
class CSV_GatewayOutput
|
802 |
+
{
|
803 |
+
private $m_nStatusCode;
|
804 |
+
private $m_szMessage;
|
805 |
+
private $m_szPassOutData;
|
806 |
+
//private $m_ptdPreviousTransactionResult;
|
807 |
+
//private $m_boAuthorisationAttempted;
|
808 |
+
private $m_lszErrorMessages;
|
809 |
+
|
810 |
+
public function getStatusCode()
|
811 |
+
{
|
812 |
+
return $this->m_nStatusCode;
|
813 |
+
}
|
814 |
+
|
815 |
+
public function getMessage()
|
816 |
+
{
|
817 |
+
return $this->m_szMessage;
|
818 |
+
}
|
819 |
+
|
820 |
+
public function getPassOutData()
|
821 |
+
{
|
822 |
+
return $this->m_szPassOutData;
|
823 |
+
}
|
824 |
+
|
825 |
+
public function getErrorMessages()
|
826 |
+
{
|
827 |
+
return $this->m_lszErrorMessages;
|
828 |
+
}
|
829 |
+
|
830 |
+
//constructor
|
831 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_StringList $lszErrorMessages = null)
|
832 |
+
{
|
833 |
+
$this->m_nStatusCode = $nStatusCode;
|
834 |
+
$this->m_szMessage = $szMessage;
|
835 |
+
$this->m_szPassOutData = $szPassOutData;
|
836 |
+
$this->m_lszErrorMessages = $lszErrorMessages;
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
class CSV_PaymentMessageGatewayOutput extends CSV_GatewayOutput
|
841 |
+
{
|
842 |
+
private $m_ptdPreviousTransactionResult;
|
843 |
+
private $m_boAuthorisationAttempted;
|
844 |
+
|
845 |
+
public function getPreviousTransactionResult()
|
846 |
+
{
|
847 |
+
return $this->m_ptdPreviousTransactionResult;
|
848 |
+
}
|
849 |
+
|
850 |
+
public function getAuthorisationAttempted()
|
851 |
+
{
|
852 |
+
return $this->m_boAuthorisationAttempted;
|
853 |
+
}
|
854 |
+
//constructor
|
855 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
|
856 |
+
{
|
857 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
|
858 |
+
$this->m_boAuthorisationAttempted = $boAuthorisationAttempted;
|
859 |
+
$this->m_ptdPreviousTransactionResult = $ptdPreviousTransactionResult;
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
class CSV_CardDetailsTransactionResult extends CSV_PaymentMessageGatewayOutput
|
864 |
+
{
|
865 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
|
866 |
+
{
|
867 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
|
868 |
+
}
|
869 |
+
}
|
870 |
+
class CSV_CrossReferenceTransactionResult extends CSV_PaymentMessageGatewayOutput
|
871 |
+
{
|
872 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
|
873 |
+
{
|
874 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
|
875 |
+
}
|
876 |
+
}
|
877 |
+
class CSV_ThreeDSecureTransactionResult extends CSV_PaymentMessageGatewayOutput
|
878 |
+
{
|
879 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
|
880 |
+
{
|
881 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
|
882 |
+
}
|
883 |
+
}
|
884 |
+
class CSV_GetGatewayEntryPointsResult extends CSV_GatewayOutput
|
885 |
+
{
|
886 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, StringList $lszErrorMessages = null)
|
887 |
+
{
|
888 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
|
889 |
+
}
|
890 |
+
}
|
891 |
+
class CSV_GetCardTypeResult extends CSV_GatewayOutput
|
892 |
+
{
|
893 |
+
public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_StringList $lszErrorMessages = null)
|
894 |
+
{
|
895 |
+
parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
class CSV_ThreeDSecureOutputData
|
900 |
+
{
|
901 |
+
private $m_szPaREQ;
|
902 |
+
private $m_szACSURL;
|
903 |
+
|
904 |
+
public function getPaREQ()
|
905 |
+
{
|
906 |
+
return $this->m_szPaREQ;
|
907 |
+
}
|
908 |
+
|
909 |
+
public function getACSURL()
|
910 |
+
{
|
911 |
+
return ($this->m_szACSURL);
|
912 |
+
}
|
913 |
+
|
914 |
+
//constructor
|
915 |
+
public function __construct($szPaREQ, $szACSURL)
|
916 |
+
{
|
917 |
+
$this->m_szPaREQ = $szPaREQ;
|
918 |
+
$this->m_szACSURL = $szACSURL;
|
919 |
+
}
|
920 |
+
}
|
921 |
+
|
922 |
+
class CSV_GetGatewayEntryPointsOutputData extends CSV_BaseOutputData
|
923 |
+
{
|
924 |
+
//constructor
|
925 |
+
function __construct(CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
|
926 |
+
{
|
927 |
+
parent::__construct($lgepGatewayEntryPoints);
|
928 |
+
}
|
929 |
+
}
|
930 |
+
|
931 |
+
class CSV_TransactionOutputData extends CSV_BaseOutputData
|
932 |
+
{
|
933 |
+
private $m_szCrossReference;
|
934 |
+
private $m_szAuthCode;
|
935 |
+
private $m_szAddressNumericCheckResult;
|
936 |
+
private $m_szPostCodeCheckResult;
|
937 |
+
private $m_szThreeDSecureAuthenticationCheckResult;
|
938 |
+
private $m_szCV2CheckResult;
|
939 |
+
private $m_ctdCardTypeData;
|
940 |
+
private $m_nAmountReceived;
|
941 |
+
private $m_tdsodThreeDSecureOutputData;
|
942 |
+
private $m_lgvCustomVariables;
|
943 |
+
|
944 |
+
public function getCrossReference()
|
945 |
+
{
|
946 |
+
return $this->m_szCrossReference;
|
947 |
+
}
|
948 |
+
|
949 |
+
public function getAuthCode()
|
950 |
+
{
|
951 |
+
return $this->m_szAuthCode;
|
952 |
+
}
|
953 |
+
|
954 |
+
public function getAddressNumericCheckResult()
|
955 |
+
{
|
956 |
+
return $this->m_szAddressNumericCheckResult;
|
957 |
+
}
|
958 |
+
|
959 |
+
public function getPostCodeCheckResult()
|
960 |
+
{
|
961 |
+
return $this->m_szPostCodeCheckResult;
|
962 |
+
}
|
963 |
+
|
964 |
+
public function getThreeDSecureAuthenticationCheckResult()
|
965 |
+
{
|
966 |
+
return $this->m_szThreeDSecureAuthenticationCheckResult;
|
967 |
+
}
|
968 |
+
|
969 |
+
public function getCV2CheckResult()
|
970 |
+
{
|
971 |
+
return $this->m_szCV2CheckResult;
|
972 |
+
}
|
973 |
+
|
974 |
+
public function getCardTypeData()
|
975 |
+
{
|
976 |
+
return $this->m_ctdCardTypeData;
|
977 |
+
}
|
978 |
+
|
979 |
+
public function getAmountReceived()
|
980 |
+
{
|
981 |
+
return $this->m_nAmountReceived;
|
982 |
+
}
|
983 |
+
|
984 |
+
public function getThreeDSecureOutputData()
|
985 |
+
{
|
986 |
+
return $this->m_tdsodThreeDSecureOutputData;
|
987 |
+
}
|
988 |
+
|
989 |
+
public function getCustomVariables()
|
990 |
+
{
|
991 |
+
return $this->m_lgvCustomVariables;
|
992 |
+
}
|
993 |
+
|
994 |
+
//constructor
|
995 |
+
public function __construct($szCrossReference,
|
996 |
+
$szAuthCode,
|
997 |
+
$szAddressNumericCheckResult,
|
998 |
+
$szPostCodeCheckResult,
|
999 |
+
$szThreeDSecureAuthenticationCheckResult,
|
1000 |
+
$szCV2CheckResult,
|
1001 |
+
CSV_CardTypeData $ctdCardTypeData = null,
|
1002 |
+
CSV_NullableInt $nAmountReceived = null,
|
1003 |
+
CSV_ThreeDSecureOutputData $tdsodThreeDSecureOutputData = null,
|
1004 |
+
CSV_GenericVariableList $lgvCustomVariables = null,
|
1005 |
+
CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
|
1006 |
+
{
|
1007 |
+
//first calling the parent constructor
|
1008 |
+
parent::__construct($lgepGatewayEntryPoints);
|
1009 |
+
|
1010 |
+
$this->m_szCrossReference = $szCrossReference;
|
1011 |
+
$this->m_szAuthCode = $szAuthCode;
|
1012 |
+
$this->m_szAddressNumericCheckResult = $szAddressNumericCheckResult;
|
1013 |
+
$this->m_szPostCodeCheckResult = $szPostCodeCheckResult;
|
1014 |
+
$this->m_szThreeDSecureAuthenticationCheckResult = $szThreeDSecureAuthenticationCheckResult;
|
1015 |
+
$this->m_szCV2CheckResult = $szCV2CheckResult;
|
1016 |
+
$this->m_ctdCardTypeData = $ctdCardTypeData;
|
1017 |
+
$this->m_nAmountReceived = $nAmountReceived;
|
1018 |
+
$this->m_tdsodThreeDSecureOutputData = $tdsodThreeDSecureOutputData;
|
1019 |
+
$this->m_lgvCustomVariables = $lgvCustomVariables;
|
1020 |
+
}
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
class CSV_GetCardTypeOutputData extends CSV_BaseOutputData
|
1024 |
+
{
|
1025 |
+
private $m_ctdCardTypeData;
|
1026 |
+
|
1027 |
+
public function getCardTypeData()
|
1028 |
+
{
|
1029 |
+
return $this->m_ctdCardTypeData;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
//constructor
|
1033 |
+
public function __construct(CSV_CardTypeData $ctdCardTypeData = null,
|
1034 |
+
CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
|
1035 |
+
{
|
1036 |
+
parent::__construct($lgepGatewayEntryPoints);
|
1037 |
+
|
1038 |
+
$this->m_ctdCardTypeData = $ctdCardTypeData;
|
1039 |
+
}
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
class CSV_BaseOutputData
|
1043 |
+
{
|
1044 |
+
private $m_lgepGatewayEntryPoints;
|
1045 |
+
|
1046 |
+
public function getGatewayEntryPoints()
|
1047 |
+
{
|
1048 |
+
return $this->m_lgepGatewayEntryPoints;
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
//constructor
|
1052 |
+
public function __construct(CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
|
1053 |
+
{
|
1054 |
+
$this->m_lgepGatewayEntryPoints = $lgepGatewayEntryPoints;
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
|
1059 |
+
/********************/
|
1060 |
+
/* Gateway messages */
|
1061 |
+
/********************/
|
1062 |
+
class CSV_GetGatewayEntryPoints extends CSV_GatewayTransaction
|
1063 |
+
{
|
1064 |
+
function processTransaction(CSV_GetGatewayEntryPointsResult &$ggeprGetGatewayEntryPointsResult = null, CSV_GetGatewayEntryPointsOutputData &$ggepGetGatewayEntryPointsOutputData = null)
|
1065 |
+
{
|
1066 |
+
$boTransactionSubmitted = false;
|
1067 |
+
$sSOAPClient;
|
1068 |
+
$lgepGatewayEntryPoints;
|
1069 |
+
|
1070 |
+
$ggepGetGatewayEntryPointsOutputData = null;
|
1071 |
+
$goGatewayOutput = null;
|
1072 |
+
|
1073 |
+
$sSOAPClient = new CSV_SOAP('GetGatewayEntryPoints', CSV_GatewayTransaction::getSOAPNamespace());
|
1074 |
+
|
1075 |
+
$boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetGatewayEntryPointsMessage', 'GetGatewayEntryPointsResult', 'GetGatewayEntryPointsOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
|
1076 |
+
|
1077 |
+
if ($boTransactionSubmitted)
|
1078 |
+
{
|
1079 |
+
$ggeprGetGatewayEntryPointsResult = $goGatewayOutput;
|
1080 |
+
|
1081 |
+
$ggepGetGatewayEntryPointsOutputData = new CSV_GetGatewayEntryPointsOutputData($lgepGatewayEntryPoints);
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
return $boTransactionSubmitted;
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
//constructor
|
1088 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
1089 |
+
$nRetryAttempts,
|
1090 |
+
CSV_NullableInt $nTimeout = null,
|
1091 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
1092 |
+
$szPassOutData)
|
1093 |
+
{
|
1094 |
+
if ($nRetryAttempts == null &&
|
1095 |
+
$nTimeout == null)
|
1096 |
+
{
|
1097 |
+
CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, 1, null, $maMerchantAuthentication, $szPassOutData);
|
1098 |
+
}
|
1099 |
+
else
|
1100 |
+
{
|
1101 |
+
CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
|
1102 |
+
}
|
1103 |
+
}
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
|
1107 |
+
class CSV_CardDetailsTransaction extends CSV_GatewayTransaction
|
1108 |
+
{
|
1109 |
+
private $m_tdTransactionDetails;
|
1110 |
+
private $m_cdCardDetails;
|
1111 |
+
private $m_cdCustomerDetails;
|
1112 |
+
|
1113 |
+
public function getTransactionDetails()
|
1114 |
+
{
|
1115 |
+
return $this->m_tdTransactionDetails;
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
public function getCardDetails()
|
1119 |
+
{
|
1120 |
+
return $this->m_cdCardDetails;
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
public function getCustomerDetails()
|
1124 |
+
{
|
1125 |
+
return $this->m_cdCardDetails;
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
public function processTransaction(CSV_CardDetailsTransactionResult &$cdtrCardDetailsTransactionResult = null, CSV_TransactionOutputData &$todTransactionOutputData = null)
|
1129 |
+
{
|
1130 |
+
$boTransactionSubmitted = false;
|
1131 |
+
$sSOAPClient;
|
1132 |
+
$lgepGatewayEntryPoints = null;
|
1133 |
+
$sxXmlDocument;
|
1134 |
+
$goGatewayOutput = null;
|
1135 |
+
|
1136 |
+
$todTransactionOutputData = null;
|
1137 |
+
$cdtrCardDetailsTransactionResult = null;
|
1138 |
+
|
1139 |
+
$sSOAPClient = new CSV_SOAP('CardDetailsTransaction', parent::getSOAPNamespace());
|
1140 |
+
|
1141 |
+
// transaction details
|
1142 |
+
if ($this->m_tdTransactionDetails != null)
|
1143 |
+
{
|
1144 |
+
$test = $this->m_tdTransactionDetails->getAmount();
|
1145 |
+
if ($this->m_tdTransactionDetails->getAmount() != null)
|
1146 |
+
{
|
1147 |
+
if ($this->m_tdTransactionDetails->getAmount()->getHasValue())
|
1148 |
+
{
|
1149 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'Amount', (string)$this->m_tdTransactionDetails->getAmount()->getValue());
|
1150 |
+
}
|
1151 |
+
}
|
1152 |
+
if ($this->m_tdTransactionDetails->getCurrencyCode() != null)
|
1153 |
+
{
|
1154 |
+
if ($this->m_tdTransactionDetails->getCurrencyCode()->getHasValue())
|
1155 |
+
{
|
1156 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'CurrencyCode', (string)$this->m_tdTransactionDetails->getCurrencyCode()->getValue());
|
1157 |
+
}
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
if ($this->m_tdTransactionDetails->getMessageDetails() != null)
|
1161 |
+
{
|
1162 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
|
1163 |
+
{
|
1164 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
|
1165 |
+
}
|
1166 |
+
}
|
1167 |
+
if ($this->m_tdTransactionDetails->getTransactionControl() != null)
|
1168 |
+
{
|
1169 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
|
1170 |
+
{
|
1171 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
|
1172 |
+
}
|
1173 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy() != null)
|
1174 |
+
{
|
1175 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecureOverridePolicy', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy()->getValue()));
|
1176 |
+
}
|
1177 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
|
1178 |
+
{
|
1179 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
|
1180 |
+
}
|
1181 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
|
1182 |
+
{
|
1183 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', ($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()));
|
1184 |
+
}
|
1185 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
|
1186 |
+
{
|
1187 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
|
1188 |
+
{
|
1189 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)$this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue());
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
|
1193 |
+
{
|
1194 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
|
1195 |
+
{
|
1196 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
|
1197 |
+
}
|
1198 |
+
}
|
1199 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
|
1200 |
+
{
|
1201 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
|
1202 |
+
{
|
1203 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
|
1204 |
+
}
|
1205 |
+
}
|
1206 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
|
1207 |
+
{
|
1208 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
|
1209 |
+
{
|
1210 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
|
1211 |
+
}
|
1212 |
+
}
|
1213 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
|
1214 |
+
{
|
1215 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
|
1216 |
+
{
|
1217 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
|
1218 |
+
}
|
1219 |
+
}
|
1220 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
|
1221 |
+
{
|
1222 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
|
1223 |
+
{
|
1224 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
|
1225 |
+
}
|
1226 |
+
}
|
1227 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData() != null)
|
1228 |
+
{
|
1229 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus()))
|
1230 |
+
{
|
1231 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'EnrolmentStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus());
|
1232 |
+
}
|
1233 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus()))
|
1234 |
+
{
|
1235 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'AuthenticationStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus());
|
1236 |
+
}
|
1237 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator()))
|
1238 |
+
{
|
1239 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.ElectronicCommerceIndicator', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator());
|
1240 |
+
}
|
1241 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue()))
|
1242 |
+
{
|
1243 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.AuthenticationValue', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue());
|
1244 |
+
}
|
1245 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier()))
|
1246 |
+
{
|
1247 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.TransactionIdentifier', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier());
|
1248 |
+
}
|
1249 |
+
}
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails() != null)
|
1253 |
+
{
|
1254 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders()))
|
1255 |
+
{
|
1256 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.AcceptHeaders', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders());
|
1257 |
+
}
|
1258 |
+
if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory() != null)
|
1259 |
+
{
|
1260 |
+
if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getHasValue())
|
1261 |
+
{
|
1262 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails', 'DeviceCategory', (string)$this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getValue());
|
1263 |
+
}
|
1264 |
+
}
|
1265 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent()))
|
1266 |
+
{
|
1267 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.UserAgent', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent());
|
1268 |
+
}
|
1269 |
+
}
|
1270 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
|
1271 |
+
{
|
1272 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
|
1273 |
+
}
|
1274 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
|
1275 |
+
{
|
1276 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
|
1277 |
+
}
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
// card details
|
1281 |
+
if ($this->m_cdCardDetails != null)
|
1282 |
+
{
|
1283 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardName()))
|
1284 |
+
{
|
1285 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.CardName', $this->m_cdCardDetails->getCardName());
|
1286 |
+
}
|
1287 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCV2()))
|
1288 |
+
{
|
1289 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_cdCardDetails->getCV2());
|
1290 |
+
}
|
1291 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardNumber()))
|
1292 |
+
{
|
1293 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.CardNumber', $this->m_cdCardDetails->getCardNumber());
|
1294 |
+
}
|
1295 |
+
if ($this->m_cdCardDetails->getExpiryDate() != null)
|
1296 |
+
{
|
1297 |
+
if ($this->m_cdCardDetails->getExpiryDate()->getMonth() != null)
|
1298 |
+
{
|
1299 |
+
if ($this->m_cdCardDetails->getExpiryDate()->getMonth()->getHasValue())
|
1300 |
+
{
|
1301 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Month', (string)$this->m_cdCardDetails->getExpiryDate()->getMonth()->getValue());
|
1302 |
+
}
|
1303 |
+
}
|
1304 |
+
if ($this->m_cdCardDetails->getExpiryDate()->getYear() != null)
|
1305 |
+
{
|
1306 |
+
if ($this->m_cdCardDetails->getExpiryDate()->getYear()->getHasValue())
|
1307 |
+
{
|
1308 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Year', (string)$this->m_cdCardDetails->getExpiryDate()->getYear()->getValue());
|
1309 |
+
}
|
1310 |
+
}
|
1311 |
+
}
|
1312 |
+
if ($this->m_cdCardDetails->getStartDate() != null)
|
1313 |
+
{
|
1314 |
+
if ($this->m_cdCardDetails->getStartDate()->getMonth() != null)
|
1315 |
+
{
|
1316 |
+
if ($this->m_cdCardDetails->getStartDate()->getMonth()->getHasValue())
|
1317 |
+
{
|
1318 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Month', (string)$this->m_cdCardDetails->getStartDate()->getMonth()->getValue());
|
1319 |
+
}
|
1320 |
+
}
|
1321 |
+
if ($this->m_cdCardDetails->getStartDate()->getYear() != null)
|
1322 |
+
{
|
1323 |
+
if ($this->m_cdCardDetails->getStartDate()->getYear()->getHasValue())
|
1324 |
+
{
|
1325 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Year', (string)$this->m_cdCardDetails->getStartDate()->getYear()->getValue());
|
1326 |
+
}
|
1327 |
+
}
|
1328 |
+
}
|
1329 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getIssueNumber()))
|
1330 |
+
{
|
1331 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_cdCardDetails->getIssueNumber());
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
// customer details
|
1336 |
+
if ($this->m_cdCustomerDetails != null)
|
1337 |
+
{
|
1338 |
+
if ($this->m_cdCustomerDetails->getBillingAddress() != null)
|
1339 |
+
{
|
1340 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
|
1341 |
+
{
|
1342 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
|
1343 |
+
}
|
1344 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
|
1345 |
+
{
|
1346 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
|
1347 |
+
}
|
1348 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
|
1349 |
+
{
|
1350 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
|
1351 |
+
}
|
1352 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
|
1353 |
+
{
|
1354 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
|
1355 |
+
}
|
1356 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
|
1357 |
+
{
|
1358 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
|
1359 |
+
}
|
1360 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
|
1361 |
+
{
|
1362 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
|
1363 |
+
}
|
1364 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
|
1365 |
+
{
|
1366 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', $this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
|
1367 |
+
}
|
1368 |
+
if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
|
1369 |
+
{
|
1370 |
+
if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
|
1371 |
+
{
|
1372 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
|
1373 |
+
}
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
|
1377 |
+
{
|
1378 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
|
1379 |
+
}
|
1380 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
|
1381 |
+
{
|
1382 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
|
1383 |
+
}
|
1384 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
|
1385 |
+
{
|
1386 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
|
1387 |
+
}
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
$boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CardDetailsTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
|
1391 |
+
|
1392 |
+
if ($boTransactionSubmitted)
|
1393 |
+
{
|
1394 |
+
$cdtrCardDetailsTransactionResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CardDetailsTransactionResult, $goGatewayOutput);
|
1395 |
+
|
1396 |
+
$todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
return ($boTransactionSubmitted);
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
1403 |
+
$nRetryAttempts,
|
1404 |
+
CSV_NullableInt $nTimeout = null,
|
1405 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
1406 |
+
CSV_TransactionDetails $tdTransactionDetails = null,
|
1407 |
+
CSV_CardDetails $cdCardDetails = null,
|
1408 |
+
CSV_CustomerDetails $cdCustomerDetails = null,
|
1409 |
+
$szPassOutData)
|
1410 |
+
{
|
1411 |
+
parent::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
|
1412 |
+
|
1413 |
+
$this->m_tdTransactionDetails = $tdTransactionDetails;
|
1414 |
+
$this->m_cdCardDetails = $cdCardDetails;
|
1415 |
+
$this->m_cdCustomerDetails = $cdCustomerDetails;
|
1416 |
+
}
|
1417 |
+
|
1418 |
+
}
|
1419 |
+
class CSV_CrossReferenceTransaction extends CSV_GatewayTransaction
|
1420 |
+
{
|
1421 |
+
private $m_tdTransactionDetails;
|
1422 |
+
private $m_ocdOverrideCardDetails;
|
1423 |
+
private $m_cdCustomerDetails;
|
1424 |
+
|
1425 |
+
public function getTransactionDetails()
|
1426 |
+
{
|
1427 |
+
return $this->m_tdTransactionDetails;
|
1428 |
+
}
|
1429 |
+
public function getOverrideCardDetails()
|
1430 |
+
{
|
1431 |
+
return $this->m_ocdOverrideCardDetails;
|
1432 |
+
}
|
1433 |
+
public function getCustomerDetails()
|
1434 |
+
{
|
1435 |
+
return $this->m_cdCustomerDetails;
|
1436 |
+
}
|
1437 |
+
|
1438 |
+
public function processTransaction(CSV_CrossReferenceTransactionResult &$crtrCrossReferenceTransactionResult = null, CSV_TransactionOutputData &$todTransactionOutputData = null)
|
1439 |
+
{
|
1440 |
+
$boTransactionSubmitted = false;
|
1441 |
+
$sSOAPClient;
|
1442 |
+
$lgepGatewayEntryPoints = null;
|
1443 |
+
$sxXmlDocument = null;
|
1444 |
+
|
1445 |
+
$todTransactionOutputData = null;
|
1446 |
+
$goGatewayOutput = null;
|
1447 |
+
|
1448 |
+
$sSOAPClient = new CSV_SOAP('CrossReferenceTransaction', CSV_GatewayTransaction::getSOAPNamespace());
|
1449 |
+
// transaction details
|
1450 |
+
if ($this->m_tdTransactionDetails != null)
|
1451 |
+
{
|
1452 |
+
if ($this->m_tdTransactionDetails->getAmount() != null)
|
1453 |
+
{
|
1454 |
+
if ($this->m_tdTransactionDetails->getAmount()->getHasValue())
|
1455 |
+
{
|
1456 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'Amount', (string)$this->m_tdTransactionDetails->getAmount()->getValue());
|
1457 |
+
}
|
1458 |
+
}
|
1459 |
+
if ($this->m_tdTransactionDetails->getCurrencyCode() != null)
|
1460 |
+
{
|
1461 |
+
if ($this->m_tdTransactionDetails->getCurrencyCode()->getHasValue())
|
1462 |
+
{
|
1463 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'CurrencyCode', (string)$this->m_tdTransactionDetails->getCurrencyCode()->getValue());
|
1464 |
+
}
|
1465 |
+
}
|
1466 |
+
if ($this->m_tdTransactionDetails->getMessageDetails() != null)
|
1467 |
+
{
|
1468 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
|
1469 |
+
{
|
1470 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
|
1471 |
+
}
|
1472 |
+
if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction() != null)
|
1473 |
+
{
|
1474 |
+
if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getHasValue())
|
1475 |
+
{
|
1476 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'NewTransaction', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getValue()));
|
1477 |
+
}
|
1478 |
+
}
|
1479 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getCrossReference()))
|
1480 |
+
{
|
1481 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'CrossReference', $this->m_tdTransactionDetails->getMessageDetails()->getCrossReference());
|
1482 |
+
}
|
1483 |
+
}
|
1484 |
+
if ($this->m_tdTransactionDetails->getTransactionControl() != null)
|
1485 |
+
{
|
1486 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
|
1487 |
+
{
|
1488 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
|
1489 |
+
}
|
1490 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
|
1491 |
+
{
|
1492 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
|
1493 |
+
}
|
1494 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
|
1495 |
+
{
|
1496 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy());
|
1497 |
+
}
|
1498 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
|
1499 |
+
{
|
1500 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
|
1501 |
+
{
|
1502 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue()));
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
|
1506 |
+
{
|
1507 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
|
1508 |
+
{
|
1509 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
|
1510 |
+
}
|
1511 |
+
}
|
1512 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
|
1513 |
+
{
|
1514 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
|
1515 |
+
{
|
1516 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
|
1517 |
+
}
|
1518 |
+
}
|
1519 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
|
1520 |
+
{
|
1521 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
|
1522 |
+
{
|
1523 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
|
1524 |
+
}
|
1525 |
+
}
|
1526 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
|
1527 |
+
{
|
1528 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
|
1529 |
+
{
|
1530 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
|
1531 |
+
}
|
1532 |
+
}
|
1533 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
|
1534 |
+
{
|
1535 |
+
if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
|
1536 |
+
{
|
1537 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
|
1538 |
+
}
|
1539 |
+
}
|
1540 |
+
}
|
1541 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
|
1542 |
+
{
|
1543 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
|
1544 |
+
}
|
1545 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
|
1546 |
+
{
|
1547 |
+
$sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
|
1548 |
+
}
|
1549 |
+
}
|
1550 |
+
// card details
|
1551 |
+
if ($this->m_ocdOverrideCardDetails != null)
|
1552 |
+
{
|
1553 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardName()))
|
1554 |
+
{
|
1555 |
+
$sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardName', $this->m_ocdOverrideCardDetails->getCardName());
|
1556 |
+
}
|
1557 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCV2()))
|
1558 |
+
{
|
1559 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_ocdOverrideCardDetails->getCV2());
|
1560 |
+
}
|
1561 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardNumber()))
|
1562 |
+
{
|
1563 |
+
$sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardNumber', $this->m_ocdOverrideCardDetails->getCardNumber());
|
1564 |
+
}
|
1565 |
+
if ($this->m_ocdOverrideCardDetails->getExpiryDate() != null)
|
1566 |
+
{
|
1567 |
+
if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth() != null)
|
1568 |
+
{
|
1569 |
+
if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getHasValue())
|
1570 |
+
{
|
1571 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getValue());
|
1572 |
+
}
|
1573 |
+
}
|
1574 |
+
if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear() != null)
|
1575 |
+
{
|
1576 |
+
if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getHasValue())
|
1577 |
+
{
|
1578 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getValue());
|
1579 |
+
}
|
1580 |
+
}
|
1581 |
+
}
|
1582 |
+
if ($this->m_ocdOverrideCardDetails->getStartDate() != null)
|
1583 |
+
{
|
1584 |
+
if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth() != null)
|
1585 |
+
{
|
1586 |
+
if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getHasValue())
|
1587 |
+
{
|
1588 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getValue());
|
1589 |
+
}
|
1590 |
+
}
|
1591 |
+
if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear() != null)
|
1592 |
+
{
|
1593 |
+
if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getHasValue())
|
1594 |
+
{
|
1595 |
+
$sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getValue());
|
1596 |
+
}
|
1597 |
+
}
|
1598 |
+
}
|
1599 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getIssueNumber()))
|
1600 |
+
{
|
1601 |
+
$sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_ocdOverrideCardDetails->getIssueNumber());
|
1602 |
+
}
|
1603 |
+
}
|
1604 |
+
// customer details
|
1605 |
+
if ($this->m_cdCustomerDetails != null)
|
1606 |
+
{
|
1607 |
+
if ($this->m_cdCustomerDetails->getBillingAddress() != null)
|
1608 |
+
{
|
1609 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
|
1610 |
+
{
|
1611 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
|
1612 |
+
}
|
1613 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
|
1614 |
+
{
|
1615 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
|
1616 |
+
}
|
1617 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
|
1618 |
+
{
|
1619 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
|
1620 |
+
}
|
1621 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
|
1622 |
+
{
|
1623 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
|
1624 |
+
}
|
1625 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
|
1626 |
+
{
|
1627 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
|
1628 |
+
}
|
1629 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
|
1630 |
+
{
|
1631 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
|
1632 |
+
}
|
1633 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
|
1634 |
+
{
|
1635 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
|
1636 |
+
}
|
1637 |
+
if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
|
1638 |
+
{
|
1639 |
+
if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
|
1640 |
+
{
|
1641 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
|
1642 |
+
}
|
1643 |
+
}
|
1644 |
+
}
|
1645 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
|
1646 |
+
{
|
1647 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
|
1648 |
+
}
|
1649 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
|
1650 |
+
{
|
1651 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
|
1652 |
+
}
|
1653 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
|
1654 |
+
{
|
1655 |
+
$sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
|
1656 |
+
}
|
1657 |
+
}
|
1658 |
+
|
1659 |
+
$boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CrossReferenceTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
|
1660 |
+
|
1661 |
+
if ($boTransactionSubmitted)
|
1662 |
+
{
|
1663 |
+
$crtrCrossReferenceTransactionResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CrossReferenceTransactionResult, $goGatewayOutput);
|
1664 |
+
|
1665 |
+
$todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
return $boTransactionSubmitted;
|
1669 |
+
}
|
1670 |
+
|
1671 |
+
//constructor
|
1672 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
1673 |
+
$nRetryAttempts,
|
1674 |
+
CSV_NullableInt $nTimeout = null,
|
1675 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
1676 |
+
CSV_TransactionDetails $tdTransactionDetails = null,
|
1677 |
+
CSV_CardDetails $cdOverrideCardDetails = null,
|
1678 |
+
CSV_CustomerDetails $cdCustomerDetails = null,
|
1679 |
+
$szPassOutData)
|
1680 |
+
{
|
1681 |
+
GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
|
1682 |
+
|
1683 |
+
$this->m_tdTransactionDetails = $tdTransactionDetails;
|
1684 |
+
$this->m_ocdOverrideCardDetails = $cdOverrideCardDetails;
|
1685 |
+
$this->m_cdCustomerDetails = $cdCustomerDetails;
|
1686 |
+
}
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
class CSV_ThreeDSecureAuthentication extends CSV_GatewayTransaction
|
1690 |
+
{
|
1691 |
+
private $m_tdsidThreeDSecureInputData;
|
1692 |
+
|
1693 |
+
public function getThreeDSecureInputData()
|
1694 |
+
{
|
1695 |
+
return $this->m_tdsidThreeDSecureInputData;
|
1696 |
+
}
|
1697 |
+
|
1698 |
+
public function processTransaction(CSV_ThreeDSecureAuthenticationResult &$tdsarThreeDSecureAuthenticationResult = null, CSV_TransactionOutputData &$todTransactionOutputData = null)
|
1699 |
+
{
|
1700 |
+
$boTransactionSubmitted = false;
|
1701 |
+
$sSOAPClient;
|
1702 |
+
$lgepGatewayEntryPoints = null;
|
1703 |
+
$sxXmlDocument = null;
|
1704 |
+
|
1705 |
+
$todTransactionOutputData = null;
|
1706 |
+
$goGatewayOutput = null;
|
1707 |
+
|
1708 |
+
$sSOAPClient = new CSV_SOAP('ThreeDSecureAuthentication', CSV_GatewayTransaction::getSOAPNamespace());
|
1709 |
+
if ($this->m_tdsidThreeDSecureInputData != null)
|
1710 |
+
{
|
1711 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getCrossReference()))
|
1712 |
+
{
|
1713 |
+
$sSOAPClient->addParamAttribute('ThreeDSecureMessage.ThreeDSecureInputData', 'CrossReference', $this->m_tdsidThreeDSecureInputData->getCrossReference());
|
1714 |
+
}
|
1715 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getPaRES()))
|
1716 |
+
{
|
1717 |
+
$sSOAPClient->addParam('ThreeDSecureMessage.ThreeDSecureInputData.PaRES', $this->m_tdsidThreeDSecureInputData->getPaRES());
|
1718 |
+
}
|
1719 |
+
}
|
1720 |
+
|
1721 |
+
$boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'ThreeDSecureMessage', 'ThreeDSecureAuthenticationResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
|
1722 |
+
|
1723 |
+
if ($boTransactionSubmitted)
|
1724 |
+
{
|
1725 |
+
$tdsarThreeDSecureAuthenticationResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->ThreeDSecureAuthenticationResult, $goGatewayOutput);
|
1726 |
+
|
1727 |
+
$todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
return $boTransactionSubmitted;
|
1731 |
+
}
|
1732 |
+
|
1733 |
+
//constructor
|
1734 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
1735 |
+
$nRetryAttempts,
|
1736 |
+
CSV_NullableInt $nTimeout = null,
|
1737 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
1738 |
+
CSV_ThreeDSecureInputData $tdsidThreeDSecureInputData = null,
|
1739 |
+
$szPassOutData)
|
1740 |
+
{
|
1741 |
+
CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
|
1742 |
+
|
1743 |
+
$this->m_tdsidThreeDSecureInputData = $tdsidThreeDSecureInputData;
|
1744 |
+
}
|
1745 |
+
}
|
1746 |
+
|
1747 |
+
class CSV_GetCardType extends CSV_GatewayTransaction
|
1748 |
+
{
|
1749 |
+
private $m_szCardNumber;
|
1750 |
+
|
1751 |
+
public function getCardNumber()
|
1752 |
+
{
|
1753 |
+
return $this->m_szCardNumber;
|
1754 |
+
}
|
1755 |
+
|
1756 |
+
public function processTransaction(CSV_GetCardTypeResult &$gctrGetCardTypeResult = null, CSV_GetCardTypeOutputData &$gctodGetCardTypeOutputData = null)
|
1757 |
+
{
|
1758 |
+
$boTransactionSubmitted = false;
|
1759 |
+
$sSOAPClient;
|
1760 |
+
$lgepGatewayEntryPoints = null;
|
1761 |
+
$ctdCardTypeData = null;
|
1762 |
+
$sxXmlDocument = null;
|
1763 |
+
|
1764 |
+
$gctodGetCardTypeOutputData = null;
|
1765 |
+
$goGatewayOutput = null;
|
1766 |
+
|
1767 |
+
$sSOAPClient = new CSV_SOAP('GetCardType', CSV_GatewayTransaction::getSOAPNamespace());
|
1768 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_szCardNumber))
|
1769 |
+
{
|
1770 |
+
$sSOAPClient->addParam('GetCardTypeMessage.CardNumber', $this->m_szCardNumber);
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
$boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetCardTypeMessage', 'GetCardTypeResult', 'GetCardTypeOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
|
1774 |
+
|
1775 |
+
if ($boTransactionSubmitted)
|
1776 |
+
{
|
1777 |
+
$gctrGetCardTypeResult = $goGatewayOutput;
|
1778 |
+
|
1779 |
+
if(!$sxXmlDocument->GetCardTypeOutputData->CardTypeData)
|
1780 |
+
{
|
1781 |
+
$ctdCardTypeData = null;
|
1782 |
+
}
|
1783 |
+
else
|
1784 |
+
{
|
1785 |
+
$ctdCardTypeData = CSV_SharedFunctionsPaymentSystemShared::getCardTypeData($sxXmlDocument->GetCardTypeOutputData->CardTypeData);
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
if (!is_null($ctdCardTypeData))
|
1789 |
+
{
|
1790 |
+
$gctodGetCardTypeOutputData = new CSV_GetCardTypeOutputData($ctdCardTypeData, $lgepGatewayEntryPoints);
|
1791 |
+
}
|
1792 |
+
}
|
1793 |
+
return $boTransactionSubmitted;
|
1794 |
+
}
|
1795 |
+
|
1796 |
+
//constructor
|
1797 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
1798 |
+
$nRetryAttempts,
|
1799 |
+
CSV_NullableInt $nTimeout = null,
|
1800 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
1801 |
+
$szCardNumber,
|
1802 |
+
$szPassOutData)
|
1803 |
+
{
|
1804 |
+
CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
|
1805 |
+
|
1806 |
+
$this->m_szCardNumber = $szCardNumber;
|
1807 |
+
}
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
abstract class CSV_GatewayTransaction
|
1811 |
+
{
|
1812 |
+
private $m_maMerchantAuthentication;
|
1813 |
+
private $m_szPassOutData;
|
1814 |
+
private $m_lrgepRequestGatewayEntryPoints;
|
1815 |
+
private $m_nRetryAttempts;
|
1816 |
+
private $m_nTimeout;
|
1817 |
+
private $m_szSOAPNamespace = 'https://www.thepaymentgateway.net/';
|
1818 |
+
private $m_szLastRequest;
|
1819 |
+
private $m_szLastResponse;
|
1820 |
+
private $m_eLastException;
|
1821 |
+
private $m_szEntryPointUsed;
|
1822 |
+
|
1823 |
+
public function getMerchantAuthentication()
|
1824 |
+
{
|
1825 |
+
return $this->m_maMerchantAuthentication;
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
public function getPassOutData()
|
1829 |
+
{
|
1830 |
+
return $this->m_szPassOutData;
|
1831 |
+
}
|
1832 |
+
|
1833 |
+
public function getRequestGatewayEntryPoints()
|
1834 |
+
{
|
1835 |
+
return $this->m_lrgepRequestGatewayEntryPoints;
|
1836 |
+
}
|
1837 |
+
|
1838 |
+
public function getRetryAttempts()
|
1839 |
+
{
|
1840 |
+
return $this->m_nRetryAttempts;
|
1841 |
+
}
|
1842 |
+
|
1843 |
+
public function getTimeout()
|
1844 |
+
{
|
1845 |
+
return $this->m_nTimeout;
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
public function getSOAPNamespace()
|
1849 |
+
{
|
1850 |
+
return $this->m_szSOAPNamespace;
|
1851 |
+
}
|
1852 |
+
public function setSOAPNamespace($value)
|
1853 |
+
{
|
1854 |
+
$this->m_szSOAPNamespace = $value;
|
1855 |
+
}
|
1856 |
+
|
1857 |
+
public function getLastRequest()
|
1858 |
+
{
|
1859 |
+
return $this->m_szLastRequest;
|
1860 |
+
}
|
1861 |
+
|
1862 |
+
public function getLastResponse()
|
1863 |
+
{
|
1864 |
+
return $this->m_szLastResponse;
|
1865 |
+
}
|
1866 |
+
|
1867 |
+
public function getLastException()
|
1868 |
+
{
|
1869 |
+
return $this->m_eLastException;
|
1870 |
+
}
|
1871 |
+
public function getEntryPointUsed()
|
1872 |
+
{
|
1873 |
+
return $this->m_szEntryPointUsed;
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
public static function compare($x, $y)
|
1877 |
+
{
|
1878 |
+
$rgepFirst = null;
|
1879 |
+
$rgepSecond = null;
|
1880 |
+
|
1881 |
+
$rgepFirst = $x;
|
1882 |
+
$rgepSecond = $y;
|
1883 |
+
|
1884 |
+
return (CSV_GatewayTransaction::compareGatewayEntryPoints($rgepFirst, $rgepSecond));
|
1885 |
+
}
|
1886 |
+
|
1887 |
+
private static function compareGatewayEntryPoints(CSV_RequestGatewayEntryPoint $rgepFirst, CSV_RequestGatewayEntryPoint $rgepSecond)
|
1888 |
+
{
|
1889 |
+
$nReturnValue = 0;
|
1890 |
+
// returns >0 if rgepFirst greater than rgepSecond
|
1891 |
+
// returns 0 if they are equal
|
1892 |
+
// returns <0 if rgepFirst less than rgepSecond
|
1893 |
+
|
1894 |
+
// both null, then they are the same
|
1895 |
+
if ($rgepFirst == null &&
|
1896 |
+
$rgepSecond == null)
|
1897 |
+
{
|
1898 |
+
$nReturnValue = 0;
|
1899 |
+
}
|
1900 |
+
// just first null? then second is greater
|
1901 |
+
elseif ($rgepFirst == null &&
|
1902 |
+
$rgepSecond != null)
|
1903 |
+
{
|
1904 |
+
$nReturnValue = 1;
|
1905 |
+
}
|
1906 |
+
// just second null? then first is greater
|
1907 |
+
elseif ($rgepFirst != null && $rgepSecond == null)
|
1908 |
+
{
|
1909 |
+
$nReturnValue = -1;
|
1910 |
+
}
|
1911 |
+
// can now assume that first & second both have a value
|
1912 |
+
elseif ($rgepFirst->getMetric() == $rgepSecond->getMetric())
|
1913 |
+
{
|
1914 |
+
$nReturnValue = 0;
|
1915 |
+
}
|
1916 |
+
elseif ($rgepFirst->getMetric() < $rgepSecond->getMetric())
|
1917 |
+
{
|
1918 |
+
$nReturnValue = -1;
|
1919 |
+
}
|
1920 |
+
elseif ($rgepFirst->getMetric() > $rgepSecond->getMetric())
|
1921 |
+
{
|
1922 |
+
$nReturnValue = 1;
|
1923 |
+
}
|
1924 |
+
|
1925 |
+
return $nReturnValue;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
protected function processTransactionBase(CSV_SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, CSV_GatewayOutput &$goGatewayOutput = null, CSV_GatewayEntryPointList &$lgepGatewayEntryPoints = null)
|
1929 |
+
{
|
1930 |
+
$boTransactionSubmitted = false;
|
1931 |
+
$nOverallRetryCount = 0;
|
1932 |
+
$nOverallGatewayEntryPointCount = 0;
|
1933 |
+
$nGatewayEntryPointCount = 0;
|
1934 |
+
$nErrorMessageCount = 0;
|
1935 |
+
$rgepCurrentGatewayEntryPoint;
|
1936 |
+
$nStatusCode;
|
1937 |
+
$szMessage = null;
|
1938 |
+
$lszErrorMessages;
|
1939 |
+
$szString;
|
1940 |
+
$sbXMLString;
|
1941 |
+
$szXMLFormatString;
|
1942 |
+
$nCount = 0;
|
1943 |
+
$szEntryPointURL;
|
1944 |
+
$nMetric;
|
1945 |
+
$gepGatewayEntryPoint = null;
|
1946 |
+
$szPassOutData = null;
|
1947 |
+
$ResponseDocument = null;
|
1948 |
+
$ResponseMethod = null;
|
1949 |
+
|
1950 |
+
$lgepGatewayEntryPoints = null;
|
1951 |
+
$goGatewayOutput = null;
|
1952 |
+
|
1953 |
+
$this->m_szEntryPointUsed = null;
|
1954 |
+
|
1955 |
+
if ($sSOAPClient == null)
|
1956 |
+
{
|
1957 |
+
return false;
|
1958 |
+
}
|
1959 |
+
|
1960 |
+
// populate the merchant details
|
1961 |
+
if ($this->m_maMerchantAuthentication != null)
|
1962 |
+
{
|
1963 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getMerchantID()))
|
1964 |
+
{
|
1965 |
+
$sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'MerchantID', $this->m_maMerchantAuthentication->getMerchantID());
|
1966 |
+
}
|
1967 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getPassword()))
|
1968 |
+
{
|
1969 |
+
$sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'Password', $this->m_maMerchantAuthentication->getPassword());
|
1970 |
+
}
|
1971 |
+
}
|
1972 |
+
|
1973 |
+
// populate the passout data
|
1974 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_szPassOutData))
|
1975 |
+
{
|
1976 |
+
$sSOAPClient->addParam($szMessageXMLPath. '.PassOutData', $this->m_szPassOutData, null);
|
1977 |
+
}
|
1978 |
+
|
1979 |
+
// first need to sort the gateway entry points into the correct usage order
|
1980 |
+
$number = $this->m_lrgepRequestGatewayEntryPoints->sort('CSV_GatewayTransaction','Compare');
|
1981 |
+
|
1982 |
+
// loop over the overall number of transaction attempts
|
1983 |
+
while (!$boTransactionSubmitted &&
|
1984 |
+
$nOverallRetryCount < $this->m_nRetryAttempts)
|
1985 |
+
{
|
1986 |
+
$nOverallGatewayEntryPointCount = 0;
|
1987 |
+
|
1988 |
+
// loop over the number of gateway entry points in the list
|
1989 |
+
while (!$boTransactionSubmitted &&
|
1990 |
+
$nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount())
|
1991 |
+
{
|
1992 |
+
|
1993 |
+
$rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount);
|
1994 |
+
|
1995 |
+
// ignore if the metric is "-1" this indicates that the entry point is offline
|
1996 |
+
if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0)
|
1997 |
+
{
|
1998 |
+
$nGatewayEntryPointCount = 0;
|
1999 |
+
$sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL());
|
2000 |
+
|
2001 |
+
// loop over the number of times to try this specific entry point
|
2002 |
+
while (!$boTransactionSubmitted &&
|
2003 |
+
$nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts())
|
2004 |
+
{
|
2005 |
+
if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod))
|
2006 |
+
{
|
2007 |
+
//getting the valid transaction type document format
|
2008 |
+
$sxXmlDocument = $ResponseDocument->$ResponseMethod;
|
2009 |
+
|
2010 |
+
$lszErrorMessages = new CSV_StringList();
|
2011 |
+
|
2012 |
+
$nStatusCode = (int)current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->StatusCode[0]);
|
2013 |
+
|
2014 |
+
// a status code of 50 means that this entry point is not to be used
|
2015 |
+
if ($nStatusCode != 50)
|
2016 |
+
{
|
2017 |
+
$this->m_szEntryPointUsed = $rgepCurrentGatewayEntryPoint->getEntryPointURL();
|
2018 |
+
|
2019 |
+
// the transaction was submitted
|
2020 |
+
$boTransactionSubmitted = true;
|
2021 |
+
|
2022 |
+
if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message)
|
2023 |
+
{
|
2024 |
+
$szMessage = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message[0]);
|
2025 |
+
}
|
2026 |
+
if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages)
|
2027 |
+
{
|
2028 |
+
foreach ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages->MessageDetail as $key => $value)
|
2029 |
+
{
|
2030 |
+
$lszErrorMessages->add(current($value->Detail));
|
2031 |
+
}
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData)
|
2035 |
+
{
|
2036 |
+
$szPassOutData = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData[0]);
|
2037 |
+
}
|
2038 |
+
else
|
2039 |
+
{
|
2040 |
+
$szPassOutData = null;
|
2041 |
+
}
|
2042 |
+
|
2043 |
+
$goGatewayOutput = new CSV_GatewayOutput($nStatusCode, $szMessage, $szPassOutData/*, $boAuthorisationAttempted, $ptdPreviousTransactionResult*/, $lszErrorMessages);
|
2044 |
+
|
2045 |
+
// look to see if there are any gateway entry points
|
2046 |
+
$nCount = 0;
|
2047 |
+
|
2048 |
+
$nMetric = -1;
|
2049 |
+
|
2050 |
+
if ($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints)
|
2051 |
+
{
|
2052 |
+
if($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint)
|
2053 |
+
{
|
2054 |
+
$szXMLFormatString = $ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint;
|
2055 |
+
|
2056 |
+
foreach($szXMLFormatString->attributes() as $key => $value)
|
2057 |
+
{
|
2058 |
+
if (is_numeric(current($value)))
|
2059 |
+
{
|
2060 |
+
$nMetric = current($value);
|
2061 |
+
}
|
2062 |
+
else
|
2063 |
+
{
|
2064 |
+
$szEntryPointURL = current($value);
|
2065 |
+
}
|
2066 |
+
}
|
2067 |
+
|
2068 |
+
//$gepGatewayEntryPoint = new GatewayEntryPoint($szEntryPointURL, $nMetric);
|
2069 |
+
if ($lgepGatewayEntryPoints == null)
|
2070 |
+
{
|
2071 |
+
$lgepGatewayEntryPoints = new CSV_GatewayEntryPointList();
|
2072 |
+
}
|
2073 |
+
$lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric); //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint);
|
2074 |
+
}
|
2075 |
+
}
|
2076 |
+
$nCount++;
|
2077 |
+
}
|
2078 |
+
}
|
2079 |
+
|
2080 |
+
$nGatewayEntryPointCount++;
|
2081 |
+
}
|
2082 |
+
}
|
2083 |
+
$nOverallGatewayEntryPointCount++;
|
2084 |
+
}
|
2085 |
+
$nOverallRetryCount++;
|
2086 |
+
}
|
2087 |
+
$this->m_szLastRequest = $sSOAPClient->getSOAPPacket();
|
2088 |
+
$this->m_szLastResponse = $sSOAPClient->getLastResponse();
|
2089 |
+
$this->m_eLastException = $sSOAPClient->getLastException();
|
2090 |
+
|
2091 |
+
return $boTransactionSubmitted;
|
2092 |
+
}
|
2093 |
+
|
2094 |
+
public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
|
2095 |
+
$nRetryAttempts,
|
2096 |
+
CSV_NullableInt $nTimeout = null,
|
2097 |
+
CSV_MerchantAuthentication $maMerchantAuthentication = null,
|
2098 |
+
$szPassOutData)
|
2099 |
+
{
|
2100 |
+
$this->m_maMerchantAuthentication = $maMerchantAuthentication;
|
2101 |
+
$this->m_szPassOutData = $szPassOutData;
|
2102 |
+
$this->m_lrgepRequestGatewayEntryPoints = $lrgepRequestGatewayEntryPoints;
|
2103 |
+
$this->m_nRetryAttempts = $nRetryAttempts;
|
2104 |
+
$this->m_nTimeout = $nTimeout;
|
2105 |
+
}
|
2106 |
+
}
|
2107 |
+
|
2108 |
+
class CSV_SharedFunctionsPaymentSystemShared
|
2109 |
+
{
|
2110 |
+
public static function getTransactionOutputData(SimpleXMLElement $sxXmlDocument, CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
|
2111 |
+
{
|
2112 |
+
$szCrossReference = null;
|
2113 |
+
$szAddressNumericCheckResult = null;
|
2114 |
+
$szPostCodeCheckResult = null;
|
2115 |
+
$szThreeDSecureAuthenticationCheckResult = null;
|
2116 |
+
$szCV2CheckResult = null;
|
2117 |
+
$nAmountReceived = null;
|
2118 |
+
$szPaREQ = null;
|
2119 |
+
$szACSURL = null;
|
2120 |
+
$ctdCardTypeData = null;
|
2121 |
+
$tdsodThreeDSecureOutputData = null;
|
2122 |
+
$lgvCustomVariables = null;
|
2123 |
+
$nCount = 0;
|
2124 |
+
$sbString;
|
2125 |
+
$szXMLFormatString;
|
2126 |
+
$szName;
|
2127 |
+
$szValue;
|
2128 |
+
$gvGenericVariable;
|
2129 |
+
$nCount = 0;
|
2130 |
+
$szCardTypeData;
|
2131 |
+
|
2132 |
+
$todTransactionOutputData = null;
|
2133 |
+
|
2134 |
+
if (!$sxXmlDocument->TransactionOutputData)
|
2135 |
+
{
|
2136 |
+
return (null);
|
2137 |
+
}
|
2138 |
+
|
2139 |
+
if ($sxXmlDocument->TransactionOutputData->attributes())
|
2140 |
+
{
|
2141 |
+
foreach($sxXmlDocument->TransactionOutputData->attributes() as $key => $value)
|
2142 |
+
{
|
2143 |
+
$szCrossReference = current($value);
|
2144 |
+
}
|
2145 |
+
}
|
2146 |
+
else
|
2147 |
+
{
|
2148 |
+
$szCrossReference = null;
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
if ($sxXmlDocument->TransactionOutputData->AuthCode)
|
2152 |
+
{
|
2153 |
+
$szAuthCode = current($sxXmlDocument->TransactionOutputData->AuthCode[0]);
|
2154 |
+
}
|
2155 |
+
else
|
2156 |
+
{
|
2157 |
+
$szAuthCode = null;
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
if ($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult)
|
2161 |
+
{
|
2162 |
+
$szAddressNumericCheckResult = current($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult[0]);
|
2163 |
+
}
|
2164 |
+
|
2165 |
+
if ($sxXmlDocument->TransactionOutputData->PostCodeCheckResult)
|
2166 |
+
{
|
2167 |
+
$szPostCodeCheckResult = current($sxXmlDocument->TransactionOutputData->PostCodeCheckResult[0]);
|
2168 |
+
}
|
2169 |
+
|
2170 |
+
if ($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult)
|
2171 |
+
{
|
2172 |
+
$szThreeDSecureAuthenticationCheckResult = current($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult[0]);
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
if ($sxXmlDocument->TransactionOutputData->CV2CheckResult)
|
2176 |
+
{
|
2177 |
+
$szCV2CheckResult = current($sxXmlDocument->TransactionOutputData->CV2CheckResult[0]);
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
if ($sxXmlDocument->TransactionOutputData->CardTypeData)
|
2181 |
+
{
|
2182 |
+
$ctdCardTypeData = self::getCardTypeData($sxXmlDocument->TransactionOutputData->CardTypeData);
|
2183 |
+
}
|
2184 |
+
else
|
2185 |
+
{
|
2186 |
+
$ctdCardTypeData = null;
|
2187 |
+
}
|
2188 |
+
|
2189 |
+
if ($sxXmlDocument->TransactionOutputData->AmountReceived)
|
2190 |
+
{
|
2191 |
+
$nAmountReceived = new CSV_NullableInt(current($sxXmlDocument->TransactionOutputData->AmountReceived[0]));
|
2192 |
+
}
|
2193 |
+
else
|
2194 |
+
{
|
2195 |
+
$nAmountReceived = new CSV_NullableInt(null);
|
2196 |
+
}
|
2197 |
+
|
2198 |
+
if ($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData)
|
2199 |
+
{
|
2200 |
+
$szPaREQ = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->PaREQ[0]);
|
2201 |
+
$szACSURL = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->ACSURL[0]);
|
2202 |
+
}
|
2203 |
+
else
|
2204 |
+
{
|
2205 |
+
$szPaREQ = null;
|
2206 |
+
$szACSURL = null;
|
2207 |
+
}
|
2208 |
+
|
2209 |
+
|
2210 |
+
if (!CSV_SharedFunctions::isStringNullOrEmpty($szACSURL) &&
|
2211 |
+
!CSV_SharedFunctions::isStringNullOrEmpty($szPaREQ))
|
2212 |
+
{
|
2213 |
+
$tdsodThreeDSecureOutputData = new CSV_ThreeDSecureOutputData($szPaREQ, $szACSURL);
|
2214 |
+
}
|
2215 |
+
|
2216 |
+
if ($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable)
|
2217 |
+
{
|
2218 |
+
if ($lgvCustomVariables == null)
|
2219 |
+
{
|
2220 |
+
$lgvCustomVariables = new CSV_GenericVariableList();
|
2221 |
+
}
|
2222 |
+
for ($nCount=0; $nCount < count($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable); $nCount++)
|
2223 |
+
{
|
2224 |
+
$szName = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Name[0]);
|
2225 |
+
$szValue = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Value[0]);
|
2226 |
+
$gvGenericVariable = new CSV_GenericVariable($szName, $szValue);
|
2227 |
+
$lgvCustomVariables->add($gvGenericVariable);
|
2228 |
+
}
|
2229 |
+
}
|
2230 |
+
else
|
2231 |
+
{
|
2232 |
+
$lgvCustomVariables = null;
|
2233 |
+
}
|
2234 |
+
|
2235 |
+
|
2236 |
+
$todTransactionOutputData = new CSV_TransactionOutputData($szCrossReference,
|
2237 |
+
$szAuthCode,
|
2238 |
+
$szAddressNumericCheckResult,
|
2239 |
+
$szPostCodeCheckResult,
|
2240 |
+
$szThreeDSecureAuthenticationCheckResult,
|
2241 |
+
$szCV2CheckResult,
|
2242 |
+
$ctdCardTypeData,
|
2243 |
+
$nAmountReceived,
|
2244 |
+
$tdsodThreeDSecureOutputData,
|
2245 |
+
$lgvCustomVariables,
|
2246 |
+
$lgepGatewayEntryPoints);
|
2247 |
+
|
2248 |
+
return $todTransactionOutputData;
|
2249 |
+
}
|
2250 |
+
|
2251 |
+
public static function getCardTypeData($CardTypeDataTag)
|
2252 |
+
{
|
2253 |
+
$ctdCardTypeData = null;
|
2254 |
+
$szCardType = null;
|
2255 |
+
$boLuhnCheckRequired = null;
|
2256 |
+
$szStartDateStatus = null;
|
2257 |
+
$szIssueNumberStatus = null;
|
2258 |
+
$szIssuer = null;
|
2259 |
+
$nISOCode = null;
|
2260 |
+
$iIssuer;
|
2261 |
+
|
2262 |
+
if ($CardTypeDataTag->CardType)
|
2263 |
+
{
|
2264 |
+
$szCardType = current($CardTypeDataTag->CardType[0]);
|
2265 |
+
}
|
2266 |
+
|
2267 |
+
if ($CardTypeDataTag->Issuer)
|
2268 |
+
{
|
2269 |
+
try
|
2270 |
+
{
|
2271 |
+
$szIssuer = (string)$CardTypeDataTag->Issuer[0];
|
2272 |
+
}
|
2273 |
+
catch (Exception $e)
|
2274 |
+
{
|
2275 |
+
$szIssuer = null;
|
2276 |
+
}
|
2277 |
+
|
2278 |
+
try
|
2279 |
+
{
|
2280 |
+
$nISOCode = current($CardTypeDataTag->Issuer->attributes()->ISOCode);
|
2281 |
+
}
|
2282 |
+
catch (Exception $e)
|
2283 |
+
{
|
2284 |
+
$nISOCode = null;
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
$iIssuer = new CSV_Issuer($szIssuer, $nISOCode);
|
2288 |
+
}
|
2289 |
+
else
|
2290 |
+
{
|
2291 |
+
$iIssuer = null;
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
if ($CardTypeDataTag->LuhnCheckRequired)
|
2295 |
+
{
|
2296 |
+
$boLuhnCheckRequired = new CSV_NullableBool(current($CardTypeDataTag->LuhnCheckRequired[0]));
|
2297 |
+
}
|
2298 |
+
else
|
2299 |
+
{
|
2300 |
+
$boLuhnCheckRequired = null;
|
2301 |
+
}
|
2302 |
+
|
2303 |
+
if ($CardTypeDataTag->IssueNumberStatus)
|
2304 |
+
{
|
2305 |
+
try
|
2306 |
+
{
|
2307 |
+
$szIssueNumberStatus = current($CardTypeDataTag->IssueNumberStatus[0]);
|
2308 |
+
}
|
2309 |
+
catch (Exception $e)
|
2310 |
+
{
|
2311 |
+
$szIssueNumberStatus = null;
|
2312 |
+
}
|
2313 |
+
}
|
2314 |
+
else
|
2315 |
+
{
|
2316 |
+
$szIssueNumberStatus = null;
|
2317 |
+
}
|
2318 |
+
|
2319 |
+
if ($CardTypeDataTag->StartDateStatus)
|
2320 |
+
{
|
2321 |
+
try
|
2322 |
+
{
|
2323 |
+
$szStartDateStatus = current($CardTypeDataTag->StartDateStatus[0]);
|
2324 |
+
}
|
2325 |
+
catch (Exception $e)
|
2326 |
+
{
|
2327 |
+
$szStartDateStatus = null;
|
2328 |
+
}
|
2329 |
+
}
|
2330 |
+
else
|
2331 |
+
{
|
2332 |
+
$szStartDateStatus = null;
|
2333 |
+
}
|
2334 |
+
|
2335 |
+
$ctdCardTypeData = new CSV_CardTypeData($szCardType, $iIssuer, $boLuhnCheckRequired, $szIssueNumberStatus, $szStartDateStatus);
|
2336 |
+
|
2337 |
+
return ($ctdCardTypeData);
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
|
2341 |
+
|
2342 |
+
public static function getPaymentMessageGatewayOutput($GatewayOutput, CSV_GatewayOutput $goGatewayOutput = null)
|
2343 |
+
{
|
2344 |
+
$nPreviousStatusCode = null;
|
2345 |
+
$szPreviousMessage = null;
|
2346 |
+
$ptdPreviousTransactionResult = null;
|
2347 |
+
$pmgoPaymentMessageGatewayOutput = null;
|
2348 |
+
$boAuthorisationAttempted = null;
|
2349 |
+
|
2350 |
+
if ($GatewayOutput->attributes())
|
2351 |
+
{
|
2352 |
+
try
|
2353 |
+
{
|
2354 |
+
$szAuthorisationAttempted = current($GatewayOutput->attributes()->AuthorisationAttempted);
|
2355 |
+
if (strtolower($boAuthorisationAttempted) == 'false')
|
2356 |
+
{
|
2357 |
+
$boAuthorisationAttempted = new CSV_NullableBool(false);
|
2358 |
+
}
|
2359 |
+
elseif (strtolower($boAuthorisationAttempted) == 'true')
|
2360 |
+
{
|
2361 |
+
$boAuthorisationAttempted = new CSV_NullableBool(true);
|
2362 |
+
}
|
2363 |
+
else
|
2364 |
+
{
|
2365 |
+
throw new Exception('Return value must be true or false');
|
2366 |
+
}
|
2367 |
+
}
|
2368 |
+
catch (Exception $e)
|
2369 |
+
{
|
2370 |
+
$boAuthorisationAttempted = null;
|
2371 |
+
}
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
//check to see if there is any previous transaction data
|
2375 |
+
if ($GatewayOutput->PreviousTransactionResult->StatusCode)
|
2376 |
+
{
|
2377 |
+
$nPreviousStatusCode = new CSV_NullableInt(current($GatewayOutput->PreviousTransactionResult->StatusCode[0]));
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
if ($GatewayOutput->PreviousTransactionResult->Message)
|
2381 |
+
{
|
2382 |
+
$szPreviousMessage = current($GatewayOutput->PreviousTransactionResult->Message[0]);
|
2383 |
+
}
|
2384 |
+
|
2385 |
+
if ($nPreviousStatusCode != null &&
|
2386 |
+
!CSV_SharedFunctions::isStringNullOrEmpty($szPreviousMessage))
|
2387 |
+
{
|
2388 |
+
$ptdPreviousTransactionResult = new CSV_PreviousTransactionResult($nPreviousStatusCode, $szPreviousMessage);
|
2389 |
+
}
|
2390 |
+
|
2391 |
+
$pmgoPaymentMessageGatewayOutput = new CSV_PaymentMessageGatewayOutput($goGatewayOutput->getStatusCode(),
|
2392 |
+
$goGatewayOutput->getMessage(),
|
2393 |
+
$goGatewayOutput->getPassOutData(),
|
2394 |
+
$boAuthorisationAttempted,
|
2395 |
+
$ptdPreviousTransactionResult,
|
2396 |
+
$goGatewayOutput->getErrorMessages());
|
2397 |
+
|
2398 |
+
return $pmgoPaymentMessageGatewayOutput;
|
2399 |
+
}
|
2400 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/SOAP.php
ADDED
@@ -0,0 +1,968 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//accessing external files
|
3 |
+
require_once('TPG_Common.php');
|
4 |
+
|
5 |
+
class CSV_SOAPNamespace
|
6 |
+
{
|
7 |
+
private $m_szNamespace;
|
8 |
+
private $m_szPrefix;
|
9 |
+
|
10 |
+
public function getNamespace()
|
11 |
+
{
|
12 |
+
return $this->m_szNamespace;
|
13 |
+
}
|
14 |
+
public function getPrefix()
|
15 |
+
{
|
16 |
+
return $this->m_szPrefix;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function __construct($szPrefix,$szNamespace)
|
20 |
+
{
|
21 |
+
$this->m_szNamespace = $szNamespace;
|
22 |
+
$this->m_szPrefix = $szPrefix;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
class CSV_SOAPNamespaceList
|
27 |
+
{
|
28 |
+
private $m_lsnSOAPNamespaceList;
|
29 |
+
|
30 |
+
function getAt($nIndex)
|
31 |
+
{
|
32 |
+
if ($nIndex < 0 ||
|
33 |
+
$nIndex >= count($this->m_lsnSOAPNamespaceList))
|
34 |
+
{
|
35 |
+
throw new Exception('Array index out of bounds');
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->m_lsnSOAPNamespaceList[$nIndex];
|
39 |
+
}
|
40 |
+
|
41 |
+
function getCount()
|
42 |
+
{
|
43 |
+
return count($this->m_lsnSOAPNamespaceList);
|
44 |
+
}
|
45 |
+
|
46 |
+
private function add1(CSV_SOAPNamespace $snSOAPNamespace)
|
47 |
+
{
|
48 |
+
$this->m_lsnSOAPNamespaceList[] = $snSOAPNamespace;
|
49 |
+
}
|
50 |
+
private function add2($szPrefix, $szSOAPNamespace)
|
51 |
+
{
|
52 |
+
if (!is_string($szPrefix) || !is_string($szSOAPNamespace))
|
53 |
+
{
|
54 |
+
throw new Exception('Invalid parameter type');
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->m_lsnSOAPNamespaceList[] = new CSV_SOAPNamespace($szPrefix, $szSOAPNamespace);
|
58 |
+
}
|
59 |
+
|
60 |
+
//function overloading
|
61 |
+
public function add()
|
62 |
+
{
|
63 |
+
$num_args = func_num_args();
|
64 |
+
$args = func_get_args();
|
65 |
+
|
66 |
+
switch ($num_args)
|
67 |
+
{
|
68 |
+
case 1:
|
69 |
+
//$this->__call('add1', $args);
|
70 |
+
$this->add1($args[0]);
|
71 |
+
break;
|
72 |
+
case 3:
|
73 |
+
//$this->__call('add2', $args);
|
74 |
+
$this->add2($args[0], $args[1], $args[2]);
|
75 |
+
break;
|
76 |
+
default:
|
77 |
+
throw new Exception('Invalid number of parameters for fucntion Add');
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
//constructor
|
82 |
+
public function __construct()
|
83 |
+
{
|
84 |
+
$this->m_lsnSOAPNamespaceList = array();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
class CSV_SOAPParameter
|
89 |
+
{
|
90 |
+
private $m_szName;
|
91 |
+
private $m_szValue;
|
92 |
+
//private $m_lspaSOAPParamAttributeList = array();
|
93 |
+
private $m_lspaSOAPParamAttributeList;
|
94 |
+
private $m_lspSOAPParamList;
|
95 |
+
|
96 |
+
//public property functions
|
97 |
+
public function getName()
|
98 |
+
{
|
99 |
+
return $this->m_szName;
|
100 |
+
}
|
101 |
+
public function getValue()
|
102 |
+
{
|
103 |
+
return $this->m_szValue;
|
104 |
+
}
|
105 |
+
public function setValue($szValue)
|
106 |
+
{
|
107 |
+
$this->m_szValue = $szValue;
|
108 |
+
}
|
109 |
+
public function getSOAPParamAttributeList()
|
110 |
+
{
|
111 |
+
return $this->m_lspaSOAPParamAttributeList;
|
112 |
+
}
|
113 |
+
public function getSOAPParamList()
|
114 |
+
{
|
115 |
+
return $this->m_lspSOAPParamList;
|
116 |
+
}
|
117 |
+
|
118 |
+
//constructor
|
119 |
+
public function __construct($szName, $szValue, CSV_SOAPParamAttributeList $lspaSOAPParamAttributeList = null)
|
120 |
+
{
|
121 |
+
$nCount = 0;
|
122 |
+
$spaSOAPParamAttribute = null;
|
123 |
+
|
124 |
+
if (!is_string($szName) ||
|
125 |
+
!is_string($szValue))
|
126 |
+
{
|
127 |
+
throw new Exception('Invalid parameter type');
|
128 |
+
}
|
129 |
+
|
130 |
+
$this->m_szName = $szName;
|
131 |
+
//$this->m_szValue = SharedFunctions::replaceCharsInStringWithEntities($szValue);
|
132 |
+
$this->setValue($szValue);
|
133 |
+
|
134 |
+
$this->m_lspSOAPParamList = new CSV_SOAPParamList();
|
135 |
+
$this->m_lspaSOAPParamAttributeList = new CSV_SOAPParamAttributeList();
|
136 |
+
|
137 |
+
if ($lspaSOAPParamAttributeList != null)
|
138 |
+
{
|
139 |
+
for ($nCount = 0; $nCount < $lspaSOAPParamAttributeList->getCount();$nCount++)
|
140 |
+
{
|
141 |
+
$spaSOAPParamAttribute = new CSV_SOAPParamAttribute($lspaSOAPParamAttributeList->getAt($nCount)->getName(), $lspaSOAPParamAttributeList->getAt($nCount)->getValue());
|
142 |
+
|
143 |
+
$this->m_lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
function toXMLString()
|
149 |
+
{
|
150 |
+
$sbReturnString = null;
|
151 |
+
$nCount = null;
|
152 |
+
$spParam = null;
|
153 |
+
$spaAttribute = null;
|
154 |
+
$sbString = null;
|
155 |
+
|
156 |
+
$sbReturnString = '';
|
157 |
+
$sbReturnString .= '<' . $this->getName();
|
158 |
+
|
159 |
+
if ($this->m_lspaSOAPParamAttributeList != null)
|
160 |
+
{
|
161 |
+
for ($nCount = 0; $nCount < $this->m_lspaSOAPParamAttributeList->getCount(); $nCount++)
|
162 |
+
{
|
163 |
+
$spaAttribute = $this->m_lspaSOAPParamAttributeList->getAt($nCount);
|
164 |
+
|
165 |
+
if ($spaAttribute != null)
|
166 |
+
{
|
167 |
+
$sbString = '';
|
168 |
+
$sbString .= ' ' .$spaAttribute->getName(). '="' .CSV_SharedFunctions::replaceCharsInStringWithEntities($spaAttribute->getValue()). '"';
|
169 |
+
$sbReturnString .= (string)$sbString;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
if ($this->m_lspSOAPParamList->getCount() == 0 &&
|
175 |
+
$this->getValue() == '')
|
176 |
+
{
|
177 |
+
$sbReturnString .= ' />';
|
178 |
+
}
|
179 |
+
else
|
180 |
+
{
|
181 |
+
$sbReturnString .= '>';
|
182 |
+
|
183 |
+
if ($this->getValue() != '')
|
184 |
+
{
|
185 |
+
$sbReturnString .= CSV_SharedFunctions::replaceCharsInStringWithEntities($this->getValue());
|
186 |
+
}
|
187 |
+
|
188 |
+
for ($nCount = 0; $nCount < $this->m_lspSOAPParamList->getCount(); $nCount++)
|
189 |
+
{
|
190 |
+
$spParam = $this->m_lspSOAPParamList->getAt($nCount);
|
191 |
+
|
192 |
+
if ($spParam != null)
|
193 |
+
{
|
194 |
+
$sbReturnString .= $spParam->toXMLString();
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
$sbReturnString .= '</' . $this->getName() . '>';
|
199 |
+
}
|
200 |
+
|
201 |
+
return (string)$sbReturnString;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
class CSV_SOAPParamList
|
206 |
+
{
|
207 |
+
private $m_lspSOAPParamList;
|
208 |
+
|
209 |
+
public function getAt($nIndex)
|
210 |
+
{
|
211 |
+
if ($nIndex < 0 ||
|
212 |
+
$nIndex > count($this->m_lspSOAPParamList))
|
213 |
+
{
|
214 |
+
throw new Exception('Array index out of bounds');
|
215 |
+
}
|
216 |
+
|
217 |
+
return $this->m_lspSOAPParamList[$nIndex];
|
218 |
+
}
|
219 |
+
|
220 |
+
function getCount()
|
221 |
+
{
|
222 |
+
return count($this->m_lspSOAPParamList);
|
223 |
+
}
|
224 |
+
|
225 |
+
protected function add1(CSV_SOAPParameter $spSOAPParam)
|
226 |
+
{
|
227 |
+
$this->m_lspSOAPParamList[] = $spSOAPParam;
|
228 |
+
}
|
229 |
+
protected function add2($szName, $szValue)
|
230 |
+
{
|
231 |
+
$nReturnValue = -1;
|
232 |
+
|
233 |
+
if (!is_string($szName) ||
|
234 |
+
!is_string($szValue))
|
235 |
+
{
|
236 |
+
throw new Exception('Invalid parameter type: '. $szName .', '. $szValue);
|
237 |
+
}
|
238 |
+
|
239 |
+
if ($szName != '' &&
|
240 |
+
$szName != null)
|
241 |
+
{
|
242 |
+
$this->m_lspSOAPParamList[] = new CSV_SOAPParameter($szName, $szValue);
|
243 |
+
}
|
244 |
+
|
245 |
+
return $nReturnValue;
|
246 |
+
}
|
247 |
+
|
248 |
+
//overloading
|
249 |
+
public function add()
|
250 |
+
{
|
251 |
+
$num_args = func_num_args();
|
252 |
+
$args = func_get_args();
|
253 |
+
|
254 |
+
switch ($num_args)
|
255 |
+
{
|
256 |
+
case 1:
|
257 |
+
//$this->__call('add1', $args);
|
258 |
+
$this->add1($args[0]);
|
259 |
+
break;
|
260 |
+
case 2:
|
261 |
+
//$this->__call('add2', $args);
|
262 |
+
$this->add2($args[0], $args[1]);
|
263 |
+
break;
|
264 |
+
default:
|
265 |
+
throw new Exception('Invalid number of parameters');
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
//constructor
|
270 |
+
public function __construct()
|
271 |
+
{
|
272 |
+
$this->m_lspSOAPParamList = array();
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
class CSV_SOAPParamAttribute
|
277 |
+
{
|
278 |
+
private $m_szName;
|
279 |
+
private $m_szValue;
|
280 |
+
|
281 |
+
public function getName()
|
282 |
+
{
|
283 |
+
return $this->m_szName;
|
284 |
+
}
|
285 |
+
public function getValue()
|
286 |
+
{
|
287 |
+
return $this->m_szValue;
|
288 |
+
}
|
289 |
+
|
290 |
+
//constructor
|
291 |
+
public function __construct($szName, $szValue)
|
292 |
+
{
|
293 |
+
if (!is_string($szName) ||
|
294 |
+
!is_string($szValue))
|
295 |
+
{
|
296 |
+
throw new Exception('Invalid parameter type');
|
297 |
+
}
|
298 |
+
|
299 |
+
$this->m_szName = $szName;
|
300 |
+
$this->m_szValue = $szValue;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
class CSV_SOAPParamAttributeList
|
305 |
+
{
|
306 |
+
private $m_lspaSOAPParamAttributeAttributeList;
|
307 |
+
|
308 |
+
public function getAt($nIndex)
|
309 |
+
{
|
310 |
+
if ($nIndex < 0 ||
|
311 |
+
$nIndex >= count($this->m_lspaSOAPParamAttributeAttributeList))
|
312 |
+
{
|
313 |
+
throw new Exception('Array index out of bounds');
|
314 |
+
}
|
315 |
+
|
316 |
+
return $this->m_lspaSOAPParamAttributeAttributeList[$nIndex];
|
317 |
+
}
|
318 |
+
public function getCount()
|
319 |
+
{
|
320 |
+
return count($this->m_lspaSOAPParamAttributeAttributeList);
|
321 |
+
}
|
322 |
+
|
323 |
+
private function add1(CSV_SOAPParamAttribute $spaSOAPParamAttributeAttribute)
|
324 |
+
{
|
325 |
+
$result = array_push($this->m_lspaSOAPParamAttributeAttributeList, $spaSOAPParamAttributeAttribute);
|
326 |
+
return $result;
|
327 |
+
}
|
328 |
+
private function add2($szName, $szValue)
|
329 |
+
{
|
330 |
+
$nReturnValue = -1;
|
331 |
+
|
332 |
+
if (!is_string($szName) ||
|
333 |
+
!is_string($szValue))
|
334 |
+
{
|
335 |
+
throw new Exception('Invalid parameter type');
|
336 |
+
}
|
337 |
+
|
338 |
+
if ($szName != '' &&
|
339 |
+
$szName != null)
|
340 |
+
{
|
341 |
+
$nReturnValue = array_push($this->m_lspaSOAPParamAttributeAttributeList, new CSV_SOAPParamAttribute($szName, $szValue));
|
342 |
+
}
|
343 |
+
|
344 |
+
return $nReturnValue;
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
+
public function add()
|
349 |
+
{
|
350 |
+
$num_args = func_num_args();
|
351 |
+
$args = func_get_args();
|
352 |
+
|
353 |
+
switch ($num_args)
|
354 |
+
{
|
355 |
+
case 1:
|
356 |
+
//$this->__call('add1', $args);
|
357 |
+
$this->add1($args[0]);
|
358 |
+
break;
|
359 |
+
case 2:
|
360 |
+
//$this->__call('add2', $args);
|
361 |
+
$this->add2($args[0], $args[1]);
|
362 |
+
break;
|
363 |
+
default:
|
364 |
+
throw new Exception('Invalid number of parameters for fucntion Add');
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
//constructor
|
369 |
+
public function __construct()
|
370 |
+
{
|
371 |
+
$this->m_lspaSOAPParamAttributeAttributeList = array();
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
class CSV_SOAP
|
376 |
+
{
|
377 |
+
private $m_szMethod;
|
378 |
+
private $m_szMethodURI;
|
379 |
+
private $m_szURL;
|
380 |
+
private $m_szActionURI;
|
381 |
+
private $m_szSOAPEncoding;
|
382 |
+
private $m_boPacketBuilt;
|
383 |
+
private $m_szLastResponse;
|
384 |
+
private $m_szSOAPPacket;
|
385 |
+
private $m_xmlParser;
|
386 |
+
private $m_xmlTag;
|
387 |
+
private $m_nTimeout;
|
388 |
+
private $m_eLastException;
|
389 |
+
|
390 |
+
private $m_lsnSOAPNamespaceList;
|
391 |
+
private $m_lspSOAPParamList;
|
392 |
+
|
393 |
+
//public property like functions
|
394 |
+
public function getMethod()
|
395 |
+
{
|
396 |
+
return $this->m_szMethod;
|
397 |
+
}
|
398 |
+
public function getMethodURI()
|
399 |
+
{
|
400 |
+
return $this->m_szMethodURI;
|
401 |
+
}
|
402 |
+
public function getURL()
|
403 |
+
{
|
404 |
+
return $this->m_szURL;
|
405 |
+
}
|
406 |
+
public function setURL($value)
|
407 |
+
{
|
408 |
+
$this->m_szURL = $value;
|
409 |
+
}
|
410 |
+
public function getActionURI()
|
411 |
+
{
|
412 |
+
return $this->m_szActionURI;
|
413 |
+
}
|
414 |
+
public function getSOAPEncoding()
|
415 |
+
{
|
416 |
+
return $this->m_szSOAPEncoding;
|
417 |
+
}
|
418 |
+
public function getPacketBuilt()
|
419 |
+
{
|
420 |
+
return $this->m_boPacketBuilt;
|
421 |
+
}
|
422 |
+
public function getLastResponse()
|
423 |
+
{
|
424 |
+
return $this->m_szLastResponse;
|
425 |
+
}
|
426 |
+
public function getSOAPPacket()
|
427 |
+
{
|
428 |
+
return $this->m_szSOAPPacket;
|
429 |
+
}
|
430 |
+
public function getXmlTag()
|
431 |
+
{
|
432 |
+
return $this->m_xmlTag;
|
433 |
+
}
|
434 |
+
public function getTimeout()
|
435 |
+
{
|
436 |
+
return $this->m_nTimeout;
|
437 |
+
}
|
438 |
+
public function setTimeout($value)
|
439 |
+
{
|
440 |
+
$this->m_nTimeout = $value;
|
441 |
+
}
|
442 |
+
public function getLastException()
|
443 |
+
{
|
444 |
+
$this->m_eLastException;
|
445 |
+
}
|
446 |
+
|
447 |
+
public function buildPacket()
|
448 |
+
{
|
449 |
+
$sbString = null;
|
450 |
+
$sbString2 = null;
|
451 |
+
$snNamespace = null;
|
452 |
+
$szFirstNamespace = null;
|
453 |
+
$szFirstPrefix = null;
|
454 |
+
$nCount = 0;
|
455 |
+
$spSOAPParam = null;
|
456 |
+
|
457 |
+
// build the xml SOAP request
|
458 |
+
// start with the XML version
|
459 |
+
$sbString = '';
|
460 |
+
$sbString .= '<?xml version="1.0" encoding="utf-8" ?>';
|
461 |
+
|
462 |
+
if ($this->m_lsnSOAPNamespaceList->getCount() == 0)
|
463 |
+
{
|
464 |
+
$szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
|
465 |
+
$szFirstPrefix = 'soap';
|
466 |
+
}
|
467 |
+
else
|
468 |
+
{
|
469 |
+
$snNamespace = $this->m_lsnSOAPNamespaceList->getAt(0);
|
470 |
+
|
471 |
+
if ($snNamespace == null)
|
472 |
+
{
|
473 |
+
$szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
|
474 |
+
$szFirstPrefix = 'soap';
|
475 |
+
}
|
476 |
+
else
|
477 |
+
{
|
478 |
+
if ($snNamespace->getNamespace() == null ||
|
479 |
+
$snNamespace->getNamespace() == '')
|
480 |
+
{
|
481 |
+
$szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
|
482 |
+
}
|
483 |
+
else
|
484 |
+
{
|
485 |
+
$szFirstNamespace = $snNamespace->getNamespace();
|
486 |
+
}
|
487 |
+
|
488 |
+
if ($snNamespace->getPrefix() == null ||
|
489 |
+
$snNamespace->getPrefix() == '')
|
490 |
+
{
|
491 |
+
$szFirstPrefix = 'soap';
|
492 |
+
}
|
493 |
+
else
|
494 |
+
{
|
495 |
+
$szFirstPrefix = $snNamespace->getPrefix();
|
496 |
+
}
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
$sbString2 = '';
|
501 |
+
$sbString2 .= '<' .$szFirstPrefix. ':Envelope xmlns:' .$szFirstPrefix. '="' .$szFirstNamespace. '"';
|
502 |
+
|
503 |
+
for ($nCount = 1; $nCount <$this->m_lsnSOAPNamespaceList->getCount(); $nCount++)
|
504 |
+
{
|
505 |
+
$snNamespace = $this->m_lsnSOAPNamespaceList->getAt($nCount);
|
506 |
+
|
507 |
+
if ($snNamespace != null)
|
508 |
+
{
|
509 |
+
if ($snNamespace->getNamespace() != '' &&
|
510 |
+
$snNamespace->getPrefix() != '')
|
511 |
+
{
|
512 |
+
$sbString2 .= ' xmlns:' .$snNamespace->getPrefix(). '="' .$snNamespace->getNamespace(). '"';
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
$sbString2 .= '>';
|
518 |
+
|
519 |
+
$sbString .= (string)$sbString2;
|
520 |
+
$sbString2 = '';
|
521 |
+
$sbString2 .= '<' .$szFirstPrefix. ':Body>';
|
522 |
+
$sbString .= (string)$sbString2;
|
523 |
+
$sbString2 = '';
|
524 |
+
$sbString2 .= '<' .$this->getMethod(). ' xmlns="' .$this->getMethodURI(). '">';
|
525 |
+
$sbString .= (string)$sbString2;
|
526 |
+
|
527 |
+
for ($nCount = 0;$nCount < $this->m_lspSOAPParamList->getCount(); $nCount++)
|
528 |
+
{
|
529 |
+
$spSOAPParam = $this->m_lspSOAPParamList->getAt($nCount);
|
530 |
+
|
531 |
+
if ($spSOAPParam != null)
|
532 |
+
{
|
533 |
+
$sbString .= $spSOAPParam->toXMLString();
|
534 |
+
}
|
535 |
+
}
|
536 |
+
|
537 |
+
$sbString2 = '';
|
538 |
+
$sbString2 .= '</' .$this->getMethod(). '>';
|
539 |
+
$sbString .= (string)$sbString2;
|
540 |
+
$sbString2 = '';
|
541 |
+
$sbString2 .= '</' .$szFirstPrefix. ':Body></' .$szFirstPrefix. ':Envelope>';
|
542 |
+
$sbString .= (string)$sbString2;
|
543 |
+
|
544 |
+
$this->m_szSOAPPacket = (string)$sbString;
|
545 |
+
$this->m_boPacketBuilt = true;
|
546 |
+
}
|
547 |
+
|
548 |
+
public function sendRequest(&$ResponseDocument, &$ResponseMethod)
|
549 |
+
{
|
550 |
+
$szString = ''; //response string
|
551 |
+
$sbString;
|
552 |
+
$XmlDoc; //response in parsed array format
|
553 |
+
$boReturnValue = false;
|
554 |
+
$szUserAgent = 'ThePaymentGateway SOAP Library PHP';
|
555 |
+
|
556 |
+
|
557 |
+
if (!$this->m_boPacketBuilt)
|
558 |
+
{
|
559 |
+
$this->buildPacket();
|
560 |
+
}
|
561 |
+
|
562 |
+
$this->m_xmlParser = null;
|
563 |
+
$this->m_xmlTag = null;
|
564 |
+
|
565 |
+
try
|
566 |
+
{
|
567 |
+
//intialising the curl for XML parsing
|
568 |
+
$cURL = curl_init();
|
569 |
+
|
570 |
+
//http settings
|
571 |
+
$HttpHeader[] = 'SOAPAction:'. $this->getActionURI();
|
572 |
+
$HttpHeader[] = 'Content-Type: text/xml; charset = utf-8';
|
573 |
+
$HttpHeader[] = 'Connection: close';
|
574 |
+
|
575 |
+
/*$http_options = array( CURLOPT_HEADER => false,
|
576 |
+
CURLOPT_HTTPHEADER => $HttpHeader,
|
577 |
+
CURLOPT_POST => true,
|
578 |
+
CURLOPT_URL => $this->getURL(),
|
579 |
+
CURLOPT_USERAGENT => $szUserAgent,
|
580 |
+
CURLOPT_POSTFIELDS => $this->getSOAPPacket(),
|
581 |
+
CURLOPT_RETURNTRANSFER => true,
|
582 |
+
CURLOPT_ENCODING => "UTF-8",
|
583 |
+
CURLOPT_SSL_VERIFYPEER => false, //disabling default peer SSL certificate verification
|
584 |
+
);
|
585 |
+
|
586 |
+
curl_setopt_array($cURL, $http_options);*/
|
587 |
+
|
588 |
+
curl_setopt($cURL, CURLOPT_HEADER, false);
|
589 |
+
curl_setopt($cURL, CURLOPT_HTTPHEADER, $HttpHeader);
|
590 |
+
curl_setopt($cURL, CURLOPT_POST, true);
|
591 |
+
curl_setopt($cURL, CURLOPT_URL, $this->getURL());
|
592 |
+
curl_setopt($cURL, CURLOPT_USERAGENT, $szUserAgent);
|
593 |
+
curl_setopt($cURL, CURLOPT_POSTFIELDS, $this->getSOAPPacket());
|
594 |
+
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
|
595 |
+
curl_setopt($cURL, CURLOPT_ENCODING, "UTF-8");
|
596 |
+
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false);
|
597 |
+
|
598 |
+
if ($this->getTimeout() != null)
|
599 |
+
{
|
600 |
+
curl_setopt($cURL, CURLOPT_TIMEOUT, $this->getTimeout());
|
601 |
+
}
|
602 |
+
|
603 |
+
//$this->m_szLastResponse = curl_exec($cURL);
|
604 |
+
$szString = curl_exec($cURL);
|
605 |
+
$errorNo = curl_errno($cURL);//test
|
606 |
+
$errorMsg = curl_error($cURL);//test
|
607 |
+
$header = curl_getinfo($cURL);//test
|
608 |
+
curl_close($cURL);
|
609 |
+
|
610 |
+
$this->m_szLastResponse = $szString;
|
611 |
+
|
612 |
+
$szString = str_replace("<soap:", '<soap', $szString);
|
613 |
+
$szString = str_replace("</soap:", '</soap', $szString);
|
614 |
+
|
615 |
+
$XmlDoc = new SimpleXMLElement($szString);
|
616 |
+
$ResponseDocument = $XmlDoc->soapBody;
|
617 |
+
$ResponseMethod = $this->getMethod(). 'Response';
|
618 |
+
|
619 |
+
$boReturnValue = true;
|
620 |
+
}
|
621 |
+
catch (Exception $exc)
|
622 |
+
{
|
623 |
+
$boReturnValue = false;
|
624 |
+
$m_eLastException = $exc;
|
625 |
+
}
|
626 |
+
|
627 |
+
return $boReturnValue;
|
628 |
+
}
|
629 |
+
|
630 |
+
public function addParam1($szName, $szValue, CSV_SOAPParamAttributeList $lspaSOAPParamAttributeList = null)
|
631 |
+
{
|
632 |
+
$spSOAPParam;
|
633 |
+
|
634 |
+
$spSOAPParam = new CSV_SOAPParameter($szName, $szValue, $lspaSOAPParamAttributeList);
|
635 |
+
|
636 |
+
$this->addParam2($spSOAPParam, true);
|
637 |
+
}
|
638 |
+
public function addParam2(CSV_SOAPParameter $spSOAPParam, $boOverWriteValue)
|
639 |
+
{
|
640 |
+
$lszHierarchicalNames;
|
641 |
+
$nCurrentIndex = 0;
|
642 |
+
$szTagNameToFind;
|
643 |
+
$szString;
|
644 |
+
$nCount = 0;
|
645 |
+
$nCount2 = 0;
|
646 |
+
$lspParamList;
|
647 |
+
$spWorkingSOAPParam;
|
648 |
+
$spNewSOAPParam;
|
649 |
+
$boFound = false;
|
650 |
+
$lspaAttributeList;
|
651 |
+
$spaAttribute;
|
652 |
+
$spaNewAttribute;
|
653 |
+
$spaSOAPParamAttributeList;
|
654 |
+
|
655 |
+
// need to check the name of the incoming item to see if it is a
|
656 |
+
// complex soap parameter
|
657 |
+
$lszHierarchicalNames = new CSV_StringList();
|
658 |
+
|
659 |
+
$lszHierarchicalNames = CSV_SharedFunctions::getStringListFromCharSeparatedString($spSOAPParam->getName(), '.');
|
660 |
+
|
661 |
+
if ($lszHierarchicalNames->getCount() == 1)
|
662 |
+
{
|
663 |
+
$this->m_lspSOAPParamList->add($spSOAPParam);
|
664 |
+
}
|
665 |
+
else
|
666 |
+
{
|
667 |
+
$lspParamList = $this->m_lspSOAPParamList;
|
668 |
+
|
669 |
+
//complex
|
670 |
+
for ($nCount = 0; $nCount < $lszHierarchicalNames->getCount(); $nCount++)
|
671 |
+
{
|
672 |
+
// get the current tag name
|
673 |
+
$szString = (string)$lszHierarchicalNames->getAt($nCount);
|
674 |
+
//continuework
|
675 |
+
$szTagNameToFind = CSV_SharedFunctions::getArrayNameAndIndex($szString, $nCurrentIndex);
|
676 |
+
|
677 |
+
// first thing is to try to find the tag in the list
|
678 |
+
if ($boFound ||
|
679 |
+
$nCount == 0)
|
680 |
+
{
|
681 |
+
// try to find this tag name in the list
|
682 |
+
$spWorkingSOAPParam = CSV_Functions::isSOAPParamInParamList($lspParamList, $szTagNameToFind, $nCurrentIndex);
|
683 |
+
|
684 |
+
if ($spWorkingSOAPParam == null)
|
685 |
+
{
|
686 |
+
$boFound = false;
|
687 |
+
}
|
688 |
+
else
|
689 |
+
{
|
690 |
+
$boFound = true;
|
691 |
+
|
692 |
+
// is this the last item in the hierarchy?
|
693 |
+
if ($nCount == ($lszHierarchicalNames->getCount() - 1))
|
694 |
+
{
|
695 |
+
if ($boOverWriteValue)
|
696 |
+
{
|
697 |
+
// change the value
|
698 |
+
$spWorkingSOAPParam->setValue($spSOAPParam->getValue());
|
699 |
+
}
|
700 |
+
|
701 |
+
// add the attributes to the list
|
702 |
+
for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++)
|
703 |
+
{
|
704 |
+
//$spaAttribute = $spaSOAPParamAttributeList[$nCount2];
|
705 |
+
$spaAttribute = $spSOAPParam->getSOAPParamAttributeList()->getAt($nCount2);
|
706 |
+
|
707 |
+
if ($spaAttribute != null)
|
708 |
+
{
|
709 |
+
$spaNewAttribute = new CSV_SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue());
|
710 |
+
|
711 |
+
$spWorkingSOAPParam->getSOAPParamAttributeList()->add($spaNewAttribute);
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
$lspParamList = $spWorkingSOAPParam->getSOAPParamList();
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
if (!$boFound)
|
720 |
+
{
|
721 |
+
// is this the last tag?
|
722 |
+
if ($nCount == ($lszHierarchicalNames->getCount() - 1))
|
723 |
+
{
|
724 |
+
$lspaAttributeList = new CSV_SOAPParamAttributeList();
|
725 |
+
|
726 |
+
for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++)
|
727 |
+
{
|
728 |
+
$spaSOAPParamAttributeList = $spSOAPParam->getSOAPParamAttributeList();
|
729 |
+
|
730 |
+
$spaAttribute = $spaSOAPParamAttributeList->getAt( $nCount2);
|
731 |
+
|
732 |
+
if ($spaAttribute != null)
|
733 |
+
{
|
734 |
+
$spaNewAttribute = new CSV_SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue());
|
735 |
+
$lspaAttributeList->add($spaNewAttribute);
|
736 |
+
}
|
737 |
+
}
|
738 |
+
|
739 |
+
$spNewSOAPParam = new CSV_SOAPParameter($szTagNameToFind, $spSOAPParam->getValue(), $lspaAttributeList);
|
740 |
+
|
741 |
+
$lspParamList->add($spNewSOAPParam);
|
742 |
+
}
|
743 |
+
else
|
744 |
+
{
|
745 |
+
$spNewSOAPParam = new CSV_SOAPParameter($szTagNameToFind, '', null);
|
746 |
+
$lspParamList->add($spNewSOAPParam);
|
747 |
+
$lspParamList = $spNewSOAPParam->getSOAPParamList();
|
748 |
+
}
|
749 |
+
}
|
750 |
+
}
|
751 |
+
}
|
752 |
+
|
753 |
+
$this->m_boPacketBuilt = false;
|
754 |
+
}
|
755 |
+
|
756 |
+
//overloading for addParam
|
757 |
+
public function addParam()
|
758 |
+
{
|
759 |
+
//number of parameters passed into addParam()
|
760 |
+
$num_args = func_num_args();
|
761 |
+
//array of parameters passed into addParam()
|
762 |
+
$args = func_get_args();
|
763 |
+
|
764 |
+
switch ($num_args)
|
765 |
+
{
|
766 |
+
case 2:
|
767 |
+
if (is_string($args[0]) &&
|
768 |
+
is_string($args[1]))
|
769 |
+
{
|
770 |
+
//$this->__call('addParam1',$args);
|
771 |
+
//$this->addParam1($args[0], $args[1], $args[3]);
|
772 |
+
$this->addParam1($args[0], $args[1], null);
|
773 |
+
}
|
774 |
+
elseif ($args[0] instanceof CSV_SOAPParameter &&
|
775 |
+
is_bool($args[1]))
|
776 |
+
{
|
777 |
+
//$this->__call('addParam2', $args);
|
778 |
+
$this->addParam2($args[0], $args[1]);
|
779 |
+
}
|
780 |
+
else
|
781 |
+
{
|
782 |
+
throw new Exception('Invalid parameter list for function: addParam');
|
783 |
+
}
|
784 |
+
break;
|
785 |
+
case 3:
|
786 |
+
//$this->__call('addParam1', $args);
|
787 |
+
$this->addParam1($args[0], $args[1], $args[2]);
|
788 |
+
break;
|
789 |
+
default:
|
790 |
+
throw new Exception('Invalid number of parameters for function Add');
|
791 |
+
}
|
792 |
+
}
|
793 |
+
|
794 |
+
private function addParamAttribute1($szName, $szParamAttributeName, $szParamAttributeValue)
|
795 |
+
{
|
796 |
+
$spSOAPParam;
|
797 |
+
$lspaSOAPParamAttributeList;
|
798 |
+
$spaSOAPParamAttribute;
|
799 |
+
|
800 |
+
if (!is_string($szName) ||
|
801 |
+
!is_string($szParamAttributeName) ||
|
802 |
+
!is_string($szParamAttributeValue))
|
803 |
+
{
|
804 |
+
throw new Exception('Invalid parameter type');
|
805 |
+
}
|
806 |
+
|
807 |
+
$lspaSOAPParamAttributeList = new CSV_SOAPParamAttributeList();
|
808 |
+
$spaSOAPParamAttribute = new CSV_SOAPParamAttribute($szParamAttributeName, $szParamAttributeValue);
|
809 |
+
$lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
|
810 |
+
|
811 |
+
$spSOAPParam = new CSV_SOAPParameter($szName, '', $lspaSOAPParamAttributeList);
|
812 |
+
|
813 |
+
$this->addParam2($spSOAPParam, false);
|
814 |
+
}
|
815 |
+
private function addParamAttribute2($szName, CSV_SOAPParamAttribute $spaSOAPParamAttribute)
|
816 |
+
{
|
817 |
+
$spSOAPParam;
|
818 |
+
$lspaSOAPParamAttributeList;
|
819 |
+
|
820 |
+
$lspaSOAPParamAttributeList = new CSV_SOAPParamAttributeList();
|
821 |
+
$lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
|
822 |
+
|
823 |
+
$spSOAPParam = new CSV_SOAPParameter($szName, '', $lspaSOAPParamAttributeList);
|
824 |
+
|
825 |
+
$this->addParam2($spSOAPParam, false);
|
826 |
+
}
|
827 |
+
|
828 |
+
//overloading for addParamAttribute
|
829 |
+
public function addParamAttribute()
|
830 |
+
{
|
831 |
+
$num_args = func_num_args();
|
832 |
+
$args = func_get_args();
|
833 |
+
|
834 |
+
switch ($num_args)
|
835 |
+
{
|
836 |
+
case 2:
|
837 |
+
//$this->__call('addParamAttribute2', $args);
|
838 |
+
$this->addParamAttribute2($args[0], $args[1]);
|
839 |
+
break;
|
840 |
+
case 3:
|
841 |
+
//$this->__call('addParamAttribute1', $args);
|
842 |
+
$this->addParamAttribute1($args[0], $args[1], $args[2]);
|
843 |
+
break;
|
844 |
+
default:
|
845 |
+
throw new Exception('Invalid number of parameters for fucntion Add');
|
846 |
+
}
|
847 |
+
}
|
848 |
+
|
849 |
+
//overloading constructor
|
850 |
+
private function SOAP1($szMethod, $szMethodURI)
|
851 |
+
{
|
852 |
+
$this->SOAP3($szMethod, $szMethodURI, null, 'http://schemas.xmlsoap.org/soap/encoding/', true, null);
|
853 |
+
}
|
854 |
+
private function SOAP2($szMethod, $szMethodURI, $szURL)
|
855 |
+
{
|
856 |
+
$this->SOAP3($szMethod, $szMethodURI, $szURL, 'http://schemas.xmlsoap.org/soap/encoding/', true, null);
|
857 |
+
}
|
858 |
+
private function SOAP3($szMethod, $szMethodURI, $szURL, $szSOAPEncoding, $boAddDefaultNamespaces, CSV_SOAPNamespaceList $lsnSOAPNamespaceList = null)
|
859 |
+
{
|
860 |
+
$snSOAPNamespace;
|
861 |
+
$nCount = 0;
|
862 |
+
|
863 |
+
$this->m_szMethod = $szMethod;
|
864 |
+
$this->m_szMethodURI = $szMethodURI;
|
865 |
+
$this->m_szURL = $szURL;
|
866 |
+
$this->m_szSOAPEncoding = $szSOAPEncoding;
|
867 |
+
|
868 |
+
if ($this->m_szMethodURI != "" &&
|
869 |
+
$this->m_szMethod != "")
|
870 |
+
{
|
871 |
+
if ($this->m_szMethodURI[(strlen($this->m_szMethodURI) - 1)] == '/')
|
872 |
+
{
|
873 |
+
$this->m_szActionURI = $this->m_szMethodURI . $this->m_szMethod;
|
874 |
+
}
|
875 |
+
else
|
876 |
+
{
|
877 |
+
$this->m_szActionURI = $this->m_szMethodURI . '/' . $this->m_szMethod;
|
878 |
+
}
|
879 |
+
}
|
880 |
+
|
881 |
+
$this->m_lsnSOAPNamespaceList = new CSV_SOAPNamespaceList();
|
882 |
+
|
883 |
+
if ($boAddDefaultNamespaces)
|
884 |
+
{
|
885 |
+
$snSOAPNamespace = new CSV_SOAPNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
|
886 |
+
$this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
|
887 |
+
$snSOAPNamespace = new CSV_SOAPNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
888 |
+
$this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
|
889 |
+
$snSOAPNamespace = new CSV_SOAPNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
|
890 |
+
$this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
|
891 |
+
}
|
892 |
+
if ($lsnSOAPNamespaceList != null)
|
893 |
+
{
|
894 |
+
for ($nCount = 0; $nCount < count($lsnSOAPNamespaceList); $nCount++)
|
895 |
+
{
|
896 |
+
$snSOAPNamespace = new CSV_SOAPNamespace($lsnSOAPNamespaceList->getAt($nCount)->getPrefix(), $lsnSOAPNamespaceList->getAt($nCount)->getNamespace());
|
897 |
+
$this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
|
898 |
+
}
|
899 |
+
}
|
900 |
+
$this->m_lspSOAPParamList = new CSV_SOAPParamList();
|
901 |
+
|
902 |
+
$this->m_boPacketBuilt = false;
|
903 |
+
}
|
904 |
+
|
905 |
+
//constructor
|
906 |
+
public function __construct()
|
907 |
+
{
|
908 |
+
$num_args = func_num_args();
|
909 |
+
$args = func_get_args();
|
910 |
+
|
911 |
+
switch ($num_args)
|
912 |
+
{
|
913 |
+
case 2:
|
914 |
+
//$this->__call('SOAP1', $args);
|
915 |
+
$this->SOAP1($args[0], $args[1]);
|
916 |
+
break;
|
917 |
+
case 3:
|
918 |
+
//$this->__call('SOAP2', $args);
|
919 |
+
$this->SOAP2($args[0], $args[1], $args[2]);
|
920 |
+
break;
|
921 |
+
case 6:
|
922 |
+
//$this->__call('SOAP3', $args);
|
923 |
+
$this->SOAP3($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
|
924 |
+
default:
|
925 |
+
throw new Exception('Invalid number of parameters for constructor SOAP');
|
926 |
+
}
|
927 |
+
}
|
928 |
+
}
|
929 |
+
|
930 |
+
class CSV_Functions
|
931 |
+
{
|
932 |
+
public static function isSOAPParamInParamList(CSV_SOAPParamList $lspParamList, $szTagNameToFind, $nIndex)
|
933 |
+
{
|
934 |
+
$spReturnParam = null;
|
935 |
+
$boFound = false;
|
936 |
+
$nFound = 0;
|
937 |
+
$nCount = 0;
|
938 |
+
$spCurrentParam = null;
|
939 |
+
|
940 |
+
if ($lspParamList == null)
|
941 |
+
{
|
942 |
+
return (null);
|
943 |
+
}
|
944 |
+
|
945 |
+
while(!$boFound &&
|
946 |
+
$nCount < $lspParamList->getCount())
|
947 |
+
{
|
948 |
+
$spCurrentParam = $lspParamList->getAt($nCount);
|
949 |
+
|
950 |
+
if ($spCurrentParam->getName() == $szTagNameToFind)
|
951 |
+
{
|
952 |
+
if ($nFound == $nIndex)
|
953 |
+
{
|
954 |
+
$boFound = true;
|
955 |
+
$spReturnParam = $spCurrentParam;
|
956 |
+
}
|
957 |
+
else
|
958 |
+
{
|
959 |
+
$nFound++;
|
960 |
+
}
|
961 |
+
}
|
962 |
+
|
963 |
+
$nCount++;
|
964 |
+
}
|
965 |
+
|
966 |
+
return $spReturnParam;
|
967 |
+
}
|
968 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/ThePaymentGateway/TPG_Common.php
ADDED
@@ -0,0 +1,882 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//XMLEntities
|
3 |
+
$g_XMLEntities = array();
|
4 |
+
$g_XMLEntities[] = new CSV_XMLEntity(0x26, "&");
|
5 |
+
$g_XMLEntities[] = new CSV_XMLEntity(0x22, """);
|
6 |
+
$g_XMLEntities[] = new CSV_XMLEntity(0x27, "'");
|
7 |
+
$g_XMLEntities[] = new CSV_XMLEntity(0x3c, "<");
|
8 |
+
$g_XMLEntities[] = new CSV_XMLEntity(0x3e, ">");
|
9 |
+
|
10 |
+
abstract class CSV_Nullable
|
11 |
+
{
|
12 |
+
protected $m_boHasValue;
|
13 |
+
|
14 |
+
function getHasValue()
|
15 |
+
{
|
16 |
+
return $this->m_boHasValue;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
$this->m_boHasValue = false;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
class CSV_NullableInt extends CSV_Nullable
|
26 |
+
{
|
27 |
+
private $m_nValue;
|
28 |
+
|
29 |
+
function getValue()
|
30 |
+
{
|
31 |
+
if ($this->m_boHasValue == false)
|
32 |
+
{
|
33 |
+
throw new Exception('Object has no value');
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->m_nValue;
|
37 |
+
}
|
38 |
+
function setValue($value)
|
39 |
+
{
|
40 |
+
$this->m_boHasValue = true;
|
41 |
+
$this->m_nValue = $value;
|
42 |
+
}
|
43 |
+
|
44 |
+
//constructor
|
45 |
+
public function __construct($nValue)
|
46 |
+
{
|
47 |
+
CSV_Nullable::__construct();
|
48 |
+
|
49 |
+
$this->setValue($nValue);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
class CSV_NullableBool extends CSV_Nullable
|
54 |
+
{
|
55 |
+
private $m_boValue;
|
56 |
+
|
57 |
+
public function getValue()
|
58 |
+
{
|
59 |
+
if ($this->m_boHasValue == false)
|
60 |
+
{
|
61 |
+
throw new Exception("Object has no value");
|
62 |
+
}
|
63 |
+
|
64 |
+
return ($this->m_boValue);
|
65 |
+
}
|
66 |
+
public function setValue($value)
|
67 |
+
{
|
68 |
+
$this->m_boHasValue = true;
|
69 |
+
$this->m_boValue = $value;
|
70 |
+
}
|
71 |
+
|
72 |
+
//constructor
|
73 |
+
public function __construct($boValue)
|
74 |
+
{
|
75 |
+
CSV_Nullable::__construct();
|
76 |
+
|
77 |
+
$this->setValue($boValue);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
/******************/
|
82 |
+
/* Common classes */
|
83 |
+
/******************/
|
84 |
+
class CSV_StringList
|
85 |
+
{
|
86 |
+
private $m_lszStrings;
|
87 |
+
|
88 |
+
public function getAt($nIndex)
|
89 |
+
{
|
90 |
+
if ($nIndex < 0 ||
|
91 |
+
$nIndex >= count($this->m_lszStrings))
|
92 |
+
{
|
93 |
+
throw new Exception('Array index out of bounds');
|
94 |
+
}
|
95 |
+
|
96 |
+
return (string)($this->m_lszStrings[$nIndex]);
|
97 |
+
}
|
98 |
+
|
99 |
+
function getCount()
|
100 |
+
{
|
101 |
+
return count($this->m_lszStrings);
|
102 |
+
}
|
103 |
+
|
104 |
+
function add($szString)
|
105 |
+
{
|
106 |
+
if (!is_string($szString))
|
107 |
+
{
|
108 |
+
throw new Exception('Invalid parameter type');
|
109 |
+
}
|
110 |
+
|
111 |
+
return ($this->m_lszStrings[] = $szString);
|
112 |
+
}
|
113 |
+
|
114 |
+
//constructor
|
115 |
+
function __construct()
|
116 |
+
{
|
117 |
+
$this->m_lszStrings = array();
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
class CSV_ISOCountry
|
122 |
+
{
|
123 |
+
private $m_szCountryName;
|
124 |
+
private $m_szCountryShort;
|
125 |
+
private $m_nISOCode;
|
126 |
+
private $m_nListPriority;
|
127 |
+
|
128 |
+
//public properties
|
129 |
+
public function getCountryName()
|
130 |
+
{
|
131 |
+
return $this->m_szCountryName;
|
132 |
+
}
|
133 |
+
public function getCountryShort()
|
134 |
+
{
|
135 |
+
return $this->m_szCountryShort;
|
136 |
+
}
|
137 |
+
public function getISOCode()
|
138 |
+
{
|
139 |
+
return $this->m_nISOCode;
|
140 |
+
}
|
141 |
+
public function getListPriority()
|
142 |
+
{
|
143 |
+
return $this->m_nListPriority;
|
144 |
+
}
|
145 |
+
|
146 |
+
//constructor
|
147 |
+
public function __construct($nISOCode, $szCountryName, $szCountryShort, $nListPriority)
|
148 |
+
{
|
149 |
+
if (!is_int($nISOCode) ||
|
150 |
+
!is_string($szCountryName) ||
|
151 |
+
!is_string($szCountryShort) ||
|
152 |
+
!is_int($nListPriority))
|
153 |
+
{
|
154 |
+
throw new Exception('Invalid parameter type');
|
155 |
+
}
|
156 |
+
|
157 |
+
$this->m_nISOCode = $nISOCode;
|
158 |
+
$this->m_szCountryName = $szCountryName;
|
159 |
+
$this->m_szCountryShort = $szCountryShort;
|
160 |
+
$this->m_nListPriority = $nListPriority;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
class CSV_ISOCountryList
|
165 |
+
{
|
166 |
+
private $m_licISOCountries;
|
167 |
+
|
168 |
+
public function getISOCountry($szCountryShort, CSV_ISOCountry &$icISOCountry = null)
|
169 |
+
{
|
170 |
+
$boFound = false;
|
171 |
+
$nCount = 0;
|
172 |
+
$icISOCountry2;
|
173 |
+
|
174 |
+
$icISOCountry = null;
|
175 |
+
|
176 |
+
while(!$boFound &&
|
177 |
+
$nCount < count($this->m_licISOCountries))
|
178 |
+
{
|
179 |
+
$icISOCountry2 = $this->m_licISOCountries[$nCount];
|
180 |
+
|
181 |
+
if ($szCountryShort == $icISOCountry2->getCountryShort())
|
182 |
+
{
|
183 |
+
$icISOCountry = new CSV_ISOCountry($icISOCountry2->getISOCode(), $icISOCountry2->getCountryName(), $icISOCountry2->getCountryShort(), $icISOCountry2->getListPriority());
|
184 |
+
$boFound = true;
|
185 |
+
}
|
186 |
+
|
187 |
+
$nCount++;
|
188 |
+
}
|
189 |
+
|
190 |
+
return $boFound;
|
191 |
+
}
|
192 |
+
|
193 |
+
public function getCount()
|
194 |
+
{
|
195 |
+
return count($this->m_licISOCountries);
|
196 |
+
}
|
197 |
+
|
198 |
+
public function getAt($nIndex)
|
199 |
+
{
|
200 |
+
if ($nIndex < 0 ||
|
201 |
+
$nIndex >= count($this->m_licISOCountries))
|
202 |
+
{
|
203 |
+
throw new Exception('Array index out of bounds');
|
204 |
+
}
|
205 |
+
|
206 |
+
return $this->m_licISOCountries[$nIndex];
|
207 |
+
}
|
208 |
+
|
209 |
+
public function add($nISOCode, $szCountryName, $szCountryShort, $nListPriority)
|
210 |
+
{
|
211 |
+
$newISOCountry = new CSV_ISOCountry($nISOCode, $szCountryName, $szCountryShort, $nListPriority);
|
212 |
+
|
213 |
+
$this->m_licISOCountries[] = $newISOCountry;
|
214 |
+
}
|
215 |
+
|
216 |
+
//constructor
|
217 |
+
public function __construct()
|
218 |
+
{
|
219 |
+
$this->m_licISOCountries = array();
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
class CSV_ISOCurrency
|
224 |
+
{
|
225 |
+
private $m_nExponent;
|
226 |
+
private $m_nISOCode;
|
227 |
+
private $m_szCurrency;
|
228 |
+
private $m_szCurrencyShort;
|
229 |
+
|
230 |
+
//public properties
|
231 |
+
public function getExponent()
|
232 |
+
{
|
233 |
+
return $this->m_nExponent;
|
234 |
+
}
|
235 |
+
|
236 |
+
public function getCurrency()
|
237 |
+
{
|
238 |
+
return $this->m_szCurrency;
|
239 |
+
}
|
240 |
+
|
241 |
+
public function getCurrencyShort()
|
242 |
+
{
|
243 |
+
return $this->m_szCurrencyShort;
|
244 |
+
}
|
245 |
+
|
246 |
+
public function getISOCode()
|
247 |
+
{
|
248 |
+
return $this->m_nISOCode;
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
+
public function getAmountCurrencyString($nAmount, $boAppendCurrencyShort = true)
|
253 |
+
{
|
254 |
+
$szReturnString = "";
|
255 |
+
|
256 |
+
$nDivideAmount = pow(10, $this->m_nExponent);
|
257 |
+
$lfAmount = $nAmount / $nDivideAmount;
|
258 |
+
|
259 |
+
$szFormatString = "%.".$this->m_nExponent."f";
|
260 |
+
$szReturnString = sprintf($szFormatString, $lfAmount);
|
261 |
+
|
262 |
+
if ($boAppendCurrencyShort)
|
263 |
+
{
|
264 |
+
$szReturnString = $szReturnString." ".$this->m_szCurrencyShort;
|
265 |
+
}
|
266 |
+
|
267 |
+
return ($szReturnString);
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
//constructor
|
272 |
+
public function __construct($nISOCode, $szCurrency, $szCurrencyShort, $nExponent)
|
273 |
+
{
|
274 |
+
$this->m_nISOCode = $nISOCode;
|
275 |
+
$this->m_nExponent = $nExponent;
|
276 |
+
$this->m_szCurrency = $szCurrency;
|
277 |
+
$this->m_szCurrencyShort = $szCurrencyShort;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
class CSV_ISOCurrencyList
|
282 |
+
{
|
283 |
+
private $m_licISOCurrencies;
|
284 |
+
|
285 |
+
public function getISOCurrency($szCurrencyShort, CSV_ISOCurrency &$icISOCurrency = null)
|
286 |
+
{
|
287 |
+
$boFound = false;
|
288 |
+
$nCount = 0;
|
289 |
+
$icISOCurrency2;
|
290 |
+
|
291 |
+
$icISOCurrency = null;
|
292 |
+
|
293 |
+
while (!$boFound &&
|
294 |
+
$nCount < count($this->m_licISOCurrencies))
|
295 |
+
{
|
296 |
+
$icISOCurrency2 = $this->m_licISOCurrencies[$nCount];
|
297 |
+
|
298 |
+
if ($szCurrencyShort == $icISOCurrency2->getCurrencyShort())
|
299 |
+
{
|
300 |
+
$icISOCurrency = new CSV_ISOCurrency($icISOCurrency2->getISOCode(), $icISOCurrency2->getCurrency(),$icISOCurrency2->getCurrencyShort(), $icISOCurrency2->getExponent());
|
301 |
+
$boFound = true;
|
302 |
+
}
|
303 |
+
|
304 |
+
$nCount++;
|
305 |
+
}
|
306 |
+
|
307 |
+
return ($boFound);
|
308 |
+
}
|
309 |
+
|
310 |
+
public function getCount()
|
311 |
+
{
|
312 |
+
return count($this->m_licISOCurrencies);
|
313 |
+
}
|
314 |
+
|
315 |
+
public function getAt($nIndex)
|
316 |
+
{
|
317 |
+
if ($nIndex < 0 ||
|
318 |
+
$nIndex >= count($this->m_licISOCurrencies))
|
319 |
+
{
|
320 |
+
throw new Exception('Array index out of bounds');
|
321 |
+
}
|
322 |
+
|
323 |
+
return $this->m_licISOCurrencies[$nIndex];
|
324 |
+
}
|
325 |
+
|
326 |
+
public function add($nISOCode, $szCurrency, $szCurrencyShort, $nExponent)
|
327 |
+
{
|
328 |
+
$newISOCurrency = new CSV_ISOCurrency($nISOCode, $szCurrency, $szCurrencyShort, $nExponent);
|
329 |
+
|
330 |
+
$this->m_licISOCurrencies[] = $newISOCurrency;
|
331 |
+
}
|
332 |
+
|
333 |
+
//constructor
|
334 |
+
public function __construct()
|
335 |
+
{
|
336 |
+
$this->m_licISOCurrencies = array();
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
class CSV_XMLEntity
|
341 |
+
{
|
342 |
+
private $m_bCharCode;
|
343 |
+
private $m_szReplacement;
|
344 |
+
|
345 |
+
public function getCharCode()
|
346 |
+
{
|
347 |
+
return $this->m_bCharCode;
|
348 |
+
}
|
349 |
+
public function getReplacement()
|
350 |
+
{
|
351 |
+
return $this->m_szReplacement;
|
352 |
+
}
|
353 |
+
|
354 |
+
//constructor
|
355 |
+
public function __construct($bCharCode, $szReplacement)
|
356 |
+
{
|
357 |
+
$this->m_bCharCode = $bCharCode;
|
358 |
+
$this->m_szReplacement = $szReplacement;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
class CSV_SharedFunctions
|
363 |
+
{
|
364 |
+
public static function getNamedTagInTagList($szName, $xtlTagList)
|
365 |
+
{
|
366 |
+
$lszHierarchicalNames = null;
|
367 |
+
$nCount = 0;
|
368 |
+
$boAbort = false;
|
369 |
+
$boFound = false;
|
370 |
+
$boLastNode = false;
|
371 |
+
$szString;
|
372 |
+
$szTagNameToFind;
|
373 |
+
$nCurrentIndex = 0;
|
374 |
+
$xtReturnTag = null;
|
375 |
+
$xtCurrentTag = null;
|
376 |
+
$nTagCount = 0;
|
377 |
+
$xtlCurrentTagList = null;
|
378 |
+
$nCount2 = 0;
|
379 |
+
|
380 |
+
if (is_null($xtlTagList))
|
381 |
+
{
|
382 |
+
return null;
|
383 |
+
}
|
384 |
+
|
385 |
+
if (count($xtlTagList) == 0)
|
386 |
+
{
|
387 |
+
return null;
|
388 |
+
}
|
389 |
+
|
390 |
+
$lszHierarchicalNames = new CSV_StringList();
|
391 |
+
|
392 |
+
$lszHierarchicalNames = CSV_SharedFunctions::getStringListFromCharSeparatedString($szName, '.');
|
393 |
+
|
394 |
+
$xtlCurrentTagList = $xtlTagList;
|
395 |
+
|
396 |
+
// loop over the hierarchical list
|
397 |
+
for ($nCount = 0; $nCount <$lszHierarchicalNames->getCount() && !$boAbort; $nCount++)
|
398 |
+
{
|
399 |
+
if ($nCount == ($lszHierarchicalNames->getCount() - 1))
|
400 |
+
{
|
401 |
+
$boLastNode = true;
|
402 |
+
}
|
403 |
+
|
404 |
+
$szString = (string)$lszHierarchicalNames[$nCount];
|
405 |
+
|
406 |
+
// look to see if this tag name has the special "[]" array chars
|
407 |
+
$szTagNameToFind = CSV_SharedFunctions::getArrayNameAndIndex(szString, $nCurrentIndex);
|
408 |
+
$nCurrentIndex = $nIndex;
|
409 |
+
|
410 |
+
$boFound = false;
|
411 |
+
$nCount2 = 0;
|
412 |
+
|
413 |
+
for ($nTagCount = 0; $nTagCount < $xtlCurrentTagList->getCount() && !$boFound; $nTagCount++)
|
414 |
+
{
|
415 |
+
$xtCurrentTag = $xtlCurrentTagList->getXmlTagForIndex($nTagCount);
|
416 |
+
|
417 |
+
// if this is the last node then check the attributes of the tag first
|
418 |
+
|
419 |
+
if ($xtCurrentTag->getName() == $szTagNameToFind)
|
420 |
+
{
|
421 |
+
if ($nCount2 == $nCurrentIndex)
|
422 |
+
{
|
423 |
+
$boFound = true;
|
424 |
+
}
|
425 |
+
else
|
426 |
+
{
|
427 |
+
$nCount2++;
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
if ($boFound)
|
432 |
+
{
|
433 |
+
if (!$boLastNode)
|
434 |
+
{
|
435 |
+
$xtlCurrentTagList = $xtCurrentTag->getChildTags();
|
436 |
+
}
|
437 |
+
else
|
438 |
+
{
|
439 |
+
// don't continue the search
|
440 |
+
$xtReturnTag = $xtCurrentTag;
|
441 |
+
}
|
442 |
+
}
|
443 |
+
}
|
444 |
+
|
445 |
+
if (!$boFound)
|
446 |
+
{
|
447 |
+
$boAbort = true;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
return $xtReturnTag;
|
452 |
+
}
|
453 |
+
|
454 |
+
public static function getStringListFromCharSeparatedString($szString, $cDelimiter)
|
455 |
+
{
|
456 |
+
$nCount = 0;
|
457 |
+
$nLastCount = -1;
|
458 |
+
$szSubString;
|
459 |
+
$nStringLength;
|
460 |
+
$lszStringList;
|
461 |
+
|
462 |
+
if ($szString == null ||
|
463 |
+
$szString == "" ||
|
464 |
+
(string)$cDelimiter == "")
|
465 |
+
{
|
466 |
+
return null;
|
467 |
+
}
|
468 |
+
|
469 |
+
$lszStringList = new CSV_StringList();
|
470 |
+
|
471 |
+
$nStringLength = strlen($szString);
|
472 |
+
|
473 |
+
for ($nCount = 0; $nCount < $nStringLength; $nCount++)
|
474 |
+
{
|
475 |
+
if ($szString[$nCount] == $cDelimiter)
|
476 |
+
{
|
477 |
+
$szSubString = substr($szString, ($nLastCount + 1), ($nCount - $nLastCount - 1));
|
478 |
+
$nLastCount = $nCount;
|
479 |
+
$lszStringList->add($szSubString);
|
480 |
+
|
481 |
+
if ($nCount == $nStringLength)
|
482 |
+
{
|
483 |
+
$lszStringList->add('');
|
484 |
+
}
|
485 |
+
}
|
486 |
+
else
|
487 |
+
{
|
488 |
+
if ($nCount == ($nStringLength - 1))
|
489 |
+
{
|
490 |
+
$szSubString = substr($szString, ($nLastCount + 1), ($nCount - $nLastCount));
|
491 |
+
$lszStringList->add($szSubString);
|
492 |
+
}
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
return $lszStringList;
|
497 |
+
}
|
498 |
+
|
499 |
+
public static function getValue($szXMLVariable, $xtlTagList, & $szValue)
|
500 |
+
{
|
501 |
+
$boReturnValue = false;
|
502 |
+
$lszHierarchicalNames;
|
503 |
+
$szXMLTagName;
|
504 |
+
$szLastXMLTagName;
|
505 |
+
$nCount = 0;
|
506 |
+
$xtCurrentTag = null;
|
507 |
+
$xaXmlAttribute = null;
|
508 |
+
$lXmlTagAttributeList;
|
509 |
+
|
510 |
+
if (xtlTagList == null)
|
511 |
+
{
|
512 |
+
$szValue = null;
|
513 |
+
return (false);
|
514 |
+
}
|
515 |
+
|
516 |
+
$lszHierarchicalNames = new CSV_StringList();
|
517 |
+
$szValue = null;
|
518 |
+
$lszHierarchicalNames = CSV_SharedFunctions::getStringListFromCharSeparatedString($szXMLVariable, '.');
|
519 |
+
|
520 |
+
if (count($lszHierarchicalNames) == 1)
|
521 |
+
{
|
522 |
+
$szXMLTagName = $lszHierarchicalNames->getAt(0);
|
523 |
+
|
524 |
+
$xtCurrentTag = CSV_SharedFunctions::GetNamedTagInTagList($szXMLTagName, $xtlTagList);
|
525 |
+
|
526 |
+
if ($xtCurrentTag != null)
|
527 |
+
{
|
528 |
+
$lXmlTagAttributeList = $xtCurrentTag->getAttributes();
|
529 |
+
$xaXmlAttribute = $lXmlTagAttributeList->getAt($szXMLTagName);
|
530 |
+
|
531 |
+
if ($xaXmlAttribute != null)
|
532 |
+
{
|
533 |
+
$szValue = $xaXmlAttribute->getValue();
|
534 |
+
$boReturnValue = true;
|
535 |
+
}
|
536 |
+
else
|
537 |
+
{
|
538 |
+
$szValue = $xtCurrentTag->getContent();
|
539 |
+
$boReturnValue = true;
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
+
else
|
544 |
+
{
|
545 |
+
if (count($lszHierarchicalNames) > 1)
|
546 |
+
{
|
547 |
+
$szXMLTagName = $lszHierarchicalNames->getAt(0);
|
548 |
+
$szLastXMLTagName = $lszHierarchicalNames->getAt(($lszHierarchicalNames->getCount() - 1));
|
549 |
+
|
550 |
+
// need to remove the last variable from the passed name
|
551 |
+
for ($nCount = 1; $nCount < ($lszHierarchicalNames->getCount() - 1); $nCount++)
|
552 |
+
{
|
553 |
+
$szXMLTagName .= "." . $lszHierarchicalNames->getAt($nCount);
|
554 |
+
}
|
555 |
+
|
556 |
+
$xtCurrentTag = CSV_SharedFunctions::getNamedTagInTagList($szXMLTagName, $xtlTagList);
|
557 |
+
|
558 |
+
// first check the attributes of this tag
|
559 |
+
if ($xtCurrentTag != null)
|
560 |
+
{
|
561 |
+
$lXmlTagAttributeList = $xtCurrentTag->getAttributes();
|
562 |
+
$xaXmlAttribute = $lXmlTagAttributeList->getXmlAttributeForAttributeName($szLastXMLTagName);
|
563 |
+
|
564 |
+
if ($xaXmlAttribute != null)
|
565 |
+
{
|
566 |
+
$szValue = $xaXmlAttribute->getValue();
|
567 |
+
$boReturnValue = true;
|
568 |
+
}
|
569 |
+
else
|
570 |
+
{
|
571 |
+
// check to see if it's actually a tag
|
572 |
+
$xtCurrentTag = CSV_SharedFunctions::getNamedTagInTagList($szLastXMLTagName, $xtCurrentTag->getChildTags());
|
573 |
+
|
574 |
+
if ($xtCurrentTag != null)
|
575 |
+
{
|
576 |
+
$szValue = CSV_SharedFunctions::replaceEntitiesInStringWithChars($xtCurrentTag->getContent());
|
577 |
+
$boReturnValue = true;
|
578 |
+
}
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
582 |
+
}
|
583 |
+
|
584 |
+
return $boReturnValue;
|
585 |
+
}
|
586 |
+
|
587 |
+
public static function getArrayNameAndIndex($szName, &$nIndex)
|
588 |
+
{
|
589 |
+
$szReturnString;
|
590 |
+
$nCount = 0;
|
591 |
+
$szSubString;
|
592 |
+
$boFound = false;
|
593 |
+
$boAbort = false;
|
594 |
+
$boAtLeastOneDigitFound = false;
|
595 |
+
|
596 |
+
if ($szName == '')
|
597 |
+
{
|
598 |
+
$nIndex = 0;
|
599 |
+
return $szName;
|
600 |
+
}
|
601 |
+
|
602 |
+
$szReturnString = $szName;
|
603 |
+
$nIndex = 0;
|
604 |
+
|
605 |
+
if ($szName[(strlen($szName) - 1)] == ']')
|
606 |
+
{
|
607 |
+
$nCount = strlen($szName) - 2;
|
608 |
+
|
609 |
+
while (!$boFound &&
|
610 |
+
!$boAbort &&
|
611 |
+
$nCount >= 0)
|
612 |
+
{
|
613 |
+
// if we've found the closing array brace
|
614 |
+
if ($szName[$nCount] == '[')
|
615 |
+
{
|
616 |
+
$boFound = true;
|
617 |
+
}
|
618 |
+
else
|
619 |
+
{
|
620 |
+
if (!is_numeric($szName[$nCount]))
|
621 |
+
{
|
622 |
+
$boAbort = true;
|
623 |
+
}
|
624 |
+
else
|
625 |
+
{
|
626 |
+
$boAtLeastOneDigitFound = true;
|
627 |
+
$nCount--;
|
628 |
+
}
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
// did we finish successfully?
|
633 |
+
if ($boFound &&
|
634 |
+
$boAtLeastOneDigitFound)
|
635 |
+
{
|
636 |
+
$szSubString = substr($szName, ($nCount + 1), (strlen($szName) - $nCount - 2));
|
637 |
+
$szReturnString = substr($szName, 0, $nCount);
|
638 |
+
$nIndex = (int)($szSubString);
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
return $szReturnString;
|
643 |
+
}
|
644 |
+
|
645 |
+
public static function stringToByteArray($str)
|
646 |
+
{
|
647 |
+
$encoded;
|
648 |
+
|
649 |
+
$encoded = utf8_encode($str);
|
650 |
+
|
651 |
+
return $encoded;
|
652 |
+
}
|
653 |
+
|
654 |
+
public static function byteArrayToString($aByte)
|
655 |
+
{
|
656 |
+
return utf8_decode($aByte);
|
657 |
+
}
|
658 |
+
|
659 |
+
public static function forwardPaddedNumberString($nNumber, $nPaddingAmount, $cPaddingChar)
|
660 |
+
{
|
661 |
+
$szReturnString;
|
662 |
+
$sbString;
|
663 |
+
$nCount = 0;
|
664 |
+
|
665 |
+
$szReturnString = (string)$nNumber;
|
666 |
+
|
667 |
+
if (strlen($szReturnString) < $nPaddingAmount &&
|
668 |
+
$nPaddingAmount > 0)
|
669 |
+
{
|
670 |
+
$sbString = '';
|
671 |
+
|
672 |
+
for ($nCount = 0; $nCount < ($nPaddingAmount - strlen($szReturnString)); $nCount++)
|
673 |
+
{
|
674 |
+
$sbString .= $cPaddingChar;
|
675 |
+
}
|
676 |
+
|
677 |
+
$sbString .= $szReturnString;
|
678 |
+
$szReturnString = (string)$sbString;
|
679 |
+
}
|
680 |
+
|
681 |
+
return $szReturnString;
|
682 |
+
}
|
683 |
+
|
684 |
+
public static function stripAllWhitespace($szString)
|
685 |
+
{
|
686 |
+
$sbReturnString;
|
687 |
+
$nCount = 0;
|
688 |
+
|
689 |
+
if ($szString == null)
|
690 |
+
{
|
691 |
+
return (null);
|
692 |
+
}
|
693 |
+
|
694 |
+
$sbReturnString = '';
|
695 |
+
|
696 |
+
for ($nCount = 0; $nCount < strlen($szString); $nCount++)
|
697 |
+
{
|
698 |
+
if ($szString[$nCount] != ' ' &&
|
699 |
+
$szString[$nCount] != '\t' &&
|
700 |
+
$szString[$nCount] != '\n' &&
|
701 |
+
$szString[$nCount] != '\r')
|
702 |
+
{
|
703 |
+
$sbReturnString .= $szString[$nCount];
|
704 |
+
}
|
705 |
+
}
|
706 |
+
|
707 |
+
return (string)$sbReturnString;
|
708 |
+
}
|
709 |
+
|
710 |
+
public static function getAmountCurrencyString($nAmount, $nExponent)
|
711 |
+
{
|
712 |
+
$szReturnString = "";
|
713 |
+
$lfAmount;
|
714 |
+
$nDivideAmount;
|
715 |
+
|
716 |
+
$nDivideAmount = (int)(pow(10, $nExponent));
|
717 |
+
$lfAmount = (double)($nAmount/$nDivideAmount);
|
718 |
+
$szReturnString = (string)$lfAmount;
|
719 |
+
|
720 |
+
return ($szReturnString);
|
721 |
+
}
|
722 |
+
|
723 |
+
public static function isStringNullOrEmpty($szString)
|
724 |
+
{
|
725 |
+
$boReturnValue = false;
|
726 |
+
|
727 |
+
if ($szString == null ||
|
728 |
+
$szString == '')
|
729 |
+
{
|
730 |
+
$boReturnValue = true;
|
731 |
+
}
|
732 |
+
|
733 |
+
return ($boReturnValue);
|
734 |
+
}
|
735 |
+
|
736 |
+
public static function replaceCharsInStringWithEntities($szString)
|
737 |
+
{
|
738 |
+
//give access to enum like associated array
|
739 |
+
global $g_XMLEntities;
|
740 |
+
|
741 |
+
$szReturnString;
|
742 |
+
$nCount;
|
743 |
+
$boFound;
|
744 |
+
$nHTMLEntityCount;
|
745 |
+
|
746 |
+
$szReturnString = null;
|
747 |
+
|
748 |
+
for ($nCount = 0; $nCount < strlen($szString); $nCount++)
|
749 |
+
{
|
750 |
+
$boFound = false;
|
751 |
+
$nHTMLEntityCount = 0;
|
752 |
+
|
753 |
+
while (!$boFound &&
|
754 |
+
$nHTMLEntityCount < count($g_XMLEntities))
|
755 |
+
{
|
756 |
+
//$test1 = htmlspecialchars('&');
|
757 |
+
|
758 |
+
if ($g_XMLEntities[$nHTMLEntityCount]->getReplacement() == htmlspecialchars($szString[$nCount]))
|
759 |
+
{
|
760 |
+
$boFound = true;
|
761 |
+
}
|
762 |
+
else
|
763 |
+
{
|
764 |
+
$nHTMLEntityCount++;
|
765 |
+
}
|
766 |
+
}
|
767 |
+
|
768 |
+
if ($boFound)
|
769 |
+
{
|
770 |
+
$szReturnString .= $g_XMLEntities[$nHTMLEntityCount]->getReplacement();
|
771 |
+
}
|
772 |
+
else
|
773 |
+
{
|
774 |
+
$szReturnString .= $szString[$nCount];
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
return $szReturnString;
|
779 |
+
}
|
780 |
+
|
781 |
+
public static function replaceEntitiesInStringWithChars($szString)
|
782 |
+
{
|
783 |
+
$szReturnString = null;
|
784 |
+
$nCount;
|
785 |
+
$boFound = false;
|
786 |
+
$boFoundAmpersand = false;
|
787 |
+
$nHTMLEntityCount;
|
788 |
+
$szAmpersandBuffer = "";
|
789 |
+
$nAmpersandBufferCount = 0;
|
790 |
+
|
791 |
+
for ($nCount = 0; $nCount < strlen($szString); $nCount++)
|
792 |
+
{
|
793 |
+
$boFound = false;
|
794 |
+
$nHTMLEntityCount = 0;
|
795 |
+
|
796 |
+
if (!$boFoundAmpersand)
|
797 |
+
{
|
798 |
+
if ($szString[$nCount] == '&')
|
799 |
+
{
|
800 |
+
$boFoundAmpersand = true;
|
801 |
+
$szAmpersandBuffer = (string)$szString[$nCount];
|
802 |
+
$nAmpersandBufferCount = 0;
|
803 |
+
}
|
804 |
+
else
|
805 |
+
{
|
806 |
+
$szReturnString .= $szString[$nCount];
|
807 |
+
}
|
808 |
+
}
|
809 |
+
else
|
810 |
+
{
|
811 |
+
$szAmpersandBuffer .= $szString[$nCount];
|
812 |
+
|
813 |
+
if ($nAmpersandBufferCount < (10 - 2))
|
814 |
+
{
|
815 |
+
if ($szString[$nCount] == ';')
|
816 |
+
{
|
817 |
+
$boFound = true;
|
818 |
+
$boFoundAmpersand = false;
|
819 |
+
}
|
820 |
+
else
|
821 |
+
{
|
822 |
+
$nAmpersandBufferCount++;
|
823 |
+
}
|
824 |
+
}
|
825 |
+
else
|
826 |
+
{
|
827 |
+
$szReturnString .= $szAmpersandBuffer;
|
828 |
+
$boFoundAmpersand = false;
|
829 |
+
}
|
830 |
+
}
|
831 |
+
|
832 |
+
if ($boFound)
|
833 |
+
{
|
834 |
+
// need to find the entity in the list
|
835 |
+
$boFoundEntity = false;
|
836 |
+
$nXMLEntityCount = 0;
|
837 |
+
|
838 |
+
while (!$boFoundEntity &&
|
839 |
+
$nXMLEntityCount < count($g_XMLEntities))
|
840 |
+
{
|
841 |
+
if (strtoupper($g_XMLEntities[$nXMLEntityCount]->getReplacement()) == strtoupper($szAmpersandBuffer))
|
842 |
+
{
|
843 |
+
$boFoundEntity = true;
|
844 |
+
}
|
845 |
+
else
|
846 |
+
{
|
847 |
+
$nXMLEntityCount++;
|
848 |
+
}
|
849 |
+
}
|
850 |
+
|
851 |
+
if ($boFoundEntity)
|
852 |
+
{
|
853 |
+
$szReturnString .= $g_XMLEntities[$nXMLEntityCount]->getCharCode();
|
854 |
+
}
|
855 |
+
else
|
856 |
+
{
|
857 |
+
$szReturnString .= $szAmpersandBuffer;
|
858 |
+
}
|
859 |
+
$boFound = false;
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
if ($boFoundAmpersand && !$boFound)
|
864 |
+
{
|
865 |
+
$szReturnString .= $szAmpersandBuffer;
|
866 |
+
}
|
867 |
+
|
868 |
+
return $szReturnString;
|
869 |
+
}
|
870 |
+
|
871 |
+
public static function boolToString($boValue)
|
872 |
+
{
|
873 |
+
if ($boValue == true)
|
874 |
+
{
|
875 |
+
return 'true';
|
876 |
+
}
|
877 |
+
elseif ($boValue == false)
|
878 |
+
{
|
879 |
+
return 'false';
|
880 |
+
}
|
881 |
+
}
|
882 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/controllers/PaymentController.php
ADDED
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once "app/code/local/Cardsave/Cardsaveonlinepayments/Model/Tpg/PaymentFormHelper.php";
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Standard Checkout Controller
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class Cardsave_Cardsaveonlinepayments_PaymentController extends Mage_Core_Controller_Front_Action
|
10 |
+
{
|
11 |
+
protected function _expireAjax()
|
12 |
+
{
|
13 |
+
if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems())
|
14 |
+
{
|
15 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
public function errorAction()
|
21 |
+
{
|
22 |
+
//$this->_redirect('checkout/cart');
|
23 |
+
$this->_redirect('checkout/onepage/failure');
|
24 |
+
#$this->loadLayout();
|
25 |
+
#$this->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* When a customer cancel payment from paypal.
|
30 |
+
*/
|
31 |
+
public function cancelAction()
|
32 |
+
{
|
33 |
+
$session = Mage::getSingleton('checkout/session');
|
34 |
+
$session->setQuoteId($session->getPaypalStandardQuoteId(true));
|
35 |
+
|
36 |
+
$this->_redirect('checkout/cart');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Action logic for Hosted Payment mode
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
public function redirectAction()
|
44 |
+
{
|
45 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('cardsaveonlinepayments/redirect')->toHtml());
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Action logic for 3D Secure redirection
|
50 |
+
*
|
51 |
+
*/
|
52 |
+
public function threedsecureAction()
|
53 |
+
{
|
54 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('cardsaveonlinepayments/threedsecure')->toHtml());
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Action logic for handling the reception of the 3D Secure authentication result (PaRes)
|
59 |
+
*
|
60 |
+
* @return unknown
|
61 |
+
*/
|
62 |
+
public function callback3dAction()
|
63 |
+
{
|
64 |
+
$boError = false;
|
65 |
+
$szMessage = '';
|
66 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
67 |
+
$session = Mage::getSingleton('checkout/session');
|
68 |
+
$szPaymentProcessorResponse = '';
|
69 |
+
|
70 |
+
try
|
71 |
+
{
|
72 |
+
$szPaRes = $this->getRequest()->getPost('PaRes');
|
73 |
+
$szMD = $this->getRequest()->getPost('MD');
|
74 |
+
|
75 |
+
// complete the 3D Secure transaction with the 3D Authorization result
|
76 |
+
$checkout->saveOrderAfter3dSecure($szPaRes, $szMD);
|
77 |
+
}
|
78 |
+
catch (Exception $exc)
|
79 |
+
{
|
80 |
+
$boError = true;
|
81 |
+
Mage::logException($exc);
|
82 |
+
|
83 |
+
if( isset($_SESSION['cardsaveonlinepayments_message']) )
|
84 |
+
{
|
85 |
+
$szMessage = $_SESSION['cardsaveonlinepayments_message'];
|
86 |
+
unset($_SESSION['cardsaveonlinepayments_message']);
|
87 |
+
}
|
88 |
+
else
|
89 |
+
{
|
90 |
+
$szMessage = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_7655;
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
$szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
|
95 |
+
if ($boError)
|
96 |
+
{
|
97 |
+
if($szPaymentProcessorResponse != null &&
|
98 |
+
$szPaymentProcessorResponse != '')
|
99 |
+
{
|
100 |
+
$szMessage .= '<br/>'.$szPaymentProcessorResponse;
|
101 |
+
}
|
102 |
+
// report out an fatal error
|
103 |
+
Mage::getSingleton('core/session')->addError($szMessage);
|
104 |
+
$this->_redirect('checkout/onepage/failure');
|
105 |
+
}
|
106 |
+
else
|
107 |
+
{
|
108 |
+
// set the quote as inactive after back from paypal
|
109 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
110 |
+
|
111 |
+
// send confirmation email to customer
|
112 |
+
$order = Mage::getModel('sales/order');
|
113 |
+
|
114 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
115 |
+
if($order->getId())
|
116 |
+
{
|
117 |
+
$order->sendNewOrderEmail();
|
118 |
+
}
|
119 |
+
|
120 |
+
if($szPaymentProcessorResponse != '')
|
121 |
+
{
|
122 |
+
Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
|
123 |
+
}
|
124 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Action logic for handling the result from the Hosted Payment page
|
130 |
+
*
|
131 |
+
*/
|
132 |
+
public function callbackhostedpaymentAction()
|
133 |
+
{
|
134 |
+
$boError = false;
|
135 |
+
$formVariables = array();
|
136 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
137 |
+
$szOrderID = $this->getRequest()->getPost('OrderID');
|
138 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
139 |
+
$session = Mage::getSingleton('checkout/session');
|
140 |
+
$szPaymentProcessorResponse = '';
|
141 |
+
|
142 |
+
try
|
143 |
+
{
|
144 |
+
$hmHashMethod = $model->getConfigData('hashmethod');
|
145 |
+
$szPassword = $model->getConfigData('password');
|
146 |
+
$szPreSharedKey = $model->getConfigData('presharedkey');
|
147 |
+
|
148 |
+
$formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
|
149 |
+
$formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
|
150 |
+
$formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
|
151 |
+
$formVariables['Message'] = $this->getRequest()->getPost('Message');
|
152 |
+
$formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
|
153 |
+
$formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
|
154 |
+
$formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
|
155 |
+
$formVariables['Amount'] = $this->getRequest()->getPost('Amount');
|
156 |
+
$formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
|
157 |
+
$formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
|
158 |
+
$formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
|
159 |
+
$formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
|
160 |
+
$formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
|
161 |
+
$formVariables['CustomerName'] = $this->getRequest()->getPost('CustomerName');
|
162 |
+
$formVariables['Address1'] = $this->getRequest()->getPost('Address1');
|
163 |
+
$formVariables['Address2'] = $this->getRequest()->getPost('Address2');
|
164 |
+
$formVariables['Address3'] = $this->getRequest()->getPost('Address3');
|
165 |
+
$formVariables['Address4'] = $this->getRequest()->getPost('Address4');
|
166 |
+
$formVariables['City'] = $this->getRequest()->getPost('City');
|
167 |
+
$formVariables['State'] = $this->getRequest()->getPost('State');
|
168 |
+
$formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
|
169 |
+
$formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
|
170 |
+
|
171 |
+
if(!CSV_PaymentFormHelper::compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
|
172 |
+
{
|
173 |
+
$boError = true;
|
174 |
+
$szNotificationMessage = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
|
175 |
+
Mage::log("The Hosted Payment Form transaction couldn't be completed for the following reason: [".$szNotificationMessage. "]. Form variables: ".print_r($formVariables, 1));
|
176 |
+
}
|
177 |
+
else
|
178 |
+
{
|
179 |
+
// need to finish off the transaction
|
180 |
+
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
181 |
+
$this->getRequest()->getPost('StatusCode'),
|
182 |
+
$this->getRequest()->getPost('Message'),
|
183 |
+
$this->getRequest()->getPost('PreviousStatusCode'),
|
184 |
+
$this->getRequest()->getPost('PreviousMessage'),
|
185 |
+
$this->getRequest()->getPost('OrderID'));
|
186 |
+
}
|
187 |
+
}
|
188 |
+
catch (Exception $exc)
|
189 |
+
{
|
190 |
+
$boError = true;
|
191 |
+
$szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_183;
|
192 |
+
Mage::logException($exc);
|
193 |
+
}
|
194 |
+
|
195 |
+
$szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
|
196 |
+
if($boError)
|
197 |
+
{
|
198 |
+
if($szPaymentProcessorResponse != null &&
|
199 |
+
$szPaymentProcessorResponse != '')
|
200 |
+
{
|
201 |
+
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
202 |
+
}
|
203 |
+
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
204 |
+
$this->_redirect('checkout/onepage/failure');
|
205 |
+
}
|
206 |
+
else
|
207 |
+
{
|
208 |
+
$order = Mage::getModel('sales/order');
|
209 |
+
|
210 |
+
// set the quote as inactive after back from paypal
|
211 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
212 |
+
|
213 |
+
// send confirmation email to customer
|
214 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
215 |
+
|
216 |
+
if($order->getId())
|
217 |
+
{
|
218 |
+
$order->sendNewOrderEmail();
|
219 |
+
}
|
220 |
+
|
221 |
+
if($szPaymentProcessorResponse != '')
|
222 |
+
{
|
223 |
+
Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
|
224 |
+
}
|
225 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Action logic for handling the server to server communication in case of Result Delivery Method = SERVER
|
231 |
+
*
|
232 |
+
*/
|
233 |
+
public function serverresultAction()
|
234 |
+
{
|
235 |
+
$boError = false;
|
236 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
237 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
238 |
+
$szOrderID = $this->getRequest()->getPost('OrderID');
|
239 |
+
|
240 |
+
try
|
241 |
+
{
|
242 |
+
// need to finish off the transaction - if StatusCode = 0 create an order otherwise do nothing
|
243 |
+
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
244 |
+
$this->getRequest()->getPost('StatusCode'),
|
245 |
+
$this->getRequest()->getPost('Message'),
|
246 |
+
$this->getRequest()->getPost('PreviousStatusCode'),
|
247 |
+
$this->getRequest()->getPost('PreviousMessage'),
|
248 |
+
$this->getRequest()->getPost('OrderID'));
|
249 |
+
}
|
250 |
+
catch (Exception $exc)
|
251 |
+
{
|
252 |
+
$boError = true;
|
253 |
+
$szErrorMessage = $exc->getMessage();
|
254 |
+
$szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_183;
|
255 |
+
Mage::logException($exc);
|
256 |
+
}
|
257 |
+
|
258 |
+
if($boError == true)
|
259 |
+
{
|
260 |
+
$this->getResponse()->setBody('StatusCode=30&Message='.$szErrorMessage);
|
261 |
+
}
|
262 |
+
else
|
263 |
+
{
|
264 |
+
$order = Mage::getModel('sales/order');
|
265 |
+
|
266 |
+
// set the quote as inactive after back from paypal
|
267 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
268 |
+
|
269 |
+
// send confirmation email to customer
|
270 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
271 |
+
|
272 |
+
if($order->getId())
|
273 |
+
{
|
274 |
+
$order->sendNewOrderEmail();
|
275 |
+
}
|
276 |
+
|
277 |
+
// if the payment was successful clear the session so that if the customer navigates back to the Magento store
|
278 |
+
// the shopping cart will be emptied rather than 'uncomplete'
|
279 |
+
if($this->getRequest()->getPost('StatusCode') == '0')
|
280 |
+
{
|
281 |
+
Mage::getSingleton('checkout/session')->clear();
|
282 |
+
}
|
283 |
+
|
284 |
+
$this->getResponse()->setBody('StatusCode=0');
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Action logic for handling the result set from the Transparent Redirect page
|
290 |
+
*
|
291 |
+
*/
|
292 |
+
public function callbacktransparentredirectAction()
|
293 |
+
{
|
294 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
295 |
+
|
296 |
+
try
|
297 |
+
{
|
298 |
+
$hmHashMethod = $model->getConfigData('hashmethod');
|
299 |
+
$szPassword = $model->getConfigData('password');
|
300 |
+
$szPreSharedKey = $model->getConfigData('presharedkey');
|
301 |
+
|
302 |
+
$szPaREQ = $this->getRequest()->getPost('PaREQ');
|
303 |
+
$szPaRES = $this->getRequest()->getPost('PaRes');
|
304 |
+
$nStatusCode = $this->getRequest()->getPost('StatusCode');
|
305 |
+
|
306 |
+
if(isset($szPaREQ))
|
307 |
+
{
|
308 |
+
// 3D Secure authentication required
|
309 |
+
self::_threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey);
|
310 |
+
}
|
311 |
+
else if(isset($szPaRES))
|
312 |
+
{
|
313 |
+
// 3D Secure post authentication
|
314 |
+
self::_postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey);
|
315 |
+
}
|
316 |
+
else
|
317 |
+
{
|
318 |
+
// payment complete
|
319 |
+
self::_paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey);
|
320 |
+
}
|
321 |
+
|
322 |
+
}
|
323 |
+
catch (Exception $exc)
|
324 |
+
{
|
325 |
+
$error = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_260;
|
326 |
+
Mage::logException($exc);
|
327 |
+
|
328 |
+
Mage::getSingleton('core/session')->addError($error);
|
329 |
+
$this->_redirect('checkout/onepage/failure');
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
private function _threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey)
|
334 |
+
{
|
335 |
+
$error = false;
|
336 |
+
$formVariables = array();
|
337 |
+
|
338 |
+
$formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
|
339 |
+
$formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
|
340 |
+
$formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
|
341 |
+
$formVariables['Message'] = $this->getRequest()->getPost('Message');
|
342 |
+
$formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
|
343 |
+
$formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
|
344 |
+
$formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
|
345 |
+
$formVariables['ACSURL'] = $this->getRequest()->getPost('ACSURL');
|
346 |
+
$formVariables['PaREQ'] = $this->getRequest()->getPost('PaREQ');
|
347 |
+
|
348 |
+
if(!CSV_PaymentFormHelper::compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
|
349 |
+
{
|
350 |
+
$error = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
|
351 |
+
Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: ".$error. " Form variables: ".print_r($formVariables, 1));
|
352 |
+
}
|
353 |
+
|
354 |
+
if($error)
|
355 |
+
{
|
356 |
+
Mage::getSingleton('core/session')->addError($error);
|
357 |
+
$this->_redirect('checkout/onepage/failure');
|
358 |
+
}
|
359 |
+
else
|
360 |
+
{
|
361 |
+
// redirect to a secure 3DS authentication page
|
362 |
+
Mage::getSingleton('checkout/session')->setMd($formVariables['CrossReference'])
|
363 |
+
->setAcsurl($formVariables['ACSURL'])
|
364 |
+
->setPareq($formVariables['PaREQ'])
|
365 |
+
->setTermurl('cardsaveonlinepayments/payment/callbacktransparentredirect');
|
366 |
+
|
367 |
+
// redirect to a 3D Secure page
|
368 |
+
$this->_redirect('cardsaveonlinepayments/payment/threedsecure');
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
private function _postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey)
|
373 |
+
{
|
374 |
+
$error = false;
|
375 |
+
$formVariables = array();
|
376 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
377 |
+
|
378 |
+
$szPaRES = $this->getRequest()->getPost('PaRes');
|
379 |
+
$szCrossReference = $this->getRequest()->getPost('MD');
|
380 |
+
$szMerchantID = $model->getConfigData('merchantid');
|
381 |
+
$szTransactionDateTime = date('Y-m-d H:i:s P');
|
382 |
+
$szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbacktransparentredirect');
|
383 |
+
$szHashDigest = CSV_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
|
384 |
+
|
385 |
+
|
386 |
+
Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
|
387 |
+
->setMerchantid($szMerchantID)
|
388 |
+
->setCrossreference($szCrossReference)
|
389 |
+
->setTransactiondatetime($szTransactionDateTime)
|
390 |
+
->setCallbackurl($szCallbackURL)
|
391 |
+
->setPares($szPaRES);
|
392 |
+
|
393 |
+
// redirect to the redirection bridge page
|
394 |
+
$this->_redirect('cardsaveonlinepayments/payment/redirect');
|
395 |
+
}
|
396 |
+
|
397 |
+
private function _paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey)
|
398 |
+
{
|
399 |
+
$boError = false;
|
400 |
+
$formVariables = array();
|
401 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
402 |
+
$szOrderID = $this->getRequest()->getPost('OrderID');
|
403 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
404 |
+
$session = Mage::getSingleton('checkout/session');
|
405 |
+
$szPaymentProcessorResponse = '';
|
406 |
+
|
407 |
+
try
|
408 |
+
{
|
409 |
+
$formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
|
410 |
+
$formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
|
411 |
+
$formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
|
412 |
+
$formVariables['Message'] = $this->getRequest()->getPost('Message');
|
413 |
+
$formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
|
414 |
+
$formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
|
415 |
+
$formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
|
416 |
+
$formVariables['Amount'] = $this->getRequest()->getPost('Amount');
|
417 |
+
$formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
|
418 |
+
$formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
|
419 |
+
$formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
|
420 |
+
$formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
|
421 |
+
$formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
|
422 |
+
$formVariables['Address1'] = $this->getRequest()->getPost('Address1');
|
423 |
+
$formVariables['Address2'] = $this->getRequest()->getPost('Address2');
|
424 |
+
$formVariables['Address3'] = $this->getRequest()->getPost('Address3');
|
425 |
+
$formVariables['Address4'] = $this->getRequest()->getPost('Address4');
|
426 |
+
$formVariables['City'] = $this->getRequest()->getPost('City');
|
427 |
+
$formVariables['State'] = $this->getRequest()->getPost('State');
|
428 |
+
$formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
|
429 |
+
$formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
|
430 |
+
|
431 |
+
if(!CSV_PaymentFormHelper::comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
|
432 |
+
{
|
433 |
+
$boError = true;
|
434 |
+
$szNotificationMessage = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
|
435 |
+
Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: [".$szNotificationMessage."] Form variables: ".print_r($formVariables, 1));
|
436 |
+
}
|
437 |
+
else
|
438 |
+
{
|
439 |
+
// need to finish off the transaction
|
440 |
+
$checkout->saveOrderAfterRedirectedPaymentAction(false,
|
441 |
+
$this->getRequest()->getPost('StatusCode'),
|
442 |
+
$this->getRequest()->getPost('Message'),
|
443 |
+
$this->getRequest()->getPost('PreviousStatusCode'),
|
444 |
+
$this->getRequest()->getPost('PreviousMessage'),
|
445 |
+
$this->getRequest()->getPost('OrderID'));
|
446 |
+
}
|
447 |
+
}
|
448 |
+
catch(Exception $exc)
|
449 |
+
{
|
450 |
+
$boError = true;
|
451 |
+
$szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Tpg_GlobalErrors::ERROR_183;
|
452 |
+
Mage::logException($exc);
|
453 |
+
}
|
454 |
+
|
455 |
+
$szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
|
456 |
+
if($boError == true)
|
457 |
+
{
|
458 |
+
if($szPaymentProcessorResponse != null &&
|
459 |
+
$szPaymentProcessorResponse != '')
|
460 |
+
{
|
461 |
+
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
462 |
+
}
|
463 |
+
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
464 |
+
$this->_redirect('checkout/onepage/failure');
|
465 |
+
}
|
466 |
+
else
|
467 |
+
{
|
468 |
+
$order = Mage::getModel('sales/order');
|
469 |
+
|
470 |
+
// set the quote as inactive after back from paypal
|
471 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
472 |
+
|
473 |
+
// send confirmation email to customer
|
474 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
475 |
+
|
476 |
+
if($order->getId())
|
477 |
+
{
|
478 |
+
$order->sendNewOrderEmail();
|
479 |
+
}
|
480 |
+
|
481 |
+
if($szPaymentProcessorResponse != '')
|
482 |
+
{
|
483 |
+
Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
|
484 |
+
}
|
485 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
486 |
+
}
|
487 |
+
}
|
488 |
+
}
|
app/code/local/Cardsave/Cardsaveonlinepayments/etc/config.xml
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Cardsave_Cardsaveonlinepayments>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Cardsave_Cardsaveonlinepayments>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<cardsaveonlinepayments>
|
12 |
+
<class>Cardsave_Cardsaveonlinepayments_Model</class>
|
13 |
+
</cardsaveonlinepayments>
|
14 |
+
</models>
|
15 |
+
<resources>
|
16 |
+
<cardsaveonlinepayments_setup>
|
17 |
+
<setup>
|
18 |
+
<module>Cardsave_Cardsaveonlinepayments</module>
|
19 |
+
</setup>
|
20 |
+
<connection>
|
21 |
+
<use>core_setup</use>
|
22 |
+
</connection>
|
23 |
+
</cardsaveonlinepayments_setup>
|
24 |
+
<cardsaveonlinepayments_write>
|
25 |
+
<connection>
|
26 |
+
<use>core_write</use>
|
27 |
+
</connection>
|
28 |
+
</cardsaveonlinepayments_write>
|
29 |
+
<cardsaveonlinepayments_read>
|
30 |
+
<connection>
|
31 |
+
<use>core_read</use>
|
32 |
+
</connection>
|
33 |
+
</cardsaveonlinepayments_read>
|
34 |
+
</resources>
|
35 |
+
<blocks>
|
36 |
+
<cardsaveonlinepayments>
|
37 |
+
<class>Cardsave_Cardsaveonlinepayments_Block</class>
|
38 |
+
</cardsaveonlinepayments>
|
39 |
+
</blocks>
|
40 |
+
<!-- Define the helper class type -->
|
41 |
+
<helpers>
|
42 |
+
<Cardsaveonlinepayments>
|
43 |
+
<class>Cardsave_Cardsaveonlinepayments_Helper</class>
|
44 |
+
</Cardsaveonlinepayments>
|
45 |
+
<cardsaveonlinepayments>
|
46 |
+
<rewrite>
|
47 |
+
<data>Cardsave_Cardsaveonlinepayments_Helper_Data</data>
|
48 |
+
</rewrite>
|
49 |
+
</cardsaveonlinepayments>
|
50 |
+
</helpers>
|
51 |
+
</global>
|
52 |
+
|
53 |
+
<frontend>
|
54 |
+
<secure_url>
|
55 |
+
<cardsaveonlinepayments>/cardsaveonlinepayments/standard</cardsaveonlinepayments>
|
56 |
+
</secure_url>
|
57 |
+
<routers>
|
58 |
+
<cardsaveonlinepayments>
|
59 |
+
<use>standard</use>
|
60 |
+
<args>
|
61 |
+
<module>Cardsave_Cardsaveonlinepayments</module>
|
62 |
+
<frontName>cardsaveonlinepayments</frontName>
|
63 |
+
</args>
|
64 |
+
</cardsaveonlinepayments>
|
65 |
+
</routers>
|
66 |
+
<translate>
|
67 |
+
<modules>
|
68 |
+
<Cardsave_Cardsaveonlinepayments>
|
69 |
+
<files>
|
70 |
+
<default>Cardsave_Cardsaveonlinepayments.csv</default>
|
71 |
+
</files>
|
72 |
+
</Cardsave_Cardsaveonlinepayments>
|
73 |
+
</modules>
|
74 |
+
</translate>
|
75 |
+
</frontend>
|
76 |
+
|
77 |
+
<!-- declare default configuration values for this module -->
|
78 |
+
<default>
|
79 |
+
<payment>
|
80 |
+
<cardsaveonlinepayments>
|
81 |
+
<active>1</active>
|
82 |
+
<model>cardsaveonlinepayments/direct</model>
|
83 |
+
<title>CardSave</title>
|
84 |
+
<hashmethod>sha1</hashmethod>
|
85 |
+
<paymentprocessordomain>cardsaveonlinepayments.com</paymentprocessordomain>
|
86 |
+
<paymentprocessorport>4430</paymentprocessorport>
|
87 |
+
<hostedpaymentactionurl>https://mms.cardsaveonlinepayments.com/Pages/PublicPages/PaymentForm.aspx</hostedpaymentactionurl>
|
88 |
+
<transparentredirectactionurl>https://mms.cardsaveonlinepayments.com/Pages/PublicPages/TransparentRedirect.aspx</transparentredirectactionurl>
|
89 |
+
<payment_action>capture</payment_action>
|
90 |
+
<mode>direct</mode>
|
91 |
+
<cv2mandatory>1</cv2mandatory>
|
92 |
+
<address1mandatory>1</address1mandatory>
|
93 |
+
<citymandatory>1</citymandatory>
|
94 |
+
<statemandatory>1</statemandatory>
|
95 |
+
<postcodemandatory>1</postcodemandatory>
|
96 |
+
<countrymandatory>1</countrymandatory>
|
97 |
+
<resultdeliverymethod>POST</resultdeliverymethod>
|
98 |
+
<allowspecific>0</allowspecific>
|
99 |
+
</cardsaveonlinepayments>
|
100 |
+
</payment>
|
101 |
+
</default>
|
102 |
+
</config>
|
app/code/local/Cardsave/Cardsaveonlinepayments/etc/system.xml
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<cardsaveonlinepayments translate="label">
|
7 |
+
<label>CardSave</label>
|
8 |
+
<comment>
|
9 |
+
<![CDATA[
|
10 |
+
<div style="color:Blue;font-weight:bold;">
|
11 |
+
Merchant Management System (MMS) <a href="https://mms.cardsaveonlinepayments.com" target="_blank">login</a>
|
12 |
+
</div>
|
13 |
+
]]>
|
14 |
+
</comment>
|
15 |
+
<sort_order>670</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<fields>
|
20 |
+
<title translate="label">
|
21 |
+
<label>Title</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>10</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>0</show_in_store>
|
27 |
+
</title>
|
28 |
+
<active translate="label">
|
29 |
+
<label>Enabled</label>
|
30 |
+
<sort_order>20</sort_order>
|
31 |
+
<frontend_type>select</frontend_type>
|
32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>0</show_in_store>
|
36 |
+
</active>
|
37 |
+
<debug translate="label">
|
38 |
+
<label>Debug</label>
|
39 |
+
<frontend_type>select</frontend_type>
|
40 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
41 |
+
<sort_order>30</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>0</show_in_store>
|
45 |
+
</debug>
|
46 |
+
<order_status translate="label">
|
47 |
+
<label>New order status</label>
|
48 |
+
<sort_order>40</sort_order>
|
49 |
+
<frontend_type>select</frontend_type>
|
50 |
+
<source_model>cardsaveonlinepayments/source_orderStatus</source_model>
|
51 |
+
<sort_order>50</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>0</show_in_store>
|
55 |
+
</order_status>
|
56 |
+
<merchantid translate="label">
|
57 |
+
<label>Merchant ID</label>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
+
<sort_order>60</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>0</show_in_store>
|
63 |
+
</merchantid>
|
64 |
+
<password translate="label">
|
65 |
+
<label>Password</label>
|
66 |
+
<frontend_type>password</frontend_type>
|
67 |
+
<sort_order>70</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</password>
|
72 |
+
<presharedkey translate="label">
|
73 |
+
<label>Pre Shared Key</label>
|
74 |
+
<frontend_type>text</frontend_type>
|
75 |
+
<sort_order>80</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</presharedkey>
|
80 |
+
<hashmethod translate="label">
|
81 |
+
<label>Hash Method</label>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<sort_order>81</sort_order>
|
84 |
+
<source_model>cardsaveonlinepayments/source_hashMethod</source_model>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>1</show_in_website>
|
87 |
+
<show_in_store>0</show_in_store>
|
88 |
+
</hashmethod>
|
89 |
+
<paymentprocessordomain translate="label">
|
90 |
+
<label>Payment Processor Domain</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<sort_order>100</sort_order>
|
93 |
+
<show_in_default>1</show_in_default>
|
94 |
+
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>0</show_in_store>
|
96 |
+
</paymentprocessordomain>
|
97 |
+
<paymentprocessorport translate="label">
|
98 |
+
<label>Payment Processor Port</label>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>110</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>0</show_in_store>
|
104 |
+
</paymentprocessorport>
|
105 |
+
<payment_action translate="label">
|
106 |
+
<label>Payment Action</label>
|
107 |
+
<sort_order>120</sort_order>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<source_model>cardsaveonlinepayments/source_paymentAction</source_model>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>0</show_in_store>
|
113 |
+
</payment_action>
|
114 |
+
<mode translate="label">
|
115 |
+
<label>Payment Integration Method</label>
|
116 |
+
<sort_order>130</sort_order>
|
117 |
+
<frontend_type>select</frontend_type>
|
118 |
+
<source_model>cardsaveonlinepayments/source_paymentMode</source_model>
|
119 |
+
<show_in_default>1</show_in_default>
|
120 |
+
<show_in_website>1</show_in_website>
|
121 |
+
<show_in_store>0</show_in_store>
|
122 |
+
</mode>
|
123 |
+
<hostedpaymentactionurl>
|
124 |
+
<label>Hosted Payment Form Action URL</label>
|
125 |
+
<frontend_type>label</frontend_type>
|
126 |
+
<sort_order>131</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>0</show_in_store>
|
130 |
+
</hostedpaymentactionurl>
|
131 |
+
<transparentredirectactionurl>
|
132 |
+
<label>Transparent Redirect Action URL</label>
|
133 |
+
<frontend_type>label</frontend_type>
|
134 |
+
<sort_order>132</sort_order>
|
135 |
+
<show_in_default>1</show_in_default>
|
136 |
+
<show_in_website>1</show_in_website>
|
137 |
+
<show_in_store>0</show_in_store>
|
138 |
+
</transparentredirectactionurl>
|
139 |
+
<cv2mandatory>
|
140 |
+
<label>CV2 Mandatory <![CDATA[<span style="color:Red;font-weight:bold;font-size:12px;">(ON FORM ONLY)</span>]]></label>
|
141 |
+
<sort_order>140</sort_order>
|
142 |
+
<frontend_type>select</frontend_type>
|
143 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
144 |
+
<show_in_default>1</show_in_default>
|
145 |
+
<show_in_website>1</show_in_website>
|
146 |
+
<show_in_store>0</show_in_store>
|
147 |
+
<comment><![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode. If you want to change the CV2 behaviour, please log into the <span style="font-weight:bold;color:Blue;">MMS</span> and update your Account Settings]]></comment>
|
148 |
+
</cv2mandatory>
|
149 |
+
<address1mandatory>
|
150 |
+
<label>Address1 Mandatory</label>
|
151 |
+
<sort_order>150</sort_order>
|
152 |
+
<frontend_type>select</frontend_type>
|
153 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
154 |
+
<show_in_default>1</show_in_default>
|
155 |
+
<show_in_website>1</show_in_website>
|
156 |
+
<show_in_store>0</show_in_store>
|
157 |
+
<comment>
|
158 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
159 |
+
</comment>
|
160 |
+
</address1mandatory>
|
161 |
+
<citymandatory>
|
162 |
+
<label>City Mandatory</label>
|
163 |
+
<sort_order>160</sort_order>
|
164 |
+
<frontend_type>select</frontend_type>
|
165 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
166 |
+
<show_in_default>1</show_in_default>
|
167 |
+
<show_in_website>1</show_in_website>
|
168 |
+
<show_in_store>0</show_in_store>
|
169 |
+
<comment>
|
170 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
171 |
+
</comment>
|
172 |
+
</citymandatory>
|
173 |
+
<postcodemandatory>
|
174 |
+
<label>PostCode Mandatory</label>
|
175 |
+
<sort_order>170</sort_order>
|
176 |
+
<frontend_type>select</frontend_type>
|
177 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
178 |
+
<show_in_default>1</show_in_default>
|
179 |
+
<show_in_website>1</show_in_website>
|
180 |
+
<show_in_store>0</show_in_store>
|
181 |
+
<comment>
|
182 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
183 |
+
</comment>
|
184 |
+
</postcodemandatory>
|
185 |
+
<statemandatory>
|
186 |
+
<label>State Mandatory</label>
|
187 |
+
<sort_order>180</sort_order>
|
188 |
+
<frontend_type>select</frontend_type>
|
189 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
190 |
+
<show_in_default>1</show_in_default>
|
191 |
+
<show_in_website>1</show_in_website>
|
192 |
+
<show_in_store>0</show_in_store>
|
193 |
+
<comment>
|
194 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
195 |
+
</comment>
|
196 |
+
</statemandatory>
|
197 |
+
<countrymandatory>
|
198 |
+
<label>Country Mandatory</label>
|
199 |
+
<sort_order>190</sort_order>
|
200 |
+
<frontend_type>select</frontend_type>
|
201 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
202 |
+
<show_in_default>1</show_in_default>
|
203 |
+
<show_in_website>1</show_in_website>
|
204 |
+
<show_in_store>0</show_in_store>
|
205 |
+
<comment>
|
206 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
207 |
+
</comment>
|
208 |
+
</countrymandatory>
|
209 |
+
<resultdeliverymethod>
|
210 |
+
<label>Result Delivery Method</label>
|
211 |
+
<sort_order>200</sort_order>
|
212 |
+
<frontend_type>select</frontend_type>
|
213 |
+
<source_model>cardsaveonlinepayments/source_resultDeliveryMethod</source_model>
|
214 |
+
<show_in_default>1</show_in_default>
|
215 |
+
<show_in_website>1</show_in_website>
|
216 |
+
<show_in_store>0</show_in_store>
|
217 |
+
<comment>
|
218 |
+
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
219 |
+
</comment>
|
220 |
+
</resultdeliverymethod>
|
221 |
+
</fields>
|
222 |
+
</cardsaveonlinepayments>
|
223 |
+
</groups>
|
224 |
+
</payment>
|
225 |
+
</sections>
|
226 |
+
</config>
|
app/code/local/Cardsave/Checkout/Block/Onepage/Payment/Methods.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* One page checkout status
|
5 |
+
*
|
6 |
+
* @category Mage
|
7 |
+
* @category Mage
|
8 |
+
* @package Mage_Checkout
|
9 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
10 |
+
*/
|
11 |
+
class Cardsave_Checkout_Block_Onepage_Payment_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Override the base function - by default the CardSave payment option will be selected
|
15 |
+
*
|
16 |
+
* @return mixed
|
17 |
+
*/
|
18 |
+
public function getSelectedMethodCode()
|
19 |
+
{
|
20 |
+
$method = false;
|
21 |
+
$model = Mage::getModel('cardsaveonlinepayments/direct');
|
22 |
+
|
23 |
+
if ($this->getQuote()->getPayment()->getMethod())
|
24 |
+
{
|
25 |
+
$method = $this->getQuote()->getPayment()->getMethod();
|
26 |
+
}
|
27 |
+
/*else
|
28 |
+
{
|
29 |
+
// force the current payment to be selected
|
30 |
+
if($model)
|
31 |
+
{
|
32 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Create an order
|
7 |
+
*
|
8 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
9 |
+
*/
|
10 |
+
public function saveOrder()
|
11 |
+
{
|
12 |
+
$this->validateOrder();
|
13 |
+
$billing = $this->getQuote()->getBillingAddress();
|
14 |
+
|
15 |
+
if (!$this->getQuote()->isVirtual())
|
16 |
+
{
|
17 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
18 |
+
}
|
19 |
+
|
20 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
21 |
+
{
|
22 |
+
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
|
23 |
+
if (!$this->getQuote()->isAllowedGuestCheckout())
|
24 |
+
{
|
25 |
+
Mage::throwException(Mage::helper('checkout')->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
|
26 |
+
}
|
27 |
+
$this->getQuote()->setCustomerId(null)
|
28 |
+
->setCustomerEmail($billing->getEmail())
|
29 |
+
->setCustomerIsGuest(true)
|
30 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
31 |
+
break;
|
32 |
+
|
33 |
+
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
|
34 |
+
$customer = Mage::getModel('customer/customer');
|
35 |
+
|
36 |
+
$customerBilling = $billing->exportCustomerAddress();
|
37 |
+
$customer->addAddress($customerBilling);
|
38 |
+
|
39 |
+
if (!$this->getQuote()->isVirtual() &&
|
40 |
+
!$shipping->getSameAsBilling())
|
41 |
+
{
|
42 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
43 |
+
$customer->addAddress($customerShipping);
|
44 |
+
}
|
45 |
+
|
46 |
+
if ($this->getQuote()->getCustomerDob() &&
|
47 |
+
!$billing->getCustomerDob())
|
48 |
+
{
|
49 |
+
$billing->setCustomerDob($this->getQuote()->getCustomerDob());
|
50 |
+
}
|
51 |
+
|
52 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
53 |
+
|
54 |
+
$customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
|
55 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
56 |
+
|
57 |
+
$this->getQuote()->setCustomer($customer);
|
58 |
+
Mage::log(time());
|
59 |
+
break;
|
60 |
+
|
61 |
+
default:
|
62 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
63 |
+
|
64 |
+
if (!$billing->getCustomerId() ||
|
65 |
+
$billing->getSaveInAddressBook())
|
66 |
+
{
|
67 |
+
$customerBilling = $billing->exportCustomerAddress();
|
68 |
+
$customer->addAddress($customerBilling);
|
69 |
+
}
|
70 |
+
if (!$this->getQuote()->isVirtual() &&
|
71 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
72 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
73 |
+
{
|
74 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
75 |
+
$customer->addAddress($customerShipping);
|
76 |
+
}
|
77 |
+
$customer->setSavedFromQuote(true);
|
78 |
+
$customer->save();
|
79 |
+
|
80 |
+
$changed = false;
|
81 |
+
if (isset($customerBilling) &&
|
82 |
+
!$customer->getDefaultBilling())
|
83 |
+
{
|
84 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
85 |
+
$changed = true;
|
86 |
+
}
|
87 |
+
if (!$this->getQuote()->isVirtual() &&
|
88 |
+
isset($customerBilling) &&
|
89 |
+
!$customer->getDefaultShipping() &&
|
90 |
+
$shipping->getSameAsBilling())
|
91 |
+
{
|
92 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
93 |
+
$changed = true;
|
94 |
+
}
|
95 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
96 |
+
isset($customerShipping) &&
|
97 |
+
!$customer->getDefaultShipping())
|
98 |
+
{
|
99 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
100 |
+
$changed = true;
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($changed)
|
104 |
+
{
|
105 |
+
$customer->save();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
$this->getQuote()->reserveOrderId();
|
110 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
111 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
112 |
+
if ($this->getQuote()->isVirtual())
|
113 |
+
{
|
114 |
+
$order = $convertQuote->addressToOrder($billing);
|
115 |
+
}
|
116 |
+
else
|
117 |
+
{
|
118 |
+
$order = $convertQuote->addressToOrder($shipping);
|
119 |
+
}
|
120 |
+
// @var $order Mage_Sales_Model_Order
|
121 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
122 |
+
|
123 |
+
if (!$this->getQuote()->isVirtual())
|
124 |
+
{
|
125 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
126 |
+
}
|
127 |
+
|
128 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
129 |
+
|
130 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
131 |
+
{
|
132 |
+
$orderItem = $convertQuote->itemToOrderItem($item);
|
133 |
+
if ($item->getParentItem())
|
134 |
+
{
|
135 |
+
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
136 |
+
}
|
137 |
+
$order->addItem($orderItem);
|
138 |
+
}
|
139 |
+
|
140 |
+
// We can use configuration data for declare new order status
|
141 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
142 |
+
// check again, if customer exists
|
143 |
+
if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
144 |
+
{
|
145 |
+
if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
|
146 |
+
{
|
147 |
+
Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
// clear 3dSecure session variables
|
152 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(null);
|
153 |
+
Mage::getSingleton('checkout/session')->setMd(null);
|
154 |
+
Mage::getSingleton('checkout/session')->setPares(null);
|
155 |
+
Mage::getSingleton('checkout/session')->setAcsurl(null);
|
156 |
+
|
157 |
+
$order->place();
|
158 |
+
|
159 |
+
if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
160 |
+
{
|
161 |
+
$customer->save();
|
162 |
+
$customerBillingId = $customerBilling->getId();
|
163 |
+
if (!$this->getQuote()->isVirtual())
|
164 |
+
{
|
165 |
+
$customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
|
166 |
+
$customer->setDefaultShipping($customerShippingId);
|
167 |
+
}
|
168 |
+
$customer->setDefaultBilling($customerBillingId);
|
169 |
+
$customer->save();
|
170 |
+
|
171 |
+
$this->getQuote()->setCustomerId($customer->getId());
|
172 |
+
|
173 |
+
$order->setCustomerId($customer->getId());
|
174 |
+
Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
|
175 |
+
|
176 |
+
$billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
|
177 |
+
if (!$this->getQuote()->isVirtual())
|
178 |
+
{
|
179 |
+
$shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
|
180 |
+
}
|
181 |
+
|
182 |
+
if ($customer->isConfirmationRequired())
|
183 |
+
{
|
184 |
+
$customer->sendNewAccountEmail('confirmation');
|
185 |
+
}
|
186 |
+
else
|
187 |
+
{
|
188 |
+
$customer->sendNewAccountEmail();
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* a flag to set that there will be redirect to third party after confirmation
|
194 |
+
* eg: paypal standard ipn
|
195 |
+
*/
|
196 |
+
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
197 |
+
if(!$redirectUrl)
|
198 |
+
{
|
199 |
+
$order->setEmailSent(true);
|
200 |
+
}
|
201 |
+
|
202 |
+
if(!$redirectUrl ||
|
203 |
+
$this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'cardsaveonlinepayments')
|
204 |
+
{
|
205 |
+
$order->save();
|
206 |
+
}
|
207 |
+
|
208 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
209 |
+
|
210 |
+
|
211 |
+
/**
|
212 |
+
* need to have somelogic to set order as new status to make sure order is not finished yet
|
213 |
+
* quote will be still active when we send the customer to paypal
|
214 |
+
*/
|
215 |
+
|
216 |
+
$orderId = $order->getIncrementId();
|
217 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
218 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
219 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
220 |
+
$this->getCheckout()->setRedirectUrl($redirectUrl);
|
221 |
+
|
222 |
+
/**
|
223 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
224 |
+
*/
|
225 |
+
if(!$redirectUrl)
|
226 |
+
{
|
227 |
+
$order->sendNewOrderEmail();
|
228 |
+
}
|
229 |
+
|
230 |
+
if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
|
231 |
+
!Mage::getSingleton('customer/session')->isLoggedIn())
|
232 |
+
{
|
233 |
+
/**
|
234 |
+
* we need to save quote here to have it saved with Customer Id.
|
235 |
+
* so when loginById() executes checkout/session method loadCustomerQuote
|
236 |
+
* it would not create new quotes and merge it with old one.
|
237 |
+
*/
|
238 |
+
$this->getQuote()->save();
|
239 |
+
if ($customer->isConfirmationRequired())
|
240 |
+
{
|
241 |
+
Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
|
242 |
+
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
|
243 |
+
));
|
244 |
+
}
|
245 |
+
else
|
246 |
+
{
|
247 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
//Setting this one more time like control flag that we haves saved order
|
252 |
+
//Must be checkout on success page to show it or not.
|
253 |
+
$this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
|
254 |
+
|
255 |
+
$this->getQuote()->setIsActive(false);
|
256 |
+
$this->getQuote()->save();
|
257 |
+
|
258 |
+
return $this;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Create an order for a Direct (API) 3D Secure enabled payment on the callback
|
263 |
+
*
|
264 |
+
* @param unknown_type $pares
|
265 |
+
* @param unknown_type $md
|
266 |
+
* @return unknown
|
267 |
+
*/
|
268 |
+
public function saveOrderAfter3dSecure($pares, $md)
|
269 |
+
{
|
270 |
+
$this->validateOrder();
|
271 |
+
$billing = $this->getQuote()->getBillingAddress();
|
272 |
+
if (!$this->getQuote()->isVirtual())
|
273 |
+
{
|
274 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
275 |
+
}
|
276 |
+
|
277 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
278 |
+
{
|
279 |
+
case 'guest':
|
280 |
+
$this->getQuote()->setCustomerEmail($billing->getEmail())
|
281 |
+
->setCustomerIsGuest(true)
|
282 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
283 |
+
break;
|
284 |
+
|
285 |
+
default:
|
286 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
287 |
+
|
288 |
+
if (!$billing->getCustomerId() ||
|
289 |
+
$billing->getSaveInAddressBook())
|
290 |
+
{
|
291 |
+
$customerBilling = $billing->exportCustomerAddress();
|
292 |
+
$customer->addAddress($customerBilling);
|
293 |
+
}
|
294 |
+
if (!$this->getQuote()->isVirtual() &&
|
295 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
296 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
297 |
+
{
|
298 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
299 |
+
$customer->addAddress($customerShipping);
|
300 |
+
}
|
301 |
+
$customer->setSavedFromQuote(true);
|
302 |
+
$customer->save();
|
303 |
+
|
304 |
+
$changed = false;
|
305 |
+
if (isset($customerBilling) &&
|
306 |
+
!$customer->getDefaultBilling())
|
307 |
+
{
|
308 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
309 |
+
$changed = true;
|
310 |
+
}
|
311 |
+
if (!$this->getQuote()->isVirtual() &&
|
312 |
+
isset($customerBilling) &&
|
313 |
+
!$customer->getDefaultShipping() &&
|
314 |
+
$shipping->getSameAsBilling())
|
315 |
+
{
|
316 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
317 |
+
$changed = true;
|
318 |
+
}
|
319 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
320 |
+
isset($customerShipping) &&
|
321 |
+
!$customer->getDefaultShipping())
|
322 |
+
{
|
323 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
324 |
+
$changed = true;
|
325 |
+
}
|
326 |
+
|
327 |
+
if ($changed)
|
328 |
+
{
|
329 |
+
$customer->save();
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
$this->getQuote()->reserveOrderId();
|
334 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
335 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
336 |
+
if ($this->getQuote()->isVirtual())
|
337 |
+
{
|
338 |
+
$order = $convertQuote->addressToOrder($billing);
|
339 |
+
}
|
340 |
+
else
|
341 |
+
{
|
342 |
+
$order = $convertQuote->addressToOrder($shipping);
|
343 |
+
}
|
344 |
+
/* @var $order Mage_Sales_Model_Order */
|
345 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
346 |
+
|
347 |
+
if (!$this->getQuote()->isVirtual())
|
348 |
+
{
|
349 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
350 |
+
}
|
351 |
+
|
352 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
353 |
+
|
354 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
355 |
+
{
|
356 |
+
$order->addItem($convertQuote->itemToOrderItem($item));
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* We can use configuration data for declare new order status
|
361 |
+
*/
|
362 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
363 |
+
|
364 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(true);
|
365 |
+
Mage::getSingleton('checkout/session')->setMd($md);
|
366 |
+
Mage::getSingleton('checkout/session')->setPares($pares);
|
367 |
+
|
368 |
+
$order->place();
|
369 |
+
|
370 |
+
if ( $order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
|
371 |
+
$order->getStatus() != 'pending' )
|
372 |
+
{
|
373 |
+
$order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
|
374 |
+
|
375 |
+
$order->addStatusToHistory($order_status);
|
376 |
+
$order->setStatus($order_status);
|
377 |
+
}
|
378 |
+
|
379 |
+
$order->save();
|
380 |
+
|
381 |
+
|
382 |
+
|
383 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
384 |
+
|
385 |
+
|
386 |
+
$this->getQuote()->setIsActive(false);
|
387 |
+
$this->getQuote()->save();
|
388 |
+
|
389 |
+
$orderId = $order->getIncrementId();
|
390 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
391 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
392 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
393 |
+
// $this->getCheckout()->setRedirectUrl($redirectUrl);
|
394 |
+
|
395 |
+
/**
|
396 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
397 |
+
*/
|
398 |
+
/*if(!$redirectUrl){
|
399 |
+
$order->sendNewOrderEmail();
|
400 |
+
}*/
|
401 |
+
|
402 |
+
if ($this->getQuote()->getCheckoutMethod() == 'register')
|
403 |
+
{
|
404 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
405 |
+
}
|
406 |
+
|
407 |
+
return $this;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Create an order for a Hosted Payment Form/Transparent Redirect payment on the callback
|
412 |
+
*
|
413 |
+
* @param unknown_type $boIsHostedPaymentAction
|
414 |
+
* @param unknown_type $szStatusCode
|
415 |
+
* @param unknown_type $szMessage
|
416 |
+
* @param unknown_type $szPreviousStatusCode
|
417 |
+
* @param unknown_type $szPreviousMessage
|
418 |
+
* @param unknown_type $szOrderID
|
419 |
+
* @return unknown
|
420 |
+
*/
|
421 |
+
public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
|
422 |
+
{
|
423 |
+
$this->validateOrder();
|
424 |
+
$billing = $this->getQuote()->getBillingAddress();
|
425 |
+
|
426 |
+
if (!$this->getQuote()->isVirtual())
|
427 |
+
{
|
428 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
429 |
+
}
|
430 |
+
|
431 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
432 |
+
{
|
433 |
+
case 'guest':
|
434 |
+
$this->getQuote()->setCustomerEmail($billing->getEmail())
|
435 |
+
->setCustomerIsGuest(true)
|
436 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
437 |
+
break;
|
438 |
+
|
439 |
+
default:
|
440 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
441 |
+
|
442 |
+
if (!$billing->getCustomerId() ||
|
443 |
+
$billing->getSaveInAddressBook())
|
444 |
+
{
|
445 |
+
$customerBilling = $billing->exportCustomerAddress();
|
446 |
+
$customer->addAddress($customerBilling);
|
447 |
+
}
|
448 |
+
if (!$this->getQuote()->isVirtual() &&
|
449 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
450 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
451 |
+
{
|
452 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
453 |
+
$customer->addAddress($customerShipping);
|
454 |
+
}
|
455 |
+
$customer->setSavedFromQuote(true);
|
456 |
+
$customer->save();
|
457 |
+
|
458 |
+
$changed = false;
|
459 |
+
if (isset($customerBilling) &&
|
460 |
+
!$customer->getDefaultBilling())
|
461 |
+
{
|
462 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
463 |
+
$changed = true;
|
464 |
+
}
|
465 |
+
if (!$this->getQuote()->isVirtual() &&
|
466 |
+
isset($customerBilling) &&
|
467 |
+
!$customer->getDefaultShipping() &&
|
468 |
+
$shipping->getSameAsBilling())
|
469 |
+
{
|
470 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
471 |
+
$changed = true;
|
472 |
+
}
|
473 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
474 |
+
isset($customerShipping) &&
|
475 |
+
!$customer->getDefaultShipping())
|
476 |
+
{
|
477 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
478 |
+
$changed = true;
|
479 |
+
}
|
480 |
+
|
481 |
+
if ($changed)
|
482 |
+
{
|
483 |
+
$customer->save();
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
$this->getQuote()->reserveOrderId();
|
488 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
489 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
490 |
+
if ($this->getQuote()->isVirtual())
|
491 |
+
{
|
492 |
+
$order = $convertQuote->addressToOrder($billing);
|
493 |
+
}
|
494 |
+
else
|
495 |
+
{
|
496 |
+
$order = $convertQuote->addressToOrder($shipping);
|
497 |
+
}
|
498 |
+
/* @var $order Mage_Sales_Model_Order */
|
499 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
500 |
+
|
501 |
+
if (!$this->getQuote()->isVirtual())
|
502 |
+
{
|
503 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
504 |
+
}
|
505 |
+
|
506 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
507 |
+
|
508 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
509 |
+
{
|
510 |
+
$order->addItem($convertQuote->itemToOrderItem($item));
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* We can use configuration data for declare new order status
|
515 |
+
*/
|
516 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
517 |
+
|
518 |
+
Mage::getSingleton('checkout/session')->setRedirectedpayment(true)
|
519 |
+
->setIshostedpayment($boIsHostedPaymentAction)
|
520 |
+
->setStatuscode($szStatusCode)
|
521 |
+
->setMessage($szMessage)
|
522 |
+
->setPreviousstatuscode($szPreviousStatusCode)
|
523 |
+
->setPreviousmessage($szPreviousMessage)
|
524 |
+
->setOrderid($szOrderID);
|
525 |
+
|
526 |
+
$order->place();
|
527 |
+
|
528 |
+
if ( $order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
|
529 |
+
$order->getStatus() != 'pending' )
|
530 |
+
{
|
531 |
+
$order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
|
532 |
+
|
533 |
+
$order->addStatusToHistory($order_status);
|
534 |
+
$order->setStatus($order_status);
|
535 |
+
}
|
536 |
+
|
537 |
+
$order->save();
|
538 |
+
|
539 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
540 |
+
|
541 |
+
$this->getQuote()->setIsActive(false);
|
542 |
+
$this->getQuote()->save();
|
543 |
+
|
544 |
+
$orderId = $order->getIncrementId();
|
545 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
546 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
547 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
548 |
+
|
549 |
+
/**
|
550 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
551 |
+
*/
|
552 |
+
/*if(!$redirectUrl){
|
553 |
+
$order->sendNewOrderEmail();
|
554 |
+
}*/
|
555 |
+
|
556 |
+
if ($this->getQuote()->getCheckoutMethod()=='register')
|
557 |
+
{
|
558 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
559 |
+
}
|
560 |
+
|
561 |
+
return $this;
|
562 |
+
}
|
563 |
+
}
|
app/code/local/Cardsave/Checkout/etc/config.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Cardsave_Checkout>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Cardsave_Checkout>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<checkout>
|
11 |
+
<rewrite>
|
12 |
+
<type_onepage>Cardsave_Checkout_Model_Type_Onepage</type_onepage>
|
13 |
+
</rewrite>
|
14 |
+
</checkout>
|
15 |
+
</models>
|
16 |
+
<blocks>
|
17 |
+
<checkout>
|
18 |
+
<rewrite>
|
19 |
+
<onepage_payment_methods>Cardsave_Checkout_Block_Onepage_Payment_Methods</onepage_payment_methods>
|
20 |
+
</rewrite>
|
21 |
+
</checkout>
|
22 |
+
</blocks>
|
23 |
+
</global>
|
24 |
+
</config>
|
app/code/local/Cardsave/Sales/Model/Order.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Sales_Model_Order extends Mage_Sales_Model_Order
|
4 |
+
{
|
5 |
+
protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
|
6 |
+
{
|
7 |
+
// attempt to set the specified state
|
8 |
+
if ($shouldProtectState)
|
9 |
+
{
|
10 |
+
if ($this->isStateProtected($state))
|
11 |
+
{
|
12 |
+
Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
$this->setData('state', $state);
|
17 |
+
|
18 |
+
// add status history
|
19 |
+
if ($status)
|
20 |
+
{
|
21 |
+
if ($status === true)
|
22 |
+
{
|
23 |
+
$status = $this->getConfig()->getStateDefaultStatus($state);
|
24 |
+
}
|
25 |
+
|
26 |
+
$this->setStatus($status);
|
27 |
+
$history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
|
28 |
+
$history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
|
29 |
+
}
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
}
|
app/code/local/Cardsave/Sales/Model/Order/Invoice.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Cardsave_Sales_Model_Order_Invoice extends Mage_Sales_Model_Order_Invoice
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Capture invoice
|
7 |
+
*
|
8 |
+
* @return Mage_Sales_Model_Order_Invoice
|
9 |
+
*/
|
10 |
+
public function capture()
|
11 |
+
{
|
12 |
+
$this->getOrder()->getPayment()->capture($this);
|
13 |
+
|
14 |
+
if ($this->getIsPaid())
|
15 |
+
{
|
16 |
+
$this->pay();
|
17 |
+
}
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Cardsave/Sales/etc/config.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Cardsave_Sales>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Cardsave_Sales>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<sales>
|
11 |
+
<rewrite>
|
12 |
+
<order>Cardsave_Sales_Model_Order</order>
|
13 |
+
<order_invoice>Cardsave_Sales_Model_Order_Invoice</order_invoice>
|
14 |
+
</rewrite>
|
15 |
+
</sales>
|
16 |
+
</models>
|
17 |
+
</global>
|
18 |
+
</config>
|
app/design/adminhtml/default/default/template/cardsaveonlinepayments/form.phtml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
|
2 |
+
<?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
3 |
+
<fieldset class="form-list">
|
4 |
+
<?php $_code=$this->getMethodCode() ?>
|
5 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
6 |
+
<li>
|
7 |
+
<?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
|
8 |
+
</li>
|
9 |
+
</ul>
|
10 |
+
</fieldset>
|
11 |
+
<?php } else {?>
|
12 |
+
<fieldset class="form-list">
|
13 |
+
<?php $_code = $this->getMethodCode(); ?>
|
14 |
+
<ul id="payment_form_<?php echo $_code; ?>" style="display:none">
|
15 |
+
<li>
|
16 |
+
<div class="input-box">
|
17 |
+
<label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
|
18 |
+
<input type="text" title="<?php echo $this->__('Name On Card') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
|
19 |
+
</div>
|
20 |
+
</li>
|
21 |
+
<li>
|
22 |
+
<div class="input-box">
|
23 |
+
<label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
|
24 |
+
<input type="text" id="<?php echo $_code; ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="required-entry input-text" value=""/>
|
25 |
+
</div>
|
26 |
+
</li>
|
27 |
+
<li>
|
28 |
+
<div class="input-box">
|
29 |
+
<label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br/>
|
30 |
+
<div class="v-fix">
|
31 |
+
<select id="<?php echo $_code; ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
|
32 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
33 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
34 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
35 |
+
<?php endforeach ?>
|
36 |
+
</select>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
<div class="v-fix" style="padding-left:5px;">
|
40 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
41 |
+
<select id="<?php echo $_code; ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
|
42 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
43 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
44 |
+
<?php endforeach ?>
|
45 |
+
</select>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
</li>
|
49 |
+
<li>
|
50 |
+
<div class="input-box">
|
51 |
+
<label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
|
52 |
+
<div class="v-fix">
|
53 |
+
<select id="<?php echo $_code; ?>_cc_ss_start_month" style="width:140px;" name="payment[cc_ss_start_month]" class="validate-cc-start">
|
54 |
+
<?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
|
55 |
+
<?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
|
56 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
57 |
+
<?php endforeach ?>
|
58 |
+
</select>
|
59 |
+
</div>
|
60 |
+
<div class="v-fix" style="padding-left:5px;">
|
61 |
+
<?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
|
62 |
+
<select id="<?php echo $_code ?>_cc_ss_start_year" style="width:103px;" name="payment[cc_ss_start_year]">
|
63 |
+
<?php foreach ($this->getCcStartYears() as $k=>$v): ?>
|
64 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
65 |
+
<?php endforeach ?>
|
66 |
+
</select>
|
67 |
+
</div>
|
68 |
+
</div>
|
69 |
+
</li>
|
70 |
+
<li>
|
71 |
+
<div class="input-box">
|
72 |
+
<label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
|
73 |
+
<div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text" id="<?php echo $_code ?>_cc_ss_issue" name="payment[cc_ss_issue]" style="width:3em;" value="" /></div>
|
74 |
+
</div>
|
75 |
+
</li>
|
76 |
+
<li>
|
77 |
+
<div class="input-box">
|
78 |
+
<label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
|
79 |
+
<div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value=""/></div>
|
80 |
+
|
81 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
82 |
+
</div>
|
83 |
+
</li>
|
84 |
+
</ul>
|
85 |
+
</fieldset>
|
86 |
+
<?php }?>
|
app/design/adminhtml/default/default/template/cardsaveonlinepayments/info.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
|
2 |
+
<?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
+
<?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
+
<?php echo $this->__('CardSave secure payment'); ?>
|
5 |
+
<?php } else {?>
|
6 |
+
<?php echo $this->__('No card information is available'); ?>
|
7 |
+
<?php }?>
|
8 |
+
<?php } else {?>
|
9 |
+
<?php if($_info = $this->getInfo()): ?>
|
10 |
+
<?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
|
11 |
+
<br/>
|
12 |
+
<?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getCcNumber())) ?>
|
13 |
+
<br/>
|
14 |
+
<?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getInfo()->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
|
15 |
+
<br />
|
16 |
+
<?php else: ?>
|
17 |
+
<?php endif; ?>
|
18 |
+
<?php }?>
|
app/design/frontend/default/default/template/cardsaveonlinepayments/form.phtml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
|
2 |
+
<?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
3 |
+
<fieldset class="form-list">
|
4 |
+
<?php $_code=$this->getMethodCode() ?>
|
5 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
6 |
+
<li>
|
7 |
+
<img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
|
8 |
+
</li>
|
9 |
+
<li>
|
10 |
+
<?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
|
11 |
+
</li>
|
12 |
+
</ul>
|
13 |
+
</fieldset>
|
14 |
+
<?php } else {?>
|
15 |
+
<fieldset class="form-list">
|
16 |
+
<?php $_code = $this->getMethodCode(); ?>
|
17 |
+
<ul id="payment_form_<?php echo $_code; ?>" style="display:none">
|
18 |
+
<li>
|
19 |
+
<img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
|
20 |
+
</li>
|
21 |
+
<li>
|
22 |
+
<div class="input-box">
|
23 |
+
<label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
|
24 |
+
<input type="text" title="<?php echo $this->__('Name On Card') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
|
25 |
+
</div>
|
26 |
+
</li>
|
27 |
+
<li>
|
28 |
+
<div class="input-box">
|
29 |
+
<label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
|
30 |
+
<input type="text" id="<?php echo $_code; ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="required-entry input-text" value=""/>
|
31 |
+
</div>
|
32 |
+
</li>
|
33 |
+
<li>
|
34 |
+
<div class="input-box">
|
35 |
+
<label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiry Date') ?> <span class="required">*</span></label><br/>
|
36 |
+
<div class="v-fix">
|
37 |
+
<select id="<?php echo $_code; ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
|
38 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
39 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
40 |
+
<option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
41 |
+
<?php endforeach ?>
|
42 |
+
</select>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<div class="v-fix" style="padding-left:5px;">
|
46 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
47 |
+
<select id="<?php echo $_code; ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
|
48 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
49 |
+
<option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
50 |
+
<?php endforeach ?>
|
51 |
+
</select>
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
+
</li>
|
55 |
+
<li>
|
56 |
+
<div class="input-box">
|
57 |
+
<label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
|
58 |
+
<div class="v-fix">
|
59 |
+
<select id="<?php echo $_code; ?>_cc_ss_start_month" style="width:140px;" name="payment[cc_ss_start_month]" class="validate-cc-start">
|
60 |
+
<?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
|
61 |
+
<?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
|
62 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
63 |
+
<?php endforeach ?>
|
64 |
+
</select>
|
65 |
+
</div>
|
66 |
+
<div class="v-fix" style="padding-left:5px;">
|
67 |
+
<?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
|
68 |
+
<select id="<?php echo $_code ?>_cc_ss_start_year" style="width:103px;" name="payment[cc_ss_start_year]">
|
69 |
+
<?php foreach ($this->getCcStartYears() as $k=>$v): ?>
|
70 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
71 |
+
<?php endforeach ?>
|
72 |
+
</select>
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
+
</li>
|
76 |
+
<li>
|
77 |
+
<div class="input-box">
|
78 |
+
<label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
|
79 |
+
<div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text" id="<?php echo $_code ?>_cc_ss_issue" name="payment[cc_ss_issue]" style="width:3em;" value="" /></div>
|
80 |
+
</div>
|
81 |
+
</li>
|
82 |
+
<li>
|
83 |
+
<div class="input-box">
|
84 |
+
<label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
|
85 |
+
<div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value=""/></div>
|
86 |
+
|
87 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
88 |
+
</div>
|
89 |
+
</li>
|
90 |
+
</ul>
|
91 |
+
</fieldset>
|
92 |
+
<?php }?>
|
app/design/frontend/default/default/template/cardsaveonlinepayments/info.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
|
2 |
+
<?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
+
<?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
+
<?php echo $this->__('CardSave secure payment'); ?>
|
5 |
+
<?php } else {?>
|
6 |
+
<?php echo $this->__('No card information is available'); ?>
|
7 |
+
<?php }?>
|
8 |
+
<?php } else {?>
|
9 |
+
<?php if($_info = $this->getInfo()): ?>
|
10 |
+
<?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
|
11 |
+
<br/>
|
12 |
+
<?php echo $this->__('Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
|
13 |
+
<br/>
|
14 |
+
<?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getInfo()->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
|
15 |
+
<?php else: ?>
|
16 |
+
<?php endif; ?>
|
17 |
+
<?php }?>
|
app/etc/modules/Cardsave_All.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Cardsave_Cardsaveonlinepayments>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
<depends>
|
7 |
+
<Mage_Payment />
|
8 |
+
</depends>
|
9 |
+
</Cardsave_Cardsaveonlinepayments>
|
10 |
+
<Cardsave_Checkout>
|
11 |
+
<active>true</active>
|
12 |
+
<codePool>local</codePool>
|
13 |
+
</Cardsave_Checkout>
|
14 |
+
<Cardsave_Sales>
|
15 |
+
<active>true</active>
|
16 |
+
<codePool>local</codePool>
|
17 |
+
</Cardsave_Sales>
|
18 |
+
</modules>
|
19 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Cardsave_Cardsaveonlinepayments</name>
|
4 |
+
<version>1.7.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>CardSave Payment Extension</summary>
|
10 |
+
<description>Magento payment extension for the CardSave payment gateway. This extension fully supports the processing of 3D secure (Verified By Visa and Mastercard SecureCode) transactions. It also supports all of the integration methods provided by Iridium.</description>
|
11 |
+
<notes>ServerResult action exception message included in the Message response variable</notes>
|
12 |
+
<authors><author><name>CardSave Support</name><user>auto-converted</user><email>integrationsupport@cardsaveonlinepayments.com</email></author></authors>
|
13 |
+
<date>2010-08-04</date>
|
14 |
+
<time>15:42:17</time>
|
15 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="2b0b8a72c9f4a6d2ab9f0ea020c8f2ed"/><file name="info.phtml" hash="ebd858f4a39de4384d82214268df5e18"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="206c8703ef4d160dfc6c739c128ab47b"/><file name="info.phtml" hash="086176ae3d7bef055c87029fb96a3933"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="b5a1f7af807dc9a41ec5b9db5c74e87e"/><file name="Threedsecure.php" hash="3b3cb2347316ad91dfb4ff53a58f623f"/></dir><dir name="controllers"><file name="PaymentController.php" hash="c50bdf83d52e22c9a19b21f86e277e5b"/></dir><dir name="etc"><file name="config.xml" hash="afa8160f9973a3de03be08521c304ef7"/><file name="system.xml" hash="f5c0d07410e819d0a174f8445d4cff6e"/></dir><dir name="Helper"><file name="Data.php" hash="e024ec0479d1e8e7efcf4751b05194d6"/></dir><dir name="Model"><file name="Direct.php" hash="5dbe5367f9e30cc096814ef57c356ad2"/><file name="Request.php" hash="370f028086d13ae1df470e93a67dea66"/><dir name="Source"><file name="HashMethod.php" hash="997928579b69d21ae9eebec698c715c6"/><file name="OrderStatus.php" hash="4c44f8ba1652f20d934aa200ed4c8d00"/><file name="PaymentAction.php" hash="fa94be37c18bbb2f6301bdad1db3698d"/><file name="PaymentMode.php" hash="ea8af602bd09d54a123af64bc4b680d0"/><file name="ResultDeliveryMethod.php" hash="cd9f3e997b9a5a1ba2abed8ed11534a7"/></dir><dir name="Tpg"><file name="GlobalErrors.php" hash="fc971555973a0c9eaf73701d4f976a6a"/><file name="ISOCountries.php" hash="78dc558da68ca9a6ef44898a3980ecf2"/><file name="ISOCurrencies.php" hash="a32bc47b2d9896c293ecdcbf847144f9"/><file name="PaymentFormHelper.php" hash="2f7fb5ce0d2f74f0955d8e1a8e98b9b3"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="e4d4df170c21b7e3571b3ba1205ca979"/><file name="SOAP.php" hash="a0e5474dce51dc90ba4d37b5de3cdd84"/><file name="TPG_Common.php" hash="d86997c977cfd55b8ab577a514ab149c"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="695d628564f6e1e0c85e3821699e6b45"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="9dbd58b6b32491d65e5c7d5850aa3420"/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="651262752fd172df050151a4a916a72b"/></dir></dir></dir><dir name="Sales"><dir name="etc"><file name="config.xml" hash="21fea9901bfaed9c0964aa91817af05c"/></dir><dir name="Model"><file name="Order.php" hash="9ffa9e06b0d5d8d2d810ab50017e81fa"/><dir name="Order"><file name="Invoice.php" hash="e7e1e003f4e8c0540ff8e9ad0465a6cb"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.jpg" hash="abb239c81edb9ae8df8cf891e914e2aa"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash="e1d59fd8c4d4b5d87607f43fecf47e59"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|
skin/frontend/default/default/images/cardsave_online.jpg
ADDED
Binary file
|