You are here

function commerce_stripe_capture_access in Commerce Stripe 7.3

Access callback for processing capture.

Parameters

stdClass $order: The commerce order entity.

stdClass $transaction: The commerce payment transaction entity.

Return value

bool Return TRUE if the user can update the transaction.

1 string reference to 'commerce_stripe_capture_access'
commerce_stripe_menu in ./commerce_stripe.module
Implements hook_menu().

File

./commerce_stripe.module, line 1808
This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.

Code

function commerce_stripe_capture_access($order, $transaction) {

  // Return FALSE if the transaction isn't for Commerce Stripe or isn't
  // awaiting capture.  This is detected by the AUTH_ONLY status
  if ($transaction->payment_method != 'commerce_stripe' || empty($transaction->remote_id) || strtoupper($transaction->remote_status) != 'AUTH_ONLY') {
    return FALSE;
  }

  // Return FALSE if it is more than 7 days past the original authorization.
  // Stripe does not allow capture after this time
  if (time() - $transaction->created > 86400 * 7) {
    return FALSE;
  }

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