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

stripe / stripe-php / #7504

05 Oct 2023 05:47PM UTC coverage: 66.134% (-0.07%) from 66.206%
#7504

push

php-coveralls

web-flow
Merge pull request #1587 from stripe/latest-codegen-beta

Update generated code for beta

20 of 20 new or added lines in 3 files covered. (100.0%)

1822 of 2755 relevant lines covered (66.13%)

3.75 hits per line

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

43.14
/lib/Quote.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * A Quote is a way to model prices that you'd like to provide to a customer.
9
 * Once accepted, it will automatically create an invoice, subscription or subscription schedule.
10
 *
11
 * @property string $id Unique identifier for the object.
12
 * @property string $object String representing the object's type. Objects of the same type share the same value.
13
 * @property null|bool $allow_backdated_lines Allow quote lines to have <code>starts_at</code> in the past if collection is paused between <code>starts_at</code> and now.
14
 * @property int $amount_subtotal Total before any discounts or taxes are applied.
15
 * @property int $amount_total Total after discounts and taxes are applied.
16
 * @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the quote.
17
 * @property null|int $application_fee_amount The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. Only applicable if there are no line items with recurring prices on the quote.
18
 * @property null|float $application_fee_percent A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. Only applicable if there are line items with recurring prices on the quote.
19
 * @property \Stripe\StripeObject $automatic_tax
20
 * @property string $collection_method Either <code>charge_automatically</code>, or <code>send_invoice</code>. When charging automatically, Stripe will attempt to pay invoices at the end of the subscription cycle or on finalization using the default payment method attached to the subscription or customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as <code>active</code>. Defaults to <code>charge_automatically</code>.
21
 * @property \Stripe\StripeObject $computed
22
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
23
 * @property null|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>.
24
 * @property null|string|\Stripe\Customer $customer The customer which this quote belongs to. A customer is required before finalizing the quote. Once specified, it cannot be changed.
25
 * @property null|(string|\Stripe\TaxRate)[] $default_tax_rates The tax rates applied to this quote.
26
 * @property null|string $description A description that will be displayed on the quote PDF.
27
 * @property (string|\Stripe\Discount)[] $discounts The discounts applied to this quote.
28
 * @property int $expires_at The date on which the quote will be canceled if in <code>open</code> or <code>draft</code> status. Measured in seconds since the Unix epoch.
29
 * @property null|string $footer A footer that will be displayed on the quote PDF.
30
 * @property null|\Stripe\StripeObject $from_quote Details of the quote that was cloned. See the <a href="https://stripe.com/docs/quotes/clone">cloning documentation</a> for more details.
31
 * @property null|string $header A header that will be displayed on the quote PDF.
32
 * @property null|string|\Stripe\Invoice $invoice The invoice that was created from this quote.
33
 * @property null|\Stripe\StripeObject $invoice_settings All invoices will be billed using the specified settings.
34
 * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items A list of items the customer is being quoted for.
35
 * @property null|string[] $lines A list of lines on the quote. These lines describe changes, in the order provided, that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.
36
 * @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.
37
 * @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.
38
 * @property null|string $number A unique number that identifies this particular quote. This number is assigned once the quote is <a href="https://stripe.com/docs/quotes/overview#finalize">finalized</a>.
39
 * @property null|string|\Stripe\Account $on_behalf_of The account on behalf of which to charge. See the <a href="https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts">Connect documentation</a> for details.
40
 * @property string $status The status of the quote.
41
 * @property null|\Stripe\StripeObject $status_details Details on when and why a quote has been marked as stale or canceled.
42
 * @property \Stripe\StripeObject $status_transitions
43
 * @property null|string|\Stripe\Subscription $subscription The subscription that was created or updated from this quote.
44
 * @property \Stripe\StripeObject $subscription_data
45
 * @property null|\Stripe\StripeObject[] $subscription_data_overrides
46
 * @property null|string|\Stripe\SubscriptionSchedule $subscription_schedule The subscription schedule that was created or updated from this quote.
