|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\DonationContext\UseCases\HandlePayPalPaymentNotification; |
|
6
|
|
|
|
|
7
|
|
|
use WMDE\Euro\Euro; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @license GNU GPL v2+ |
|
11
|
|
|
* @author Kai Nissen < [email protected] > |
|
12
|
|
|
*/ |
|
13
|
|
|
class PayPalNotificationRequest { |
|
14
|
|
|
|
|
15
|
|
|
private $transactionType; |
|
16
|
|
|
private $transactionId; |
|
17
|
|
|
|
|
18
|
|
|
private $payerId; |
|
19
|
|
|
private $payerEmail; |
|
20
|
|
|
private $payerStatus; |
|
21
|
|
|
private $subscriberId; |
|
22
|
|
|
|
|
23
|
|
|
private $payerFirstName; |
|
24
|
|
|
private $payerLastName; |
|
25
|
|
|
private $payerAddressName; |
|
26
|
|
|
private $payerAddressStreet; |
|
27
|
|
|
private $payerAddressPostalCode; |
|
28
|
|
|
private $payerAddressCity; |
|
29
|
|
|
private $payerAddressCountryCode; |
|
30
|
|
|
private $payerAddressStatus; |
|
31
|
|
|
|
|
32
|
|
|
private $donationId; |
|
33
|
|
|
private $token; |
|
34
|
|
|
|
|
35
|
|
|
private $currencyCode; |
|
36
|
|
|
private $transactionFee; |
|
37
|
|
|
private $amountGross; |
|
38
|
|
|
private $settleAmount; |
|
39
|
|
|
private $paymentTimestamp; |
|
40
|
|
|
private $paymentStatus; |
|
41
|
|
|
private $paymentType; |
|
42
|
|
|
|
|
43
|
|
|
public function getTransactionType(): string { |
|
44
|
|
|
return $this->transactionType; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function setTransactionType( string $transactionType ): self { |
|
48
|
|
|
$this->transactionType = $transactionType; |
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function getTransactionId(): string { |
|
53
|
|
|
return $this->transactionId; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setTransactionId( string $transactionId ): self { |
|
57
|
|
|
$this->transactionId = $transactionId; |
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getPayerId(): string { |
|
62
|
|
|
return $this->payerId; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function setPayerId( string $payerId ): self { |
|
66
|
|
|
$this->payerId = $payerId; |
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getSubscriberId(): string { |
|
71
|
|
|
return $this->subscriberId; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function setSubscriberId( string $subscriberId ) { |
|
75
|
|
|
$this->subscriberId = $subscriberId; |
|
76
|
|
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getPayerEmail(): string { |
|
80
|
|
|
return $this->payerEmail; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function setPayerEmail( string $payerEmail ): self { |
|
84
|
|
|
$this->payerEmail = $payerEmail; |
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getPayerStatus(): string { |
|
89
|
|
|
return $this->payerStatus; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function setPayerStatus( string $payerStatus ): self { |
|
93
|
|
|
$this->payerStatus = $payerStatus; |
|
94
|
|
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getPayerFirstName(): string { |
|
98
|
|
|
return $this->payerFirstName; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function setPayerFirstName( string $payerFirstName ): self { |
|
102
|
|
|
$this->payerFirstName = $payerFirstName; |
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getPayerLastName(): string { |
|
107
|
|
|
return $this->payerLastName; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function setPayerLastName( string $payerLastName ): self { |
|
111
|
|
|
$this->payerLastName = $payerLastName; |
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function getPayerAddressName(): string { |
|
116
|
|
|
return $this->payerAddressName; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function setPayerAddressName( string $payerAddressName ): self { |
|
120
|
|
|
$this->payerAddressName = $payerAddressName; |
|
121
|
|
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getPayerAddressStreet(): string { |
|
125
|
|
|
return $this->payerAddressStreet; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function setPayerAddressStreet( string $payerAddressStreet ): self { |
|
129
|
|
|
$this->payerAddressStreet = $payerAddressStreet; |
|
130
|
|
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function getPayerAddressPostalCode(): string { |
|
134
|
|
|
return $this->payerAddressPostalCode; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setPayerAddressPostalCode( string $payerAddressPostalCode ): self { |
|
138
|
|
|
$this->payerAddressPostalCode = $payerAddressPostalCode; |
|
139
|
|
|
return $this; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function getPayerAddressCity(): string { |
|
143
|
|
|
return $this->payerAddressCity; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function setPayerAddressCity( string $payerAddressCity ): self { |
|
147
|
|
|
$this->payerAddressCity = $payerAddressCity; |
|
148
|
|
|
return $this; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
public function getPayerAddressCountryCode(): string { |
|
152
|
|
|
return $this->payerAddressCountryCode; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function setPayerAddressCountryCode( string $payerAddressCountryCode ): self { |
|
156
|
|
|
$this->payerAddressCountryCode = $payerAddressCountryCode; |
|
157
|
|
|
return $this; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function getPayerAddressStatus(): string { |
|
161
|
|
|
return $this->payerAddressStatus; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function setPayerAddressStatus( string $payerAddressStatus ): self { |
|
165
|
|
|
$this->payerAddressStatus = $payerAddressStatus; |
|
166
|
|
|
return $this; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function getDonationId(): int { |
|
170
|
|
|
return $this->donationId; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
public function setDonationId( int $donationId ): self { |
|
174
|
|
|
$this->donationId = $donationId; |
|
175
|
|
|
return $this; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function getToken(): string { |
|
179
|
|
|
return $this->token; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function setToken( string $token ): self { |
|
183
|
|
|
$this->token = $token; |
|
184
|
|
|
return $this; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function getCurrencyCode(): string { |
|
188
|
|
|
return $this->currencyCode; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
public function setCurrencyCode( string $currencyCode ): self { |
|
192
|
|
|
$this->currencyCode = $currencyCode; |
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function getTransactionFee(): Euro { |
|
197
|
|
|
return $this->transactionFee; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
public function setTransactionFee( Euro $transactionFee ): self { |
|
201
|
|
|
$this->transactionFee = $transactionFee; |
|
202
|
|
|
return $this; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
public function getAmountGross(): Euro { |
|
206
|
|
|
return $this->amountGross; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
public function setAmountGross( Euro $amountGross ): self { |
|
210
|
|
|
$this->amountGross = $amountGross; |
|
211
|
|
|
return $this; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
public function getPaymentTimestamp(): string { |
|
215
|
|
|
return $this->paymentTimestamp; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function setPaymentTimestamp( string $paymentTimestamp ): self { |
|
219
|
|
|
$this->paymentTimestamp = $paymentTimestamp; |
|
220
|
|
|
return $this; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public function getPaymentStatus(): string { |
|
224
|
|
|
return $this->paymentStatus; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
public function setPaymentStatus( string $paymentStatus ): self { |
|
228
|
|
|
$this->paymentStatus = $paymentStatus; |
|
229
|
|
|
return $this; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
public function getPaymentType(): string { |
|
233
|
|
|
return $this->paymentType; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
public function setPaymentType( string $paymentType ): self { |
|
237
|
|
|
$this->paymentType = $paymentType; |
|
238
|
|
|
return $this; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
public function getSettleAmount() { |
|
242
|
|
|
return $this->settleAmount; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function setSettleAmount( Euro $settleAmount ) { |
|
246
|
|
|
$this->settleAmount = $settleAmount; |
|
247
|
|
|
return $this; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
public function isSuccessfulPaymentNotification(): bool { |
|
251
|
|
|
return $this->paymentStatus === 'Completed' || $this->paymentStatus === 'Processed'; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
public function isRecurringPaymentCompletion(): bool { |
|
255
|
|
|
return $this->transactionType === 'subscr_payment'; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
public function isForRecurringPayment(): bool { |
|
259
|
|
|
return strpos( $this->transactionType, 'subscr_' ) === 0; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function toArray(): array { |
|
263
|
|
|
return [ |
|
264
|
|
|
'transactionType' => $this->transactionType, |
|
265
|
|
|
'transactionId' => $this->transactionId, |
|
266
|
|
|
|
|
267
|
|
|
'payerId' => $this->payerId, |
|
268
|
|
|
'payerEmail' => $this->payerEmail, |
|
269
|
|
|
'payerStatus' => $this->payerStatus, |
|
270
|
|
|
'subscriberId' => $this->subscriberId, |
|
271
|
|
|
|
|
272
|
|
|
'payerFirstName' => $this->payerFirstName, |
|
273
|
|
|
'payerLastName' => $this->payerLastName, |
|
274
|
|
|
'payerAddressName' => $this->payerAddressName, |
|
275
|
|
|
'payerAddressStreet' => $this->payerAddressStreet, |
|
276
|
|
|
'payerAddressPostalCode' => $this->payerAddressPostalCode, |
|
277
|
|
|
'payerAddressCity' => $this->payerAddressCity, |
|
278
|
|
|
'payerAddressCountryCode' => $this->payerAddressCountryCode, |
|
279
|
|
|
'payerAddressStatus' => $this->payerAddressStatus, |
|
280
|
|
|
|
|
281
|
|
|
'donationId' => $this->donationId, |
|
282
|
|
|
'token' => $this->token, |
|
283
|
|
|
|
|
284
|
|
|
'currencyCode' => $this->currencyCode, |
|
285
|
|
|
'transactionFee' => $this->transactionFee, |
|
286
|
|
|
'amountGross' => $this->amountGross, |
|
287
|
|
|
'settleAmount' => $this->settleAmount, |
|
288
|
|
|
'paymentTimestamp' => $this->paymentTimestamp, |
|
289
|
|
|
'paymentStatus' => $this->paymentStatus, |
|
290
|
|
|
'paymentType' => $this->paymentType |
|
291
|
|
|
]; |
|
292
|
|
|
} |
|
293
|
|
|
} |
|
294
|
|
|
|