• 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

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

3
// File generated from our OpenAPI spec
4

5
namespace Stripe\Service;
6

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

26
    /**
27
     * When retrieving an invoice, you’ll get a <strong>lines</strong> property
28
     * containing the total count of line items and the first handful of those items.
29
     * There is also a URL where you can retrieve the full (paginated) list of line
30
     * items.
31
     *
32
     * @param string $parentId
33
     * @param null|array $params
34
     * @param null|array|\Stripe\Util\RequestOptions $opts
35
     *
36
     * @throws \Stripe\Exception\ApiErrorException if the request fails
37
     *
38
     * @return \Stripe\Collection<\Stripe\InvoiceLineItem>
39
     */
40
    public function allLines($parentId, $params = null, $opts = null)
1✔
41
    {
42
        return $this->requestCollection('get', $this->buildPath('/v1/invoices/%s/lines', $parentId), $params, $opts);
1✔
43
    }
44

45
    /**
46
     * This endpoint creates a draft invoice for a given customer. The invoice remains
47
     * a draft until you <a href="#finalize_invoice">finalize</a> the invoice, which
48
     * allows you to <a href="#pay_invoice">pay</a> or <a href="#send_invoice">send</a>
49
     * the invoice to your customers.
50
     *
51
     * @param null|array $params
52
     * @param null|array|\Stripe\Util\RequestOptions $opts
53
     *
54
     * @throws \Stripe\Exception\ApiErrorException if the request fails
55
     *
56
     * @return \Stripe\Invoice
57
     */
58
    public function create($params = null, $opts = null)
1✔
59
    {
60
        return $this->request('post', '/v1/invoices', $params, $opts);
1✔
61
    }
62

63
    /**
64
     * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to
65
     * delete invoices that are no longer in a draft state will fail; once an invoice
66
     * has been finalized or if an invoice is for a subscription, it must be <a
67
     * href="#void_invoice">voided</a>.
68
     *
69
     * @param string $id
70
     * @param null|array $params
71
     * @param null|array|\Stripe\Util\RequestOptions $opts
72
     *
73
     * @throws \Stripe\Exception\ApiErrorException if the request fails
74
     *
75
     * @return \Stripe\Invoice
76
     */
77
    public function delete($id, $params = null, $opts = null)
