$versions{'AuthorizeNetSIM-order_lib.pl'} = '06.6.00.0000';
#####################################################################
#
# AgoraCart and all associated files, except where noted, are
# Copyright 2001 to Present jointly by K-Factor Technologies, Inc.
# and by C E Mayo (aka Mister Ed) at AgoraCart.com & K-Factor.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This copyright notice may not be removed or altered in any way.
#
#######################################################################
#                    Order Form Definition Variables
#######################################################################

$gateway_button_name{'AuthorizeNetSIM'} = 'Authorize.net';

$sc_order_response_vars{'AuthorizeNetSIM'} = 'x_response_code';
add_codehook( 'printSubmitPage', 'print_AuthNetSIM_SubmitPage' );
add_codehook( 'set_form_required_fields', 'AuthNetSIM_fields' );
add_codehook( 'gateway_response', 'check_for_AuthNetSIM_response' );

#######################################################################

sub AuthNetSIM_check_and_load {
    local ($myname) = 'AuthorizeNetSIM';
    if ( $myname ne $sc_gateway_name ) {
        require_supporting_libraries( __FILE__, __LINE__, "$sc_userpay_conf_dir/$myname-user_lib.pl" );
    }

}

#######################################################################

sub check_for_AuthNetSIM_response {
    if ( $form_data{'x_response_code'} && $form_data{'x_cust_id'} && $form_data{'x_invoice_num'} && $mc_mgr_gateways_enabled =~ /AuthorizeNetSIM/i) {
        $cart_id = $form_data{'x_cust_id'};
        AuthNetSIM_check_and_load();
        set_sc_cart_path();
        load_order_libs();
        load_cart_libs();
        codehook('AuthNetSIM_order');
        if ( $sc_header_printed ne 1 ) {
            &print_agora_http_headers();
        }
        process_AuthNetSIM_Order();
        call_exit();
    }
}

#######################################################################

sub AuthNetSIM_fields {

    local ($myname) = 'AuthorizeNetSIM';

    if ( !( $form_data{'gateway'} eq $myname ) ) { return; }

    set_order_form_array();

    @sc_order_form_required_fields =
      ( 'Ecom_ShipTo_Postal_City', 'Ecom_ShipTo_Postal_StateProv', 'Ecom_ShipTo_Postal_PostalCode',
      'Ecom_BillTo_Online_Email', 'Ecom_ShipTo_Postal_CountryCode' );

    # override if in donation mode
    if ( $sc_donation_mode eq 'yes' && $sc_donation_orderform_name  ) {
        @sc_order_form_required_fields = @sc_donation_form_required_fields;
    }

    if ( $AuthNetSIM_display_checkout_tos =~ /yes/i ) {
        push( @sc_order_form_required_fields, 'Ecom_tos' );
    }

    # use this codehook to change the above arrays for required fields and such
    codehook('AuthorizeNet_fields_bottom');

}

#######################################################################
# load the customer info ...

sub AuthNetSIM_order_form_prep {
    AuthNetSIM_check_and_load();
    if ( $AuthNetSIM_form_prep == 0 ) {
        if ( -f "$sc_verify_order_path" ) {
            read_verify_file();
        }
        else {
            codehook('load_customer_info');
        }
        $AuthNetSIM_form_prep = 1;
    }
    return '';
}

#######################################################################

