You are here

function uc_recurring_authorizenet_cim_renew in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 includes/uc_recurring.uc_authorizenet.inc \uc_recurring_authorizenet_cim_renew()

Process a renewal using the CIM profile.

Parameters

$order: The order object.

$fee: The fee object.

Return value

TRUE if renewal succeeded

1 string reference to 'uc_recurring_authorizenet_cim_renew'
uc_recurring_uc_authorizenet_recurring_info in includes/uc_recurring.uc_authorizenet.inc
Implements hook_recurring_info().

File

includes/uc_recurring.uc_authorizenet.inc, line 76
Uc recurring implementation for the test gateway module.

Code

function uc_recurring_authorizenet_cim_renew($order, &$fee) {
  global $user;
  if (!empty($order->data['cc_txns']['references'])) {
    $refs = array_keys($order->data['cc_txns']['references']);
    $data = array(
      'txn_type' => UC_CREDIT_REFERENCE_TXN,
      'ref_id' => end($refs),
    );
    $result = uc_authorizenet_charge($order->order_id, $order->order_total, $data);
    if ($result['success'] == TRUE) {
      $result['data'] = isset($result['data']) ? $result['data'] : "";
      uc_payment_enter($order->order_id, $order->payment_method, $order->order_total, $fee->uid, $result['data'], $result['comment']);
      return TRUE;
    }
    else {
      uc_order_comment_save($order->order_id, $user->uid, $result['comment']);
      return FALSE;
    }
  }

  // Upon failure, log a message.
  uc_order_comment_save($order->order_id, $user->uid, t('Error: No credit card reference found for order.'));
  return FALSE;
}