Event dispatched after a payment is created.
Typical use case is to perform additional operations after payment creation (e.g. logging, cache purge, reindexing, etc.)
The following example logs the creation of the payment:
 final class PaymentEventSubscriber implements EventSubscriberInterface
 {
     private function __construct(private LoggerInterface $logger)
     {
     }
     public static function getSubscribedEvents(): array
     {
        return [
            CreatePaymentEvent::class => 'onCreatePayment',
        ];
     }
    public function onCreatePayment(CreatePaymentEvent $event): void
    {
        $payment = $event->getPaymentResult();
        $this->logger->info(
            'Payment {name} has been created',
            [
                'name' => $payment->getName(),
            ]
        );
    }
 }
Tags
Methods¶
                 __construct()
            ¶
__construct()
            ¶
    
        
        CreatePaymentEvent.php
                :
        57
                 
    
        |  |  | 
Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
| $createStruct | PaymentCreateStruct | - | - | 
| $paymentResult | PaymentInterface | - | - | 
                 getCreateStruct()
            ¶
getCreateStruct()
            ¶
    
        
        CreatePaymentEvent.php
                :
        66
                 
    
        Returns create struct used to create payment.
|  |  | 
Return values
                 getPaymentResult()
            ¶
getPaymentResult()
            ¶
    
        
        CreatePaymentEvent.php
                :
        74
                 
    
        Returns the payment that has been created.
|  |  | 
Return values
                 isPropagationStopped()
            ¶
isPropagationStopped()
            ¶
    
        
        Event.php
                :
        38
                 
    
        |  |  | 
Return values
bool
                 stopPropagation()
            ¶
stopPropagation()
            ¶
    
        
        Event.php
                :
        50
                 
    
        Stops the propagation of the event to further event listeners.
|  |  | 
If multiple event listeners are connected to the same event, no further event listener will be triggered once any trigger calls stopPropagation().