Class: Stripe::Checkout::SessionService::CreateParams

Inherits:
RequestParams
  • Object
show all
Defined in:
lib/stripe/services/checkout/session_service.rb

Defined Under Namespace

Classes: AdaptivePricing, AfterExpiration, AutomaticTax, ConsentCollection, CustomField, CustomText, CustomerUpdate, Discount, InvoiceCreation, LineItem, OptionalItem, PaymentIntentData, PaymentMethodData, PaymentMethodOptions, Permissions, PhoneNumberCollection, SavedPaymentMethodOptions, SetupIntentData, ShippingAddressCollection, ShippingOption, SubscriptionData, TaxIdCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RequestParams

#to_h

Constructor Details

#initialize(adaptive_pricing: nil, after_expiration: nil, allow_promotion_codes: nil, automatic_tax: nil, billing_address_collection: nil, cancel_url: nil, client_reference_id: nil, consent_collection: nil, currency: nil, custom_fields: nil, custom_text: nil, customer: nil, customer_creation: nil, customer_email: nil, customer_update: nil, discounts: nil, expand: nil, expires_at: nil, invoice_creation: nil, line_items: nil, locale: nil, metadata: nil, mode: nil, optional_items: nil, payment_intent_data: nil, payment_method_collection: nil, payment_method_configuration: nil, payment_method_data: nil, payment_method_options: nil, payment_method_types: nil, permissions: nil, phone_number_collection: nil, redirect_on_completion: nil, return_url: nil, saved_payment_method_options: nil, setup_intent_data: nil, shipping_address_collection: nil, shipping_options: nil, submit_type: nil, subscription_data: nil, success_url: nil, tax_id_collection: nil, ui_mode: nil) ⇒ CreateParams

Returns a new instance of CreateParams.



2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
# File 'lib/stripe/services/checkout/session_service.rb', line 2121

def initialize(
  adaptive_pricing: nil,
  after_expiration: nil,
  allow_promotion_codes: nil,
  automatic_tax: nil,
  billing_address_collection: nil,
  cancel_url: nil,
  client_reference_id: nil,
  consent_collection: nil,
  currency: nil,
  custom_fields: nil,
  custom_text: nil,
  customer: nil,
  customer_creation: nil,
  customer_email: nil,
  customer_update: nil,
  discounts: nil,
  expand: nil,
  expires_at: nil,
  invoice_creation: nil,
  line_items: nil,
  locale: nil,
  metadata: nil,
  mode: nil,
  optional_items: nil,
  payment_intent_data: nil,
  payment_method_collection: nil,
  payment_method_configuration: nil,
  payment_method_data: nil,
  payment_method_options: nil,
  payment_method_types: nil,
  permissions: nil,
  phone_number_collection: nil,
  redirect_on_completion: nil,
  return_url: nil,
  saved_payment_method_options: nil,
  setup_intent_data: nil,
  shipping_address_collection: nil,
  shipping_options: nil,
  submit_type: nil,
  subscription_data: nil,
  success_url: nil,
  tax_id_collection: nil,
  ui_mode: nil
)
  @adaptive_pricing = adaptive_pricing
  @after_expiration = after_expiration
  @allow_promotion_codes = allow_promotion_codes
  @automatic_tax = automatic_tax
  @billing_address_collection = billing_address_collection
  @cancel_url = cancel_url
  @client_reference_id = client_reference_id
  @consent_collection = consent_collection
  @currency = currency
  @custom_fields = custom_fields
  @custom_text = custom_text
  @customer = customer
  @customer_creation = customer_creation
  @customer_email = customer_email
  @customer_update = customer_update
  @discounts = discounts
  @expand = expand
  @expires_at = expires_at
  @invoice_creation = invoice_creation
  @line_items = line_items
  @locale = locale
  @metadata = 
  @mode = mode
  @optional_items = optional_items
  @payment_intent_data = payment_intent_data
  @payment_method_collection = payment_method_collection
  @payment_method_configuration = payment_method_configuration
  @payment_method_data = payment_method_data
  @payment_method_options = payment_method_options
  @payment_method_types = payment_method_types
  @permissions = permissions
  @phone_number_collection = phone_number_collection
  @redirect_on_completion = redirect_on_completion
  @return_url = return_url
  @saved_payment_method_options = saved_payment_method_options
  @setup_intent_data = setup_intent_data
  @shipping_address_collection = shipping_address_collection
  @shipping_options = shipping_options
  @submit_type = submit_type
  @subscription_data = subscription_data
  @success_url = success_url
  @tax_id_collection = tax_id_collection
  @ui_mode = ui_mode
