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: AcceptParams, AutomaticTax, CancelParams, Computed, CreateParams, FinalizeQuoteParams, FromQuote, InvoiceSettings, ListComputedUpfrontLineItemsParams, ListLineItemsParams, ListLinesParams, ListParams, ListPreviewInvoiceLinesParams, MarkDraftParams, MarkStaleParams, PdfParams, ReestimateParams, RetrieveParams, StatusDetails, StatusTransitions, SubscriptionData, SubscriptionDataOverride, SubscriptionSchedule, TotalDetails, TransferData, UpdateParams

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.



3202
3203
3204
# File 'lib/stripe/resources/quote.rb', line 3202

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



3205
3206
3207
# File 'lib/stripe/resources/quote.rb', line 3205

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



3208
3209
3210
# File 'lib/stripe/resources/quote.rb', line 3208

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



3211
3212
3213
# File 'lib/stripe/resources/quote.rb', line 3211

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.



3214
3215
3216
# File 'lib/stripe/resources/quote.rb', line 3214

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.



3217
3218
3219
# File 'lib/stripe/resources/quote.rb', line 3217

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



3220
3221
3222
# File 'lib/stripe/resources/quote.rb', line 3220

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`.



3223
3224
3225
# File 'lib/stripe/resources/quote.rb', line 3223

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



3226
3227
3228
# File 'lib/stripe/resources/quote.rb', line 3226

def computed
  @computed
end

#createdObject (readonly)

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



3229
3230
3231
# File 'lib/stripe/resources/quote.rb', line 3229

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).



3232
3233
3234
# File 'lib/stripe/resources/quote.rb', line 3232

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.



3235
3236
3237
# File 'lib/stripe/resources/quote.rb', line 3235

def customer
  @customer
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



3238
3239
3240
# File 'lib/stripe/resources/quote.rb', line 3238

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



3241
3242
3243
# File 'lib/stripe/resources/quote.rb', line 3241

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



3244
3245
3246
# File 'lib/stripe/resources/quote.rb', line 3244

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.



3247
3248
3249
# File 'lib/stripe/resources/quote.rb', line 3247

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



3250
3251
3252
# File 'lib/stripe/resources/quote.rb', line 3250

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.



3253
3254
3255
# File 'lib/stripe/resources/quote.rb', line 3253

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



3256
3257
3258
# File 'lib/stripe/resources/quote.rb', line 3256

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



3259
3260
3261
# File 'lib/stripe/resources/quote.rb', line 3259

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



3262
3263
3264
# File 'lib/stripe/resources/quote.rb', line 3262

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



3265
3266
3267
# File 'lib/stripe/resources/quote.rb', line 3265

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



3268
3269
3270
# File 'lib/stripe/resources/quote.rb', line 3268

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.



3271
3272
3273
# File 'lib/stripe/resources/quote.rb', line 3271

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.



3274
3275
3276
# File 'lib/stripe/resources/quote.rb', line 3274

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.



3277
3278
3279
# File 'lib/stripe/resources/quote.rb', line 3277

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).



3280
3281
3282
# File 'lib/stripe/resources/quote.rb', line 3280

def number
  @number
end

#objectObject (readonly)

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



3283
3284
3285
# File 'lib/stripe/resources/quote.rb', line 3283

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.



3286
3287
3288
# File 'lib/stripe/resources/quote.rb', line 3286

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



3289
3290
3291
# File 'lib/stripe/resources/quote.rb', line 3289

def status
  @status
end

#status_detailsObject (readonly)

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



3292
3293
3294
# File 'lib/stripe/resources/quote.rb', line 3292

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



3295
3296
3297
# File 'lib/stripe/resources/quote.rb', line 3295

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



3298
3299
3300
# File 'lib/stripe/resources/quote.rb', line 3298

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



3301
3302
3303
# File 'lib/stripe/resources/quote.rb', line 3301

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

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



3304
3305
3306
# File 'lib/stripe/resources/quote.rb', line 3304

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

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



3307
3308
3309
# File 'lib/stripe/resources/quote.rb', line 3307

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

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



3310
3311
3312
# File 'lib/stripe/resources/quote.rb', line 3310

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



3313
3314
3315
# File 'lib/stripe/resources/quote.rb', line 3313

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



3316
3317
3318
# File 'lib/stripe/resources/quote.rb', line 3316

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.



3319
3320
3321
# File 'lib/stripe/resources/quote.rb', line 3319

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



3332
3333
3334
3335
3336
3337
3338
3339
# File 'lib/stripe/resources/quote.rb', line 3332

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.



3352
3353
3354
3355
3356
3357
3358
3359
# File 'lib/stripe/resources/quote.rb', line 3352

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).



3362
3363
3364
# File 'lib/stripe/resources/quote.rb', line 3362

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.



3377
3378
3379
3380
3381
3382
3383
3384
# File 'lib/stripe/resources/quote.rb', line 3377

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(params = {}, opts = {}) ⇒ Object

Returns a list of your quotes.



3387
3388
3389
# File 'lib/stripe/resources/quote.rb', line 3387

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/quotes", params: params, 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.



3402
3403
3404
3405
3406
3407
3408
3409
# File 'lib/stripe/resources/quote.rb', line 3402

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.



3422
3423
3424
3425
3426
3427
3428
3429
# File 'lib/stripe/resources/quote.rb', line 3422

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.



3442
3443
3444
3445
3446
3447
3448
3449
# File 'lib/stripe/resources/quote.rb', line 3442

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.



3462
3463
3464
3465
3466
3467
3468
3469
# File 'lib/stripe/resources/quote.rb', line 3462

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.



3482
3483
3484
3485
3486
3487
3488
3489
# File 'lib/stripe/resources/quote.rb', line 3482

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.



3502
3503
3504
3505
3506
3507
3508
3509
# File 'lib/stripe/resources/quote.rb', line 3502

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)



3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
# File 'lib/stripe/resources/quote.rb', line 3525

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.



3548
3549
3550
3551
3552
3553
3554
3555
# File 'lib/stripe/resources/quote.rb', line 3548

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.



3558
3559
3560
3561
3562
3563
3564
3565
# File 'lib/stripe/resources/quote.rb', line 3558

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.



3322
3323
3324
3325
3326
3327
3328
3329
# File 'lib/stripe/resources/quote.rb', line 3322

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.



3342
3343
3344
3345
3346
3347
3348
3349
# File 'lib/stripe/resources/quote.rb', line 3342

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.



3367
3368
3369
3370
3371
3372
3373
3374
# File 'lib/stripe/resources/quote.rb', line 3367

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.



3392
3393
3394
3395
3396
3397
3398
3399
# File 'lib/stripe/resources/quote.rb', line 3392

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.



3412
3413
3414
3415
3416
3417
3418
3419
# File 'lib/stripe/resources/quote.rb', line 3412

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.



3432
3433
3434
3435
3436
3437
3438
3439
# File 'lib/stripe/resources/quote.rb', line 3432

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.



3452
3453
3454
3455
3456
3457
3458
3459
# File 'lib/stripe/resources/quote.rb', line 3452

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.



3472
3473
3474
3475
3476
3477
3478
3479
# File 'lib/stripe/resources/quote.rb', line 3472

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.



3492
3493
3494
3495
3496
3497
3498
3499
# File 'lib/stripe/resources/quote.rb', line 3492

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)



3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
# File 'lib/stripe/resources/quote.rb', line 3512

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.



3538
3539
3540
3541
3542
3543
3544
3545
# File 'lib/stripe/resources/quote.rb', line 3538

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