#!/usr/bin/perl
my $bFound = 0;
my $sDir;
foreach $sDir (@INC)
{
if ($sDir eq ".")
{
$bFound = 1;
last;
}
}
if (!$bFound)
{
push (@INC, ".");
}
push (@INC, "cgi-bin");
require al000009;
require as000009;
require ad000009;
require ae000009;
require ao000009;
require sm000009;
use Socket;
use strict;
$::prog_name = "ORDERSCR";
$::prog_name = $::prog_name;
$::prog_ver = '$Revision: 20345 $ ';
$::prog_ver = substr($::prog_ver, 11);
$::prog_ver =~ s/ \$//;
$::FORWARD = 0;
$::BACKWARD = 1;
$::eApplet = 0;
$::eSharedSSL = 1;
$::eDelivery = 0;
$::eInvoice = 1;
$::ORDER_BLOB_VERSION = 22;
$::ORDER_DETAIL_BLOB_VERSION = 12;
$::g_sSmtpServer = "relay.gradwell.net";
$::g_sUserKey = "bfbc05856bd994747d4863b0209b3384";
$::g_nCurrentSequenceNumber = -1;
$::g_nNextSequenceNumber = -1;
$::g_bSpitSSLChange = $::FALSE;
my $nDebugLogLevel = 0;
$::g_pFieldSizes =
{
'NAME' => 40,
'FIRSTNAME' => 40,
'LASTNAME' => 40,
'SALUTATION' => 15,
'JOBTITLE' => 50,
'COMPANY' => 100,
'PHONE' => 25,
'MOBILE' => 25,
'FAX' => 25,
'EMAIL' => 255,
'ADDRESS1' => 200,
'ADDRESS2' => 200,
'ADDRESS3' => 200,
'ADDRESS4' => 200,
'POSTALCODE' => 50,
'COUNTRY' => 75,
'USERDEFINED' => 255,
'HOWFOUND' => 255,
'WHYBUY' => 255,
'PONO' => 50,
};
Init();
ProcessInput();
exit;
sub Init
{
$::g_bFirstError = $::TRUE;
my (@Response, $Status, $Message, $sAction, $sSendMailButton);
@Response = ReadAndParseInput();
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
ACTINIC::TerminalError($Message);
}
if ((not defined $::g_InputHash{'ACTION'}) &&
($::g_InputHash{'m_6'} eq 'VCSCALL'))
{
my $sAuthCallURL = ACTINIC::DecodeText($::g_InputHash{'m_3'}, $ACTINIC::FORM_URL_ENCODED);
$sAuthCallURL =~ /.*?PATH=(.*?)\&/;
$::g_InputHash{'PATH'} = $1;
$sAuthCallURL =~ /.*?SEQUENCE=(.*?)\&/;
$::g_InputHash{'SEQUENCE'} = $1;
$sAuthCallURL =~ /.*?ACTION=(.*?)\&/;
$::g_InputHash{'ACTION'} = $1;
$sAuthCallURL =~ /.*?CARTID=(.*?)\&/;
$::g_InputHash{'CARTID'} = $1;
$::g_InputHash{'ACT_POSTPROCESS'} = 1;
$::g_InputHash{ON} = $::g_InputHash{m_1};
$::g_InputHash{AM} = $::g_InputHash{p6} * $::g_InputHash{m_8};
}
if ($::g_InputHash{'ACTION'} =~ m/SSP_TRACK/i)
{
my $sPath = ACTINIC::GetPath();
@Response = ACTINIC::ReadPromptFile($sPath);
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
ACTINIC::ReportError($Message, ACTINIC::GetPath());
}
@Response = ACTINIC::ReadSSPSetupFile($sPath);
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
ACTINIC::ReportError($Message, ACTINIC::GetPath());
}
@Response = FormatTrackingPage();
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
ACTINIC::ReportError($Message, ACTINIC::GetPath());
}
my $sHTML = $Response[2];
ACTINIC::PrintPage($sHTML, undef);
exit;
}
if ($::g_InputHash{'SEQUENCE'} <= 3)
{
CreateAddressBook();
}
@Response = ReadAndParseBlobs();
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
ACTINIC::ReportError($Message, ACTINIC::GetPath());
}
$::g_sWebSiteUrl = $::Session->GetBaseUrl();
$::g_sContentUrl = $::g_sWebSiteUrl;
if ($::g_InputHash{"ACTION"} =~ /^OFFLINE_AUTHORIZE/i)
{
DoOfflineAuthorization();
exit;
}
if($::g_InputHash{"ACTION"} eq "OCC_VALIDATE" ||
($::g_InputHash{ACTION} =~ /^AUTHORIZE/i) ||
($::g_InputHash{"ACTION"} eq "RECORDORDER" && $$::g_pSetupBlob{USE_SHARED_SSL}))
{
$::Session->SetCallBack($::TRUE);
if(defined $::g_PaymentInfo{BUYERHASH})
{
$ACTINIC::B2B->Set('UserDigest', $::g_PaymentInfo{BUYERHASH});
$ACTINIC::B2B->Set('UserName', $::g_PaymentInfo{BUYERNAME});
$ACTINIC::B2B->Set('BaseFile', $::g_PaymentInfo{BASEFILE});
}
}
else
{
$ACTINIC::B2B->Set('UserDigest',ACTINIC::CAccFindUser());
}
ACTINIC::InitMonthMap();
if( $::g_InputHash{'BASE'} )
{
$::g_sContentUrl = $::g_InputHash{'BASE'};
}
}
sub ReadAndParseInput
{
my ($status, $message, $temp);
($status, $message, $::g_OriginalInputData, $temp, %::g_InputHash) = ACTINIC::ReadAndParseInput();
if ($status != $::SUCCESS)
{
return ($status, $message, 0, 0);
}
if ($::g_InputHash{'SESSIONID'})
{
if ($ENV{'HTTP_COOKIE'} !~ /ACTINIC_CART/)
{
$ENV{'HTTP_COOKIE'} = ACTINIC::DecodeText($::g_InputHash{'COOKIE'}, $ACTINIC::FORM_URL_ENCODED);
}
else
{
$ENV{'HTTP_COOKIE'} =~ s/(ACTINIC_CART=)[^;]*;?/$1$::g_InputHash{'SESSIONID'};/;
$ENV{'HTTP_COOKIE'} =~ s/(CART_CONTENT=)[^;]*;?/$1$::g_InputHash{'CARTCOOKIE'};/;
$ENV{'HTTP_COOKIE'} =~ s/(ACTINIC_BUSINESS=)[^;]*;?/$1$::g_InputHash{'DIGEST'};/;
}
$::g_bSpitSSLChange = $::TRUE;
}
if( $::g_InputHash{ADDRESSSELECT} )
{
undef $::g_InputHash{'INVOICESALUTATION'};
undef $::g_InputHash{'INVOICENAME'};
undef $::g_InputHash{'INVOICEFIRSTNAME'};
undef $::g_InputHash{'INVOICELASTNAME'};
undef $::g_InputHash{'INVOICEJOBTITLE'};
undef $::g_InputHash{'INVOICECOMPANY'};
undef $::g_InputHash{'INVOICEADDRESS1'};
undef $::g_InputHash{'INVOICEADDRESS2'};
undef $::g_InputHash{'INVOICEADDRESS3'};
undef $::g_InputHash{'INVOICEADDRESS4'};
undef $::g_InputHash{'INVOICEPOSTALCODE'};
undef $::g_InputHash{'INVOICECOUNTRY'};
undef $::g_InputHash{'INVOICEPHONE'};
undef $::g_InputHash{'INVOICEMOBILE'};
undef $::g_InputHash{'INVOICEFAX'};
undef $::g_InputHash{'INVOICEEMAIL'};
undef $::g_InputHash{'DELIVERSALUTATION'};
undef $::g_InputHash{'DELIVERNAME'};
undef $::g_InputHash{'DELIVERFIRSTNAME'};
undef $::g_InputHash{'DELIVERLASTNAME'};
undef $::g_InputHash{'DELIVERJOBTITLE'};
undef $::g_InputHash{'DELIVERCOMPANY'};
undef $::g_InputHash{'DELIVERADDRESS1'};
undef $::g_InputHash{'DELIVERADDRESS2'};
undef $::g_InputHash{'DELIVERADDRESS3'};
undef $::g_InputHash{'DELIVERADDRESS4'};
undef $::g_InputHash{'DELIVERPOSTALCODE'};
undef $::g_InputHash{'DELIVERCOUNTRY'};
undef $::g_InputHash{'DELIVERPHONE'};
undef $::g_InputHash{'DELIVERMOBILE'};
undef $::g_InputHash{'DELIVERFAX'};
undef $::g_InputHash{'DELIVEREMAIL'};
undef $::g_InputHash{'DELIVERUSERDEFINED'};
}
return ($::SUCCESS, "", 0, 0);
}
sub ReadAndParseBlobs
{
my ($Status, $Message, @Response, $sPath);
$sPath = ACTINIC::GetPath();
@Response = ACTINIC::ReadCatalogFile($sPath);
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadSetupFile($sPath);
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadLocationsFile($sPath);
($Status, $Message) = @Response;
if ($Status != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadPaymentFile($sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadPhaseFile($sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadPromptFile($sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadTaxSetupFile($sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::ReadSSPSetupFile($sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
my ($Status, $Message) = ACTINIC::ReadDiscountBlob($sPath);
if ($Status != $::SUCCESS)
{
return ($Status, $Message);
}
my ($sContactDetails);
($::g_sCartId, $sContactDetails) = ACTINIC::GetCookies();;
if ($::g_InputHash{CARTID} &&
$::g_InputHash{CARTID} =~ /^[a-zA-Z0-9]+$/)
{
$::g_sCartId = $::g_InputHash{CARTID};
}
if ($::g_InputHash{CART} &&
$::g_InputHash{CART} =~ /^[a-zA-Z0-9]+$/)
{
$::g_sCartId = $::g_InputHash{CART};
}
my $sCallbackFlag;
if($::g_InputHash{"ACTION"} eq "OCC_VALIDATE" ||
($::g_InputHash{ACTION} =~ /^AUTHORIZE/i) ||
($::g_InputHash{ACTION} =~ /^OFFLINE_AUTHORIZE/i) ||
($::g_InputHash{"ACTION"} eq "RECORDORDER" && $$::g_pSetupBlob{USE_SHARED_SSL}))
{
$sCallbackFlag = $::TRUE;
}
else
{
$sCallbackFlag = $::FALSE;
}
$::Session = new Session($::g_sCartId, $sContactDetails, ACTINIC::GetPath(), $::FALSE, $sCallbackFlag);
if ($::g_bSpitSSLChange &&
$sContactDetails ne "")
{
$::Session->CookieStringToContactDetails();
}
my ($pBillContact, $pShipContact, $pShipInfo, $pTaxInfo, $pGeneralInfo, $pPaymentInfo, $pLocationInfo);
@Response = $::Session->RestoreCheckoutInfo();
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
no strict 'refs';
($Status, $Message, $pBillContact, $pShipContact, $pShipInfo, $pTaxInfo, $pGeneralInfo, $pPaymentInfo, $pLocationInfo) = @Response;
%::g_BillContact = %$pBillContact;
%::g_ShipContact = %$pShipContact;
%::g_ShipInfo = %$pShipInfo;
%::g_TaxInfo = %$pTaxInfo;
%::g_GeneralInfo = %$pGeneralInfo;
%::g_PaymentInfo = %$pPaymentInfo;
%::g_LocationInfo = %$pLocationInfo;
$::g_sTaxDump = (join "|", keys %::g_TaxInfo) . (join "|", values %::g_TaxInfo);
$::g_sShippingDump = (join "|", keys %::g_ShipInfo) . (join "|", values %::g_ShipInfo);
return ($::SUCCESS, "", 0, 0);
}
sub ProcessInput
{
my (@Response, $sDetailCookie);
$::g_nCurrentSequenceNumber = $::g_InputHash{'SEQUENCE'};
if (!defined $::g_nCurrentSequenceNumber)
{
$::g_nCurrentSequenceNumber = $::STARTSEQUENCE;
}
my ($sConfirmButton, $sStartButton, $sDoneButton, $sNextButton, $sFinishButton, $sBackButton, $sCancelButton, $sChangeLocationButton);
$sConfirmButton = ACTINIC::GetPhrase(-1, 153);
$sStartButton = ACTINIC::GetPhrase(-1, 113);
$sDoneButton = ACTINIC::GetPhrase(-1, 114);
$sNextButton = ACTINIC::GetPhrase(-1, 502);
$sBackButton = ACTINIC::GetPhrase(-1, 503);
$sFinishButton = ACTINIC::GetPhrase(-1, 504);
$sCancelButton = ACTINIC::GetPhrase(-1, 505);
$sChangeLocationButton = ACTINIC::GetPhrase(0, 18);
my ($sHTML, $sAction, $eDirection);
$sAction = $::g_InputHash{'ACTION'};
if ($sAction =~ m/$sStartButton/i)
{
$::Session->SetCheckoutStarted();
}
elsif (!$::Session->IsCheckoutStarted())
{
@Response = ACTINIC::BounceToPageEnhanced(5, ACTINIC::GetPhrase(-1, 2300),
$$::g_pSetupBlob{CHECKOUT_DESCRIPTION},
$::g_sWebSiteUrl,
$::g_sContentUrl, $::g_pSetupBlob, $::Session->GetLastShopPage(), \%::g_InputHash,
$::FALSE);
$sHTML = $Response[2];
goto THEEND;
}
if ($sAction eq "PPSTARTCHECKOUT")
{
IncludePaypalScript();
@Response = StartPaypalProCheckout();
if ($Response[0] == $::BADDATA)
{
$sHTML = $Response[1];
$sDetailCookie = $Response[2];
goto THEEND;
}
elsif ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
$sHTML = $Response[1];
goto THEEND;
}
elsif ($sAction eq "PPCOMPLETECHECKOUT")
{
IncludePaypalScript();
CompletePaypalProCheckout();
exit;
}
elsif ($sAction eq $sConfirmButton)
{
IncludePaypalScript();
my $sError = ValidateOrderConfirmPhase();
if ($sError ne "")
{
$sHTML = DisplayOrderConfirmPhase($sError);
goto THEEND;
}
else
{
my $oPaypal = new ActinicPaypalConnection();
my $nAmount = ActinicOrder::GetOrderTotal();
my @Response = $oPaypal->DoExpressCheckoutPayment($nAmount);
if ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
@Response = RecordPaypalOrder($oPaypal);
if ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
$::g_nCurrentSequenceNumber = 3;
$sAction = $sNextButton;
}
}
if ($sAction eq "" &&
$::g_InputHash{ACTIONOVERRIDE})
{
$sAction = $::g_InputHash{ACTIONOVERRIDE};
}
elsif ($sAction =~ m/$sStartButton/i ||
$sAction =~ m/$sNextButton/i ||
$sAction =~ m/$sFinishButton/i ||
$sAction =~ m/^AUTHORIZE/i ||
$sAction =~ m/RECORDORDER/i ||
exists $::g_InputHash{$sNextButton . ".x"} ||
exists $::g_InputHash{$sFinishButton . ".x"})
{
$eDirection = $::FORWARD;
}
elsif ($sAction =~ m/$sBackButton/i ||
$sAction =~ m/$sChangeLocationButton/i ||
exists $::g_InputHash{$sBackButton . ".x"})
{
$eDirection = $::BACKWARD;
}
elsif ($sAction =~ m/$sDoneButton/i ||
exists $::g_InputHash{$sDoneButton . ".x"})
{
my $sRefPage = $::Session->GetLastShopPage();
if (defined $$::g_pSetupBlob{'UNFRAMED_CHECKOUT_URL'} &&
$$::g_pSetupBlob{'UNFRAMED_CHECKOUT_URL'} ne "")
{
$sRefPage = $$::g_pSetupBlob{'UNFRAMED_CHECKOUT_URL'};
}
if( !$ACTINIC::B2B->Get('UserDigest') )
{
if (defined $::g_InputHash{'ALTERNATEMALLHOME'})
{
$sRefPage = $::g_InputHash{'ALTERNATEMALLHOME'};
}
}
@Response = ACTINIC::BounceToPagePlain(0, undef, undef, $::g_sWebSiteUrl,
$::g_sContentUrl, $::g_pSetupBlob, $sRefPage, \%::g_InputHash);
if ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
$sHTML = $Response[2];
if ($ACTINIC::B2B->Get('UserDigest'))
{
$sHTML =~ s/([\?|\&]ACTINIC_REFERRER[^\&|"|']*)//gi;
$sHTML =~ s/($::g_sAccountScriptName)(\&)/$1\?/gi;
}
goto THEEND;
}
elsif ($sAction =~ m/OCC_VALIDATE/i)
{
@Response = GetOCCValidationData();
if ($Response[0] != $::SUCCESS)
{
ACTINIC::RecordErrors($Response[1], ACTINIC::GetPath());
$sHTML = '0';
}
else
{
$sHTML = $Response[2];
}
ACTINIC::PrintText($sHTML);
return;
}
else
{
$sHTML = GetCancelPage();
goto THEEND;
}
@Response = ValidateInput($eDirection);
if ($Response[0] == $::BADDATA)
{
$sHTML = $Response[1];
$sDetailCookie = $Response[2];
goto THEEND;
}
elsif ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
if($sAction =~ m/$sChangeLocationButton/i)
{
$::g_nCurrentSequenceNumber = $::STARTSEQUENCE;
$eDirection = $::FORWARD;
}
if ($eDirection == $::FORWARD)
{
$::g_nNextSequenceNumber = $::g_nCurrentSequenceNumber + 1;
}
else
{
$::g_nNextSequenceNumber = $::g_nCurrentSequenceNumber - 1;
}
ActinicOrder::ParseAdvancedTax();
@Response = DisplayPage("", $::g_nNextSequenceNumber, $eDirection);
if ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($Response[1], ACTINIC::GetPath());
return;
}
$sHTML = $Response[2];
$sDetailCookie = $Response[3];
THEEND:
ACTINIC::UpdateDisplay($sHTML, $::g_OriginalInputData, undef, undef, $sDetailCookie, ActinicOrder::GenerateCartCookie());
}
sub ValidateInput
{
my ($eDirection);
if ($#_ != 0)
{
$eDirection = $::FORWARD;
}
($eDirection) = @_;
my ($bActuallyValidate) = ($eDirection == $::FORWARD);
my (@Response);
if ($::g_nCurrentSequenceNumber == $::STARTSEQUENCE)
{
@Response = ValidateStart($bActuallyValidate); # validate the input/cart settings
return (@Response);
}
else
{
my ($sPhaseList) = $$::g_pPhaseList{$::g_nCurrentSequenceNumber};
my (@Phases) = split (//, $sPhaseList);
my ($nPhase, $sError);
foreach $nPhase (@Phases)
{
if ($nPhase == $::BILLCONTACTPHASE)
{
$sError .= ValidateBill($bActuallyValidate);
}
elsif ($nPhase == $::SHIPCONTACTPHASE)
{
$sError .= ValidateShipContact($bActuallyValidate);
}
elsif ($nPhase == $::SHIPCHARGEPHASE)
{
$sError .= ValidateShipCharge($bActuallyValidate);
}
elsif ($nPhase == $::TAXCHARGEPHASE)
{
$sError .= ActinicOrder::ValidateTax($bActuallyValidate);
}
elsif ($nPhase == $::GENERALPHASE)
{
$sError .= ValidateGeneral($bActuallyValidate);
}
elsif ($nPhase == $::PAYMENTPHASE)
{
$sError .= ValidatePayment($bActuallyValidate);
}
elsif ($nPhase == $::COMPLETEPHASE)
{
if($::g_InputHash{'ACTION'} =~ m/^AUTHORIZE_(\d+)$/i)
{
$::g_PaymentInfo{'METHOD'} = $1;
}
if (!defined $::g_PaymentInfo{'METHOD'})
{
if ($$::g_pSetupBlob{USE_DH})
{
$sError .= ACTINIC::GetPhrase(-1, 2040);
}
else
{
$sError .= ACTINIC::GetPhrase(-1, 1282);
}
next;
}
if (length $::g_PaymentInfo{'METHOD'} == 0)
{
EnsurePaymentSelection();
}
my ($ePaymentMethod) = ActinicOrder::PaymentStringToEnum($::g_PaymentInfo{'METHOD'}); # the payment method is stored as "ENUMERATEDID:DESCRIPTION"
if ($ACTINIC::B2B->Get('UserDigest') &&
($ePaymentMethod == $::PAYMENT_ON_ACCOUNT ||
$ePaymentMethod == $::PAYMENT_INVOICE))
{
$sError .= ValidateSignature($bActuallyValidate);
}
}
elsif ($nPhase == $::RECEIPTPHASE)
{
}
elsif ($nPhase == $::PRELIMINARYINFOPHASE)
{
$sError .= ActinicOrder::ValidatePreliminaryInfo($bActuallyValidate);
}
}
if ($sError ne '')
{
@Response = DisplayPage($sError, $::g_nCurrentSequenceNumber, $eDirection);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
$Response[0] = $::BADDATA;
$Response[1] = $Response[2];
$Response[2] = $Response[3];
return (@Response);
}
}
return (UpdateCheckoutRecord());
}
sub ValidateStart
{
if ($#_ != 0)
{
return ($::FAILURE, ACTINIC::GetPhrase(-1, 12, 'ValidateStart'), 0, 0);
}
my ($bActuallyValidate) = @_;
if (!$bActuallyValidate)
{
return ($::SUCCESS, "", 0, 0);
}
my ($nLineCount, @Response, $Status, $Message);
my $pCartObject;
@Response = $::Session->GetCartObject();
if ($Response[0] != $::SUCCESS)
{
$nLineCount = 0;
}
else
{
$pCartObject = $Response[2];
$nLineCount = $pCartObject->CountItems();
}
my ($sLocalPage, $sBaseUrl, $sHTML);
if ($nLineCount <= 0)
{
$sLocalPage = $::Session->GetLastShopPage();
if (ACTINIC::IsCatalogFramed() ||
($$::g_pSetupBlob{CLEAR_ALL_FRAMES} &&
$$::g_pSetupBlob{UNFRAMED_CHECKOUT}))
{
$sLocalPage = ACTINIC::RestoreFrameURL($sLocalPage);
}
@Response = ACTINIC::BounceToPageEnhanced(5, ACTINIC::GetPhrase(-1, 1962) . ACTINIC::GetPhrase(-1, 44, $::g_sCart, $::g_sCart) . ACTINIC::GetPhrase(-1, 1970) . ACTINIC::GetPhrase(-1, 2049),
$$::g_pSetupBlob{CHECKOUT_DESCRIPTION},
$::g_sWebSiteUrl,
$::g_sContentUrl, $::g_pSetupBlob, $sLocalPage, \%::g_InputHash,
$::FALSE);
($Status, $Message, $sHTML) = @Response;
if ($Status != $::SUCCESS)
{
return (@Response);
}
return ($::BADDATA, $sHTML, 0, 0);
}
my $pCartList = $pCartObject->GetCartList();
my $nIndex;
foreach ($nIndex = $#$pCartList; $nIndex >= 0; $nIndex--)
{
my $pFailure;
($Status, $Message, $pFailure) = ActinicOrder::ValidateOrderDetails($pCartList->[$nIndex], $nIndex);
if ($Status != $::SUCCESS)
{
my $sURL = $::g_sCartScript . "?ACTION=SHOWCART";
$sURL .= $::g_InputHash{SHOP} ? '&SHOP=' . ACTINIC::EncodeText2($::g_InputHash{SHOP}, $::FALSE) : '';
@Response = ACTINIC::BounceToPageEnhanced(5, ACTINIC::GetPhrase(-1, 1962) . ACTINIC::GetPhrase(-1, 2167) . ACTINIC::GetPhrase(-1, 1970) . ACTINIC::GetPhrase(-1, 2049),
$$::g_pSetupBlob{CHECKOUT_DESCRIPTION},
$::g_sWebSiteUrl,
$::g_sContentUrl, $::g_pSetupBlob, $sURL , \%::g_InputHash,
$::FALSE);
($Status, $Message, $sHTML) = @Response;
if ($Status != $::SUCCESS)
{
return (@Response);
}
return ($::BADDATA, $sHTML, 0, 0);
}
}
($Status, $sHTML) = ActinicOrder::CheckBuyerLimit($::g_sCartId,'',$::TRUE);
if ($Status != $::SUCCESS)
{
return ($::BADDATA,$sHTML);
}
return ($::SUCCESS, "", 0, 0);
}
sub ValidateBill
{
if ($#_ != 0)
{
ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidateBill'), ACTINIC::GetPath());
}
my ($bActuallyValidate) = @_;
my $sPreValidationError = "";
if( $::g_InputHash{ADBACTION} )
{
return('');
}
if( $::g_InputHash{ADDRESSSELECT} )
{
my $sUserDigest = $ACTINIC::B2B->Get('UserDigest');
my ($status, $sMessage, $pBuyer) = ACTINIC::GetBuyer($sUserDigest, ACTINIC::GetPath());
if ($status != $::SUCCESS)
{
return ($sMessage);
}
my $pAccount;
($status, $sMessage, $pAccount) = ACTINIC::GetCustomerAccount($$pBuyer{AccountID}, ACTINIC::GetPath());
if ($status != $::SUCCESS)
{
return ($sMessage);
}
my $pAddress;
($status, $sMessage, $pAddress) = ACTINIC::GetCustomerAddress($$pBuyer{AccountID}, $::g_InputHash{ADDRESSSELECT}, ACTINIC::GetPath());
ACTINIC::CloseCustomerAddressIndex();
if ($status != $::SUCCESS)
{
return ($sMessage);
}
if( $pBuyer->{InvoiceAddressRule} != 0 )
{
$::g_BillContact{'NAME'} = $pBuyer->{'Name'};
$::g_BillContact{'FIRSTNAME'} = $pBuyer->{'FirstName'};
$::g_BillContact{'LASTNAME'} = $pBuyer->{'LastName'};
$::g_BillContact{'SALUTATION'} = $pBuyer->{'Salutation'};
$::g_BillContact{'JOBTITLE'} = $pBuyer->{'Title'};
}
else
{
$::g_BillContact{'NAME'} = $pAccount->{'Name'};
$::g_BillContact{'FIRSTNAME'} = $pAccount->{'FirstName'};
$::g_BillContact{'LASTNAME'} = $pAccount->{'LastName'};
$::g_BillContact{'SALUTATION'} = $pAccount->{'Salutation'};
$::g_BillContact{'JOBTITLE'} = $pAccount->{'Title'};
}
$::g_BillContact{'PHONE'} = $pAccount->{'TelephoneNumber'};
$::g_BillContact{'MOBILE'} = $pAccount->{'MobileNumber'};
$::g_BillContact{'FAX'} = $pAccount->{'FaxNumber'};
if (length $::g_BillContact{'PHONE'} > $::g_pFieldSizes->{'PHONE'})
{
$::g_BillContact{'PHONE'} =~ s/(.*?)(\/.*|$)/$1/;
}
$::g_BillContact{'PHONE'} =~ s/(.{0,$::g_pFieldSizes->{'PHONE'}}).*/$1/;
$::g_BillContact{'MOBILE'} =~ s/(.{0,$::g_pFieldSizes->{'MOBILE'}}).*/$1/;
$::g_BillContact{'FAX'} =~ s/(.{0,$::g_pFieldSizes->{'FAX'}}).*/$1/;
$::g_BillContact{'EMAIL'} = $pAccount->{'EmailAddress'};
$::g_BillContact{'ADDRESS1'} = $pAddress->{'Line1'};
$::g_BillContact{'ADDRESS2'} = $pAddress->{'Line2'};
$::g_BillContact{'ADDRESS3'} = $pAddress->{'Line3'};
$::g_BillContact{'ADDRESS4'} = $pAddress->{'Line4'};
$::g_BillContact{'POSTALCODE'} = $pAddress->{'PostCode'};
$::g_BillContact{'COUNTRY'} = ACTINIC::GetCountryName($pAddress->{'CountryCode'});
$::g_BillContact{'SEPARATE'} = $::TRUE;
if ($::g_LocationInfo{SEPARATESHIP} eq "" &&
$::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED &&
$::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $pAddress->{'CountryCode'})
{
$sPreValidationError = ACTINIC::GetPhrase(-1, 2298,
ACTINIC::GetCountryName($::g_LocationInfo{INVOICE_COUNTRY_CODE}),
ACTINIC::GetCountryName($pAddress->{'CountryCode'}));
}
else
{
$::g_LocationInfo{INVOICE_COUNTRY_CODE} = $pAddress->{'CountryCode'};
if (!$::g_LocationInfo{SEPARATESHIP})
{
$::g_LocationInfo{DELIVERY_COUNTRY_CODE} = $pAddress->{'CountryCode'};
}
}
ActinicOrder::ParseAdvancedTax();
if($$::g_pTaxSetupBlob{TAX_BY} == $::eTaxByInvoice)
{
if(defined $$::g_pTaxSetupBlob{TAX_1} &&
$$::g_pTaxSetupBlob{TAX_1}{ID} == $pAddress->{'Tax1ID'})
{
$::g_TaxInfo{'EXEMPT1'} = $pAddress->{'ExemptTax1'} ? 1 : 0;
$::g_TaxInfo{'EXEMPT1DATA'} = $pAddress->{'Tax1ExemptData'};
}
if(defined $$::g_pTaxSetupBlob{TAX_2} &&
$$::g_pTaxSetupBlob{TAX_2}{ID} == $pAddress->{'Tax2ID'})
{
$::g_TaxInfo{'EXEMPT2'} = $pAddress->{'ExemptTax2'} ? 1 : 0;
$::g_TaxInfo{'EXEMPT2DATA'} = $pAddress->{'Tax2ExemptData'};
}
}
$::g_BillContact{'MOVING'} = $::FALSE;
$::g_BillContact{'PRIVACY'} = $::TRUE;
$::g_BillContact{'REMEMBERME'} = $::FALSE;
}
else
{
$::g_BillContact{'SALUTATION'} = $::g_InputHash{'INVOICESALUTATION'};
$::g_BillContact{'NAME'} = $::g_InputHash{'INVOICENAME'};
$::g_BillContact{'FIRSTNAME'} = $::g_InputHash{'INVOICEFIRSTNAME'};
$::g_BillContact{'LASTNAME'} = $::g_InputHash{'INVOICELASTNAME'};
$::g_BillContact{'JOBTITLE'} = $::g_InputHash{'INVOICEJOBTITLE'};
$::g_BillContact{'COMPANY'} = $::g_InputHash{'INVOICECOMPANY'};
$::g_BillContact{'ADDRESS1'} = $::g_InputHash{'INVOICEADDRESS1'};
$::g_BillContact{'ADDRESS2'} = $::g_InputHash{'INVOICEADDRESS2'};
$::g_BillContact{'ADDRESS3'} = $::g_InputHash{'INVOICEADDRESS3'};
$::g_BillContact{'ADDRESS4'} = $::g_InputHash{'INVOICEADDRESS4'};
$::g_BillContact{'POSTALCODE'} = $::g_InputHash{'INVOICEPOSTALCODE'};
$::g_BillContact{'COUNTRY'} = $::g_InputHash{'INVOICECOUNTRY'};
$::g_BillContact{'PHONE'} = $::g_InputHash{'INVOICEPHONE'};
$::g_BillContact{'MOBILE'} = $::g_InputHash{'INVOICEMOBILE'};
$::g_BillContact{'FAX'} = $::g_InputHash{'INVOICEFAX'};
$::g_BillContact{'EMAIL'} = $::g_InputHash{'INVOICEEMAIL'};
$::g_BillContact{'USERDEFINED'} = $::g_InputHash{'INVOICEUSERDEFINED'};
$::g_BillContact{'MOVING'} = ($::g_InputHash{'INVOICEMOVING'} ne "") ? $::TRUE : $::FALSE;
$::g_BillContact{'PRIVACY'} = ($::g_InputHash{'INVOICEPRIVACY'} ne "") ? $::TRUE : $::FALSE;
$::g_BillContact{'SEPARATE'} = ($::g_InputHash{'SEPARATESHIP'} ne "") ? $::TRUE : $::FALSE;
$::g_BillContact{'REMEMBERME'} = (defined $::g_InputHash{'REMEMBERME'} && $::g_InputHash{'REMEMBERME'} ne "") ?
$::TRUE : $::FALSE;
}
if ($$::g_pSetupBlob{SHOPPER_NAME_HANDLING_MODE} eq 1)
{
$::g_BillContact{'NAME'} = $::g_BillContact{'FIRSTNAME'}.' '.$::g_BillContact{'LASTNAME'};
$::g_BillContact{'NAME'} =~ s/(.{0,$::g_pFieldSizes->{'NAME'}}).*/$1/;
}
$::g_BillContact{'AGREEDTANDC'} = (defined $::g_InputHash{'AGREETERMSCONDITIONS'} && $::g_InputHash{'AGREETERMSCONDITIONS'} ne "") ? $::TRUE : $::FALSE;
if (!ACTINIC::IsPromptRequired(0, 12) &&
(length $::g_BillContact{'EMAIL'} == 0) &&
ACTINIC::IsPromptRequired(1, 12) &&
!$::g_BillContact{'SEPARATE'})
{
$sPreValidationError .= ACTINIC::GetPhrase(-1, 2417);
}
if ((ACTINIC::IsPromptRequired(0, 12) ||
length $::g_BillContact{'EMAIL'} > 0) &&
$::g_BillContact{'EMAIL'} !~ /\@/)
{
$sPreValidationError .= ACTINIC::GetPhrase(-1, 2378);
}
ACTINIC::TrimHashEntries(\%::g_BillContact);
my ($sError);
if (!$bActuallyValidate)
{
return ($sError);
}
$sError = $sPreValidationError;
my (@Response);
my $pMapping =
{
'SALUTATION' => 0,
'NAME' => 1,
'JOBTITLE' => 2,
'COMPANY' => 3,
'ADDRESS1' => 4,
'ADDRESS2' => 5,
'ADDRESS3' => 6,
'ADDRESS4' => 7,
'POSTALCODE' => 8,
'COUNTRY' => 9,
'PHONE' => 10,
'FAX' => 11,
'EMAIL' => 12,
'FIRSTNAME' => 2464,
'LASTNAME' => 2465,
'MOBILE' => 2453,
};
if ($$::g_pSetupBlob{SHOPPER_NAME_HANDLING_MODE} eq 1) # first name/ last name handling
{
delete $pMapping->{'NAME'};
}
else
{
delete $pMapping->{'FIRSTNAME'};
delete $pMapping->{'LASTNAME'};
}
$sError .= CheckInputField(0, $pMapping, \%::g_BillContact);
if ($::g_InputHash{'COUPONCODE'} ne "" &&
$$::g_pDiscountBlob{'COUPON_ON_CHECKOUT'})
{
$::Session->GetCartObject();
$::g_PaymentInfo{'COUPONCODE'} = $::g_InputHash{'COUPONCODE'};
@Response = ActinicDiscounts::ValidateCoupon($::g_PaymentInfo{'COUPONCODE'});
if ($Response[0] == $::FAILURE)
{
$sError .= ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . $Response[1] . ACTINIC::GetPhrase(-1, 1970);
}
}
if ($$::g_pSetupBlob{'CHECKOUT_NEEDS_TERMS_AGREED'} &&
!$::g_BillContact{'AGREEDTANDC'})
{
$sError .= ACTINIC::GetPhrase(-1, 2385);
}
if (ACTINIC::IsPromptRequired(0, 14) &&
$::g_BillContact{'USERDEFINED'} eq "" &&
!$ACTINIC::B2B->Get('UserDigest'))
{
$sError .= ACTINIC::GetRequiredMessage(0, 14);
}
if (length $::g_BillContact{'USERDEFINED'} > $::g_pFieldSizes->{'USERDEFINED'})
{
$sError .= ACTINIC::GetLengthFailureMessage(0, 14, $::g_pFieldSizes->{'USERDEFINED'});
}
if($sError eq '')
{
$sError .= ActinicOrder::ValidatePreliminaryInfo($bActuallyValidate);
}
return ($sError);
}
sub ValidateShipContact
{
if ($#_ != 0)
{
ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidateShipContact'), ACTINIC::GetPath());
}
my ($bActuallyValidate) = @_;
if ($::ACT_ADB)
{
ConfigureAddressBook();
$::ACT_ADB->ToForm();
$::s_VariableTable{$::VARPREFIX.'ADDRESSBOOK'} = $::ACT_ADB->Show();
}
else
{
$::s_VariableTable{$::VARPREFIX.'ADDRESSBOOK'} = "";
}
my $bCheckReversed = (defined $$::g_pSetupBlob{'REVERSE_ADDRESS_CHECK'} &&
$$::g_pSetupBlob{'REVERSE_ADDRESS_CHECK'});
if( $::g_InputHash{ADDRESSSELECT} )
{
my $sUserDigest = $ACTINIC::B2B->Get('UserDigest');
my ($status, $sMessage, $pBuyer) = ACTINIC::GetBuyer($sUserDigest, ACTINIC::GetPath());
if ($status != $::SUCCESS)
{
return ($sMessage);
}
my $pAccount;
($status, $sMessage, $pAccount) = ACTINIC::GetCustomerAccount($$pBuyer{AccountID}, ACTINIC::GetPath());
if ($status != $::SUCCESS)
{
return ($sMessage);
}
my $pAddress;
($status, $sMessage, $pAddress) = ACTINIC::GetCustomerAddress($$pBuyer{AccountID}, $::g_InputHash{ADDRESSSELECT}, ACTINIC::GetPath());
ACTINIC::CloseCustomerAddressIndex();
if ($status != $::SUCCESS)
{
return ($sMessage);
}
$::g_ShipContact{'COMPANY'} = $pAccount->{AccountName};
$::g_ShipContact{'NAME'} = $pBuyer->{Name};
$::g_ShipContact{'FIRSTNAME'} = $pBuyer->{'FirstName'};
$::g_ShipContact{'LASTNAME'} = $pBuyer->{'LastName'};
$::g_ShipContact{'SALUTATION'} = $pBuyer->{Salutation};
$::g_ShipContact{'JOBTITLE'} = $pBuyer->{Title};
$::g_ShipContact{'PHONE'} = $pBuyer->{'TelephoneNumber'};
$::g_ShipContact{'MOBILE'} = $pBuyer->{'MobileNumber'};
$::g_ShipContact{'FAX'} = $pBuyer->{'FaxNumber'};
if (length $::g_ShipContact{'PHONE'} > $::g_pFieldSizes->{'PHONE'})
{
$::g_ShipContact{'PHONE'} =~ s/(.*?)(\/.*|$)/$1/;
}
$::g_ShipContact{'PHONE'} =~ s/(.{0,$::g_pFieldSizes->{'PHONE'}}).*/$1/;
$::g_ShipContact{'MOBILE'} =~ s/(.{0,$::g_pFieldSizes->{'MOBILE'}}).*/$1/;
$::g_ShipContact{'FAX'} =~ s/(.{0,$::g_pFieldSizes->{'FAX'}}).*/$1/;
$::g_ShipContact{'EMAIL'} = $pBuyer->{'EmailAddress'};
$::g_ShipContact{'ADDRESS1'} = $pAddress->{'Line1'};
$::g_ShipContact{'ADDRESS2'} = $pAddress->{'Line2'};
$::g_ShipContact{'ADDRESS3'} = $pAddress->{'Line3'};
$::g_ShipContact{'ADDRESS4'} = $pAddress->{'Line4'};
$::g_ShipContact{'POSTALCODE'} = $pAddress->{'PostCode'};
$::g_ShipContact{'COUNTRY'} = ACTINIC::GetCountryName($pAddress->{'CountryCode'});
$::g_ShipContact{PRIVACY} = $::TRUE;
}
else
{
if (((!$bCheckReversed && !$::g_BillContact{'SEPARATE'}) ||
($bCheckReversed && $::g_BillContact{'SEPARATE'})) )
{
$::g_ShipContact{'SALUTATION'} = $::g_BillContact{'SALUTATION'};
$::g_ShipContact{'NAME'} = $::g_BillContact{'NAME'};
$::g_ShipContact{'FIRSTNAME'} = $::g_BillContact{'FIRSTNAME'};
$::g_ShipContact{'LASTNAME'} = $::g_BillContact{'LASTNAME'};
$::g_ShipContact{'JOBTITLE'} = $::g_BillContact{'JOBTITLE'};
$::g_ShipContact{'COMPANY'} = $::g_BillContact{'COMPANY'};
$::g_ShipContact{'ADDRESS1'} = $::g_BillContact{'ADDRESS1'};
$::g_ShipContact{'ADDRESS2'} = $::g_BillContact{'ADDRESS2'};
$::g_ShipContact{'ADDRESS3'} = $::g_BillContact{'ADDRESS3'};
$::g_ShipContact{'ADDRESS4'} = $::g_BillContact{'ADDRESS4'};
$::g_ShipContact{'POSTALCODE'} = $::g_BillContact{'POSTALCODE'};
$::g_ShipContact{'COUNTRY'} = $::g_BillContact{'COUNTRY'};
my $sUserDigest = $ACTINIC::B2B->Get('UserDigest');
if ($sUserDigest)
{
my ($status, $sMessage, $pBuyer) = ACTINIC::GetBuyer($sUserDigest, ACTINIC::GetPath());
if ($status != $::SUCCESS)
{
return ($sMessage);
}
$::g_ShipContact{'PHONE'} = $pBuyer->{'TelephoneNumber'};
$::g_ShipContact{'MOBILE'} = $pBuyer->{'MobileNumber'};
$::g_ShipContact{'FAX'} = $pBuyer->{'FaxNumber'};
if (length $::g_ShipContact{'PHONE'} > $::g_pFieldSizes->{'PHONE'})
{
$::g_ShipContact{'PHONE'} =~ s/(.*?)(\/.*|$)/$1/;
}
$::g_ShipContact{'PHONE'} =~ s/(.{0,$::g_pFieldSizes->{'PHONE'}}).*/$1/;
$::g_ShipContact{'MOBILE'} =~ s/(.{0,$::g_pFieldSizes->{'MOBILE'}}).*/$1/;
$::g_ShipContact{'EMAIL'} = $pBuyer->{'EmailAddress'};
}
else
{
$::g_ShipContact{'PHONE'} = $::g_BillContact{'PHONE'};
$::g_ShipContact{'MOBILE'} = $::g_BillContact{'MOBILE'};
$::g_ShipContact{'FAX'} = $::g_BillContact{'FAX'};
$::g_ShipContact{'EMAIL'} = $::g_BillContact{'EMAIL'};
}
$::g_ShipContact{'USERDEFINED'} = "";
}
else
{
$::g_ShipContact{'SALUTATION'} = $::g_InputHash{'DELIVERSALUTATION'};
$::g_ShipContact{'NAME'} = $::g_InputHash{'DELIVERNAME'};
$::g_ShipContact{'FIRSTNAME'} = $::g_InputHash{'DELIVERFIRSTNAME'};
$::g_ShipContact{'LASTNAME'} = $::g_InputHash{'DELIVERLASTNAME'};
$::g_ShipContact{'JOBTITLE'} = $::g_InputHash{'DELIVERJOBTITLE'};
$::g_ShipContact{'COMPANY'} = $::g_InputHash{'DELIVERCOMPANY'};
$::g_ShipContact{'ADDRESS1'} = $::g_InputHash{'DELIVERADDRESS1'};
$::g_ShipContact{'ADDRESS2'} = $::g_InputHash{'DELIVERADDRESS2'};
$::g_ShipContact{'ADDRESS3'} = $::g_InputHash{'DELIVERADDRESS3'};
$::g_ShipContact{'ADDRESS4'} = $::g_InputHash{'DELIVERADDRESS4'};
$::g_ShipContact{'POSTALCODE'} = $::g_InputHash{'DELIVERPOSTALCODE'};
$::g_ShipContact{'COUNTRY'} = $::g_InputHash{'DELIVERCOUNTRY'};
$::g_ShipContact{'PHONE'} = $::g_InputHash{'DELIVERPHONE'};
$::g_ShipContact{'MOBILE'} = $::g_InputHash{'DELIVERMOBILE'};
$::g_ShipContact{'FAX'} = $::g_InputHash{'DELIVERFAX'};
$::g_ShipContact{'EMAIL'} = $::g_InputHash{'DELIVEREMAIL'};
$::g_ShipContact{'USERDEFINED'} = $::g_InputHash{'DELIVERUSERDEFINED'};
}
$::g_ShipContact{'PRIVACY'} = $::g_BillContact{'PRIVACY'};
}
if ($$::g_pSetupBlob{SHOPPER_NAME_HANDLING_MODE} eq 1)
{
$::g_ShipContact{'NAME'} = $::g_ShipContact{'FIRSTNAME'} .' '. $::g_ShipContact{'LASTNAME'};
$::g_ShipContact{'NAME'} =~ s/(.{0,$::g_pFieldSizes->{'NAME'}}).*/$1/;
}
ACTINIC::TrimHashEntries(\%::g_ShipContact);
my ($sError);
if ((ACTINIC::IsPromptRequired(1, 12) ||
length $::g_ShipContact{'EMAIL'} > 0) &&
$::g_ShipContact{'EMAIL'} !~ /\@/)
{
$sError.= ACTINIC::GetPhrase(-1, 2378);
}
if (!$bActuallyValidate ||
(!$bCheckReversed && !$::g_BillContact{'SEPARATE'}) ||
($bCheckReversed && $::g_BillContact{'SEPARATE'}))
{
return ($sError);
}
my $pMapping =
{
'SALUTATION' => 0,
'NAME' => 1,
'FIRSTNAME' => 2451,
'LASTNAME' => 2452,
'JOBTITLE' => 2,
'COMPANY' => 3,
'ADDRESS1' => 4,
'ADDRESS2' => 5,
'ADDRESS3' => 6,
'ADDRESS4' => 7,
'POSTALCODE' => 8,
'COUNTRY' => 9,
'PHONE' => 10,
'MOBILE' => 2454,
'FAX' => 11,
'EMAIL' => 12,
};
if ($$::g_pSetupBlob{SHOPPER_NAME_HANDLING_MODE} eq 1)
{
delete $pMapping->{'NAME'};
}
else
{
delete $pMapping->{'FIRSTNAME'};
delete $pMapping->{'LASTNAME'};
}
$sError .= CheckInputField(1, $pMapping, \%::g_ShipContact);
if (ACTINIC::IsPromptRequired(1, 13) &&
$::g_ShipContact{'USERDEFINED'} eq "" &&
!$ACTINIC::B2B->Get('UserDigest'))
{
$sError .= ACTINIC::GetRequiredMessage(1, 13);
}
if (length $::g_ShipContact{'USERDEFINED'} > $::g_pFieldSizes->{'USERDEFINED'})
{
$sError .= ACTINIC::GetLengthFailureMessage(1, 13, $::g_pFieldSizes->{'USERDEFINED'});
}
if($sError eq '')
{
$sError .= ActinicOrder::ValidatePreliminaryInfo($bActuallyValidate);
}
return ($sError);
}
sub CheckInputField
{
my ($nPhase, $pMapping, $pHash) = @_;
my ($sKey, $sError);
foreach $sKey (keys %{$pMapping})
{
if (ACTINIC::IsPromptRequired($nPhase, $pMapping->{$sKey}) &&
$$pHash{$sKey} eq "")
{
$sError .= ACTINIC::GetRequiredMessage($nPhase, $pMapping->{$sKey});
}
if (length $$pHash{$sKey} > $::g_pFieldSizes->{$sKey})
{
$sError .= ACTINIC::GetLengthFailureMessage($nPhase, $pMapping->{$sKey}, $::g_pFieldSizes->{$sKey});
}
}
return $sError;
}
sub ValidateShipCharge
{
if ($#_ != 0)
{
ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidateShipCharge'), ACTINIC::GetPath());
}
my ($bActuallyValidate) = @_;
my ($sError);
if ($$::g_pSetupBlob{MAKE_SHIPPING_CHARGE} &&
!ActinicOrder::IsPhaseHidden($::SHIPCHARGEPHASE))
{
my @Response = ActinicOrder::CallShippingPlugIn();
if ($bActuallyValidate)
{
if ($Response[0] != $::SUCCESS)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) .
ACTINIC::GetPhrase(-1, 102) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". $Response[1] . "
\n";
}
elsif (${$Response[2]}{ValidateFinalInput} != $::SUCCESS)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) .
ACTINIC::GetPhrase(-1, 102) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ${$Response[3]}{ValidateFinalInput} . "
\n";
}
}
}
$::g_ShipInfo{'USERDEFINED'} = $::g_InputHash{'SHIPUSERDEFINED'};
ACTINIC::TrimHashEntries(\%::g_ShipInfo);
if (defined $::g_InputHash{'SHIPUSERDEFINED'})
{
if ($bActuallyValidate &&
ACTINIC::IsPromptRequired(2, 1) &&
$::g_ShipInfo{'USERDEFINED'} eq "")
{
$sError .= ACTINIC::GetRequiredMessage(2, 1);
}
if (length $::g_ShipInfo{'USERDEFINED'} > $::g_pFieldSizes->{'USERDEFINED'})
{
$sError .= ACTINIC::GetLengthFailureMessage(2, 1, $::g_pFieldSizes->{'USERDEFINED'});
}
if ($sError ne "")
{
$sError = ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 149) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1961, $sError);
}
}
return ($sError);
}
sub ValidateGeneral
{
if ($#_ != 0)
{
ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidateGeneral'), ACTINIC::GetPath());
}
my ($bActuallyValidate) = @_;
$::g_GeneralInfo{'HOWFOUND'} = $::g_InputHash{'GENERALHOWFOUND'};
$::g_GeneralInfo{'WHYBUY'} = $::g_InputHash{'GENERALWHYBUY'};
$::g_GeneralInfo{'USERDEFINED'} = $::g_InputHash{'GENERALUSERDEFINED'};
ACTINIC::TrimHashEntries(\%::g_GeneralInfo);
my ($sError);
if (!$bActuallyValidate)
{
return ($sError);
}
my $pMapping =
{
'HOWFOUND' => 0,
'WHYBUY' => 1,
'USERDEFINED' => 2,
};
$sError .= CheckInputField(4, $pMapping, \%::g_GeneralInfo);
if ($sError ne "")
{
$sError = ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 151) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1961, $sError);
}
return ($sError);
}
sub ValidatePayment
{
if ($#_ != 0)
{
ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidatePayment'), ACTINIC::GetPath());
}
my ($bActuallyValidate) = @_;
$::g_PaymentInfo{'METHOD'} = $::g_InputHash{'PAYMENTMETHOD'};
$::g_PaymentInfo{'USERDEFINED'} = $::g_InputHash{'PAYMENTUSERDEFINED'};
$::g_PaymentInfo{'PONO'} = $::g_InputHash{'PAYMENTPONO'};
$::g_PaymentInfo{'CARDTYPE'} = $::g_InputHash{'PAYMENTCARDTYPE'};
$::g_PaymentInfo{'CARDNUMBER'} = $::g_InputHash{'PAYMENTCARDNUMBER'};
$::g_PaymentInfo{'CARDISSUE'} = $::g_InputHash{'PAYMENTCARDISSUE'};
$::g_PaymentInfo{'CARDVV2'} = $::g_InputHash{'PAYMENTCARDVV2'};
$::g_PaymentInfo{'EXPMONTH'} = $::g_InputHash{'PAYMENTEXPMONTH'};
$::g_PaymentInfo{'EXPYEAR'} = $::g_InputHash{'PAYMENTEXPYEAR'};
$::g_PaymentInfo{'STARTMONTH'} = $::g_InputHash{'PAYMENTSTARTMONTH'};
$::g_PaymentInfo{'STARTYEAR'} = $::g_InputHash{'PAYMENTSTARTYEAR'};
ACTINIC::TrimHashEntries(\%::g_PaymentInfo);
my ($sError);
if (!$bActuallyValidate)
{
return ($sError);
}
my @Response = $::Session->GetCartObject();
if ($Response[0] != $::SUCCESS)
{
return (@Response[1]);
}
my $pCartObject = $Response[2];
my $pCartList = $pCartObject->GetCartList();
my (@SummaryResponse) = $pCartObject->SummarizeOrder($::FALSE);
if (($SummaryResponse[6] == 0) ||
(!$$::g_pSetupBlob{'PRICES_DISPLAYED'}))
{
EnsurePaymentSelection();
}
else
{
if (0 == length $::g_PaymentInfo{'METHOD'})
{
return(ACTINIC::GetPhrase(-1, 55, ACTINIC::GetPhrase(-1, 152)));
}
my (@arrMethods, $nMethodID);
ActinicOrder::GenerateValidPayments(\@arrMethods);
my ($bFound) = $::FALSE;
foreach $nMethodID (@arrMethods)
{
if ($nMethodID == $::g_PaymentInfo{'METHOD'})
{
$bFound = $::TRUE;
last;
}
}
if (!$bFound)
{
return (ACTINIC::GetPhrase(-1, 2448, $::g_PaymentInfo{'METHOD'}));
}
}
my $pMapping =
{
'PONO' => 6,
'USERDEFINED' => 7,
};
$sError .= CheckInputField(5, $pMapping, \%::g_PaymentInfo);
my ($ePaymentMethod) = ActinicOrder::PaymentStringToEnum($::g_PaymentInfo{'METHOD'}); # the payment method is stored as "ENUMERATEDID:DESCRIPTION"
if ($ePaymentMethod == $::PAYMENT_CREDIT_CARD &&
!$$::g_pSetupBlob{USE_SHARED_SSL} &&
!$$::g_pSetupBlob{USE_DH} )
{
if ($::g_PaymentInfo{'CARDTYPE'} eq "")
{
$sError .= ACTINIC::GetRequiredMessage(5, 1);
}
my ($nIndex, $sCCID, $bFound);
$bFound = $::FALSE;
for ($nIndex = 0; $nIndex < 12; $nIndex++)
{
$sCCID = sprintf('CC%d', $nIndex);
if ($$::g_pSetupBlob{$sCCID} eq
$::g_PaymentInfo{'CARDTYPE'})
{
$bFound = $::TRUE;
last;
}
}
if (!$bFound)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 1) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 107, $::g_PaymentInfo{'CARDTYPE'}) . "
\n"
}
my ($nNumber) = $::g_PaymentInfo{'CARDNUMBER'};
$nNumber =~ s/\s//g;
$nNumber =~ s/-//g;
if ($nNumber eq "")
{
$sError .= ACTINIC::GetRequiredMessage(5, 2);
}
if ($nNumber =~ /[^0-9]/)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 2) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 108) . "
\n"
}
my ($nCheckSum, $nDigitCount) = (0, 0);
my ($nDigit, $nCheck);
for($nIndex = (length $nNumber) - 1; $nIndex >= 0; $nIndex--)
{
$nDigit = substr($nNumber, $nIndex, 1);
$nCheck = (1 + $nDigitCount++ % 2) *
$nDigit;
if ( $nCheck >= 10)
{
$nCheck++;
}
$nCheckSum += $nCheck;
}
if (($nCheckSum % 10) != 0)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 2) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 109) . "
\n"
}
if ($$::g_pSetupBlob{$sCCID . '_ISSUENUMBERFLAG'})
{
if ($::g_PaymentInfo{'CARDISSUE'} eq "" ||
$::g_PaymentInfo{'CARDISSUE'} < 0 ||
$::g_PaymentInfo{'CARDISSUE'} > 255)
{
$sError .= ACTINIC::GetPhrase(-1, 110, ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) .
ACTINIC::GetPhrase(5, 5) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970), $::g_PaymentInfo{'CARDTYPE'}) . "
\n"
}
}
else
{
$::g_PaymentInfo{'CARDISSUE'} = "";
}
if ($$::g_pSetupBlob{$sCCID . '_CVV2FLAG'})
{
if (length $::g_PaymentInfo{'CARDVV2'} != $$::g_pSetupBlob{$sCCID . '_CVV2DIGITS'})
{
$sError .= ACTINIC::GetPhrase(-1, 560) . "
\n"
}
}
else
{
$::g_PaymentInfo{'CARDVV2'} = "";
}
my @listCurrentTime = localtime(time);
my $nMonth = $listCurrentTime[$::TIME_MONTH];
my $nYear = $listCurrentTime[$::TIME_YEAR];
$nMonth++;
$nYear += 1900;
if ($$::g_pSetupBlob{$sCCID . '_STARTDATEFLAG'})
{
if (($::g_PaymentInfo{'STARTMONTH'} !~ /^\d{2}$/) ||
($::g_PaymentInfo{'STARTYEAR'} !~ /^\d{4}$/))
{
$sError .= ACTINIC::GetRequiredMessage(5, 3);
$::g_PaymentInfo{'STARTMONTH'} = "";
$::g_PaymentInfo{'STARTYEAR'} = "";
}
if ($::g_PaymentInfo{'STARTYEAR'} == $nYear &&
$::g_PaymentInfo{'STARTMONTH'} > $nMonth)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 3) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 111) . "
\n"
}
}
else
{
$::g_PaymentInfo{'STARTMONTH'} = "";
$::g_PaymentInfo{'STARTYEAR'} = "";
}
if (($::g_PaymentInfo{'EXPMONTH'} !~ /^\d{2}$/) ||
($::g_PaymentInfo{'EXPYEAR'} !~ /^\d{4}$/))
{
$sError .= ACTINIC::GetRequiredMessage(5, 4);
$::g_PaymentInfo{'EXPMONTH'} = "";
$::g_PaymentInfo{'EXPYEAR'} = "";
}
if ($::g_PaymentInfo{'EXPYEAR'} == $nYear &&
$::g_PaymentInfo{'EXPMONTH'} < $nMonth)
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 4) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 112) . "
\n"
}
if ($$::g_pSetupBlob{$sCCID . '_STARTDATEFLAG'})
{
if ($::g_PaymentInfo{'EXPYEAR'} < $::g_PaymentInfo{'STARTYEAR'} ||
($::g_PaymentInfo{'EXPYEAR'} == $::g_PaymentInfo{'STARTYEAR'} &&
$::g_PaymentInfo{'EXPMONTH'} <= $::g_PaymentInfo{'STARTMONTH'}))
{
$sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(5, 4) .
ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) .
ACTINIC::GetPhrase(-1, 561) . "
\n"
}
}
}
else
{
$::g_PaymentInfo{'CARDTYPE'} = "";
$::g_PaymentInfo{'CARDNUMBER'} = "";
$::g_PaymentInfo{'CARDISSUE'} = "";
$::g_PaymentInfo{'CARDVV2'} = "";
$::g_PaymentInfo{'EXPMONTH'} = "";
$::g_PaymentInfo{'EXPYEAR'} = "";
$::g_PaymentInfo{'STARTMONTH'} = "";
$::g_PaymentInfo{'STARTYEAR'} = "";
}
if ($sError ne "")
{
$sError = ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 152) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1961, $sError);
}
return ($sError);
}
sub ValidateSignature
{
$::g_sSignature = $::g_InputHash{SIGNATURE};
if ($::g_sSignature ne '')
{
$::g_sSignature =~ /^([a-fA-F0-9]{32})$/;
$::g_sSignature = $1;
}
return (undef);
}
sub DisplayPage
{
if ($#_ != 2)
{
return ($::FAILURE, ACTINIC::GetPhrase(-1, 12, 'DisplayPage'), 0, 0);
}
my (%VariableTable, $sDetailCookie);
my ($sError, $nPageNumber, $eDirection) = @_;
my (@Response, $sPath);
$sPath = ACTINIC::GetPath();
my ($pCartList);
my $sMessage;
my $bReDisplayReceipt = $::FALSE;
if($::g_InputHash{'ACTION'} !~ m/^AUTHORIZE_(\d+)$/i)
{
@Response = $::Session->GetCartObject();
if ($Response[0] == $::EOF)
{
if ($::g_InputHash{'ACTION'} =~ m/RECORDORDER/i)
{
if ($$::g_pSetupBlob{USE_DH})
{
ACTINIC::PrintText("0" . ACTINIC::GetPhrase(-1, 2040));
}
else
{
ACTINIC::PrintText("0" . ACTINIC::GetPhrase(-1, 1282));
}
exit;
}
my ($sPhaseList) = $$::g_pPhaseList{$nPageNumber};
my (@Phases) = split (//, $sPhaseList);
if (($nPageNumber == 3 && $Phases[0] == $::COMPLETEPHASE) ||
($nPageNumber == 4 && $Phases[0] == $::RECEIPTPHASE))
{
@Response = $::Session->RestoreCheckoutInfo();
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
my ($Status, $Message, $pBillContact, $pShipContact, $pShipInfo, $pTaxInfo, $pGeneralInfo, $pPaymentInfo, $pLocationInfo) = @Response;
%::g_BillContact = %$pBillContact;
%::g_ShipContact = %$pShipContact;
%::g_ShipInfo = %$pShipInfo;
%::g_TaxInfo = %$pTaxInfo;
%::g_GeneralInfo = %$pGeneralInfo;
%::g_PaymentInfo = %$pPaymentInfo;
%::g_LocationInfo = %$pLocationInfo;
@Response = $::Session->GetCartObject($::TRUE);
if ($Response[0] == $::SUCCESS)
{
$bReDisplayReceipt = $::TRUE;
}
}
if (!$bReDisplayReceipt)
{
@Response = ACTINIC::BounceToPageEnhanced(7, ACTINIC::GetPhrase(-1, 1282),
$$::g_pSetupBlob{CHECKOUT_DESCRIPTION},
$::g_sWebSiteUrl,
$::g_sContentUrl, $::g_pSetupBlob,
$::Session->GetLastShopPage(),
\%::g_InputHash,
$::FALSE);
return (@Response);
}
}
my $pCartObject = $Response[2];
$pCartList = $pCartObject->GetCartList();
my $nLineCount = CountValidCartItems($pCartList);
if ($nLineCount != scalar @$pCartList &&
$::g_bFirstError)
{
$::g_bFirstError = $::FALSE;
$sMessage = "
" . ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 175) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970);
return(DisplayPage($sMessage, $::g_nCurrentSequenceNumber, $eDirection));
}
}
my (@DeleteDelimiters, @KeepDelimiters, $nInc, $status);
my ($pVarTable, $pDeleteDelimiters, $pKeepDelimiters, $nKeyCount, $pSelectTable);
if ($bReDisplayReceipt)
{
($status, $sMessage, $pVarTable, $pDeleteDelimiters, $pKeepDelimiters) = DisplayReceiptPhase($::g_PaymentInfo{'ORDERNUMBER'}, $::g_PaymentInfo{METHOD}, $bReDisplayReceipt);
$nPageNumber = 4;
}
else
{
$nInc = ($eDirection == $::FORWARD) ? 1 : -1;
$nKeyCount = 0;
while ($nKeyCount == 0 &&
$nPageNumber >= 0)
{
my $sTempCookie;
($status, $sMessage, $pVarTable, $pDeleteDelimiters, $pKeepDelimiters, $pSelectTable, $sTempCookie) =
ProcessPage($nPageNumber);
$sDetailCookie .= $sTempCookie;
if ($status != $::SUCCESS)
{
if ($::g_bFirstError)
{
$::g_bFirstError = $::FALSE;
$sMessage = "
" . ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . $sMessage . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970);
return(DisplayPage($sMessage, $::g_nCurrentSequenceNumber, $eDirection));
}
else
{
return($status, $sMessage, 0, undef);
}
}
$nKeyCount = (keys %$pVarTable) + (keys %$pSelectTable);
$nPageNumber += $nInc;
}
$nPageNumber -= $nInc;
if ($nKeyCount == 0)
{
if (length $sError > 0)
{
my ($sRefPage) = $::Session->GetLastShopPage();
if ($$::g_pSetupBlob{UNFRAMED_CHECKOUT} &&
$$::g_pSetupBlob{UNFRAMED_CHECKOUT_URL})
{
$sRefPage = $$::g_pSetupBlob{UNFRAMED_CHECKOUT_URL};
}
my @Response = ACTINIC::BounceToPageEnhanced(-1, $sError, ACTINIC::GetPhrase(-1, 25),
$::g_sWebSiteUrl, $::g_sContentUrl, $::g_pSetupBlob, $sRefPage, \%::g_InputHash);
if ($Response[0] != $::SUCCESS)
{
ACTINIC::ReportError($sError, ACTINIC::GetPath());
}
return ($::SUCCESS, '', $Response[2], undef);
}
else
{
return ($::SUCCESS, "", GetCancelPage(), undef);
}
}
}
my (@a1, @a2);
@a1 = %VariableTable;
@a2 = %$pVarTable;
push (@a1, @a2);
%VariableTable = @a1;
@DeleteDelimiters = @$pDeleteDelimiters;
@KeepDelimiters = @$pKeepDelimiters;
if (length $VariableTable{$::VARPREFIX.'ERROR'})
{
$sError .= ' ' . $VariableTable{$::VARPREFIX.'ERROR'};
}
$sError = ACTINIC::GroomError($sError);
$VariableTable{$::VARPREFIX.'ERROR'} = $sError;
$VariableTable{$::VARPREFIX.'SEQUENCE'} = $nPageNumber;
my ($sFileName);
$sFileName = sprintf('order%2.2d.html', $nPageNumber);
if ($::g_sOverrideCheckoutFileName)
{
$sFileName = $::g_sOverrideCheckoutFileName;
}
@Response = ActinicOrder::GenerateShoppingCartLines($pCartList, $::FALSE, [], $sFileName);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
@Response = ACTINIC::TemplateFile($sPath.$sFileName, \%VariableTable);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
my ($sDigest,$sBaseFile) = ACTINIC::CaccGetCookies();
$sPath = ($sBaseFile) ? $sBaseFile : $::g_sContentUrl;
@Response = ACTINIC::MakeLinksAbsolute($Response[2], $::g_sWebSiteUrl, $sPath);
if ($Response[0] != $::SUCCESS)
{
return (@Response);
}
my ($sHTML) = $Response[2];
my ($sDelimiter);
foreach $sDelimiter (@DeleteDelimiters)
{
$sHTML =~ s/$::DELPREFIX$sDelimiter(.*?)$::DELPREFIX$sDelimiter//gs;
}
foreach $sDelimiter (@KeepDelimiters)
{
$sHTML =~ s/$::DELPREFIX$sDelimiter//gs;
}
my ($sSelectName, $sDefaultOption);
while ( ($sSelectName, $sDefaultOption) = each %$pSelectTable)
{
$sHTML =~ s/(<\s*SELECT[^>]+?NAME\s*=\s*("|')?$sSelectName.+?)