You are here

function uc_recurring_fee_load in Ubercart 5

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.

10 calls to uc_recurring_fee_load()
uc_authorizenet_arb_admin_cancel_form_submit in payment/uc_authorizenet/uc_authorizenet.module
uc_authorizenet_arb_admin_update_form in payment/uc_authorizenet/uc_authorizenet.module
uc_authorizenet_arb_admin_update_form_submit in payment/uc_authorizenet/uc_authorizenet.module
uc_authorizenet_arb_user_cancel_form_submit in payment/uc_authorizenet/uc_authorizenet.module
uc_authorizenet_arb_user_update_form in payment/uc_authorizenet/uc_authorizenet.module

... See full list

File

payment/uc_recurring/uc_recurring.module, line 939
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;
}