CODE FROM THE PAYMENT SCRIPT
CODE FROM THE PAYMENT SCRIPT
<?php
$Protx_EncryptionPassword = "XXXXXXXXXXXXXXXXX";
$Protx_VSPForm_Bindings = WA_Protx_GetVSPFormBindings($Protx_EncryptionPassword);
$ProTX_VSPForm_Bindings = WA_Protx_GetVSPFormBindings($Protx_EncryptionPassword);
function WA_Protx_GetVSPFormBindings($Protx_EncryptionPassword) {
$retArray = array("VendorTxCode" => "", "Status" => "", "VPSTxId" => "", "TxAuthNo" => "", "AVSCV2" => "", "Amount" => "", "AddressResult" => "", "PostCodeResult" => "", "CV2Result" => "", "GiftAid" => "", "SecureStatus3D" => "", "CAVV" => "", "FullResponse" => "");
if (isset($_GET) && isset($_GET["crypt"]) && $_GET["crypt"] != "") {
$decodedStr = WA_Protx_VSPForm_SimpleXor(WA_Protx_VSPForm_Base64Decode($_GET["crypt"]), $Protx_EncryptionPassword);
$retArray["FullResponse"] = $decodedStr;
$retArray["VendorTxCode"] = WA_Protx_VSPForm_GetToken($decodedStr, "VendorTxCode");
$retArray["Status"] = WA_Protx_VSPForm_GetToken($decodedStr, "Status");
$retArray["StatusDetail"] = WA_Protx_VSPForm_GetToken($decodedStr, "StatusDetail");
$retArray["VPSTxId"] = WA_Protx_VSPForm_GetToken($decodedStr, "VPSTxId");
$retArray["TxAuthNo"] = WA_Protx_VSPForm_GetToken($decodedStr, "TxAuthNo");
$retArray["AVSCV2"] = WA_Protx_VSPForm_GetToken($decodedStr, "AVSCV2");
$retArray["Amount"] = WA_Protx_VSPForm_GetToken($decodedStr, "Amount");
$retArray["AddressResult"] = WA_Protx_VSPForm_GetToken($decodedStr, "AddressResult");
$retArray["PostCodeResult"] = WA_Protx_VSPForm_GetToken($decodedStr, "PostCodeResult");
$retArray["CV2Result"] = WA_Protx_VSPForm_GetToken($decodedStr, "CV2Result");
$retArray["GiftAid"] = WA_Protx_VSPForm_GetToken($decodedStr, "GiftAid");
$retArray["SecureStatus3D"] = WA_Protx_VSPForm_GetToken($decodedStr, "3DSecureStatus");
$retArray["CAVV"] = WA_Protx_VSPForm_GetToken($decodedStr,"CAVV");
}
return $retArray;
}
function WA_Protx_VSPFormHash($theCart, $tPassword, $tVendorTxCode, $tAmount, $tCurrency, $tDescription, $tSuccessURL, $tFailureURL, $tCustomerEmail, $tVendorEmail, $tDeliverySurname, $tDeliveryFirstnames, $tDeliveryAddress1, $tDeliveryPostCode, $tDeliveryCity, $tDeliveryCountry, $tBillingSurname, $tBillingFirstnames, $tBillingAddress1, $tBillingPostCode, $tBillingCity, $tBillingCountry, $tContactNumber, $tContactFax, $tAllowGiftAid, $tApplyAVSCV2, $tApply3DSecure, $tEMailMessage) {
$Protx_EncryptionPassword = $tPassword;
WA_Protx_GetVSPFormBindings($Protx_EncryptionPassword);
$retStr = "VendorTxCode=" . $tVendorTxCode . "&";
$retStr .= "Amount=" . $tAmount . "&";
$retStr .= "Currency=" . $tCurrency . "&";
$retStr .= "Description=" . $tDescription . "&";
$retStr .= "SuccessURL=" . $tSuccessURL . "&";
$retStr .= "FailureURL=" . $tFailureURL . "&";
if ($tCustomerEmail) {
$retStr .= "CustomerEmail=" . $tCustomerEmail . "&";
}
if ($tVendorEmail) {
$retStr .= "VendorEmail=" . $tVendorEmail . "&";
}
if ($tDeliverySurname) {
$retStr .= "DeliverySurname=" . $tDeliverySurname . "&";
}
if ($tDeliveryFirstnames) {
$retStr .= "DeliveryFirstnames=" . $tDeliveryFirstnames . "&";
}
if ($tDeliveryAddress1) {
$retStr .= "DeliveryAddress1=" . $tDeliveryAddress1 . "&";
}
if ($tDeliveryPostCode) {
$retStr .= "DeliveryPostCode=" . $tDeliveryPostCode . "&";
}
if ($tDeliveryCity) {
$retStr .= "DeliveryCity=" . $tDeliveryCity . "&";
}
if ($tDeliveryCountry) {
$retStr .= "DeliveryCountry=" . $tDeliveryCountry . "&";
}
if ($tBillingSurname) {
$retStr .= "BillingSurname=" . $tBillingSurname . "&";
}
if ($tBillingFirstnames) {
$retStr .= "BillingFirstnames=" . $tBillingFirstnames . "&";
}
if ($tBillingAddress1) {
$retStr .= "BillingAddress1=" . $tBillingAddress1 . "&";
}
if ($tBillingPostCode) {
$retStr .= "BillingPostCode=" . $tBillingPostCode . "&";
}
if ($tBillingCity) {
$retStr .= "BillingCity=" . $tBillingCity . "&";
}
if ($tBillingCountry) {
$retStr .= "BillingCountry=" . $tBillingCountry . "&";
}
if ($tContactNumber) {
$retStr .= "ContactNumber=" . $tContactNumber . "&";
}
if ($tContactFax) {
$retStr .= "ContactFax=" . $tContactFax . "&";
}
if ($tAllowGiftAid) {
$retStr .= "AllowGiftAid=" . $tAllowGiftAid . "&";
}
if ($tApplyAVSCV2) {
$retStr .= "ApplyAVSCV2=" . $tApplyAVSCV2 . "&";
}
if ($tApply3DSecure) {
$retStr .= "Apply3DSecure=" . $tApply3DSecure . "&";
}
if ($tEMailMessage) {
$retStr .= "EMailMessage=" . $tEMailMessage . "&";
}
$theBasket = "";
$basketCount = 0;
while (!$theCart->EOF()) {
$theBasket .= ":".$theCart->DisplayInfo("Name").":".$theCart->DisplayInfo("Quantity").":".WA_eCart_DisplayMoney($theCart, $theCart->DisplayInfo("Price"))."::".WA_eCart_DisplayMoney($theCart, $theCart->DisplayInfo("TotalPrice")).":".WA_eCart_DisplayMoney($theCart, $theCart->DisplayInfo("TotalPrice"));
$theCart->MoveNext();
$basketCount++;
}
$theCart->MoveFirst();
if (!$theCart->Rules_EOF("Discounts")) {
while (!$theCart->Rules_EOF("Discounts")) {
if ($theCart->RuleLooperValue("Discounts") > 0) {
$theBasket .= ":".$theCart->RuleLooperName("Discounts").":::::-".WA_eCart_DisplayMoney($theCart, $theCart->RuleLooperValue("Discounts"));
$theCart->MoveNext();
$basketCount++;
}
$theCart->Rules_MoveNext("Discounts");
}
$theCart->Rules_MoveFirst("Discounts");
}
if (!$theCart->Rules_EOF("Charges")) {
while (!$theCart->Rules_EOF("Charges")) {
if ($theCart->RuleLooperValue("Charges") > 0) {
$theBasket .= ":".$theCart->RuleLooperName("Charges").":::::".WA_eCart_DisplayMoney($theCart, $theCart->RuleLooperValue("Charges"));
$theCart->MoveNext();
$basketCount++;
}
$theCart->Rules_MoveNext("Charges");
}
$theCart->Rules_MoveFirst("Charges");
}
$tempParam = "Tax";
if ($theCart->ShippingIsTaxed) {
$tempParam = "Shipping";
}
if (!$theCart->Rules_EOF($tempParam)) {
while (!$theCart->Rules_EOF($tempParam)) {
if ($theCart->RuleLooperValue($tempParam) > 0) {
$theBasket .= ":".$theCart->RuleLooperName($tempParam).":::::".WA_eCart_DisplayMoney($theCart, $theCart->RuleLooperValue($tempParam));
$theCart->MoveNext();
$basketCount++;
}
$theCart->Rules_MoveNext($tempParam);
}
$theCart->Rules_MoveFirst($tempParam);
}
$tempParam = "Shipping";
if ($theCart->ShippingIsTaxed) {
$tempParam = "Tax";
}
if (!$theCart->Rules_EOF($tempParam)) {
while (!$theCart->Rules_EOF($tempParam)) {
if ($theCart->RuleLooperValue($tempParam) > 0) {
$theBasket .= ":".$theCart->RuleLooperName($tempParam).":::::".WA_eCart_DisplayMoney($theCart, $theCart->RuleLooperValue($tempParam));
$theCart->MoveNext();
$basketCount++;
}
$theCart->Rules_MoveNext($tempParam);
}
$theCart->Rules_MoveFirst($tempParam);
}
$theBasket = $basketCount.$theBasket;
$retStr .= "Basket=" . $theBasket;
$cryptStr = WA_Protx_VSPForm_Base64Encode(WA_Protx_VSPForm_SimpleXor($retStr, $tPassword));
return $cryptStr;
}
function WA_Protx_VSPForm_Base64Encode($plain) {
$output = "";
$output = base64_encode($plain);
return $output;
}
function WA_Protx_VSPForm_Base64Decode($scrambled) {
$output = "";
$scrambled = str_replace(" ","+",$scrambled);
$output = base64_decode($scrambled);
return $output;
}
function WA_Protx_VSPForm_SimpleXor($InString, $Key) {
$KeyList = array();
$output = "";
for($i = 0; $i < strlen($Key); $i++){
$KeyList[$i] = ord(substr($Key, $i, 1));
}
for($i = 0; $i < strlen($InString); $i++) {
$output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)]));
}
return $output;
}
function WA_Protx_VSPForm_GetToken($thisString, $thisToken) {
$Tokens = array( "Status", "StatusDetail", "VendorTxCode", "VPSTxId", "TxAuthNo", "AVSCV2", "Amount", "AddressResult", "PostCodeResult", "CV2Result", "GiftAid", "3DSecureStatus", "CAVV" );
$retStr = "";
if (strpos($thisString, $thisToken."=") === false || (strpos($thisString, $thisToken."=") > 0 && strpos($thisString, "&".$thisToken."=") === false)) {
return "";
}
else {
for ($n=0; $n<sizeof($Tokens); $n++) {
if ($Tokens[$n] == $thisToken) {
if (strpos($thisString, $thisToken."=") !== false && strpos($thisString, $thisToken."=") == 0) {
$retStr = substr($thisString, strlen($thisToken)+1);
}
else {
$retStr = substr($thisString, strpos($thisString, "&".$thisToken."=") + strlen("&".$thisToken."="));
}
if (strpos($retStr, "&") !== false) {
$retStr = substr($retStr, 0, strpos($retStr, "&"));
}
}
}
}
return $retStr;
}
function WA_Protx_VSPForm_Randomise() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
?>