my (@Response); # record the error to error.err #ACTINIC::RecordErrors($::g_OriginalInputData, $::g_InputHash{PATH}); # # Check if we have an unsuccessful transaction # if ($::g_InputHash{'x_response_code'} ne '1') { @Response = DisplayOCCErrorResponsePage(); ACTINIC::PrintPage($Response[2], undef); return ($::SUCCESS); } # # Check for AuthorizeNet set to Test Mode # if (($::g_InputHash{'x_auth_code'} eq '000000') && ($::g_InputHash{'x_trans_id'} =~ /^[0]+$/)) { $::g_InputHash{TM} = '1'; } # # Send relay as early as possible. The 10 second clock is ticking. # @Response = DisplayOCCSuccessResponsePage(); if ($Response[0] != $::SUCCESS) { ACTINIC::PrintText($Response[1]); } else { ACTINIC::PrintPage($Response[2], undef); } # # Ok so now we know we have a transaction so we'll cherry-pick the bits we want # my $sActinicFormatOriginalData = 'PATH=' . $::g_InputHash{PATH}; # # Add the order number # $sActinicFormatOriginalData .= '&ON=' . $::g_InputHash{ON}; # # Add the amount # $sActinicFormatOriginalData .= '&AM=' . $::g_InputHash{x_amount} * 100; $sActinicFormatOriginalData .= '&x_amount=' . $::g_InputHash{x_amount}; # # Add the authorisation_code:transaction_id # $sActinicFormatOriginalData .= '&CD=' . $::g_InputHash{x_auth_code}; $sActinicFormatOriginalData .= ':' . $::g_InputHash{x_trans_id}; # # Get the current date/time on the server # my ($sDate) = ACTINIC::GetActinicDate(); ($sDate) = ACTINIC::EncodeText2($sDate, $::FALSE); # # Add the transaction date # $sActinicFormatOriginalData .= '&DT=' . $sDate; # # Add the test mode flag if supplied # if(defined $::g_InputHash{TM}) { $sActinicFormatOriginalData .= '&TM=' . $::g_InputHash{TM}; } # # Add the authorization only flag if supplied # if(defined $::g_InputHash{PA}) { $sActinicFormatOriginalData .= '&PA=' . $::g_InputHash{PA}; } # # Add the Authorize.Net transaction ID # $sActinicFormatOriginalData .= '&TX=' . $::g_InputHash{x_trans_id}; $sActinicFormatOriginalData .= '&x_trans_id=' . $::g_InputHash{x_trans_id}; # # Add the Authorize.Net signature # $sActinicFormatOriginalData .= '&SN=' . $::g_InputHash{x_MD5_Hash}; # # Fool RecordAuthorization by ditching the original input string # $::g_OriginalInputData = $sActinicFormatOriginalData; # record the error to error.err #ACTINIC::RecordErrors($::g_OriginalInputData, $::g_InputHash{PATH}); my $sText; my $sError = RecordAuthorization(); if (length $sError != 0) # if there were any errors, { ACTINIC::RecordErrors($sError, $::g_InputHash{PATH}); # record the error to error.err } ####################################################### # # DisplayOCCSuccessResponsePage - display the OCC Response # page # # Returns: 0 - status # 1 - error if any # 2 - html # # Affects: %s_::s_VariableTable # ####################################################### sub DisplayOCCSuccessResponsePage { undef %::s_VariableTable; # # convert our receipt URL into a button form # my @Response = PrepareCallbackForm($::g_InputHash{'CALLBACKURLUSER'}); if ($Response[0] != $::SUCCESS) { return (@Response); } # # plug the values into a substitution hash # $::s_VariableTable{$::VARPREFIX.'CALLBACKURL'} = $Response[2]; $::s_VariableTable{$::VARPREFIX.'HIDDENVALUES'} = $Response[3]; $::s_VariableTable{$::VARPREFIX.'ORDERNUMBER'} = $::g_InputHash{'ON'}; if(defined $::g_InputHash{TM}) { $::s_VariableTable{$::VARPREFIX.'TXNIDMESSAGE'} = "Test Transaction. No charge was made to your Credit Card."; } else { $::s_VariableTable{$::VARPREFIX.'TXNIDMESSAGE'} = "Transaction Number: $::g_InputHash{x_trans_id}."; } # # substitute the values into the template # my ($sFileName); $sFileName = $::g_InputHash{"PATH"} . 'Act_OCCOK.html'; @Response = ACTINIC::TemplateFile($sFileName, \%::s_VariableTable); # make the substitutions if ($Response[0] != $::SUCCESS) { return (@Response); } return ($::SUCCESS, '', $Response[2]); } ####################################################### # # DisplayOCCErrorResponsePage - display the OCC error # response page # # Returns: 0 - status # 1 - error if any # 2 - html # # Affects: %s_::s_VariableTable # ####################################################### sub DisplayOCCErrorResponsePage { undef %::s_VariableTable; # # convert our return to catalog URL into a button form # my @Response = PrepareCallbackForm($::g_InputHash{'CALLBACKURLBACK'}); if ($Response[0] != $::SUCCESS) { return (@Response); } # # plug the values into a substitution hash # $::s_VariableTable{$::VARPREFIX.'CALLBACKURL'} = $Response[2]; $::s_VariableTable{$::VARPREFIX.'HIDDENVALUES'} = $Response[3]; # # get the reason for failure from AN # my $sReasonText = $::g_InputHash{'x_response_reason_text'}; $::s_VariableTable{$::VARPREFIX.'OCCFAILURE'} = ACTINIC::DecodeText($sReasonText); # # substitute the values into the template # my ($sFileName); $sFileName = $::g_InputHash{"PATH"} . 'Act_OCCError.html'; @Response = ACTINIC::TemplateFile($sFileName, \%::s_VariableTable); # make the substitutions if ($Response[0] != $::SUCCESS) { return (@Response); } return ($::SUCCESS, '', $Response[2]); } ####################################################### # # PrepareCallbackForm - Split a callback URL into a URL # and arguments as HIDDEN input # # Pararms: $sCallbackURL - callback URL # # Returns: 0 - status # 1 - error if any # 2 - URL # 3 - Hidden html # # Affects: %s_::s_VariableTable # ####################################################### sub PrepareCallbackForm { my ($sCallbackURL) = @_; my ($sURL, $sQuery) = split(/\?/, $sCallbackURL);# split query from url # # use the URL without the arguments as ADC URL # my $sHiddenValues; my ($sPair, $sName, $sValue); # # split the rest of the URL into name value pairs # foreach $sPair(split(/&/, $sQuery)) { if ($sPair ne '') # ignore the trailing '&' { ($sName, $sValue) = split(/=/, $sPair); $sHiddenValues .= "\n"; } } return ($::SUCCESS, '', $sURL, $sHiddenValues); } return ($::SUCCESS);