You are here

function uc_credit_cache in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 payment/uc_credit/uc_credit.module \uc_credit_cache()
  2. 5 payment/uc_credit/uc_credit.module \uc_credit_cache()
  3. 7.3 payment/uc_credit/uc_credit.module \uc_credit_cache()

Caches CC details on a pageload for use in various functions.

Parameters

$op: The cache operation to perform; either 'save', 'load', or 'clear'.

$data: The encrypted, serialized string containing the CC data.

Return value

An array of credit card details.

8 calls to uc_credit_cache()
uc_credit_cart_review_back_submit in payment/uc_credit/uc_credit.module
Caches the encrypted CC data on the review order form for processing.
uc_credit_cart_review_pre_form_submit in payment/uc_credit/uc_credit.module
Caches the encrypted CC data on the review order form for processing.
uc_credit_cron in payment/uc_credit/uc_credit.module
Implements hook_cron().
uc_credit_form_alter in payment/uc_credit/uc_credit.module
Implements hook_form_alter().
uc_credit_order in payment/uc_credit/uc_credit.module
Implements hook_order().

... See full list

File

payment/uc_credit/uc_credit.module, line 1340
Defines the credit card payment method and hooks in payment gateways.

Code

function uc_credit_cache($op, $data = NULL, $encrypted = TRUE) {

  // The CC data will be stored in this static variable.
  static $cc_cache = array();
  if ($op == 'save') {
    if ($encrypted) {

      // Initialize the encryption key and class.
      $key = uc_credit_encryption_key();
      $crypt = new uc_encryption_class();

      // Save the unencrypted CC details for the duration of this request.
      // In recent versions, we base64_encode() the payment details before
      // encrypting. We can detect encoded data by the lack of colons,
      // due to base64's limited character set.
      $data = $crypt
        ->decrypt($key, $data);
      if (strpos($data, ':') === FALSE) {
        $data = base64_decode($data);
      }
      $cc_cache = unserialize($data);
    }
    else {
      $cc_cache = $data;
    }
  }
  elseif ($op == 'clear') {
    $cc_cache = array();
  }
  return $cc_cache;
}