Struct stripe::CreateCheckoutSession

source ·
pub struct CreateCheckoutSession<'a> {
Show 38 fields pub after_expiration: Option<CreateCheckoutSessionAfterExpiration>, pub allow_promotion_codes: Option<bool>, pub automatic_tax: Option<CreateCheckoutSessionAutomaticTax>, pub billing_address_collection: Option<CheckoutSessionBillingAddressCollection>, pub cancel_url: Option<&'a str>, pub client_reference_id: Option<&'a str>, pub consent_collection: Option<CreateCheckoutSessionConsentCollection>, pub currency: Option<Currency>, pub custom_fields: Option<Vec<CreateCheckoutSessionCustomFields>>, pub custom_text: Option<CreateCheckoutSessionCustomText>, pub customer: Option<CustomerId>, pub customer_creation: Option<CheckoutSessionCustomerCreation>, pub customer_email: Option<&'a str>, pub customer_update: Option<CreateCheckoutSessionCustomerUpdate>, pub discounts: Option<Vec<CreateCheckoutSessionDiscounts>>, pub expand: &'a [&'a str], pub expires_at: Option<Timestamp>, pub invoice_creation: Option<CreateCheckoutSessionInvoiceCreation>, pub line_items: Option<Vec<CreateCheckoutSessionLineItems>>, pub locale: Option<CheckoutSessionLocale>, pub metadata: Option<Metadata>, pub mode: Option<CheckoutSessionMode>, pub payment_intent_data: Option<CreateCheckoutSessionPaymentIntentData>, pub payment_method_collection: Option<CheckoutSessionPaymentMethodCollection>, pub payment_method_configuration: Option<PaymentMethodConfigurationId>, pub payment_method_options: Option<CreateCheckoutSessionPaymentMethodOptions>, pub payment_method_types: Option<Vec<CreateCheckoutSessionPaymentMethodTypes>>, pub phone_number_collection: Option<CreateCheckoutSessionPhoneNumberCollection>, pub redirect_on_completion: Option<CheckoutSessionRedirectOnCompletion>, pub return_url: Option<&'a str>, pub setup_intent_data: Option<CreateCheckoutSessionSetupIntentData>, pub shipping_address_collection: Option<CreateCheckoutSessionShippingAddressCollection>, pub shipping_options: Option<Vec<CreateCheckoutSessionShippingOptions>>, pub submit_type: Option<CheckoutSessionSubmitType>, pub subscription_data: Option<CreateCheckoutSessionSubscriptionData>, pub success_url: Option<&'a str>, pub tax_id_collection: Option<CreateCheckoutSessionTaxIdCollection>, pub ui_mode: Option<CheckoutSessionUiMode>,
}
Expand description

The parameters for CheckoutSession::create.

Fields§

§after_expiration: Option<CreateCheckoutSessionAfterExpiration>

Configure actions after a Checkout Session has expired.

§allow_promotion_codes: Option<bool>

Enables user redeemable promotion codes.

§automatic_tax: Option<CreateCheckoutSessionAutomaticTax>

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

§billing_address_collection: Option<CheckoutSessionBillingAddressCollection>

Specify whether Checkout should collect the customer’s billing address.

§cancel_url: Option<&'a str>

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.

§client_reference_id: Option<&'a str>

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.

§consent_collection: Option<CreateCheckoutSessionConsentCollection>

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

§currency: Option<Currency>

Three-letter ISO currency code, in lowercase.

Must be a supported currency. Required in setup mode when payment_method_types is not set.

§custom_fields: Option<Vec<CreateCheckoutSessionCustomFields>>

Collect additional information from your customer using custom fields.

Up to 3 fields are supported.

§custom_text: Option<CreateCheckoutSessionCustomText>

Display additional text for your customers using custom text.

§customer: Option<CustomerId>

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 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 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 to have Checkout automatically attach the payment method to the Customer you pass in for future reuse.

