• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / 6471862601

10 Oct 2023 04:02PM UTC coverage: 69.665% (-0.5%) from 70.141%
6471862601

push

github

web-flow
Merge pull request #1570 from localheinz/feature/coveralls

Enhancement: Use `coverallsapp/github-action` to report code coverage

2393 of 3435 relevant lines covered (69.67%)

3.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/lib/Service/CustomerService.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe\Service;
6

7
class CustomerService extends \Stripe\Service\AbstractService
8
{
9
    /**
10
     * Returns a list of your customers. The customers are returned sorted by creation
11
     * date, with the most recent customers appearing first.
12
     *
13
     * @param null|array $params
14
     * @param null|array|\Stripe\Util\RequestOptions $opts
15
     *
16
     * @throws \Stripe\Exception\ApiErrorException if the request fails
17
     *
18
     * @return \Stripe\Collection<\Stripe\Customer>
19
     */
20
    public function all($params = null, $opts = null)
1✔
21
    {
22
        return $this->requestCollection('get', '/v1/customers', $params, $opts);
1✔
23
    }
24

25
    /**
26
     * Returns a list of transactions that updated the customer’s <a
27
     * href="/docs/billing/customer/balance">balances</a>.
28
     *
29
     * @param string $parentId
30
     * @param null|array $params
31
     * @param null|array|\Stripe\Util\RequestOptions $opts
32
     *
33
     * @throws \Stripe\Exception\ApiErrorException if the request fails
34
     *
35
     * @return \Stripe\Collection<\Stripe\CustomerBalanceTransaction>
36
     */
37
    public function allBalanceTransactions($parentId, $params = null, $opts = null)
1✔
38
    {
39
        return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts);
1✔
40
    }
41

42
    /**
43
     * Returns a list of transactions that modified the customer’s <a
44
     * href="/docs/payments/customer-balance">cash balance</a>.
45
     *
46
     * @param string $parentId
47
     * @param null|array $params
48
     * @param null|array|\Stripe\Util\RequestOptions $opts
49
     *
50
     * @throws \Stripe\Exception\ApiErrorException if the request fails
51
     *
52
     * @return \Stripe\Collection<\Stripe\CustomerCashBalanceTransaction>
53
     */
54
    public function allCashBalanceTransactions($parentId, $params = null, $opts = null)
×
55
    {
56
        return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions', $parentId), $params, $opts);
×
57
    }
58

59
    /**
60
     * Returns a list of PaymentMethods for a given Customer.
61
     *
62
     * @param string $id
63
     * @param null|array $params
64
     * @param null|array|\Stripe\Util\RequestOptions $opts
65
     *
66
     * @throws \Stripe\Exception\ApiErrorException if the request fails
67
     *
68
     * @return \Stripe\Collection<\Stripe\PaymentMethod>
69
     */
70
    public function allPaymentMethods($id, $params = null, $opts = null)
×
71
    {
72
        return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/payment_methods', $id), $params, $opts);
×
73
    }
74

75
    /**
76
     * List sources for a specified customer.
77
     *
78
     * @param string $parentId
79
     * @param null|array $params
80
     * @param null|array|\Stripe\Util\RequestOptions $opts
81
     *
82
     * @throws \Stripe\Exception\ApiErrorException if the request fails
83
     *
84
     * @return \Stripe\Collection<\Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source>
85
     */
86
    public function allSources($parentId, $params = null, $opts = null)
1✔
87
    {
88
        return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/sources', $parentId), $params, $opts);
1✔
89
    }
90

91
    /**
92
     * Returns a list of tax IDs for a customer.
93
     *
94
     * @param string $parentId
95
     * @param null|array $params
96
     * @param null|array|\Stripe\Util\RequestOptions $opts
97
     *
98
     * @throws \Stripe\Exception\ApiErrorException if the request fails
99
     *
100
     * @return \Stripe\Collection<\Stripe\TaxId>
101
     */
102
    public function allTaxIds($parentId, $params = null, $opts = null)
1✔
103
    {
104
        return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/tax_ids', $parentId), $params, $opts);
1✔
105
    }
106

107
    /**
108
     * Creates a new customer object.
109
     *
110
     * @param null|array $params
111
     * @param null|array|\Stripe\Util\RequestOptions $opts
112
     *
113
     * @throws \Stripe\Exception\ApiErrorException if the request fails
114
     *
115
     * @return \Stripe\Customer
116
     */
117
    public function create($params = null, $opts = null)
1✔
118
    {
119
        return $this->request('post', '/v1/customers', $params, $opts);
1✔
120
    }
121

