You are here

class Other in Ubercart 8.4

Defines a generic payment method.

Plugin annotation


@UbercartPaymentMethod(
  id = "other",
  name = @Translation("Other"),
)

Hierarchy

Expanded class hierarchy of Other

4 string references to 'Other'
OtherTest::testOther in payment/uc_payment_pack/tests/src/Functional/OtherTest.php
Tests for Other payment method.
uc_payment_tokens in payment/uc_payment/uc_payment.tokens.inc
Implements hook_tokens().
uc_payment_uc_payment_receipt_delete in payment/uc_payment/uc_payment.module
Implements hook_uc_payment_receipt_delete().
uc_payment_uc_payment_receipt_insert in payment/uc_payment/uc_payment.module
Implements hook_uc_payment_receipt_insert().

File

payment/uc_payment_pack/src/Plugin/Ubercart/PaymentMethod/Other.php, line 16

Namespace

Drupal\uc_payment_pack\Plugin\Ubercart\PaymentMethod
View source
class Other extends PaymentMethodPluginBase {

  /**
   * {@inheritdoc}
   */
  public function orderView(OrderInterface $order) {
    $build = [];
    if ($description = $this->database
      ->query('SELECT description FROM {uc_payment_other} WHERE order_id = :id', [
      ':id' => $order
        ->id(),
    ])
      ->fetchField()) {
      $build = [
        '#markup' => $this
          ->t('Description: @desc', [
          '@desc' => $description,
        ]),
      ];
    }
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function orderEditDetails(OrderInterface $order) {
    $build = [];
    $build['description'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Description'),
      '#default_value' => isset($order->payment_details['description']) ? $order->payment_details['description'] : '',
      '#size' => 32,
      '#maxlength' => 64,
    ];
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function orderLoad(OrderInterface $order) {
    $description = $this->database
      ->query('SELECT description FROM {uc_payment_other} WHERE order_id = :id', [
      ':id' => $order
        ->id(),
    ])
      ->fetchField();
    if (isset($description)) {
      $order->payment_details['description'] = $description;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function orderSave(OrderInterface $order) {
    if (empty($order->payment_details['description'])) {
      $this->database
        ->delete('uc_payment_other')
        ->condition('order_id', $order
        ->id())
        ->execute();
    }
    else {
      $this->database
        ->merge('uc_payment_other')
        ->key([
        'order_id' => $order
          ->id(),
      ])
        ->fields([
        'description' => $order->payment_details['description'],
      ])
        ->execute();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
Other::orderEditDetails public function Called when an order is being edited with this payment method. Overrides PaymentMethodPluginBase::orderEditDetails
Other::orderLoad public function Called when an order is being loaded with this payment method. Overrides PaymentMethodPluginBase::orderLoad
Other::orderSave public function Called when an order is being saved with this payment method. Overrides PaymentMethodPluginBase::orderSave
Other::orderView public function Called when an order is being viewed by an administrator. Overrides PaymentMethodPluginBase::orderView
PaymentMethodPluginBase::$database protected property The database service.
PaymentMethodPluginBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm 5
PaymentMethodPluginBase::cartDetails public function Returns the form or render array to be displayed at checkout. Overrides PaymentMethodPluginInterface::cartDetails 5
PaymentMethodPluginBase::cartProcess public function Called when checkout is submitted with this payment method selected. Overrides PaymentMethodPluginInterface::cartProcess 3
PaymentMethodPluginBase::cartReview public function Returns the payment method review details. Overrides PaymentMethodPluginInterface::cartReview 3
PaymentMethodPluginBase::cartReviewTitle public function Returns the payment method title to be used on the checkout review page. Overrides PaymentMethodPluginInterface::cartReviewTitle 2
PaymentMethodPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
PaymentMethodPluginBase::customerView public function Called when an order is being viewed by a customer. Overrides PaymentMethodPluginInterface::customerView 2
PaymentMethodPluginBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration 5
PaymentMethodPluginBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
PaymentMethodPluginBase::getDisplayLabel public function Returns the payment method label with logo. Overrides PaymentMethodPluginInterface::getDisplayLabel 3
PaymentMethodPluginBase::orderDelete public function Called when an order is being deleted. Overrides PaymentMethodPluginInterface::orderDelete 1
PaymentMethodPluginBase::orderEditProcess public function Called when an order is being submitted after being edited. Overrides PaymentMethodPluginInterface::orderEditProcess 1
PaymentMethodPluginBase::orderSubmit public function Called when an order is being submitted with this payment method. Overrides PaymentMethodPluginInterface::orderSubmit 4
PaymentMethodPluginBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
PaymentMethodPluginBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm 5
PaymentMethodPluginBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
PaymentMethodPluginBase::__construct public function Constructs the PaymentMethodPluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
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.