You are here

class CommercePaymentGateway in Commerce Core 8.2

Defines the payment gateway plugin annotation object.

Plugin namespace: Plugin\Commerce\PaymentGateway.

Hierarchy

Expanded class hierarchy of CommercePaymentGateway

See also

Plugin API

6 classes are annotated with CommercePaymentGateway
Manual in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Provides the Manual payment gateway.
OffsiteRedirect in modules/payment_example/src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php
Provides the Off-site Redirect payment gateway.
Onsite in modules/payment_example/src/Plugin/Commerce/PaymentGateway/Onsite.php
Provides the On-site payment gateway.
StoredOffsiteRedirect in modules/payment_example/src/Plugin/Commerce/PaymentGateway/StoredOffsiteRedirect.php
Provides an example offsite payment gateway with stored payment methods.
TestOffsite in modules/payment/tests/modules/commerce_payment_test/src/Plugin/Commerce/PaymentGateway/TestOffsite.php
Provides the Test off-site payment gateway.

... See full list

File

modules/payment/src/Annotation/CommercePaymentGateway.php, line 18

Namespace

Drupal\commerce_payment\Annotation
View source
class CommercePaymentGateway extends Plugin {
  use StringTranslationTrait;

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The payment gateway label.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $label;

  /**
   * The payment gateway display label.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $display_label;

  /**
   * The supported modes.
   *
   * An array of mode labels keyed by machine name.
   *
   * @var string[]
   */
  public $modes;

  /**
   * The payment gateway forms.
   *
   * An array of form classes keyed by operation.
   * For example:
   * <code>
   *   'add-payment-method' => "Drupal\commerce_payment\PluginForm\PaymentMethodAddForm",
   *   'capture-payment' => "Drupal\commerce_payment\PluginForm\PaymentCaptureForm",
   * </code>
   *
   * @var array
   */
  public $forms = [];

  /**
   * The JS library ID.
   *
   * @var string
   */
  public $js_library;

  /**
   * The payment type used by the payment gateway.
   *
   * @var string
   */
  public $payment_type = 'payment_default';

  /**
   * The payment method types handled by the payment gateway.
   *
   * @var string[]
   */
  public $payment_method_types = [];

  /**
   * The default payment method type.
   *
   * Defaults to the first payment method type if no value is provided.
   *
   * @var string
   */
  public $default_payment_method_type;

  /**
   * The credit card types handled by the payment gateway.
   *
   * @var string[]
   */
  public $credit_card_types = [];

  /**
   * Whether the payment gateway requires billing information to be collected.
   *
   * Defaults to TRUE because prior to Commerce 2.14 payment gateways could
   * assume that billing information is always collected.
   *
   * @var bool
   */
  public $requires_billing_information = TRUE;

  /**
   * Constructs a new CommercePaymentGateway object.
   *
   * @param array $values
   *   The annotation values.
   */
  public function __construct(array $values) {
    if (empty($values['modes'])) {
      $values['modes'] = [
        'test' => $this
          ->t('Test'),
        'live' => $this
          ->t('Live'),
      ];
    }
    if (empty($values['payment_method_types'])) {

      // NestedArray merging causes duplicates for array defaults on properties.
      $values['payment_method_types'] = [
        'credit_card',
      ];
    }
    if (empty($values['default_payment_method_type'])) {
      $values['default_payment_method_type'] = reset($values['payment_method_types']);
    }
    if (empty($values['credit_card_types'])) {
      $values['credit_card_types'] = array_keys(CreditCard::getTypes());
    }
    parent::__construct($values);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommercePaymentGateway::$credit_card_types public property The credit card types handled by the payment gateway.
CommercePaymentGateway::$default_payment_method_type public property The default payment method type.
CommercePaymentGateway::$display_label public property The payment gateway display label.
CommercePaymentGateway::$forms public property The payment gateway forms.
CommercePaymentGateway::$id public property The plugin ID.
CommercePaymentGateway::$js_library public property The JS library ID.
CommercePaymentGateway::$label public property The payment gateway label.
CommercePaymentGateway::$modes public property The supported modes.
CommercePaymentGateway::$payment_method_types public property The payment method types handled by the payment gateway.
CommercePaymentGateway::$payment_type public property The payment type used by the payment gateway.
CommercePaymentGateway::$requires_billing_information public property Whether the payment gateway requires billing information to be collected.
CommercePaymentGateway::__construct public function Constructs a new CommercePaymentGateway object. Overrides Plugin::__construct
Plugin::$definition protected property The plugin definition read from the class annotation. 1
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 5
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.