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

stripe / stripe-php / 9769699544

03 Jul 2024 12:14AM UTC coverage: 64.957% (-0.3%) from 65.215%
9769699544

Pull #1718

github

web-flow
Merge bb28d8052 into 96f0dbe9c
Pull Request #1718: Update generated code

0 of 21 new or added lines in 2 files covered. (0.0%)

12 existing lines in 1 file now uncovered.

3444 of 5302 relevant lines covered (64.96%)

2.28 hits per line

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

68.42
/lib/Service/InvoiceService.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe\Service;
6

7
/**
8
 * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
9
 * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
10
 */
11
class InvoiceService extends \Stripe\Service\AbstractService
12
{
13
    /**
14
     * Adds multiple line items to an invoice. This is only possible when an invoice is
15
     * still a draft.
16
     *
17
     * @param string $id
18
     * @param null|array $params
19
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
20
     *
21
     * @throws \Stripe\Exception\ApiErrorException if the request fails
22
     *
23
     * @return \Stripe\Invoice
24
     */
NEW
25
    public function addLines($id, $params = null, $opts = null)
×
26
    {
NEW
27
        return $this->request('post', $this->buildPath('/v1/invoices/%s/add_lines', $id), $params, $opts);
×
28
    }
29

30
    /**
31
     * You can list all invoices, or list the invoices for a specific customer. The
32
     * invoices are returned sorted by creation date, with the most recently created
33
     * invoices appearing first.
34
     *
35
     * @param null|array $params
36
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
37
     *
38
     * @throws \Stripe\Exception\ApiErrorException if the request fails
39
     *
40
     * @return \Stripe\Collection<\Stripe\Invoice>
41
     */
42
    public function all($params = null, $opts = null)
1✔
43
    {
44
        return $this->requestCollection('get', '/v1/invoices', $params, $opts);
1✔
45
    }
46

47
    /**
48
     * When retrieving an invoice, you’ll get a <strong>lines</strong> property
49
     * containing the total count of line items and the first handful of those items.
50
     * There is also a URL where you can retrieve the full (paginated) list of line
51
     * items.
52
     *
53
     * @param string $parentId
54
     * @param null|array $params
55
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
56
     *
57
     * @throws \Stripe\Exception\ApiErrorException if the request fails
58
     *
59
     * @return \Stripe\Collection<\Stripe\InvoiceLineItem>
60
     */
61
    public function allLines($parentId, $params = null, $opts = null)
1✔
62
    {
63
        return $this->requestCollection('get', $this->buildPath('/v1/invoices/%s/lines', $parentId), $params, $opts);
1✔
64
    }
65

66
    /**
67
     * This endpoint creates a draft invoice for a given customer. The invoice remains
68
     * a draft until you <a href="#finalize_invoice">finalize</a> the invoice, which
69
     * allows you to <a href="#pay_invoice">pay</a> or <a href="#send_invoice">send</a>
70
     * the invoice to your customers.
71
     *
72
     * @param null|array $params
73
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
74
     *
75
     * @throws \Stripe\Exception\ApiErrorException if the request fails
76
     *
77
     * @return \Stripe\Invoice
78
     */
79
    public function create($params = null, $opts = null)
1✔
80
    {
81
        return $this->request('post', '/v1/invoices', $params, $opts);
1✔
82
    }
83

84
    /**
85
     * At any time, you can preview the upcoming invoice for a customer. This will show
86
     * you all the charges that are pending, including subscription renewal charges,
87
     * invoice item charges, etc. It will also show you any discounts that are
88
     * applicable to the invoice.
89
     *
90
     * Note that when you are viewing an upcoming invoice, you are simply viewing a
91
     * preview – the invoice has not yet been created. As such, the upcoming invoice
92
     * will not show up in invoice listing calls, and you cannot use the API to pay or
93
     * edit the invoice. If you want to change the amount that your customer will be
94
     * billed, you can add, remove, or update pending invoice items, or update the
95
     * customer’s discount.
96
     *
97
     * You can preview the effects of updating a subscription, including a preview of
98
     * what proration will take place. To ensure that the actual proration is
99
     * calculated exactly the same as the previewed proration, you should pass the
100
     * <code>subscription_details.proration_date</code> parameter when doing the actual
101
     * subscription update. The recommended way to get only the prorations being
102
     * previewed is to consider only proration line items where
103
     * <code>period[start]</code> is equal to the
104
     * <code>subscription_details.proration_date</code> value passed in the request.
105
     *
106
     * Note: Currency conversion calculations use the latest exchange rates. Exchange
107
     * rates may vary between the time of the preview and the time of the actual
108
     * invoice creation. <a href="https://docs.stripe.com/currencies/conversions">Learn
109
     * more</a>
110
     *
111
     * @param null|array $params
112
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
113
     *
114
     * @throws \Stripe\Exception\ApiErrorException if the request fails
115
     *
116
     * @return \Stripe\Invoice
117
     */
118
    public function createPreview($params = null, $opts = null)
×
119
    {
120
        return $this->request('post', '/v1/invoices/create_preview', $params, $opts);
×
121
    }
122

123
    /**
124
     * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to
125
     * delete invoices that are no longer in a draft state will fail; once an invoice
126
     * has been finalized or if an invoice is for a subscription, it must be <a
127
     * href="#void_invoice">voided</a>.
128
     *
129
     * @param string $id
130
     * @param null|array $params
131
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
132
     *
133
     * @throws \Stripe\Exception\ApiErrorException if the request fails
134
     *
135
     * @return \Stripe\Invoice
136
     */
137
    public function delete($id, $params = null, $opts = null)
1✔
138
    {
139
        return $this->request('delete', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
140
    }
141

142
    /**
143
     * Stripe automatically finalizes drafts before sending and attempting payment on
144
     * invoices. However, if you’d like to finalize a draft invoice manually, you can
145
     * do so using this method.
146
     *
147
     * @param string $id
148
     * @param null|array $params
149
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
150
     *
151
     * @throws \Stripe\Exception\ApiErrorException if the request fails
152
     *
153
     * @return \Stripe\Invoice
154
     */
155
    public function finalizeInvoice($id, $params = null, $opts = null)
1✔
156
    {
157
        return $this->request('post', $this->buildPath('/v1/invoices/%s/finalize', $id), $params, $opts);
1✔
158
    }
159

160
    /**
161
     * Marking an invoice as uncollectible is useful for keeping track of bad debts
162
     * that can be written off for accounting purposes.
163
     *
164
     * @param string $id
165
     * @param null|array $params
166
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
167
     *
168
     * @throws \Stripe\Exception\ApiErrorException if the request fails
169
     *
170
     * @return \Stripe\Invoice
171
     */
172
    public function markUncollectible($id, $params = null, $opts = null)
1✔
173
    {
174
        return $this->request('post', $this->buildPath('/v1/invoices/%s/mark_uncollectible', $id), $params, $opts);
1✔
175
    }
176

177
    /**
178
     * Stripe automatically creates and then attempts to collect payment on invoices
179
     * for customers on subscriptions according to your <a
180
     * href="https://dashboard.stripe.com/account/billing/automatic">subscriptions
181
     * settings</a>. However, if you’d like to attempt payment on an invoice out of the
182
     * normal collection schedule or for some other reason, you can do so.
183
     *
184
     * @param string $id
185
     * @param null|array $params
186
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
187
     *
188
     * @throws \Stripe\Exception\ApiErrorException if the request fails
189
     *
190
     * @return \Stripe\Invoice
191
     */
192
    public function pay($id, $params = null, $opts = null)
1✔
193
    {
194
        return $this->request('post', $this->buildPath('/v1/invoices/%s/pay', $id), $params, $opts);
1✔
195
    }
196

197
    /**
198
     * Removes multiple line items from an invoice. This is only possible when an
199
     * invoice is still a draft.
200
     *
201
     * @param string $id
202
     * @param null|array $params
203
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
204
     *
205
     * @throws \Stripe\Exception\ApiErrorException if the request fails
206
     *
207
     * @return \Stripe\Invoice
208
     */
NEW
209
    public function removeLines($id, $params = null, $opts = null)
×
210
    {
NEW
211
        return $this->request('post', $this->buildPath('/v1/invoices/%s/remove_lines', $id), $params, $opts);
×
212
    }
213

214
    /**
215
     * Retrieves the invoice with the given ID.
216
     *
217
     * @param string $id
218
     * @param null|array $params
219
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
220
     *
221
     * @throws \Stripe\Exception\ApiErrorException if the request fails
222
     *
223
     * @return \Stripe\Invoice
224
     */
225
    public function retrieve($id, $params = null, $opts = null)
1✔
226
    {
227
        return $this->request('get', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
228
    }
229

230
    /**
231
     * Search for invoices you’ve previously created using Stripe’s <a
232
     * href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
233
     * search in read-after-write flows where strict consistency is necessary. Under
234
     * normal operating conditions, data is searchable in less than a minute.
235
     * Occasionally, propagation of new or updated data can be up to an hour behind
236
     * during outages. Search functionality is not available to merchants in India.
237
     *
238
     * @param null|array $params
239
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
240
     *
241
     * @throws \Stripe\Exception\ApiErrorException if the request fails
242
     *
243
     * @return \Stripe\SearchResult<\Stripe\Invoice>
244
     */
245
    public function search($params = null, $opts = null)
×
246
    {
247
        return $this->requestSearchResult('get', '/v1/invoices/search', $params, $opts);
×
248
    }
249

250
    /**
251
     * Stripe will automatically send invoices to customers according to your <a
252
     * href="https://dashboard.stripe.com/account/billing/automatic">subscriptions
253
     * settings</a>. However, if you’d like to manually send an invoice to your
254
     * customer out of the normal schedule, you can do so. When sending invoices that
255
     * have already been paid, there will be no reference to the payment in the email.
256
     *
257
     * Requests made in test-mode result in no emails being sent, despite sending an
258
     * <code>invoice.sent</code> event.
259
     *
260
     * @param string $id
261
     * @param null|array $params
262
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
263
     *
264
     * @throws \Stripe\Exception\ApiErrorException if the request fails
265
     *
266
     * @return \Stripe\Invoice
267
     */
268
    public function sendInvoice($id, $params = null, $opts = null)
1✔
269
    {
270
        return $this->request('post', $this->buildPath('/v1/invoices/%s/send', $id), $params, $opts);
1✔
271
    }
272

273
    /**
274
     * At any time, you can preview the upcoming invoice for a customer. This will show
275
     * you all the charges that are pending, including subscription renewal charges,
276
     * invoice item charges, etc. It will also show you any discounts that are
277
     * applicable to the invoice.
278
     *
279
     * Note that when you are viewing an upcoming invoice, you are simply viewing a
280
     * preview – the invoice has not yet been created. As such, the upcoming invoice
281
     * will not show up in invoice listing calls, and you cannot use the API to pay or
282
     * edit the invoice. If you want to change the amount that your customer will be
283
     * billed, you can add, remove, or update pending invoice items, or update the
284
     * customer’s discount.
285
     *
286
     * You can preview the effects of updating a subscription, including a preview of
287
     * what proration will take place. To ensure that the actual proration is
288
     * calculated exactly the same as the previewed proration, you should pass the
289
     * <code>subscription_details.proration_date</code> parameter when doing the actual
290
     * subscription update. The recommended way to get only the prorations being
291
     * previewed is to consider only proration line items where
292
     * <code>period[start]</code> is equal to the
293
     * <code>subscription_details.proration_date</code> value passed in the request.
294
     *
295
     * Note: Currency conversion calculations use the latest exchange rates. Exchange
296
     * rates may vary between the time of the preview and the time of the actual
297
     * invoice creation. <a href="https://docs.stripe.com/currencies/conversions">Learn
298
     * more</a>
299
     *
300
     * @param null|array $params
301
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
302
     *
303
     * @throws \Stripe\Exception\ApiErrorException if the request fails
304
     *
305
     * @return \Stripe\Invoice
306
     */
307
    public function upcoming($params = null, $opts = null)
1✔
308
    {
309
        return $this->request('get', '/v1/invoices/upcoming', $params, $opts);
1✔
310
    }
311

312
    /**
313
     * When retrieving an upcoming invoice, you’ll get a <strong>lines</strong>
314
     * property containing the total count of line items and the first handful of those
315
     * items. There is also a URL where you can retrieve the full (paginated) list of
316
     * line items.
317
     *
318
     * @param null|array $params
319
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
320
     *
321
     * @throws \Stripe\Exception\ApiErrorException if the request fails
322
     *
323
     * @return \Stripe\Collection<\Stripe\InvoiceLineItem>
324
     */
325
    public function upcomingLines($params = null, $opts = null)
1✔
326
    {
327
        return $this->requestCollection('get', '/v1/invoices/upcoming/lines', $params, $opts);
1✔
328
    }
329

330
    /**
331
     * Draft invoices are fully editable. Once an invoice is <a
332
     * href="/docs/billing/invoices/workflow#finalized">finalized</a>, monetary values,
333
     * as well as <code>collection_method</code>, become uneditable.
334
     *
335
     * If you would like to stop the Stripe Billing engine from automatically
336
     * finalizing, reattempting payments on, sending reminders for, or <a
337
     * href="/docs/billing/invoices/reconciliation">automatically reconciling</a>
338
     * invoices, pass <code>auto_advance=false</code>.
339
     *
340
     * @param string $id
341
     * @param null|array $params
342
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
343
     *
344
     * @throws \Stripe\Exception\ApiErrorException if the request fails
345
     *
346
     * @return \Stripe\Invoice
347
     */
348
    public function update($id, $params = null, $opts = null)
1✔
349
    {
350
        return $this->request('post', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
351
    }
352

353
    /**
354
     * Updates an invoice’s line item. Some fields, such as <code>tax_amounts</code>,
355
     * only live on the invoice line item, so they can only be updated through this
356
     * endpoint. Other fields, such as <code>amount</code>, live on both the invoice
357
     * item and the invoice line item, so updates on this endpoint will propagate to
358
     * the invoice item as well. Updating an invoice’s line item is only possible
359
     * before the invoice is finalized.
360
     *
361
     * @param string $parentId
362
     * @param string $id
363
     * @param null|array $params
364
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
365
     *
366
     * @throws \Stripe\Exception\ApiErrorException if the request fails
367
     *
368
     * @return \Stripe\InvoiceLineItem
369
     */
370
    public function updateLine($parentId, $id, $params = null, $opts = null)
×
371
    {
372
        return $this->request('post', $this->buildPath('/v1/invoices/%s/lines/%s', $parentId, $id), $params, $opts);
×
373
    }
374

375
    /**
376
     * Updates multiple line items on an invoice. This is only possible when an invoice
377
     * is still a draft.
378
     *
379
     * @param string $id
380
     * @param null|array $params
381
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
382
     *
383
     * @throws \Stripe\Exception\ApiErrorException if the request fails
384
     *
385
     * @return \Stripe\Invoice
386
     */
NEW
387
    public function updateLines($id, $params = null, $opts = null)
×
388
    {
NEW
389
        return $this->request('post', $this->buildPath('/v1/invoices/%s/update_lines', $id), $params, $opts);
×
390
    }
391

392
    /**
393
     * Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is
394
     * similar to <a href="#delete_invoice">deletion</a>, however it only applies to
395
     * finalized invoices and maintains a papertrail where the invoice can still be
396
     * found.
397
     *
398
     * Consult with local regulations to determine whether and how an invoice might be
399
     * amended, canceled, or voided in the jurisdiction you’re doing business in. You
400
     * might need to <a href="#create_invoice">issue another invoice</a> or <a
401
     * href="#create_credit_note">credit note</a> instead. Stripe recommends that you
402
     * consult with your legal counsel for advice specific to your business.
403
     *
404
     * @param string $id
405
     * @param null|array $params
406
     * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
407
     *
408
     * @throws \Stripe\Exception\ApiErrorException if the request fails
409
     *
410
     * @return \Stripe\Invoice
411
     */
412
    public function voidInvoice($id, $params = null, $opts = null)
1✔
413
    {
414
        return $this->request('post', $this->buildPath('/v1/invoices/%s/void', $id), $params, $opts);
1✔
415
    }
416
}
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

© 2024 Coveralls, Inc