You are here

function commerce_authnet_aim_capture_access in Commerce Authorize.Net 7

Determines access to the prior authorization capture form for Authorize.Net AIM credit card transactions.

Parameters

$order: The order the transaction is on.

$transaction: The payment transaction object to be captured.

Return value

TRUE or FALSE indicating capture access.

1 string reference to 'commerce_authnet_aim_capture_access'
commerce_authnet_menu in ./commerce_authnet.module
Implements hook_menu().

File

./commerce_authnet.module, line 109
Implements Authorize.Net payment services for use in Drupal Commerce.

Code

function commerce_authnet_aim_capture_access($order, $transaction) {

  // Return FALSE if the transaction isn't for Authorize.Net AIM or isn't
  // awaiting capture.
  if (!in_array($transaction->payment_method, array(
    'authnet_aim',
    'authnet_acceptjs',
  )) || empty($transaction->remote_id) || strtoupper($transaction->remote_status) != 'AUTH_ONLY') {
    return FALSE;
  }

  // Return FALSE if it is more than 30 days past the original authorization.
  if (time() - $transaction->created > 86400 * 30) {
    return FALSE;
  }

  // Allow access if the user can update this transaction.
  return commerce_payment_transaction_access('update', $transaction);
}