Payment.php
505 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @copyright © TMS-Plugins. All rights reserved. |
| 4 | * @licence See LICENCE.md for license details. |
| 5 | */ |
| 6 | |
| 7 | namespace AmeliaBooking\Domain\Entity\Payment; |
| 8 | |
| 9 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 10 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; |
| 13 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 15 | use AmeliaBooking\Domain\ValueObjects\String\PaymentStatus; |
| 16 | use AmeliaBooking\Domain\ValueObjects\String\PaymentData; |
| 17 | use AmeliaBooking\Domain\ValueObjects\String\Url; |
| 18 | |
| 19 | /** |
| 20 | * Class Payment |
| 21 | * |
| 22 | * @package AmeliaBooking\Domain\Entity\Payment |
| 23 | */ |
| 24 | class Payment |
| 25 | { |
| 26 | /** @var Id */ |
| 27 | private $id; |
| 28 | |
| 29 | /** @var Id */ |
| 30 | private $customerBookingId; |
| 31 | |
| 32 | /** @var Id */ |
| 33 | private $packageCustomerId; |
| 34 | |
| 35 | /** @var Id */ |
| 36 | private $parentId; |
| 37 | |
| 38 | /** @var Id */ |
| 39 | private $invoiceNumber; |
| 40 | |
| 41 | /** @var Price */ |
| 42 | private $amount; |
| 43 | |
| 44 | /** @var DateTimeValue */ |
| 45 | private $dateTime; |
| 46 | |
| 47 | /** @var PaymentStatus */ |
| 48 | private $status; |
| 49 | |
| 50 | /** @var PaymentGateway */ |
| 51 | private $gateway; |
| 52 | |
| 53 | /** @var Name */ |
| 54 | private $gatewayTitle; |
| 55 | |
| 56 | /** @var PaymentData */ |
| 57 | private $data; |
| 58 | |
| 59 | /** @var DateTimeValue */ |
| 60 | private $created; |
| 61 | |
| 62 | /** @var Name */ |
| 63 | private $entity; |
| 64 | |
| 65 | /** @var BooleanValueObject */ |
| 66 | private $actionsCompleted; |
| 67 | |
| 68 | /** @var BooleanValueObject */ |
| 69 | private $triggeredActions; |
| 70 | |
| 71 | /** @var Id */ |
| 72 | private $wcOrderId; |
| 73 | |
| 74 | /** @var Id */ |
| 75 | private $wcOrderItemId; |
| 76 | |
| 77 | /** @var Url */ |
| 78 | private $wcOrderUrl; |
| 79 | |
| 80 | /** @var Price */ |
| 81 | private $wcItemCouponValue; |
| 82 | |
| 83 | /** @var Price */ |
| 84 | private $wcItemTaxValue; |
| 85 | |
| 86 | /** @var string */ |
| 87 | private $transactionId; |
| 88 | |
| 89 | /** @var Json */ |
| 90 | private $transfers; |
| 91 | |
| 92 | /** |
| 93 | * Payment constructor. |
| 94 | * |
| 95 | * @param Price $amount |
| 96 | * @param DateTimeValue $dateTime |
| 97 | * @param PaymentStatus $status |
| 98 | * @param PaymentGateway $gateway |
| 99 | * @param PaymentData $data |
| 100 | */ |
| 101 | public function __construct( |
| 102 | Price $amount, |
| 103 | DateTimeValue $dateTime, |
| 104 | PaymentStatus $status, |
| 105 | PaymentGateway $gateway, |
| 106 | PaymentData $data |
| 107 | ) { |
| 108 | $this->amount = $amount; |
| 109 | |
| 110 | $this->dateTime = $dateTime; |
| 111 | |
| 112 | $this->status = $status; |
| 113 | |
| 114 | $this->gateway = $gateway; |
| 115 | |
| 116 | $this->data = $data; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * @return Id |
| 121 | */ |
| 122 | public function getId() |
| 123 | { |
| 124 | return $this->id; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * @param Id $id |
| 129 | */ |
| 130 | public function setId($id) |
| 131 | { |
| 132 | $this->id = $id; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * @return Id |
| 137 | */ |
| 138 | public function getCustomerBookingId() |
| 139 | { |
| 140 | return $this->customerBookingId; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * @param Id $customerBookingId |
| 145 | */ |
| 146 | public function setCustomerBookingId($customerBookingId) |
| 147 | { |
| 148 | $this->customerBookingId = $customerBookingId; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @return Id |
| 153 | */ |
| 154 | public function getPackageCustomerId() |
| 155 | { |
| 156 | return $this->packageCustomerId; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * @param Id $packageCustomerId |
| 161 | */ |
| 162 | public function setPackageCustomerId($packageCustomerId) |
| 163 | { |
| 164 | $this->packageCustomerId = $packageCustomerId; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * @return Id |
| 169 | */ |
| 170 | public function getParentId() |
| 171 | { |
| 172 | return $this->parentId; |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * @param Id $parentId |
| 177 | */ |
| 178 | public function setParentId($parentId) |
| 179 | { |
| 180 | $this->parentId = $parentId; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * @return Id |
| 185 | */ |
| 186 | public function getInvoiceNumber() |
| 187 | { |
| 188 | return $this->invoiceNumber; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * @param Id $invoiceNumber |
| 193 | */ |
| 194 | public function setInvoiceNumber($invoiceNumber) |
| 195 | { |
| 196 | $this->invoiceNumber = $invoiceNumber; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * @return Price |
| 202 | */ |
| 203 | public function getAmount() |
| 204 | { |
| 205 | return $this->amount; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * @param Price $amount |
| 210 | */ |
| 211 | public function setAmount($amount) |
| 212 | { |
| 213 | $this->amount = $amount; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * @return DateTimeValue |
| 218 | */ |
| 219 | public function getDateTime() |
| 220 | { |
| 221 | return $this->dateTime; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * @param DateTimeValue $dateTime |
| 226 | */ |
| 227 | public function setDateTime($dateTime) |
| 228 | { |
| 229 | $this->dateTime = $dateTime; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * @return PaymentStatus |
| 234 | */ |
| 235 | public function getStatus() |
| 236 | { |
| 237 | return $this->status; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * @param PaymentStatus $status |
| 242 | */ |
| 243 | public function setStatus($status) |
| 244 | { |
| 245 | $this->status = $status; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * @return PaymentGateway |
| 250 | */ |
| 251 | public function getGateway() |
| 252 | { |
| 253 | return $this->gateway; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * @param PaymentGateway $gateway |
| 258 | */ |
| 259 | public function setGateway($gateway) |
| 260 | { |
| 261 | $this->gateway = $gateway; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * @return Name |
| 266 | */ |
| 267 | public function getGatewayTitle() |
| 268 | { |
| 269 | return $this->gatewayTitle; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * @param Name $gatewayTitle |
| 274 | */ |
| 275 | public function setGatewayTitle($gatewayTitle) |
| 276 | { |
| 277 | $this->gatewayTitle = $gatewayTitle; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @return PaymentData |
| 282 | */ |
| 283 | public function getData() |
| 284 | { |
| 285 | return $this->data; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * @param PaymentData $data |
| 290 | */ |
| 291 | public function setData($data) |
| 292 | { |
| 293 | $this->data = $data; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * @return DateTimeValue |
| 298 | */ |
| 299 | public function getCreated() |
| 300 | { |
| 301 | return $this->created; |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * @param DateTimeValue $created |
| 306 | */ |
| 307 | public function setCreated($created) |
| 308 | { |
| 309 | $this->created = $created; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * @return Name |
| 314 | */ |
| 315 | public function getEntity() |
| 316 | { |
| 317 | return $this->entity; |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * @param Name $entity |
| 322 | */ |
| 323 | public function setEntity($entity) |
| 324 | { |
| 325 | $this->entity = $entity; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * @return BooleanValueObject |
| 330 | */ |
| 331 | public function getActionsCompleted() |
| 332 | { |
| 333 | return $this->actionsCompleted; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * @param BooleanValueObject $actionsCompleted |
| 338 | */ |
| 339 | public function setActionsCompleted($actionsCompleted) |
| 340 | { |
| 341 | $this->actionsCompleted = $actionsCompleted; |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * @return BooleanValueObject |
| 346 | */ |
| 347 | public function getTriggeredActions() |
| 348 | { |
| 349 | return $this->triggeredActions; |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * @param BooleanValueObject $triggeredActions |
| 354 | */ |
| 355 | public function setTriggeredActions($triggeredActions) |
| 356 | { |
| 357 | $this->triggeredActions = $triggeredActions; |
| 358 | } |
| 359 | |
| 360 | /** |
| 361 | * @return Id |
| 362 | */ |
| 363 | public function getWcOrderId() |
| 364 | { |
| 365 | return $this->wcOrderId; |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * @param Id $wcOrderId |
| 370 | */ |
| 371 | public function setWcOrderId($wcOrderId) |
| 372 | { |
| 373 | $this->wcOrderId = $wcOrderId; |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * @return Id |
| 378 | */ |
| 379 | public function getWcOrderItemId() |
| 380 | { |
| 381 | return $this->wcOrderItemId; |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * @param Id $wcOrderItemId |
| 386 | */ |
| 387 | public function setWcOrderItemId($wcOrderItemId) |
| 388 | { |
| 389 | $this->wcOrderItemId = $wcOrderItemId; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * @return Url |
| 394 | */ |
| 395 | public function getWcOrderUrl() |
| 396 | { |
| 397 | return $this->wcOrderUrl; |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * @param Url $wcOrderUrl |
| 402 | */ |
| 403 | public function setWcOrderUrl($wcOrderUrl) |
| 404 | { |
| 405 | $this->wcOrderUrl = $wcOrderUrl; |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * @return Price |
| 410 | */ |
| 411 | public function getWcItemCouponValue() |
| 412 | { |
| 413 | return $this->wcItemCouponValue; |
| 414 | } |
| 415 | |
| 416 | /** |
| 417 | * @param Price $wcItemCouponValue |
| 418 | */ |
| 419 | public function setWcItemCouponValue($wcItemCouponValue) |
| 420 | { |
| 421 | $this->wcItemCouponValue = $wcItemCouponValue; |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * @return Price |
| 426 | */ |
| 427 | public function getWcItemTaxValue() |
| 428 | { |
| 429 | return $this->wcItemTaxValue; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * @param Price $wcItemTaxValue |
| 434 | */ |
| 435 | public function setWcItemTaxValue($wcItemTaxValue) |
| 436 | { |
| 437 | $this->wcItemTaxValue = $wcItemTaxValue; |
| 438 | } |
| 439 | |
| 440 | |
| 441 | /** |
| 442 | * @return string|null |
| 443 | */ |
| 444 | public function getTransactionId() |
| 445 | { |
| 446 | return $this->transactionId; |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * @param string|null $transactionId |
| 451 | */ |
| 452 | public function setTransactionId($transactionId) |
| 453 | { |
| 454 | $this->transactionId = $transactionId; |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * @return Json |
| 459 | */ |
| 460 | public function getTransfers() |
| 461 | { |
| 462 | return $this->transfers; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * @param Json $transfers |
| 467 | */ |
| 468 | public function setTransfers($transfers) |
| 469 | { |
| 470 | $this->transfers = $transfers; |
| 471 | } |
| 472 | |
| 473 | |
| 474 | /** |
| 475 | * @return array |
| 476 | */ |
| 477 | public function toArray() |
| 478 | { |
| 479 | return [ |
| 480 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 481 | 'customerBookingId' => $this->customerBookingId ? $this->customerBookingId->getValue() : null, |
| 482 | 'packageCustomerId' => $this->packageCustomerId ? $this->packageCustomerId->getValue() : null, |
| 483 | 'parentId' => $this->getParentId() ? $this->getParentId()->getValue() : null, |
| 484 | 'amount' => $this->amount->getValue(), |
| 485 | 'gateway' => $this->gateway->getName()->getValue(), |
| 486 | 'gatewayTitle' => null !== $this->getGatewayTitle() ? $this->getGatewayTitle()->getValue() : '', |
| 487 | 'dateTime' => null !== $this->dateTime ? $this->dateTime->getValue()->format('Y-m-d H:i:s') : null, |
| 488 | 'status' => $this->status->getValue(), |
| 489 | 'data' => $this->data->getValue(), |
| 490 | 'entity' => $this->getEntity() ? $this->getEntity()->getValue() : null, |
| 491 | 'created' => $this->getCreated() ? $this->getCreated()->getValue()->format('Y-m-d H:i:s') : null, |
| 492 | 'actionsCompleted' => $this->getActionsCompleted() ? $this->getActionsCompleted()->getValue() : null, |
| 493 | 'triggeredActions' => $this->getTriggeredActions() ? $this->getTriggeredActions()->getValue() : null, |
| 494 | 'wcOrderId' => $this->getWcOrderId() ? $this->getWcOrderId()->getValue() : null, |
| 495 | 'wcOrderItemId' => $this->getWcOrderItemId() ? $this->getWcOrderItemId()->getValue() : null, |
| 496 | 'wcOrderUrl' => $this->getWcOrderUrl() ? $this->getWcOrderUrl()->getValue() : null, |
| 497 | 'wcItemCouponValue' => $this->getWcItemCouponValue() ? $this->getWcItemCouponValue()->getValue() : null, |
| 498 | 'wcItemTaxValue' => $this->getWcItemTaxValue() ? $this->getWcItemTaxValue()->getValue() : null, |
| 499 | 'transactionId' => $this->getTransactionId(), |
| 500 | 'transfers' => $this->getTransfers() ? $this->getTransfers()->getValue() : null, |
| 501 | 'invoiceNumber' => $this->getInvoiceNumber() ? $this->getInvoiceNumber()->getValue() : null, |
| 502 | ]; |
| 503 | } |
| 504 | } |
| 505 |