end

Instance Attribute Details

#adaptive_pricingObject

Settings for price localization with [Adaptive Pricing](docs.stripe.com/payments/checkout/adaptive-pricing).



1972
1973
1974
# File 'lib/stripe/services/checkout/session_service.rb', line 1972

def adaptive_pricing
  @adaptive_pricing
end

#after_expirationObject

Configure actions after a Checkout Session has expired.



1974
1975
1976
# File 'lib/stripe/services/checkout/session_service.rb', line 1974

def after_expiration
  @after_expiration
end

#allow_promotion_codesObject

Enables user redeemable promotion codes.



1976
1977
1978
# File 'lib/stripe/services/checkout/session_service.rb', line 1976

def allow_promotion_codes
  @allow_promotion_codes
end

#automatic_taxObject

Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions.



1978
1979
1980
# File 'lib/stripe/services/checkout/session_service.rb', line 1978

def automatic_tax
  @automatic_tax
end

#billing_address_collectionObject

Specify whether Checkout should collect the customer’s billing address. Defaults to ‘auto`.



1980
1981
1982
# File 'lib/stripe/services/checkout/session_service.rb', line 1980

def billing_address_collection
  @billing_address_collection
end

#cancel_urlObject

If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. This parameter is not allowed if ui_mode is ‘embedded` or `custom`.



1982
1983
1984
# File 'lib/stripe/services/checkout/session_service.rb', line 1982

def cancel_url
  @cancel_url
end

#client_reference_idObject

A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems.



1986
1987
1988
# File 'lib/stripe/services/checkout/session_service.rb', line 1986

def client_reference_id
  @client_reference_id
end

Configure fields for the Checkout Session to gather active consent from customers.



1988
1989
1990
# File 'lib/stripe/services/checkout/session_service.rb', line 1988

def consent_collection
  @consent_collection
end

#currencyObject

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies). Required in ‘setup` mode when `payment_method_types` is not set.



1990
1991
1992
# File 'lib/stripe/services/checkout/session_service.rb', line 1990

def currency
  @currency
end

#custom_fieldsObject

Collect additional information from your customer using custom fields. Up to 3 fields are supported.



1992
1993
1994
# File 'lib/stripe/services/checkout/session_service.rb', line 1992

def custom_fields
  @custom_fields
end

#custom_textObject

Display additional text for your customers using custom text.



1994
1995
1996
# File 'lib/stripe/services/checkout/session_service.rb', line 1994

def custom_text
  @custom_text
end

#customerObject

ID of an existing Customer, if one exists. In ‘payment` mode, the customer’s most recently saved card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page. In `subscription` mode, the customer’s [default payment method](stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method) will be used if it’s a card, otherwise the most recently saved card will be used. A valid billing address, billing name and billing email are required on the payment method for Checkout to prefill the customer’s card details.

If the Customer already has a valid [email](stripe.com/docs/api/customers/object#customer_object-email) set, the email will be prefilled and not editable in Checkout. If the Customer does not have a valid ‘email`, Checkout will set the email entered during the session on the Customer.

If blank for Checkout Sessions in ‘subscription` mode or with `customer_creation` set as `always` in `payment` mode, Checkout will create a new Customer object based on information provided during the payment flow.

You can set [‘payment_intent_data.setup_future_usage`](stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage) to have Checkout automatically attach the payment method to the Customer you pass in for future reuse.



2006
2007
2008
# File 'lib/stripe/services/checkout/session_service.rb', line 2006

def customer
  @customer
end

#customer_creationObject

Configure whether a Checkout Session creates a [Customer](stripe.com/docs/api/customers) during Session confirmation.

When a Customer is not created, you can still retrieve email, address, and other customer data entered in Checkout with [customer_details](stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_details).

Sessions that don’t create Customers instead are grouped by [guest customers](stripe.com/docs/payments/checkout/guest-customers) in the Dashboard. Promotion codes limited to first time customers will return invalid for these Sessions.

Can only be set in ‘payment` and `setup` mode.



2016
2017
2018
# File 'lib/stripe/services/checkout/session_service.rb', line 2016

def customer_creation
  @customer_creation
end

#customer_emailObject

If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the ‘customer` field.



2022
2023
2024
# File 'lib/stripe/services/checkout/session_service.rb', line 2022

def customer_email
  @customer_email
end

#customer_updateObject

