1 | <?php |
||
17 | class CaptureAction extends BaseApiAwareAction implements ActionInterface, GatewayAwareInterface, GenericTokenFactoryAwareInterface |
||
18 | { |
||
19 | use GatewayAwareTrait; |
||
20 | use GenericTokenFactoryAwareTrait; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | * |
||
25 | * @param Capture $request |
||
26 | */ |
||
27 | 2 | public function execute($request) |
|
28 | { |
||
29 | 2 | RequestNotSupportedException::assertSupports($this, $request); |
|
30 | 2 | $details = ArrayObject::ensureArrayObject($request->getModel()); |
|
31 | |||
32 | 2 | $httpRequest = new GetHttpRequest(); |
|
33 | 2 | $this->gateway->execute($httpRequest); |
|
34 | |||
35 | 2 | if (isset($httpRequest->request['paymentResult']) === true) { |
|
36 | 1 | $httpRequest->request = $this->api->parseResponse($httpRequest->request); |
|
37 | 1 | if ($this->api->verifyHash($httpRequest->request) === false) { |
|
38 | $httpRequest->request['RspCode'] = '-1'; |
||
39 | } |
||
40 | 1 | $details->replace($httpRequest->request); |
|
41 | |||
42 | 1 | return; |
|
43 | } |
||
44 | |||
45 | 1 | $token = $request->getToken(); |
|
46 | 1 | $targetUrl = $token->getTargetUrl(); |
|
47 | |||
48 | 1 | if (empty($details['Merchanturl']) === true) { |
|
49 | 1 | $details['Merchanturl'] = $targetUrl; |
|
50 | } |
||
51 | |||
52 | 1 | if (empty($details['FailUrl']) === true) { |
|
53 | 1 | $details['FailUrl'] = $targetUrl; |
|
54 | } |
||
55 | |||
56 | 1 | if (empty($details['ServerUrl']) === true) { |
|
57 | 1 | $notifyToken = $this->tokenFactory->createNotifyToken( |
|
58 | 1 | $token->getGatewayName(), |
|
59 | 1 | $token->getDetails() |
|
60 | ); |
||
61 | |||
62 | 1 | $details['ServerUrl'] = $notifyToken->getTargetUrl(); |
|
63 | } |
||
64 | |||
65 | 1 | $this->gateway->execute(new CreateTransaction($details)); |
|
66 | 1 | } |
|
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | 2 | public function supports($request) |
|
77 | } |
||
78 |