Attributes array not being passed to authorize.net correctly

luthien's picture
Offline
Joined: 01/13/2011
Juice: 22
Attributes array not being passed to authorize.net correctly

Below is some code to fix the problem with the attributes array not being passed to authorize.net correctly. Please review the code before adding to the module as there should be an easier way to do it.

in /uc_authorizenet_redirect.module, around line 276, replace:

// Form to build the submission to Authorize.net DPM
function uc_authorizenet_redirect_form(&$form_state, $order) {
  global $user, $response;

  $description = '';
  if (is_array($order->products)) {
    foreach ($order->products as $product) {
      if (!empty($description)) {
        $description .= ' / ';
      }
      $description .= $product->title . ' x' . $product->qty;
      if (is_array($product->data['attributes'])) {
        foreach ($product->data['attributes'] as $key => $value) {
          $description .= ', ' . $key . ': ' . $value;
        }
      }
    }
  }
  $description = substr($description, 0, 255);

with:

// Form to build the submission to Authorize.net DPM
function uc_authorizenet_redirect_form(&$form_state, $order) {
  global $user, $response;

  $description = '';
  if (is_array($order->products)) {
    foreach ($order->products as $product) {
      if (!empty($description)) {
        $description .= ' / ';
      }
      $description .= $product->title . ' x' . $product->qty;
      if (is_array($product->data['attributes'])) {
        foreach ($product->data['attributes'] as $key => $value) {
          if (is_array($value)) {
          $description .= ', ' . $key . ': ';
          foreach ($value as $valuestring) {
          $description .= ' ' . $valuestring;
          }
          } else {
          $description .= ', ' . $key . ': ' . $value;
          }
        }
      }
    }
  }
  $description = substr($description, 0, 255);

Authorize.net (SIM) payment method By: Tanjerine (72 replies) Fri, 06/06/2008 - 07:14