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

stripe / stripe-php / #7371

31 Aug 2023 11:57PM UTC coverage: 66.703% (+0.2%) from 66.496%
#7371

push

php-coveralls

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

Update generated code for beta

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

1823 of 2733 relevant lines covered (66.7%)

3.78 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 int $amount_subtotal Total before any discounts or taxes are applied.
14
 * @property int $amount_total Total after discounts and taxes are applied.
15
 * @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the quote.
16
 * @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.
17
 * @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.
18
 * @property \Stripe\StripeObject $automatic_tax
19
 * @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>.
20
 * @property \Stripe\StripeObject $computed
21
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
22
 * @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>.
23
 * @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.
24
 * @property null|(string|\Stripe\TaxRate)[] $default_tax_rates The tax rates applied to this quote.
25
 * @property null|string $description A description that will be displayed on the quote PDF.
26
 * @property (string|\Stripe\Discount)[] $discounts The discounts applied to this quote.
27
 * @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.
28
 * @property null|string $footer A footer that will be displayed on the quote PDF.
29
 * @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.
30
 * @property null|string $header A header that will be displayed on the quote PDF.
31
 * @property null|string|\Stripe\Invoice $invoice The invoice that was created from this quote.
32
 * @property null|\Stripe\StripeObject $invoice_settings All invoices will be billed using the specified settings.
33
 * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items A list of items the customer is being quoted for.
34
 * @property null|string[] $lines A list of lines on the quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.
35
 * @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.
36
 * @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.
37
 * @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>.
38
 * @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.
39
 * @property string $status The status of the quote.
40
 * @property null|\Stripe\StripeObject $status_details Details on when and why a quote has been marked as stale or canceled.
41
 * @property \Stripe\StripeObject $status_transitions
42
 * @property null|string|\Stripe\Subscription $subscription The subscription that was created or updated from this quote.
43
 * @property \Stripe\StripeObject $subscription_data
44
 * @property null|\Stripe\StripeObject[] $subscription_data_overrides
45
 * @property null|string|\Stripe\SubscriptionSchedule $subscription_schedule The subscription schedule that was created or updated from this quote.
46
 * @property null|\Stripe\StripeObject[] $subscription_schedules The subscription schedules that were created or updated from this quote.
47
 * @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this quote belongs to.
48
 * @property \Stripe\StripeObject $total_details
49
 * @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.
50
 */
51
class Quote extends ApiResource
52
{
53
    const OBJECT_NAME = 'quote';
54

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

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

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

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

85
        return $this;
1✔
86
    }
87

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

102
        return $this;
1✔
103
    }
104

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

119
        return $this;
×
120
    }
121

122
    /**
123
     * @param null|array $params
124
     * @param null|array|string $opts
125
     *
126
     * @throws \Stripe\Exception\ApiErrorException if the request fails
127
     *
128
     * @return \Stripe\Quote the finalized quote
129
     */
130
    public function finalizeQuote($params = null, $opts = null)
131
    {
132
        $url = $this->instanceUrl() . '/finalize';
1✔
133
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
134
        $this->refreshFrom($response, $opts);
1✔
135

136
        return $this;
1✔
137
    }
138

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

155
        return $obj;
×
156
    }
157

158
    /**
159
     * @param string $id
160
     * @param null|array $params
161
     * @param null|array|string $opts
162
     *
163
     * @throws \Stripe\Exception\ApiErrorException if the request fails
164
     *
165
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
166
     */
167
    public static function allLineItems($id, $params = null, $opts = null)
168
    {
169
        $url = static::resourceUrl($id) . '/line_items';
1✔
170
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
1✔
171
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
1✔
172
        $obj->setLastResponse($response);
1✔
173

174
        return $obj;
1✔
175
    }
176

177
    /**
178
     * @param string $id
179
     * @param null|array $params
180
     * @param null|array|string $opts
181
     *
182
     * @throws \Stripe\Exception\ApiErrorException if the request fails
183
     *
184
     * @return \Stripe\Collection<\Stripe\QuoteLine> list of quote lines
185
     */
186
    public static function allLines($id, $params = null, $opts = null)
187
    {
188
        $url = static::resourceUrl($id) . '/lines';
×
189
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
190
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
191
        $obj->setLastResponse($response);
×
192

193
        return $obj;
×
194
    }
195

196
    /**
197
     * @param null|array $params
198
     * @param null|array|string $opts
199
     *
200
     * @throws \Stripe\Exception\ApiErrorException if the request fails
201
     *
202
     * @return \Stripe\Quote the marked quote
203
     */
204
    public function markStaleQuote($params = null, $opts = null)
205
    {
206
        $url = $this->instanceUrl() . '/mark_stale';
×
207
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
208
        $this->refreshFrom($response, $opts);
×
209

210
        return $this;
×
211
    }
212

213
    /**
214
     * @param callable $readBodyChunkCallable
215
     * @param null|array $params
216
     * @param null|array|string $opts
217
     *
218
     * @throws \Stripe\Exception\ApiErrorException if the request fails
219
     *
220
     * @return void
221
     */
222
    public function pdf($readBodyChunkCallable, $params = null, $opts = null)
223
    {
224
        $opts = \Stripe\Util\RequestOptions::parse($opts);
1✔
225
        if (!isset($opts->apiBase)) {
1✔
226
            $opts->apiBase = \Stripe\Stripe::$apiUploadBase;
1✔
227
        }
228
        $url = $this->instanceUrl() . '/pdf';
1✔
229
        $this->_requestStream('get', $url, $readBodyChunkCallable, $params, $opts);
1✔
230
    }
231

232
    /**
233
     * @param string $id
234
     * @param string $preview_invoice
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\Collection<\Stripe\InvoiceLineItem> list of invoice line items
241
     */
242
    public static function previewInvoiceLines($id, $preview_invoice, $params = null, $opts = null)
243
    {
244
        $url = static::resourceUrl($id) . '/preview_invoices/' . $preview_invoice . '/lines';
×
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\Quote the reestimated quote
259
     */
260
    public function reestimate($params = null, $opts = null)
261
    {
262
        $url = $this->instanceUrl() . '/reestimate';
×
263
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
264
        $this->refreshFrom($response, $opts);
×
265

266
        return $this;
×
267
    }
268

269
    const PATH_PREVIEW_INVOICES = '/preview_invoices';
270

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

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