Class: Stripe::Quote

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::NestedResource
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/quote.rb

Overview

A Quote is a way to model prices that you’d like to provide to a customer. Once accepted, it will automatically create an invoice, subscription or subscription schedule.

Defined Under Namespace

Classes: AutomaticTax, Computed, FromQuote, InvoiceSettings, StatusDetails, StatusTransitions, SubscriptionData, SubscriptionDataOverride, SubscriptionSchedule, TotalDetails, TransferData

Constant Summary collapse

OBJECT_NAME =
"quote"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#allow_backdated_linesObject (readonly)

Allow quote lines to have ‘starts_at` in the past if collection is paused between `starts_at` and now.



193
194
195
# File 'lib/stripe/resources/quote.rb', line 193

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



195
196
197
# File 'lib/stripe/resources/quote.rb', line 195

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



197
198
199
# File 'lib/stripe/resources/quote.rb', line 197

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



199
200
201
# File 'lib/stripe/resources/quote.rb', line 199

def application
  @application
end

#application_fee_amountObject (readonly)

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.



201
202
203
# File 'lib/stripe/resources/quote.rb', line 201

def application_fee_amount
  @application_fee_amount
end

#application_fee_percentObject (readonly)

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.



203
204
205
# File 'lib/stripe/resources/quote.rb', line 203

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



205
206
207
# File 'lib/stripe/resources/quote.rb', line 205

def automatic_tax
  @automatic_tax
end

#collection_methodObject (readonly)

Either ‘charge_automatically`, or `send_invoice`. 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 `active`. Defaults to `charge_automatically`.



207
208
209
# File 'lib/stripe/resources/quote.rb', line 207

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



209
210
211
# File 'lib/stripe/resources/quote.rb', line 209

def computed
  @computed
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



211
212
213
# File 'lib/stripe/resources/quote.rb', line 211

def created
  @created
end

#currencyObject (readonly)

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).



213
214
215
# File 'lib/stripe/resources/quote.rb', line 213

def currency
  @currency
end

#customerObject (readonly)

The customer which this quote belongs to. A customer is required before finalizing the quote. Once specified, it cannot be changed.



215
216
217
# File 'lib/stripe/resources/quote.rb', line 215

def customer
  @customer
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



217
218
219
# File 'lib/stripe/resources/quote.rb', line 217

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



219
220
221
# File 'lib/stripe/resources/quote.rb', line 219

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



221
222
223
# File 'lib/stripe/resources/quote.rb', line 221

def discounts
  @discounts
end

#expires_atObject (readonly)

The date on which the quote will be canceled if in ‘open` or `draft` status. Measured in seconds since the Unix epoch.



223
224
225
# File 'lib/stripe/resources/quote.rb', line 223

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



225
226
227
# File 'lib/stripe/resources/quote.rb', line 225

def footer
  @footer
end

#from_quoteObject (readonly)

Details of the quote that was cloned. See the [cloning documentation](stripe.com/docs/quotes/clone) for more details.



227
228
229
# File 'lib/stripe/resources/quote.rb', line 227

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



229
230
231
# File 'lib/stripe/resources/quote.rb', line 229

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



231
232
233
# File 'lib/stripe/resources/quote.rb', line 231

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



233
234
235
# File 'lib/stripe/resources/quote.rb', line 233

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



235
236
237
# File 'lib/stripe/resources/quote.rb', line 235

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



237
238
239
# File 'lib/stripe/resources/quote.rb', line 237

def line_items
  @line_items
end

#linesObject (readonly)

A list of [quote lines](docs.stripe.com/api/quote_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.



239
240
241
# File 'lib/stripe/resources/quote.rb', line 239

def lines
  @lines
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



241
242
243
# File 'lib/stripe/resources/quote.rb', line 241

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



243
244
245
# File 'lib/stripe/resources/quote.rb', line 243

def 
  @metadata
end

#numberObject (readonly)

A unique number that identifies this particular quote. This number is assigned once the quote is [finalized](stripe.com/docs/quotes/overview#finalize).



245
246
247
# File 'lib/stripe/resources/quote.rb', line 245

def number
  @number
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



247
248
249
# File 'lib/stripe/resources/quote.rb', line 247

def object
  @object
end

#on_behalf_ofObject (readonly)

The account on behalf of which to charge. See the [Connect documentation](support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details.



249
250
251
# File 'lib/stripe/resources/quote.rb', line 249

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



251
252
253
# File 'lib/stripe/resources/quote.rb', line 251

def status
  @status
end

#status_detailsObject (readonly)

Details on when and why a quote has been marked as stale or canceled.



253
254
255
# File 'lib/stripe/resources/quote.rb', line 253

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



255
256
257
# File 'lib/stripe/resources/quote.rb', line 255

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



257
258
259
# File 'lib/stripe/resources/quote.rb', line 257

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



259
260
261
# File 'lib/stripe/resources/quote.rb', line 259

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

List representing overrides for ‘subscription_data` configurations for specific subscription schedules.



