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: AutomaticTax, Computed, FromQuote, InvoiceSettings, StatusDetails, StatusTransitions, SubscriptionData, SubscriptionDataOverride, SubscriptionSchedule, TotalDetails, TransferData

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

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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.



1152
1153
1154
# File 'lib/stripe/resources/quote.rb', line 1152

def allow_backdated_lines
  @allow_backdated_lines
end

#amount_subtotalObject (readonly)

Total before any discounts or taxes are applied.



1154
1155
1156
# File 'lib/stripe/resources/quote.rb', line 1154

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total after discounts and taxes are applied.



1156
1157
1158
# File 'lib/stripe/resources/quote.rb', line 1156

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect Application that created the quote.



1158
1159
1160
# File 'lib/stripe/resources/quote.rb', line 1158

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.



1160
1161
1162
# File 'lib/stripe/resources/quote.rb', line 1160

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.



1162
1163
1164
# File 'lib/stripe/resources/quote.rb', line 1162

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



1164
1165
1166
# File 'lib/stripe/resources/quote.rb', line 1164

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.



1166
1167
1168
# File 'lib/stripe/resources/quote.rb', line 1166

def collection_method
  @collection_method
end

#computedObject (readonly)

Attribute for field computed



1168
1169
1170
# File 'lib/stripe/resources/quote.rb', line 1168

def computed
  @computed
end

#createdObject (readonly)

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



1170
1171
1172
# File 'lib/stripe/resources/quote.rb', line 1170

def created
  @created
end

#currencyObject (readonly)

Three-letter ISO currency code, in lowercase. Must be a supported currency.



1172
1173
1174
# File 'lib/stripe/resources/quote.rb', line 1172

def currency
  @currency
end

#customerObject (readonly)

The customer who received this quote. A customer is required to finalize the quote. Once specified, you can't change it.



1174
1175
1176
# File 'lib/stripe/resources/quote.rb', line 1174

def customer
  @customer
end

#customer_accountObject (readonly)

The account representing the customer who received this quote. A customer or account is required to finalize the quote. Once specified, you can't change it.



1176
1177
1178
# File 'lib/stripe/resources/quote.rb', line 1176

def 
  @customer_account
end

#default_tax_ratesObject (readonly)

The tax rates applied to this quote.



1178
1179
1180
# File 'lib/stripe/resources/quote.rb', line 1178

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

A description that will be displayed on the quote PDF.



1180
1181
1182
# File 'lib/stripe/resources/quote.rb', line 1180

def description
  @description
end

#discountsObject (readonly)

The discounts applied to this quote.



1182
1183
1184
# File 'lib/stripe/resources/quote.rb', line 1182

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.



1184
1185
1186
# File 'lib/stripe/resources/quote.rb', line 1184

def expires_at
  @expires_at
end

A footer that will be displayed on the quote PDF.



1186
1187
1188
# File 'lib/stripe/resources/quote.rb', line 1186

def footer
  @footer
end

#from_quoteObject (readonly)

Details of the quote that was cloned. See the cloning documentation for more details.



1188
1189
1190
# File 'lib/stripe/resources/quote.rb', line 1188

def from_quote
  @from_quote
end

#headerObject (readonly)

A header that will be displayed on the quote PDF.



1190
1191
1192
# File 'lib/stripe/resources/quote.rb', line 1190

def header
  @header
end

#idObject (readonly)

Unique identifier for the object.



1192
1193
1194
# File 'lib/stripe/resources/quote.rb', line 1192

def id
  @id
end

#invoiceObject (readonly)

The invoice that was created from this quote.



1194
1195
1196
# File 'lib/stripe/resources/quote.rb', line 1194

def invoice
  @invoice
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



1196
1197
1198
# File 'lib/stripe/resources/quote.rb', line 1196

def invoice_settings
  @invoice_settings
end

#line_itemsObject (readonly)

A list of items the customer is being quoted for.



1198
1199
1200
# File 'lib/stripe/resources/quote.rb', line 1198

def line_items
  @line_items
end

#linesObject (readonly)

A list of 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.



1200
1201
1202
# File 'lib/stripe/resources/quote.rb', line 1200

def lines
  @lines
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



1202
1203
1204
# File 'lib/stripe/resources/quote.rb', line 1202

def livemode
  @livemode
end

#metadataObject (readonly)

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



1204
1205
1206
# File 'lib/stripe/resources/quote.rb', line 1204

def 
  @metadata
end

#numberObject (readonly)

A unique number that identifies this particular quote. This number is assigned once the quote is finalized.



1206
1207
1208
# File 'lib/stripe/resources/quote.rb', line 1206

def number
  @number
end

#objectObject (readonly)

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



1208
1209
1210
# File 'lib/stripe/resources/quote.rb', line 1208

def object
  @object
end

#on_behalf_ofObject (readonly)

The account on behalf of which to charge. See the Connect documentation for details.



1210
1211
1212
# File 'lib/stripe/resources/quote.rb', line 1210

def on_behalf_of
  @on_behalf_of
end

#statusObject (readonly)

The status of the quote.



1212
1213
1214
# File 'lib/stripe/resources/quote.rb', line 1212

def status
  @status
end

#status_detailsObject (readonly)

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



1214
1215
1216
# File 'lib/stripe/resources/quote.rb', line 1214

def status_details
  @status_details
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



