class Check in Ubercart 8.4
Defines the check payment method.
Plugin annotation
@UbercartPaymentMethod(
id = "check",
name = @Translation("Check", context = "cheque"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\uc_payment\PaymentMethodPluginBase implements ContainerFactoryPluginInterface, PaymentMethodPluginInterface
- class \Drupal\uc_payment_pack\Plugin\Ubercart\PaymentMethod\Check
- class \Drupal\uc_payment\PaymentMethodPluginBase implements ContainerFactoryPluginInterface, PaymentMethodPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Check
1 string reference to 'Check'
- CheckTest::testCheck in payment/
uc_payment_pack/ tests/ src/ Functional/ CheckTest.php - Tests for Check payment method.
File
- payment/
uc_payment_pack/ src/ Plugin/ Ubercart/ PaymentMethod/ Check.php, line 20
Namespace
Drupal\uc_payment_pack\Plugin\Ubercart\PaymentMethodView source
class Check extends PaymentMethodPluginBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$config = \Drupal::config('uc_store.settings');
return [
'policy' => $this
->t('Personal and business checks will be held for up to 10 business days to ensure payment clears before an order is shipped.'),
'name' => '',
'address' => $config
->get('address') + [
'company' => $config
->get('name'),
],
];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['policy'] = [
'#type' => 'textarea',
'#title' => $this
->t('Check payment policy', [], [
'context' => 'cheque',
]),
'#description' => $this
->t('Instructions for customers on the checkout page.'),
'#default_value' => $this->configuration['policy'],
'#rows' => 3,
];
$form['name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Contact'),
'#description' => $this
->t('Direct checks to a person or department.'),
'#default_value' => $this->configuration['name'],
];
$form['address'] = [
'#type' => 'uc_address',
'#tree' => TRUE,
'#hide' => [
'first_name',
'last_name',
'phone',
'email',
],
'#default_value' => $this->configuration['address'],
'#required' => FALSE,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['policy'] = $form_state
->getValue('policy');
$this->configuration['name'] = $form_state
->getValue('name');
$this->configuration['address'] = $form_state
->getValue('address');
}
/**
* {@inheritdoc}
*/
public function cartDetails(OrderInterface $order, array $form, FormStateInterface $form_state) {
$build['instructions'] = [
'#markup' => $this
->t('Checks should be made out to:'),
];
$address = Address::create($this->configuration['address']);
$address
->setFirstName($this->configuration['name']);
$build['address'] = [
'#prefix' => '<p>',
'#markup' => (string) $address,
'#suffix' => '</p>',
];
$build['policy'] = [
'#prefix' => '<p>',
'#markup' => Html::escape($this->configuration['policy']),
'#suffix' => '</p>',
];
return $build;
}
/**
* {@inheritdoc}
*/
public function cartReview(OrderInterface $order) {
$address = Address::create($this->configuration['address']);
$address
->setFirstName($this->configuration['name']);
$review[] = [
'title' => $this
->t('Mail to'),
'data' => [
'#markup' => (string) $address,
],
];
return $review;
}
/**
* {@inheritdoc}
*/
public function orderView(OrderInterface $order) {
$build = [
'#suffix' => '<br />',
];
$result = $this->database
->query('SELECT clear_date FROM {uc_payment_check} WHERE order_id = :id ', [
':id' => $order
->id(),
]);
if ($clear_date = $result
->fetchField()) {
$build['#markup'] = $this
->t('Clear Date:') . ' ' . \Drupal::service('date.formatter')
->format($clear_date, 'uc_store');
}
else {
$build['#type'] = 'link';
$build['#title'] = $this
->t('Receive Check');
$build['#url'] = Url::fromRoute('uc_payment_pack.check.receive', [
'uc_order' => $order
->id(),
]);
}
return $build;
}
/**
* {@inheritdoc}
*/
public function customerView(OrderInterface $order) {
$build = [];
$result = $this->database
->query('SELECT clear_date FROM {uc_payment_check} WHERE order_id = :id ', [
':id' => $order
->id(),
]);
if ($clear_date = $result
->fetchField()) {
$build['#markup'] = $this
->t('Check received') . '<br />' . $this
->t('Expected clear date:') . '<br />' . \Drupal::service('date.formatter')
->format($clear_date, 'uc_store');
}
return $build;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Check:: |
public | function |
Form constructor. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Returns the form or render array to be displayed at checkout. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Returns the payment method review details. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Called when an order is being viewed by a customer. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Gets default configuration for this plugin. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Called when an order is being viewed by an administrator. Overrides PaymentMethodPluginBase:: |
|
Check:: |
public | function |
Form submission handler. Overrides PaymentMethodPluginBase:: |
|
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. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PaymentMethodPluginBase:: |
protected | property | The database service. | |
PaymentMethodPluginBase:: |
public | function |
Called when checkout is submitted with this payment method selected. Overrides PaymentMethodPluginInterface:: |
3 |
PaymentMethodPluginBase:: |
public | function |
Returns the payment method title to be used on the checkout review page. Overrides PaymentMethodPluginInterface:: |
2 |
PaymentMethodPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
PaymentMethodPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
PaymentMethodPluginBase:: |
public | function |
Returns the payment method label with logo. Overrides PaymentMethodPluginInterface:: |
3 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being deleted. Overrides PaymentMethodPluginInterface:: |
1 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being edited with this payment method. Overrides PaymentMethodPluginInterface:: |
3 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being submitted after being edited. Overrides PaymentMethodPluginInterface:: |
1 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being loaded with this payment method. Overrides PaymentMethodPluginInterface:: |
3 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being saved with this payment method. Overrides PaymentMethodPluginInterface:: |
3 |
PaymentMethodPluginBase:: |
public | function |
Called when an order is being submitted with this payment method. Overrides PaymentMethodPluginInterface:: |
4 |
PaymentMethodPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
PaymentMethodPluginBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
PaymentMethodPluginBase:: |
public | function |
Constructs the PaymentMethodPluginBase object. Overrides PluginBase:: |
|
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. | |
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. |