You are here

function commerce_cardonfile_order_can_charge_card in Commerce Card on File 7.2

Returns TRUE if the card can be charged for the given order

2 calls to commerce_cardonfile_order_can_charge_card()
commerce_cardonfile_order_charge_card in ./commerce_cardonfile.module
Process a charge for a given an order
commerce_cardonfile_order_select_card in ./commerce_cardonfile.module
Select the card on file that can be charged for an order.

File

./commerce_cardonfile.module, line 1385
Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.

Code

function commerce_cardonfile_order_can_charge_card($order, $card) {

  // DENY if no order id
  if (empty($order->order_id)) {
    return FALSE;
  }

  // DENY if no owner provided
  if (empty($order->uid) || empty($card->uid)) {
    return FALSE;
  }

  // DENY if owners do not match
  if ($card->uid != $order->uid) {
    return FALSE;
  }
  return commerce_cardonfile_can_charge($card);
}