1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Speicher210\FastbillBundle\Controller\Notification; |
4
|
|
|
|
5
|
|
|
use Speicher210\Fastbill\Api\Model\Notification\Payment\PaymentChargebackNotification; |
6
|
|
|
use Speicher210\Fastbill\Api\Model\Notification\Payment\PaymentCreatedNotification; |
7
|
|
|
use Speicher210\Fastbill\Api\Model\Notification\Payment\PaymentFailedNotification; |
8
|
|
|
use Speicher210\Fastbill\Api\Model\Notification\Payment\PaymentRefundedNotification; |
9
|
|
|
use Speicher210\FastbillBundle\Event\PaymentChargebackEvent; |
10
|
|
|
use Speicher210\FastbillBundle\Event\PaymentCreatedEvent; |
11
|
|
|
use Speicher210\FastbillBundle\Event\PaymentFailedEvent; |
12
|
|
|
use Speicher210\FastbillBundle\Event\PaymentRefundedEvent; |
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Controller for payments notifications. |
18
|
|
|
*/ |
19
|
|
|
class PaymentController extends AbstractController |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Action when a payment is created. |
24
|
|
|
* |
25
|
|
|
* @param Request $request The made request. |
26
|
|
|
* @return Response |
27
|
|
|
*/ |
28
|
3 |
|
public function createdAction(Request $request) |
29
|
|
|
{ |
30
|
3 |
|
$event = new PaymentCreatedEvent(); |
31
|
|
|
|
32
|
3 |
|
return $this->handleNotification($request, $event, PaymentCreatedNotification::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Action when a payment is chargebacked. |
37
|
|
|
* |
38
|
|
|
* @param Request $request The made request. |
39
|
|
|
* @return Response |
40
|
|
|
*/ |
41
|
3 |
|
public function chargebackAction(Request $request) |
42
|
|
|
{ |
43
|
3 |
|
$event = new PaymentChargebackEvent(); |
44
|
|
|
|
45
|
3 |
|
return $this->handleNotification($request, $event, PaymentChargebackNotification::class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Action when a payment failed. |
50
|
|
|
* |
51
|
|
|
* @param Request $request The made request. |
52
|
|
|
* @return Response |
53
|
|
|
*/ |
54
|
3 |
|
public function failedAction(Request $request) |
55
|
|
|
{ |
56
|
3 |
|
$event = new PaymentFailedEvent(); |
57
|
|
|
|
58
|
3 |
|
return $this->handleNotification($request, $event, PaymentFailedNotification::class); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Action when a payment is refunded. |
63
|
|
|
* |
64
|
|
|
* @param Request $request The made request. |
65
|
|
|
* @return Response |
66
|
|
|
*/ |
67
|
3 |
|
public function refundedAction(Request $request) |
68
|
|
|
{ |
69
|
3 |
|
$event = new PaymentRefundedEvent(); |
70
|
|
|
|
71
|
3 |
|
return $this->handleNotification($request, $event, PaymentRefundedNotification::class); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|