1
|
|
|
<?php namespace Arcanedev\Stripe\Resources; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Stripe\Contracts\Resources\Recipient as RecipientContract; |
4
|
|
|
use Arcanedev\Stripe\StripeResource; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class Recipient |
8
|
|
|
* |
9
|
|
|
* @package Arcanedev\Stripe\Resources |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
* @link https://stripe.com/docs/api/php#recipient_object |
12
|
|
|
* |
13
|
|
|
* @deprecated since the end of 2015, use Connect (https://stripe.com/docs/connect) instead. |
14
|
|
|
* |
15
|
|
|
* @property string id |
16
|
|
|
* @property string object // 'recipient' |
17
|
|
|
* @property \Arcanedev\Stripe\Bases\ExternalAccount|null active_account |
18
|
|
|
* @property \Arcanedev\Stripe\Collection cards |
19
|
|
|
* @property int created // timestamp |
20
|
|
|
* @property string default_card |
21
|
|
|
* @property string description |
22
|
|
|
* @property string email |
23
|
|
|
* @property bool livemode |
24
|
|
|
* @property \Arcanedev\Stripe\AttachedObject metadata |
25
|
|
|
* @property string|null migrated_to |
26
|
|
|
* @property string name |
27
|
|
|
* @property string type // 'individual' or 'corporation' |
28
|
|
|
*/ |
29
|
|
|
class Recipient extends StripeResource implements RecipientContract |
30
|
|
|
{ |
31
|
|
|
/* ------------------------------------------------------------------------------------------------ |
32
|
|
|
| Properties |
33
|
|
|
| ------------------------------------------------------------------------------------------------ |
34
|
|
|
*/ |
35
|
|
|
/** |
36
|
|
|
* Allow to check attributes while setting |
37
|
|
|
* |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
protected $checkUnsavedAttributes = true; |
41
|
|
|
|
42
|
|
|
/* ------------------------------------------------------------------------------------------------ |
43
|
|
|
| Main Functions |
44
|
|
|
| ------------------------------------------------------------------------------------------------ |
45
|
|
|
*/ |
46
|
|
|
/** |
47
|
|
|
* List all Recipients. |
48
|
|
|
* @link https://stripe.com/docs/api/php#list_recipients |
49
|
|
|
* |
50
|
|
|
* @param array|null $params |
51
|
|
|
* @param array|string|null $options |
52
|
|
|
* |
53
|
|
|
* @return \Arcanedev\Stripe\Collection|array |
54
|
|
|
*/ |
55
|
2 |
|
public static function all($params = [], $options = null) |
56
|
|
|
{ |
57
|
2 |
|
return self::scopedAll($params, $options); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Retrieve a Recipient. |
62
|
|
|
* @link https://stripe.com/docs/api/php#retrieve_recipient |
63
|
|
|
* |
64
|
|
|
* @param string $id |
65
|
|
|
* @param array|string|null $options |
66
|
|
|
* |
67
|
|
|
* @return self |
68
|
|
|
*/ |
69
|
16 |
|
public static function retrieve($id, $options = null) |
70
|
|
|
{ |
71
|
16 |
|
return self::scopedRetrieve($id, $options); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Create a new Recipient. |
76
|
|
|
* @link https://stripe.com/docs/api/php#create_recipient |
77
|
|
|
* |
78
|
|
|
* @param array|null $params |
79
|
|
|
* @param array|string|null $options |
80
|
|
|
* |
81
|
|
|
* @return self|array |
82
|
|
|
*/ |
83
|
30 |
|
public static function create($params = [], $options = null) |
84
|
|
|
{ |
85
|
30 |
|
return self::scopedCreate($params, $options); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Update a Recipient. |
90
|
|
|
* @link https://stripe.com/docs/api/php#update_recipient |
91
|
|
|
* |
92
|
|
|
* @param string $id |
93
|
|
|
* @param array|null $params |
94
|
|
|
* @param array|string|null $options |
95
|
|
|
* |
96
|
|
|
* @return self |
97
|
|
|
*/ |
98
|
2 |
|
public static function update($id, $params = [], $options = null) |
99
|
|
|
{ |
100
|
2 |
|
return self::scopedUpdate($id, $params, $options); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Update/Save a Recipient. |
105
|
|
|
* @link https://stripe.com/docs/api/php#update_recipient |
106
|
|
|
* |
107
|
|
|
* @param array|string|null $options |
108
|
|
|
* |
109
|
|
|
* @return self |
110
|
|
|
*/ |
111
|
12 |
|
public function save($options = null) |
112
|
|
|
{ |
113
|
12 |
|
return self::scopedSave($options); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Delete a Recipient. |
118
|
|
|
* @link https://stripe.com/docs/api/php#delete_recipient |
119
|
|
|
* |
120
|
|
|
* @param array|null $params |
121
|
|
|
* @param array|string|null $options |
122
|
|
|
* |
123
|
|
|
* @return self |
124
|
|
|
*/ |
125
|
2 |
|
public function delete($params = [], $options = null) |
126
|
|
|
{ |
127
|
2 |
|
return self::scopedDelete($params, $options); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/* ------------------------------------------------------------------------------------------------ |
131
|
|
|
| Relationships Functions |
132
|
|
|
| ------------------------------------------------------------------------------------------------ |
133
|
|
|
*/ |
134
|
|
|
/** |
135
|
|
|
* List all Recipient's Transfers. |
136
|
|
|
* |
137
|
|
|
* @param array $params |
138
|
|
|
* |
139
|
|
|
* @return \Arcanedev\Stripe\Collection|array |
140
|
|
|
*/ |
141
|
|
|
public function transfers($params = []) |
142
|
|
|
{ |
143
|
|
|
$this->addRecipientParam($params); |
144
|
|
|
|
145
|
|
|
return Transfer::all($params, $this->opts); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/* ------------------------------------------------------------------------------------------------ |
149
|
|
|
| Other Functions |
150
|
|
|
| ------------------------------------------------------------------------------------------------ |
151
|
|
|
*/ |
152
|
|
|
/** |
153
|
|
|
* Add Recipient ID to Parameters. |
154
|
|
|
* |
155
|
|
|
* @param array $params |
156
|
|
|
*/ |
157
|
|
|
private function addRecipientParam(&$params) |
158
|
|
|
{ |
159
|
|
|
$params['recipient'] = $this->id; |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|