You are here

function commerce_paypal_ec_enabled_rules in Commerce PayPal 7.2

Returns an array of enabled payment method rules that enable payment via Express Checkout.

Return value

An associative array where the key and value are a matching Rule name and label for payment method rules that enable payment via Express Checkout.

2 calls to commerce_paypal_ec_enabled_rules()
commerce_payflow_link_create_secure_token in modules/payflow/commerce_payflow.module
Requests a Secure Token from Payflow for use in follow-up API requests.
commerce_payflow_link_settings_form in modules/payflow/commerce_payflow.module
Payment method callback: settings form.

File

modules/ec/commerce_paypal_ec.module, line 1568
Implements PayPal Express Checkout in Drupal Commerce checkout.

Code

function commerce_paypal_ec_enabled_rules($enabled = FALSE) {
  $rules = array();

  // Loop over all of the enabled payment method rules.
  $event = rules_get_cache('event_commerce_payment_methods');
  if (!empty($event)) {
    foreach ($event as $rule) {

      // Look in all of the Rule's actions for a payment method settings array
      // that enables Express Checkout.
      foreach ($rule
        ->actions() as $action) {
        if (!empty($action->settings['payment_method']['method_id']) && $action->settings['payment_method']['method_id'] == 'paypal_ec') {

          // Add the present rule to the return value.
          $rules[$rule->name] = $rule->label;
        }
      }
    }
  }
  return $rules;
}