function commerce_sagepay_release_access in Drupal Commerce SagePay Integration 7
Determines access to the prior authorization release form for SagePay.
Parameters
commerce_order $order: The order the transaction is on.
commerce_payment_transaction $transaction: The payment transaction object to be released.
Return value
bool TRUE or FALSE indicating release access.
1 string reference to 'commerce_sagepay_release_access'
- commerce_sagepay_menu in ./
commerce_sagepay.module - Implements hook_menu().
File
- ./
commerce_sagepay.module, line 269
Code
function commerce_sagepay_release_access($order, $transaction) {
global $user;
// Return FALSE if the transaction isn't for SagePay Server or Direct or isn't
// awaiting capture.
if ($transaction->payment_method != 'commerce_sagepay_server' && $transaction->payment_method != 'commerce_sagepay_direct') {
return FALSE;
}
if ($transaction->remote_status != SAGEPAY_REMOTE_STATUS_REPEAT_DEFERRED && $transaction->remote_status != SAGEPAY_REMOTE_STATUS_DEFERRED) {
return FALSE;
}
// Return FALSE if it is more than 90 days past the original authorization.
if (time() - $transaction->created > 86400 * 90) {
return FALSE;
}
// check SagePay Payment permission
if (!user_access('sagepay release payment', $user)) {
return FALSE;
}
// Allow access if the user can update payments on this order.
return commerce_payment_transaction_access('update', $order, $user);
}