You are here

public function PaymentReferenceForm::validateConfigurationForm in Commerce PayPal 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides PluginFormBase::validateConfigurationForm

File

src/PluginForm/PaymentReferenceForm.php, line 79

Class

PaymentReferenceForm
Class PaymentReferenceForm.

Namespace

Drupal\commerce_paypal\PluginForm

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

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

  // If the transaction has expired, display an error message and redirect.
  if ($payment
    ->getCompletedTime() && $payment
    ->getCompletedTime() < strtotime('-365 days')) {
    $form_state
      ->setError($form, $this
      ->t('This transaction has passed its 365 day limit and can no longer be used for reference transactions.'));
  }
}