| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Entity\Payment; |
| 4 |
|
| 5 |
use IvyForms\ValueObjects\Payment\Payment as PaymentValueObject; |
| 6 |
|
| 7 |
/** |
| 8 |
* Payment entity wrapping the value object. |
| 9 |
*/ |
| 10 |
class Payment |
| 11 |
{ |
| 12 |
private PaymentValueObject $payment; |
| 13 |
|
| 14 |
public function __construct(PaymentValueObject $payment) |
| 15 |
{ |
| 16 |
$this->payment = $payment; |
| 17 |
} |
| 18 |
|
| 19 |
public function getId(): int |
| 20 |
{ |
| 21 |
return $this->payment->id; |
| 22 |
} |
| 23 |
|
| 24 |
public function setId(int $id): void |
| 25 |
{ |
| 26 |
$this->payment->id = $id; |
| 27 |
} |
| 28 |
|
| 29 |
public function getEntryId(): ?int |
| 30 |
{ |
| 31 |
return $this->payment->entryId; |
| 32 |
} |
| 33 |
|
| 34 |
public function getFormId(): int |
| 35 |
{ |
| 36 |
return $this->payment->formId; |
| 37 |
} |
| 38 |
|
| 39 |
public function getTransactionId(): string |
| 40 |
{ |
| 41 |
return $this->payment->transactionId; |
| 42 |
} |
| 43 |
|
| 44 |
public function getPaymentMethod(): string |
| 45 |
{ |
| 46 |
return $this->payment->paymentMethod; |
| 47 |
} |
| 48 |
|
| 49 |
public function getCustomerName(): ?string |
| 50 |
{ |
| 51 |
return $this->payment->customerName; |
| 52 |
} |
| 53 |
|
| 54 |
public function setCustomerName(?string $customerName): void |
| 55 |
{ |
| 56 |
$this->payment = $this->payment->withCustomerName( |
| 57 |
$customerName !== null && $customerName !== '' ? $customerName : null |
| 58 |
); |
| 59 |
} |
| 60 |
|
| 61 |
public function getAmount(): int |
| 62 |
{ |
| 63 |
return $this->payment->amount; |
| 64 |
} |
| 65 |
|
| 66 |
public function getCurrency(): string |
| 67 |
{ |
| 68 |
return $this->payment->currency; |
| 69 |
} |
| 70 |
|
| 71 |
public function getSquareReceiptUrl(): ?string |
| 72 |
{ |
| 73 |
return $this->payment->squareReceiptUrl; |
| 74 |
} |
| 75 |
|
| 76 |
public function getStatus(): string |
| 77 |
{ |
| 78 |
return $this->payment->status; |
| 79 |
} |
| 80 |
|
| 81 |
public function setStatus(string $status): void |
| 82 |
{ |
| 83 |
$this->payment->status = $status; |
| 84 |
} |
| 85 |
|
| 86 |
public function getProviderMeta(): ?string |
| 87 |
{ |
| 88 |
return $this->payment->providerMeta; |
| 89 |
} |
| 90 |
|
| 91 |
public function setProviderMeta(?string $providerMeta): void |
| 92 |
{ |
| 93 |
$this->payment = $this->payment->withProviderMeta($providerMeta); |
| 94 |
} |
| 95 |
|
| 96 |
public function setEntryId(?int $entryId): void |
| 97 |
{ |
| 98 |
$this->payment->entryId = $entryId !== null && $entryId > 0 ? $entryId : null; |
| 99 |
} |
| 100 |
|
| 101 |
public function setSquareReceiptUrl(?string $receiptUrl): void |
| 102 |
{ |
| 103 |
$this->payment->squareReceiptUrl = $receiptUrl !== null && $receiptUrl !== '' |
| 104 |
? $receiptUrl |
| 105 |
: null; |
| 106 |
} |
| 107 |
|
| 108 |
public function getDateCreated(): ?string |
| 109 |
{ |
| 110 |
return $this->payment->dateCreated; |
| 111 |
} |
| 112 |
|
| 113 |
public function setDateCreated(string $dateCreated): void |
| 114 |
{ |
| 115 |
$this->payment->dateCreated = $dateCreated; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* @return mixed[] |
| 120 |
*/ |
| 121 |
public function toArray(): array |
| 122 |
{ |
| 123 |
return $this->payment->toArray(); |
| 124 |
} |
| 125 |
} |
| 126 |
|