You are here

function Payment::availablePaymentMethods in Payment 7

Get available/valid payment methods for this payment.

Parameters

PaymentMethod[] $payment_methods: Use an empty array to check the availability of all payment methods.

Return value

PaymentMethod[] An array with payment methods usable for Payment in its current state, keyed by PMID.

File

./payment.classes.inc, line 296
The API and related functions for executing and managing payments.

Class

Payment
A single payment. Contains all payment-specific data.

Code

function availablePaymentMethods(array $payment_methods = array()) {
  if (!$payment_methods) {
    $payment_methods = entity_load('payment_method', FALSE);
  }
  $available = array();
  foreach ($payment_methods as $payment_method) {
    try {
      $payment_method
        ->validate($this, FALSE);
      $available[$payment_method->pmid] = $payment_method;
    } catch (PaymentValidationException $e) {
    }
  }
  return $available;
}