You are here

public function WorldpayRedirectForm::buildConfigurationForm in Commerce Worldpay 8

Same name and namespace in other branches
  1. 8.2 src/PluginForm/OffsiteRedirect/WorldpayRedirectForm.php \Drupal\commerce_worldpay\PluginForm\OffsiteRedirect\WorldpayRedirectForm::buildConfigurationForm()

Throws

\Drupal\commerce\Response\NeedsRedirectException

Overrides PaymentOffsiteForm::buildConfigurationForm

File

src/PluginForm/OffsiteRedirect/WorldpayRedirectForm.php, line 17

Class

WorldpayRedirectForm

Namespace

Drupal\commerce_worldpay\PluginForm\OffsiteRedirect

Code

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 WorldpayRedirectInterface $paymentGatewayPlugin */
  $paymentGatewayPlugin = $payment
    ->getPaymentGateway()
    ->getPlugin();
  $data = $paymentGatewayPlugin
    ->buildFormData($payment);
  foreach ($data as $name => $value) {
    if (!empty($value)) {
      $form[$name] = array(
        '#type' => 'hidden',
        '#value' => $value,
      );
    }
  }
  return $this
    ->buildRedirectForm($form, $form_state, $paymentGatewayPlugin
    ->getUrl(), $data, BasePaymentOffsiteForm::REDIRECT_POST);
}