You are here

function commerce_authnet_aim_credit_access in Commerce Authorize.Net 7

Determines access to the credit form for successful Authorize.Net AIM credit card transactions.

Parameters

$order: The order the transaction is on.

$transaction: The payment transaction object to be credited.

Return value

TRUE or FALSE indicating credit access.

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

File

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

Code

function commerce_authnet_aim_credit_access($order, $transaction) {

  // Return FALSE if the transaction isn't for Authorize.Net AIM, doesn't have a
  // success status or has an amount of 0 or less.
  if (!in_array($transaction->payment_method, array(
    'authnet_aim',
    'authnet_acceptjs',
  )) || $transaction->status != 'success' || $transaction->amount <= 0) {
    return FALSE;
  }

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

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