You are here

class RulesDataUIPaymentSettings in Commerce Core 7

Adds a payment method settings form to the enabling action.

Hierarchy

Expanded class hierarchy of RulesDataUIPaymentSettings

1 string reference to 'RulesDataUIPaymentSettings'
commerce_payment_rules_data_info in modules/payment/commerce_payment.rules.inc
Implements hook_rules_data_info().

File

modules/payment/commerce_payment.rules.inc, line 292
Rules integration for payments.

View source
class RulesDataUIPaymentSettings extends RulesDataUI implements RulesDataDirectInputFormInterface {
  public static function getDefaultMode() {
    return 'input';
  }
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {

    // If the specified payment method exists...
    if (!empty($info['payment_method']) && ($payment_method = commerce_payment_method_load($info['payment_method']))) {
      $form[$name]['method_id'] = array(
        '#type' => 'value',
        '#value' => $info['payment_method'],
      );

      // If the payment method has a settings callback...
      if ($callback = commerce_payment_method_callback($payment_method, 'settings_form')) {

        // Prepare an array of payment method settings defaults.
        $method_settings = !empty($settings[$name]['settings']) && is_array($settings[$name]['settings']) ? $settings[$name]['settings'] : array();

        // Add the settings form elements to the action form.
        $form[$name]['settings'] = $callback($method_settings);
      }
      else {

        // Otherwise add an appropriate message.
        $form[$name]['settings']['no_settings']['#markup'] = t('No settings for this payment method.');
      }
    }
    else {
      $form[$name]['invalid']['#markup'] = t('Invalid or missing payment method.');
    }
    return $form;
  }
  public static function render($value) {
    return array();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesDataUI::getTypeInfo public static function Returns the data type and parameter information for the given arguments.
RulesDataUI::renderOptionsLabel public static function Renders the value with a label if an options list is available.
RulesDataUI::selectionForm public static function Provides the selection form for a parameter.
RulesDataUIPaymentSettings::getDefaultMode public static function Specifies the default input mode per data type. Overrides RulesDataUI::getDefaultMode
RulesDataUIPaymentSettings::inputForm public static function Constructs the direct input form. Overrides RulesDataDirectInputFormInterface::inputForm
RulesDataUIPaymentSettings::render public static function Render the configured value. Overrides RulesDataDirectInputFormInterface::render