47
 * @property null|\Stripe\StripeObject[] $subscription_schedules The subscription schedules that were created or updated from this quote.
48
 * @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this quote belongs to.
49
 * @property \Stripe\StripeObject $total_details
50
 * @property null|\Stripe\StripeObject $transfer_data The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the invoices.
51
 */
52
class Quote extends ApiResource
53
{
54
    const OBJECT_NAME = 'quote';
55

56
    use ApiOperations\All;
57
    use ApiOperations\Create;
58
    use ApiOperations\NestedResource;
59
    use ApiOperations\Retrieve;
60
    use ApiOperations\Update;
61

62
    const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically';
63
    const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';
64

65
    const STATUS_ACCEPTED = 'accepted';
66
    const STATUS_ACCEPTING = 'accepting';
67
    const STATUS_CANCELED = 'canceled';
68
    const STATUS_DRAFT = 'draft';
69
    const STATUS_OPEN = 'open';
70
    const STATUS_STALE = 'stale';
71

72
    /**
73
     * @param null|array $params
74
     * @param null|array|string $opts
75
     *
76
     * @throws \Stripe\Exception\ApiErrorException if the request fails
77
     *
78
     * @return \Stripe\Quote the accepted quote
79
     */
80
    public function accept($params = null, $opts = null)
81
    {
82
        $url = $this->instanceUrl() . '/accept';
1✔
83
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
84
        $this->refreshFrom($response, $opts);
1✔
85

86
        return $this;
1✔
87
    }
88

89
    /**
90
     * @param null|array $params
91
     * @param null|array|string $opts
92
     *
93
     * @throws \Stripe\Exception\ApiErrorException if the request fails
94
     *
95
     * @return \Stripe\Quote the canceled quote
96
     */
97
    public function cancel($params = null, $opts = null)
98
    {
99
        $url = $this->instanceUrl() . '/cancel';
1✔
100
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
101
        $this->refreshFrom($response, $opts);
1✔
102

103
        return $this;
1✔
104
    }
105

106
    /**
107
     * @param null|array $params
108
     * @param null|array|string $opts
109
     *
110
     * @throws \Stripe\Exception\ApiErrorException if the request fails
111
     *
112
     * @return \Stripe\Quote the finalized quote
113
     */
114
    public function finalizeQuote($params = null, $opts = null)
115
    {
116
        $url = $this->instanceUrl() . '/finalize';
1✔
117
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
118
        $this->refreshFrom($response, $opts);
1✔
119

120
        return $this;
1✔
121
    }
122

123
    /**
124
     * @param string $id
125
     * @param null|array $params
126
     * @param null|array|string $opts
127
     *
128
     * @throws \Stripe\Exception\ApiErrorException if the request fails
129
     *
130
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
131
     */
132
    public static function allComputedUpfrontLineItems($id, $params = null, $opts = null)
133
    {
134
        $url = static::resourceUrl($id) . '/computed_upfront_line_items';
×
135
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
136
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
137
        $obj->setLastResponse($response);
×
138

139
        return $obj;
×
140
    }
141

142
    /**
143
     * @param string $id
144
     * @param null|array $params
145
     * @param null|array|string $opts
146
     *
147
     * @throws \Stripe\Exception\ApiErrorException if the request fails
148
     *
149
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
150
     */
151
    public static function allLineItems($id, $params = null, $opts = null)
152
    {
153
        $url = static::resourceUrl($id) . '/line_items';
1✔
154
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
1✔
155
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
1✔
156
        $obj->setLastResponse($response);
1✔
157

158
        return $obj;
1✔
159
    }
160

161
    /**
162
     * @param string $id
163
     * @param null|array $params
164
     * @param null|array|string $opts
165
     *
166
     * @throws \Stripe\Exception\ApiErrorException if the request fails
167
     *
168
     * @return \Stripe\Collection<\Stripe\QuoteLine> list of quote lines
169
     */
170
    public static function allLines($id, $params = null, $opts = null)
171
    {
172
        $url = static::resourceUrl($id) . '/lines';
×
173
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
174
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
175
        $obj->setLastResponse($response);
×
176

177
        return $obj;
×
178
    }
179

180
    /**
181
     * @param string $id
182
     * @param string $preview_invoice
183
     * @param null|array $params
184
     * @param null|array|string $opts
185
     *
186
     * @throws \Stripe\Exception\ApiErrorException if the request fails
187
     *
188
     * @return \Stripe\Collection<\Stripe\InvoiceLineItem> list of invoice line items
189
     */
190
    public static function allPreviewInvoiceLines($id, $preview_invoice, $params = null, $opts = null)
191
    {
192
        $url = static::resourceUrl($id) . '/preview_invoices/' . $preview_invoice . '/lines';
×
193
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
194
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
195
        $obj->setLastResponse($response);
×
196

197
        return $obj;
×
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\Quote the marked quote
207
     */
208
    public function markDraft($params = null, $opts = null)
209
    {
210
        $url = $this->instanceUrl() . '/mark_draft';
×
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\Quote the marked quote
224
     */
225
    public function markStale($params = null, $opts = null)
226
    {
227
        $url = $this->instanceUrl() . '/mark_stale';
×
228
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
229
        $this->refreshFrom($response, $opts);
×
230

231
        return $this;
×
232
    }
233

234
    /**
235
     * @param callable $readBodyChunkCallable
236
     * @param null|array $params
237
     * @param null|array|string $opts
238
     *
239
     * @throws \Stripe\Exception\ApiErrorException if the request fails
240
     *
241
     * @return void
242
     */
243
    public function pdf($readBodyChunkCallable, $params = null, $opts = null)
244
    {
245
        $opts = \Stripe\Util\RequestOptions::parse($opts);
1✔
246
        if (!isset($opts->apiBase)) {
1✔
247
            $opts->apiBase = \Stripe\Stripe::$apiUploadBase;
1✔
248
        }
249
        $url = $this->instanceUrl() . '/pdf';
1✔
250
        $this->_requestStream('get', $url, $readBodyChunkCallable, $params, $opts);
1✔
251
    }
252

253
    /**
254
     * @param null|array $params
255
     * @param null|array|string $opts
256
     *
257
     * @throws \Stripe\Exception\ApiErrorException if the request fails
258
     *
259
     * @return \Stripe\Quote the reestimated quote
260
     */
261
    public function reestimate($params = null, $opts = null)
262
    {
263
        $url = $this->instanceUrl() . '/reestimate';
×
264
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
265
        $this->refreshFrom($response, $opts);
×
266

267
        return $this;
×
268
    }
269

270
    const PATH_PREVIEW_INVOICES = '/preview_invoices';
271

272
    /**
273
     * @param string $id the ID of the quote on which to retrieve the quote preview invoices
274
     * @param null|array $params
275
     * @param null|array|string $opts
276
     *
277
     * @throws \Stripe\Exception\ApiErrorException if the request fails
278
     *
279
     * @return \Stripe\Collection<\Stripe\QuotePreviewInvoice> the list of quote preview invoices
280
     */
281
    public static function allPreviewInvoices($id, $params = null, $opts = null)
282
    {
283
        return self::_allNestedResources($id, static::PATH_PREVIEW_INVOICES, $params, $opts);
×
284
    }
285
    const PATH_PREVIEW_SUBSCRIPTION_SCHEDULES = '/preview_subscription_schedules';
286

287
    /**
288
     * @param string $id the ID of the quote on which to retrieve the quote preview subscription schedules
289
     * @param null|array $params
290
     * @param null|array|string $opts
291
     *
292
     * @throws \Stripe\Exception\ApiErrorException if the request fails
293
     *
294
     * @return \Stripe\Collection<\Stripe\QuotePreviewSubscriptionSchedule> the list of quote preview subscription schedules
295
     */
296
    public static function allPreviewSubscriptionSchedules($id, $params = null, $opts = null)
297
    {
298
        return self::_allNestedResources($id, static::PATH_PREVIEW_SUBSCRIPTION_SCHEDULES, $params, $opts);
×
299
    }
300
}
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