cancel
Showing results for 
Search instead for 
Did you mean: 

Adding multiple line items using AIM in vb.net windows client.

Hello, I've been trying many different options and looking at many post here but cannot figure out how to get multiple line items to post.

If I only have one line item this code works perfect, but as soon as I try two or more I get proverbial Error [ Line Item 1 is invalid (270) ]. someone mentioned a AddLineItem function that is in the SDK but I can find no information on how to use it and certainly not in vb.net.

 

'Line Items

If LineItems IsNot Nothing AndAlso LineItems.Count > 0 Then

For Each itm In LineItems

Dim ItemString = String.Format("{0}<|>{1}<|><|>{2}<|>{3:0.00}<|>N", itm.itemID, itm.Name, itm.Quantity, itm.UnitPrice)

InputObject.Add("x_line_item", ItemString)

Next

End If

 

Any help would be greatly appreciated.

Gatesay
Member
6 REPLIES 6

How are you passing the x_line_item? Check the exact url string you are posting to authorize.net

 

https://community.developer.authorize.net/t5/Integration-and-Testing/Itemized-order-info-with-AIM/m-...

RaynorC1emen7
Expert

Thanks for the reply Raynor,

but obviously It wouldn't even work for one item if I wasn't passing the key "x_line_item".

The code creates a valued pair objects(Key/Value) which is then posted along with all the other required processing values using:

 

webClientRequest.BaseAddress = Merchant.AuthNetBaseURL
ReturnBytes = webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject)

 

Note: the InputObject is a 30 element array off key/value pairs.

 

After seeing that Authorize.net can't accept more than one "x_line_item" key, then one must assume that the value of that key must include all the line items you have. So I am guessing you must build a delimited string of all the line items. I'm not sure how it parses that out on the Authorize.net side, but I have seen some examples of just using a comma as the delimiter. 

I did try building a string of line items delimited by a comma, but got the same failure so I'm still stumped on this.

It is odd that they would use a comma, since they went to great lenghts to define tags to seperate the line item values (i.e. <|> ) but settled on just a comma for seperating the line items?

 

The key value pair that I am sending tells Authorize.net that the string I am passing is the x_line_item so what the heck is the text string value suppose to look like for multiple items?

 

Thank you.

 

adding this to work

&x_line_item=123456<|>item3<|><|>2<|>1.00<|>N&x_line_item=987654<|>item6<|><|>4<|>5.00<|>N

 

The issue is with the key value object, it can only have 1 key of x_line_item.

thanks for the response, but it's Interesting and not clear.

 

You say that the post can only have 1 key of x_line_item, yet in your example string above you have included it 2 times.

Further more you have concatenated your example string with what, as you have a "&" as the first character in the string.

Also I asked specifically what delimiter should be used when concatenating the line item strings. Your example shows no delimiter at all unless your saying the the delimiter is actually the "&" and should be in the final string. If that is the case then the data for my "Value Pair Object" would be:

 

Key  =  "x_line_item"

Value = "123456<|>item3<|><|>2<|>1.00<|>N&987654<|>item6<|> "

 

Is that correct?

Remember I'm using the following command to post!

ReturnBytes = webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject)

the object "InputObject" is a key/value pair array (1 array element per key)

 

Example:

InputObject.Add("x_card_num", Order.CreditCardNumber)
InputObject.Add("x_exp_date", Order.ExpireDate) 'MM/DD
InputObject.Add("x_card_code", Order.SecurityCode)
InputObject.Add("x_line_item", ItemString)

etc....

 

thanks

 

Gatesay
Member

When you use AIM, at the end what you sending to authorize.net is basically an url string. How you want to build the string is up to you.

 

https://test.authorize.net/gateway/transact.dll?x_version=3.1&x_type=AUTH_ONLY&x_amount=1.99&x_card_...]

Clearly I need someone that is familar with the Authorize.net SDK.

 

The Method I'm using:

webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject)

to post is not my method, but part of the Authorize.net SDK. So I'm simply trying to build the proper Input Object to feed it.

 

the webClientRequest.UploadValues builds that actual sting that is transmitted.

 

Is there  anyone out there in this gourp that can offer me some assistance on the proper way to build the value string for the x_line_item key  used by the UploadValues method when you have multiple line items.

 

I have tried several secenarios with no luck (other than sending just one line item).

Any help in that area would be greatly appreciated.