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.



2783
2784
2785
# File 'lib/stripe/resources/quote.rb', line 2783

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



2785
2786
2787
# File 'lib/stripe/resources/quote.rb', line 2785

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



2787
2788
2789
# File 'lib/stripe/resources/quote.rb', line 2787

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



2789
2790
2791
# File 'lib/stripe/resources/quote.rb', line 2789

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.



2791
2792
2793
# File 'lib/stripe/resources/quote.rb', line 2791

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.



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

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



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

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



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

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



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

def computed
  @computed
end

#createdObject (readonly)

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



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

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



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

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.



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

def customer
  @customer
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



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

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



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

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



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

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.



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

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



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

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.



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

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



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

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



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

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



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

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



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

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



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

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.



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

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.



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

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.



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

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



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

def number
  @number
end

#objectObject (readonly)

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



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

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.



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

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



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

def status
  @status
end

#status_detailsObject (readonly)

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



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

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



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

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



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

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



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

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

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



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

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

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



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

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

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



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

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



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

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



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

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.



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

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



2874
2875
2876
2877
2878
2879
2880
2881
# File 'lib/stripe/resources/quote.rb', line 2874

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.



2894
2895
2896
2897
2898
2899
2900
2901
# File 'lib/stripe/resources/quote.rb', line 2894

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



2904
2905
2906
# File 'lib/stripe/resources/quote.rb', line 2904

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.



2919
2920
2921
2922
2923
2924
2925
2926
# File 'lib/stripe/resources/quote.rb', line 2919

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.



2929
2930
2931
# File 'lib/stripe/resources/quote.rb', line 2929

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.



2944
2945
2946
2947
2948
2949
2950
2951
# File 'lib/stripe/resources/quote.rb', line 2944

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.



2964
2965
2966
2967
2968
2969
2970
2971
# File 'lib/stripe/resources/quote.rb', line 2964

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.



2984
2985
2986
2987
2988
2989
2990
2991
# File 'lib/stripe/resources/quote.rb', line 2984

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.



3004
3005
3006
3007
3008
3009
3010
3011
# File 'lib/stripe/resources/quote.rb', line 3004

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.



3024
3025
3026
3027
3028
3029
3030
3031
# File 'lib/stripe/resources/quote.rb', line 3024

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.



3044
3045
3046
3047
3048
3049
3050
3051
# File 'lib/stripe/resources/quote.rb', line 3044

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)



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

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.



3090
3091
3092
3093
3094
3095
3096
3097
# File 'lib/stripe/resources/quote.rb', line 3090

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.



3100
3101
3102
3103
3104
3105
3106
3107
# File 'lib/stripe/resources/quote.rb', line 3100

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.



2864
2865
2866
2867
2868
2869
2870
2871
# File 'lib/stripe/resources/quote.rb', line 2864

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.



2884
2885
2886
2887
2888
2889
2890
2891
# File 'lib/stripe/resources/quote.rb', line 2884

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.



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

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.



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

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.



2954
2955
2956
2957
2958
2959
2960
2961
# File 'lib/stripe/resources/quote.rb', line 2954

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.



2974
2975
2976
2977
2978
2979
2980
2981
# File 'lib/stripe/resources/quote.rb', line 2974

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.



2994
2995
2996
2997
2998
2999
3000
3001
# File 'lib/stripe/resources/quote.rb', line 2994

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.



3014
3015
3016
3017
3018
3019
3020
3021
# File 'lib/stripe/resources/quote.rb', line 3014

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.



3034
3035
3036
3037
3038
3039
3040
3041
# File 'lib/stripe/resources/quote.rb', line 3034

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)



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

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.



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

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