You are here

function commerce_payflow_link_refund_access in Commerce PayPal 7.2

Determines access to the refund form for Payflow Link 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_payflow_link_refund_access'
commerce_payflow_menu in modules/payflow/commerce_payflow.module
Implements hook_menu().

File

modules/payflow/commerce_payflow.module, line 179
Implements PayPal Payments Advanced (U.S. only) and Payflow Link Hosted Checkout pages and Transparent Redirect.

Code

function commerce_payflow_link_refund_access($order, $transaction) {

  // Return FALSE if the transaction isn't valid for credit transactions:
  // Sale or Delayed Capture.
  $valid_types = array(
    'S',
    'D',
  );
  if (!in_array($transaction->payment_method, array(
    'payflow_link',
    'paypal_ppa',
  )) || !in_array($transaction->remote_status, $valid_types)) {
    return FALSE;
  }

  // Return FALSE if the transaction was created through Express Checkout.
  if (!empty($transaction->data['commerce_payflow']['tender']) && $transaction->data['commerce_payflow']['tender'] == 'P') {
    return FALSE;
  }

  // Return FALSE if the transaction was not a success.
  if ($transaction->status != COMMERCE_PAYMENT_STATUS_SUCCESS) {
    return FALSE;
  }

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

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