Class: Stripe::Order

Inherits:
APIResource show all
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, CancelParams, CreateParams, Credit, ListLineItemsParams, ListParams, Payment, ReopenParams, RetrieveParams, ShippingCost, ShippingDetails, SubmitParams, TaxDetails, TotalDetails, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"order"

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_remainingObject (readonly)

Attribute for field amount_remaining



3060
3061
3062
# File 'lib/stripe/resources/order.rb', line 3060

def amount_remaining
  @amount_remaining
end

#amount_subtotalObject (readonly)

Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the [smallest currency unit](stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).



3063
3064
3065
# File 'lib/stripe/resources/order.rb', line 3063

def amount_subtotal
  @amount_subtotal
end

#amount_totalObject (readonly)

Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the [smallest currency unit](stripe.com/docs/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](stripe.com/docs/currencies#minimum-and-maximum-charge-amounts).



3066
3067
3068
# File 'lib/stripe/resources/order.rb', line 3066

def amount_total
  @amount_total
end

#applicationObject (readonly)

ID of the Connect application that created the Order, if any.



3069
3070
3071
# File 'lib/stripe/resources/order.rb', line 3069

def application
  @application
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



3072
3073
3074
# File 'lib/stripe/resources/order.rb', line 3072

def automatic_tax
  @automatic_tax
end

#billing_detailsObject (readonly)

Customer billing details associated with the order.



3075
3076
3077
# File 'lib/stripe/resources/order.rb', line 3075

def billing_details
  @billing_details
end

#client_secretObject (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](stripe.com/docs/orders-beta/create-and-process) to learn about how client_secret should be handled.



3082
3083
3084
# File 'lib/stripe/resources/order.rb', line 3082

def client_secret
  @client_secret
end

#createdObject (readonly)

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



3085
3086
3087
# File 'lib/stripe/resources/order.rb', line 3085

def created
  @created
end

#creditsObject (readonly)

The credits applied to the Order. At most 10 credits can be applied to an Order.



3088
3089
3090
# File 'lib/stripe/resources/order.rb', line 3088

def credits
  @credits
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).



3091
3092
3093
# File 'lib/stripe/resources/order.rb', line 3091

def currency
  @currency
end

#customerObject (readonly)

The customer which this orders belongs to.



3094
3095
3096
# File 'lib/stripe/resources/order.rb', line 3094

def customer
  @customer
end

#descriptionObject (readonly)

An arbitrary string attached to the object. Often useful for displaying to users.



3097
3098
3099
# File 'lib/stripe/resources/order.rb', line 3097

def description
  @description
end

#discountsObject (readonly)

The discounts applied to the order. Use ‘expand[]=discounts` to expand each discount.



3100
3101
3102
# File 'lib/stripe/resources/order.rb', line 3100

def discounts
  @discounts
end

#idObject (readonly)

Unique identifier for the object.



3103
3104
3105
# File 'lib/stripe/resources/order.rb', line 3103

def id
  @id
end

#ip_addressObject (readonly)

A recent IP address of the purchaser used for tax reporting and tax location inference.



3106
3107
3108
# File 'lib/stripe/resources/order.rb', line 3106

def ip_address
  @ip_address
end

#line_itemsObject (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.



3109
3110
3111
# File 'lib/stripe/resources/order.rb', line 3109

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.



3112
3113
3114
# File 'lib/stripe/resources/order.rb', line 3112

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.



3115
3116
3117
# File 'lib/stripe/resources/order.rb', line 3115

def 
  @metadata
end

#objectObject (readonly)

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



3118
3119
3120
# File 'lib/stripe/resources/order.rb', line 3118

def object
  @object
end

#paymentObject (readonly)

Attribute for field payment



3121
3122
3123
# File 'lib/stripe/resources/order.rb', line 3121

def payment
  @payment
end

#shipping_costObject (readonly)

The details of the customer cost of shipping, including the customer chosen ShippingRate.



3124
3125
3126
# File 'lib/stripe/resources/order.rb', line 3124

def shipping_cost
  @shipping_cost
end

#shipping_detailsObject (readonly)

Customer shipping information associated with the order.



3127
3128
3129
# File 'lib/stripe/resources/order.rb', line 3127

def shipping_details
  @shipping_details
end

#statusObject (readonly)

The overall status of the order.



3130
3131
3132
# File 'lib/stripe/resources/order.rb', line 3130

def status
  @status
end

#tax_detailsObject (readonly)

Attribute for field tax_details



3133
3134
3135
# File 'lib/stripe/resources/order.rb', line 3133

def tax_details
  @tax_details
end

#total_detailsObject (readonly)

Attribute for field total_details



3136
3137
3138
# File 'lib/stripe/resources/order.rb', line 3136

def total_details
  @total_details
end

Class Method Details

.cancel(id, params = {}, opts = {}) ⇒ Object

Cancels the order as well as the payment intent if one is attached.



3149
3150
3151
3152
3153
3154
3155
3156
# File 'lib/stripe/resources/order.rb', line 3149

def self.cancel(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/orders/%<id>s/cancel", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

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

Creates a new open order object.



3159
3160
3161
# File 'lib/stripe/resources/order.rb', line 3159

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/orders", params: params, opts: opts)
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.



3164
3165
3166
# File 'lib/stripe/resources/order.rb', line 3164

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/orders", params: params, opts: opts)
end

.list_line_items(id, params = {}, opts = {}) ⇒ Object

When retrieving an order, 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.



3179
3180
3181
3182
3183
3184
3185
3186
# File 'lib/stripe/resources/order.rb', line 3179

def self.list_line_items(id, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/orders/%<id>s/line_items", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

.object_nameObject



16
17
18
# File 'lib/stripe/resources/order.rb', line 16

def self.object_name
  "order"
end

.reopen(id, params = {}, opts = {}) ⇒ Object

Reopens a submitted order.



3199
3200
3201
3202
3203
3204
3205
3206
# File 'lib/stripe/resources/order.rb', line 3199

def self.reopen(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/orders/%<id>s/reopen", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
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](stripe.com/docs/api#reopen_order) method is called.



3219
3220
3221
3222
3223
3224
3225
3226
# File 'lib/stripe/resources/order.rb', line 3219

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.



3229
3230
3231
3232
3233
3234
3235
3236
# File 'lib/stripe/resources/order.rb', line 3229

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

#cancel(params = {}, opts = {}) ⇒ Object

Cancels the order as well as the payment intent if one is attached.



3139
3140
3141
3142
3143
3144
3145
3146
# File 'lib/stripe/resources/order.rb', line 3139

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/orders/%<id>s/cancel", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#list_line_items(params = {}, opts = {}) ⇒ Object

When retrieving an order, 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.



3169
3170
3171
3172
3173
3174
3175
3176
# File 'lib/stripe/resources/order.rb', line 3169

def list_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/orders/%<id>s/line_items", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#reopen(params = {}, opts = {}) ⇒ Object

Reopens a submitted order.



3189
3190
3191
3192
3193
3194
3195
3196
# File 'lib/stripe/resources/order.rb', line 3189

def reopen(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/orders/%<id>s/reopen", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#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](stripe.com/docs/api#reopen_order) method is called.



3209
3210
3211
3212
3213
3214
3215
3216
# File 'lib/stripe/resources/order.rb', line 3209

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