1216
1217
1218
# File 'lib/stripe/resources/quote.rb', line 1216

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that was created or updated from this quote.



1218
1219
1220
# File 'lib/stripe/resources/quote.rb', line 1218

def subscription
  @subscription
end

#subscription_dataObject (readonly)

Attribute for field subscription_data



1220
1221
1222
# File 'lib/stripe/resources/quote.rb', line 1220

def subscription_data
  @subscription_data
end

#subscription_data_overridesObject (readonly)

List representing overrides for subscription_data configurations for specific subscription schedules.



1222
1223
1224
# File 'lib/stripe/resources/quote.rb', line 1222

def subscription_data_overrides
  @subscription_data_overrides
end

#subscription_scheduleObject (readonly)

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



1224
1225
1226
# File 'lib/stripe/resources/quote.rb', line 1224

def subscription_schedule
  @subscription_schedule
end

#subscription_schedulesObject (readonly)

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



1226
1227
1228
# File 'lib/stripe/resources/quote.rb', line 1226

def subscription_schedules
  @subscription_schedules
end

#test_clockObject (readonly)

ID of the test clock this quote belongs to.



1228
1229
1230
# File 'lib/stripe/resources/quote.rb', line 1228

def test_clock
  @test_clock
end

#total_detailsObject (readonly)

Attribute for field total_details



1230
1231
1232
# File 'lib/stripe/resources/quote.rb', line 1230

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.



1232
1233
1234
# File 'lib/stripe/resources/quote.rb', line 1232

def transfer_data
  @transfer_data
end

Class Method Details

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

Accepts the specified quote.



1245
1246
1247
1248
1249
1250
1251
1252
# File 'lib/stripe/resources/quote.rb', line 1245

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.



1265
1266
1267
1268
1269
1270
1271
1272
# File 'lib/stripe/resources/quote.rb', line 1265

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.



1275
1276
1277
# File 'lib/stripe/resources/quote.rb', line 1275

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/quotes", params: params, opts: opts)
end

.field_remappingsObject



1496
1497
1498
# File 'lib/stripe/resources/quote.rb', line 1496

def self.field_remappings
  @field_remappings = {}
end

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

Finalizes the quote.



1290
1291
1292
1293
1294
1295
1296
1297
# File 'lib/stripe/resources/quote.rb', line 1290

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

.inner_class_typesObject



1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
# File 'lib/stripe/resources/quote.rb', line 1480

def self.inner_class_types
  @inner_class_types = {
    automatic_tax: AutomaticTax,
    computed: Computed,
    from_quote: FromQuote,
    invoice_settings: InvoiceSettings,
    status_details: StatusDetails,
    status_transitions: StatusTransitions,
    subscription_data: SubscriptionData,
    subscription_data_overrides: SubscriptionDataOverride,
    subscription_schedules: SubscriptionSchedule,
    total_details: TotalDetails,
    transfer_data: TransferData,
  }
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of your quotes.



1300
1301
1302
# File 'lib/stripe/resources/quote.rb', line 1300

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



1315
1316
1317
1318
1319
1320
1321
1322
# File 'lib/stripe/resources/quote.rb', line 1315

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.



1335
1336
1337
1338
1339
1340
1341
1342
# File 'lib/stripe/resources/quote.rb', line 1335

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.



1355
1356
1357
1358
1359
1360
1361
1362
# File 'lib/stripe/resources/quote.rb', line 1355

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.



1375
1376
1377
1378
1379
1380
1381
1382
# File 'lib/stripe/resources/quote.rb', line 1375

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.



1395
1396
1397
1398
1399
1400
1401
1402
# File 'lib/stripe/resources/quote.rb', line 1395

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.



1415
1416
1417
1418
1419
1420
1421
1422
# File 'lib/stripe/resources/quote.rb', line 1415

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



1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
# File 'lib/stripe/resources/quote.rb', line 1438

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.



1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/stripe/resources/quote.rb', line 1461

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.



1471
1472
1473
1474
1475
1476
1477
1478
# File 'lib/stripe/resources/quote.rb', line 1471

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.



1235
1236
1237
1238
1239
1240
1241
1242
# File 'lib/stripe/resources/quote.rb', line 1235

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.



1255
1256
1257
1258
1259
1260
1261
1262
# File 'lib/stripe/resources/quote.rb', line 1255

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.



1280
1281
1282
1283
1284
1285
1286
1287
# File 'lib/stripe/resources/quote.rb', line 1280

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



1305
1306
1307
1308
1309
1310
1311
1312
# File 'lib/stripe/resources/quote.rb', line 1305

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.



1325
1326
1327
1328
1329
1330
1331
1332
# File 'lib/stripe/resources/quote.rb', line 1325

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.



1345
1346
1347
1348
1349
1350
1351
1352
# File 'lib/stripe/resources/quote.rb', line 1345

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.



1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/stripe/resources/quote.rb', line 1365

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.



1385
1386
1387
1388
1389
1390
1391
1392
# File 'lib/stripe/resources/quote.rb', line 1385

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.



1405
1406
1407
1408
1409
1410
1411
1412
# File 'lib/stripe/resources/quote.rb', line 1405

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



1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
# File 'lib/stripe/resources/quote.rb', line 1425

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.



1451
1452
1453
1454
1455
1456
1457
1458
# File 'lib/stripe/resources/quote.rb', line 1451

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