You are here

function commerce_recurring_fetch_last_payment_transaction_id in Commerce Recurring Framework 7

Util to fetch the last payment transaction made against an order

Parameters

$order_id int: The order id

Return value

object commerce_payment_transaction

1 call to commerce_recurring_fetch_last_payment_transaction_id()
commerce_recurring_process_payment in ./commerce_recurring.rules.inc
Rules callback to process a payment against an order

File

./commerce_recurring.rules.inc, line 432

Code

function commerce_recurring_fetch_last_payment_transaction_id($order_id) {
  $query = db_select("commerce_payment_transaction", 'cpt');
  $query
    ->fields('cpt', array(
    'transaction_id',
  ));
  $query
    ->range(0, 1);
  $query
    ->condition('cpt.order_id', $order_id);
  $query
    ->orderBy('cpt.created', 'DESC');
  $result = $query
    ->execute();
  foreach ($result as $row) {
    return $row->transaction_id;
  }
  return FALSE;
}