function submit_to_authorize() { $eStore_default_currency = get_option('cart_payment_currency'); $eStore_return_url = get_option('cart_return_from_paypal_url'); $eStore_sandbox_enabled = get_option('eStore_cart_enable_sandbox'); $myAuthorize = new Authorize(); $authorize_login_id = get_option('eStore_authorize_login'); $authorize_tx_key = get_option('eStore_authorize_tx_key'); $myAuthorize->setUserInfo($authorize_login_id, $authorize_tx_key); if (get_option('eStore_auto_product_delivery') != '') { $notify = WP_ESTORE_URL . '/eStore_auth_ipn.php'; $myAuthorize->addField('x_Relay_URL', $notify); } global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $x_Description = "Cart Checkout: "; $count = 1; foreach ($_SESSION['eStore_cart'] as $item) { $id = $item['item_number']; $ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); if ($count > 1) { $x_Description .= ", "; } $x_Description .= $item['item_number']; $rounded_price = round($item['price'], 2); $item_name = substr(htmlspecialchars($item['name']), 0, 30); $line_item_val = $item['item_number'] . "<|>" . $item_name . "<|><|>" . $item['quantity'] . "<|>" . $rounded_price . "<|>" . "N"; $myAuthorize->addField('x_line_item-' . $count, $line_item_val); $count++; } //Specify the url where auth.net will return the customer after payment $total_items_in_cart = count($_SESSION['eStore_cart']); if ($total_items_in_cart == 1 && !empty($ret_product->return_url)) { //$myAuthorize->addField('x_receipt_link_URL', $ret_product->return_url); $eStore_return_url = $ret_product->return_url; } if (!empty($eStore_return_url)) { //Set the return URL $myAuthorize->addField('x_receipt_link_URL', $eStore_return_url); } //TODO - new auth.net redirection method if (WP_ESTORE_USE_AUTH_NET_ALT_REDIRECTION === '1') { $myAuthorize->addField('x_receipt_link_method', "GET"); $myAuthorize->addField('x_receipt_link_text', "Click Here to Complete Transaction"); $myAuthorize->addField('x_Relay_Response', "FALSE"); } // Shipping $myAuthorize->addField('x_freight', $_SESSION['eStore_cart_postage_cost']); // Tax if (!empty($_SESSION['eStore_cart_total_tax'])) { $myAuthorize->addField('x_tax', round($_SESSION['eStore_cart_total_tax'], 2)); } else { $myAuthorize->addField('x_tax', 0); } // Duty $myAuthorize->addField('x_duty', 0); // Total $total = round($_SESSION['eStore_cart_sub_total'] + $_SESSION['eStore_cart_postage_cost'] + $_SESSION['eStore_cart_total_tax'], 2); $myAuthorize->addField('x_Amount', $total); //If currency code is set then the "x_fp_hash" algorithm need to be updated to include this field. //$myAuthorize->addField('x_currency_code', $eStore_default_currency); // Description $myAuthorize->addField('x_Description', $x_Description); //$val = "item2<|>cricket bag<|>Wilson cricket carry bag, red<|>1<|>39.99<|>N"; $myAuthorize->addField('x_Invoice_num', rand(1, 100)); //Generate Customer ID $custId = uniqid(); $myAuthorize->addField('x_Cust_ID', $custId); // Enable test mode if needed if ($eStore_sandbox_enabled) { $myAuthorize->enableTestMode(); } // Save the order details eStore_save_order_details($custId); // Lets clear the cart reset_eStore_cart(); // Let's start the train! $myAuthorize->submitPayment2(WP_ESTORE_CLICK_HERE); }