sub AuthNetSIM_table_setup {

    #
    # To use this, put this in the email_text in the manager for HTML:
    #
    #	<!--agorascript-pre
    #	  return $AuthorizeNet_cart_table;
    #	-->
    #
    # or for text in an email:
    #
    #	<!--agorascript-pre
    #	  return $AuthorizeNet_prod_in_cart;
    #	-->
    #

    local ( @my_cart_fields, $my_cart_row_number, $result );
    local ( $count, $price, $product_id, $quantity, $total_cost, $total_qty ) = 0;
    local ( $name, $cost );

    $result   = q{};
    open( CART, "$sc_cart_path" ) || file_open_error(
        "$sc_cart_path", 'display_cart_contents_in_header',__FILE__, __LINE__ );
    while (<CART>) {
        $count++;
        chop;
        @my_cart_fields = split( /\|/, $_ );
        $my_cart_row_number = pop(@my_cart_fields);
        push( @my_cart_fields, $my_cart_row_number );
        $quantity   = $my_cart_fields[0];
        $product_id = $my_cart_fields[1];
        $price      = $my_cart_fields[$sc_cart_indeAuthNetSIM_x_of_price_after_options];
        $name       = $my_cart_fields[ $cart{'name'} ];
        $name       = substr( $name, 0, 35 );
        $cost       = format_price( $quantity * $price );
        $total_cost = $total_cost + $quantity * $price;
        $total_qty  = $total_qty + $quantity;
        $options    = $my_cart_fields[ $cart{'options'} ];
        $options =~ s/<br>/ /g;

        if ( $result eq '' ) {
            $result .= '<table cellpadding=0 cellspacing=0 border=0 width=425>';
            $result .= "<tr><td>Items Ordered:</td></tr><tr><td>\n";
            $result .=
              "<table cellpadding=3 cellspacing=0 border=1 width=100%>\n";
            $result .= "<tr><th>QTY</th><th>ID #</th><th>Description</th>";
            $result .= "<th>Cost</th></tr>\n";
            $AuthorizeNet_prod_in_cart .= "  --PRODUCT INFORMATION--\n\n";
        }
        $result .= "<tr><td>$quantity</td><td>$product_id</td>\n";
        $result .= "<td>$name</td><td>$cost</td>";
        $result .= "</tr>\n";
        $AuthorizeNet_prod_in_cart .= cart_textinfo(*my_cart_fields);
    }    # End of while (<CART>)
    close(CART);
    if ( $result ne '' ) {
        $result .= "</table></td></tr></table>\n";
    }

    # use this to change $result
    codehook('AuthNetSIM_table_setup_bottom');

    $AuthorizeNet_cart_table = $result;

}

#######################################################################