122
    /**
123
     * Creates an immutable transaction that updates the customer’s credit <a
124
     * href="/docs/billing/customer/balance">balance</a>.
125
     *
126
     * @param string $parentId
127
     * @param null|array $params
128
     * @param null|array|\Stripe\Util\RequestOptions $opts
129
     *
130
     * @throws \Stripe\Exception\ApiErrorException if the request fails
131
     *
132
     * @return \Stripe\CustomerBalanceTransaction
133
     */
134
    public function createBalanceTransaction($parentId, $params = null, $opts = null)
1✔
135
    {
136
        return $this->request('post', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts);
1✔
137
    }
138

139
    /**
140
     * Retrieve funding instructions for a customer cash balance. If funding
141
     * instructions do not yet exist for the customer, new funding instructions will be
142
     * created. If funding instructions have already been created for a given customer,
143
     * the same funding instructions will be retrieved. In other words, we will return
144
     * the same funding instructions each time.
145
     *
146
     * @param string $id
147
     * @param null|array $params
148
     * @param null|array|\Stripe\Util\RequestOptions $opts
149
     *
150
     * @throws \Stripe\Exception\ApiErrorException if the request fails
151
     *
152
     * @return \Stripe\FundingInstructions
153
     */
154
    public function createFundingInstructions($id, $params = null, $opts = null)
×
155
    {
156
        return $this->request('post', $this->buildPath('/v1/customers/%s/funding_instructions', $id), $params, $opts);
×
157
    }
158

159
    /**
160
     * When you create a new credit card, you must specify a customer or recipient on
161
     * which to create it.
162
     *
163
     * If the card’s owner has no default card, then the new card will become the
164
     * default. However, if the owner already has a default, then it will not change.
165
     * To change the default, you should <a href="/docs/api#update_customer">update the
166
     * customer</a> to have a new <code>default_source</code>.
167
     *
168
     * @param string $parentId
169
     * @param null|array $params
170
     * @param null|array|\Stripe\Util\RequestOptions $opts
171
     *
172
     * @throws \Stripe\Exception\ApiErrorException if the request fails
173
     *
174
     * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
175
     */
176
    public function createSource($parentId, $params = null, $opts = null)
1✔
177
    {
178
        return $this->request('post', $this->buildPath('/v1/customers/%s/sources', $parentId), $params, $opts);
1✔
179
    }
180

181
    /**
182
     * Creates a new <code>tax_id</code> object for a customer.
183
     *
184
     * @param string $parentId
185
     * @param null|array $params
186
     * @param null|array|\Stripe\Util\RequestOptions $opts
187
     *
188
     * @throws \Stripe\Exception\ApiErrorException if the request fails
189
     *
190
     * @return \Stripe\TaxId
191
     */
192
    public function createTaxId($parentId, $params = null, $opts = null)
1✔
193
    {
194
        return $this->request('post', $this->buildPath('/v1/customers/%s/tax_ids', $parentId), $params, $opts);
1✔
195
    }
196

197
    /**
198
     * Permanently deletes a customer. It cannot be undone. Also immediately cancels
199
     * any active subscriptions on the customer.
200
     *
201
     * @param string $id
202
     * @param null|array $params
203
     * @param null|array|\Stripe\Util\RequestOptions $opts
204
     *
205
     * @throws \Stripe\Exception\ApiErrorException if the request fails
206
     *
207
     * @return \Stripe\Customer
208
     */
209
    public function delete($id, $params = null, $opts = null)
1✔
210
    {
211
        return $this->request('delete', $this->buildPath('/v1/customers/%s', $id), $params, $opts);
1✔
212
    }
213

214
    /**
215
     * Removes the currently applied discount on a customer.
216
     *
217
     * @param string $id
218
     * @param null|array $params
219
     * @param null|array|\Stripe\Util\RequestOptions $opts
220
     *
221
     * @throws \Stripe\Exception\ApiErrorException if the request fails
222
     *
223
     * @return \Stripe\Discount
224
     */
225
    public function deleteDiscount($id, $params = null, $opts = null)
1✔
226
    {
227
        return $this->request('delete', $this->buildPath('/v1/customers/%s/discount', $id), $params, $opts);
1✔
228
    }
229

230
    /**
231
     * Delete a specified source for a given customer.
232
     *
233
     * @param string $parentId
234
     * @param string $id
235
     * @param null|array $params
236
     * @param null|array|\Stripe\Util\RequestOptions $opts
237
     *
238
     * @throws \Stripe\Exception\ApiErrorException if the request fails
239
     *
240
     * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
241
     */
242
    public function deleteSource($parentId, $id, $params = null, $opts = null)
1✔
243
    {
244
        return $this->request('delete', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts);
1✔
245
    }
246

