commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
PaymentModel.php
1<?php
2
3declare(strict_types=1);
10
30use DateTimeImmutable;
31use stdClass;
32
36final class PaymentModel extends JsonObjectModel implements Payment
37{
42 protected $id;
43
48 protected $version;
49
54 protected $createdAt;
55
60 protected $lastModifiedAt;
61
66 protected $lastModifiedBy;
67
72 protected $createdBy;
73
78 protected $customer;
79
84 protected $anonymousId;
85
90 protected $interfaceId;
91
96 protected $amountPlanned;
97
103
108 protected $paymentStatus;
109
114 protected $transactions;
115
121
126 protected $custom;
127
132 protected $key;
133
134
138 public function __construct(
139 ?string $id = null,
140 ?int $version = null,
141 ?DateTimeImmutable $createdAt = null,
142 ?DateTimeImmutable $lastModifiedAt = null,
144 ?CreatedBy $createdBy = null,
146 ?string $anonymousId = null,
147 ?string $interfaceId = null,
153 ?CustomFields $custom = null,
154 ?string $key = null
155 ) {
156 $this->id = $id;
157 $this->version = $version;
158 $this->createdAt = $createdAt;
159 $this->lastModifiedAt = $lastModifiedAt;
160 $this->lastModifiedBy = $lastModifiedBy;
161 $this->createdBy = $createdBy;
162 $this->customer = $customer;
163 $this->anonymousId = $anonymousId;
164 $this->interfaceId = $interfaceId;
165 $this->amountPlanned = $amountPlanned;
166 $this->paymentMethodInfo = $paymentMethodInfo;
167 $this->paymentStatus = $paymentStatus;
168 $this->transactions = $transactions;
169 $this->interfaceInteractions = $interfaceInteractions;
170 $this->custom = $custom;
171 $this->key = $key;
172 }
173
180 public function getId()
181 {
182 if (is_null($this->id)) {
184 $data = $this->raw(self::FIELD_ID);
185 if (is_null($data)) {
186 return null;
187 }
188 $this->id = (string) $data;
189 }
190
191 return $this->id;
192 }
193
200 public function getVersion()
201 {
202 if (is_null($this->version)) {
204 $data = $this->raw(self::FIELD_VERSION);
205 if (is_null($data)) {
206 return null;
207 }
208 $this->version = (int) $data;
209 }
210
211 return $this->version;
212 }
213
220 public function getCreatedAt()
221 {
222 if (is_null($this->createdAt)) {
224 $data = $this->raw(self::FIELD_CREATED_AT);
225 if (is_null($data)) {
226 return null;
227 }
228 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
229 if (false === $data) {
230 return null;
231 }
232 $this->createdAt = $data;
233 }
234
235 return $this->createdAt;
236 }
237
244 public function getLastModifiedAt()
245 {
246 if (is_null($this->lastModifiedAt)) {
248 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
249 if (is_null($data)) {
250 return null;
251 }
252 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
253 if (false === $data) {
254 return null;
255 }
256 $this->lastModifiedAt = $data;
257 }
258
260 }
261
268 public function getLastModifiedBy()
269 {
270 if (is_null($this->lastModifiedBy)) {
272 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
273 if (is_null($data)) {
274 return null;
275 }
276
277 $this->lastModifiedBy = LastModifiedByModel::of($data);
278 }
279
281 }
282
289 public function getCreatedBy()
290 {
291 if (is_null($this->createdBy)) {
293 $data = $this->raw(self::FIELD_CREATED_BY);
294 if (is_null($data)) {
295 return null;
296 }
297
298 $this->createdBy = CreatedByModel::of($data);
299 }
300
301 return $this->createdBy;
302 }
303
310 public function getCustomer()
311 {
312 if (is_null($this->customer)) {
314 $data = $this->raw(self::FIELD_CUSTOMER);
315 if (is_null($data)) {
316 return null;
317 }
318
319 $this->customer = CustomerReferenceModel::of($data);
320 }
321
322 return $this->customer;
323 }
324
331 public function getAnonymousId()
332 {
333 if (is_null($this->anonymousId)) {
335 $data = $this->raw(self::FIELD_ANONYMOUS_ID);
336 if (is_null($data)) {
337 return null;
338 }
339 $this->anonymousId = (string) $data;
340 }
341
342 return $this->anonymousId;
343 }
344
352 public function getInterfaceId()
353 {
354 if (is_null($this->interfaceId)) {
356 $data = $this->raw(self::FIELD_INTERFACE_ID);
357 if (is_null($data)) {
358 return null;
359 }
360 $this->interfaceId = (string) $data;
361 }
362
363 return $this->interfaceId;
364 }
365
373 public function getAmountPlanned()
374 {
375 if (is_null($this->amountPlanned)) {
377 $data = $this->raw(self::FIELD_AMOUNT_PLANNED);
378 if (is_null($data)) {
379 return null;
380 }
381
382 $this->amountPlanned = CentPrecisionMoneyModel::of($data);
383 }
384
386 }
387
394 public function getPaymentMethodInfo()
395 {
396 if (is_null($this->paymentMethodInfo)) {
398 $data = $this->raw(self::FIELD_PAYMENT_METHOD_INFO);
399 if (is_null($data)) {
400 return null;
401 }
402
403 $this->paymentMethodInfo = PaymentMethodInfoModel::of($data);
404 }
405
407 }
408
415 public function getPaymentStatus()
416 {
417 if (is_null($this->paymentStatus)) {
419 $data = $this->raw(self::FIELD_PAYMENT_STATUS);
420 if (is_null($data)) {
421 return null;
422 }
423
424 $this->paymentStatus = PaymentStatusModel::of($data);
425 }
426
428 }
429
436 public function getTransactions()
437 {
438 if (is_null($this->transactions)) {
440 $data = $this->raw(self::FIELD_TRANSACTIONS);
441 if (is_null($data)) {
442 return null;
443 }
444 $this->transactions = TransactionCollection::fromArray($data);
445 }
446
447 return $this->transactions;
448 }
449
456 public function getInterfaceInteractions()
457 {
458 if (is_null($this->interfaceInteractions)) {
460 $data = $this->raw(self::FIELD_INTERFACE_INTERACTIONS);
461 if (is_null($data)) {
462 return null;
463 }
464 $this->interfaceInteractions = CustomFieldsCollection::fromArray($data);
465 }
466
468 }
469
476 public function getCustom()
477 {
478 if (is_null($this->custom)) {
480 $data = $this->raw(self::FIELD_CUSTOM);
481 if (is_null($data)) {
482 return null;
483 }
484
485 $this->custom = CustomFieldsModel::of($data);
486 }
487
488 return $this->custom;
489 }
490
497 public function getKey()
498 {
499 if (is_null($this->key)) {
501 $data = $this->raw(self::FIELD_KEY);
502 if (is_null($data)) {
503 return null;
504 }
505 $this->key = (string) $data;
506 }
507
508 return $this->key;
509 }
510
511
515 public function setId(?string $id): void
516 {
517 $this->id = $id;
518 }
519
523 public function setVersion(?int $version): void
524 {
525 $this->version = $version;
526 }
527
531 public function setCreatedAt(?DateTimeImmutable $createdAt): void
532 {
533 $this->createdAt = $createdAt;
534 }
535
539 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
540 {
541 $this->lastModifiedAt = $lastModifiedAt;
542 }
543
548 {
549 $this->lastModifiedBy = $lastModifiedBy;
550 }
551
555 public function setCreatedBy(?CreatedBy $createdBy): void
556 {
557 $this->createdBy = $createdBy;
558 }
559
564 {
565 $this->customer = $customer;
566 }
567
571 public function setAnonymousId(?string $anonymousId): void
572 {
573 $this->anonymousId = $anonymousId;
574 }
575
579 public function setInterfaceId(?string $interfaceId): void
580 {
581 $this->interfaceId = $interfaceId;
582 }
583
588 {
589 $this->amountPlanned = $amountPlanned;
590 }
591
596 {
597 $this->paymentMethodInfo = $paymentMethodInfo;
598 }
599
604 {
605 $this->paymentStatus = $paymentStatus;
606 }
607
612 {
613 $this->transactions = $transactions;
614 }
615
620 {
621 $this->interfaceInteractions = $interfaceInteractions;
622 }
623
627 public function setCustom(?CustomFields $custom): void
628 {
629 $this->custom = $custom;
630 }
631
635 public function setKey(?string $key): void
636 {
637 $this->key = $key;
638 }
639
640
641 #[\ReturnTypeWillChange]
642 public function jsonSerialize()
643 {
644 $data = $this->toArray();
645 if (isset($data[Payment::FIELD_CREATED_AT]) && $data[Payment::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
646 $data[Payment::FIELD_CREATED_AT] = $data[Payment::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
647 }
648
649 if (isset($data[Payment::FIELD_LAST_MODIFIED_AT]) && $data[Payment::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
650 $data[Payment::FIELD_LAST_MODIFIED_AT] = $data[Payment::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
651 }
652 return (object) $data;
653 }
654}
setAmountPlanned(?CentPrecisionMoney $amountPlanned)
setTransactions(?TransactionCollection $transactions)
setInterfaceInteractions(?CustomFieldsCollection $interfaceInteractions)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setPaymentMethodInfo(?PaymentMethodInfo $paymentMethodInfo)
setPaymentStatus(?PaymentStatus $paymentStatus)
setCreatedAt(?DateTimeImmutable $createdAt)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?CustomerReference $customer=null, ?string $anonymousId=null, ?string $interfaceId=null, ?CentPrecisionMoney $amountPlanned=null, ?PaymentMethodInfo $paymentMethodInfo=null, ?PaymentStatus $paymentStatus=null, ?TransactionCollection $transactions=null, ?CustomFieldsCollection $interfaceInteractions=null, ?CustomFields $custom=null, ?string $key=null)
setCustomer(?CustomerReference $customer)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
static fromArray(array $data)