function commerce_payflow_link_reference_access in Commerce PayPal 7.2
Determines access to the reference transaction 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_reference_access'
- commerce_payflow_menu in modules/
payflow/ commerce_payflow.module - Implements hook_menu().
File
- modules/
payflow/ commerce_payflow.module, line 122 - Implements PayPal Payments Advanced (U.S. only) and Payflow Link Hosted Checkout pages and Transparent Redirect.
Code
function commerce_payflow_link_reference_access($order, $transaction) {
// Return FALSE if the transaction isn't valid for reference transactions:
// Sale, Authorization, Delayed Capture, Void, or Credit. This list includes
// both the Payflow Link codes and Express Checkout statuses.
$valid_types = array(
'S',
'A',
'D',
'V',
'C',
'Pending',
'Completed',
'Voided',
'Refunded',
);
if (!in_array($transaction->payment_method, array(
'payflow_link',
'paypal_ppa',
'paypal_ec',
)) || !in_array($transaction->remote_status, $valid_types)) {
return FALSE;
}
// Return FALSE if the transaction was a failure.
if ($transaction->status == COMMERCE_PAYMENT_STATUS_FAILURE) {
return FALSE;
}
// Return FALSE if the transaction is an Express Checkout transaction that
// does not have Payflow data.
if ($transaction->payment_method == 'paypal_ec' && empty($transaction->data['commerce_payflow'])) {
return FALSE;
}
// Return FALSE if the transaction came through PayPal and does not have a
// billing agreement ID.
if (!empty($transaction->data['commerce_payflow']['tender']) && $transaction->data['commerce_payflow']['tender'] == 'P' && empty($transaction->data['commerce_payflow']['baid'])) {
return FALSE;
}
// Return FALSE if it is more than 365 days since the original transaction.
if (REQUEST_TIME - $transaction->created > 86400 * 365) {
return FALSE;
}
// Return FALSE if the payment method instance does not have reference
// transaction support enabled.
$payment_method = commerce_payment_method_instance_load($transaction->instance_id);
if (empty($payment_method['settings']['reference_transactions'])) {
return FALSE;
}
// Allow access if the user can update payments on this transaction.
return commerce_payment_transaction_access('update', $transaction);
}