1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Speicher210\FastbillBundle\EventListener; |
4
|
|
|
|
5
|
|
|
use Speicher210\FastbillBundle\Event\PaymentChargebackEvent; |
6
|
|
|
use Speicher210\FastbillBundle\Event\PaymentCreatedEvent; |
7
|
|
|
use Speicher210\FastbillBundle\Event\PaymentFailedEvent; |
8
|
|
|
use Speicher210\FastbillBundle\Event\PaymentRefundedEvent; |
9
|
|
|
use Speicher210\FastbillBundle\FastbillNotificationEvents; |
10
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Event listener for incoming Fastbill payment notifications. |
14
|
|
|
*/ |
15
|
|
|
abstract class AbstractPaymentListener implements EventSubscriberInterface |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Handle creating a payment. |
20
|
|
|
* |
21
|
|
|
* @param PaymentCreatedEvent $event The raised event. |
22
|
|
|
*/ |
23
|
|
|
abstract public function onPaymentCreated(PaymentCreatedEvent $event); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Handle payment chargeback. |
27
|
|
|
* |
28
|
|
|
* @param PaymentChargebackEvent $event The raised event. |
29
|
|
|
*/ |
30
|
|
|
abstract public function onPaymentChargeback(PaymentChargebackEvent $event); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Handle failed payment. |
34
|
|
|
* |
35
|
|
|
* @param PaymentFailedEvent $event The raised event. |
36
|
|
|
*/ |
37
|
|
|
abstract public function onPaymentFailed(PaymentFailedEvent $event); |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Handle refunded payment. |
41
|
|
|
* |
42
|
|
|
* @param PaymentRefundedEvent $event The raised event. |
43
|
|
|
*/ |
44
|
|
|
abstract public function onPaymentRefundedEvent(PaymentRefundedEvent $event); |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public static function getSubscribedEvents() |
50
|
|
|
{ |
51
|
|
|
return array( |
52
|
|
|
FastbillNotificationEvents::INCOMING_PAYMENT_CREATED => 'onPaymentCreated', |
53
|
|
|
FastbillNotificationEvents::INCOMING_PAYMENT_CHARGEBACK => 'onPaymentChargeback', |
54
|
|
|
FastbillNotificationEvents::INCOMING_PAYMENT_FAILED => 'onPaymentFailed', |
55
|
|
|
FastbillNotificationEvents::INCOMING_PAYMENT_REFUNDED => 'onPaymentRefundedEvent' |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|