PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / ValueObjects / Payment / Payment.php

Payment.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/ValueObjects/Payment/Payment.php

126 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\ValueObjects\Payment;
4
5 /**
6 * Immutable payment record value object.
7 */
8 final class Payment
9 {
10 public int $id;
11 public ?int $entryId;
12 public int $formId;
13 public string $transactionId;
14 public string $paymentMethod;
15 public ?string $customerName;
16 public int $amount;
17 public string $currency;
18 public ?string $squareReceiptUrl;
19 public ?string $dateCreated;
20 public string $status;
21 public ?string $providerMeta;
22
23 /**
24 * @param int $id
25 * @param int|null $entryId
26 * @param int $formId
27 * @param string $transactionId
28 * @param string $paymentMethod
29 * @param string|null $customerName
30 * @param int $amount
31 * @param string $currency
32 * @param string|null $squareReceiptUrl
33 * @param string|null $dateCreated
34 * @param string|null $providerMeta
35 *
36 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
37 */
38 public function __construct(
39 int $id,
40 ?int $entryId,
41 int $formId,
42 string $transactionId,
43 string $paymentMethod,
44 ?string $customerName,
45 int $amount,
46 string $currency,
47 ?string $squareReceiptUrl = null,
48 ?string $dateCreated = null,
49 ?string $providerMeta = null
50 ) {
51 $this->id = $id;
52 $this->entryId = $entryId;
53 $this->formId = $formId;
54 $this->transactionId = $transactionId;
55 $this->paymentMethod = $paymentMethod;
56 $this->customerName = $customerName;
57 $this->amount = $amount;
58 $this->currency = $currency;
59 $this->squareReceiptUrl = $squareReceiptUrl;
60 $this->dateCreated = $dateCreated;
61 $this->status = 'succeeded';
62 $this->providerMeta = $providerMeta;
63 }
64
65 public function withCustomerName(?string $customerName): self
66 {
67 $copy = new self(
68 $this->id,
69 $this->entryId,
70 $this->formId,
71 $this->transactionId,
72 $this->paymentMethod,
73 $customerName,
74 $this->amount,
75 $this->currency,
76 $this->squareReceiptUrl,
77 $this->dateCreated,
78 $this->providerMeta
79 );
80 $copy->status = $this->status;
81
82 return $copy;
83 }
84
85 public function withProviderMeta(?string $providerMeta): self
86 {
87 $copy = new self(
88 $this->id,
89 $this->entryId,
90 $this->formId,
91 $this->transactionId,
92 $this->paymentMethod,
93 $this->customerName,
94 $this->amount,
95 $this->currency,
96 $this->squareReceiptUrl,
97 $this->dateCreated,
98 $providerMeta
99 );
100 $copy->status = $this->status;
101
102 return $copy;
103 }
104
105 /**
106 * @return mixed[]
107 */
108 public function toArray(): array
109 {
110 return [
111 'id' => $this->id,
112 'entryId' => $this->entryId,
113 'formId' => $this->formId,
114 'transactionId' => $this->transactionId,
115 'paymentMethod' => $this->paymentMethod,
116 'customerName' => $this->customerName,
117 'amount' => $this->amount,
118 'currency' => $this->currency,
119 'squareReceiptUrl' => $this->squareReceiptUrl,
120 'dateCreated' => $this->dateCreated,
121 'status' => $this->status,
122 'providerMeta' => $this->providerMeta,
123 ];
124 }
125 }
126