Jump to content



Issue Information

  • #000454

  • 0 - None Assigned

  • New

  • 2.3.1

  • -

Issue Confirmations

  • Yes (0)No (0)
Photo

Authorize.net AIM Failure authorize.net failure

Posted by cannuck1964 on 01 May 2012 - 13:31

When using the authorize.net_cc_aim module and the customer has an item like this in the cart :


Energizer® Illumifold™ Flashlight Folding Fluorescent

the special characters will create a failure on the payment with an item is invalid error.

this comes from lines 173 - 175 :

	  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

		$post_string .= '&x_line_item=' . urlencode($i+1) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 15)) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 255)) . '<|>' . urlencode($order->products[$i]['qty']) . '<|>' . urlencode($this->format_raw($order->products[$i]['final_price'])) . '<|>' . urlencode($order->products[$i]['tax'] > 0 ? 'YES' : 'NO');

	  }

The line is truncated first, then ulrencoded.

This makes the resulting line longer then 31 characters and thus fails. Fix is to urlencode first, then truncate to 31 characters.

The SIM module may have this as an issue as well.

cheers

Further to this, it seems that the special characters will still fail even if they are encoded then truncated.

Maybe that the information needs to be parsed first then urlencode then truncated.

cheers

Further testing has shown this is working with the special characters :


	  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
	    $post_string .= '&x_line_item=' . urlencode($i+1) . '<|>' . substr(htmlspecialchars($order->products[$i]['name']), 0, 31) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 255)) . '<|>' . urlencode($order->products[$i]['qty']) . '<|>' . urlencode($this->format_raw($order->products[$i]['final_price'])) . '<|>' . urlencode($order->products[$i]['tax'] > 0 ? 'YES' : 'NO');
	  }


Not a perfect fix, but one that at least fixes the issue.

cheers