1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tbclla\Revolut\Builders; |
4
|
|
|
|
5
|
|
|
class PaymentBuilder extends Builder |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* The ID of the account to pay from |
9
|
|
|
* |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
public $account_id; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The receiving party |
16
|
|
|
* |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
public $receiver; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The payment amount |
23
|
|
|
* |
24
|
|
|
* @var float |
25
|
|
|
*/ |
26
|
|
|
public $amount; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The payment currency |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $currency; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* An optional payment reference |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $reference; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* An optional date to schedule the payment |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
public $schedule_for; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Set the outgoing account ID |
51
|
|
|
* |
52
|
|
|
* @param string $accountId the ID of the account to pay from |
53
|
|
|
* @return self |
54
|
|
|
*/ |
55
|
|
|
public function account(string $accountId) |
56
|
|
|
{ |
57
|
|
|
return $this->setAttribute('account_id', $accountId); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Set the receiver of the payment |
62
|
|
|
* |
63
|
|
|
* @param string $counterpartyId the ID of the receiving counterparty |
64
|
|
|
* @param string $accountId the ID of the receiving counterparty's account, only for payments to business counterparties |
65
|
|
|
* @return self |
66
|
|
|
*/ |
67
|
|
|
public function receiver(string $counterpartyId, string $accountId = null) |
68
|
|
|
{ |
69
|
|
|
$receiver = ['counterparty_id' => $counterpartyId]; |
70
|
|
|
|
71
|
|
|
if ($accountId) { |
72
|
|
|
$receiver['account_id'] = $accountId; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $this->setAttribute('receiver', $receiver); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Set the transaction amount |
80
|
|
|
* |
81
|
|
|
* @param float $amount |
82
|
|
|
* @return self |
83
|
|
|
*/ |
84
|
|
|
public function amount(float $amount) |
85
|
|
|
{ |
86
|
|
|
return $this->setAttribute('amount', $amount); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Set the transaction currency |
91
|
|
|
* |
92
|
|
|
* @param float $amount |
93
|
|
|
* @return self |
94
|
|
|
*/ |
95
|
|
|
public function currency(string $currency) |
96
|
|
|
{ |
97
|
|
|
return $this->setAttribute('currency', $currency); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Set an optional textual reference shown on the transaction |
102
|
|
|
* |
103
|
|
|
* @param string $reference |
104
|
|
|
* @return self |
105
|
|
|
*/ |
106
|
|
|
public function reference(string $reference) |
107
|
|
|
{ |
108
|
|
|
return $this->setAttribute('reference', $reference); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Set an optional date to schedule the payment |
113
|
|
|
* |
114
|
|
|
* @param string $date |
115
|
|
|
* @return self |
116
|
|
|
*/ |
117
|
|
|
public function schedule(string $date) |
118
|
|
|
{ |
119
|
|
|
return $this->setAttribute('schedule_for', $date); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|