247
    /**
248
     * Deletes an existing <code>tax_id</code> object.
249
     *
250
     * @param string $parentId
251
     * @param string $id
252
     * @param null|array $params
253
     * @param null|array|\Stripe\Util\RequestOptions $opts
254
     *
255
     * @throws \Stripe\Exception\ApiErrorException if the request fails
256
     *
257
     * @return \Stripe\TaxId
258
     */
259
    public function deleteTaxId($parentId, $id, $params = null, $opts = null)
1✔
260
    {
261
        return $this->request('delete', $this->buildPath('/v1/customers/%s/tax_ids/%s', $parentId, $id), $params, $opts);
1✔
262
    }
263

264
    /**
265
     * Retrieves a Customer object.
266
     *
267
     * @param string $id
268
     * @param null|array $params
269
     * @param null|array|\Stripe\Util\RequestOptions $opts
270
     *
271
     * @throws \Stripe\Exception\ApiErrorException if the request fails
272
     *
273
     * @return \Stripe\Customer
274
     */
275
    public function retrieve($id, $params = null, $opts = null)
1✔
276
    {
277
        return $this->request('get', $this->buildPath('/v1/customers/%s', $id), $params, $opts);
1✔
278
    }
279

280
    /**
281
     * Retrieves a specific customer balance transaction that updated the customer’s <a
282
     * href="/docs/billing/customer/balance">balances</a>.
283
     *
284
     * @param string $parentId
285
     * @param string $id
286
     * @param null|array $params
287
     * @param null|array|\Stripe\Util\RequestOptions $opts
288
     *
289
     * @throws \Stripe\Exception\ApiErrorException if the request fails
290
     *
291
     * @return \Stripe\CustomerBalanceTransaction
292
     */
293
    public function retrieveBalanceTransaction($parentId, $id, $params = null, $opts = null)
1✔
294
    {
295
        return $this->request('get', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts);
1✔
296
    }
297

298
    /**
299
     * Retrieves a customer’s cash balance.
300
     *
301
     * @param string $parentId
302
     * @param null|array $params
303
     * @param null|array|\Stripe\Util\RequestOptions $opts
304
     *
305
     * @throws \Stripe\Exception\ApiErrorException if the request fails
306
     *
307
     * @return \Stripe\CashBalance
308
     */
309
    public function retrieveCashBalance($parentId, $params = null, $opts = null)
×
310
    {
311
        return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts);
×
312
    }
313

314
    /**
315
     * Retrieves a specific cash balance transaction, which updated the customer’s <a
316
     * href="/docs/payments/customer-balance">cash balance</a>.
317
     *
318
     * @param string $parentId
319
     * @param string $id
320
     * @param null|array $params
321
     * @param null|array|\Stripe\Util\RequestOptions $opts
322
     *
323
     * @throws \Stripe\Exception\ApiErrorException if the request fails
324
     *
325
     * @return \Stripe\CustomerCashBalanceTransaction
326
     */
327
    public function retrieveCashBalanceTransaction($parentId, $id, $params = null, $opts = null)
×
328
    {
329
        return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions/%s', $parentId, $id), $params, $opts);
×
330
    }
331

332
    /**
333
     * Retrieves a PaymentMethod object for a given Customer.
334
     *
335
     * @param string $parentId
336
     * @param string $id
337
     * @param null|array $params
338
     * @param null|array|\Stripe\Util\RequestOptions $opts
339
     *
340
     * @throws \Stripe\Exception\ApiErrorException if the request fails
341
     *
342
     * @return \Stripe\PaymentMethod
343
     */
344
    public function retrievePaymentMethod($parentId, $id, $params = null, $opts = null)
×
345
    {
346
        return $this->request('get', $this->buildPath('/v1/customers/%s/payment_methods/%s', $parentId, $id), $params, $opts);
×
347
    }
348

349
    /**
350
     * Retrieve a specified source for a given customer.
351
     *
352
     * @param string $parentId
353
     * @param string $id
354
     * @param null|array $params
355
     * @param null|array|\Stripe\Util\RequestOptions $opts
356
     *
357
     * @throws \Stripe\Exception\ApiErrorException if the request fails
358
     *
359
     * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
360
     */
361
    public function retrieveSource($parentId, $id, $params = null, $opts = null)
1✔
362
    {
363
        return $this->request('get', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts);
1✔
364
    }
365

366
    /**
367
     * Retrieves the <code>tax_id</code> object with the given identifier.
368
     *
369
     * @param string $parentId
370
     * @param string $id
371
     * @param null|array $params
372
     * @param null|array|\Stripe\Util\RequestOptions $opts
373
     *
374
     * @throws \Stripe\Exception\ApiErrorException if the request fails
375
     *
376
     * @return \Stripe\TaxId
377
     */
378
    public function retrieveTaxId($parentId, $id, $params = null, $opts = null)
