|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* amadeus-ws-client |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2015 Amadeus Benelux NV |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
9
|
|
|
* you may not use this file except in compliance with the License. |
|
10
|
|
|
* You may obtain a copy of the License at |
|
11
|
|
|
* |
|
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
13
|
|
|
* |
|
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17
|
|
|
* See the License for the specific language governing permissions and |
|
18
|
|
|
* limitations under the License. |
|
19
|
|
|
* |
|
20
|
|
|
* @package Amadeus |
|
21
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace Amadeus\Client\ResponseHandler\PAY; |
|
25
|
|
|
|
|
26
|
|
|
use Amadeus\Client\Exception; |
|
27
|
|
|
use Amadeus\Client\Result; |
|
28
|
|
|
use Amadeus\Client\Session\Handler\SendResult; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* HandlerGetVirtualCardDetails |
|
32
|
|
|
* |
|
33
|
|
|
* @package Amadeus\Client\ResponseHandler\PAY |
|
34
|
|
|
* @author Konstantin Bogomolov <[email protected]> |
|
35
|
|
|
*/ |
|
36
|
|
|
class HandlerGetVirtualCardDetails extends AbstractCardDetailsResponseHandler |
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* Analyze the result from the message operation and check for any error messages |
|
40
|
|
|
* |
|
41
|
|
|
* @param SendResult $response |
|
42
|
|
|
* @return Result |
|
43
|
|
|
* @throws Exception |
|
44
|
|
|
*/ |
|
45
|
|
|
public function analyze(SendResult $response) |
|
46
|
|
|
{ |
|
47
|
|
|
$analyzeResponse = new Result($response); |
|
48
|
|
|
|
|
49
|
|
|
$code = null; |
|
50
|
|
|
$message = null; |
|
51
|
|
|
|
|
52
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
53
|
|
|
|
|
54
|
|
|
$categoryNodes = $domXpath->query('//ama_ct:Errors/ama_ct:Error/@Type'); |
|
55
|
|
|
if ($categoryNodes->length > 0) { |
|
56
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNodes->item(0)->nodeValue); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$codeNodes = $domXpath->query('//ama_ct:Errors/ama_ct:Error/@Code'); |
|
60
|
|
|
if ($codeNodes->length > 0) { |
|
61
|
|
|
$code = $codeNodes->item(0)->nodeValue; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$messageNodes = $domXpath->query('//ama_ct:Errors/ama_ct:Error/@ShortText'); |
|
65
|
|
|
if ($messageNodes->length > 0) { |
|
66
|
|
|
$message = $this->makeMessageFromMessagesNodeList($messageNodes); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (!is_null($message) && !is_null($code)) { |
|
70
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, $message); |
|
71
|
|
|
return $analyzeResponse; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return $this->fillCardDetails($analyzeResponse, $domXpath); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|