Reply
Highlighted
Administrator
Posts: 591
Registered: ‎08-21-2009

Re: Itemized order info with AIM

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.

 

Highlighted
Contributor
Posts: 10
Registered: ‎10-07-2010

Re: Itemized order info with AIM

Any chance there's a Perl example of this?

 

Thanks!

Highlighted
Administrator
Posts: 591
Registered: ‎08-21-2009

Re: Itemized order info with AIM

[ Edited ]

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.

Highlighted
Contributor
Posts: 10
Registered: ‎10-07-2010

Re: Itemized order info with AIM

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.

Highlighted
Administrator
Posts: 591
Registered: ‎08-21-2009

Re: Itemized order info with AIM

[ Edited ]

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.

 

Highlighted
Contributor
Posts: 10
Registered: ‎10-07-2010

Re: Itemized order info with AIM

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

Highlighted
Trusted Contributor
Posts: 264
Registered: ‎09-10-2009

Re: Itemized order info with AIM

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.

Highlighted
Member
Posts: 8
Registered: ‎12-04-2010

Re: Itemized order info with AIM

[ Edited ]

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.

Highlighted
Member
Posts: 4
Registered: ‎01-18-2011

Re: Itemized order info with AIM

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 ); }

Highlighted
Administrator
Posts: 591
Registered: ‎08-21-2009

Re: Itemized order info with AIM

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'];