sub print_AuthNetSIM_SubmitPage {

    local ( $invoice_number, $customer_number, $displayTotal );
    local ( $test_mode, $zemail_text );
    local ($myname) = 'AuthorizeNetSIM';
    local ( $HREF_FIELDS ) = make_hidden_fields();
    local ( $my_message, $my_desc );
    local ( $additional_form_thingies ) = q{};
    local ( $AuthorizeNet_prod_in_cart ) = q{};
    local ( $AuthorizeNet_cart_table )   = q{};
    my ($tempbodytags) = q{};

    if ( !( $form_data{'gateway'} eq $myname ) || $mc_mgr_gateways_enabled !~ /$myname/i ) { return; }
    &AuthNetSIM_check_and_load();

    $displayTotal = display_price($authPrice);

    $invoice_number  = $current_verify_inv_no;
    $customer_number = $cart_id;
    $customer_number =~ s/_/./g;
    &AuthNetSIM_table_setup();
    $xAuthNetSIM_x_Header_Html_Payment_Form = script_and_substitute( $AuthNetSIM_x_header_html_payment_form, 'Anet' );
    $xAuthNetSIM_x_Footer_Html_Payment_Form = script_and_substitute( $AuthNetSIM_x_footer_html_payment_form, 'Anet' );
    $xAuthNetSIM_x_Header_Html_Receipt = script_and_substitute( $AuthNetSIM_x_header_html_receipt, 'Anet' );
    $xAuthNetSIM_x_Footer_Html_Receipt = script_and_substitute( $AuthNetSIM_x_footer_html_receipt, 'Anet' );
    $xAuthNetSIM_x_Header_Email_Receipt = script_and_substitute( $AuthNetSIM_x_header_email_receipt, 'Anet' );
    $xAuthNetSIM_x_Footer_Email_Receipt = script_and_substitute( $AuthNetSIM_x_footer_email_receipt, 'Anet' );
    $my_desc = script_and_substitute($AuthNetSIM_x_description);

    $sc_display_checkout_tos = $AuthNetSIM_display_checkout_tos;

    $my_message = script_and_substitute($AuthnetSIM_verify_message);

    if ( $AuthNetSIM_merchant_live_mode =~ /yes/i ) {
        $test_mode = q{};
    }
    else {
        $test_mode = qq|<input type="hidden" name="x_test_request" value="TRUE">|;
    }

    if ( $AuthNetSIM_sale_mode =~ /AUTH_ONLY/ ) {
        $AuthNetSIM_sale_mode =
          qq~<input type="hidden" name="x_type" value="AUTH_ONLY">~;
    }
    else {
        $AuthNetSIM_sale_mode = q{};
    }

    $tstamp = time;
    if ( $AuthNetSIM_tstamp3 =~ /add/i ) {
        $tstamp = $tstamp + $AuthNetSIM_tstamp2;
    }
    if ( $AuthNetSIM_tstamp3 =~ /subtract/i ) {
        $tstamp = $tstamp - $AuthNetSIM_tstamp2;
    }
    $sequence = int( rand 1000 );
    require "$sc_lib_dir/MD5.pl" || die "Can't require $sc_lib_dir/MD5.pl";
    $fp = hmac_hex(
        $AuthNetSIM_gateway_username . q{^}
          . $sequence . q{^}
          . $tstamp . q{^}
          . $authPrice . q{^},
        $AuthNetSIM_txnkey
    );

    # use this to add hidden form elements to submit to Auth Net
    codehook('AuthNetSIM_additional_form_elements');

    #<input type="hidden" name="x_receipt_link_method" value="POST">
    #<input type="hidden" name="x_receipt_link_text" value="$AuthNetSIM_x_receipt_link_text">
    #<input type="hidden" name="x_receipt_link_url" value="$sc_ssl_location_url2">
    #<input type="hidden" name="x_adc_url" value="$sc_ssl_location_url2">
    #<input type="hidden" name="x_adc_relay_response" value="TRUE">
    my $temp_URL = $sc_ssl_location_url2 . '?gateresponse=AuthNetSIM&cart_id=' . $customer_number;


    print <<ENDOFTEXT;
<form method="post" action="$AuthNetSIM_order_script_url">

<input type="hidden" name="x_amount" value="$authPrice">
<input type="hidden" name="x_freight" value="$zfinal_shipping">
<input type="hidden" name="ud_Discount" value="$zfinal_discount">
<input type="hidden" name="x_tax" value="$zfinal_sales_tax">

<input type="hidden" name="x_login" value="$AuthNetSIM_gateway_username">
<input type="hidden" name="x_invoice_num" value="$invoice_number">
<input type="hidden" name="x_description" value="$AuthNetSIM_x_description">
<input type="hidden" name="x_cust_id" value="$customer_number">
<input type="hidden" name="x_show_form" value="PAYMENT_FORM">
$AuthNetSIM_sale_mode
$test_mode
$additional_form_thingies
<input type="hidden" name="x_relay_url" value="$sc_ssl_location_url2">
<input type="hidden" name="x_relay_response" value="TRUE">
<input type="hidden" name="x_version" value="3.1">
<input type="hidden" name="x_header_html_payment_form" value="$xAuthNetSIM_x_Header_Html_Payment_Form">
<input type="hidden" name="x_footer_html_payment_form" value="$xAuthNetSIM_x_Footer_Html_Payment_Form">
<input type="hidden" name="x_color_background" value="$AuthNetSIM_x_color_background">
<input type="hidden" name="x_color_link" value="$AuthNetSIM_x_color_link">
<input type="hidden" name="x_color_text" value="$AuthNetSIM_x_color_text">
<input type="hidden" name="x_logo_url" value="$AuthNetSIM_x_logo_url">
<input type="hidden" name="x_header_html_receipt" value="$xAuthNetSIM_x_Header_Html_Receipt">
<input type="hidden" name="x_footer_html_receipt" value="$xAuthNetSIM_x_Footer_Html_Receipt">
<input type="hidden" name="x_header_email_receipt" value="$xAuthNetSIM_x_Header_Email_Receipt">
<input type="hidden" name="x_footer_email_receipt" value="$xAuthNetSIM_x_Footer_Email_Receipt">
<input type="hidden" name="x_fp_sequence" value="$sequence">
<input type="hidden" name="x_fp_timestamp" value="$tstamp">
<input type="hidden" name="x_fp_hash" value="$fp">
<!--Billing Address-->
<input type="hidden" name="x_first_name" value="$eform_data{'Ecom_BillTo_Postal_Name_First'}">
<input type="hidden" name="x_last_name" value="$eform_data{'Ecom_BillTo_Postal_Name_Last'}">
<input type="hidden" name="x_address" value="$eform_data{'Ecom_BillTo_Postal_Street_Line1'}">
<input type="hidden" name="x_city" value="$eform_data{'Ecom_BillTo_Postal_City'}">
<input type="hidden" name="x_state" value="$eform_data{'Ecom_BillTo_Postal_StateProv'}">
<input type="hidden" name="x_zip" value="$eform_data{'Ecom_BillTo_Postal_PostalCode'}">
<input type="hidden" name="x_country" value="$eform_data{'Ecom_BillTo_Postal_CountryCode'}">
<input type="hidden" name="x_phone" value="$eform_data{'Ecom_BillTo_Telecom_Phone_Number'}">
<input type="hidden" name="x_email" value="$eform_data{'Ecom_BillTo_Online_Email'}">
<!--Shipping Address-->
<input type="hidden" name="x_ship_to_first_name" value="$eform_data{'Ecom_ShipTo_Postal_Name_First'}">
<input type="hidden" name="x_ship_to_last_name" value="$eform_data{'Ecom_ShipTo_Postal_Name_Last'}">
<input type="hidden" name="x_ship_to_address" value="$eform_data{'Ecom_ShipTo_Postal_Street_Line1'}">
<input type="hidden" name="x_ship_to_city" value="$eform_data{'Ecom_ShipTo_Postal_City'}">
<input type="hidden" name="x_ship_to_state" value="$eform_data{'Ecom_ShipTo_Postal_StateProv'}">
<input type="hidden" name="x_ship_to_zip" value="$eform_data{'Ecom_ShipTo_Postal_PostalCode'}">
<input type="hidden" name="x_ship_to_country" value="$eform_data{'Ecom_ShipTo_Postal_CountryCode'}">
ENDOFTEXT

    if ( $AuthNetSIM_verifytable eq '' ) {
        $AuthNetSIM_verifytable = 'verifyTable_standard.inc';
    }
    require_supporting_libraries( __FILE__, __LINE__, "$sc_cartverifyplates_dir/$AuthNetSIM_verifytable" );

    print $sc_verifytable_at_checkout;

}
############################################################################################
sub process_AuthNetSIM_Order {
    local ( $subtotal, $total_quantity, $total_measured_quantity, $text_of_cart,
        $html_of_cart, $html_of_cart_header, $weight, $required_fields_filled_in,
        $product, $quantity, $options );
    local ($stevo_shipping_thing) = q{};
    local ($stevo_shipping_names) = q{};
    local ( $ship_thing_too, $ship_instructions, $xcomments_html );
    local (%orderLoggingHash);
    local ($verification) = q{};
    local (%zip_list);
    local (%zip_names_list);
    $sc_use_secure_header_at_checkout = 'yes';
    $sc_skip_store_header_at_thankyou = 'yes';

    my $temp_admin_email_template = $AuthNetSIM_admin_email_template;
    if ( $temp_admin_email_template eq '' ) {
        $temp_admin_email_template = 'admin_emailPlate_text_default01.inc';
    }

    my $temp_email_template = $AuthNetSIM_email_template;
    if ( $temp_email_template eq '' ) {
        $temp_email_template = 'emailPlate_text_default01.inc';
    }

    load_verify_file();

    if ( $cart_id ne $form_data{'x_cust_id'} ) {
        $verification .= "\nWARNING: Cart ID does NOT match expected value!!\n\n";
    }

    codehook('process-order-routine-top');

    $orderDate = get_date();

    # print store header
    standard_page_header();
    CheckoutStoreHeader();

        # default data entered at cart order  form logged here, if exists.
    populate_orderlogging_hash();

    $orderLoggingHash{'orderDate'}   = "$orderDate";
    $orderLoggingHash{'GatewayUsed'} = 'AuthorizeNetSIM';

    if ( $sc_use_html_customer_emails =~ /yes/i )  {
        $html_of_cart_header = cart_html_headerinfo();
    }

    open( CART, "$sc_cart_path" )
      || file_open_error( "$sc_cart_path", 'display_cart_contents', __FILE__,__LINE__ );

    while (<CART>) {
        $cartData++;
        @cart_fields   = split( /\|/, $_ );
        $quantity      = $cart_fields[0];
        $product_price = $cart_fields[3];
        $product       = $cart_fields[4];
        $weight        = $cart_fields[6];
        $options       = $cart_fields[ $cart{"options"} ];
        $options =~ s/<br>/ /g;
        $text_of_cart         .= cart_textinfo(*cart_fields);
        if ($sc_use_html_customer_emails =~ /yes/i)  {
            $html_of_cart .= cart_html_textinfo(*cart_fields);
        }
        $stevo_shipping_thing .= "|$quantity\*$weight";
        $stevo_shipping_names .= "|$product\($options\)";
        codehook('process-cart-item');
    }
    close(CART);

    $sc_orderlib_use_SBW_for_ship_ins = $sc_use_SBW;

    codehook('orderlib-ship-instructions');

    if ( $sc_orderlib_use_SBW_for_ship_ins =~ /yes/i ) {
        ( $ship_thing_too, $ship_instructions ) = ship_put_in_boxes(
            $stevo_shipping_thing, $stevo_shipping_names,
            $sc_verify_Origin_ZIP, $sc_verify_boxes_maAuthNetSIM_x_wt
        );
    }

    $orderLoggingHash{'shippingMessages'} = "$ship_instructions";
    $orderLoggingHash{'shippingMessages'} =~ s/\n/<br>/g;
    $orderLoggingHash{'cart_and_order_id'} = "$form_data{'x_cust_id'}";
    $orderLoggingHash{'cart_invoiceNumber'}  = "$form_data{'x_invoice_num'}";

    if ( $sc_verify_shipping ne $form_data{'x_freight'} ) {
        $verification .= "\nWARNING: Shipping Cost from gateway does NOT match expected value!!\n\n";
    }

    if ( $form_data{'x_tax'} ne $sc_verify_tax ) {
        $verification .= 'WARNING: sales taxes from gateway does not match expected sales tax.\n';
    }

    if ( $form_data{'x_amount'} ne $sc_verify_grand_total ) {
        $verification .= "WARNING: Grand total from gateway does not match expected grand total.\n";
    }

    $orderLoggingHash{'fullName'} =   "$form_data{'x_first_name'} $form_data{'x_last_name'}";
    $orderLoggingHash{'firstName'}        = "$form_data{'x_first_name'}";
    $orderLoggingHash{'lastName'}         = "$form_data{'x_last_name'}";
    $orderLoggingHash{'orderFromAddress'} = "$form_data{'x_address'}";
    $orderLoggingHash{'orderFromCity'}    = "$form_data{'x_city'}";
    $orderLoggingHash{'orderFromState'}   = "$form_data{'x_state'}";
    $orderLoggingHash{'orderFromPostal'}  = "$form_data{'x_zip'}";
    $orderLoggingHash{'orderFromCountry'} = "$form_data{'x_country'}";
    $orderLoggingHash{'customerPhone'}    = "$form_data{'x_phone'}";
    $orderLoggingHash{'emailAddress'}     = "$form_data{'x_email'}";

    $sc_thankyou_page_header_title_box =~ s/\[\[verify_page_header_text\]\]/$agora_thankyou_page_title_text/g;
    $sc_thankyou_page_header_title_box =~ s/\[\[name\]\]/$orderLoggingHash{'firstName'}/g;
    print $sc_thankyou_page_header_title_box;
    if ( $AuthNetSIM_show_table ne 'no') {
        display_thanks_cart_table();
    }

    if ( $form_data{'x_ship_to_first_name'} ) {
        $orderLoggingHash{'shipToName'} = "$form_data{'x_ship_to_first_name'} $form_data{'x_ship_to_last_name'}";
    }
    else {
        $orderLoggingHash{'shipToName'} =
          "$form_data{'x_first_name'} $form_data{'x_last_name'}";
    }

    if ( $form_data{'x_ship_to_address'} ) {
        $orderLoggingHash{'shipToAddress'} = "$form_data{'x_ship_to_address'}";
    }
    else {
        $orderLoggingHash{'shipToAddress'} = "$form_data{'x_address'}";
    }

    if ( $form_data{'x_ship_to_city'} ) {
        $orderLoggingHash{'shipToCity'} = "$form_data{'x_ship_to_city'}";
    }
    else {
        $orderLoggingHash{'shipToCity'} = "$form_data{'x_city'}";
    }

    if ( ( $form_data{'x_ship_to_state'} ) && ( $form_data{'x_ship_to_state'} eq $eform_Ecom_ShipTo_Postal_StateProv ) )  {
        $orderLoggingHash{'shipToState'} = "$form_data{'x_ship_to_state'}";
    }
    else {
        $orderLoggingHash{'shipToState'} = "$eform_Ecom_ShipTo_Postal_StateProv";
        $verification .= "WARNING: Ship to State/Province from gateway does not match expected state/province.\n";
    }

    if ( ( $form_data{'x_ship_to_zip'} ) && ( $form_data{'x_ship_to_zip'} eq $eform_Ecom_ShipTo_Postal_PostalCode ) )   {
        $orderLoggingHash{'shipToPostal'} = "$form_data{'x_ship_to_zip'}";
    }
    else {
        $orderLoggingHash{'shipToPostal'} = "$eform_Ecom_ShipTo_Postal_PostalCode";
        $verification .= "WARNING: Ship to zip/postal code from gateway does not match expected zip/postal code.\n";
    }

    if ( $form_data{'x_ship_to_country'} ) {
        $orderLoggingHash{'shipToCountry'} = "$form_data{'x_ship_to_country'}";
    }
    else {
        $orderLoggingHash{'shipToCountry'} = "$eform_Ecom_ShipTo_Postal_CountryCode";
    }

    codehook('process-order-pre-xcomments');

    $orderLoggingHash{'adminMessages'} =
      "$verification<br><br>$XCOMMENTS_ADMIN";
    $orderLoggingHash{'adminMessages'} .=
        qq|\nAUTHORIZATION INFORMATION --------------\nRESP CODE: $form_data{'x_response_code'}\nRESP SUBCODE: $form_data{'x_response_subcode'}\nREASON CODE: $form_data{'x_response_reason_code'}\nREASON TEXT: $form_data{'x_response_reason_text'}\nAUTH CODE: $form_data{'x_auth_code'}\nAVS CODE: $form_data{'x_avs_code'}\nTRANS ID: $form_data{'x_trans_id'}\n--------------------------------------------\n|;
    $orderLoggingHash{'xcomments'} = "$XCOMMENTS";

    $AuthNetSIM_x_description .= ' - ' . $form_data{'x_invoice_num'};

    if ( $sc_send_order_to_email =~ /yes/i ) {
        local $text_of_cart_to_send = replace_email_template_tokens($temp_admin_email_template);
        codehook('admin_mailtosend');
        send_mail(
            $sc_admin_email, $sc_order_email,
            $AuthNetSIM_x_description, $text_of_cart_to_send
        );
    }

    if ( $cartData && $form_data{'x_email'} ) {
        if ($sc_use_html_customer_emails =~ /yes/i)  {
            $sc_email_content_type = 'text/html';
        }
        $xcomments_html = $orderLoggingHash{'xcomments'};
        $xcomments_html =~ s/\n/<br>/g;
        my $text_of_cart_to_send = replace_email_template_tokens($temp_email_template);
        send_mail(
            $sc_admin_email,        $form_data{'x_email'},
            $messages{'ordcnf_08'}, "$text_of_cart_to_send"
        );
    }

    $orderLoggingHash{'adminMessages'} =~ s/\n/<br>/g;
    $orderLoggingHash{'adminMessages'} =~ s/\t/ /g;
    $orderLoggingHash{'xcomments'}     =~ s/\n/<br>/g;
    $orderLoggingHash{'adminMessages'} =~ s/\t/ /g;

    log_order( $form_data{'x_invoice_num'}, $form_data{'x_cust_id'} );

    $sc_affiliate_order_unique = $form_data{'x_invoice_num'};
    $sc_affiliate_order_total = format_price( $orderLoggingHash{'affiliateTotal'} );
    $sc_affiliate_image_call =~ s/AMOUNT/$sc_affiliate_order_total/g;
    $sc_affiliate_image_call =~ s/UNIQUE/$sc_affiliate_order_unique/g;

    codehook('process-order-display-thankyou-page');

    if ( $AuthNetSIM_thankstable eq '' ) {
        $AuthNetSIM_thankstable = 'thanksTable_basic1.inc';
    }
    require_supporting_libraries( __FILE__, __LINE__,"$sc_thankyouplates_dir/$AuthNetSIM_thankstable" );

    print $sc_thankstable_after_checkout;
    print qq{<br><br>$sc_affiliate_image_call};

    CheckoutStoreFooter();

    undef(%form_data);

    set_agora('AGORA_ORDER_COMPLETED', 'yes');
    agora_cookie_save();
    empty_cart();

}

#######################################################################

1;
