class CommercePaymentGateway in Commerce Core 8.2
Defines the payment gateway plugin annotation object.
Plugin namespace: Plugin\Commerce\PaymentGateway.
Hierarchy
- class \Drupal\Component\Annotation\Plugin implements AnnotationInterface
- class \Drupal\commerce_payment\Annotation\CommercePaymentGateway uses StringTranslationTrait
Expanded class hierarchy of CommercePaymentGateway
See also
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.
File
- modules/
payment/ src/ Annotation/ CommercePaymentGateway.php, line 18
Namespace
Drupal\commerce_payment\AnnotationView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommercePaymentGateway:: |
public | property | The credit card types handled by the payment gateway. | |
CommercePaymentGateway:: |
public | property | The default payment method type. | |
CommercePaymentGateway:: |
public | property | The payment gateway display label. | |
CommercePaymentGateway:: |
public | property | The payment gateway forms. | |
CommercePaymentGateway:: |
public | property | The plugin ID. | |
CommercePaymentGateway:: |
public | property | The JS library ID. | |
CommercePaymentGateway:: |
public | property | The payment gateway label. | |
CommercePaymentGateway:: |
public | property | The supported modes. | |
CommercePaymentGateway:: |
public | property | The payment method types handled by the payment gateway. | |
CommercePaymentGateway:: |
public | property | The payment type used by the payment gateway. | |
CommercePaymentGateway:: |
public | property | Whether the payment gateway requires billing information to be collected. | |
CommercePaymentGateway:: |
public | function |
Constructs a new CommercePaymentGateway object. Overrides Plugin:: |
|
Plugin:: |
protected | property | The plugin definition read from the class annotation. | 1 |
Plugin:: |
public | function |
Gets the value of an annotation. Overrides AnnotationInterface:: |
5 |
Plugin:: |
public | function |
Gets the class of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Gets the unique ID for this annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Gets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
protected | function | Parses an annotation into its definition. | |
Plugin:: |
public | function |
Sets the class of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Sets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |