class WorldpayDirect in Commerce Worldpay 8
Same name and namespace in other branches
- 8.2 src/Plugin/Commerce/PaymentGateway/WorldpayDirect.php \Drupal\commerce_worldpay\Plugin\Commerce\PaymentGateway\WorldpayDirect
Provides the Worldpay direct payment gateway.
Plugin annotation
@CommercePaymentGateway(
id = "worldpay_direct",
label = @Translation("Worldpay (Direct)"),
display_label = @Translation("Worldpay"),
forms = {
"onsite-payment" = "Drupal\commerce_worldpay\PluginForm\Onsite\WorldpayDirectForm",
},
payment_method_types = {"credit_card"},
credit_card_types = {
"amex", "discover", "mastercard", "visa", "dinersclub", "jcb", "unionpay"
},
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase implements PaymentGatewayInterface, ContainerFactoryPluginInterface uses PluginWithFormsTrait
- class \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OnsitePaymentGatewayBase implements OnsitePaymentGatewayInterface
- class \Drupal\commerce_worldpay\Plugin\Commerce\PaymentGateway\WorldpayDirect implements WorldpayDirectInterface
- class \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OnsitePaymentGatewayBase implements OnsitePaymentGatewayInterface
- class \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase implements PaymentGatewayInterface, ContainerFactoryPluginInterface uses PluginWithFormsTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of WorldpayDirect
File
- src/
Plugin/ Commerce/ PaymentGateway/ WorldpayDirect.php, line 26
Namespace
Drupal\commerce_worldpay\Plugin\Commerce\PaymentGatewayView source
class WorldpayDirect extends OnsitePaymentGatewayBase implements WorldpayDirectInterface {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'merchant_id' => '',
'service_key' => '',
'client_key' => '',
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['merchant_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Merchant ID'),
'#required' => TRUE,
'#default_value' => $this->configuration['merchant_id'],
];
$form['service_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('Service Key'),
'#required' => TRUE,
'#default_value' => $this->configuration['service_key'],
];
$form['client_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('Client Key'),
'#required' => TRUE,
'#default_value' => $this->configuration['client_key'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
if (!$form_state
->getErrors() && $form_state
->isSubmitted()) {
$values = $form_state
->getValue($form['#parents']);
$this->configuration['merchant_id'] = $values['merchant_id'];
$this->configuration['service_key'] = $values['service_key'];
$this->configuration['client_key'] = $values['client_key'];
}
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
if (!$form_state
->getErrors()) {
$values = $form_state
->getValue($form['#parents']);
$this->configuration['merchant_id'] = $values['merchant_id'];
$this->configuration['service_key'] = $values['service_key'];
$this->configuration['client_key'] = $values['client_key'];
}
}
/**
* Creates a payment.
*
* @param \Drupal\commerce_payment\Entity\PaymentInterface $payment
* The payment.
* @param bool $capture
* Whether the created payment should be captured (VS authorized only).
* Allowed to be FALSE only if the plugin supports authorizations.
*
* @throws \InvalidArgumentException
* If $capture is FALSE but the plugin does not support authorizations.
* @throws \Drupal\commerce_payment\Exception\PaymentGatewayException
* Thrown when the transaction fails for any reason.
*/
public function createPayment(PaymentInterface $payment, $capture = TRUE) {
// TODO: Implement createPayment() method.
}
/**
* Creates a payment method with the given payment details.
*
* @param \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method
* The payment method.
* @param array $payment_details
* The gateway-specific payment details.
*
* @throws \Drupal\commerce_payment\Exception\PaymentGatewayException
* Thrown when the transaction fails for any reason.
*/
public function createPaymentMethod(PaymentMethodInterface $payment_method, array $payment_details) {
// TODO: Implement createPaymentMethod() method.
}
/**
* Deletes the given payment method.
*
* Both the entity and the remote record are deleted.
*
* @param \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method
* The payment method.
*
* @throws \Drupal\commerce_payment\Exception\PaymentGatewayException
* Thrown when the transaction fails for any reason.
*/
public function deletePaymentMethod(PaymentMethodInterface $payment_method) {
// TODO: Implement deletePaymentMethod() method.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
OnsitePaymentGatewayBase:: |
protected | function |
Gets the default payment gateway forms. Overrides PaymentGatewayBase:: |
|
PaymentGatewayBase:: |
protected | property | The ID of the parent config entity. | |
PaymentGatewayBase:: |
protected | property | The entity type manager. | |
PaymentGatewayBase:: |
protected | property | The minor units converter. | |
PaymentGatewayBase:: |
protected | property | The parent config entity. | |
PaymentGatewayBase:: |
protected | property | The payment method types handled by the gateway. | |
PaymentGatewayBase:: |
protected | property | The payment type used by the gateway. | |
PaymentGatewayBase:: |
protected | property | The time. | |
PaymentGatewayBase:: |
protected | function | Asserts that the payment method is neither empty nor expired. | |
PaymentGatewayBase:: |
protected | function | Asserts that the payment state matches one of the allowed states. | |
PaymentGatewayBase:: |
protected | function | Asserts that the refund amount is valid. | |
PaymentGatewayBase:: |
public | function |
Builds a label for the given AVS response code and card type. Overrides PaymentGatewayInterface:: |
2 |
PaymentGatewayBase:: |
public | function |
Builds the available operations for the given payment. Overrides PaymentGatewayInterface:: |
1 |
PaymentGatewayBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
PaymentGatewayBase:: |
public | function | ||
PaymentGatewayBase:: |
public | function | ||
PaymentGatewayBase:: |
public | function | ||
PaymentGatewayBase:: |
public | function |
Gets whether the payment gateway collects billing information. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
PaymentGatewayBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the credit card types handled by the gateway. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the default payment method type. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the payment gateway display label. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the JS library ID. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the payment gateway label. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the mode in which the payment gateway is operating. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the payment method types handled by the payment gateway. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Gets the payment type used by the payment gateway. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
protected | function | Gets the remote customer ID for the given user. | |
PaymentGatewayBase:: |
public | function |
Gets the supported modes. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
PaymentGatewayBase:: |
protected | function | Sets the remote customer ID for the given user. | |
PaymentGatewayBase:: |
public | function |
Converts the given amount to its minor units. Overrides PaymentGatewayInterface:: |
|
PaymentGatewayBase:: |
public | function |
Constructs a new PaymentGatewayBase object. Overrides PluginBase:: |
3 |
PaymentGatewayBase:: |
public | function |
Overrides DependencySerializationTrait:: |
|
PaymentGatewayBase:: |
public | function |
Overrides DependencySerializationTrait:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginWithFormsTrait:: |
public | function | ||
PluginWithFormsTrait:: |
public | function | ||
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. | |
WorldpayDirect:: |
public | function |
Form constructor. Overrides OnsitePaymentGatewayBase:: |
|
WorldpayDirect:: |
public | function |
Creates a payment. Overrides SupportsStoredPaymentMethodsInterface:: |
|
WorldpayDirect:: |
public | function |
Creates a payment method with the given payment details. Overrides SupportsCreatingPaymentMethodsInterface:: |
|
WorldpayDirect:: |
public | function |
Gets default configuration for this plugin. Overrides PaymentGatewayBase:: |
|
WorldpayDirect:: |
public | function |
Deletes the given payment method. Overrides SupportsStoredPaymentMethodsInterface:: |
|
WorldpayDirect:: |
public | function |
Form submission handler. Overrides PaymentGatewayBase:: |
|
WorldpayDirect:: |
public | function |
Form validation handler. Overrides PaymentGatewayBase:: |