Pay Bill - Status "9N2dzH5ubhk", "x_tran_key" => "96549LH7EZpknb2k", "x_version" => "3.1", "x_delim_data" => "TRUE", "x_delim_char" => "|", "x_relay_response" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_card_num" => $_POST["x_card_num"], "x_exp_date" => $_POST["x_exp_date"], "x_card_code" => $_POST["x_card_code"], "x_amount" => $_POST["x_amount"], "x_invoice_num" => $_POST["x_invoice_num"], "x_description" => $_POST["x_description"], "x_first_name" => $_POST["x_first_name"], "x_last_name" => $_POST["x_last_name"], "x_address" => $_POST["x_address"], "x_state" => $_POST["x_state"], "x_zip" => $_POST["x_zip"], "x_email" => $_POST["x_email"], "x_phone" => $_POST["x_phone"], "x_patient_name" => $_POST["x_patient_name"] // Additional fields can be added here as outlined in the AIM integration // guide at: ); // This section takes the input fields and converts them to the proper format // for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4" $post_string = ""; foreach( $post_values as $key => $value ) { $post_string .= "$key=" . urlencode( $value ) . "&"; } $post_string = rtrim( $post_string, "& " ); // The following section provides an example of how to add line item details to // the post string. Because line items may consist of multiple values with the // same key/name, they cannot be simply added into the above array. // // This section is commented out by default. /* $line_items = array( "item1<|>golf balls<|><|>2<|>18.95<|>Y", "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y", "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y"); foreach( $line_items as $value ) { $post_string .= "&x_line_item=" . urlencode( $value ); } */ // This sample code uses the CURL library for php to establish a connection, // submit the post, and record the response. // If you receive an error, you may want to ensure that you have the curl // library enabled in your php configuration $request = curl_init($post_url); // initiate curl object curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. $post_response = curl_exec($request); // execute curl post and store results in $post_response // additional options may be required depending upon your server configuration // you can find documentation on curl options at curl_close ($request); // close curl object // This line takes the response and breaks it into an array using the specified delimiting character $response_array = explode($post_values["x_delim_char"], $post_response); // The results are output to the screen in the form of an html numbered list. // echo "\n"; if ($response_array[2] == 1) { echo "

".$_POST["x_first_name"].", your payment was successfully submitted. Thank you.

"; }else{ file_put_contents('payments.txt', print_r($response_array, true), FILE_APPEND); echo "

".$_POST["x_first_name"]." your payment failed. Please try again.

"; } // individual elements of the array could be accessed to read certain response // fields. For example, response_array[0] would return the Response Code, // response_array[2] would return the Response Reason Code. // for a list of response fields, please review the AIM Implementation Guide ?>