1✔
379
    {
380
        return $this->request('get', $this->buildPath('/v1/customers/%s/tax_ids/%s', $parentId, $id), $params, $opts);
1✔
381
    }
382

383
    /**
384
     * Search for customers you’ve previously created using Stripe’s <a
385
     * href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
386
     * search in read-after-write flows where strict consistency is necessary. Under
387
     * normal operating conditions, data is searchable in less than a minute.
388
     * Occasionally, propagation of new or updated data can be up to an hour behind
389
     * during outages. Search functionality is not available to merchants in India.
390
     *
391
     * @param null|array $params
392
     * @param null|array|\Stripe\Util\RequestOptions $opts
393
     *
394
     * @throws \Stripe\Exception\ApiErrorException if the request fails
395
     *
396
     * @return \Stripe\SearchResult<\Stripe\Customer>
397
     */
398
    public function search($params = null, $opts = null)
×
399
    {
400
        return $this->requestSearchResult('get', '/v1/customers/search', $params, $opts);
×
401
    }
402

403
    /**
404
     * Updates the specified customer by setting the values of the parameters passed.
405
     * Any parameters not provided will be left unchanged. For example, if you pass the
406
     * <strong>source</strong> parameter, that becomes the customer’s active source
407
     * (e.g., a card) to be used for all charges in the future. When you update a
408
     * customer to a new valid card source by passing the <strong>source</strong>
409
     * parameter: for each of the customer’s current subscriptions, if the subscription
410
     * bills automatically and is in the <code>past_due</code> state, then the latest
411
     * open invoice for the subscription with automatic collection enabled will be
412
     * retried. This retry will not count as an automatic retry, and will not affect
413
     * the next regularly scheduled payment for the invoice. Changing the
414
     * <strong>default_source</strong> for a customer will not trigger this behavior.
415
     *
416
     * This request accepts mostly the same arguments as the customer creation call.
417
     *
418
     * @param string $id
419
     * @param null|array $params
420
     * @param null|array|\Stripe\Util\RequestOptions $opts
421
     *
422
     * @throws \Stripe\Exception\ApiErrorException if the request fails
423
     *
424
     * @return \Stripe\Customer
425
     */
426
    public function update($id, $params = null, $opts = null)
1✔
427
    {
428
        return $this->request('post', $this->buildPath('/v1/customers/%s', $id), $params, $opts);
1✔
429
    }
430

431
    /**
432
     * Most credit balance transaction fields are immutable, but you may update its
433
     * <code>description</code> and <code>metadata</code>.
434
     *
435
     * @param string $parentId
436
     * @param string $id
437
     * @param null|array $params
438
     * @param null|array|\Stripe\Util\RequestOptions $opts
439
     *
440
     * @throws \Stripe\Exception\ApiErrorException if the request fails
441
     *
442
     * @return \Stripe\CustomerBalanceTransaction
443
     */
444
    public function updateBalanceTransaction($parentId, $id, $params = null, $opts = null)
1✔
445
    {
446
        return $this->request('post', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts);
1✔
447
    }
448

449
    /**
450
     * Changes the settings on a customer’s cash balance.
451
     *
452
     * @param string $parentId
453
     * @param null|array $params
454
     * @param null|array|\Stripe\Util\RequestOptions $opts
455
     *
456
     * @throws \Stripe\Exception\ApiErrorException if the request fails
457
     *
458
     * @return \Stripe\CashBalance
459
     */
460
    public function updateCashBalance($parentId, $params = null, $opts = null)
×
461
    {
462
        return $this->request('post', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts);
×
463
    }
464

465
    /**
466
     * Update a specified source for a given customer.
467
     *
468
     * @param string $parentId
469
     * @param string $id
470
     * @param null|array $params
471
     * @param null|array|\Stripe\Util\RequestOptions $opts
472
     *
473
     * @throws \Stripe\Exception\ApiErrorException if the request fails
474
     *
475
     * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
476
     */
477
    public function updateSource($parentId, $id, $params = null, $opts = null)
1✔
478
    {
479
        return $this->request('post', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts);
1✔
480
    }
481

482
    /**
483
     * Verify a specified bank account for a given customer.
484
     *
485
     * @param string $parentId
486
     * @param string $id
487
     * @param null|array $params
488
     * @param null|array|\Stripe\Util\RequestOptions $opts
489
     *
490
     * @throws \Stripe\Exception\ApiErrorException if the request fails
491
     *
492
     * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
493
     */
494
    public function verifySource($parentId, $id, $params = null, $opts = null)
1✔
495
    {
496
        return $this->request('post', $this->buildPath('/v1/customers/%s/sources/%s/verify', $parentId, $id), $params, $opts);
1✔
497
    }
498
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc