You are here

function uc_recurring_admin_charge_form_submit in Ubercart 5

File

payment/uc_recurring/uc_recurring.module, line 732
Allows you to add a recurring fee to a product/SKU to handle subscription type services.

Code

function uc_recurring_admin_charge_form_submit($form_id, $form_values) {
  $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');
  }
  return 'admin/store/orders/recurring/view/fee/' . arg(4);
}