Class: Stripe::Order
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Order
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/order.rb
Overview
An Order describes a purchase being made by a customer, including the products & quantities being purchased, the order status, the payment information, and the billing/shipping details.
Related guide: [Orders overview](stripe.com/docs/orders)
Defined Under Namespace
Classes: AutomaticTax, BillingDetails, Payment, ShippingCost, ShippingDetails, TaxDetails, TotalDetails
Constant Summary collapse
- OBJECT_NAME =
"order"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#amount_subtotal ⇒ Object
readonly
Order cost before any discounts or taxes are applied.
-
#amount_total ⇒ Object
readonly
Total order cost after discounts and taxes are applied.
-
#application ⇒ Object
readonly
ID of the Connect application that created the Order, if any.
-
#automatic_tax ⇒ Object
readonly
Attribute for field automatic_tax.
-
#billing_details ⇒ Object
readonly
Customer billing details associated with the order.
-
#client_secret ⇒ Object
readonly
The client secret of this Order.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#currency ⇒ Object
readonly
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase.
-
#customer ⇒ Object
readonly
The customer which this orders belongs to.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#discounts ⇒ Object
readonly
The discounts applied to the order.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#ip_address ⇒ Object
readonly
A recent IP address of the purchaser used for tax reporting and tax location inference.
-
#line_items ⇒ Object
readonly
A list of line items the customer is ordering.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is ‘true`.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#payment ⇒ Object
readonly
Attribute for field payment.
-
#shipping_cost ⇒ Object
readonly
The details of the customer cost of shipping, including the customer chosen ShippingRate.
-
#shipping_details ⇒ Object
readonly
Customer shipping information associated with the order.
-
#status ⇒ Object
readonly
The overall status of the order.
-
#tax_details ⇒ Object
readonly
Attribute for field tax_details.
-
#total_details ⇒ Object
readonly
Attribute for field total_details.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a new open order object.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your orders.
- .object_name ⇒ Object
-
.submit(id, params = {}, opts = {}) ⇒ Object
Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid.
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specific order by setting the values of the parameters passed.
Instance Method Summary collapse
-
#submit(params = {}, opts = {}) ⇒ Object
Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::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
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
#amount_subtotal ⇒ Object (readonly)
Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the [smallest currency unit](docs.stripe.com/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
821 822 823 |
# File 'lib/stripe/resources/order.rb', line 821 def amount_subtotal @amount_subtotal end |
#amount_total ⇒ Object (readonly)
Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the [smallest currency unit](docs.stripe.com/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or [equivalent in charge currency](docs.stripe.com/currencies#minimum-and-maximum-charge-amounts).
823 824 825 |
# File 'lib/stripe/resources/order.rb', line 823 def amount_total @amount_total end |
#application ⇒ Object (readonly)
ID of the Connect application that created the Order, if any.
825 826 827 |
# File 'lib/stripe/resources/order.rb', line 825 def application @application end |
#automatic_tax ⇒ Object (readonly)
Attribute for field automatic_tax
827 828 829 |
# File 'lib/stripe/resources/order.rb', line 827 def automatic_tax @automatic_tax end |
#billing_details ⇒ Object (readonly)
Customer billing details associated with the order.
829 830 831 |
# File 'lib/stripe/resources/order.rb', line 829 def billing_details @billing_details end |
#client_secret ⇒ Object (readonly)
The client secret of this Order. Used for client-side retrieval using a publishable key.
The client secret can be used to complete a payment for an Order from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
Refer to our docs for [creating and processing an order](docs.stripe.com/orders-beta/create-and-process) to learn about how client_secret should be handled.
835 836 837 |
# File 'lib/stripe/resources/order.rb', line 835 def client_secret @client_secret end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
837 838 839 |
# File 'lib/stripe/resources/order.rb', line 837 def created @created end |
#currency ⇒ Object (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).
839 840 841 |
# File 'lib/stripe/resources/order.rb', line 839 def currency @currency end |
#customer ⇒ Object (readonly)
The customer which this orders belongs to.
841 842 843 |
# File 'lib/stripe/resources/order.rb', line 841 def customer @customer end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
843 844 845 |
# File 'lib/stripe/resources/order.rb', line 843 def description @description end |
#discounts ⇒ Object (readonly)
The discounts applied to the order. Use ‘expand[]=discounts` to expand each discount.
845 846 847 |
# File 'lib/stripe/resources/order.rb', line 845 def discounts @discounts end |
#id ⇒ Object (readonly)
Unique identifier for the object.
847 848 849 |
# File 'lib/stripe/resources/order.rb', line 847 def id @id end |
#ip_address ⇒ Object (readonly)
A recent IP address of the purchaser used for tax reporting and tax location inference.
849 850 851 |
# File 'lib/stripe/resources/order.rb', line 849 def ip_address @ip_address end |
#line_items ⇒ Object (readonly)
A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. There is a maximum of 100 line items.
851 852 853 |
# File 'lib/stripe/resources/order.rb', line 851 def line_items @line_items end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.
853 854 855 |
# File 'lib/stripe/resources/order.rb', line 853 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
855 856 857 |
# File 'lib/stripe/resources/order.rb', line 855 def @metadata end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
857 858 859 |
# File 'lib/stripe/resources/order.rb', line 857 def object @object end |
#payment ⇒ Object (readonly)
Attribute for field payment
859 860 861 |
# File 'lib/stripe/resources/order.rb', line 859 def payment @payment end |
#shipping_cost ⇒ Object (readonly)
The details of the customer cost of shipping, including the customer chosen ShippingRate.
861 862 863 |
# File 'lib/stripe/resources/order.rb', line 861 def shipping_cost @shipping_cost end |
#shipping_details ⇒ Object (readonly)
Customer shipping information associated with the order.
863 864 865 |
# File 'lib/stripe/resources/order.rb', line 863 def shipping_details @shipping_details end |
#status ⇒ Object (readonly)
The overall status of the order.
865 866 867 |
# File 'lib/stripe/resources/order.rb', line 865 def status @status end |
#tax_details ⇒ Object (readonly)
Attribute for field tax_details
867 868 869 |
# File 'lib/stripe/resources/order.rb', line 867 def tax_details @tax_details end |
#total_details ⇒ Object (readonly)
Attribute for field total_details
869 870 871 |
# File 'lib/stripe/resources/order.rb', line 869 def total_details @total_details end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new open order object.
872 873 874 |
# File 'lib/stripe/resources/order.rb', line 872 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/orders", params: params, opts: opts) end |
.field_remappings ⇒ Object
923 924 925 |
# File 'lib/stripe/resources/order.rb', line 923 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/stripe/resources/order.rb', line 911 def self.inner_class_types @inner_class_types = { automatic_tax: AutomaticTax, billing_details: BillingDetails, payment: Payment, shipping_cost: ShippingCost, shipping_details: ShippingDetails, tax_details: TaxDetails, total_details: TotalDetails, } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your orders. The orders are returned sorted by creation date, with the most recently created orders appearing first.
877 878 879 |
# File 'lib/stripe/resources/order.rb', line 877 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/orders", params: params, opts: opts) end |
.object_name ⇒ Object
16 17 18 |
# File 'lib/stripe/resources/order.rb', line 16 def self.object_name "order" end |
.submit(id, params = {}, opts = {}) ⇒ Object
Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](docs.stripe.com/api#reopen_order) method is called.
892 893 894 895 896 897 898 899 |
# File 'lib/stripe/resources/order.rb', line 892 def self.submit(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/orders/%<id>s/submit", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specific order by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
902 903 904 905 906 907 908 909 |
# File 'lib/stripe/resources/order.rb', line 902 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/orders/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
Instance Method Details
#submit(params = {}, opts = {}) ⇒ Object
Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](docs.stripe.com/api#reopen_order) method is called.
882 883 884 885 886 887 888 889 |
# File 'lib/stripe/resources/order.rb', line 882 def submit(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/orders/%<id>s/submit", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |