You are here

class PayPalCheckout in Commerce PayPal 8

Same name in this branch
  1. 8 src/Plugin/Commerce/PaymentType/PayPalCheckout.php \Drupal\commerce_paypal\Plugin\Commerce\PaymentType\PayPalCheckout
  2. 8 src/Plugin/Commerce/PaymentMethodType/PayPalCheckout.php \Drupal\commerce_paypal\Plugin\Commerce\PaymentMethodType\PayPalCheckout
  3. 8 src/Plugin/Commerce/CheckoutFlow/PayPalCheckout.php \Drupal\commerce_paypal\Plugin\Commerce\CheckoutFlow\PayPalCheckout

Provides a custom checkout flow for use by PayPal Checkout.

Plugin annotation


@CommerceCheckoutFlow(
  id = "paypal_checkout",
  label = "PayPal Checkout",
)

Hierarchy

Expanded class hierarchy of PayPalCheckout

File

src/Plugin/Commerce/CheckoutFlow/PayPalCheckout.php, line 16

Namespace

Drupal\commerce_paypal\Plugin\Commerce\CheckoutFlow
View source
class PayPalCheckout extends CheckoutFlowWithPanesBase {

  /**
   * {@inheritdoc}
   */
  public function getSteps() {

    // Note that previous_label and next_label are not the labels
    // shown on the step itself. Instead, they are the labels shown
    // when going back to the step, or proceeding to the step.
    return [
      'order_information' => [
        'label' => $this
          ->t('Order information'),
        'has_sidebar' => TRUE,
        'previous_label' => $this
          ->t('Go back'),
      ],
      'review' => [
        'label' => $this
          ->t('Review'),
        'next_label' => $this
          ->t('Continue to review'),
        'previous_label' => $this
          ->t('Go back'),
        'has_sidebar' => TRUE,
      ],
    ] + parent::getSteps();
  }

  /**
   * {@inheritdoc}
   */
  public function getPanes() {
    $panes = parent::getPanes();

    // Create a blacklist of panes we disallow adding to steps.
    $black_list = [
      'contact_information',
      'payment_information',
      'payment_process',
    ];
    return array_diff_key($panes, array_combine($black_list, $black_list));
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::validateConfigurationForm($form, $form_state);
    $values = $form_state
      ->getValue($form['#parents']);
    $pane_values = $values['panes'];
    if (!isset($pane_values['paypal_checkout_payment_process']) || $pane_values['paypal_checkout_payment_process']['step_id'] !== 'payment') {
      $pane = $this
        ->getPane('paypal_checkout_payment_process');
      $form_state
        ->setError($form['panes'], $this
        ->t('The %title pane must be configured in the payment region.', [
        '%title' => $pane
          ->getLabel(),
      ]));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AjaxFormTrait::ajaxRefreshForm public static function Ajax handler for refreshing an entire form.
CheckoutFlowBase::$entityTypeManager protected property The entity manager.
CheckoutFlowBase::$eventDispatcher protected property The event dispatcher.
CheckoutFlowBase::$order protected property The current order.
CheckoutFlowBase::$parentEntity protected property The parent config entity.
CheckoutFlowBase::$visibleSteps protected property Static cache of visible steps.
CheckoutFlowBase::actions protected function Builds the actions element for the current form.
CheckoutFlowBase::getBaseFormId public function Returns a string identifying the base form. Overrides BaseFormIdInterface::getBaseFormId
CheckoutFlowBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
CheckoutFlowBase::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
CheckoutFlowBase::getNextStepId public function Gets the next step ID for the given step ID. Overrides CheckoutFlowInterface::getNextStepId
CheckoutFlowBase::getOrder public function Gets the current order. Overrides CheckoutFlowInterface::getOrder
CheckoutFlowBase::getPreviousStepId public function Gets the previous step ID for the given step ID. Overrides CheckoutFlowInterface::getPreviousStepId
CheckoutFlowBase::getVisibleSteps public function Gets the visible steps. Overrides CheckoutFlowInterface::getVisibleSteps
CheckoutFlowBase::hasSidebar protected function Gets whether the given step has a sidebar.
CheckoutFlowBase::onStepChange protected function Reacts to the current step changing.
CheckoutFlowBase::redirectToStep public function Redirects an order to a specific step in the checkout. Overrides CheckoutFlowInterface::redirectToStep
CheckoutFlowBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
CheckoutFlowBase::__wakeup public function Overrides DependencySerializationTrait::__wakeup
CheckoutFlowWithPanesBase::$paneManager protected property The checkout pane manager.
CheckoutFlowWithPanesBase::$panes protected property The initialized pane plugins.
CheckoutFlowWithPanesBase::buildConfigurationForm public function Form constructor. Overrides CheckoutFlowBase::buildConfigurationForm
CheckoutFlowWithPanesBase::buildForm public function Form constructor. Overrides CheckoutFlowBase::buildForm
CheckoutFlowWithPanesBase::buildPaneRow protected function Builds the table row structure for a checkout pane.
CheckoutFlowWithPanesBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides CheckoutFlowBase::calculateDependencies
CheckoutFlowWithPanesBase::create public static function Creates an instance of the plugin. Overrides CheckoutFlowBase::create
CheckoutFlowWithPanesBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides CheckoutFlowBase::defaultConfiguration
CheckoutFlowWithPanesBase::getPane public function Gets a pane with the given ID. Overrides CheckoutFlowWithPanesInterface::getPane
CheckoutFlowWithPanesBase::getPaneConfiguration protected function Gets the configuration for the given pane.
CheckoutFlowWithPanesBase::getTableRegions protected function Get the regions for the checkout pane overview table.
CheckoutFlowWithPanesBase::getVisiblePanes public function Gets the visible panes for the given step ID. Overrides CheckoutFlowWithPanesInterface::getVisiblePanes
CheckoutFlowWithPanesBase::isStepVisible protected function Gets whether the given step is visible. Overrides CheckoutFlowBase::isStepVisible
CheckoutFlowWithPanesBase::multistepAjax public static function Ajax handler for multistep buttons.
CheckoutFlowWithPanesBase::multistepSubmit public static function Form submission handler for multistep buttons.
CheckoutFlowWithPanesBase::submitConfigurationForm public function Form submission handler. Overrides CheckoutFlowBase::submitConfigurationForm
CheckoutFlowWithPanesBase::submitForm public function Form submission handler. Overrides CheckoutFlowBase::submitForm
CheckoutFlowWithPanesBase::validateForm public function Form validation handler. Overrides CheckoutFlowBase::validateForm
CheckoutFlowWithPanesBase::validatePaneConfigurationForm public static function Validates the pane configuration form.
CheckoutFlowWithPanesBase::__construct public function Constructs a new CheckoutFlowWithPanesBase object. Overrides CheckoutFlowBase::__construct
CheckoutFlowWithPanesBase::__sleep public function Overrides CheckoutFlowBase::__sleep
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.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PayPalCheckout::getPanes public function Gets the panes. Overrides CheckoutFlowWithPanesBase::getPanes
PayPalCheckout::getSteps public function Gets the defined steps. Overrides CheckoutFlowBase::getSteps
PayPalCheckout::validateConfigurationForm public function Form validation handler. Overrides CheckoutFlowBase::validateConfigurationForm
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.