cancel
Showing results for 
Search instead for 
Did you mean: 

Itemized order info with AIM

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

txm1004
Member
21 REPLIES 21

Hi Tom,

 

I'm not entirely sure that I understand your question.  Just to be clear, the post string itself is never truly encoded, just each of the values that is added on to it.  You can add more values at any time prior to the obj.request being sent using a function simililar to:

 

post_string = post_string & "&<VARIABLE_NAME>=" & Server.URLEncode(<VALUE>)

 

In fact, this is exatly what is being done with the line item code that I just added.

 

Any chance there's a Perl example of this?

 

Thanks!

Actually, the feedback in this thread encouraged me to update the rest of the samples. Since late July, all of the AIM sample code available from this site has included an example of how to submit line item details.  The new section is commented out by default and is found just a few lines after the other variables are declared in all of the samples.

Thank you.  I tried that and can get 1 item to work, comment it out and the 2nd one works, but when I build out my string in Perl it won't accept it.

The logic for submitting the line items in perl is very different then what is described earlier in this thread for PHP, and actually much simpler.  The same basic problem is there, you can't add a multiple key/value pairs for x_line_item without them conflicting.  Luckily, this was accounted for in perl and you can pass multiple values for an indvidual key and the LWP::UserAgent class will automatically separate it into multiple key/value pairs when it creates the post string.

 

Within the sample, three line items are passed using the following format within $post_values:

 

"x_line_item" => ["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"]

 

This a list of 3 separate line item values in one key, it is only spread across 3 lines for readability, you will encounter formatting errors if you uncomment only one line or another.  Also don't forget to add a comma after the previous name/value pair (x_zip in the sample).  You should be able to add or remove items to that x_line_item list without any errors.

 

I was able to get the sample to work first try earlier this week (thanks for the samples!).  :manhappy:

 

My issue seems to when I pass my shopping cart values into a Perl string and try to have it passed to $post_values.  Here is the code:

 

 $cust_items = '"' . $ID_1 . "<|>" . $NAME_1 . "<|>" . $ADDTLINFO_1 . "<|>" . $QUANTITY_1 . "<|>" . $PRICE_1 . "<|>" . $tax_item . '",' .
     '"' . $ID_2 . "<|>" . $NAME_2 . "<|>" . $ADDTLINFO_2 . "<|>" . $QUANTITY_2 . "<|>" . $PRICE_2 . "<|>" . $tax_item . '"';

and then I'm trying to pass that to x_line_item this way,  "x_line_item"    => [$cust_items]

 

It works great with 1 item, but fails with the 2nd.  I have been able to print $cust_items to see tha values and it comes back as "30-02<|>2012 Fire Combo T-Shirt<|>Medium<|>1<|>14.95<|>Y","30-01<|>2012 Party T-Shirt<|>Extra Large<|>1<|>14.95<|>Y"  I can copy/paste that string to "x_line_item" it that works, but when I try to pass my sting $cust_items I get "Line item 1 is invalid."

Am I not able to place the string into "x_line_item"? 

Thank you

Good Morning All!

 

The general syntax and structure of your line item data does follow Authorize.Net's standards. Your example indicates the passing of all shopping cart items to a single line item variable (x_line_item).

 

You must instead pass each individual cart item (line item) to the corresponding x_line_item variable.

 

GOOD EXAMPLE:

 

x_line_item="30-02<|>2012 Fire Combo T-Shirt<|>Medium<|>1<|>14.95<|>Y"

x_line_item="30-01<|>2012 Party T-Shirt<|>Extra Large<|>1<|>14.95<|>Y"

 

BAD EXAMPLE:

 

x_line_item="30-02<|>2012 Fire Combo T-Shirt<|>Medium<|>1<|>14.95<|>Y,30-01<|>2012 Party T-Shirt<|>Extra Large<|>1<|>14.95<|>Y"

 

YOUR COMMENT:

 

It works great with 1 item, but fails with the 2nd.

OUR COMMENT:

Authorize.Net will pick-up the first line item based on the "Bad Example" code (provided by you), but will drop the second line item because it doesn't have a corresponding "x_line_item" parameter to match it to.

SOLUTION:

Pass each shopping cart item to the x_line_item variable individually, or come up with a secondary function to split the items before passing it to the line item variable.

How do I get the itemized order information to show up in the Merchant EMail Receipt?

 

EDIT:  Nevermind; found out I could also add merchant definited fields, so I added the information there as well.

AndrewBucklin
Member

Why will this not work with variables? I get a 500 error.  It works fine if I just enter $ amounts.  Thanks. chris

 

$dues = "$_POST['dues']";
$fund = "$_POST['fund']";
$award = "$_POST['award']";

 

$line_items = array(
"item1<|>Dues<|><|>1<|>$dues<|>Y",
"item2<|>Fund<|><|>1<|>$fund<|>Y",
"item3<|>Award<|><|>1<|>$award<|>Y");

 

foreach( $line_items as $value )
 { $data .= "&x_line_item=" . urlencode( $value ); }

I just tested this out swapping in variables instead of static values and didn't receive any kind of error.  However, I do get an error if I try and capture POST values with the code that you are using.  I would remove the extra quotation marks in $dues = "$_POST['dues']";

 

Try usingt his format:

$dues = $_POST['dues'];