1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* PayPal Donation extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2015 Skouat |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace skouat\ppde\entity; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @property \phpbb\db\driver\driver_interface db phpBB Database object |
15
|
|
|
* @property \phpbb\user user phpBB User object |
16
|
|
|
* @property string lang_key_prefix Prefix for the messages thrown by exceptions |
17
|
|
|
* @property string lang_key_suffix Suffix for the messages thrown by exceptions |
18
|
|
|
*/ |
19
|
|
|
class transactions extends main |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Data for this entity |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
* transaction_id |
26
|
|
|
* txn_id |
27
|
|
|
* txn_type |
28
|
|
|
* confirmed |
29
|
|
|
* user_id |
30
|
|
|
* item_name |
31
|
|
|
* item_number |
32
|
|
|
* business |
33
|
|
|
* receiver_id |
34
|
|
|
* receiver_email |
35
|
|
|
* payment_status |
36
|
|
|
* mc_gross |
37
|
|
|
* mc_fee |
38
|
|
|
* mc_currency |
39
|
|
|
* settle_amount |
40
|
|
|
* settle_currency |
41
|
|
|
* net_amount |
42
|
|
|
* exchange_rate |
43
|
|
|
* payment_type |
44
|
|
|
* payment_date |
45
|
|
|
* payer_id |
46
|
|
|
* payer_email |
47
|
|
|
* payer_status |
48
|
|
|
* first_name |
49
|
|
|
* last_name |
50
|
|
|
* @access protected |
51
|
|
|
*/ |
52
|
|
|
protected $data; |
53
|
|
|
protected $extra_data; |
54
|
|
|
protected $transactions_log_table; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Constructor |
58
|
|
|
* |
59
|
|
|
* @param \phpbb\db\driver\driver_interface $db Database object |
60
|
|
|
* @param \phpbb\user $user User object |
61
|
|
|
* @param string $table_name Name of the table used to store data |
62
|
|
|
* |
63
|
|
|
* @access public |
64
|
|
|
*/ |
65
|
|
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $table_name) |
66
|
|
|
{ |
67
|
|
|
$this->db = $db; |
68
|
|
|
$this->user = $user; |
69
|
|
|
$this->transactions_log_table = $table_name; |
70
|
|
|
parent::__construct( |
71
|
|
|
$db, |
72
|
|
|
$user, |
73
|
|
|
'PPDE_DT', |
74
|
|
|
'TRANSACTION', |
75
|
|
|
$table_name, |
76
|
|
|
array( |
77
|
|
|
'item_id' => array('name' => 'transaction_id', 'type' => 'integer'), |
78
|
|
|
'item_receiver_id' => array('name' => 'receiver_id', 'type' => 'string'), |
79
|
|
|
'item_receiver_email' => array('name' => 'receiver_email', 'type' => 'string'), |
80
|
|
|
'item_residence_country' => array('name' => 'residence_country', 'type' => 'string'), |
81
|
|
|
'item_business' => array('name' => 'business', 'type' => 'string'), |
82
|
|
|
'item_confirmed' => array('name' => 'confirmed', 'type' => 'boolean'), |
83
|
|
|
'item_test_ipn' => array('name' => 'test_ipn', 'type' => 'boolean'), |
84
|
|
|
'item_txn_id' => array('name' => 'txn_id', 'type' => 'string'), |
85
|
|
|
'item_txn_type' => array('name' => 'txn_type', 'type' => 'string'), |
86
|
|
|
'item_parent_txn_id' => array('name' => 'parent_txn_id', 'type' => 'string'), |
87
|
|
|
'item_payer_email' => array('name' => 'payer_email', 'type' => 'string'), |
88
|
|
|
'item_payer_id' => array('name' => 'payer_id', 'type' => 'string'), |
89
|
|
|
'item_payer_status' => array('name' => 'payer_status', 'type' => 'string'), |
90
|
|
|
'item_first_name' => array('name' => 'first_name', 'type' => 'string'), |
91
|
|
|
'item_last_name' => array('name' => 'last_name', 'type' => 'string'), |
92
|
|
|
'item_user_id' => array('name' => 'user_id', 'type' => 'integer'), |
93
|
|
|
'item_custom' => array('name' => 'custom', 'type' => 'string'), |
94
|
|
|
'item_item_name' => array('name' => 'item_name', 'type' => 'string'), |
95
|
|
|
'item_item_number' => array('name' => 'item_number', 'type' => 'string'), |
96
|
|
|
'item_mc_currency' => array('name' => 'mc_currency', 'type' => 'string'), |
97
|
|
|
'item_mc_fee' => array('name' => 'mc_fee', 'type' => 'float'), |
98
|
|
|
'item_mc_gross' => array('name' => 'mc_gross', 'type' => 'float'), |
99
|
|
|
'item_net_amount' => array('name' => 'net_amount', 'type' => 'float'), |
100
|
|
|
'item_payment_date' => array('name' => 'payment_date', 'type' => 'integer'), |
101
|
|
|
'item_payment_status' => array('name' => 'payment_status', 'type' => 'string'), |
102
|
|
|
'item_payment_type' => array('name' => 'payment_type', 'type' => 'string'), |
103
|
|
|
'item_settle_amount' => array('name' => 'settle_amount', 'type' => 'float'), |
104
|
|
|
'item_settle_currency' => array('name' => 'settle_currency', 'type' => 'string'), |
105
|
|
|
'item_exchange_rate' => array('name' => 'exchange_rate', 'type' => 'string'), |
106
|
|
|
) |
107
|
|
|
); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Checks if the txn_id exists for this transaction |
112
|
|
|
* |
113
|
|
|
* @return int $this->data['transaction_id'] Transaction identifier; 0 if the transaction doesn't exist |
114
|
|
|
* @access public |
115
|
|
|
*/ |
116
|
|
|
public function transaction_exists() |
117
|
|
|
{ |
118
|
|
|
$sql = 'SELECT transaction_id |
119
|
|
|
FROM ' . $this->transactions_log_table . " |
120
|
|
|
WHERE txn_id = '" . $this->db->sql_escape($this->data['txn_id']) . "'"; |
121
|
|
|
$this->db->sql_query($sql); |
122
|
|
|
|
123
|
|
|
return $this->db->sql_fetchfield('transaction_id'); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get PayPal transaction id |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
* @access public |
131
|
|
|
*/ |
132
|
|
|
public function get_txn_id() |
133
|
|
|
{ |
134
|
|
|
return (isset($this->data['txn_id'])) ? (string) $this->data['txn_id'] : ''; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Get PayPal receiver ID |
139
|
|
|
* |
140
|
|
|
* @return string |
141
|
|
|
* @access public |
142
|
|
|
*/ |
143
|
|
|
public function get_receiver_id() |
144
|
|
|
{ |
145
|
|
|
return (isset($this->data['receiver_id'])) ? (string) $this->data['receiver_id'] : ''; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Get PayPal receiver e-mail |
150
|
|
|
* |
151
|
|
|
* @return string |
152
|
|
|
* @access public |
153
|
|
|
*/ |
154
|
|
|
public function get_receiver_email() |
155
|
|
|
{ |
156
|
|
|
return (isset($this->data['receiver_email'])) ? (string) $this->data['receiver_email'] : ''; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get PayPal receiver ID |
161
|
|
|
* |
162
|
|
|
* @return string |
163
|
|
|
* @access public |
164
|
|
|
*/ |
165
|
|
|
public function get_residence_country() |
166
|
|
|
{ |
167
|
|
|
return (isset($this->data['residence_country'])) ? (string) $this->data['residence_country'] : ''; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Get PayPal business (same as receiver ID or receiver_email) |
172
|
|
|
* |
173
|
|
|
* @return string |
174
|
|
|
* @access public |
175
|
|
|
*/ |
176
|
|
|
public function get_business() |
177
|
|
|
{ |
178
|
|
|
return (isset($this->data['business'])) ? (string) $this->data['business'] : ''; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get PayPal transaction status |
183
|
|
|
* |
184
|
|
|
* @return bool |
185
|
|
|
* @access public |
186
|
|
|
*/ |
187
|
|
|
public function get_confirmed() |
188
|
|
|
{ |
189
|
|
|
return (isset($this->data['confirmed'])) ? (bool) $this->data['confirmed'] : false; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Get Test IPN status |
194
|
|
|
* |
195
|
|
|
* @return bool |
196
|
|
|
* @access public |
197
|
|
|
*/ |
198
|
|
|
public function get_test_ipn() |
199
|
|
|
{ |
200
|
|
|
return (isset($this->data['test_ipn'])) ? (bool) $this->data['test_ipn'] : false; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Get PayPal transaction type |
205
|
|
|
* |
206
|
|
|
* @return string |
207
|
|
|
* @access public |
208
|
|
|
*/ |
209
|
|
|
public function get_txn_type() |
210
|
|
|
{ |
211
|
|
|
return (isset($this->data['txn_type'])) ? (string) $this->data['txn_type'] : ''; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Get PayPal parent transaction ID (in case of refund) |
216
|
|
|
* |
217
|
|
|
* @return string |
218
|
|
|
* @access public |
219
|
|
|
*/ |
220
|
|
|
public function get_parent_txn_id() |
221
|
|
|
{ |
222
|
|
|
return (isset($this->data['parent_txn_id'])) ? (string) $this->data['parent_txn_id'] : ''; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Get PayPal payer e-mail |
227
|
|
|
* |
228
|
|
|
* @return string |
229
|
|
|
* @access public |
230
|
|
|
*/ |
231
|
|
|
public function get_payer_email() |
232
|
|
|
{ |
233
|
|
|
return (isset($this->data['payer_email'])) ? (string) $this->data['payer_email'] : ''; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Get PayPal payer account ID |
238
|
|
|
* |
239
|
|
|
* @return string |
240
|
|
|
* @access public |
241
|
|
|
*/ |
242
|
|
|
public function get_payer_id() |
243
|
|
|
{ |
244
|
|
|
return (isset($this->data['payer_id'])) ? (string) $this->data['payer_id'] : ''; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Get PayPal payer Status (such as unverified/verified) |
249
|
|
|
* |
250
|
|
|
* @return string |
251
|
|
|
* @access public |
252
|
|
|
*/ |
253
|
|
|
public function get_payer_status() |
254
|
|
|
{ |
255
|
|
|
return (isset($this->data['payer_status'])) ? (string) $this->data['payer_status'] : ''; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Get PayPal payer first name |
260
|
|
|
* |
261
|
|
|
* @return string |
262
|
|
|
* @access public |
263
|
|
|
*/ |
264
|
|
|
public function get_first_name() |
265
|
|
|
{ |
266
|
|
|
return (isset($this->data['first_name'])) ? (string) $this->data['first_name'] : ''; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Get PayPal payer last name |
271
|
|
|
* |
272
|
|
|
* @return string |
273
|
|
|
* @access public |
274
|
|
|
*/ |
275
|
|
|
public function get_last_name() |
276
|
|
|
{ |
277
|
|
|
return (isset($this->data['last_name'])) ? (string) $this->data['last_name'] : ''; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Get member user_id |
282
|
|
|
* |
283
|
|
|
* @return integer |
284
|
|
|
* @access public |
285
|
|
|
*/ |
286
|
|
|
public function get_user_id() |
287
|
|
|
{ |
288
|
|
|
return (isset($this->data['user_id'])) ? (integer) $this->data['user_id'] : 0; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Get member username |
293
|
|
|
* |
294
|
|
|
* @return string |
295
|
|
|
* @access public |
296
|
|
|
*/ |
297
|
|
|
public function get_username() |
298
|
|
|
{ |
299
|
|
|
return (isset($this->extra_data['username'])) ? (string) $this->extra_data['username'] : ''; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Get PayPal payer last name |
304
|
|
|
* |
305
|
|
|
* @return string |
306
|
|
|
* @access public |
307
|
|
|
*/ |
308
|
|
|
public function get_custom() |
309
|
|
|
{ |
310
|
|
|
return (isset($this->data['custom'])) ? (string) $this->data['custom'] : ''; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Get PayPal item name |
315
|
|
|
* |
316
|
|
|
* @return string |
317
|
|
|
* @access public |
318
|
|
|
*/ |
319
|
|
|
public function get_item_name() |
320
|
|
|
{ |
321
|
|
|
return (isset($this->data['item_name'])) ? (string) $this->data['item_name'] : ''; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Get PayPal item number (contains user_id) |
326
|
|
|
* |
327
|
|
|
* @return string |
328
|
|
|
* @access public |
329
|
|
|
*/ |
330
|
|
|
public function get_item_number() |
331
|
|
|
{ |
332
|
|
|
return (isset($this->data['item_number'])) ? (string) $this->data['item_number'] : ''; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* Get PayPal currency name (eg: USD, EUR, etc.) |
337
|
|
|
* |
338
|
|
|
* @return string |
339
|
|
|
* @access public |
340
|
|
|
*/ |
341
|
|
|
public function get_mc_currency() |
342
|
|
|
{ |
343
|
|
|
return (isset($this->data['mc_currency'])) ? (string) $this->data['mc_currency'] : ''; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Get PayPal fees |
348
|
|
|
* |
349
|
|
|
* @return float |
350
|
|
|
* @access public |
351
|
|
|
*/ |
352
|
|
|
public function get_mc_fee() |
353
|
|
|
{ |
354
|
|
|
return (isset($this->data['mc_fee'])) ? (float) $this->data['mc_fee'] : 0; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* Get PayPal amount |
359
|
|
|
* This is the amount of donation received before fees |
360
|
|
|
* |
361
|
|
|
* @return float |
362
|
|
|
* @access public |
363
|
|
|
*/ |
364
|
|
|
public function get_mc_gross() |
365
|
|
|
{ |
366
|
|
|
return (isset($this->data['mc_gross'])) ? (float) $this->data['mc_gross'] : 0; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Get Net amount |
371
|
|
|
* This is the amount of donation received after fees |
372
|
|
|
* |
373
|
|
|
* @return float |
|
|
|
|
374
|
|
|
* @access public |
375
|
|
|
*/ |
376
|
|
|
public function get_net_amount() |
377
|
|
|
{ |
378
|
|
|
return (isset($this->data['net_amount'])) ? (float) $this->data['net_amount'] : 0; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* Get PayPal payment date |
383
|
|
|
* |
384
|
|
|
* @return integer |
385
|
|
|
* @access public |
386
|
|
|
*/ |
387
|
|
|
public function get_payment_date() |
388
|
|
|
{ |
389
|
|
|
return (isset($this->data['payment_date'])) ? (int) $this->data['payment_date'] : ''; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Get PayPal payment status |
394
|
|
|
* |
395
|
|
|
* @return string |
396
|
|
|
* @access public |
397
|
|
|
*/ |
398
|
|
|
public function get_payment_status() |
399
|
|
|
{ |
400
|
|
|
return (isset($this->data['payment_status'])) ? (string) $this->data['payment_status'] : ''; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* Get PayPal payment type |
405
|
|
|
* |
406
|
|
|
* @return string |
407
|
|
|
* @access public |
408
|
|
|
*/ |
409
|
|
|
public function get_payment_type() |
410
|
|
|
{ |
411
|
|
|
return (isset($this->data['payment_type'])) ? (string) $this->data['payment_type'] : ''; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Get PayPal settle amount |
416
|
|
|
* This is in case or the currency of the Payer is not in the same currency of the Receiver |
417
|
|
|
* |
418
|
|
|
* @return float |
|
|
|
|
419
|
|
|
* @access public |
420
|
|
|
*/ |
421
|
|
|
public function get_settle_amount() |
422
|
|
|
{ |
423
|
|
|
return (isset($this->data['settle_amount'])) ? (float) $this->data['settle_amount'] : 0; |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* Get PayPal settle currency |
428
|
|
|
* |
429
|
|
|
* @return string |
430
|
|
|
* @access public |
431
|
|
|
*/ |
432
|
|
|
public function get_settle_currency() |
433
|
|
|
{ |
434
|
|
|
return (isset($this->data['settle_currency'])) ? (string) $this->data['settle_currency'] : ''; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* Get PayPal exchange rate |
439
|
|
|
* This is when the donation don’t use the same currency defined by the receiver |
440
|
|
|
* |
441
|
|
|
* @return string |
442
|
|
|
* @access public |
443
|
|
|
*/ |
444
|
|
|
public function get_exchange_rate() |
445
|
|
|
{ |
446
|
|
|
return (isset($this->data['exchange_rate'])) ? (string) $this->data['exchange_rate'] : ''; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* Set PayPal transaction id |
451
|
|
|
* |
452
|
|
|
* @param string $txn_id |
453
|
|
|
* |
454
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
455
|
|
|
* @access public |
456
|
|
|
*/ |
457
|
|
|
public function set_txn_id($txn_id) |
458
|
|
|
{ |
459
|
|
|
$this->data['txn_id'] = (string) $txn_id; |
460
|
|
|
|
461
|
|
|
return $this; |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Set PayPal receiver ID |
466
|
|
|
* |
467
|
|
|
* @param string $receiver_id |
468
|
|
|
* |
469
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
470
|
|
|
* @access public |
471
|
|
|
*/ |
472
|
|
|
public function set_receiver_id($receiver_id) |
473
|
|
|
{ |
474
|
|
|
$this->data['receiver_id'] = (string) $receiver_id; |
475
|
|
|
|
476
|
|
|
return $this; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Set PayPal receiver e-mail |
481
|
|
|
* |
482
|
|
|
* @param string $receiver_email |
483
|
|
|
* |
484
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
485
|
|
|
* @access public |
486
|
|
|
*/ |
487
|
|
|
public function set_receiver_email($receiver_email) |
488
|
|
|
{ |
489
|
|
|
$this->data['receiver_email'] = (string) $receiver_email; |
490
|
|
|
|
491
|
|
|
return $this; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* Set PayPal receiver ID |
496
|
|
|
* |
497
|
|
|
* @param string $residence_country |
498
|
|
|
* |
499
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
500
|
|
|
* @access public |
501
|
|
|
*/ |
502
|
|
|
public function set_residence_country($residence_country) |
503
|
|
|
{ |
504
|
|
|
$this->data['residence_country'] = (string) $residence_country; |
505
|
|
|
|
506
|
|
|
return $this; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Set PayPal business (same as receiver ID or receiver_email) |
511
|
|
|
* |
512
|
|
|
* @param string $business |
513
|
|
|
* |
514
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
515
|
|
|
* @access public |
516
|
|
|
*/ |
517
|
|
|
public function set_business($business) |
518
|
|
|
{ |
519
|
|
|
$this->data['business'] = (string) $business; |
520
|
|
|
|
521
|
|
|
return $this; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* Set PayPal transaction status |
526
|
|
|
* |
527
|
|
|
* @param bool $confirmed |
528
|
|
|
* |
529
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
530
|
|
|
* @access public |
531
|
|
|
*/ |
532
|
|
|
public function set_confirmed($confirmed) |
533
|
|
|
{ |
534
|
|
|
$this->data['confirmed'] = (bool) $confirmed; |
535
|
|
|
|
536
|
|
|
return $this; |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* Set Test IPN status |
541
|
|
|
* |
542
|
|
|
* @param bool $test_ipn |
543
|
|
|
* |
544
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
545
|
|
|
* @access public |
546
|
|
|
*/ |
547
|
|
|
public function set_test_ipn($test_ipn) |
548
|
|
|
{ |
549
|
|
|
$this->data['test_ipn'] = (bool) $test_ipn; |
550
|
|
|
|
551
|
|
|
return $this; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* Set PayPal transaction type |
556
|
|
|
* |
557
|
|
|
* @param string $txn_type |
558
|
|
|
* |
559
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
560
|
|
|
* @access public |
561
|
|
|
*/ |
562
|
|
|
public function set_txn_type($txn_type) |
563
|
|
|
{ |
564
|
|
|
$this->data['txn_type'] = (string) $txn_type; |
565
|
|
|
|
566
|
|
|
return $this; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Set PayPal parent transaction ID (in case of refund) |
571
|
|
|
* |
572
|
|
|
* @param string $parent_txn_id |
573
|
|
|
* |
574
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
575
|
|
|
* @access public |
576
|
|
|
*/ |
577
|
|
|
public function set_parent_txn_id($parent_txn_id) |
578
|
|
|
{ |
579
|
|
|
$this->data['parent_txn_id'] = (string) $parent_txn_id; |
580
|
|
|
|
581
|
|
|
return $this; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* Set PayPal payer e-mail |
586
|
|
|
* |
587
|
|
|
* @param string $payer_email |
588
|
|
|
* |
589
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
590
|
|
|
* @access public |
591
|
|
|
*/ |
592
|
|
|
public function set_payer_email($payer_email) |
593
|
|
|
{ |
594
|
|
|
$this->data['payer_email'] = (string) $payer_email; |
595
|
|
|
|
596
|
|
|
return $this; |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* Set PayPal payer account ID |
601
|
|
|
* |
602
|
|
|
* @param string $payer_id |
603
|
|
|
* |
604
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
605
|
|
|
* @access public |
606
|
|
|
*/ |
607
|
|
|
public function set_payer_id($payer_id) |
608
|
|
|
{ |
609
|
|
|
$this->data['payer_id'] = (string) $payer_id; |
610
|
|
|
|
611
|
|
|
return $this; |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
/** |
615
|
|
|
* Set PayPal payer Status (such as unverified/verified) |
616
|
|
|
* |
617
|
|
|
* @param string $payer_status |
618
|
|
|
* |
619
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
620
|
|
|
* @access public |
621
|
|
|
*/ |
622
|
|
|
public function set_payer_status($payer_status) |
623
|
|
|
{ |
624
|
|
|
$this->data['payer_status'] = (string) $payer_status; |
625
|
|
|
|
626
|
|
|
return $this; |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* Set PayPal payer first name |
631
|
|
|
* |
632
|
|
|
* @param string $first_name |
633
|
|
|
* |
634
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
635
|
|
|
* @access public |
636
|
|
|
*/ |
637
|
|
|
public function set_first_name($first_name) |
638
|
|
|
{ |
639
|
|
|
$this->data['first_name'] = (string) $first_name; |
640
|
|
|
|
641
|
|
|
return $this; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* Set PayPal payer last name |
646
|
|
|
* |
647
|
|
|
* @param string $last_name |
648
|
|
|
* |
649
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
650
|
|
|
* @access public |
651
|
|
|
*/ |
652
|
|
|
public function set_last_name($last_name) |
653
|
|
|
{ |
654
|
|
|
$this->data['last_name'] = (string) $last_name; |
655
|
|
|
|
656
|
|
|
return $this; |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
/** |
660
|
|
|
* Set member user_id |
661
|
|
|
* |
662
|
|
|
* @param integer $user_id |
663
|
|
|
* |
664
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
665
|
|
|
* @access public |
666
|
|
|
*/ |
667
|
|
|
public function set_user_id($user_id) |
668
|
|
|
{ |
669
|
|
|
$this->data['user_id'] = (integer) $user_id; |
670
|
|
|
|
671
|
|
|
return $this; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
/** |
675
|
|
|
* Set member username |
676
|
|
|
* |
677
|
|
|
* @param string $username |
678
|
|
|
* |
679
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
680
|
|
|
* @access public |
681
|
|
|
*/ |
682
|
|
|
public function set_username($username) |
683
|
|
|
{ |
684
|
|
|
$this->extra_data['username'] = (string) $username; |
685
|
|
|
|
686
|
|
|
return $this; |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Set PayPal payer last name |
691
|
|
|
* |
692
|
|
|
* @param string $custom |
693
|
|
|
* |
694
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
695
|
|
|
* @access public |
696
|
|
|
*/ |
697
|
|
|
public function set_custom($custom) |
698
|
|
|
{ |
699
|
|
|
$this->data['custom'] = (string) $custom; |
700
|
|
|
|
701
|
|
|
return $this; |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
/** |
705
|
|
|
* Set PayPal item name |
706
|
|
|
* |
707
|
|
|
* @param string $item_name |
708
|
|
|
* |
709
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
710
|
|
|
* @access public |
711
|
|
|
*/ |
712
|
|
|
public function set_item_name($item_name) |
713
|
|
|
{ |
714
|
|
|
$this->data['item_name'] = (string) $item_name; |
715
|
|
|
|
716
|
|
|
return $this; |
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
/** |
720
|
|
|
* Set PayPal item number (contains user_id) |
721
|
|
|
* |
722
|
|
|
* @param string $item_number |
723
|
|
|
* |
724
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
725
|
|
|
* @access public |
726
|
|
|
*/ |
727
|
|
|
public function set_item_number($item_number) |
728
|
|
|
{ |
729
|
|
|
$this->data['item_number'] = (string) $item_number; |
730
|
|
|
|
731
|
|
|
return $this; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
/** |
735
|
|
|
* Set PayPal currency name (eg: USD, EUR, etc.) |
736
|
|
|
* |
737
|
|
|
* @param string $mc_currency |
738
|
|
|
* |
739
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
740
|
|
|
* @access public |
741
|
|
|
*/ |
742
|
|
|
public function set_mc_currency($mc_currency) |
743
|
|
|
{ |
744
|
|
|
$this->data['mc_currency'] = (string) $mc_currency; |
745
|
|
|
|
746
|
|
|
return $this; |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
/** |
750
|
|
|
* Set PayPal fees |
751
|
|
|
* |
752
|
|
|
* @param float $mc_fee |
753
|
|
|
* |
754
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
755
|
|
|
* @access public |
756
|
|
|
*/ |
757
|
|
|
public function set_mc_fee($mc_fee) |
758
|
|
|
{ |
759
|
|
|
$this->data['mc_fee'] = (float) $mc_fee; |
760
|
|
|
|
761
|
|
|
return $this; |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* Set PayPal amount |
766
|
|
|
* This is the amount of donation received before fees |
767
|
|
|
* |
768
|
|
|
* @param float $mc_gross |
769
|
|
|
* |
770
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
771
|
|
|
* @access public |
772
|
|
|
*/ |
773
|
|
|
public function set_mc_gross($mc_gross) |
774
|
|
|
{ |
775
|
|
|
$this->data['mc_gross'] = (float) $mc_gross; |
776
|
|
|
|
777
|
|
|
return $this; |
778
|
|
|
} |
779
|
|
|
|
780
|
|
|
/** |
781
|
|
|
* Set Net amount |
782
|
|
|
* This is the amount of donation received after fees |
783
|
|
|
* |
784
|
|
|
* @param float $net_amount |
785
|
|
|
* |
786
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
787
|
|
|
* @access public |
788
|
|
|
*/ |
789
|
|
|
public function set_net_amount($net_amount) |
790
|
|
|
{ |
791
|
|
|
$this->data['net_amount'] = (float) $net_amount; |
792
|
|
|
|
793
|
|
|
return $this; |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
/** |
797
|
|
|
* Set PayPal payment date |
798
|
|
|
* |
799
|
|
|
* @param integer $payment_date |
800
|
|
|
* |
801
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
802
|
|
|
* @access public |
803
|
|
|
*/ |
804
|
|
|
public function set_payment_date($payment_date) |
805
|
|
|
{ |
806
|
|
|
$this->data['payment_date'] = (int) $payment_date; |
807
|
|
|
|
808
|
|
|
return $this; |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
/** |
812
|
|
|
* Set PayPal payment status |
813
|
|
|
* |
814
|
|
|
* @param string $payment_status |
815
|
|
|
* |
816
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
817
|
|
|
* @access public |
818
|
|
|
*/ |
819
|
|
|
public function set_payment_status($payment_status) |
820
|
|
|
{ |
821
|
|
|
$this->data['payment_status'] = (string) $payment_status; |
822
|
|
|
|
823
|
|
|
return $this; |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* Set PayPal payment type |
828
|
|
|
* |
829
|
|
|
* @param string $payment_type |
830
|
|
|
* |
831
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
832
|
|
|
* @access public |
833
|
|
|
*/ |
834
|
|
|
public function set_payment_type($payment_type) |
835
|
|
|
{ |
836
|
|
|
$this->data['payment_type'] = (string) $payment_type; |
837
|
|
|
|
838
|
|
|
return $this; |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
/** |
842
|
|
|
* Set PayPal settle amount |
843
|
|
|
* This is in case or the currency of the Payer is not in the same currency of the Receiver |
844
|
|
|
* |
845
|
|
|
* @param float $settle_amount |
846
|
|
|
* |
847
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
848
|
|
|
* @access public |
849
|
|
|
*/ |
850
|
|
|
public function set_settle_amount($settle_amount) |
851
|
|
|
{ |
852
|
|
|
$this->data['settle_amount'] = (float) $settle_amount; |
853
|
|
|
|
854
|
|
|
return $this; |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* Set PayPal settle currency |
859
|
|
|
* |
860
|
|
|
* @param string $settle_currency |
861
|
|
|
* |
862
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
863
|
|
|
* @access public |
864
|
|
|
*/ |
865
|
|
|
public function set_settle_currency($settle_currency) |
866
|
|
|
{ |
867
|
|
|
$this->data['settle_currency'] = (string) $settle_currency; |
868
|
|
|
|
869
|
|
|
return $this; |
870
|
|
|
} |
871
|
|
|
|
872
|
|
|
/** |
873
|
|
|
* Set PayPal exchange rate |
874
|
|
|
* This is when the donation don’t use the same currency defined by the receiver |
875
|
|
|
* |
876
|
|
|
* @param string $exchange_rate |
877
|
|
|
* |
878
|
|
|
* @return transactions $this object for chaining calls; load()->set()->save() |
879
|
|
|
* @access public |
880
|
|
|
*/ |
881
|
|
|
public function set_exchange_rate($exchange_rate) |
882
|
|
|
{ |
883
|
|
|
$this->data['exchange_rate'] = (string) $exchange_rate; |
884
|
|
|
|
885
|
|
|
return $this; |
886
|
|
|
} |
887
|
|
|
} |
888
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.