You are here

class PaymentOffsiteForm in Commerce PayPal 8

Provides the Off-site form for PayPal Checkout.

This is provided as a fallback when no "review" step is present in Checkout.

Hierarchy

Expanded class hierarchy of PaymentOffsiteForm

File

src/PluginForm/Checkout/PaymentOffsiteForm.php, line 16

Namespace

Drupal\commerce_paypal\PluginForm\Checkout
View source
class PaymentOffsiteForm extends BasePaymentOffsiteForm implements ContainerInjectionInterface {

  /**
   * The Smart payment buttons builder.
   *
   * @var \Drupal\commerce_paypal\SmartPaymentButtonsBuilderInterface
   */
  protected $builder;

  /**
   * Constructs a new PaymentOffsiteForm object.
   *
   * @param \Drupal\commerce_paypal\SmartPaymentButtonsBuilderInterface $builder
   *   The Smart payment buttons builder.
   */
  public function __construct(SmartPaymentButtonsBuilderInterface $builder) {
    $this->builder = $builder;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('commerce_paypal.smart_payment_buttons_builder'));
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {

    /** @var \Drupal\commerce_payment\Entity\PaymentInterface $payment */
    $payment = $this->entity;
    $payment_gateway_plugin = $payment
      ->getPaymentGateway()
      ->getPlugin();
    if ($payment_gateway_plugin
      ->getPaymentSolution() === 'smart_payment_buttons') {
      $form['paypal_smart_payment_buttons'] = $this->builder
        ->build($payment
        ->getOrder(), $payment
        ->getPaymentGateway(), TRUE);
      return $form;
    }
  }

}

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
PaymentGatewayFormBase::$entity protected property The form entity.
PaymentGatewayFormBase::getEntity public function Gets the form entity. Overrides PaymentGatewayFormInterface::getEntity
PaymentGatewayFormBase::getErrorElement public function Gets the form element to which errors should be assigned. Overrides PaymentGatewayFormInterface::getErrorElement 1
PaymentGatewayFormBase::setEntity public function Sets the form entity. Overrides PaymentGatewayFormInterface::setEntity
PaymentOffsiteForm::$builder protected property The Smart payment buttons builder.
PaymentOffsiteForm::buildConfigurationForm public function Form constructor. Overrides PaymentOffsiteForm::buildConfigurationForm
PaymentOffsiteForm::buildRedirectForm protected function Builds the redirect form.
PaymentOffsiteForm::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
PaymentOffsiteForm::processRedirectForm public static function Prepares the complete form for a POST redirect.
PaymentOffsiteForm::REDIRECT_GET constant
PaymentOffsiteForm::REDIRECT_POST constant
PaymentOffsiteForm::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
PaymentOffsiteForm::__construct public function Constructs a new PaymentOffsiteForm object.
PluginFormBase::$plugin protected property The plugin this form is for. 3
PluginFormBase::setPlugin public function Sets the plugin for this object. Overrides PluginAwareInterface::setPlugin 1
PluginFormBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm 2
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.