|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PayumTW\Ezship\Action; |
|
4
|
|
|
|
|
5
|
|
|
use Payum\Core\Request\Capture; |
|
6
|
|
|
use Payum\Core\GatewayAwareTrait; |
|
7
|
|
|
use Payum\Core\GatewayAwareInterface; |
|
8
|
|
|
use Payum\Core\Action\ActionInterface; |
|
9
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
|
10
|
|
|
use Payum\Core\Request\GetHttpRequest; |
|
11
|
|
|
use PayumTW\Ezship\Action\Api\BaseApiAwareAction; |
|
12
|
|
|
use PayumTW\Ezship\Request\Api\CreateTransaction; |
|
13
|
|
|
use Payum\Core\Exception\RequestNotSupportedException; |
|
14
|
|
|
|
|
15
|
|
|
class CaptureAction extends BaseApiAwareAction implements ActionInterface, GatewayAwareInterface |
|
16
|
|
|
{ |
|
17
|
|
|
use GatewayAwareTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
* |
|
22
|
|
|
* @param Capture $request |
|
23
|
|
|
*/ |
|
24
|
3 |
|
public function execute($request) |
|
25
|
|
|
{ |
|
26
|
3 |
|
RequestNotSupportedException::assertSupports($this, $request); |
|
27
|
|
|
|
|
28
|
3 |
|
$details = ArrayObject::ensureArrayObject($request->getModel()); |
|
29
|
|
|
|
|
30
|
3 |
|
$httpRequest = new GetHttpRequest(); |
|
31
|
3 |
|
$this->gateway->execute($httpRequest); |
|
32
|
|
|
|
|
33
|
3 |
|
if (isset($httpRequest->request['order_status']) === true || |
|
34
|
2 |
|
isset($httpRequest->request['processID']) === true // CVS |
|
35
|
3 |
|
) { |
|
36
|
2 |
|
if ($this->api->verifyHash($httpRequest->request, (array) $details) === false) { |
|
37
|
2 |
|
$httpRequest->request['order_status'] = 'E99'; |
|
38
|
2 |
|
} |
|
39
|
2 |
|
$details->replace($httpRequest->request); |
|
40
|
|
|
|
|
41
|
2 |
|
return; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
1 |
|
$token = $request->getToken(); |
|
45
|
1 |
|
$targetUrl = $token->getTargetUrl(); |
|
46
|
|
|
|
|
47
|
1 |
|
if (empty($details['rtn_url']) === true) { |
|
48
|
1 |
|
$details['rtn_url'] = $targetUrl; |
|
49
|
1 |
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
$this->gateway->execute(new CreateTransaction($details)); |
|
52
|
1 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inheritdoc} |
|
56
|
|
|
*/ |
|
57
|
3 |
|
public function supports($request) |
|
58
|
|
|
{ |
|
59
|
|
|
return |
|
60
|
3 |
|
$request instanceof Capture && |
|
61
|
3 |
|
$request->getModel() instanceof \ArrayAccess; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|