You are here

function uc_credit_log_prior_auth_capture in Ubercart 8.4

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

Logs the capture of a prior authorization to an order's data array.

Parameters

int $order_id: The order associated with the credit card capture.

string $auth_id: The payment service's ID for the authorization that was captured.

Return value

array|false The entire updated data array for the order or FALSE to indicate the specified authorization was not found.

2 calls to uc_credit_log_prior_auth_capture()
AuthorizeNet::_uc_authorizenet_charge in payment/uc_authorizenet/src/Plugin/Ubercart/PaymentMethod/AuthorizeNet.php
Handles authorizations and captures through AIM at Authorize.Net.
PayPalWebsitePaymentsPro::chargeCard in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalWebsitePaymentsPro.php
Called when a credit card should be processed.

File

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

Code

function uc_credit_log_prior_auth_capture($order_id, $auth_id) {

  // Load the existing order data array.
  $connection = \Drupal::database();
  $data = $connection
    ->query("SELECT data FROM {uc_orders} WHERE order_id = :id", [
    ':id' => $order_id,
  ])
    ->fetchField();
  $data = unserialize($data);

  // Return FALSE if we can't find the authorization.
  if (empty($data['cc_txns']['authorizations'][$auth_id])) {
    return FALSE;
  }

  // Otherwise log the capture timestamp to the authorization.
  $data['cc_txns']['authorizations'][$auth_id]['captured'] = \Drupal::time()
    ->getRequestTime();

  // Save the updated data array to the database.
  $connection
    ->update('uc_orders')
    ->fields([
    'data' => serialize($data),
  ])
    ->condition('order_id', $order_id)
    ->execute();
  return $data;
}