You are here

function uc_credit_cache in Ubercart 5

Same name and namespace in other branches
  1. 8.4 payment/uc_credit/uc_credit.module \uc_credit_cache()
  2. 6.2 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.

7 calls to uc_credit_cache()
uc_credit_cart_review_pre_form_submit in payment/uc_credit/uc_credit.module
uc_credit_cron in payment/uc_credit/uc_credit.module
Implementation of hook_cron().
uc_credit_form_alter in payment/uc_credit/uc_credit.module
Implementation of hook_form_alter().
uc_credit_order in payment/uc_credit/uc_credit.module
Implementation of hook_order().
uc_credit_terminal_form_submit in payment/uc_credit/uc_credit.module

... See full list

File

payment/uc_credit/uc_credit.module, line 1606
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.
      $cc_cache = unserialize($crypt
        ->decrypt($key, $data));
    }
    else {
      $cc_cache = $data;
    }
  }
  elseif ($op == 'clear') {
    $cc_cache = array();
  }
  return $cc_cache;
}