Credit Card Number * Credit Card Expiry * / "; } function gateway_bluepay($seperator, $sessionid) { //$transact_url = get_option('transact_url'); //exit("
".print_r($_POST,true)."
"); // if($_SESSION['cart_paid'] == true) // { // header("Location: ".get_option('transact_url').$seperator."sessionid=".$sessionid); // } $x_Login= urlencode(get_option('bluepay_login')); // Replace LOGIN with your login $x_Password= urlencode(get_option("bluepay_password")); // Replace PASS with your password $x_Delim_Data= urlencode("TRUE"); $x_Delim_Char= urlencode(","); $x_Encap_Char= urlencode(""); $x_Type= urlencode("AUTH_CAPTURE"); $x_ADC_Relay_Response = urlencode("FALSE"); if(get_option('bluepay_testmode') == 1) { $x_Test_Request= urlencode("TRUE"); // Remove this line of code when you are ready to go live } # # Customer Information # $x_Method= urlencode("CC"); $x_Amount= urlencode(nzshpcrt_overall_total_price($_SESSION['delivery_country'])); //exit($x_Amount); $x_First_Name= urlencode($_POST['collected_data'][get_option('bluepay_form_first_name')]); $x_Last_Name= urlencode($_POST['collected_data'][get_option('bluepay_form_last_name')]); $x_Card_Num= urlencode($_POST['card_number']); $ExpDate = urlencode(($_POST['expiry']['month'] . $_POST['expiry']['year'])); $x_Exp_Date= $ExpDate; $x_Address= urlencode($_POST['collected_data'][get_option('bluepay_form_address')]); $x_City= urlencode($_POST['collected_data'][get_option('bluepay_form_city')]); $x_State= urlencode($_POST['collected_data'][get_option('bluepay_form_state')]); $x_Zip= urlencode($_POST['collected_data'][get_option('bluepay_form_post_code')]); $x_Email= urlencode($_POST['collected_data'][get_option('bluepay_form_email')]); $x_Email_Customer= urlencode("TRUE"); $x_Merchant_Email= urlencode(get_option('purch_log_email')); // Replace MERCHANT_EMAIL with the merchant email address # # Build fields string to post # $fields="x_Version=3.1&x_Login=$x_Login&x_Delim_Data=$x_Delim_Data&x_Delim_Char=$x_Delim_Char&x_Encap_Char=$x_Encap_Char"; $fields.="&x_Type=$x_Type&x_Test_Request=$x_Test_Request&x_Method=$x_Method&x_Amount=$x_Amount&x_First_Name=$x_First_Name"; $fields.="&x_Last_Name=$x_Last_Name&x_Card_Num=$x_Card_Num&x_Exp_Date=$x_Exp_Date&x_Address=$x_Address&x_City=$x_City&x_State=$x_State&x_Zip=$x_Zip&x_Email=$x_Email&x_Email_Customer=$x_Email_Customer&x_Merchant_Email=$x_Merchant_Email&x_ADC_Relay_Response=$x_ADC_Relay_Response"; if($x_Password!='') { $fields.="&x_Password=$x_Password"; } //exit($fields); # # Start CURL session # $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; $ref = get_option('transact_url'); // Replace this URL with the URL of this script $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "https://secure.bluepay.com/interfaces/a.net"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_NOPROGRESS, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($ch); curl_close($ch); // This section of the code is the change from Version 1. // This allows this script to process all information provided by Authorize.net... // and not just whether if the transaction was successful or not // Provided in the true spirit of giving by Chuck Carpenter (Chuck@MLSphotos.com) // Be sure to email him and tell him how much you appreciate his efforts for PHP coders everywhere $return = preg_split("/[,]+/", "$buffer"); // Splits out the buffer return into an array so . . . $details = $return[0]; // This can grab the Transaction ID at position 1 in the array // echo "Location: ".$transact_url.$seperator."sessionid=".$sessionid; // exit("
".print_r($return,true)."
"); // Change the number to grab additional information. Consult the AIM guidelines to see what information is provided in each position. // For instance, to get the Transaction ID from the returned information (in position 7).. // Simply add the following: // $x_trans_id = $return[6]; // You may then use the switch statement (or other process) to process the information provided // Example below is to see if the transaction was charged successfully if(get_option('permalink_structure') != '') { $seperator ="?"; } else { $seperator ="&"; } //exit("
".print_r($return,true)."
"); switch ($details) { case 1: // Credit Card Successfully Charged //$_SESSION['cart_paid'] = true; header("Location: ".get_option('transact_url').$seperator."sessionid=".$sessionid); exit(); break; default: // Credit Card Not Successfully Charged $_SESSION['wpsc_checkout_misc_error_messages'][] = "Credit Card Processing Error: ".$return[3]; header("Location: ".get_option('checkout_url').$seperator."total=".nzshpcrt_overall_total_price($_POST['collected_data'][get_option('country_form_field')])); exit(); break; } } function submit_bluepay() { //exit("
".print_r($_POST,true)."
"); update_option('bluepay_login', $_POST['bluepay_login']); update_option('bluepay_password', $_POST['bluepay_password']); if($_POST['bluepay_testmode'] == 1) { update_option('bluepay_testmode', 1); } else { update_option('bluepay_testmode', 0); } foreach((array)$_POST['bluepay_form'] as $form => $value) { update_option(('bluepay_form_'.$form), $value); } return true; } function form_bluepay() { $output .= " Bluepay Login Bluepay Password Test Mode \n"; if(get_option('bluepay_testmode') == 1) { $output .= "\n"; } else { $output .= "\n"; } $output .= " "; return $output; } ?>