1✔
78
    {
79
        return $this->request('delete', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
80
    }
81

82
    /**
83
     * Stripe automatically finalizes drafts before sending and attempting payment on
84
     * invoices. However, if you’d like to finalize a draft invoice manually, you can
85
     * do so using this method.
86
     *
87
     * @param string $id
88
     * @param null|array $params
89
     * @param null|array|\Stripe\Util\RequestOptions $opts
90
     *
91
     * @throws \Stripe\Exception\ApiErrorException if the request fails
92
     *
93
     * @return \Stripe\Invoice
94
     */
95
    public function finalizeInvoice($id, $params = null, $opts = null)
1✔
96
    {
97
        return $this->request('post', $this->buildPath('/v1/invoices/%s/finalize', $id), $params, $opts);
1✔
98
    }
99

100
    /**
101
     * Marking an invoice as uncollectible is useful for keeping track of bad debts
102
     * that can be written off for accounting purposes.
103
     *
104
     * @param string $id
105
     * @param null|array $params
106
     * @param null|array|\Stripe\Util\RequestOptions $opts
107
     *
108
     * @throws \Stripe\Exception\ApiErrorException if the request fails
109
     *
110
     * @return \Stripe\Invoice
111
     */
112
    public function markUncollectible($id, $params = null, $opts = null)
1✔
113
    {
114
        return $this->request('post', $this->buildPath('/v1/invoices/%s/mark_uncollectible', $id), $params, $opts);
1✔
115
    }
116

117
    /**
118
     * Stripe automatically creates and then attempts to collect payment on invoices
119
     * for customers on subscriptions according to your <a
120
     * href="https://dashboard.stripe.com/account/billing/automatic">subscriptions
121
     * settings</a>. However, if you’d like to attempt payment on an invoice out of the
122
     * normal collection schedule or for some other reason, you can do so.
123
     *
124
     * @param string $id
125
     * @param null|array $params
126
     * @param null|array|\Stripe\Util\RequestOptions $opts
127
     *
128
     * @throws \Stripe\Exception\ApiErrorException if the request fails
129
     *
130
     * @return \Stripe\Invoice
131
     */
132
    public function pay($id, $params = null, $opts = null)
1✔
133
    {
134
        return $this->request('post', $this->buildPath('/v1/invoices/%s/pay', $id), $params, $opts);
1✔
135
    }
136

137
    /**
138
     * Retrieves the invoice with the given ID.
139
     *
140
     * @param string $id
141
     * @param null|array $params
142
     * @param null|array|\Stripe\Util\RequestOptions $opts
143
     *
144
     * @throws \Stripe\Exception\ApiErrorException if the request fails
145
     *
146
     * @return \Stripe\Invoice
147
     */
148
    public function retrieve($id, $params = null, $opts = null)
1✔
149
    {
150
        return $this->request('get', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
151
    }
152

153
    /**
154
     * Search for invoices you’ve previously created using Stripe’s <a
155
     * href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
156
     * search in read-after-write flows where strict consistency is necessary. Under
157
     * normal operating conditions, data is searchable in less than a minute.
158
     * Occasionally, propagation of new or updated data can be up to an hour behind
159
     * during outages. Search functionality is not available to merchants in India.
160
     *
161
     * @param null|array $params
162
     * @param null|array|\Stripe\Util\RequestOptions $opts
163
     *
164
     * @throws \Stripe\Exception\ApiErrorException if the request fails
165
     *
166
     * @return \Stripe\SearchResult<\Stripe\Invoice>
167
     */
168
    public function search($params = null, $opts = null)
×
169
    {
170
        return $this->requestSearchResult('get', '/v1/invoices/search', $params, $opts);
×
171
    }
172

173
    /**
174
     * Stripe will automatically send invoices to customers according to your <a
175
     * href="https://dashboard.stripe.com/account/billing/automatic">subscriptions
176
     * settings</a>. However, if you’d like to manually send an invoice to your
177
     * customer out of the normal schedule, you can do so. When sending invoices that
178
     * have already been paid, there will be no reference to the payment in the email.
179
     *
180
     * Requests made in test-mode result in no emails being sent, despite sending an
181
     * <code>invoice.sent</code> event.
182
     *
183
     * @param string $id
184
     * @param null|array $params
185
     * @param null|array|\Stripe\Util\RequestOptions $opts
186
     *
187
     * @throws \Stripe\Exception\ApiErrorException if the request fails
188
     *
189
     * @return \Stripe\Invoice
190
     */
191
    public function sendInvoice($id, $params = null, $opts = null)
1✔
192
    {
193
        return $this->request('post', $this->buildPath('/v1/invoices/%s/send', $id), $params, $opts);
1✔
194
    }
195

196
    /**
197
     * At any time, you can preview the upcoming invoice for a customer. This will show
198
     * you all the charges that are pending, including subscription renewal charges,
199
     * invoice item charges, etc. It will also show you any discounts that are
200
     * applicable to the invoice.
201
     *
202
     * Note that when you are viewing an upcoming invoice, you are simply viewing a
203
     * preview – the invoice has not yet been created. As such, the upcoming invoice
204
     * will not show up in invoice listing calls, and you cannot use the API to pay or
205
     * edit the invoice. If you want to change the amount that your customer will be
206
     * billed, you can add, remove, or update pending invoice items, or update the
207
     * customer’s discount.
208
     *
209
     * You can preview the effects of updating a subscription, including a preview of
210
     * what proration will take place. To ensure that the actual proration is
211
     * calculated exactly the same as the previewed proration, you should pass a
212
     * <code>proration_date</code> parameter when doing the actual subscription update.
213
     * The value passed in should be the same as the
214
     * <code>subscription_proration_date</code> returned on the upcoming invoice
215
     * resource. The recommended way to get only the prorations being previewed is to
216
     * consider only proration line items where <code>period[start]</code> is equal to
217
     * the <code>subscription_proration_date</code> on the upcoming invoice resource.
218
     *
219
     * @param null|array $params
220
     * @param null|array|\Stripe\Util\RequestOptions $opts
221
     *
222
     * @throws \Stripe\Exception\ApiErrorException if the request fails
223
     *
224
     * @return \Stripe\Invoice
225
     */
226
    public function upcoming($params = null, $opts = null)
1✔
227
    {
228
        return $this->request('get', '/v1/invoices/upcoming', $params, $opts);
1✔
229
    }
230

231
    /**
232
     * When retrieving an upcoming invoice, you’ll get a <strong>lines</strong>
233
     * property containing the total count of line items and the first handful of those
234
     * items. There is also a URL where you can retrieve the full (paginated) list of
235
     * line items.
236
     *
237
     * @param null|array $params
238
     * @param null|array|\Stripe\Util\RequestOptions $opts
239
     *
240
     * @throws \Stripe\Exception\ApiErrorException if the request fails
241
     *
242
     * @return \Stripe\Collection<\Stripe\InvoiceLineItem>
243
     */
244
    public function upcomingLines($params = null, $opts = null)
1✔
245
    {
246
        return $this->requestCollection('get', '/v1/invoices/upcoming/lines', $params, $opts);
1✔
247
    }
248

249
    /**
250
     * Draft invoices are fully editable. Once an invoice is <a
251
     * href="/docs/billing/invoices/workflow#finalized">finalized</a>, monetary values,
252
     * as well as <code>collection_method</code>, become uneditable.
253
     *
254
     * If you would like to stop the Stripe Billing engine from automatically
255
     * finalizing, reattempting payments on, sending reminders for, or <a
256
     * href="/docs/billing/invoices/reconciliation">automatically reconciling</a>
257
     * invoices, pass <code>auto_advance=false</code>.
258
     *
259
     * @param string $id
260
     * @param null|array $params
261
     * @param null|array|\Stripe\Util\RequestOptions $opts
262
     *
263
     * @throws \Stripe\Exception\ApiErrorException if the request fails
264
     *
265
     * @return \Stripe\Invoice
266
     */
267
    public function update($id, $params = null, $opts = null)
1✔
268
    {
269
        return $this->request('post', $this->buildPath('/v1/invoices/%s', $id), $params, $opts);
1✔
270
    }
271

272
    /**
273
     * Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is
274
     * similar to <a href="#delete_invoice">deletion</a>, however it only applies to
275
     * finalized invoices and maintains a papertrail where the invoice can still be
276
     * found.
277
     *
278
     * @param string $id
279
     * @param null|array $params
280
     * @param null|array|\Stripe\Util\RequestOptions $opts
281
     *
282
     * @throws \Stripe\Exception\ApiErrorException if the request fails
283
     *
284
     * @return \Stripe\Invoice
285
     */
286
    public function voidInvoice($id, $params = null, $opts = null)
1✔
287
    {
288
        return $this->request('post', $this->buildPath('/v1/invoices/%s/void', $id), $params, $opts);
1✔
289
    }
290
}
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