Class: Stripe::Quote

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
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, ListParams, PdfParams, StatusTransitions, SubscriptionData, 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::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

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



866
867
868
# File 'lib/stripe/resources/quote.rb', line 866

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



868
869
870
# File 'lib/stripe/resources/quote.rb', line 868

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



870
871
872
# File 'lib/stripe/resources/quote.rb', line 870

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.



872
873
874
# File 'lib/stripe/resources/quote.rb', line 872

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.



874
875
876
# File 'lib/stripe/resources/quote.rb', line 874

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



876
877
878
# File 'lib/stripe/resources/quote.rb', line 876

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



878
879
880
# File 'lib/stripe/resources/quote.rb', line 878

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



880
881
882
# File 'lib/stripe/resources/quote.rb', line 880

def computed
  @computed
end

#createdObject (readonly)

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



882
883
884
# File 'lib/stripe/resources/quote.rb', line 882

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



884
885
886
# File 'lib/stripe/resources/quote.rb', line 884

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.



886
887
888
# File 'lib/stripe/resources/quote.rb', line 886

def customer
  @customer
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



888
889
890
# File 'lib/stripe/resources/quote.rb', line 888

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



890
891
892
# File 'lib/stripe/resources/quote.rb', line 890

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



892
893
894
# File 'lib/stripe/resources/quote.rb', line 892

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.



894
895
896
# File 'lib/stripe/resources/quote.rb', line 894

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



896
897
898
# File 'lib/stripe/resources/quote.rb', line 896

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.



898
899
900
# File 'lib/stripe/resources/quote.rb', line 898

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



900
901
902
# File 'lib/stripe/resources/quote.rb', line 900

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



902
903
904
# File 'lib/stripe/resources/quote.rb', line 902

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



904
905
906
# File 'lib/stripe/resources/quote.rb', line 904

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



906
907
908
# File 'lib/stripe/resources/quote.rb', line 906

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



908
909
910
# File 'lib/stripe/resources/quote.rb', line 908

def line_items
  @line_items
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.



910
911
912
# File 'lib/stripe/resources/quote.rb', line 910

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.



912
913
914
# File 'lib/stripe/resources/quote.rb', line 912

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



914
915
916
# File 'lib/stripe/resources/quote.rb', line 914

def number
  @number
end

#objectObject (readonly)

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



916
917
918
# File 'lib/stripe/resources/quote.rb', line 916

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.



918
919
920
# File 'lib/stripe/resources/quote.rb', line 918

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



920
921
922
# File 'lib/stripe/resources/quote.rb', line 920

def status
  @status
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



922
923
924
# File 'lib/stripe/resources/quote.rb', line 922

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



924
925
926
# File 'lib/stripe/resources/quote.rb', line 924

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



926
927
928
# File 'lib/stripe/resources/quote.rb', line 926

def subscription_data
  @subscription_data
end

#subscription_scheduleObject (readonly)

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



928
929
930
# File 'lib/stripe/resources/quote.rb', line 928

def subscription_schedule
  @subscription_schedule
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



930
931
932
# File 'lib/stripe/resources/quote.rb', line 930

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



932
933
934
# File 'lib/stripe/resources/quote.rb', line 932

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.



934
935
936
# File 'lib/stripe/resources/quote.rb', line 934

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



947
948
949
950
951
952
953
954
# File 'lib/stripe/resources/quote.rb', line 947

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.



967
968
969
970
971
972
973
974
# File 'lib/stripe/resources/quote.rb', line 967

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



977
978
979
# File 'lib/stripe/resources/quote.rb', line 977

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.



992
993
994
995
996
997
998
999
# File 'lib/stripe/resources/quote.rb', line 992

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.



1002
1003
1004
# File 'lib/stripe/resources/quote.rb', line 1002

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.



1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/stripe/resources/quote.rb', line 1017

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.



1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/stripe/resources/quote.rb', line 1037

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

.object_nameObject



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

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)



1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
# File 'lib/stripe/resources/quote.rb', line 1060

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

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

A quote models prices and services for a customer.



1073
1074
1075
1076
1077
1078
1079
1080
# File 'lib/stripe/resources/quote.rb', line 1073

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.



937
938
939
940
941
942
943
944
# File 'lib/stripe/resources/quote.rb', line 937

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.



957
958
959
960
961
962
963
964
# File 'lib/stripe/resources/quote.rb', line 957

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.



982
983
984
985
986
987
988
989
# File 'lib/stripe/resources/quote.rb', line 982

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.



1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/stripe/resources/quote.rb', line 1007

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.



1027
1028
1029
1030
1031
1032
1033
1034
# File 'lib/stripe/resources/quote.rb', line 1027

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

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



1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
# File 'lib/stripe/resources/quote.rb', line 1047

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