PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.4
GiveWP – Donation Plugin and Fundraising Platform v4.15.4
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / vendor / stripe / stripe-php / lib / Invoice.php

Invoice.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.4, at vendor/stripe/stripe-php/lib/Invoice.php

284 lines 20.1 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 * Invoices are statements of amounts owed by a customer, and are either generated
9 * one-off, or generated periodically from a subscription.
10 *
11 * They contain <a href="https://stripe.com/docs/api#invoiceitems">invoice
12 * items</a>, and proration adjustments that may be caused by subscription
13 * upgrades/downgrades (if necessary).
14 *
15 * If your invoice is configured to be billed through automatic charges, Stripe
16 * automatically finalizes your invoice and attempts payment. Note that finalizing
17 * the invoice, <a
18 * href="https://stripe.com/docs/billing/invoices/workflow/#auto_advance">when
19 * automatic</a>, does not happen immediately as the invoice is created. Stripe
20 * waits until one hour after the last webhook was successfully sent (or the last
21 * webhook timed out after failing). If you (and the platforms you may have
22 * connected to) have no webhooks configured, Stripe waits one hour after creation
23 * to finalize the invoice.
24 *
25 * If your invoice is configured to be billed by sending an email, then based on
26 * your <a href="https://dashboard.stripe.com/account/billing/automatic">email
27 * settings</a>, Stripe will email the invoice to your customer and await payment.
28 * These emails can contain a link to a hosted page to pay the invoice.
29 *
30 * Stripe applies any customer credit on the account before determining the amount
31 * due for the invoice (i.e., the amount that will be actually charged). If the
32 * amount due for the invoice is less than Stripe's <a
33 * href="/docs/currencies#minimum-and-maximum-charge-amounts">minimum allowed
34 * charge per currency</a>, the invoice is automatically marked paid, and we add
35 * the amount due to the customer's credit balance which is applied to the next
36 * invoice.
37 *
38 * More details on the customer's credit balance are <a
39 * href="https://stripe.com/docs/billing/customer/balance">here</a>.
40 *
41 * Related guide: <a href="https://stripe.com/docs/billing/invoices/sending">Send
42 * Invoices to Customers</a>.
43 *
44 * @property string $id Unique identifier for the object.
45 * @property string $object String representing the object's type. Objects of the same type share the same value.
46 * @property null|string $account_country The country of the business associated with this invoice, most often the business creating the invoice.
47 * @property null|string $account_name The public name of the business associated with this invoice, most often the business creating the invoice.
48 * @property null|(string|\Stripe\TaxId)[] $account_tax_ids The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
49 * @property int $amount_due Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the <code>amount_due</code> may be 0. If there is a positive <code>starting_balance</code> for the invoice (the customer owes money), the <code>amount_due</code> will also take that into account. The charge that gets generated for the invoice will be for the amount specified in <code>amount_due</code>.
50 * @property int $amount_paid The amount, in %s, that was paid.
51 * @property int $amount_remaining The amount remaining, in %s, that is due.
52 * @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the invoice.
53 * @property null|int $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
54 * @property int $attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
55 * @property bool $attempted Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the <code>invoice.created</code> webhook, for example, so you might not want to display that invoice as unpaid to your users.
56 * @property bool $auto_advance Controls whether Stripe will perform <a href="https://stripe.com/docs/billing/invoices/workflow/#auto_advance">automatic collection</a> of the invoice. When <code>false</code>, the invoice's state will not automatically advance without an explicit action.
57 * @property \Stripe\StripeObject $automatic_tax
58 * @property null|string $billing_reason Indicates the reason why the invoice was created. <code>subscription_cycle</code> indicates an invoice created by a subscription advancing into a new period. <code>subscription_create</code> indicates an invoice created due to creating a subscription. <code>subscription_update</code> indicates an invoice created due to updating a subscription. <code>subscription</code> is set for all old invoices to indicate either a change to a subscription or a period advancement. <code>manual</code> is set for all invoices unrelated to a subscription (for example: created via the invoice editor). The <code>upcoming</code> value is reserved for simulated invoices per the upcoming invoice endpoint. <code>subscription_threshold</code> indicates an invoice created due to a billing threshold being reached.
59 * @property null|string|\Stripe\Charge $charge ID of the latest charge generated for this invoice, if any.
60 * @property string $collection_method Either <code>charge_automatically</code>, or <code>send_invoice</code>. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
61 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
62 * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
63 * @property null|\Stripe\StripeObject[] $custom_fields Custom fields displayed on the invoice.
64 * @property null|string|\Stripe\Customer $customer The ID of the customer who will be billed.
65 * @property null|\Stripe\StripeObject $customer_address The customer's address. Until the invoice is finalized, this field will equal <code>customer.address</code>. Once the invoice is finalized, this field will no longer be updated.
66 * @property null|string $customer_email The customer's email. Until the invoice is finalized, this field will equal <code>customer.email</code>. Once the invoice is finalized, this field will no longer be updated.
67 * @property null|string $customer_name The customer's name. Until the invoice is finalized, this field will equal <code>customer.name</code>. Once the invoice is finalized, this field will no longer be updated.
68 * @property null|string $customer_phone The customer's phone number. Until the invoice is finalized, this field will equal <code>customer.phone</code>. Once the invoice is finalized, this field will no longer be updated.
69 * @property null|\Stripe\StripeObject $customer_shipping The customer's shipping information. Until the invoice is finalized, this field will equal <code>customer.shipping</code>. Once the invoice is finalized, this field will no longer be updated.
70 * @property null|string $customer_tax_exempt The customer's tax exempt status. Until the invoice is finalized, this field will equal <code>customer.tax_exempt</code>. Once the invoice is finalized, this field will no longer be updated.
71 * @property null|\Stripe\StripeObject[] $customer_tax_ids The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as <code>customer.tax_ids</code>. Once the invoice is finalized, this field will no longer be updated.
72 * @property null|string|\Stripe\PaymentMethod $default_payment_method ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.
73 * @property null|string|\Stripe\Account|\Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source $default_source ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.
74 * @property \Stripe\TaxRate[] $default_tax_rates The tax rates applied to this invoice, if any.
75 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
76 * @property null|\Stripe\Discount $discount Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.
77 * @property null|(string|\Stripe\Discount)[] $discounts The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use <code>expand[]=discounts</code> to expand each discount.
78 * @property null|int $due_date The date on which payment for this invoice is due. This value will be <code>null</code> for invoices where <code>collection_method=charge_automatically</code>.
79 * @property null|int $ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
80 * @property null|string $footer Footer displayed on the invoice.
81 * @property null|string $hosted_invoice_url The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.
82 * @property null|string $invoice_pdf The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
83 * @property null|\Stripe\ErrorObject $last_finalization_error The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
84 * @property \Stripe\Collection<\Stripe\InvoiceLineItem> $lines The individual line items that make up the invoice. <code>lines</code> is sorted as follows: invoice items in reverse chronological order, followed by the subscription, if any.
85 * @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.
86 * @property null|\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.
87 * @property null|int $next_payment_attempt The time at which payment will next be attempted. This value will be <code>null</code> for invoices where <code>collection_method=send_invoice</code>.
88 * @property null|string $number A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified.
89 * @property null|string|\Stripe\Account $on_behalf_of The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the <a href="https://stripe.com/docs/billing/invoices/connect">Invoices with Connect</a> documentation for details.
90 * @property bool $paid Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer's account balance.
91 * @property bool $paid_out_of_band Returns true if the invoice was manually marked paid, returns false if the invoice hasn't been paid yet or was paid on Stripe.
92 * @property null|string|\Stripe\PaymentIntent $payment_intent The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent.
93 * @property \Stripe\StripeObject $payment_settings
94 * @property int $period_end End of the usage period during which invoice items were added to this invoice.
95 * @property int $period_start Start of the usage period during which invoice items were added to this invoice.
96 * @property int $post_payment_credit_notes_amount Total amount of all post-payment credit notes issued for this invoice.
97 * @property int $pre_payment_credit_notes_amount Total amount of all pre-payment credit notes issued for this invoice.
98 * @property null|string|\Stripe\Quote $quote The quote this invoice was generated from.
99 * @property null|string $receipt_number This is the transaction number that appears on email receipts sent for this invoice.
100 * @property int $starting_balance Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance.
101 * @property null|string $statement_descriptor Extra information about an invoice for the customer's credit card statement.
102 * @property null|string $status The status of the invoice, one of <code>draft</code>, <code>open</code>, <code>paid</code>, <code>uncollectible</code>, or <code>void</code>. <a href="https://stripe.com/docs/billing/invoices/workflow#workflow-overview">Learn more</a>
103 * @property \Stripe\StripeObject $status_transitions
104 * @property null|string|\Stripe\Subscription $subscription The subscription that this invoice was prepared for, if any.
105 * @property int $subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
106 * @property int $subtotal Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
107 * @property null|int $tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
108 * @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this invoice belongs to.
109 * @property \Stripe\StripeObject $threshold_reason
110 * @property int $total Total after discounts and taxes.
111 * @property null|\Stripe\StripeObject[] $total_discount_amounts The aggregate amounts calculated per discount across all line items.
112 * @property \Stripe\StripeObject[] $total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
113 * @property null|int $webhooks_delivered_at Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have <a href="https://stripe.com/docs/billing/webhooks#understand">been exhausted</a>. This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
114 */
115 class Invoice extends ApiResource
116 {
117 const OBJECT_NAME = 'invoice';
118
119 use ApiOperations\All;
120 use ApiOperations\Create;
121 use ApiOperations\Delete;
122 use ApiOperations\Retrieve;
123 use ApiOperations\Search;
124 use ApiOperations\Update;
125
126 const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
127 const BILLING_SEND_INVOICE = 'send_invoice';
128
129 const BILLING_REASON_MANUAL = 'manual';
130 const BILLING_REASON_QUOTE_ACCEPT = 'quote_accept';
131 const BILLING_REASON_SUBSCRIPTION = 'subscription';
132 const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create';
133 const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle';
134 const BILLING_REASON_SUBSCRIPTION_THRESHOLD = 'subscription_threshold';
135 const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update';
136 const BILLING_REASON_UPCOMING = 'upcoming';
137
138 const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically';
139 const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';
140
141 const STATUS_DELETED = 'deleted';
142 const STATUS_DRAFT = 'draft';
143 const STATUS_OPEN = 'open';
144 const STATUS_PAID = 'paid';
145 const STATUS_UNCOLLECTIBLE = 'uncollectible';
146 const STATUS_VOID = 'void';
147
148 use ApiOperations\NestedResource;
149
150 const PATH_LINES = '/lines';
151
152 /**
153 * @param string $id the ID of the invoice on which to retrieve the lines
154 * @param null|array $params
155 * @param null|array|string $opts
156 *
157 * @throws StripeExceptionApiErrorException if the request fails
158 *
159 * @return \Stripe\Collection<\Stripe\InvoiceLineItem> the list of lines (InvoiceLineItem)
160 */
161 public static function allLines($id, $params = null, $opts = null)
162 {
163 return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
164 }
165
166 /**
167 * @param null|array $params
168 * @param null|array|string $opts
169 *
170 * @throws \Stripe\Exception\ApiErrorException if the request fails
171 *
172 * @return \Stripe\Invoice the finalized invoice
173 */
174 public function finalizeInvoice($params = null, $opts = null)
175 {
176 $url = $this->instanceUrl() . '/finalize';
177 list($response, $opts) = $this->_request('post', $url, $params, $opts);
178 $this->refreshFrom($response, $opts);
179
180 return $this;
181 }
182
183 /**
184 * @param null|array $params
185 * @param null|array|string $opts
186 *
187 * @throws \Stripe\Exception\ApiErrorException if the request fails
188 *
189 * @return \Stripe\Invoice the uncollectible invoice
190 */
191 public function markUncollectible($params = null, $opts = null)
192 {
193 $url = $this->instanceUrl() . '/mark_uncollectible';
194 list($response, $opts) = $this->_request('post', $url, $params, $opts);
195 $this->refreshFrom($response, $opts);
196
197 return $this;
198 }
199
200 /**
201 * @param null|array $params
202 * @param null|array|string $opts
203 *
204 * @throws \Stripe\Exception\ApiErrorException if the request fails
205 *
206 * @return \Stripe\Invoice the paid invoice
207 */
208 public function pay($params = null, $opts = null)
209 {
210 $url = $this->instanceUrl() . '/pay';
211 list($response, $opts) = $this->_request('post', $url, $params, $opts);
212 $this->refreshFrom($response, $opts);
213
214 return $this;
215 }
216
217 /**
218 * @param null|array $params
219 * @param null|array|string $opts
220 *
221 * @throws \Stripe\Exception\ApiErrorException if the request fails
222 *
223 * @return \Stripe\Invoice the sent invoice
224 */
225 public function sendInvoice($params = null, $opts = null)
226 {
227 $url = $this->instanceUrl() . '/send';
228 list($response, $opts) = $this->_request('post', $url, $params, $opts);
229 $this->refreshFrom($response, $opts);
230
231 return $this;
232 }
233
234 /**
235 * @param null|array $params
236 * @param null|array|string $opts
237 *
238 * @throws \Stripe\Exception\ApiErrorException if the request fails
239 *
240 * @return \Stripe\Invoice the upcoming invoice
241 */
242 public static function upcoming($params = null, $opts = null)
243 {
244 $url = static::classUrl() . '/upcoming';
245 list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
246 $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
247 $obj->setLastResponse($response);
248
249 return $obj;
250 }
251
252 /**
253 * @param null|array $params
254 * @param null|array|string $opts
255 *
256 * @throws \Stripe\Exception\ApiErrorException if the request fails
257 *
258 * @return \Stripe\Invoice the voided invoice
259 */
260 public function voidInvoice($params = null, $opts = null)
261 {
262 $url = $this->instanceUrl() . '/void';
263 list($response, $opts) = $this->_request('post', $url, $params, $opts);
264 $this->refreshFrom($response, $opts);
265
266 return $this;
267 }
268
269 /**
270 * @param null|array $params
271 * @param null|array|string $opts
272 *
273 * @throws \Stripe\Exception\ApiErrorException if the request fails
274 *
275 * @return \Stripe\SearchResult<Invoice> the invoice search results
276 */
277 public static function search($params = null, $opts = null)
278 {
279 $url = '/v1/invoices/search';
280
281 return self::_searchResource($url, $params, $opts);
282 }
283 }
284