§customer_creation: Option<CheckoutSessionCustomerCreation>

Configure whether a Checkout Session creates a Customer 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.

Sessions that don’t create Customers instead are grouped by 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.

§customer_email: Option<&'a str>

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.

§customer_update: Option<CreateCheckoutSessionCustomerUpdate>

Controls what fields on Customer can be updated by the Checkout Session.

Can only be provided when customer is provided.

§discounts: Option<Vec<CreateCheckoutSessionDiscounts>>

The coupon or promotion code to apply to this Session.

Currently, only up to one may be specified.

§expand: &'a [&'a str]

Specifies which fields in the response should be expanded.

§expires_at: Option<Timestamp>

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.

§invoice_creation: Option<CreateCheckoutSessionInvoiceCreation>

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

§line_items: Option<Vec<CreateCheckoutSessionLineItems>>

A list of items the customer is purchasing.

Use this parameter to pass one-time or recurring 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.

§locale: Option<CheckoutSessionLocale>

The IETF language tag of the locale Checkout is displayed in.

If blank or auto, the browser’s locale is used.

§metadata: Option<Metadata>

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

§mode: Option<CheckoutSessionMode>

The mode of the Checkout Session.

Pass subscription if the Checkout Session includes at least one recurring item.

§payment_intent_data: Option<CreateCheckoutSessionPaymentIntentData>

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

§payment_method_collection: Option<CheckoutSessionPaymentMethodCollection>

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

§payment_method_configuration: Option<PaymentMethodConfigurationId>

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

§payment_method_options: Option<CreateCheckoutSessionPaymentMethodOptions>

Payment-method-specific configuration.

§payment_method_types: Option<Vec<CreateCheckoutSessionPaymentMethodTypes>>

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. See Dynamic Payment Methods for more details.

Read more about the supported payment methods and their requirements in our payment method details guide.

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.

§phone_number_collection: Option<CreateCheckoutSessionPhoneNumberCollection>

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.

§redirect_on_completion: Option<CheckoutSessionRedirectOnCompletion>

This parameter applies to ui_mode: embedded.

By default, Stripe will always redirect to your return_url after a successful confirmation. If you set redirect_on_completion: 'if_required', then we will only redirect if your user chooses a redirect-based payment method.

§return_url: Option<&'a str>

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 and redirect-based payment methods are enabled on the session.

§setup_intent_data: Option<CreateCheckoutSessionSetupIntentData>

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

§shipping_address_collection: Option<CreateCheckoutSessionShippingAddressCollection>

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

§shipping_options: Option<Vec<CreateCheckoutSessionShippingOptions>>

The shipping rate options to apply to this Session.

Up to a maximum of 5.

§submit_type: Option<CheckoutSessionSubmitType>

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 mode. If blank or auto, pay is used.

§subscription_data: Option<CreateCheckoutSessionSubscriptionData>

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

§success_url: Option<&'a str>

The URL to which Stripe should send customers when payment or setup is complete. This parameter is not allowed if ui_mode is embedded.

If you’d like to use information from the successful Checkout Session on your page, read the guide on customizing your success page.

§tax_id_collection: Option<CreateCheckoutSessionTaxIdCollection>

Controls tax ID collection settings for the session.

§ui_mode: Option<CheckoutSessionUiMode>

ui_mode can be hosted or embedded.

The default is hosted.

Implementations§

source§

impl<'a> CreateCheckoutSession<'a>

source

pub fn new() -> Self

Trait Implementations§

source§

impl<'a> Clone for CreateCheckoutSession<'a>

source§

fn clone(&self) -> CreateCheckoutSession<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for CreateCheckoutSession<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Default for CreateCheckoutSession<'a>

source§

fn default() -> CreateCheckoutSession<'a>

Returns the “default value” for a type. Read more
source§

impl<'a> Serialize for CreateCheckoutSession<'a>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more