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



2794
2795
2796
# File 'lib/stripe/resources/quote.rb', line 2794

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



2796
2797
2798
# File 'lib/stripe/resources/quote.rb', line 2796

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



2798
2799
2800
# File 'lib/stripe/resources/quote.rb', line 2798

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



2800
2801
2802
# File 'lib/stripe/resources/quote.rb', line 2800

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.



2802
2803
2804
# File 'lib/stripe/resources/quote.rb', line 2802

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.



2804
2805
2806
# File 'lib/stripe/resources/quote.rb', line 2804

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



2806
2807
2808
# File 'lib/stripe/resources/quote.rb', line 2806

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



2808
2809
2810
# File 'lib/stripe/resources/quote.rb', line 2808

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



2810
2811
2812
# File 'lib/stripe/resources/quote.rb', line 2810

def computed
  @computed
end

#createdObject (readonly)

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



2812
2813
2814
# File 'lib/stripe/resources/quote.rb', line 2812

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



2814
2815
2816
# File 'lib/stripe/resources/quote.rb', line 2814

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.



2816
2817
2818
# File 'lib/stripe/resources/quote.rb', line 2816

def customer
  @customer
end

#customer_accountObject (readonly)

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



2818
2819
2820
# File 'lib/stripe/resources/quote.rb', line 2818

def 
  @customer_account
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



2820
2821
2822
# File 'lib/stripe/resources/quote.rb', line 2820

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



2822
2823
2824
# File 'lib/stripe/resources/quote.rb', line 2822

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



2824
2825
2826
# File 'lib/stripe/resources/quote.rb', line 2824

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.



2826
2827
2828
# File 'lib/stripe/resources/quote.rb', line 2826

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



2828
2829
2830
# File 'lib/stripe/resources/quote.rb', line 2828

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.



2830
2831
2832
# File 'lib/stripe/resources/quote.rb', line 2830

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



2832
2833
2834
# File 'lib/stripe/resources/quote.rb', line 2832

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



2834
2835
2836
# File 'lib/stripe/resources/quote.rb', line 2834

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



2836
2837
2838
# File 'lib/stripe/resources/quote.rb', line 2836

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



2838
2839
2840
# File 'lib/stripe/resources/quote.rb', line 2838

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



2840
2841
2842
# File 'lib/stripe/resources/quote.rb', line 2840

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.



2842
2843
2844
# File 'lib/stripe/resources/quote.rb', line 2842

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.



2844
2845
2846
# File 'lib/stripe/resources/quote.rb', line 2844

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.



2846
2847
2848
# File 'lib/stripe/resources/quote.rb', line 2846

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



2848
2849
2850
# File 'lib/stripe/resources/quote.rb', line 2848

def number
  @number
end

#objectObject (readonly)

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



2850
2851
2852
# File 'lib/stripe/resources/quote.rb', line 2850

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.



2852
2853
2854
# File 'lib/stripe/resources/quote.rb', line 2852

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



2854
2855
2856
# File 'lib/stripe/resources/quote.rb', line 2854

def status
  @status
end

#status_detailsObject (readonly)

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



2856
2857
2858
# File 'lib/stripe/resources/quote.rb', line 2856

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



2858
2859
2860
# File 'lib/stripe/resources/quote.rb', line 2858

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



2860
2861
2862
# File 'lib/stripe/resources/quote.rb', line 2860

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



2862
2863
2864
# File 'lib/stripe/resources/quote.rb', line 2862

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

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



2864
2865
2866
# File 'lib/stripe/resources/quote.rb', line 2864

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

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



2866
2867
2868
# File 'lib/stripe/resources/quote.rb', line 2866

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

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



2868
2869
2870
# File 'lib/stripe/resources/quote.rb', line 2868

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



2870
2871
2872
# File 'lib/stripe/resources/quote.rb', line 2870

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



2872
2873
2874
# File 'lib/stripe/resources/quote.rb', line 2872

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.



2874
2875
2876
# File 'lib/stripe/resources/quote.rb', line 2874

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



2887
2888
2889
2890
2891
2892
2893
2894
# File 'lib/stripe/resources/quote.rb', line 2887

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.



2907
2908
2909
2910
2911
2912
2913
2914
# File 'lib/stripe/resources/quote.rb', line 2907

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



2917
2918
2919
# File 'lib/stripe/resources/quote.rb', line 2917

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.



2932
2933
2934
2935
2936
2937
2938
2939
# File 'lib/stripe/resources/quote.rb', line 2932

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.



2942
2943
2944
# File 'lib/stripe/resources/quote.rb', line 2942

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.



2957
2958
2959
2960
2961
2962
2963
2964
# File 'lib/stripe/resources/quote.rb', line 2957

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.



2977
2978
2979
2980
2981
2982
2983
2984
# File 'lib/stripe/resources/quote.rb', line 2977

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.



2997
2998
2999
3000
3001
3002
3003
3004
# File 'lib/stripe/resources/quote.rb', line 2997

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.



3017
3018
3019
3020
3021
3022
3023
3024
# File 'lib/stripe/resources/quote.rb', line 3017

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.



3037
3038
3039
3040
3041
3042
3043
3044
# File 'lib/stripe/resources/quote.rb', line 3037

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.



3057
3058
3059
3060
3061
3062
3063
3064
# File 'lib/stripe/resources/quote.rb', line 3057

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)



3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
# File 'lib/stripe/resources/quote.rb', line 3080

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.



3103
3104
3105
3106
3107
3108
3109
3110
# File 'lib/stripe/resources/quote.rb', line 3103

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

A quote models prices and services for a customer.



3113
3114
3115
3116
3117
3118
3119
3120
# File 'lib/stripe/resources/quote.rb', line 3113

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

Instance Method Details

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

Accepts the specified quote.



2877
2878
2879
2880
2881
2882
2883
2884
# File 'lib/stripe/resources/quote.rb', line 2877

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.



2897
2898
2899
2900
2901
2902
2903
2904
# File 'lib/stripe/resources/quote.rb', line 2897

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.



2922
2923
2924
2925
2926
2927
2928
2929
# File 'lib/stripe/resources/quote.rb', line 2922

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.



2947
2948
2949
2950
2951
2952
2953
2954
# File 'lib/stripe/resources/quote.rb', line 2947

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.



2967
2968
2969
2970
2971
2972
2973
2974
# File 'lib/stripe/resources/quote.rb', line 2967

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.



2987
2988
2989
2990
2991
2992
2993
2994
# File 'lib/stripe/resources/quote.rb', line 2987

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.



3007
3008
3009
3010
3011
3012
3013
3014
# File 'lib/stripe/resources/quote.rb', line 3007

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.



3027
3028
3029
3030
3031
3032
3033
3034
# File 'lib/stripe/resources/quote.rb', line 3027

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.



3047
3048
3049
3050
3051
3052
3053
3054
# File 'lib/stripe/resources/quote.rb', line 3047

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)



3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
# File 'lib/stripe/resources/quote.rb', line 3067

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.



3093
3094
3095
3096
3097
3098
3099
3100
# File 'lib/stripe/resources/quote.rb', line 3093

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