261
262
263
# File 'lib/stripe/resources/quote.rb', line 261

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

The subscription schedule that was created or updated from this quote.



263
264
265
# File 'lib/stripe/resources/quote.rb', line 263

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

The subscription schedules that were created or updated from this quote.



265
266
267
# File 'lib/stripe/resources/quote.rb', line 265

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



267
268
269
# File 'lib/stripe/resources/quote.rb', line 267

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



269
270
271
# File 'lib/stripe/resources/quote.rb', line 269

def total_details
  @total_details
end

#transfer_dataObject (readonly)

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.



271
272
273
# File 'lib/stripe/resources/quote.rb', line 271

def transfer_data
  @transfer_data
end

Class Method Details

.accept(quote, params = {}, opts = {}) ⇒ Object

Accepts the specified quote.



284
285
286
287
288
289
290
291
# File 'lib/stripe/resources/quote.rb', line 284

def self.accept(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/accept", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.cancel(quote, params = {}, opts = {}) ⇒ Object

Cancels the quote.



304
305
306
307
308
309
310
311
# File 'lib/stripe/resources/quote.rb', line 304

def self.cancel(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/cancel", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.create(params = {}, opts = {}) ⇒ Object

A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the [quote template](dashboard.stripe.com/settings/billing/quote).



314
315
316
# File 'lib/stripe/resources/quote.rb', line 314

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/quotes", params: params, opts: opts)
end

.finalize_quote(quote, params = {}, opts = {}) ⇒ Object

Finalizes the quote.



329
330
331
332
333
334
335
336
# File 'lib/stripe/resources/quote.rb', line 329

def self.finalize_quote(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/finalize", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.list(filters = {}, opts = {}) ⇒ Object

Returns a list of your quotes.



339
340
341
# File 'lib/stripe/resources/quote.rb', line 339

def self.list(filters = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/quotes", params: filters, opts: opts)
end

.list_computed_upfront_line_items(quote, params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable [computed.upfront.line_items](stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.



354
355
356
357
358
359
360
361
# File 'lib/stripe/resources/quote.rb', line 354

def self.list_computed_upfront_line_items(quote, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/computed_upfront_line_items", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.list_line_items(quote, params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



374
375
376
377
378
379
380
381
# File 'lib/stripe/resources/quote.rb', line 374

def self.list_line_items(quote, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/line_items", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.list_lines(quote, params = {}, opts = {}) ⇒ Object

Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.



394
395
396
397
398
399
400
401
# File 'lib/stripe/resources/quote.rb', line 394

def self.list_lines(quote, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {}) ⇒ Object

Preview the invoice line items that would be generated by accepting the quote.



414
415
416
417
418
419
420
421
# File 'lib/stripe/resources/quote.rb', line 414

def self.list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(quote), preview_invoice: CGI.escape(preview_invoice) }),
    params: params,
    opts: opts
  )
end

.mark_draft(quote, params = {}, opts = {}) ⇒ Object

Converts a stale quote to draft.



434
435
436
437
438
439
440
441
# File 'lib/stripe/resources/quote.rb', line 434

def self.mark_draft(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.mark_stale(quote, params = {}, opts = {}) ⇒ Object

Converts a draft or open quote to stale.



454
455
456
457
458
459
460
461
# File 'lib/stripe/resources/quote.rb', line 454

def self.mark_stale(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.object_nameObject



14
15
16
# File 'lib/stripe/resources/quote.rb', line 14

def self.object_name
  "quote"
end

.pdf(quote, params = {}, opts = {}, &read_body_chunk_block) ⇒ Object

Download the PDF for a finalized quote. Explanation for special handling can be found [here](docs.stripe.com/quotes/overview#quote_pdf)



477
478
479
480
481
482
483
484
485
486
487
# File 'lib/stripe/resources/quote.rb', line 477

def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
  opts = { api_base: APIRequestor.active_requestor.config.uploads_base }.merge(opts)
  execute_resource_request_stream(
    :get,
    format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(quote) }),
    :files,
    params,
    opts,
    &read_body_chunk_block
  )
end

.reestimate(quote, params = {}, opts = {}) ⇒ Object

Recompute the upcoming invoice estimate for the quote.



500
501
502
503
504
505
506
507
# File 'lib/stripe/resources/quote.rb', line 500

def self.reestimate(quote, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.update(id, params = {}, opts = {}) ⇒ Object

A quote models prices and services for a customer.



510
511
512
513
514
515
516
517
# File 'lib/stripe/resources/quote.rb', line 510

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#accept(params = {}, opts = {}) ⇒ Object

Accepts the specified quote.



274
275
276
277
278
279
280
281
# File 'lib/stripe/resources/quote.rb', line 274

def accept(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/accept", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#cancel(params = {}, opts = {}) ⇒ Object

Cancels the quote.



294
295
296
297
298
299
300
301
# File 'lib/stripe/resources/quote.rb', line 294

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/cancel", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#finalize_quote(params = {}, opts = {}) ⇒ Object

Finalizes the quote.



319
320
321
322
323
324
325
326
# File 'lib/stripe/resources/quote.rb', line 319

def finalize_quote(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/finalize", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#list_computed_upfront_line_items(params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable [computed.upfront.line_items](stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.



344
345
346
347
348
349
350
351
# File 'lib/stripe/resources/quote.rb', line 344

def list_computed_upfront_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/computed_upfront_line_items", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#list_line_items(params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



364
365
366
367
368
369
370
371
# File 'lib/stripe/resources/quote.rb', line 364

def list_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/line_items", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#list_lines(params = {}, opts = {}) ⇒ Object

Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted.



384
385
386
387
388
389
390
391
# File 'lib/stripe/resources/quote.rb', line 384

def list_lines(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/lines", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#list_preview_invoice_lines(preview_invoice, params = {}, opts = {}) ⇒ Object

Preview the invoice line items that would be generated by accepting the quote.



404
405
406
407
408
409
410
411
# File 'lib/stripe/resources/quote.rb', line 404

def list_preview_invoice_lines(preview_invoice, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(self["id"]), preview_invoice: CGI.escape(preview_invoice) }),
    params: params,
    opts: opts
  )
end

#mark_draft(params = {}, opts = {}) ⇒ Object

Converts a stale quote to draft.



424
425
426
427
428
429
430
431
# File 'lib/stripe/resources/quote.rb', line 424

def mark_draft(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#mark_stale(params = {}, opts = {}) ⇒ Object

Converts a draft or open quote to stale.



444
445
446
447
448
449
450
451
# File 'lib/stripe/resources/quote.rb', line 444

def mark_stale(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#pdf(params = {}, opts = {}, &read_body_chunk_block) ⇒ Object

Download the PDF for a finalized quote. Explanation for special handling can be found [here](docs.stripe.com/quotes/overview#quote_pdf)



464
465
466
467
468
469
470
471
472
473
474
# File 'lib/stripe/resources/quote.rb', line 464

def pdf(params = {}, opts = {}, &read_body_chunk_block)
  opts = { api_base: APIRequestor.active_requestor.config.uploads_base }.merge(opts)
  request_stream(
    method: :get,
    path: format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts,
    base_address: :files,
    &read_body_chunk_block
  )
end

#reestimate(params = {}, opts = {}) ⇒ Object

Recompute the upcoming invoice estimate for the quote.



490
491
492
493
494
495
496
497
# File 'lib/stripe/resources/quote.rb', line 490

def reestimate(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end