Controls what fields on Customer can be updated by the Checkout Session. Can only be provided when ‘customer` is provided.



2024
2025
2026
# File 'lib/stripe/services/checkout/session_service.rb', line 2024

def customer_update
  @customer_update
end

#discountsObject

The coupon or promotion code to apply to this Session. Currently, only up to one may be specified.



2026
2027
2028
# File 'lib/stripe/services/checkout/session_service.rb', line 2026

def discounts
  @discounts
end

#expandObject

Specifies which fields in the response should be expanded.



2028
2029
2030
# File 'lib/stripe/services/checkout/session_service.rb', line 2028

def expand
  @expand
end

#expires_atObject

The Epoch time in seconds at which the Checkout Session will expire. It can be anywhere from 30 minutes to 24 hours after Checkout Session creation. By default, this value is 24 hours from creation.



2030
2031
2032
# File 'lib/stripe/services/checkout/session_service.rb', line 2030

def expires_at
  @expires_at
end

#invoice_creationObject

Generate a post-purchase Invoice for one-time payments.



2032
2033
2034
# File 'lib/stripe/services/checkout/session_service.rb', line 2032

def invoice_creation
  @invoice_creation
end

#line_itemsObject

A list of items the customer is purchasing. Use this parameter to pass one-time or recurring [Prices](stripe.com/docs/api/prices).

For ‘payment` mode, there is a maximum of 100 line items, however it is recommended to consolidate line items if there are more than a few dozen.

For ‘subscription` mode, there is a maximum of 20 line items with recurring Prices and 20 line items with one-time Prices. Line items with one-time Prices will be on the initial invoice only.



2038
2039
2040
# File 'lib/stripe/services/checkout/session_service.rb', line 2038

def line_items
  @line_items
end

#localeObject

The IETF language tag of the locale Checkout is displayed in. If blank or ‘auto`, the browser’s locale is used.



2040
2041
2042
# File 'lib/stripe/services/checkout/session_service.rb', line 2040

def locale
  @locale
end

#metadataObject

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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to ‘metadata`.



2042
2043
2044
# File 'lib/stripe/services/checkout/session_service.rb', line 2042

def 
  @metadata
end

#modeObject

The mode of the Checkout Session. Pass ‘subscription` if the Checkout Session includes at least one recurring item.



2044
2045
2046
# File 'lib/stripe/services/checkout/session_service.rb', line 2044

def mode
  @mode
end

#optional_itemsObject

A list of optional items the customer can add to their order at checkout. Use this parameter to pass one-time or recurring [Prices](stripe.com/docs/api/prices).

There is a maximum of 10 optional items allowed on a Checkout Session, and the existing limits on the number of line items allowed on a Checkout Session apply to the combined number of line items and optional items.

For ‘payment` mode, there is a maximum of 100 combined line items and optional items, however it is recommended to consolidate items if there are more than a few dozen.

For ‘subscription` mode, there is a maximum of 20 line items and optional items with recurring Prices and 20 line items and optional items with one-time Prices.



2052
2053
2054
# File 'lib/stripe/services/checkout/session_service.rb', line 2052

def optional_items
  @optional_items
end

#payment_intent_dataObject

A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in ‘payment` mode.



2054
2055
2056
# File 'lib/stripe/services/checkout/session_service.rb', line 2054

def payment_intent_data
  @payment_intent_data
end

#payment_method_collectionObject

Specify whether Checkout should collect a payment method. When set to ‘if_required`, Checkout will not collect a payment method when the total due for the session is 0. This may occur if the Checkout Session includes a free trial or a discount.

Can only be set in ‘subscription` mode. Defaults to `always`.

If you’d like information on how to collect a payment method outside of Checkout, read the guide on configuring [subscriptions with a free trial](stripe.com/docs/payments/checkout/free-trials).



2061
2062
2063
# File 'lib/stripe/services/checkout/session_service.rb', line 2061

def payment_method_collection
  @payment_method_collection
end

#payment_method_configurationObject

The ID of the payment method configuration to use with this Checkout session.



2063
2064
2065
# File 'lib/stripe/services/checkout/session_service.rb', line 2063

def payment_method_configuration
  @payment_method_configuration
end

#payment_method_dataObject

This parameter allows you to set some attributes on the payment method created during a Checkout session.



2065
2066
2067
# File 'lib/stripe/services/checkout/session_service.rb', line 2065

def payment_method_data
  @payment_method_data
end

#payment_method_optionsObject

Payment-method-specific configuration.



2067
2068
2069
# File 'lib/stripe/services/checkout/session_service.rb', line 2067

def payment_method_options
  @payment_method_options
end

#payment_method_typesObject

A list of the types of payment methods (e.g., ‘card`) this Checkout Session can accept.

