You are here

function uc_recurring_admin_charge_form_submit in UC Recurring Payments and Subscriptions 6

Same name and namespace in other branches
  1. 6.2 uc_recurring.admin.inc \uc_recurring_admin_charge_form_submit()
  2. 7.2 uc_recurring.admin.inc \uc_recurring_admin_charge_form_submit()

File

./uc_recurring.admin.inc, line 124
Recurring payments administration menu items.

Code

function uc_recurring_admin_charge_form_submit($form, &$form_state) {
  $fee = uc_recurring_fee_load('user', arg(4));

  // Attempt to process the charge.
  if (uc_recurring_charge($fee)) {

    // Update the fee in the database.
    $next_charge = strtotime('+' . $fee['regular_interval']);
    db_query("UPDATE {uc_recurring_users} SET next_charge = %d, remaining_intervals = remaining_intervals - 1, charged_intervals = charged_intervals + 1 WHERE rfid = %d", $next_charge, $fee['rfid']);
    drupal_set_message(t('Recurring fee @fee charged successfully.', array(
      '@fee' => arg(4),
    )));
  }
  else {
    drupal_set_message(t('Attempt to charge recurring fee @fee failed.', array(
      '@fee' => arg(4),
    )), 'error');
  }
  $form_state['redirect'] = 'admin/store/orders/recurring/view/fee/' . arg(4);
}