You are here

class MolliePaymentOffsiteForm in Commerce Mollie 8

Starts payment with the checkout form pane.

Hierarchy

Expanded class hierarchy of MolliePaymentOffsiteForm

File

src/PluginForm/OffsiteRedirect/MolliePaymentOffsiteForm.php, line 12

Namespace

Drupal\commerce_mollie\PluginForm\OffsiteRedirect
View source
class MolliePaymentOffsiteForm extends BasePaymentOffsiteForm {

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

    /** @var \Drupal\commerce_payment\Entity\PaymentInterface $payment */
    $payment = $this->entity;

    /** @var \Drupal\commerce_mollie\Plugin\Commerce\PaymentGateway\Mollie $payment_gateway_plugin */
    $payment_gateway_plugin = $payment
      ->getPaymentGateway()
      ->getPlugin();
    $mollie_return = Url::fromRoute('commerce_mollie.checkout.mollie_return', [
      'commerce_order' => $payment
        ->getOrder()
        ->id(),
    ], [
      'absolute' => TRUE,
    ])
      ->toString();
    $data = [
      'return' => $mollie_return,
      'cancel' => $form['#cancel_url'],
      'total' => $payment
        ->getAmount()
        ->getNumber(),
    ];
    $mollie_payment = $payment_gateway_plugin
      ->createRemotePayment($payment, $data);
    return $this
      ->buildRedirectForm($form, $form_state, $mollie_payment
      ->getCheckoutUrl(), $data, 'get');
  }

}

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
MolliePaymentOffsiteForm::buildConfigurationForm public function Form constructor. Overrides PaymentOffsiteForm::buildConfigurationForm
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::buildRedirectForm protected function Builds the redirect form.
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
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.