Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / authorizenet_aim modified description

authorizenet_aim modified description

Locked

Views: 977

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
11 Jun 2009, 9:17 PM
#1
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

authorizenet_aim modified description

I needed attribute information in the authorizenet_aim payment module. I used the opportunity to change the format too.. ..it might be a useful option in the future to include or not include attribuets in the description.

 
   // Create a string that contains a listing of products ordered for the description field
    $description = '';
    for ($i=0; $i<sizeof($order->products); $i++) {
      $description .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'];
      if (sizeof($order->products[$i]['attributes']) > 0) {
        for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
          $description .= ' [' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . ']';
        }
      }
      $description .= ' + ';
    }
    // Remove the last " + " from the string
    $description = substr($description, 0, -3);
 
```SecurePay has a limit on this string and truncates ~100 characters, does anyone know if Authorize.net has a specific limit? I guess I'll find out.
12 Jun 2009, 12:11 PM
#2
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

Re: authorizenet_aim modified description

Has anyone used the "x_line_item" field? Perhaps I should have tried that instead of extending the description.

12 Jun 2009, 12:16 PM
#3
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

Re: authorizenet_aim modified description

dhcernese:

... does anyone know if Authorize.net has a specific limit? I guess I'll find out.Duh. RTFM. 255 characters.

12 Jun 2009, 12:55 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: authorizenet_aim modified description

This snippet from upcoming 2.0 code may help meet the need you're working on ... ```
// itemized contents
$itemizedItemsArray = array();
reset($this->order->products);
for ($i = 0, $n = sizeof($this->order->products); $i < $n && $i < 30; $i ++)
{
$lineItem = $this->order->products[$i]['id'] . '<|>';
$lineItem .= substr(htmlentities($this->order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 30) . '<|>';
if (isset($this->order->products[$i]['attributes']))
{
$attribs = ' (';
for ($j = 0, $m = sizeof($this->order->products[$i]['attributes']); $j < $m; $j ++)
{
$attribs .= $this->order->products[$i]['attributes'][$j]['option'] . ' - ' . $this->order->products[$i]['attributes'][$j]['value'] . '; ';
}
$attribs .= ')';
}
$lineItem .= substr(htmlentities($this->order->products[$i]['description'] . $attribs, ENT_QUOTES, 'UTF-8'), 0, 255) . '<|>';
$lineItem .= $this->order->products[$i]['qty'] . '<|>';
$lineItem .= number_format($this->order->products[$i]['final_price'], 2, '.', '') . '<|>';
$lineItem .= 'Y';
$itemizedItemsArray[] = $lineItem;
// track one-time charges
if ($this->order->products[$i]['onetime_charges'] != 0)
{
$itemizedItemsArray[] = 'OTC' . '<|>' . 'One Time Charges' . '<|>' . '(One Time Charges related to ' . substr(htmlentities($this->order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 200) . ')' . '<|>' . '1' . '<|>' . number_format($this->order->products[$i]['onetime_charges'], 2, '.', '') . '<|>' . 'Y';
}
}
$submit_data['x_line_item'] = $itemizedItemsArray;

12 Jun 2009, 1:22 PM
#5
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

Re: authorizenet_aim modified description

:clap: :clap:

1 Aug 2009, 9:14 PM
#6
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

Re: authorizenet_aim modified description

DrByte:

This snippet from upcoming 2.0 code may help meet the need you're working on ... ```
<SNIP>

1 Aug 2009, 10:00 PM
#7
dhcernese avatar

dhcernese

Zen Follower

Join Date:
Mar 2007
Location:
Pepperell, Massachusetts
Posts:
232
Plugin Contributions:
0

Re: authorizenet_aim modified description

dhcernese:

We need a nl2br() in there somewhere.```
nl2br($order->products[$i]['attributes'][$j]['value'])