You can omit this attribute to manage your payment methods from the [Stripe Dashboard](dashboard.stripe.com/settings/payment_methods). See [Dynamic Payment Methods](stripe.com/docs/payments/payment-methods/integration-options#using-dynamic-payment-methods) for more details.

Read more about the supported payment methods and their requirements in our [payment method details guide](/docs/payments/checkout/payment-methods).

If multiple payment methods are passed, Checkout will dynamically reorder them to prioritize the most relevant payment methods based on the customer’s location and other characteristics.



2079
2080
2081
# File 'lib/stripe/services/checkout/session_service.rb', line 2079

def payment_method_types
  @payment_method_types
end

#permissionsObject

This property is used to set up permissions for various actions (e.g., update) on the CheckoutSession object.

For specific permissions, please refer to their dedicated subsections, such as ‘permissions.update.shipping_details`.



2083
2084
2085
# File 'lib/stripe/services/checkout/session_service.rb', line 2083

def permissions
  @permissions
end

#phone_number_collectionObject

Controls phone number collection settings for the session.

We recommend that you review your privacy policy and check with your legal contacts before using this feature. Learn more about [collecting phone numbers with Checkout](stripe.com/docs/payments/checkout/phone-numbers).



2088
2089
2090
# File 'lib/stripe/services/checkout/session_service.rb', line 2088

def phone_number_collection
  @phone_number_collection
end

#redirect_on_completionObject

This parameter applies to ‘ui_mode: embedded`. Learn more about the [redirect behavior](stripe.com/docs/payments/checkout/custom-success-page?payment-ui=embedded-form) of embedded sessions. Defaults to `always`.



2090
2091
2092
# File 'lib/stripe/services/checkout/session_service.rb', line 2090

def redirect_on_completion
  @redirect_on_completion
end

#return_urlObject

The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method’s app or site. This parameter is required if ‘ui_mode` is `embedded` or `custom` and redirect-based payment methods are enabled on the session.



2094
2095
2096
# File 'lib/stripe/services/checkout/session_service.rb', line 2094

def return_url
  @return_url
end

#saved_payment_method_optionsObject

Controls saved payment method settings for the session. Only available in ‘payment` and `subscription` mode.



2096
2097
2098
# File 'lib/stripe/services/checkout/session_service.rb', line 2096

def saved_payment_method_options
  @saved_payment_method_options
end

#setup_intent_dataObject

A subset of parameters to be passed to SetupIntent creation for Checkout Sessions in ‘setup` mode.



2098
2099
2100
# File 'lib/stripe/services/checkout/session_service.rb', line 2098

def setup_intent_data
  @setup_intent_data
end

#shipping_address_collectionObject

When set, provides configuration for Checkout to collect a shipping address from a customer.



2100
2101
2102
# File 'lib/stripe/services/checkout/session_service.rb', line 2100

def shipping_address_collection
  @shipping_address_collection
end

#shipping_optionsObject

The shipping rate options to apply to this Session. Up to a maximum of 5.



2102
2103
2104
# File 'lib/stripe/services/checkout/session_service.rb', line 2102

def shipping_options
  @shipping_options
end

#submit_typeObject

Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button.

`submit_type` can only be specified on Checkout Sessions in

‘payment` or `subscription` mode. If blank or `auto`, `pay` is used.



2107
2108
2109
# File 'lib/stripe/services/checkout/session_service.rb', line 2107

def submit_type
  @submit_type
end

#subscription_dataObject

A subset of parameters to be passed to subscription creation for Checkout Sessions in ‘subscription` mode.



2109
2110
2111
# File 'lib/stripe/services/checkout/session_service.rb', line 2109

def subscription_data
  @subscription_data
end

#success_urlObject

The URL to which Stripe should send customers when payment or setup is complete. This parameter is not allowed if ui_mode is ‘embedded` or `custom`. If you’d like to use information from the successful Checkout Session on your page, read the guide on [customizing your success page](stripe.com/docs/payments/checkout/custom-success-page).



2115
2116
2117
# File 'lib/stripe/services/checkout/session_service.rb', line 2115

def success_url
  @success_url
end

#tax_id_collectionObject

Controls tax ID collection during checkout.



2117
2118
2119
# File 'lib/stripe/services/checkout/session_service.rb', line 2117

def tax_id_collection
  @tax_id_collection
end

#ui_modeObject

The UI mode of the Session. Defaults to ‘hosted`.



2119
2120
2121
# File 'lib/stripe/services/checkout/session_service.rb', line 2119

def ui_mode
  @ui_mode
end