function commerce_braintree_void_access in Commerce Braintree 7.2
Same name and namespace in other branches
- 7.3 commerce_braintree.module \commerce_braintree_void_access()
Access callback for voiding Braintree transactions.
1 string reference to 'commerce_braintree_void_access'
- commerce_braintree_menu in ./
commerce_braintree.module - Implements hook_menu().
File
- ./
commerce_braintree.module, line 111 - Integrates Braintree Transparent Redirect with Drupal Commerce.
Code
function commerce_braintree_void_access($order, $transaction) {
// Make sure we're referencing a valid Braintree payment transaction.
if (!in_array($transaction->payment_method, array(
'braintree_tr',
'braintree_dropin',
'braintree_hostedfields',
)) || empty($transaction->remote_id) || !in_array($transaction->remote_status, array(
'submitted_for_settlement',
'authorized',
'authorizing',
))) {
return FALSE;
}
// Settled transactions cannot be voided. Assume all transactions that are
// complete and 24 hours old have been settled.
if (time() - $transaction->changed > 2600 * 24 && $transaction->status == COMMERCE_PAYMENT_STATUS_SUCCESS) {
return FALSE;
}
// Allow access if the user can update this transaction.
return commerce_payment_transaction_access('update', $transaction);
}