|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright 2015 Alexey Maslov <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
6
|
|
|
* you may not use this file except in compliance with the License. |
|
7
|
|
|
* You may obtain a copy of the License at |
|
8
|
|
|
* |
|
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
* |
|
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14
|
|
|
* See the License for the specific language governing permissions and |
|
15
|
|
|
* limitations under the License. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace alxmsl\PaymentNinja\Response; |
|
19
|
|
|
|
|
20
|
|
|
use alxmsl\PaymentNinja\InitializationInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class for process recurring results data |
|
24
|
|
|
* @author alxmsl |
|
25
|
|
|
*/ |
|
26
|
|
|
final class ProcessRecurringResponse extends AbstractResponse implements InitializationInterface { |
|
27
|
|
|
/** |
|
28
|
|
|
* @var string transaction identifier |
|
29
|
|
|
*/ |
|
30
|
|
|
private $id = ''; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var bool request processing result |
|
34
|
|
|
*/ |
|
35
|
|
|
private $success = false; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var null|CardResponse instance with safely card data |
|
39
|
|
|
*/ |
|
40
|
|
|
private $Card = null; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return string transaction identifier |
|
44
|
|
|
*/ |
|
45
|
1 |
|
public function getId() { |
|
46
|
1 |
|
return $this->id; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return boolean request processing result |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function isSuccess() { |
|
53
|
1 |
|
return $this->success; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return null|CardResponse instance with safely card data |
|
58
|
|
|
*/ |
|
59
|
1 |
|
public function getCard() { |
|
60
|
1 |
|
return $this->Card; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @inheritdoc |
|
65
|
|
|
* @return ProcessRecurringResponse instance, that describes payment recurring process result |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public static function initializeByString($string) { |
|
68
|
1 |
|
$Response = json_decode($string); |
|
69
|
1 |
|
$Result = new ProcessRecurringResponse(); |
|
70
|
1 |
|
$Result->id = (string) $Response->id; |
|
71
|
1 |
|
$Result->success = (bool) $Response->success; |
|
72
|
1 |
|
$Result->Card = CardResponse::initializeByObject($Response->card); |
|
73
|
1 |
|
return $Result; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @inheritdoc |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function __toString() { |
|
80
|
|
|
$format = <<<'EOD' |
|
81
|
|
|
process recurring result |
|
82
|
|
|
id: %s |
|
83
|
|
|
success: %s |
|
84
|
|
|
card |
|
85
|
|
|
%s |
|
86
|
1 |
|
EOD; |
|
87
|
1 |
|
return sprintf($format |
|
88
|
1 |
|
, $this->getId() |
|
89
|
1 |
|
, json_encode($this->isSuccess()) |
|
90
|
1 |
|
, (string) $this->getCard()); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|