PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / stripe / stripe-php / lib / Customer.php

Customer.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/stripe/stripe-php/lib/Customer.php

364 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // File generated from our OpenAPI spec
4
5 namespace Stripe;
6
7 /**
8 * This object represents a customer of your business. It lets you create recurring
9 * charges and track payments that belong to the same customer.
10 *
11 * Related guide: <a
12 * href="https://stripe.com/docs/payments/save-during-payment">Save a card during
13 * payment</a>.
14 *
15 * @property string $id Unique identifier for the object.
16 * @property string $object String representing the object's type. Objects of the same type share the same value.
17 * @property null|\Stripe\StripeObject $address The customer's address.
18 * @property int $balance Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
19 * @property null|\Stripe\CashBalance $cash_balance The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source &quot;cash_balance&quot;.The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.
20 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
21 * @property null|string $currency Three-letter <a href="https://stripe.com/docs/currencies">ISO code for the currency</a> the customer can be charged in for recurring billing purposes.
22 * @property null|string|\Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source $default_source <p>ID of the default payment source for the customer.</p><p>If you are using payment methods created via the PaymentMethods API, see the <a href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method</a> field instead.</p>
23 * @property null|bool $delinquent <p>When the customer's latest invoice is billed by charging automatically, <code>delinquent</code> is <code>true</code> if the invoice's latest charge failed. When the customer's latest invoice is billed by sending an invoice, <code>delinquent</code> is <code>true</code> if the invoice isn't paid by its due date.</p><p>If an invoice is marked uncollectible by <a href="https://stripe.com/docs/billing/automatic-collection">dunning</a>, <code>delinquent</code> doesn't get reset to <code>false</code>.</p>
24 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
25 * @property null|\Stripe\Discount $discount Describes the current discount active on the customer, if there is one.
26 * @property null|string $email The customer's email address.
27 * @property \Stripe\StripeObject $invoice_credit_balance The current multi-currency balances, if any, being stored on the customer.If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency.If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices.They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.
28 * @property null|string $invoice_prefix The prefix for the customer used to generate unique invoice numbers.
29 * @property \Stripe\StripeObject $invoice_settings
30 * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
31 * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
32 * @property null|string $name The customer's full name or business name.
33 * @property int $next_invoice_sequence The suffix of the customer's next invoice number, e.g., 0001.
34 * @property null|string $phone The customer's phone number.
35 * @property null|string[] $preferred_locales The customer's preferred locales (languages), ordered by preference.
36 * @property null|\Stripe\StripeObject $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
37 * @property \Stripe\Collection<\Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source> $sources The customer's payment sources, if any.
38 * @property \Stripe\Collection<\Stripe\Subscription> $subscriptions The customer's current subscriptions, if any.
39 * @property \Stripe\StripeObject $tax
40 * @property null|string $tax_exempt Describes the customer's tax exemption status. One of <code>none</code>, <code>exempt</code>, or <code>reverse</code>. When set to <code>reverse</code>, invoice and receipt PDFs include the text <strong>&quot;Reverse charge&quot;</strong>.
41 * @property \Stripe\Collection<\Stripe\TaxId> $tax_ids The customer's tax IDs.
42 * @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this customer belongs to.
43 */
44 class Customer extends ApiResource
45 {
46 const OBJECT_NAME = 'customer';
47
48 use ApiOperations\All;
49 use ApiOperations\Create;
50 use ApiOperations\Delete;
51 use ApiOperations\NestedResource;
52 use ApiOperations\Retrieve;
53 use ApiOperations\Search;
54 use ApiOperations\Update;
55
56 const TAX_EXEMPT_EXEMPT = 'exempt';
57 const TAX_EXEMPT_NONE = 'none';
58 const TAX_EXEMPT_REVERSE = 'reverse';
59
60 public static function getSavedNestedResources()
61 {
62 static $savedNestedResources = null;
63 if (null === $savedNestedResources) {
64 $savedNestedResources = new Util\Set([
65 'source',
66 ]);
67 }
68
69 return $savedNestedResources;
70 }
71
72 /**
73 * @param null|array $params
74 * @param null|array|string $opts
75 *
76 * @return \Stripe\Customer the updated customer
77 */
78 public function deleteDiscount($params = null, $opts = null)
79 {
80 $url = $this->instanceUrl() . '/discount';
81 list($response, $opts) = $this->_request('delete', $url, $params, $opts);
82 $this->refreshFrom(['discount' => null], $opts, true);
83
84 return $this;
85 }
86
87 /**
88 * @param string $id
89 * @param null|array $params
90 * @param null|array|string $opts
91 *
92 * @throws \Stripe\Exception\ApiErrorException if the request fails
93 *
94 * @return \Stripe\Collection<\Stripe\PaymentMethod> list of PaymentMethods
95 */
96 public static function allPaymentMethods($id, $params = null, $opts = null)
97 {
98 $url = static::resourceUrl($id) . '/payment_methods';
99 list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
100 $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
101 $obj->setLastResponse($response);
102
103 return $obj;
104 }
105
106 /**
107 * @param string $payment_method
108 * @param null|array $params
109 * @param null|array|string $opts
110 *
111 * @throws \Stripe\Exception\ApiErrorException if the request fails
112 *
113 * @return \Stripe\Customer the retrieved customer
114 */
115 public function retrievePaymentMethod($payment_method, $params = null, $opts = null)
116 {
117 $url = $this->instanceUrl() . '/payment_methods/' . $payment_method;
118 list($response, $opts) = $this->_request('get', $url, $params, $opts);
119 $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts);
120 $obj->setLastResponse($response);
121
122 return $obj;
123 }
124
125 /**
126 * @param null|array $params
127 * @param null|array|string $opts
128 *
129 * @throws \Stripe\Exception\ApiErrorException if the request fails
130 *
131 * @return \Stripe\SearchResult<Customer> the customer search results
132 */
133 public static function search($params = null, $opts = null)
134 {
135 $url = '/v1/customers/search';
136
137 return self::_searchResource($url, $params, $opts);
138 }
139
140 const PATH_CASH_BALANCE = '/cash_balance';
141
142 /**
143 * @param string $id the ID of the customer to which the cash balance belongs
144 * @param null|array $params
145 * @param null|array|string $opts
146 * @param mixed $cashBalanceId
147 *
148 * @throws \Stripe\Exception\ApiErrorException if the request fails
149 *
150 * @return \Stripe\CashBalance
151 */
152 public static function retrieveCashBalance($id, $cashBalanceId, $params = null, $opts = null)
153 {
154 return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
155 }
156
157 /**
158 * @param string $id the ID of the customer to which the cash balance belongs
159 * @param null|array $params
160 * @param null|array|string $opts
161 * @param mixed $cashBalanceId
162 *
163 * @throws \Stripe\Exception\ApiErrorException if the request fails
164 *
165 * @return \Stripe\CashBalance
166 */
167 public static function updateCashBalance($id, $cashBalanceId, $params = null, $opts = null)
168 {
169 return self::_updateNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
170 }
171 const PATH_BALANCE_TRANSACTIONS = '/balance_transactions';
172
173 /**
174 * @param string $id the ID of the customer on which to retrieve the customer balance transactions
175 * @param null|array $params
176 * @param null|array|string $opts
177 *
178 * @throws \Stripe\Exception\ApiErrorException if the request fails
179 *
180 * @return \Stripe\Collection<\Stripe\CustomerBalanceTransaction> the list of customer balance transactions
181 */
182 public static function allBalanceTransactions($id, $params = null, $opts = null)
183 {
184 return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
185 }
186
187 /**
188 * @param string $id the ID of the customer on which to create the customer balance transaction
189 * @param null|array $params
190 * @param null|array|string $opts
191 *
192 * @throws \Stripe\Exception\ApiErrorException if the request fails
193 *
194 * @return \Stripe\CustomerBalanceTransaction
195 */
196 public static function createBalanceTransaction($id, $params = null, $opts = null)
197 {
198 return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
199 }
200
201 /**
202 * @param string $id the ID of the customer to which the customer balance transaction belongs
203 * @param string $balanceTransactionId the ID of the customer balance transaction to retrieve
204 * @param null|array $params
205 * @param null|array|string $opts
206 *
207 * @throws \Stripe\Exception\ApiErrorException if the request fails
208 *
209 * @return \Stripe\CustomerBalanceTransaction
210 */
211 public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
212 {
213 return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
214 }
215
216 /**
217 * @param string $id the ID of the customer to which the customer balance transaction belongs
218 * @param string $balanceTransactionId the ID of the customer balance transaction to update
219 * @param null|array $params
220 * @param null|array|string $opts
221 *
222 * @throws \Stripe\Exception\ApiErrorException if the request fails
223 *
224 * @return \Stripe\CustomerBalanceTransaction
225 */
226 public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
227 {
228 return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
229 }
230 const PATH_SOURCES = '/sources';
231
232 /**
233 * @param string $id the ID of the customer on which to retrieve the payment sources
234 * @param null|array $params
235 * @param null|array|string $opts
236 *
237 * @throws \Stripe\Exception\ApiErrorException if the request fails
238 *
239 * @return \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card|\Stripe\Source> the list of payment sources (BankAccount, Card or Source)
240 */
241 public static function allSources($id, $params = null, $opts = null)
242 {
243 return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
244 }
245
246 /**
247 * @param string $id the ID of the customer on which to create the payment source
248 * @param null|array $params
249 * @param null|array|string $opts
250 *
251 * @throws \Stripe\Exception\ApiErrorException if the request fails
252 *
253 * @return \Stripe\BankAccount|\Stripe\Card|\Stripe\Source
254 */
255 public static function createSource($id, $params = null, $opts = null)
256 {
257 return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
258 }
259
260 /**
261 * @param string $id the ID of the customer to which the payment source belongs
262 * @param string $sourceId the ID of the payment source to delete
263 * @param null|array $params
264 * @param null|array|string $opts
265 *
266 * @throws \Stripe\Exception\ApiErrorException if the request fails
267 *
268 * @return \Stripe\BankAccount|\Stripe\Card|\Stripe\Source
269 */
270 public static function deleteSource($id, $sourceId, $params = null, $opts = null)
271 {
272 return self::_deleteNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
273 }
274
275 /**
276 * @param string $id the ID of the customer to which the payment source belongs
277 * @param string $sourceId the ID of the payment source to retrieve
278 * @param null|array $params
279 * @param null|array|string $opts
280 *
281 * @throws \Stripe\Exception\ApiErrorException if the request fails
282 *
283 * @return \Stripe\BankAccount|\Stripe\Card|\Stripe\Source
284 */
285 public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
286 {
287 return self::_retrieveNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
288 }
289
290 /**
291 * @param string $id the ID of the customer to which the payment source belongs
292 * @param string $sourceId the ID of the payment source to update
293 * @param null|array $params
294 * @param null|array|string $opts
295 *
296 * @throws \Stripe\Exception\ApiErrorException if the request fails
297 *
298 * @return \Stripe\BankAccount|\Stripe\Card|\Stripe\Source
299 */
300 public static function updateSource($id, $sourceId, $params = null, $opts = null)
301 {
302 return self::_updateNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
303 }
304 const PATH_TAX_IDS = '/tax_ids';
305
306 /**
307 * @param string $id the ID of the customer on which to retrieve the tax ids
308 * @param null|array $params
309 * @param null|array|string $opts
310 *
311 * @throws \Stripe\Exception\ApiErrorException if the request fails
312 *
313 * @return \Stripe\Collection<\Stripe\TaxId> the list of tax ids
314 */
315 public static function allTaxIds($id, $params = null, $opts = null)
316 {
317 return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts);
318 }
319
320 /**
321 * @param string $id the ID of the customer on which to create the tax id
322 * @param null|array $params
323 * @param null|array|string $opts
324 *
325 * @throws \Stripe\Exception\ApiErrorException if the request fails
326 *
327 * @return \Stripe\TaxId
328 */
329 public static function createTaxId($id, $params = null, $opts = null)
330 {
331 return self::_createNestedResource($id, static::PATH_TAX_IDS, $params, $opts);
332 }
333
334 /**
335 * @param string $id the ID of the customer to which the tax id belongs
336 * @param string $taxIdId the ID of the tax id to delete
337 * @param null|array $params
338 * @param null|array|string $opts
339 *
340 * @throws \Stripe\Exception\ApiErrorException if the request fails
341 *
342 * @return \Stripe\TaxId
343 */
344 public static function deleteTaxId($id, $taxIdId, $params = null, $opts = null)
345 {
346 return self::_deleteNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
347 }
348
349 /**
350 * @param string $id the ID of the customer to which the tax id belongs
351 * @param string $taxIdId the ID of the tax id to retrieve
352 * @param null|array $params
353 * @param null|array|string $opts
354 *
355 * @throws \Stripe\Exception\ApiErrorException if the request fails
356 *
357 * @return \Stripe\TaxId
358 */
359 public static function retrieveTaxId($id, $taxIdId, $params = null, $opts = null)
360 {
361 return self::_retrieveNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
362 }
363 }
364