File tree 5 files changed +56
-6
lines changed
5 files changed +56
-6
lines changed Original file line number Diff line number Diff line change 9
9
use Payum \Core \GatewayAwareInterface ;
10
10
use Payum \Core \GatewayAwareTrait ;
11
11
use Payum \Core \Request \Capture ;
12
- use Payum \Core \Request \GetHttpRequest ;
13
12
use Payum \Core \Request \Sync ;
14
13
use Payum \Core \Security \GenericTokenFactoryAwareInterface ;
15
14
use Payum \Core \Security \GenericTokenFactoryAwareTrait ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Ekyna \Component \Payum \Payzen \Action ;
4
+
5
+ use Ekyna \Component \Commerce \Bridge \Payum \Request \GetHumanStatus ;
6
+ use Payum \Core \Action \ActionInterface ;
7
+ use Payum \Core \Bridge \Spl \ArrayObject ;
8
+ use Payum \Core \Exception \RequestNotSupportedException ;
9
+ use Payum \Core \GatewayAwareInterface ;
10
+ use Payum \Core \GatewayAwareTrait ;
11
+ use Payum \Core \Request \Refund ;
12
+
13
+ /**
14
+ * Class CaptureAction
15
+ * @package Ekyna\Component\Payum\Payzen\Action
16
+ * @author Etienne Dauvergne <contact@ekyna.com>
17
+ */
18
+ class RefundAction implements ActionInterface, GatewayAwareInterface
19
+ {
20
+ use GatewayAwareTrait;
21
+
22
+ /**
23
+ * {@inheritdoc}
24
+ */
25
+ public function execute ($ request )
26
+ {
27
+ RequestNotSupportedException::assertSupports ($ this , $ request );
28
+
29
+ $ model = ArrayObject::ensureArrayObject ($ request ->getModel ());
30
+
31
+ $ this ->gateway ->execute ($ status = new GetHumanStatus ($ model ));
32
+ if ($ status ->isCaptured ()) {
33
+ $ model ['state_override ' ] = 'refunded ' ;
34
+ }
35
+ }
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ public function supports ($ request )
41
+ {
42
+ return $ request instanceof Refund
43
+ && $ request ->getModel () instanceof \ArrayAccess;
44
+ }
45
+ }
Original file line number Diff line number Diff line change @@ -31,10 +31,8 @@ public function execute($request)
31
31
return ;
32
32
}
33
33
34
-
35
-
36
- if (false != $ responseCode = $ model ['vads_auth_result ' ]) {
37
- switch ($ responseCode ) {
34
+ if (false != $ code = $ model ['vads_auth_result ' ]) {
35
+ switch ($ code ) {
38
36
case "00 " : // transaction approuvée ou traitée avec succès
39
37
$ request ->markCaptured ();
40
38
break ;
@@ -81,6 +79,12 @@ public function execute($request)
81
79
$ request ->markUnknown ();
82
80
}
83
81
82
+ if ($ request ->isCaptured () && false != $ code = $ model ['state_override ' ]) {
83
+ if ($ code == 'refunded ' ) {
84
+ $ request ->markRefunded ();
85
+ }
86
+ }
87
+
84
88
return ;
85
89
}
86
90
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ public function getTransactionId()
80
80
81
81
$ id = 1 ;
82
82
$ date = (new \DateTime ())->format ('Ymd ' );
83
- $ isDailyFirstAccess = ($ date != date ('Ymd ' , fileatime ($ path )));
83
+ $ fileDate = date ('Ymd ' , filemtime ($ path ));
84
+ $ isDailyFirstAccess = ($ date != $ fileDate );
84
85
85
86
// Open file
86
87
$ handle = fopen ($ this ->config ['trans_id_file_path ' ], 'r+ ' );
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ protected function populateConfig(ArrayObject $config)
44
44
'payum.action.api_request ' => new Action \Api \ApiRequestAction (),
45
45
'payum.action.api_response ' => new Action \Api \ApiResponseAction (),
46
46
'payum.action.sync ' => new Action \SyncAction (),
47
+ 'payum.action.refund ' => new Action \RefundAction (),
47
48
'payum.action.status ' => new Action \StatusAction (),
48
49
]);
49
50
You can’t perform that action at this time.
0 commit comments