function commerce_amex_refund_access in Commerce American Express Payment Gateway (Amex) 7
Determines access to the prior authorization capture form for Amex hosted 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_amex_refund_access'
- commerce_amex_menu in ./
commerce_amex.module - Implements hook_menu
File
- ./
commerce_amex.module, line 170 - Implements American Express payment gateway for use in Drupal Commerce.
Code
function commerce_amex_refund_access($order, $transaction) {
// Return FALSE if the transaction isn't for Amex or isn't
// awaiting capture.
if ($transaction->payment_method != 'amex_hosted' || empty($transaction->remote_id) || strtoupper($transaction->remote_status) != 'APPROVED' || $transaction->status != COMMERCE_PAYMENT_STATUS_SUCCESS) {
return FALSE;
}
if ($transaction->amount <= 0) {
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);
}