cancel
Showing results for 
Search instead for 
Did you mean: 

Who Me Too'd this solution

Well lets start with Thanks for all the help!  Oh crap I didn't get any, Thanks you Bozo's for no help.

 

Second Thanks for crappy examples and information.

 

To solve this issue I had to download the PHP SDK and review the AIM samples again.

 

First issue, there is a Precedence in the order the data is submitted.

 

Initially I was submitting the information in this order AND when submitted with ONE item it works.

 

$sale->description = "Sales Order: " . tools::get_field_value("order_id");

$sale->line_item = "1<|>Info<|>More Info<|>1<|>23.95<|>Y"

$sale->setFields($shipping_info);

$sale->setFields($customer);

$response = $sale->authorizeAndCapture();

 

Now here is the interesting part, looking through the samples it shows to submit multiple line items you have to do the item part this way;

The first line is still the same

 

$sale->line_item = "1<|>Info<|>More Info<|>1<|>23.95<|>Y"

 

But the subsequent items are done like this

 

$sale->addLineItem('2','info','more info','1','39.95','Y')

 

SERIOUSLY A DIFFERENT FORMAT!!  Not $sale->addLineItem = "2<|>Info<|>More Info<|>1<|>23.95<|>Y" HELL NO THAT WOULD ONLY MAKE SENSE.

 

Anyway so I hard coded it and tried and tried and tried, but no it kept giving me the same error; Line 1 is invalid.  So I kept looking at the sample for multiple items in the SDK and the $sale->addLineItem were all JUST BEFORE the $response = $sale->authorizeAndCapture(); so I changed my order to;

 

$sale->description = "Sales Order: " . tools::get_field_value("order_id");

$sale->setFields($shipping_info);

$sale->setFields($customer);

$sale->line_item = "1<|>Info<|>More Info<|>1<|>23.95<|>Y"

$sale->addLineItem(2,info,more info,1,39.95,Y)

$response = $sale->authorizeAndCapture();

 

AND BAM IT WORKS.  YA THINK THAT MIGHT BE USEFULL INFORMATION TO POINT OUT!?!?!

 

Ok so on to live data, and you have to figure this out by yourself because ALL THE EXAMPLES use hardcoded data.  Anyway here is what I came up with.  The while loop is JUST before the $response = $sale->authorizeAndCapture();.

 

Notice I have to evaluate which item is being processed so the structure is changed for the first item and then all subsequent items. 

 

NOW HERE IS ANOTHER BITCH, notice the substr($row['product_name'],0,30) well I must have submitted 10 orders and all was great, then all of a sudden I got the error Line x is invalid again.  WHAT THE HELL!!!  Well it turns out there is a limit to the length of the string Authorize.net can handle, 30 characters, if you pass a string longer than that it craps out.  YA THINK THAT IS AN IMPORTANT BIT OF INFO YOU COULD HAVE NOTED IN THE EXAMPLES?!?!?  Not to mention Authorize.net could just truncate it on their end and save everyone a lot of heart ache.

 

$result = $this->system->db->query($sql);

while ($row = mysql_fetch_array($result)) {

  if ($row['order_item_id'] == 1) {

    $sale->line_item  = $row['order_item_id'] . '<|>' . substr($row['product_name'],0,30) . '<|>' . $row['width'] . ' ' . tools::get_fraction_text($row['width_frac']) . ' x ' . $row['height'] . ' ' . tools::get_fraction_text($row['height_frac']) . '<br>Color: ' . $row['option_picklist_name'] . '<|>' . $row['quantity'] . '<|>' . $row['item_total_price'] . '<|>Y';

  }

  else {

    $sale->addLineItem($row['order_item_id'], substr($row['product_name'],0,30), $row['width'] . ' ' . tools::get_fraction_text($row['width_frac']) . ' x ' . $row['height'] . ' ' . tools::get_fraction_text($row['height_frac']) . '<br>Color: ' . $row['option_picklist_name'], $row['quantity'], $row['item_total_price'], 'Y');

   }

 }

 

Again thanks for all the help you clowns. Oh that's right I didn't get any.

 

 

 

 

 

 

View solution in original post

Who Me Too'd this solution