You are here

function uc_recurring_fee_load in UC Recurring Payments and Subscriptions 6

Loads a recurring fee either from a product or for a user.

Parameters

$type: 'product' to load a recurring fee product feature. 'user' to load a recurring fee schedule for a user.

$id: The ID of the fee to load, either the product feature ID or the recurring fee ID from the appropriate table.

Return value

An associative array of data for the specified fee.

4 calls to uc_recurring_fee_load()
uc_recurring_admin_charge_form in ./uc_recurring.admin.inc
uc_recurring_admin_charge_form_submit in ./uc_recurring.admin.inc
uc_recurring_admin_edit_form in ./uc_recurring.admin.inc
uc_recurring_feature_form in ./uc_recurring.module

File

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

Code

function uc_recurring_fee_load($type, $id) {
  switch ($type) {
    case 'product':
      $fee = db_fetch_array(db_query("SELECT * FROM {uc_recurring_products} WHERE pfid = %d", $id));
      if (!empty($fee)) {
        list($fee['initial_charge_value'], $fee['initial_charge_unit']) = explode(' ', $fee['initial_charge']);
        list($fee['regular_interval_value'], $fee['regular_interval_unit']) = explode(' ', $fee['regular_interval']);
      }
      break;
    case 'user':
      $fee = db_fetch_array(db_query("SELECT * FROM {uc_recurring_users} WHERE rfid = %d", $id));
      if ($fee['fee_handler'] == 'uc_recurring') {
        $fee['data'] = unserialize($fee['data']);
        if ($key = uc_credit_encryption_key()) {
          $crypt = new uc_encryption_class();
          $fee['data']['payment_details']['cc_number'] = $crypt
            ->decrypt($key, $fee['data']['payment_details']['cc_number']);
          if (variable_get('uc_credit_debug', FALSE)) {
            $fee['data']['payment_details']['cc_cvv'] = $crypt
              ->decrypt($key, $fee['data']['payment_details']['cc_cvv']);
          }
          $fee['data']['payment_details']['cc_exp_month'] = $crypt
            ->decrypt($key, $fee['data']['payment_details']['cc_exp_month']);
          $fee['data']['payment_details']['cc_exp_year'] = $crypt
            ->decrypt($key, $fee['data']['payment_details']['cc_exp_year']);
          uc_store_encryption_errors($crypt, 'uc_recurring');
        }
      }
      break;
  }
  return $fee;
}