diff -u b/src/Plugin/Commerce/PaymentGateway/Stripe.php b/src/Plugin/Commerce/PaymentGateway/Stripe.php --- b/src/Plugin/Commerce/PaymentGateway/Stripe.php +++ b/src/Plugin/Commerce/PaymentGateway/Stripe.php @@ -7,14 +7,16 @@ use Drupal\commerce_payment\Entity\PaymentInterface; use Drupal\commerce_payment\Entity\PaymentMethodInterface; use Drupal\commerce_payment\Exception\HardDeclineException; -use Drupal\commerce_payment\Exception\InvalidRequestException; use Drupal\commerce_payment\PaymentMethodTypeManager; use Drupal\commerce_payment\PaymentTypeManager; use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OnsitePaymentGatewayBase; use Drupal\commerce_price\Price; +use Drupal\commerce_stripe\Event\PaymentMetadataEvent; +use Drupal\commerce_stripe\Event\StripeEvents; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides the Stripe payment gateway. @@ -36,12 +38,36 @@ class Stripe extends OnsitePaymentGatewayBase implements StripeInterface { /** + * An event dispatcher instance to use for map events. + * + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ + protected $eventDispatcher; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('plugin.manager.commerce_payment_type'), + $container->get('plugin.manager.commerce_payment_method_type'), + $container->get('datetime.time'), + $container->get('event_dispatcher') + ); + } + + /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PaymentTypeManager $payment_type_manager, PaymentMethodTypeManager $payment_method_type_manager, TimeInterface $time) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PaymentTypeManager $payment_type_manager, PaymentMethodTypeManager $payment_method_type_manager, TimeInterface $time, EventDispatcherInterface $event_dispatcher) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $payment_type_manager, $payment_method_type_manager, $time); \Stripe\Stripe::setApiKey($this->configuration['secret_key']); + $this->eventDispatcher = $event_dispatcher; } /**