cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

"Duplicate" transactions within a second of each other but only one cURL response logged?

I have a custom shopping cart that validates the customer's information and sends the CC details to Authorize.net. I recently ran into an issue where an order was placed but two separate transactions were processed (within 1 second of each other). The problem: only the second transaction got logged in my system.

 

Here is my process payment function that takes the payment information as a parameter and makes the cURL call and logs the response:

 

 

public function process_payment($post_data) {
		
		$auth_net_login_id			= "?????????";
		$auth_net_tran_key			= "????????????????";

		$auth_net_url				= "https://secure.authorize.net/gateway/transact.dll";
	
		switch ($post_data['payment_type']) {
			case 'CK':
				$x_method = "ECHECK";
				break;
			case 'CC':
				$x_method = "CC";
				break;
			default:
				$x_method = "CC";
				break;
		}
	
		if ($x_method == "CC") {
			$authnet_values	= array(
				"x_login" => $auth_net_login_id,
				"x_test_request" => "TRUE",
				"x_version" => "3.1",
				"x_delim_char" => "|",
				"x_delim_data" => "TRUE",
				"x_type" => "AUTH_CAPTURE",
				"x_method" => $x_method,
				"x_tran_key" => $auth_net_tran_key,
				"x_relay_response" => "FALSE",
				"x_card_num" => $post_data['cc_number'],
				"x_exp_date" => $post_data['cc_exp_month'] . '/' . $post_data['cc_exp_year'],
				"x_card_code" => $post_data['cc_verification'],
				"x_amount" => $post_data['entered_payment_amount'],
				"x_first_name" => $post_data['add_cust_fname'],
				"x_last_name" => $post_data['add_cust_lname'],
				"x_phone" => $post_data['add_cust_hphone'],
				"x_address" => $post_data['address'],
				"x_city" => $post_data['addr_city'],
				"x_state" => $post_data['addr_state'],
				"x_zip"	=> $post_data['addr_zip'],
				"x_country" => $post_data['addr_country'],
				"x_invoice_num" => date("YmdHis"),
				"x_email_customer" => "TRUE",
				"x_duplicate_window" => "1800"
			);
		}
	
		$fields = "";
		foreach( $authnet_values as $key => $value ) 
			$fields .= "$key=" . urlencode( $value ) . "&";

		$ch = curl_init($auth_net_url);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " ));
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		$resp = curl_exec($ch);
		curl_close ($ch);
		
		log_message('debug', 'payments->process_payment: ' . $resp);

		return $resp;
	}   

 

 

As you can see, each response from Authorize.net is logged, but only the second transaction's details are showing up in my log. How is it possible that two transactions could have occured within a second of each other but there is only a trace of the second one?

 

Thanks in advance!

mhunsinger
Member
7 REPLIES 7

Are you saying both transactions are in authorize.net but only logging one on your system?

Maybe your log_message can't handle 2 records with the same timestamp?

RaynorC1emen7
Expert

In your sample code, you set Test Request = True which would instruct the gateway to only validate credentials.  Transactions submitted with test request set to true won't appear in the merchant interface.

 

Richard

Yes. Both transactions are in Authorize.net but only the second one is logged.

 

Anytime Authorize.net sends a response back, it gets logged. It is as if the cURL call went out to Authorize.net to process the transaction, but never returned a response, and processed it anyway.

 

I would imagine that if two individual transactions are showing up in Authorize.net, then two individual transactions would be showing in my logs. It is as if the first transaction snuck through somehow.

The test request is set to TRUE on the live server. I must've copied the code over from the development server by mistake. Pretend that is TRUE. :)

I would imagine that if two individual transactions are showing up in Authorize.net, then two individual transactions would be showing in my logs. It is as if the first transaction snuck through somehow.

 

If the first transaction get stuck, shouldn't it be getting a timeout on the response?

 

Can you try calling this twice in a row? just to make sure it does write twice.

log_message('debug', 'payments->process_payment: ' . $resp);

log_message('debug', 'payments->process_payment: ' . $resp);

 

 

 

log_message('debug', 'payments->process_payment: ' . $resp);
log_message('debug', 'payments->process_payment: ' . $resp);

 

gives me:

 

DEBUG - 2015-08-03 10:23:56 --> payments->process_payment: 1|1|1|(TESTMODE) This transaction has been approved.|000000|P|0|20150803102355||209.98|CC|auth_capture||ma
rk|hunsinger||xxxxxxxxxx|xxxxxxxxxx|PA|22222|USA|5555555555||||||||||||||||XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|||||||||||||XXXX0027|Visa||||||||||||||||
DEBUG - 2015-08-03 10:23:56 --> payments->process_payment: 1|1|1|(TESTMODE) This transaction has been approved.|000000|P|0|20150803102355||209.98|CC|auth_capture||ma
rk|hunsinger||xxxxxxxxxx|xxxxxxxxxx|PA|22222|USA|5555555555||||||||||||||||XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|||||||||||||XXXX0027|Visa||||||||||||||||

 

Looks like it writes fine.

Look fine then, but still doesn't look like an issue with authorize.net as it did get the transactions. Do you have anything to log http traffic?