|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LauLamanApps\eCurring\Resource; |
|
6
|
|
|
|
|
7
|
|
|
use DateTimeImmutable; |
|
8
|
|
|
use LauLamanApps\eCurring\Resource\Product\AuthenticationMethod; |
|
9
|
|
|
use LauLamanApps\eCurring\Resource\Product\Status; |
|
10
|
|
|
|
|
11
|
|
|
final class Product implements ProductInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var int |
|
15
|
|
|
*/ |
|
16
|
|
|
private $id; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
* |
|
21
|
|
|
* The administrative name of the subscription plan |
|
22
|
|
|
*/ |
|
23
|
|
|
private $name; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
* |
|
28
|
|
|
* The description of the subscription plan as shown to your customers |
|
29
|
|
|
*/ |
|
30
|
|
|
private $description; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var DateTimeImmutable |
|
34
|
|
|
* |
|
35
|
|
|
* The start date of the subscription plan. |
|
36
|
|
|
* If this date is in the future, no transactions will be scheduled until this date is reached. |
|
37
|
|
|
* You can, however, already add subscriptions to the plan before it starts. |
|
38
|
|
|
*/ |
|
39
|
|
|
private $startDate; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var Status |
|
43
|
|
|
* |
|
44
|
|
|
* The current status of the subscription plan. |
|
45
|
|
|
*/ |
|
46
|
|
|
private $status; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var AuthenticationMethod |
|
50
|
|
|
* |
|
51
|
|
|
* The method used for authenticating the mandate of new subscribers. |
|
52
|
|
|
* NOTE: the ideal method has been deprecated and replaced by the online_payment method. |
|
53
|
|
|
*/ |
|
54
|
|
|
private $mandateAuthenticationMethod; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var boolean |
|
58
|
|
|
* |
|
59
|
|
|
* Whether the invoices for the transactions should be sent to the customers by email. |
|
60
|
|
|
* Invoices are sent 2 days before the expected collection date. |
|
61
|
|
|
*/ |
|
62
|
|
|
private $sendInvoice; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var int |
|
66
|
|
|
* |
|
67
|
|
|
* The amount of times a transaction should be retried after a chargeback. |
|
68
|
|
|
* For example, a $stornoRetries count of 2 could result in a total of 3 collection attempts. |
|
69
|
|
|
*/ |
|
70
|
|
|
private $stornoRetries; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var string|null |
|
74
|
|
|
* |
|
75
|
|
|
* The URL to the terms of service attached to the subscription plan |
|
76
|
|
|
*/ |
|
77
|
|
|
private $terms; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var Subscription |
|
81
|
|
|
* |
|
82
|
|
|
* The subscriptions attached to the plan |
|
83
|
|
|
*/ |
|
84
|
|
|
private $subscriptions; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @var DateTimeImmutable |
|
88
|
|
|
* |
|
89
|
|
|
* The date on which the subscription plan was created |
|
90
|
|
|
*/ |
|
91
|
|
|
private $createdAt; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @var DateTimeImmutable |
|
95
|
|
|
* |
|
96
|
|
|
* The date on which the subscription plan was last updated |
|
97
|
|
|
*/ |
|
98
|
|
|
private $updatedAt; |
|
99
|
|
|
|
|
100
|
2 |
|
public function __construct( |
|
101
|
|
|
int $id, |
|
102
|
|
|
string $name, |
|
103
|
|
|
string $description, |
|
104
|
|
|
DateTimeImmutable $startDate, |
|
105
|
|
|
Status $status, |
|
106
|
|
|
AuthenticationMethod $mandateAuthenticationMethod, |
|
107
|
|
|
bool $sendInvoice, |
|
108
|
|
|
int $stornoRetries, |
|
109
|
|
|
DateTimeImmutable $createdAt, |
|
110
|
|
|
DateTimeImmutable $updatedAt, |
|
111
|
|
|
?string $terms, |
|
112
|
|
|
?SubscriptionInterface ...$subscriptions |
|
113
|
|
|
) { |
|
114
|
2 |
|
$this->id = $id; |
|
115
|
2 |
|
$this->name = $name; |
|
116
|
2 |
|
$this->description = $description; |
|
117
|
2 |
|
$this->startDate = $startDate; |
|
118
|
2 |
|
$this->status = $status; |
|
119
|
2 |
|
$this->mandateAuthenticationMethod = $mandateAuthenticationMethod; |
|
120
|
2 |
|
$this->sendInvoice = $sendInvoice; |
|
121
|
2 |
|
$this->stornoRetries = $stornoRetries; |
|
122
|
2 |
|
$this->subscriptions = $subscriptions; |
|
|
|
|
|
|
123
|
2 |
|
$this->createdAt = $createdAt; |
|
124
|
2 |
|
$this->updatedAt = $updatedAt; |
|
125
|
2 |
|
$this->terms = $terms; |
|
126
|
2 |
|
} |
|
127
|
|
|
|
|
128
|
2 |
|
public function getId(): int |
|
129
|
|
|
{ |
|
130
|
2 |
|
return $this->id; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
2 |
|
public function getName(): string |
|
134
|
|
|
{ |
|
135
|
2 |
|
return $this->name; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
2 |
|
public function getDescription(): string |
|
139
|
|
|
{ |
|
140
|
2 |
|
return $this->description; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
2 |
|
public function getStartDate(): DateTimeImmutable |
|
144
|
|
|
{ |
|
145
|
2 |
|
return $this->startDate; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
2 |
|
public function getStatus(): Status |
|
149
|
|
|
{ |
|
150
|
2 |
|
return $this->status; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
2 |
|
public function getMandateAuthenticationMethod(): AuthenticationMethod |
|
154
|
|
|
{ |
|
155
|
2 |
|
return $this->mandateAuthenticationMethod; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
2 |
|
public function isSendInvoice(): bool |
|
159
|
|
|
{ |
|
160
|
2 |
|
return $this->sendInvoice; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
2 |
|
public function getStornoRetries(): int |
|
164
|
|
|
{ |
|
165
|
2 |
|
return $this->stornoRetries; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
public function getTerms(): ?string |
|
169
|
|
|
{ |
|
170
|
|
|
return $this->terms; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return SubscriptionInterface[]| |
|
175
|
|
|
*/ |
|
176
|
2 |
|
public function getSubscriptions(): array |
|
177
|
|
|
{ |
|
178
|
2 |
|
return $this->subscriptions; |
|
|
|
|
|
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
2 |
|
public function getCreatedAt(): DateTimeImmutable |
|
182
|
|
|
{ |
|
183
|
2 |
|
return $this->createdAt; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
2 |
|
public function getUpdatedAt(): DateTimeImmutable |
|
187
|
|
|
{ |
|
188
|
2 |
|
return $this->updatedAt; |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..