PaymentDeclineForm.php in Commerce Authorize.Net 8
File
src/PluginForm/AcceptJs/PaymentDeclineForm.php
View source
<?php
namespace Drupal\commerce_authnet\PluginForm\AcceptJs;
use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase;
class PaymentDeclineForm extends PaymentGatewayFormBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$payment = $this->entity;
$form['#theme'] = 'confirm_form';
$form['#attributes']['class'][] = 'confirmation';
$form['#page_title'] = t('Are you sure you want to decline the %label payment?', [
'%label' => $payment
->label(),
]);
$form['#success_message'] = t('Payment declined.');
$form['description'] = [
'#markup' => t('This action cannot be undone.'),
];
return $form;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$payment = $this->entity;
$payment_gateway_plugin = $this->plugin;
$payment_gateway_plugin
->declinePayment($payment);
}
}