Version Notes
* PHP 5.4 Compatibility Fix
* Store name now passed in order description.
* User friendly error messages for common errors.
* Ensured inputted values cannot exceed allowed amounts by the gateway (Direct).
* VOID, COLLECTION and REFUNDS now usable from within the back-end (Direct Integration Required).
Download this release
Release Info
Developer | CardSave |
Extension | Cardsave_Cardsaveonlinepayments |
Version | 1.15.0 |
Comparing to | |
See all releases |
Code changes from version 1.14.5 to 1.15.0
- app/code/local/Cardsave/Cardsaveonlinepayments/Block/Redirect.php +1 -1
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php +1 -1
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/CommonFunctions.php +93 -0
- app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php +539 -164
- package.xml +11 -6
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Redirect.php
CHANGED
@@ -74,7 +74,7 @@ class Cardsave_Cardsaveonlinepayments_Block_Redirect extends Mage_Core_Block_Abs
|
|
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'=>
|
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 |
|
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'=>''));
|
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 |
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php
CHANGED
@@ -166,7 +166,7 @@
|
|
166 |
'ResultDeliveryMethod='.$rdmResultdeliveryMethod.'&'.
|
167 |
'ServerResultURL='.$szServerResultURL.'&'.
|
168 |
'PaymentFormDisplaysResult='.$boPaymentFormDisplaysResult.'&'.
|
169 |
-
'ServerResultURLCookieVariables='
|
170 |
'ServerResultURLFormVariables='.$szServerResultURLFormVariables.'&'.
|
171 |
'ServerResultURLQueryStringVariables='.$szServerResultURLQueryStringVariables;
|
172 |
|
166 |
'ResultDeliveryMethod='.$rdmResultdeliveryMethod.'&'.
|
167 |
'ServerResultURL='.$szServerResultURL.'&'.
|
168 |
'PaymentFormDisplaysResult='.$boPaymentFormDisplaysResult.'&'.
|
169 |
+
'ServerResultURLCookieVariables='.''.'&'.
|
170 |
'ServerResultURLFormVariables='.$szServerResultURLFormVariables.'&'.
|
171 |
'ServerResultURLQueryStringVariables='.$szServerResultURLQueryStringVariables;
|
172 |
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/CommonFunctions.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//Functions to pull result from XML
|
3 |
+
function GetXMLValue($XMLElement, $XML, $pattern) {
|
4 |
+
$soapArray = null;
|
5 |
+
$ToReturn = null;
|
6 |
+
if (preg_match('#<'.$XMLElement.'>('.$pattern.')</'.$XMLElement.'>#iU', $XML, $soapArray)) {
|
7 |
+
$ToReturn = $soapArray[1];
|
8 |
+
} else {
|
9 |
+
$ToReturn = $XMLElement . " Not Found";
|
10 |
+
}
|
11 |
+
|
12 |
+
return $ToReturn;
|
13 |
+
}
|
14 |
+
|
15 |
+
function GetCrossReference($XML) {
|
16 |
+
$soapArray = null;
|
17 |
+
$ToReturn = null;
|
18 |
+
if (preg_match('#<TransactionOutputData CrossReference="(.+)">#iU', $XML, $soapArray)) {
|
19 |
+
$ToReturn = $soapArray[1];
|
20 |
+
} else {
|
21 |
+
$ToReturn = "No Data Found";
|
22 |
+
}
|
23 |
+
|
24 |
+
return $ToReturn;
|
25 |
+
}
|
26 |
+
|
27 |
+
// convert restricted characters to html equivalent and ensure values don�t go over the amount allowed
|
28 |
+
function clean($string, $numberLimit) {
|
29 |
+
// remove restricted characters
|
30 |
+
$toReplace = array("#","\\",">","<", "\"", "[", "]");
|
31 |
+
$string = str_replace($toReplace, "", $string);
|
32 |
+
|
33 |
+
// remove html special chars and turn into html equivalent value
|
34 |
+
$string = htmlspecialchars($string);
|
35 |
+
|
36 |
+
// now ensure it doesnt exceed the allowed amount
|
37 |
+
$string = substr($string, 0, $numberLimit);
|
38 |
+
|
39 |
+
//return clean string
|
40 |
+
return $string;
|
41 |
+
}
|
42 |
+
|
43 |
+
//get the error from the gateway and show a friendly message to the user i.e invalid card number
|
44 |
+
function getErrorFromGateway($szMessageDetail, $ret){
|
45 |
+
if ($szMessageDetail == "Invalid card type"){
|
46 |
+
// invalid card type/number
|
47 |
+
$szMessageError = "Invalid card type/number.";
|
48 |
+
}
|
49 |
+
else if ($szMessageDetail == "Passed variable (PaymentMessage.CardDetails.CV2) has an invalid value"){
|
50 |
+
// invalid CV2
|
51 |
+
$szMessageError = "Invalid CV2 number.";
|
52 |
+
}
|
53 |
+
else if ($szMessageDetail == "Required variable (PaymentMessage.CardDetails.CardNumber) is missing"){
|
54 |
+
// no card number entered
|
55 |
+
$szMessageError = "No card number entered.";
|
56 |
+
}
|
57 |
+
else if ($szMessageDetail == "Passed variable (PaymentMessage.CardDetails.CardNumber) has an invalid value"){
|
58 |
+
// invalid card number - normally caused by exceeding the length
|
59 |
+
$szMessageError = "Invalid card number.";
|
60 |
+
}
|
61 |
+
else if ($szMessageDetail == "Required variable (PaymentMessage.CardDetails.ExpiryDate.Month) is missing"){
|
62 |
+
// missing expiry month
|
63 |
+
$szMessageError = "Expiry month missing.";
|
64 |
+
}
|
65 |
+
else if ($szMessageDetail == "Required variable (PaymentMessage.CardDetails.ExpiryDate.Year) is missing"){
|
66 |
+
// missing expiry year
|
67 |
+
$szMessageError = "Expiry year missing.";
|
68 |
+
}
|
69 |
+
else if ($szMessageDetail == "Passed variable (PaymentMessage.CardDetails.ExpiryDate.Year) has an invalid value"){
|
70 |
+
// invalid expiry year - - normally caused by exceeding the length
|
71 |
+
$szMessageError = "Invalid expiry year.";
|
72 |
+
}
|
73 |
+
else if ($szMessageDetail == "Passed variable (PaymentMessage.CardDetails.ExpiryDate.Month) has an invalid value"){
|
74 |
+
// invalid expiry month - - normally caused by exceeding the length
|
75 |
+
$szMessageError = "Invalid expiry month.";
|
76 |
+
}
|
77 |
+
else if ($szMessageDetail == "Passed variable (PaymentMessage.CardDetails.IssueNumber) has an invalid value"){
|
78 |
+
// invalid issue number - normally caused by exceeding the length
|
79 |
+
$szMessageError = "Invalid issue number.";
|
80 |
+
}
|
81 |
+
else {
|
82 |
+
// other error - return what the gateway advised
|
83 |
+
$szMessageError = GetXMLValue("Message", $ret, ".+");
|
84 |
+
|
85 |
+
if ($szMessageError == "Invalid merchant details"){
|
86 |
+
$szMessageError = "Incorrect ID and/or Password";
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
//return the error from gateway
|
91 |
+
return $szMessageError;
|
92 |
+
}
|
93 |
+
?>
|
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php
CHANGED
@@ -5,11 +5,14 @@ if (!defined('COMPILER_INCLUDE_PATH')) {
|
|
5 |
include_once ("Common/PaymentFormHelper.php");
|
6 |
include_once ("Common/ISOCurrencies.php");
|
7 |
include_once ("Common/ISOCountries.php");
|
|
|
|
|
8 |
} else {
|
9 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ThePaymentGateway_PaymentSystem.php");
|
10 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_PaymentFormHelper.php");
|
11 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ISOCurrencies.php");
|
12 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ISOCountries.php");
|
|
|
13 |
}
|
14 |
|
15 |
class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
@@ -228,7 +231,7 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
228 |
// assign payment form field values to variables
|
229 |
$order = $payment->getOrder();
|
230 |
$szOrderID = $payment->getOrder()->increment_id;
|
231 |
-
$szOrderDescription =
|
232 |
$szCardName = $payment->getCcOwner();
|
233 |
$szCardNumber = $payment->getCcNumber();
|
234 |
$szIssueNumber = $payment->getCcSsIssue();
|
@@ -251,14 +254,10 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
251 |
$nDecimalAmount;
|
252 |
$szTransactionType;
|
253 |
|
254 |
-
$PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
|
255 |
$iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
|
256 |
$iclISOCountryList = CSV_ISOCountries::getISOCountryList();
|
257 |
|
258 |
-
|
259 |
-
$rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
|
260 |
-
$rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
|
261 |
-
$rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
|
262 |
|
263 |
$paymentAction = $this->getConfigData('payment_action');
|
264 |
if($paymentAction == Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE)
|
@@ -274,20 +273,14 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
274 |
Mage::throwException('Unknown payment action: '.$paymentAction);
|
275 |
}
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
$cdtCardDetailsTransaction->getMerchantAuthentication()->setMerchantID($MerchantID);
|
280 |
-
$cdtCardDetailsTransaction->getMerchantAuthentication()->setPassword($Password);
|
281 |
-
|
282 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
|
283 |
-
|
284 |
if (!$takePaymentInStoreBaseCurrency) {
|
285 |
// Take payment in order currency
|
286 |
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
287 |
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
288 |
{
|
289 |
$nCurrencyCode = $icISOCurrency->getISOCode();
|
290 |
-
|
291 |
}
|
292 |
|
293 |
// Calculate amount
|
@@ -300,95 +293,227 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
300 |
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
301 |
{
|
302 |
$nCurrencyCode = $icISOCurrency->getISOCode();
|
303 |
-
|
304 |
}
|
305 |
|
306 |
// Calculate amount
|
307 |
$nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
|
308 |
}
|
309 |
-
|
310 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getAmount()->setValue($nAmount);
|
311 |
-
|
312 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->setOrderID($szOrderID);
|
313 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->setOrderDescription($szOrderDescription);
|
314 |
-
|
315 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoCardType()->setValue(true);
|
316 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoAmountReceived()->setValue(true);
|
317 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoAVSCheckResult()->setValue(true);
|
318 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoCV2CheckResult()->setValue(true);
|
319 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getThreeDSecureOverridePolicy()->setValue(true);
|
320 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getDuplicateDelay()->setValue(60);
|
321 |
-
|
322 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->getDeviceCategory()->setValue(0);
|
323 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->setAcceptHeaders("*/*");
|
324 |
-
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->setUserAgent($_SERVER["HTTP_USER_AGENT"]);
|
325 |
-
|
326 |
-
$cdtCardDetailsTransaction->getCardDetails()->setCardName($szCardName);
|
327 |
-
$cdtCardDetailsTransaction->getCardDetails()->setCardNumber($szCardNumber);
|
328 |
-
|
329 |
-
if ($payment->getCcExpMonth() != "")
|
330 |
-
{
|
331 |
-
$cdtCardDetailsTransaction->getCardDetails()->getExpiryDate()->getMonth()->setValue($payment->getCcExpMonth());
|
332 |
-
}
|
333 |
-
if ($payment->getCcExpYear() != "")
|
334 |
-
{
|
335 |
-
$cdtCardDetailsTransaction->getCardDetails()->getExpiryDate()->getYear()->setValue($payment->getCcExpYear());
|
336 |
-
}
|
337 |
-
if ($payment->getCcSsStartMonth() != "")
|
338 |
-
{
|
339 |
-
$cdtCardDetailsTransaction->getCardDetails()->getStartDate()->getMonth()->setValue($payment->getCcSsStartMonth());
|
340 |
-
}
|
341 |
-
if ($payment->getCcSsStartYear() != "")
|
342 |
-
{
|
343 |
-
$cdtCardDetailsTransaction->getCardDetails()->getStartDate()->getYear()->setValue($payment->getCcSsStartYear());
|
344 |
-
}
|
345 |
-
|
346 |
-
$cdtCardDetailsTransaction->getCardDetails()->setIssueNumber($szIssueNumber);
|
347 |
-
$cdtCardDetailsTransaction->getCardDetails()->setCV2($szCV2);
|
348 |
-
|
349 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress1($szAddress1);
|
350 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress2($szAddress2);
|
351 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress3($szAddress3);
|
352 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress4($szAddress4);
|
353 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setCity($szCity);
|
354 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setState($szState);
|
355 |
-
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setPostCode($szPostCode);
|
356 |
|
357 |
$szCountryShort = $this->_getISO3Code($szISO2CountryCode);
|
358 |
if ($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
|
359 |
{
|
360 |
-
|
361 |
}
|
362 |
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
-
|
|
|
|
|
|
|
|
|
367 |
|
368 |
-
if ($
|
369 |
{
|
370 |
// could not communicate with the payment gateway
|
371 |
$error = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_261;
|
372 |
-
|
373 |
-
|
374 |
-
$error.= " [ ". $cdtCardDetailsTransaction->getLastException() . " ]";
|
375 |
-
}
|
376 |
-
|
377 |
-
$szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
|
378 |
Mage::log($szLogMessage);
|
379 |
-
Mage::log("Last exception: ".print_r($cdtCardDetailsTransaction->getLastException(), 1));
|
380 |
}
|
381 |
else
|
382 |
{
|
383 |
$szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Result details: ";
|
384 |
-
$szNotificationMessage = 'Payment Processor Response: '.$
|
385 |
-
$szCrossReference = $todTransactionOutputData->getCrossReference();
|
386 |
|
387 |
/* serve out the CrossReference as the TransactionId - this need to be done to enable the "Refund" button
|
388 |
in the Magento CreditMemo internal refund mechanism */
|
389 |
$payment->setTransactionId($szCrossReference);
|
390 |
|
391 |
-
switch ($
|
392 |
{
|
393 |
case 0:
|
394 |
// status code of 0 - means transaction successful
|
@@ -409,8 +534,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
409 |
$szLogMessage = "3D Secure Authentication required for OrderID: ".$szOrderID.". Response object: ";
|
410 |
$szNotificationMessage = '';
|
411 |
|
412 |
-
$szPaReq = $
|
413 |
-
$szACSURL = $
|
414 |
|
415 |
Mage::getSingleton('checkout/session')->setMd($szCrossReference)
|
416 |
->setAcsurl($szACSURL)
|
@@ -426,11 +551,20 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
426 |
break;
|
427 |
case 20:
|
428 |
// status code of 20 - means duplicate transaction
|
429 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
$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.". Response object: ";
|
431 |
$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;
|
432 |
|
433 |
-
if ($
|
434 |
{
|
435 |
$error = $szNotificationMessage;
|
436 |
}
|
@@ -441,19 +575,11 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
441 |
break;
|
442 |
case 30:
|
443 |
// status code of 30 - means an error occurred
|
444 |
-
$
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
for ($LoopIndex = 0; $LoopIndex < $cdtrCardDetailsTransactionResult->getErrorMessages()->getCount(); $LoopIndex++)
|
451 |
-
{
|
452 |
-
$szLogMessage = $szLogMessage.$cdtrCardDetailsTransactionResult->getErrorMessages()->getAt($LoopIndex).";";
|
453 |
-
}
|
454 |
-
$szLogMessage = $szLogMessage." ";
|
455 |
-
}
|
456 |
-
$szLogMessage = $szLogMessage.' Response object: ';
|
457 |
break;
|
458 |
default:
|
459 |
// unhandled status code
|
@@ -461,7 +587,7 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
461 |
break;
|
462 |
}
|
463 |
|
464 |
-
$szLogMessage = $szLogMessage.print_r($
|
465 |
Mage::log($szLogMessage);
|
466 |
}
|
467 |
|
@@ -833,23 +959,116 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
833 |
$Password = $this->getConfigData('password');
|
834 |
$SecretKey = $this->getConfigData('secretkey');
|
835 |
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
$rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
|
842 |
|
843 |
-
|
844 |
-
$
|
845 |
-
|
|
|
|
|
|
|
846 |
|
847 |
-
$tdsaThreeDSecureAuthentication->getThreeDSecureInputData()->setCrossReference($szMD);
|
848 |
-
$tdsaThreeDSecureAuthentication->getThreeDSecureInputData()->setPaRES($szPaRes);
|
849 |
|
850 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
851 |
|
852 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
{
|
854 |
// could not communicate with the payment gateway
|
855 |
$szLogMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_431;
|
@@ -858,16 +1077,14 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
858 |
}
|
859 |
else
|
860 |
{
|
861 |
-
$message = "Payment Processor Response: ".$
|
862 |
$szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Response object: ";
|
863 |
-
$szCrossReference = $todTransactionOutputData->getCrossReference();
|
864 |
|
865 |
-
switch ($
|
866 |
{
|
867 |
case 0:
|
868 |
// status code of 0 - means transaction successful
|
869 |
$szLogMessage = "3D Secure transaction successfully completed for OrderID: ".$szOrderID.". Response object: ";
|
870 |
-
|
871 |
// serve out the CrossReference as a TransactionId in the Magento system
|
872 |
$this->setPaymentAdditionalInformation($payment, $szCrossReference);
|
873 |
|
@@ -880,10 +1097,20 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
880 |
break;
|
881 |
case 20:
|
882 |
// status code of 20 - means duplicate transaction
|
883 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
$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.". Response object: ";
|
885 |
|
886 |
-
if ($
|
887 |
{
|
888 |
$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;
|
889 |
}
|
@@ -895,19 +1122,16 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
895 |
case 30:
|
896 |
$error = true;
|
897 |
// status code of 30 - means an error occurred
|
898 |
-
|
899 |
-
|
|
|
|
|
|
|
|
|
900 |
{
|
901 |
$szLogMessage = $szLogMessage.".";
|
902 |
-
$message
|
903 |
-
|
904 |
-
for ($LoopIndex = 0; $LoopIndex < $tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount(); $LoopIndex++)
|
905 |
-
{
|
906 |
-
$szLogMessage = $szLogMessage.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
|
907 |
-
$message = $message.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
|
908 |
-
}
|
909 |
-
$szLogMessage = $szLogMessage." ";
|
910 |
-
$message = $message." ";
|
911 |
}
|
912 |
break;
|
913 |
default:
|
@@ -917,7 +1141,7 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
917 |
}
|
918 |
|
919 |
// log 3DS payment result
|
920 |
-
$szLogMessage = $szLogMessage.print_r($
|
921 |
Mage::log($szLogMessage);
|
922 |
}
|
923 |
|
@@ -1233,6 +1457,9 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
1233 |
*/
|
1234 |
public function refund(Varien_Object $payment, $amount)
|
1235 |
{
|
|
|
|
|
|
|
1236 |
$error = false;
|
1237 |
$szTransactionType = "REFUND";
|
1238 |
$orderStatus = 'csv_refunded';
|
@@ -1278,6 +1505,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
1278 |
*/
|
1279 |
public function csvVoid(Varien_Object $payment)
|
1280 |
{
|
|
|
|
|
1281 |
$error = false;
|
1282 |
$szTransactionType = "VOID";
|
1283 |
$orderStatus = "csv_voided";
|
@@ -1484,44 +1713,199 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
1484 |
|
1485 |
if($error === false)
|
1486 |
{
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
|
|
1497 |
|
1498 |
-
|
1499 |
$power = pow(10, $icISOCurrency->getExponent());
|
1500 |
$nAmount = round($order->getGrandTotal() * $power,0);
|
1501 |
} else {
|
1502 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1503 |
}
|
1504 |
|
1505 |
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
1506 |
-
if ($szCurrencyShort != '' &&
|
1507 |
-
$iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
1508 |
{
|
1509 |
$nCurrencyCode = new CSV_NullableInt($icISOCurrency->getISOCode());
|
1510 |
-
|
1511 |
}
|
1512 |
|
1513 |
// round the amount before use
|
1514 |
//$nDecimalAmount = $this->_getRoundedAmount($nAmount, $icISOCurrency->getExponent());
|
1515 |
-
|
1516 |
-
$crtCrossReferenceTransaction->getTransactionDetails()->setOrderID($szOrderID);
|
1517 |
-
$crtCrossReferenceTransaction->getTransactionDetails()->getAmount()->setValue($nAmount);
|
1518 |
-
|
1519 |
-
$crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setCrossReference($szCrossReference);
|
1520 |
-
$crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
|
1521 |
-
|
1522 |
try
|
1523 |
{
|
1524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1525 |
}
|
1526 |
catch (Exception $exc)
|
1527 |
{
|
@@ -1531,35 +1915,26 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
|
|
1531 |
if ($boTransactionProcessed == false)
|
1532 |
{
|
1533 |
// could not communicate with the payment gateway
|
1534 |
-
$error = "Couldn't complete ".$szTransactionType." transaction.
|
1535 |
$szLogMessage = $error;
|
1536 |
}
|
1537 |
else
|
1538 |
{
|
1539 |
-
switch($
|
1540 |
{
|
1541 |
case 0:
|
1542 |
$error = false;
|
1543 |
-
$szNewCrossReference = $
|
1544 |
$szLogMessage = $szTransactionType . " CrossReference transaction successfully completed. Response object: ";
|
1545 |
|
1546 |
$payment->setTransactionId($szNewCrossReference)
|
1547 |
-
->setParentTransactionId($
|
1548 |
->setIsTransactionClosed(1);
|
1549 |
$payment->save();
|
1550 |
break;
|
1551 |
default:
|
1552 |
-
$szLogMessage = $
|
1553 |
-
|
1554 |
-
{
|
1555 |
-
$szLogMessage = $szLogMessage.".";
|
1556 |
-
|
1557 |
-
for ($LoopIndex = 0; $LoopIndex < $crtrCrossReferenceTransactionResult->getErrorMessages()->getCount(); $LoopIndex++)
|
1558 |
-
{
|
1559 |
-
$szLogMessage = $szLogMessage.$crtrCrossReferenceTransactionResult->getErrorMessages()->getAt($LoopIndex).";";
|
1560 |
-
}
|
1561 |
-
$szLogMessage = $szLogMessage." ";
|
1562 |
-
}
|
1563 |
|
1564 |
$error = "Couldn't complete ".$szTransactionType." transaction for CrossReference: " . $szCrossReference . ". Payment Response: ".$szLogMessage;
|
1565 |
$szLogMessage = $szTransactionType . " CrossReference transaction failed. Response object: ";
|
5 |
include_once ("Common/PaymentFormHelper.php");
|
6 |
include_once ("Common/ISOCurrencies.php");
|
7 |
include_once ("Common/ISOCountries.php");
|
8 |
+
// include some CardSave functions
|
9 |
+
include_once ("CommonFunctions.php");
|
10 |
} else {
|
11 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ThePaymentGateway_PaymentSystem.php");
|
12 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_PaymentFormHelper.php");
|
13 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ISOCurrencies.php");
|
14 |
include_once ("Cardsave_Cardsaveonlinepayments_Model_Common_ISOCountries.php");
|
15 |
+
include_once ("Cardsave_Cardsaveonlinepayments_Model_CommonFunctions.php");
|
16 |
}
|
17 |
|
18 |
class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
231 |
// assign payment form field values to variables
|
232 |
$order = $payment->getOrder();
|
233 |
$szOrderID = $payment->getOrder()->increment_id;
|
234 |
+
$szOrderDescription = Mage::app()->getStore()->getName();
|
235 |
$szCardName = $payment->getCcOwner();
|
236 |
$szCardNumber = $payment->getCcNumber();
|
237 |
$szIssueNumber = $payment->getCcSsIssue();
|
254 |
$nDecimalAmount;
|
255 |
$szTransactionType;
|
256 |
|
|
|
257 |
$iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
|
258 |
$iclISOCountryList = CSV_ISOCountries::getISOCountryList();
|
259 |
|
260 |
+
|
|
|
|
|
|
|
261 |
|
262 |
$paymentAction = $this->getConfigData('payment_action');
|
263 |
if($paymentAction == Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE)
|
273 |
Mage::throwException('Unknown payment action: '.$paymentAction);
|
274 |
}
|
275 |
|
276 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
if (!$takePaymentInStoreBaseCurrency) {
|
278 |
// Take payment in order currency
|
279 |
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
280 |
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
281 |
{
|
282 |
$nCurrencyCode = $icISOCurrency->getISOCode();
|
283 |
+
|
284 |
}
|
285 |
|
286 |
// Calculate amount
|
293 |
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
294 |
{
|
295 |
$nCurrencyCode = $icISOCurrency->getISOCode();
|
296 |
+
|
297 |
}
|
298 |
|
299 |
// Calculate amount
|
300 |
$nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
|
301 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
$szCountryShort = $this->_getISO3Code($szISO2CountryCode);
|
304 |
if ($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
|
305 |
{
|
306 |
+
|
307 |
}
|
308 |
|
309 |
+
|
310 |
+
////////////////////////////////////////////////////////////////////////////
|
311 |
+
////////////////////////////////////////////////////////////////////////////
|
312 |
+
/* php 5.4 fix */
|
313 |
+
////////////////////////////////////////////////////////////////////////////
|
314 |
+
////////////////////////////////////////////////////////////////////////////
|
315 |
+
|
316 |
+
|
317 |
+
//set transaction process to false and only to true if we have communicated
|
318 |
+
$boTransactionProcessed = false;
|
319 |
+
|
320 |
+
|
321 |
+
// Populate the variables from the shopping cart, which will then be used for the XML later
|
322 |
+
// Only change the varibles on the right hand side with the values from the shopping cart.
|
323 |
+
$MerchantID = $MerchantID;
|
324 |
+
$Password = $Password;
|
325 |
+
|
326 |
+
$Amount = $nAmount;
|
327 |
+
$CurrencyCode = $icISOCurrency->getISOCode();
|
328 |
+
$OrderID = $szOrderID;
|
329 |
+
$OrderDescription = $szOrderDescription;
|
330 |
+
$TransactionType = $szTransactionType;
|
331 |
+
|
332 |
+
$CardName = $szCardName;
|
333 |
+
$CardNumber = $szCardNumber;
|
334 |
+
$ExpMonth = $payment->getCcExpMonth();
|
335 |
+
$ExpYear = $payment->getCcExpYear();
|
336 |
+
$CV2 = $szCV2;
|
337 |
+
$IssueNumber = $szIssueNumber;
|
338 |
+
|
339 |
+
$Address1 = $szAddress1;
|
340 |
+
$Address2 = $szAddress2;
|
341 |
+
$Address3 = $szAddress3;
|
342 |
+
$Address4 = $szAddress4;
|
343 |
+
$City = $szCity;
|
344 |
+
$State = $szState;
|
345 |
+
$Postcode = $szPostCode;
|
346 |
+
$CountryCode = $icISOCountry->getISOCode();
|
347 |
+
|
348 |
+
$EmailAddress = $szEmailAddress;
|
349 |
+
$PhoneNumber = $szPhoneNumber;
|
350 |
+
$IPAddress = $_SERVER['REMOTE_ADDR'];
|
351 |
+
|
352 |
+
|
353 |
+
|
354 |
+
//XML Headers used in cURL - payment processor domain is set later.... DO NOT ALTER THIS.
|
355 |
+
$headers = array(
|
356 |
+
'SOAPAction:https://www.thepaymentgateway.net/CardDetailsTransaction',
|
357 |
+
'Content-Type: text/xml; charset = utf-8',
|
358 |
+
'Connection: close'
|
359 |
+
);
|
360 |
+
|
361 |
+
//XML to send to the Gateway. Clean it up and make sure it doesnt exceed the characters allowed
|
362 |
+
$xml = '<?xml version="1.0" encoding="utf-8"?>
|
363 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
364 |
+
<soap:Body>
|
365 |
+
<CardDetailsTransaction xmlns="https://www.thepaymentgateway.net/">
|
366 |
+
<PaymentMessage>
|
367 |
+
<MerchantAuthentication MerchantID="'. trim($MerchantID) .'" Password="'. trim($Password) .'" />
|
368 |
+
<TransactionDetails Amount="'. $Amount .'" CurrencyCode="'. $CurrencyCode .'">
|
369 |
+
<MessageDetails TransactionType="'.$TransactionType.'" />
|
370 |
+
<OrderID>'. clean($OrderID, 50) .'</OrderID>
|
371 |
+
<OrderDescription>'. clean($OrderDescription, 256) . '</OrderDescription>
|
372 |
+
<TransactionControl>
|
373 |
+
<EchoCardType>TRUE</EchoCardType>
|
374 |
+
<EchoAVSCheckResult>TRUE</EchoAVSCheckResult>
|
375 |
+
<EchoCV2CheckResult>TRUE</EchoCV2CheckResult>
|
376 |
+
<EchoAmountReceived>TRUE</EchoAmountReceived>
|
377 |
+
<DuplicateDelay>20</DuplicateDelay>
|
378 |
+
<CustomVariables>
|
379 |
+
<GenericVariable Name="MyInputVariable" Value="Ping" />
|
380 |
+
</CustomVariables>
|
381 |
+
</TransactionControl>
|
382 |
+
</TransactionDetails>
|
383 |
+
<CardDetails>
|
384 |
+
<CardName>'. clean($CardName, 100) .'</CardName>
|
385 |
+
<CardNumber>'. $CardNumber .'</CardNumber>
|
386 |
+
<StartDate Month="" Year="" />
|
387 |
+
<ExpiryDate Month="'. $ExpMonth .'" Year="'. $ExpYear .'" />
|
388 |
+
<CV2>'. $CV2 .'</CV2>
|
389 |
+
<IssueNumber>'. $IssueNumber .'</IssueNumber>
|
390 |
+
</CardDetails>
|
391 |
+
<CustomerDetails>
|
392 |
+
<BillingAddress>
|
393 |
+
<Address1>'. clean($Address1, 100) .'</Address1>
|
394 |
+
<Address2>'. clean($Address2, 50) .'</Address2>
|
395 |
+
<Address3>'. clean($Address3, 50) .'</Address3>
|
396 |
+
<Address4>'. clean($Address4, 50) .'</Address4>
|
397 |
+
<City>'. clean($City, 50) .'</City>
|
398 |
+
<State>'. clean($State, 50) .'</State>
|
399 |
+
<PostCode>'. clean($Postcode, 50) .'</PostCode>
|
400 |
+
<CountryCode>'. $CountryCode .'</CountryCode>
|
401 |
+
</BillingAddress>
|
402 |
+
<EmailAddress>'. clean($EmailAddress, 100) .'</EmailAddress>
|
403 |
+
<PhoneNumber>'. clean($PhoneNumber, 30) .'</PhoneNumber>
|
404 |
+
<CustomerIPAddress>'. $IPAddress .'</CustomerIPAddress>
|
405 |
+
</CustomerDetails>
|
406 |
+
<PassOutData>Some data to be passed out</PassOutData>
|
407 |
+
</PaymentMessage>
|
408 |
+
</CardDetailsTransaction>
|
409 |
+
</soap:Body>
|
410 |
+
</soap:Envelope>';
|
411 |
+
|
412 |
+
//set up the gateway configuration for CardSave
|
413 |
+
$gwId = 1;
|
414 |
+
$domain = "cardsaveonlinepayments.com";
|
415 |
+
$port = "4430";
|
416 |
+
$transattempt = 1;
|
417 |
+
$soapSuccess = false;
|
418 |
+
|
419 |
+
while(!$soapSuccess && $gwId <= 3 && $transattempt <= 3) {
|
420 |
+
|
421 |
+
//builds the URL to post to (rather than it being hard coded - means we can loop through all 3 gateway servers)
|
422 |
+
$url = 'https://gw'.$gwId.'.'.$domain.':'.$port.'/';
|
423 |
+
|
424 |
+
//initialise cURL
|
425 |
+
$curl = curl_init();
|
426 |
+
|
427 |
+
//set the options
|
428 |
+
curl_setopt($curl, CURLOPT_HEADER, false);
|
429 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
430 |
+
curl_setopt($curl, CURLOPT_POST, true);
|
431 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
432 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
|
433 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
434 |
+
curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');
|
435 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
436 |
+
|
437 |
+
//Execute cURL request
|
438 |
+
//$ret = returned XML
|
439 |
+
$ret = curl_exec($curl);
|
440 |
+
//$err = returned error number
|
441 |
+
$err = curl_errno($curl);
|
442 |
+
//retHead = returned XML header
|
443 |
+
$retHead = curl_getinfo($curl);
|
444 |
+
|
445 |
+
//echo "<pre><xmp>" .$ret. "</xmp></pre>";
|
446 |
+
|
447 |
+
//close cURL connection
|
448 |
+
curl_close($curl);
|
449 |
+
$curl = null;
|
450 |
+
|
451 |
+
//if no error returned
|
452 |
+
if($err == 0) {
|
453 |
+
//Get the status code
|
454 |
+
$StatusCode = GetXMLValue("StatusCode", $ret, "[0-9]+");
|
455 |
+
|
456 |
+
// if error occured... return the reason to the user
|
457 |
+
if($StatusCode == 30){
|
458 |
+
$szMessageDetail = GetXMLValue("Detail", $ret, ".+");
|
459 |
+
|
460 |
+
//run the function to get the cause of the error
|
461 |
+
$CustomerMessage = getErrorFromGateway($szMessageDetail, $ret);
|
462 |
+
}
|
463 |
+
|
464 |
+
if(is_numeric($StatusCode)) {
|
465 |
+
//request was processed correctly
|
466 |
+
|
467 |
+
//set success flag so it will not run the request again.
|
468 |
+
$soapSuccess = true;
|
469 |
+
|
470 |
+
//grab some of the most commonly used information from the response
|
471 |
+
$szMessage = GetXMLValue("Message", $ret, ".+");
|
472 |
+
$szAuthCode = GetXMLValue("AuthCode", $ret, ".+");
|
473 |
+
$szCrossReference = GetCrossReference($ret);
|
474 |
+
$szAddressNumericCheckResult = GetXMLValue("AddressNumericCheckResult", $ret, ".+");
|
475 |
+
$szPostCodeCheckResult = GetXMLValue("PostCodeCheckResult", $ret, ".+");
|
476 |
+
$szCV2CheckResult = GetXMLValue("CV2CheckResult", $ret, ".+");
|
477 |
+
$szThreeDSecureAuthenticationCheckResult = GetXMLValue("ThreeDSecureAuthenticationCheckResult", $ret, ".+");
|
478 |
+
|
479 |
+
$securityChecks = "<br />Address Check: $szAddressNumericCheckResult | Post Code Check: $szPostCodeCheckResult | CV2 Check: $szCV2CheckResult | 3D Secure Check: $szThreeDSecureAuthenticationCheckResult";
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
// attempt to communicate was unsuccessful... increment the transaction attempt if <=2
|
484 |
+
if($transattempt <=2) {
|
485 |
+
$transattempt++;
|
486 |
+
} else {
|
487 |
+
//reset transaction attempt to 1 & incremend $gwID (to use next numeric gateway number (eg. use gw2 rather than gw1 now))
|
488 |
+
$transattempt = 1;
|
489 |
+
$gwId++;
|
490 |
+
}
|
491 |
+
}
|
492 |
|
493 |
+
////////////////////////////////////////////////////////////////////////////
|
494 |
+
////////////////////////////////////////////////////////////////////////////
|
495 |
+
/* end php 5.4 fix */
|
496 |
+
////////////////////////////////////////////////////////////////////////////
|
497 |
+
////////////////////////////////////////////////////////////////////////////
|
498 |
|
499 |
+
if ($soapSuccess == false)
|
500 |
{
|
501 |
// could not communicate with the payment gateway
|
502 |
$error = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_261;
|
503 |
+
|
504 |
+
$szLogMessage = "Couldn't complete transaction. Unable to communicate with the payment gateway."; //"Couldn't communicate with payment gateway.";
|
|
|
|
|
|
|
|
|
505 |
Mage::log($szLogMessage);
|
|
|
506 |
}
|
507 |
else
|
508 |
{
|
509 |
$szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Result details: ";
|
510 |
+
$szNotificationMessage = 'Payment Processor Response: '.$szMessage;
|
|
|
511 |
|
512 |
/* serve out the CrossReference as the TransactionId - this need to be done to enable the "Refund" button
|
513 |
in the Magento CreditMemo internal refund mechanism */
|
514 |
$payment->setTransactionId($szCrossReference);
|
515 |
|
516 |
+
switch ($StatusCode)
|
517 |
{
|
518 |
case 0:
|
519 |
// status code of 0 - means transaction successful
|
534 |
$szLogMessage = "3D Secure Authentication required for OrderID: ".$szOrderID.". Response object: ";
|
535 |
$szNotificationMessage = '';
|
536 |
|
537 |
+
$szPaReq = GetXMLValue("PaREQ", $ret, ".+");
|
538 |
+
$szACSURL = GetXMLValue("ACSURL", $ret, ".+");
|
539 |
|
540 |
Mage::getSingleton('checkout/session')->setMd($szCrossReference)
|
541 |
->setAcsurl($szACSURL)
|
551 |
break;
|
552 |
case 20:
|
553 |
// status code of 20 - means duplicate transaction
|
554 |
+
$soapPreviousTransactionResult = null;
|
555 |
+
$PreviousTransactionResult = null;
|
556 |
+
if (preg_match('#<PreviousTransactionResult>(.+)</PreviousTransactionResult>#iU', $ret, $soapPreviousTransactionResult)) {
|
557 |
+
$PreviousTransactionResult = $soapPreviousTransactionResult[1];
|
558 |
+
|
559 |
+
$PreviousMessage = GetXMLValue("Message", $PreviousTransactionResult, ".+");
|
560 |
+
$PreviousStatusCode = GetXMLValue("StatusCode", $PreviousTransactionResult, ".+");
|
561 |
+
}
|
562 |
+
|
563 |
+
$szPreviousTransactionMessage = $PreviousMessage;
|
564 |
$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.". Response object: ";
|
565 |
$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;
|
566 |
|
567 |
+
if ($PreviousStatusCode != 0)
|
568 |
{
|
569 |
$error = $szNotificationMessage;
|
570 |
}
|
575 |
break;
|
576 |
case 30:
|
577 |
// status code of 30 - means an error occurred
|
578 |
+
$CustomerMessage = getErrorFromGateway($szMessageDetail, $ret);
|
579 |
+
|
580 |
+
$error = $szNotificationMessage . ".\nReason: " . $CustomerMessage;
|
581 |
+
$szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$CustomerMessage;
|
582 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
break;
|
584 |
default:
|
585 |
// unhandled status code
|
587 |
break;
|
588 |
}
|
589 |
|
590 |
+
$szLogMessage = $szLogMessage.print_r($ret, 1);
|
591 |
Mage::log($szLogMessage);
|
592 |
}
|
593 |
|
959 |
$Password = $this->getConfigData('password');
|
960 |
$SecretKey = $this->getConfigData('secretkey');
|
961 |
|
962 |
+
//////////////////////////////////////////////
|
963 |
+
//////////////////////////////////////////////
|
964 |
+
// PHP 5.4 fix //
|
965 |
+
//////////////////////////////////////////////
|
966 |
+
//////////////////////////////////////////////
|
|
|
967 |
|
968 |
+
//XML Headers used in cURL - remember to change the function after thepaymentgateway.net in SOAPAction when changing the XML to call a different function
|
969 |
+
$headers = array(
|
970 |
+
'SOAPAction:https://www.thepaymentgateway.net/ThreeDSecureAuthentication',
|
971 |
+
'Content-Type: text/xml; charset = utf-8',
|
972 |
+
'Connection: close'
|
973 |
+
);
|
974 |
|
|
|
|
|
975 |
|
976 |
+
//XML to send to the Gateway - put your merchant ID & Password in the appropriate place.
|
977 |
+
$xml = '<?xml version="1.0" encoding="utf-8"?>
|
978 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
979 |
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
980 |
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
981 |
+
<soap:Body>
|
982 |
+
<ThreeDSecureAuthentication xmlns="https://www.thepaymentgateway.net/">
|
983 |
+
<ThreeDSecureMessage>
|
984 |
+
<MerchantAuthentication MerchantID="'. trim($MerchantID) .'" Password="'. trim($Password) .'" />
|
985 |
+
<ThreeDSecureInputData CrossReference="'. $szMD .'">
|
986 |
+
<PaRES>'. $szPaRes .'</PaRES>
|
987 |
+
</ThreeDSecureInputData>
|
988 |
+
<PassOutData>Some data to be passed out</PassOutData>
|
989 |
+
</ThreeDSecureMessage>
|
990 |
+
</ThreeDSecureAuthentication>
|
991 |
+
</soap:Body>
|
992 |
+
</soap:Envelope>';
|
993 |
+
|
994 |
+
$gwId = 1;
|
995 |
+
$domain = "cardsaveonlinepayments.com";
|
996 |
+
$port = "4430";
|
997 |
+
$transattempt = 1;
|
998 |
+
$soapSuccess = false;
|
999 |
+
|
1000 |
|
1001 |
+
//It will attempt each of the gateway servers (gw1, gw2 & gw3) 3 times each before totally failing
|
1002 |
+
while(!$soapSuccess && $gwId <= 3 && $transattempt <= 3) {
|
1003 |
+
|
1004 |
+
//builds the URL to post to (rather than it being hard coded - means we can loop through all 3 gateway servers)
|
1005 |
+
$url = 'https://gw'.$gwId.'.'.$domain.':'.$port.'/';
|
1006 |
+
|
1007 |
+
//initialise cURL
|
1008 |
+
$curl = curl_init();
|
1009 |
+
|
1010 |
+
//set the options
|
1011 |
+
curl_setopt($curl, CURLOPT_HEADER, false);
|
1012 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
1013 |
+
curl_setopt($curl, CURLOPT_POST, true);
|
1014 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
1015 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
|
1016 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
1017 |
+
curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');
|
1018 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
1019 |
+
|
1020 |
+
//Execute cURL request
|
1021 |
+
//$ret = returned XML
|
1022 |
+
$ret = curl_exec($curl);
|
1023 |
+
//$err = returned error number
|
1024 |
+
$err = curl_errno($curl);
|
1025 |
+
//retHead = returned XML header
|
1026 |
+
$retHead = curl_getinfo($curl);
|
1027 |
+
|
1028 |
+
//close cURL connection
|
1029 |
+
curl_close($curl);
|
1030 |
+
$curl = null;
|
1031 |
+
|
1032 |
+
//if no error returned
|
1033 |
+
if($err == 0) {
|
1034 |
+
//Get the status code
|
1035 |
+
$StatusCode = GetXMLValue("StatusCode", $ret, "[0-9]+");
|
1036 |
+
|
1037 |
+
if(is_numeric($StatusCode)) {
|
1038 |
+
//request was processed correctly
|
1039 |
+
if( $StatusCode != 30 ) {
|
1040 |
+
//set success flag so it will not run the request again.
|
1041 |
+
$soapSuccess = true;
|
1042 |
+
|
1043 |
+
$szMessage = GetXMLValue("Message", $ret, ".+");
|
1044 |
+
$szCrossReference = GetCrossReference($ret);
|
1045 |
+
$szAddressNumericCheckResult = GetXMLValue("AddressNumericCheckResult", $ret, ".+");
|
1046 |
+
$szPostCodeCheckResult = GetXMLValue("PostCodeCheckResult", $ret, ".+");
|
1047 |
+
$szCV2CheckResult = GetXMLValue("CV2CheckResult", $ret, ".+");
|
1048 |
+
$szThreeDSecureAuthenticationCheckResult = GetXMLValue("ThreeDSecureAuthenticationCheckResult", $ret, ".+");
|
1049 |
+
|
1050 |
+
$securityChecks = "<br />Address Check: $szAddressNumericCheckResult | Post Code Check: $szPostCodeCheckResult | CV2 Check: $szCV2CheckResult | 3D Secure Check: $szThreeDSecureAuthenticationCheckResult";
|
1051 |
+
}
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
//increment the transaction attempt if <=2
|
1056 |
+
if($transattempt <=2) {
|
1057 |
+
$transattempt++;
|
1058 |
+
} else {
|
1059 |
+
//reset transaction attempt to 1 & incremend $gwID (to use next numeric gateway number (eg. use gw2 rather than gw1 now))
|
1060 |
+
$transattempt = 1;
|
1061 |
+
$gwId++;
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
//////////////////////////////////////////////
|
1066 |
+
//////////////////////////////////////////////
|
1067 |
+
// end php 5.4 fix //
|
1068 |
+
//////////////////////////////////////////////
|
1069 |
+
//////////////////////////////////////////////
|
1070 |
+
|
1071 |
+
if ($soapSuccess == false)
|
1072 |
{
|
1073 |
// could not communicate with the payment gateway
|
1074 |
$szLogMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_431;
|
1077 |
}
|
1078 |
else
|
1079 |
{
|
1080 |
+
$message = "Payment Processor Response: ".$szMessage;
|
1081 |
$szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Response object: ";
|
|
|
1082 |
|
1083 |
+
switch ($StatusCode)
|
1084 |
{
|
1085 |
case 0:
|
1086 |
// status code of 0 - means transaction successful
|
1087 |
$szLogMessage = "3D Secure transaction successfully completed for OrderID: ".$szOrderID.". Response object: ";
|
|
|
1088 |
// serve out the CrossReference as a TransactionId in the Magento system
|
1089 |
$this->setPaymentAdditionalInformation($payment, $szCrossReference);
|
1090 |
|
1097 |
break;
|
1098 |
case 20:
|
1099 |
// status code of 20 - means duplicate transaction
|
1100 |
+
$soapPreviousTransactionResult = null;
|
1101 |
+
$PreviousTransactionResult = null;
|
1102 |
+
if (preg_match('#<PreviousTransactionResult>(.+)</PreviousTransactionResult>#iU', $ret, $soapPreviousTransactionResult)) {
|
1103 |
+
$PreviousTransactionResult = $soapPreviousTransactionResult[1];
|
1104 |
+
|
1105 |
+
$PreviousMessage = GetXMLValue("Message", $PreviousTransactionResult, ".+");
|
1106 |
+
$PreviousStatusCode = GetXMLValue("StatusCode", $PreviousTransactionResult, ".+");
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
|
1110 |
+
$szPreviousTransactionMessage = $PreviousMessage;
|
1111 |
$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.". Response object: ";
|
1112 |
|
1113 |
+
if ($PreviousStatusCode == 0)
|
1114 |
{
|
1115 |
$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;
|
1116 |
}
|
1122 |
case 30:
|
1123 |
$error = true;
|
1124 |
// status code of 30 - means an error occurred
|
1125 |
+
|
1126 |
+
// status code of 30 - means an error occurred
|
1127 |
+
$CustomerMessage = getErrorFromGateway($szMessageDetail, $ret);
|
1128 |
+
|
1129 |
+
$szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$CustomerMessage;
|
1130 |
+
|
1131 |
{
|
1132 |
$szLogMessage = $szLogMessage.".";
|
1133 |
+
$message = $message.".";
|
1134 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1135 |
}
|
1136 |
break;
|
1137 |
default:
|
1141 |
}
|
1142 |
|
1143 |
// log 3DS payment result
|
1144 |
+
$szLogMessage = $szLogMessage.print_r($ret, 1);
|
1145 |
Mage::log($szLogMessage);
|
1146 |
}
|
1147 |
|
1457 |
*/
|
1458 |
public function refund(Varien_Object $payment, $amount)
|
1459 |
{
|
1460 |
+
|
1461 |
+
//Mage::throwException('This payment module does not support refunds. Please refund from within the Merchant Management System.');
|
1462 |
+
|
1463 |
$error = false;
|
1464 |
$szTransactionType = "REFUND";
|
1465 |
$orderStatus = 'csv_refunded';
|
1505 |
*/
|
1506 |
public function csvVoid(Varien_Object $payment)
|
1507 |
{
|
1508 |
+
//Mage::throwException('This payment module does not support voiding transactions. Please void transactions from within the Merchant Management System.');
|
1509 |
+
|
1510 |
$error = false;
|
1511 |
$szTransactionType = "VOID";
|
1512 |
$orderStatus = "csv_voided";
|
1713 |
|
1714 |
if($error === false)
|
1715 |
{
|
1716 |
+
|
1717 |
+
if (!$takePaymentInStoreBaseCurrency) {
|
1718 |
+
|
1719 |
+
// Take payment in order currency
|
1720 |
+
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
1721 |
+
|
1722 |
+
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
1723 |
+
{
|
1724 |
+
$nCurrencyCode = $icISOCurrency->getISOCode();
|
1725 |
+
|
1726 |
+
}
|
1727 |
|
1728 |
+
// Calculate amount
|
1729 |
$power = pow(10, $icISOCurrency->getExponent());
|
1730 |
$nAmount = round($order->getGrandTotal() * $power,0);
|
1731 |
} else {
|
1732 |
+
// Take payment in site base currency
|
1733 |
+
//$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
1734 |
+
$szCurrencyShort = $order->getBaseCurrencyCode();
|
1735 |
+
|
1736 |
+
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
1737 |
+
{
|
1738 |
+
$nCurrencyCode = $icISOCurrency->getISOCode();
|
1739 |
+
|
1740 |
+
}
|
1741 |
+
|
1742 |
+
$nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
|
1743 |
}
|
1744 |
|
1745 |
$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
|
1746 |
+
if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
|
|
|
1747 |
{
|
1748 |
$nCurrencyCode = new CSV_NullableInt($icISOCurrency->getISOCode());
|
1749 |
+
|
1750 |
}
|
1751 |
|
1752 |
// round the amount before use
|
1753 |
//$nDecimalAmount = $this->_getRoundedAmount($nAmount, $icISOCurrency->getExponent());
|
1754 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1755 |
try
|
1756 |
{
|
1757 |
+
|
1758 |
+
|
1759 |
+
///////////////////////////////////////////////
|
1760 |
+
/// PHP 5.4 fix ///
|
1761 |
+
///////////////////////////////////////////////
|
1762 |
+
|
1763 |
+
//set up the variables
|
1764 |
+
$CrossReference = $szCrossReference; //CrossReference of Original Transaction
|
1765 |
+
|
1766 |
+
$Amount = $nAmount; //Amount to charge in this new transaction
|
1767 |
+
$OrderID = $szOrderID; //Order ID for this new transaction
|
1768 |
+
$OrderDescription = $szTransactionType . " for Order: " .$OrderID; //Order Description for this new transaction
|
1769 |
+
$ThreeDEnabled = "FALSE"; //False will turn off 3DS, it should be disabled for customer not present transactions (recurring payments).
|
1770 |
+
$IPAddress = $_SERVER['REMOTE_ADDR'];
|
1771 |
+
$TransactionType = $szTransactionType; //type of transaction
|
1772 |
+
$CurrencyCode = $nCurrencyCode; //currency type
|
1773 |
+
|
1774 |
+
//XML Headers used in cURL - remember to change the function after thepaymentgateway.net in SOAPAction when changing the XML to call a different function
|
1775 |
+
$headers = array(
|
1776 |
+
'SOAPAction:https://www.thepaymentgateway.net/CrossReferenceTransaction',
|
1777 |
+
'Content-Type: text/xml; charset = utf-8',
|
1778 |
+
'Connection: close'
|
1779 |
+
);
|
1780 |
+
|
1781 |
+
|
1782 |
+
//XML to send to the Gateway
|
1783 |
+
$xml = '<?xml version="1.0" encoding="utf-8"?>
|
1784 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
1785 |
+
<soap:Body>
|
1786 |
+
<CrossReferenceTransaction xmlns="https://www.thepaymentgateway.net/">
|
1787 |
+
<PaymentMessage>
|
1788 |
+
<MerchantAuthentication MerchantID="'. trim($szMerchantID) .'" Password="'. trim($szPassword) . '" />
|
1789 |
+
<TransactionDetails Amount="'. $Amount .'" CurrencyCode="'. $CurrencyCode .'">
|
1790 |
+
<MessageDetails TransactionType="'. $TransactionType .'" NewTransaction="FALSE" CrossReference="'. $CrossReference .'" />
|
1791 |
+
<OrderID>'. $OrderID .'</OrderID>
|
1792 |
+
<OrderDescription>'. $OrderDescription .'</OrderDescription>
|
1793 |
+
<TransactionControl>
|
1794 |
+
<EchoCardType>TRUE</EchoCardType>
|
1795 |
+
<EchoAVSCheckResult>TRUE</EchoAVSCheckResult>
|
1796 |
+
<EchoCV2CheckResult>TRUE</EchoCV2CheckResult>
|
1797 |
+
<EchoAmountReceived>TRUE</EchoAmountReceived>
|
1798 |
+
<DuplicateDelay>60</DuplicateDelay>
|
1799 |
+
<ThreeDSecureOverridePolicy>'. $ThreeDEnabled .'</ThreeDSecureOverridePolicy>
|
1800 |
+
<CustomVariables>
|
1801 |
+
<GenericVariable Name="MyInputVariable" Value="Ping" />
|
1802 |
+
</CustomVariables>
|
1803 |
+
</TransactionControl>
|
1804 |
+
</TransactionDetails>
|
1805 |
+
<CustomerDetails>
|
1806 |
+
<CustomerIPAddress>' . $IPAddress . '</CustomerIPAddress>
|
1807 |
+
</CustomerDetails>
|
1808 |
+
<PassOutData>Some data to be passed out</PassOutData>
|
1809 |
+
</PaymentMessage>
|
1810 |
+
</CrossReferenceTransaction>
|
1811 |
+
</soap:Body>
|
1812 |
+
</soap:Envelope>';
|
1813 |
+
|
1814 |
+
|
1815 |
+
$gwId = 1;
|
1816 |
+
$domain = "cardsaveonlinepayments.com";
|
1817 |
+
$port = "4430";
|
1818 |
+
$transattempt = 1;
|
1819 |
+
$soapSuccess = false;
|
1820 |
+
|
1821 |
+
|
1822 |
+
//It will attempt each of the gateway servers (gw1, gw2 & gw3) 3 times each before totally failing
|
1823 |
+
while(!$soapSuccess && $gwId <= 3 && $transattempt <= 3) {
|
1824 |
+
|
1825 |
+
//builds the URL to post to (rather than it being hard coded - means we can loop through all 3 gateway servers)
|
1826 |
+
$url = 'https://gw'.$gwId.'.'.$domain.':'.$port.'/';
|
1827 |
+
|
1828 |
+
//initialise cURL
|
1829 |
+
$curl = curl_init();
|
1830 |
+
|
1831 |
+
//set the options
|
1832 |
+
curl_setopt($curl, CURLOPT_HEADER, false);
|
1833 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
1834 |
+
curl_setopt($curl, CURLOPT_POST, true);
|
1835 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
1836 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
|
1837 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
1838 |
+
curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');
|
1839 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
1840 |
+
|
1841 |
+
//Execute cURL request
|
1842 |
+
//$ret = returned XML
|
1843 |
+
$ret = curl_exec($curl);
|
1844 |
+
//$err = returned error number
|
1845 |
+
$err = curl_errno($curl);
|
1846 |
+
//retHead = returned XML header
|
1847 |
+
$retHead = curl_getinfo($curl);
|
1848 |
+
|
1849 |
+
//close cURL connection
|
1850 |
+
curl_close($curl);
|
1851 |
+
$curl = null;
|
1852 |
+
|
1853 |
+
//if no error returned
|
1854 |
+
if($err == 0) {
|
1855 |
+
//Get the status code
|
1856 |
+
$StatusCode = GetXMLValue("StatusCode", $ret, "[0-9]+");
|
1857 |
+
|
1858 |
+
if(is_numeric($StatusCode)) {
|
1859 |
+
//request was processed correctly
|
1860 |
+
if( $StatusCode != 50 ) {
|
1861 |
+
//set success flag so it will not run the request again.
|
1862 |
+
$soapSuccess = true;
|
1863 |
+
|
1864 |
+
$szMessage = GetXMLValue("Message", $ret, ".+");
|
1865 |
+
$szCrossReference = GetCrossReference($ret);
|
1866 |
+
$szAddressNumericCheckResult = GetXMLValue("AddressNumericCheckResult", $ret, ".+");
|
1867 |
+
$szPostCodeCheckResult = GetXMLValue("PostCodeCheckResult", $ret, ".+");
|
1868 |
+
$szCV2CheckResult = GetXMLValue("CV2CheckResult", $ret, ".+");
|
1869 |
+
$szThreeDSecureAuthenticationCheckResult = GetXMLValue("ThreeDSecureAuthenticationCheckResult", $ret, ".+");
|
1870 |
+
|
1871 |
+
switch ($StatusCode) {
|
1872 |
+
case 0:
|
1873 |
+
$boTransactionProcessed = true;
|
1874 |
+
break;
|
1875 |
+
|
1876 |
+
case 4:
|
1877 |
+
$boTransactionProcessed = true;
|
1878 |
+
break;
|
1879 |
+
case 5:
|
1880 |
+
//Card declined
|
1881 |
+
$boTransactionProcessed = true;
|
1882 |
+
break;
|
1883 |
+
case 20:
|
1884 |
+
$boTransactionProcessed = true;
|
1885 |
+
break;
|
1886 |
+
default:
|
1887 |
+
$szMessageDetail = GetXMLValue("Message", $ret, ".+");
|
1888 |
+
$boTransactionProcessed = true;
|
1889 |
+
break;
|
1890 |
+
}
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
}
|
1894 |
+
|
1895 |
+
//increment the transaction attempt if <=2
|
1896 |
+
if($transattempt <=2) {
|
1897 |
+
$transattempt++;
|
1898 |
+
} else {
|
1899 |
+
//reset transaction attempt to 1 & increment $gwID (to use next numeric gateway number (eg. use gw2 rather than gw1 now))
|
1900 |
+
$transattempt = 1;
|
1901 |
+
$gwId++;
|
1902 |
+
}
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
|
1906 |
+
///////////////////////////////////////////////
|
1907 |
+
/// end PHP fix ///
|
1908 |
+
///////////////////////////////////////////////
|
1909 |
}
|
1910 |
catch (Exception $exc)
|
1911 |
{
|
1915 |
if ($boTransactionProcessed == false)
|
1916 |
{
|
1917 |
// could not communicate with the payment gateway
|
1918 |
+
$error = "Couldn't complete ".$szTransactionType." transaction. Reason: Unable to communicate with payment gateway. Please check outgoing TCP port 4430 is open on your server.";
|
1919 |
$szLogMessage = $error;
|
1920 |
}
|
1921 |
else
|
1922 |
{
|
1923 |
+
switch($StatusCode)
|
1924 |
{
|
1925 |
case 0:
|
1926 |
$error = false;
|
1927 |
+
$szNewCrossReference = $szCrossReference;
|
1928 |
$szLogMessage = $szTransactionType . " CrossReference transaction successfully completed. Response object: ";
|
1929 |
|
1930 |
$payment->setTransactionId($szNewCrossReference)
|
1931 |
+
->setParentTransactionId($CrossReference)
|
1932 |
->setIsTransactionClosed(1);
|
1933 |
$payment->save();
|
1934 |
break;
|
1935 |
default:
|
1936 |
+
$szLogMessage = $szMessageDetail;
|
1937 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1938 |
|
1939 |
$error = "Couldn't complete ".$szTransactionType." transaction for CrossReference: " . $szCrossReference . ". Payment Response: ".$szLogMessage;
|
1940 |
$szLogMessage = $szTransactionType . " CrossReference transaction failed. Response object: ";
|
package.xml
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cardsave_Cardsaveonlinepayments</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Payment Plugin for the CardSave Payment Gateway.</summary>
|
10 |
<description>Fully supports 3D secure transactions and all of the integration methods provided by CardSave.</description>
|
11 |
-
<notes
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>CardSave</name><user>CardSave</user><email>alistair.richardson@cardsave.net</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>10:
|
15 |
-
<contents><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="1cff6196bd79d3989b960506cc87201e"/></dir></dir></dir><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.1.0</min><max>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cardsave_Cardsaveonlinepayments</name>
|
4 |
+
<version>1.15.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Payment Plugin for the CardSave Payment Gateway.</summary>
|
10 |
<description>Fully supports 3D secure transactions and all of the integration methods provided by CardSave.</description>
|
11 |
+
<notes>* PHP 5.4 Compatibility Fix
|
12 |
+
* Store name now passed in order description.
|
13 |
+
* User friendly error messages for common errors.
|
14 |
+
* Ensured inputted values cannot exceed allowed amounts by the gateway (Direct).
|
15 |
+
* VOID, COLLECTION and REFUNDS now usable from within the back-end (Direct Integration Required).
|
16 |
+
</notes>
|
17 |
<authors><author><name>CardSave</name><user>CardSave</user><email>alistair.richardson@cardsave.net</email></author></authors>
|
18 |
+
<date>2014-06-26</date>
|
19 |
+
<time>10:52:03</time>
|
20 |
+
<contents><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="1cff6196bd79d3989b960506cc87201e"/></dir></dir></dir><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="f1d145c83982bdfbb7f73fc7a1acc950"/><file name="Threedsecure.php" hash="9d75776f34c5acaf6ea265f35f302c69"/></dir><dir name="Helper"><file name="Data.php" hash="e024ec0479d1e8e7efcf4751b05194d6"/></dir><dir name="Model"><dir name="Common"><file name="GlobalErrors.php" hash="e0f9062ca2db4c85d17e6939f9bd7641"/><file name="ISOCountries.php" hash="6c59574f190f6a67e38578d876c14edf"/><file name="ISOCurrencies.php" hash="2568f980f09bd8a7d4beaf3d16456d28"/><file name="PaymentFormHelper.php" hash="cf5a1ea6f653f4d5024adf491d5f5ba8"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="e7d13200c853536cf641bde7f714b54e"/><file name="SOAP.php" hash="2b966f946889c6f151b222c322d7a0ee"/><file name="TPG_Common.php" hash="0170a3c7f6a01faf9aee9b0f94da6d2a"/></dir></dir><file name="CommonFunctions.php" hash="b667c1886391bbca86058c80dca1af79"/><file name="Direct.php" hash="f853e658130d8cfd697dfc6a01537fcf"/><file name="Request.php" hash="370f028086d13ae1df470e93a67dea66"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="b2a7e887464ff91517dbb4fd62f13c66"/></dir></dir></dir><dir name="Source"><file name="HashMethod.php" hash="997928579b69d21ae9eebec698c715c6"/><file name="OrderStatus.php" hash="4c44f8ba1652f20d934aa200ed4c8d00"/><file name="PaymentAction.php" hash="3aab84053c69af1de2e743ee590fdf0c"/><file name="PaymentMode.php" hash="ea8af602bd09d54a123af64bc4b680d0"/><file name="ResultDeliveryMethod.php" hash="afb838319df715e604173d6aa143feab"/></dir></dir><dir name="controllers"><file name="PaymentController.php" hash="ac32fc8147445e4177960c3482ec4179"/></dir><dir name="etc"><file name="config.xml" hash="41d10598438bb48fa5397cdbdc34b493"/><file name="system.xml" hash="09f1d7b4a9c36472b8c529a8485a2ba9"/></dir><dir name="sql"><dir name="cardsaveonlinepayments_setup"><file name="mysql4-install-0.1.0.php" hash="bda643d24b75e0dc527dc2caa6d47689"/></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Cart"><file name="Totals.php" hash="ca91395788c746c8eef3a4b4f09833f7"/></dir><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="75a8a2961be74499d47ab398a8e1ba8a"/></dir></dir></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="2dc7e8f4e2b0292dc9160e4f9cf9ae5b"/></dir></dir><dir name="etc"><file name="config.xml" hash="9dbd58b6b32491d65e5c7d5850aa3420"/></dir></dir><dir name="Sales"><dir name="Block"><dir name="Order"><file name="Totals.php" hash="ceeea63efb04baded1446aaaab94c825"/></dir></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="9be99f3fbe1c4fe98fb110d3daa8afe6"/><file name="Payment.php" hash="10102812cd1906c0cceced21f88a78ff"/></dir><file name="Order.php" hash="e84594434822e321f271e3e463ddbcb9"/><dir name="Service"><file name="Quote.php" hash="a514922157b5690772d716c29f4a653e"/></dir></dir><dir name="etc"><file name="config.xml" hash="41f8d7978cb7e4cfffa0272d80e8f7bd"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="45978066fc7ee981dec117306a33bb02"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="cardsaveonlinepayments.xml" hash="65e413716658a000d659271cd174b1e2"/></dir><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="bf8cf94001d912f6d1e77b1d2b03cf6e"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir><dir name="payment"><dir name="info"><file name="cc_cardsaveonlinepayments.phtml" hash="88065460669f1112779264bdbf710af4"/></dir></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="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash="e1d59fd8c4d4b5d87607f43fecf47e59"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="cardsaveonlinepayments.js" hash="e7b2422644d39f0eb98e63d54a55ae4d"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir></dir></target></contents>
|
21 |
<compatible/>
|
22 |
+
<dependencies><required><php><min>5.1.0</min><max>5.6.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.9.9</max></package></required></dependencies>
|
23 |
</package>
|