1: | <?php |
2: | |
3: | |
4: | |
5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
6: | |
7: | use DateTime; |
8: | use UnexpectedValueException; |
9: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
10: | |
11: | |
12: | |
13: | |
14: | class ApiPaymentResponse extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $cardPaymentData = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $initialAuthorizationCode = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $operationId = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $paymentId = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $references = null; |
40: | |
41: | |
42: | |
43: | |
44: | public $responder = null; |
45: | |
46: | |
47: | |
48: | |
49: | public $responseCode = null; |
50: | |
51: | |
52: | |
53: | |
54: | public $responseCodeCategory = null; |
55: | |
56: | |
57: | |
58: | |
59: | public $responseCodeDescription = null; |
60: | |
61: | |
62: | |
63: | |
64: | public $retryAfter = null; |
65: | |
66: | |
67: | |
68: | |
69: | public $status = null; |
70: | |
71: | |
72: | |
73: | |
74: | public $statusTimestamp = null; |
75: | |
76: | |
77: | |
78: | |
79: | public $totalAuthorizedAmount = null; |
80: | |
81: | |
82: | |
83: | |
84: | public function toObject() |
85: | { |
86: | $object = parent::toObject(); |
87: | if (!is_null($this->cardPaymentData)) { |
88: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
89: | } |
90: | if (!is_null($this->initialAuthorizationCode)) { |
91: | $object->initialAuthorizationCode = $this->initialAuthorizationCode; |
92: | } |
93: | if (!is_null($this->operationId)) { |
94: | $object->operationId = $this->operationId; |
95: | } |
96: | if (!is_null($this->paymentId)) { |
97: | $object->paymentId = $this->paymentId; |
98: | } |
99: | if (!is_null($this->references)) { |
100: | $object->references = $this->references->toObject(); |
101: | } |
102: | if (!is_null($this->responder)) { |
103: | $object->responder = $this->responder; |
104: | } |
105: | if (!is_null($this->responseCode)) { |
106: | $object->responseCode = $this->responseCode; |
107: | } |
108: | if (!is_null($this->responseCodeCategory)) { |
109: | $object->responseCodeCategory = $this->responseCodeCategory; |
110: | } |
111: | if (!is_null($this->responseCodeDescription)) { |
112: | $object->responseCodeDescription = $this->responseCodeDescription; |
113: | } |
114: | if (!is_null($this->retryAfter)) { |
115: | $object->retryAfter = $this->retryAfter; |
116: | } |
117: | if (!is_null($this->status)) { |
118: | $object->status = $this->status; |
119: | } |
120: | if (!is_null($this->statusTimestamp)) { |
121: | $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP'); |
122: | } |
123: | if (!is_null($this->totalAuthorizedAmount)) { |
124: | $object->totalAuthorizedAmount = $this->totalAuthorizedAmount->toObject(); |
125: | } |
126: | return $object; |
127: | } |
128: | |
129: | |
130: | |
131: | |
132: | |
133: | |
134: | public function fromObject($object) |
135: | { |
136: | parent::fromObject($object); |
137: | if (property_exists($object, 'cardPaymentData')) { |
138: | if (!is_object($object->cardPaymentData)) { |
139: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
140: | } |
141: | $value = new CardPaymentDataForResponse(); |
142: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
143: | } |
144: | if (property_exists($object, 'initialAuthorizationCode')) { |
145: | $this->initialAuthorizationCode = $object->initialAuthorizationCode; |
146: | } |
147: | if (property_exists($object, 'operationId')) { |
148: | $this->operationId = $object->operationId; |
149: | } |
150: | if (property_exists($object, 'paymentId')) { |
151: | $this->paymentId = $object->paymentId; |
152: | } |
153: | if (property_exists($object, 'references')) { |
154: | if (!is_object($object->references)) { |
155: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
156: | } |
157: | $value = new ApiReferencesForResponses(); |
158: | $this->references = $value->fromObject($object->references); |
159: | } |
160: | if (property_exists($object, 'responder')) { |
161: | $this->responder = $object->responder; |
162: | } |
163: | if (property_exists($object, 'responseCode')) { |
164: | $this->responseCode = $object->responseCode; |
165: | } |
166: | if (property_exists($object, 'responseCodeCategory')) { |
167: | $this->responseCodeCategory = $object->responseCodeCategory; |
168: | } |
169: | if (property_exists($object, 'responseCodeDescription')) { |
170: | $this->responseCodeDescription = $object->responseCodeDescription; |
171: | } |
172: | if (property_exists($object, 'retryAfter')) { |
173: | $this->retryAfter = $object->retryAfter; |
174: | } |
175: | if (property_exists($object, 'status')) { |
176: | $this->status = $object->status; |
177: | } |
178: | if (property_exists($object, 'statusTimestamp')) { |
179: | $this->statusTimestamp = new DateTime($object->statusTimestamp); |
180: | } |
181: | if (property_exists($object, 'totalAuthorizedAmount')) { |
182: | if (!is_object($object->totalAuthorizedAmount)) { |
183: | throw new UnexpectedValueException('value \'' . print_r($object->totalAuthorizedAmount, true) . '\' is not an object'); |
184: | } |
185: | $value = new AmountData(); |
186: | $this->totalAuthorizedAmount = $value->fromObject($object->totalAuthorizedAmount); |
187: | } |
188: | return $this; |
189: | } |
190: | } |
191: | |