You are here

function uc_credit_cache in Ubercart 7.3

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. 6.2 payment/uc_credit/uc_credit.module \uc_credit_cache()

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

Parameters

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

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

Return value

array An array of credit card details.

10 calls to uc_credit_cache()
template_preprocess_uc_order_view_row_invoice in uc_order/views/uc_order.views.inc
Preprocesses a views row invoice plugin.
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_form_uc_cart_checkout_form_alter in payment/uc_credit/uc_credit.module
Implements hook_form_FORM_ID_alter() for uc_cart_checkout_form().
uc_credit_form_uc_cart_checkout_review_form_alter in payment/uc_credit/uc_credit.module
Implements hook_form_FORM_ID_alter() for uc_cart_checkout_review_form().

... See full list

File

payment/uc_credit/uc_credit.module, line 744
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 UbercartEncryption();

      // 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;
}