class TransactionDataSubscriber in Commerce Stripe 8
Hierarchy
- class \Drupal\commerce_stripe_test\EventSubscriber\TransactionDataSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of TransactionDataSubscriber
1 string reference to 'TransactionDataSubscriber'
- commerce_stripe_test.services.yml in tests/
modules/ commerce_stripe_test/ commerce_stripe_test.services.yml - tests/modules/commerce_stripe_test/commerce_stripe_test.services.yml
1 service uses TransactionDataSubscriber
- commerce_stripe_test.transaction_data_subscriber in tests/
modules/ commerce_stripe_test/ commerce_stripe_test.services.yml - Drupal\commerce_stripe_test\EventSubscriber\TransactionDataSubscriber
File
- tests/
modules/ commerce_stripe_test/ src/ EventSubscriber/ TransactionDataSubscriber.php, line 9
Namespace
Drupal\commerce_stripe_test\EventSubscriberView source
class TransactionDataSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
StripeEvents::TRANSACTION_DATA => 'addTransactionData',
];
}
/**
* Adds additional metadata to a transaction.
*
* @param \Drupal\commerce_stripe\Event\TransactionDataEvent $event
* The transaction data event.
*/
public function addTransactionData(TransactionDataEvent $event) {
$payment = $event
->getPayment();
$metadata = $event
->getMetadata();
// Add the payment's UUID to the Stripe transaction metadata. For example,
// another service may query Stripe payment transactions and also load the
// payment from Drupal Commerce over JSON API.
$metadata['payment_uuid'] = $payment
->uuid();
$event
->setMetadata($metadata);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TransactionDataSubscriber:: |
public | function | Adds additional metadata to a transaction. | |
TransactionDataSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. |