StripeExamplesEventSubscriber.php in Stripe 2.x
File
modules/stripe_examples/src/EventSubscriber/StripeExamplesEventSubscriber.php
View source
<?php
namespace Drupal\stripe_examples\EventSubscriber;
use Drupal\stripe\Event\StripeEvents;
use Drupal\stripe\Event\StripePaymentEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class StripeExamplesEventSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
StripeEvents::PAYMENT => 'updatePayment',
];
}
public function updatePayment(StripePaymentEvent $event) {
$form = $event
->getForm();
if ($form['#form_id'] == 'stripe_examples_simple_checkout') {
$event
->setTotal(2500, 'StripeExamplesEventSubscriber');
}
}
}