Hi all,
We're having a problem with the itemized order info using the AIM method. On page 22 of the AIM developer guide is a snippet of sample code - we have copied this snippet into our test page and it always results in an error (code 270: Line item is invalid).
The code is:
x_line_item=item1<|>golf balls<|><|>2<|>18.95<|>Y&x_line_item=item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y& x_line_item=item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y&
I contacted Auth.net and told them their sample code results in an error but their customer service rep disagreed...hmmm, ok.
If we change the code to pass a single item only it works fine. Does anyone know how to fix this sample code? I've tried just about all I can think of and am close to pulling out my hair!
Thanks,
Tom
Solved! Go to Solution.
04-13-2010 04:18 PM
I'm attaching an updated copy of our AIM PHP sample code with a new section showing how to add line item details. The most common error when adding line item details to our sample code is to simply add multiple x_line_item fields to the array. Because the sample code uses associative arrays, this will usually cause a duplicate key error or all but one of the items will simply be discarded.
In the above example, the most likely problem is actually the url_encode process itself. I see that you avoided the error of duplicate keys by adding the whole url string with only one , unfortunately this presents a whole new error by urlencoding the ampersands in the string. This results in them no longer being recognized as special characters dividing the multiple x_line_item values.
Please take a look at this new sample code and let me know if you have any questions. I can provide the equivalent code for any of our AIM samples if needed. If you do find this helpful, I will consider officially adding similar code to each of our available AIM sample code downloads.
04-20-2010 02:33 PM - edited 04-20-2010 02:35 PM
Greetings,
Just submitted a sample test using the line item data provided, and was able to process a successful transaction.
========= GENERAL INFORMATION ========= Merchant : Developer Test Account Date/Time : 13-Apr-2010 06:26:14 PM Transaction ID : 2152734320 ========= ORDER INFORMATION ========= Invoice Number : Description : test Total : US $1.00 Payment Method : Visa Item : item1 Description : golf balls Quantity : 2 Unit Price : US $18.95 Item : item2 Description : golf bag Wilson golf carry bag, red Quantity : 1 Unit Price : US $39.99 Item : item3 Description : book Golf for Dummies Quantity : 1 Unit Price : US $21.99 ==== BILLING INFORMATION === Customer ID : First Name : Hasan Last Name : Robinson Company : Sound Commerce Address : 128 W13th St. Suite 916 City : Kansas city State/Province : MO Zip/Postal Code : 64105 Country : USA Phone : 8164218891 Fax : Email : hasan@soundcommerce.com ==== SHIPPING INFORMATION === First Name : Hasan Last Name : Robinson Company : Sound Commerce Address : 128 W13th St. Suite 916 City : Kansas city State/Province : MO Zip/Postal Code : 64105 Country : USA
Are you urlencoding the parameters? Please provide a snippet of how you're passing the data to Authorize.Net.
Thank You!
04-13-2010 05:29 PM
I've hardcoded it this way for testing and it always results in this error 270:
x_line_item="item1<|>golf balls<|><|>2<|>18.95<|>Y&x_line_item=item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y&x_line_item=item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y&" post_values.Add "x_line_item", x_line_item
When I pass a single item like this one below it works just fine.
x_line_item = "item1<|>golf balls<|><|>2<|>18.95<|>Y"
Is there some typo I am not seeing?
Thank you!
Tom
04-14-2010 12:49 PM
I'm having the same problem.
If I use an HTML form with multiple hidden fields with name="x_line_item" it will take the additional items.
However using the sample vb.net code for AIM, or creating a post with the same data, they get rejected.
Can anyone make this work??
04-15-2010 12:49 AM
I'm glad that I'm not the only one having problems with Authorize.net's sample code...I thought I was going crazy. :smileysad:
The itemized order feature works fine for us when using SIM...or when using just 1 single item with AIM. But the sample code does not work for multiple items and AIM.
Does anyone have a suggestion? Or may someone from Authorize.net could chime in....
Thanks!
Tom
04-15-2010 05:05 PM
I was just chatting with Auth.net's customer support (thanks, Emily - you were really trying to help!)...
We tried several things:
I believe there's a bug in this feature and asked for escalation of this issue for a development review...I hope I will hear from auth.net soon. If/when I do I will update this post.
Does anyone have any other suggestions or possible solutions? I can't image that we're the first to run into this problem...
Thanks,
Tom
04-16-2010 02:17 PM
I'm attaching an updated copy of our AIM PHP sample code with a new section showing how to add line item details. The most common error when adding line item details to our sample code is to simply add multiple x_line_item fields to the array. Because the sample code uses associative arrays, this will usually cause a duplicate key error or all but one of the items will simply be discarded.
In the above example, the most likely problem is actually the url_encode process itself. I see that you avoided the error of duplicate keys by adding the whole url string with only one , unfortunately this presents a whole new error by urlencoding the ampersands in the string. This results in them no longer being recognized as special characters dividing the multiple x_line_item values.
Please take a look at this new sample code and let me know if you have any questions. I can provide the equivalent code for any of our AIM samples if needed. If you do find this helpful, I will consider officially adding similar code to each of our available AIM sample code downloads.
04-20-2010 02:33 PM - edited 04-20-2010 02:35 PM
Hi Trevor,
Thank you for the explanation...very helpful!
Yes, if possible I'd like to see a sample code for the line items details for ASP.
Can you post this here or update the sample code library?
Thanks,
Tom
04-28-2010 12:17 PM
Since you just said ASP, I'm going to assume that you are referring to ASP classic. I've attached an updated version of the ASP classic code that adds in the line items.
04-29-2010 03:26 PM - edited 04-29-2010 03:30 PM
Hi Trevor,
Fantastic! This works like a charm now! Thank you!
One more question though...I noticed you placed the line item code after the post_string has already been completely encoded. We're then looping over our shopping cart line items and add the line items with this code:
item = Count & "<|>" & RS("ItemCode") & "<|>" & RS("ItemName") & "<|>" & RS("ItemQuantity") & "<|>" & RS("ItemDiscountedPrice") & "<|>N" post_string = post_string & "&x_line_item=" & Server.URLEncode(item)
We would also like to pass the line item info to the merchant receipt using this code:
merchant_field = "Item " & Count merchant_field_value = RS("ItemCode") & " - " & RS("ItemName") & " " & FormatCurrency(RS("ItemDiscountedPrice")) post_values.Add merchant_field, merchant_field_value
Since the post_string has already been encoded I assume that we can't add these merchant_fields during the same loop and should add them prior to the encoding of the post_string, correct? Just want to make sure we're not doing an unnecessary loop over the shopping cart...
Again, thank you for your help!
Tom
04-29-2010 04:06 PM