Total Complexity | 11 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class StatusAction implements ActionInterface, ApiAwareInterface |
||
16 | { |
||
17 | use ApiAwareTrait; |
||
18 | |||
19 | public function __construct() |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * {@inheritDoc} |
||
26 | * |
||
27 | * @param GetStatusInterface $request |
||
28 | */ |
||
29 | public function execute($request) |
||
30 | { |
||
31 | RequestNotSupportedException::assertSupports($this, $request); |
||
32 | |||
33 | $model = $request->getModel(); |
||
34 | |||
35 | if (false === isset($model['tcompayway_response'])) { |
||
36 | $request->markNew(); |
||
37 | |||
38 | return; |
||
39 | } |
||
40 | |||
41 | $statusCode = (int)$model['tcompayway_response']['pgw_result_code']; |
||
42 | |||
43 | if (0 === $statusCode && 0 === (int)$this->api->getPgwAuthorizationType()) { |
||
44 | $request->markCaptured(); |
||
45 | |||
46 | return; |
||
47 | } |
||
48 | |||
49 | if (0 === $statusCode && 1 === (int)$this->api->getPgwAuthorizationType()) { |
||
50 | $request->markCaptured(); |
||
51 | |||
52 | return; |
||
53 | } |
||
54 | |||
55 | if ($statusCode === 3) { |
||
56 | $request->markCanceled(); |
||
57 | |||
58 | return; |
||
59 | } |
||
60 | |||
61 | if ($statusCode > 0) { |
||
62 | $request->markFailed(); |
||
63 | |||
64 | return; |
||
65 | } |
||
66 | |||
67 | $request->markUnknown(); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | public function supports($request) |
||
78 | } |
||
79 | } |
||
80 |