PayPalStandard.php in PayPal for Payment 8
File
src/Plugin/Payment/MethodConfiguration/PayPalStandard.php
View source
<?php
namespace Drupal\paypal_payment\Plugin\Payment\MethodConfiguration;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\payment\Annotations\PaymentMethodConfiguration;
class PayPalStandard extends PayPalBasic {
public function getEmail() : string {
return $this->configuration['email'] ?? '';
}
public function processBuildConfigurationForm(array &$element, FormStateInterface $form_state, array &$form) {
parent::processBuildConfigurationForm($element, $form_state, $form);
$element['paypal']['email'] = [
'#type' => 'email',
'#title' => $this
->t('Email'),
'#default_value' => $this
->getEmail(),
'#maxlength' => 255,
'#required' => TRUE,
];
return $element;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$parents = $form['plugin_form']['paypal']['#parents'];
array_pop($parents);
$values = $form_state
->getValues();
$values = NestedArray::getValue($values, $parents);
$this->configuration['email'] = $values['paypal']['email'];
}
public function getDerivativeConfiguration() : array {
return parent::getDerivativeConfiguration() + [
'email' => $this
->getEmail(),
];
}
}
Classes
Name |
Description |
PayPalStandard |
Provides the configuration for the PayPal Standard payment method plugin. |