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.



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

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



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

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



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

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



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

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.



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

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.



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

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



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

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



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

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



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

def computed
  @computed
end

#createdObject (readonly)

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



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

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



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

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.



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

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.



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

def 
  @customer_account
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



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

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



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

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



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

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.



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

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



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

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.



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

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



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

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



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

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



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

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



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

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



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

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.



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

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.



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

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.



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

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



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

def number
  @number
end

#objectObject (readonly)

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



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

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.



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

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



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

def status
  @status
end

#status_detailsObject (readonly)

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



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

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



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

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



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

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



2876
2877
2878
# File 'lib/stripe/resources/quote.rb', line 2876

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

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



2878
2879
2880
# File 'lib/stripe/resources/quote.rb', line 2878

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

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



2880
2881
2882
# File 'lib/stripe/resources/quote.rb', line 2880

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

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



2882
2883
2884
# File 'lib/stripe/resources/quote.rb', line 2882

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



2884
2885
2886
# File 'lib/stripe/resources/quote.rb', line 2884

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



2886
2887
2888
# File 'lib/stripe/resources/quote.rb', line 2886

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.



2888
2889
2890
# File 'lib/stripe/resources/quote.rb', line 2888

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



2901
2902
2903
2904
2905
2906
2907
2908
# File 'lib/stripe/resources/quote.rb', line 2901

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.



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

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



2931
2932
2933
# File 'lib/stripe/resources/quote.rb', line 2931

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.



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

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.



2956
2957
2958
# File 'lib/stripe/resources/quote.rb', line 2956

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.



2971
2972
2973
2974
2975
2976
2977
2978
# File 'lib/stripe/resources/quote.rb', line 2971

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.



2991
2992
2993
2994
2995
2996
2997
2998
# File 'lib/stripe/resources/quote.rb', line 2991

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.



3011
3012
3013
3014
3015
3016
3017
3018
# File 'lib/stripe/resources/quote.rb', line 3011

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.



3031
3032
3033
3034
3035
3036
3037
3038
# File 'lib/stripe/resources/quote.rb', line 3031

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.



3051
3052
3053
3054
3055
3056
3057
3058
# File 'lib/stripe/resources/quote.rb', line 3051

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.



3071
3072
3073
3074
3075
3076
3077
3078
# File 'lib/stripe/resources/quote.rb', line 3071

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)



3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
# File 'lib/stripe/resources/quote.rb', line 3094

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.



3117
3118
3119
3120
3121
3122
3123
3124
# File 'lib/stripe/resources/quote.rb', line 3117

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.



3127
3128
3129
3130
3131
3132
3133
3134
# File 'lib/stripe/resources/quote.rb', line 3127

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.



2891
2892
2893
2894
2895
2896
2897
2898
# File 'lib/stripe/resources/quote.rb', line 2891

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.



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

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.



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

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.



2961
2962
2963
2964
2965
2966
2967
2968
# File 'lib/stripe/resources/quote.rb', line 2961

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.



2981
2982
2983
2984
2985
2986
2987
2988
# File 'lib/stripe/resources/quote.rb', line 2981

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.



3001
3002
3003
3004
3005
3006
3007
3008
# File 'lib/stripe/resources/quote.rb', line 3001

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.



3021
3022
3023
3024
3025
3026
3027
3028
# File 'lib/stripe/resources/quote.rb', line 3021

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.



3041
3042
3043
3044
3045
3046
3047
3048
# File 'lib/stripe/resources/quote.rb', line 3041

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.



3061
3062
3063
3064
3065
3066
3067
3068
# File 'lib/stripe/resources/quote.rb', line 3061

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)



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

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.



3107
3108
3109
3110
3111
3112
3113
3114
# File 'lib/stripe/resources/quote.rb', line 3107

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