You are here

function commerce_paypal_ec_capture_void_access in Commerce PayPal 7.2

Determines access to the prior authorization capture form or void form for Paypal EC 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 access.

1 string reference to 'commerce_paypal_ec_capture_void_access'
commerce_paypal_ec_menu in modules/ec/commerce_paypal_ec.module
Implements hook_menu().

File

modules/ec/commerce_paypal_ec.module, line 77
Implements PayPal Express Checkout in Drupal Commerce checkout.

Code

function commerce_paypal_ec_capture_void_access($order, $transaction) {

  // Return FALSE if the transaction isn't for Paypal EC or isn't awaiting capture.
  if ($transaction->payment_method != 'paypal_ec' || $transaction->remote_status != 'Pending') {
    return FALSE;
  }

  // Return FALSE if the transaction is not pending.
  if ($transaction->status != COMMERCE_PAYMENT_STATUS_PENDING) {
    return FALSE;
  }

  // Return FALSE if the transaction is actually a pending echeck.
  if (!empty($transaction->data['commerce_paypal_ec']['paymenttype']) && $transaction->data['commerce_paypal_ec']['paymenttype'] == 'echeck') {
    return FALSE;
  }

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

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