Struct stripe::CheckoutSession
source · [−]pub struct CheckoutSession {Show 41 fields
pub id: CheckoutSessionId,
pub after_expiration: Option<PaymentPagesCheckoutSessionAfterExpiration>,
pub allow_promotion_codes: Option<bool>,
pub amount_subtotal: Option<i64>,
pub amount_total: Option<i64>,
pub automatic_tax: PaymentPagesCheckoutSessionAutomaticTax,
pub billing_address_collection: Option<CheckoutSessionBillingAddressCollection>,
pub cancel_url: String,
pub client_reference_id: Option<String>,
pub consent: Option<PaymentPagesCheckoutSessionConsent>,
pub consent_collection: Option<PaymentPagesCheckoutSessionConsentCollection>,
pub currency: Option<Currency>,
pub customer: Option<Expandable<Customer>>,
pub customer_creation: Option<CheckoutSessionCustomerCreation>,
pub customer_details: Option<PaymentPagesCheckoutSessionCustomerDetails>,
pub customer_email: Option<String>,
pub expires_at: Timestamp,
pub line_items: List<CheckoutSessionItem>,
pub livemode: bool,
pub locale: Option<CheckoutSessionLocale>,
pub metadata: Metadata,
pub mode: CheckoutSessionMode,
pub payment_intent: Option<Expandable<PaymentIntent>>,
pub payment_link: Option<Expandable<PaymentLink>>,
pub payment_method_options: Option<CheckoutSessionPaymentMethodOptions>,
pub payment_method_types: Vec<String>,
pub payment_status: CheckoutSessionPaymentStatus,
pub phone_number_collection: Option<PaymentPagesCheckoutSessionPhoneNumberCollection>,
pub recovered_from: Option<String>,
pub setup_intent: Option<Expandable<SetupIntent>>,
pub shipping: Option<Shipping>,
pub shipping_address_collection: Option<PaymentPagesCheckoutSessionShippingAddressCollection>,
pub shipping_options: Vec<PaymentPagesCheckoutSessionShippingOption>,
pub shipping_rate: Option<Expandable<ShippingRate>>,
pub status: Option<CheckoutSessionStatus>,
pub submit_type: Option<CheckoutSessionSubmitType>,
pub subscription: Option<Expandable<Subscription>>,
pub success_url: String,
pub tax_id_collection: Option<PaymentPagesCheckoutSessionTaxIdCollection>,
pub total_details: Option<PaymentPagesCheckoutSessionTotalDetails>,
pub url: Option<String>,
}
Expand description
The resource representing a Stripe “Session”.
Fields
id: CheckoutSessionId
Unique identifier for the object.
Used to pass to redirectToCheckout
in Stripe.js.
after_expiration: Option<PaymentPagesCheckoutSessionAfterExpiration>
When set, provides configuration for actions to take if this Checkout Session expires.
allow_promotion_codes: Option<bool>
Enables user redeemable promotion codes.
amount_subtotal: Option<i64>
Total of all items before discounts or taxes are applied.
amount_total: Option<i64>
Total of all items after discounts and taxes are applied.
automatic_tax: PaymentPagesCheckoutSessionAutomaticTax
billing_address_collection: Option<CheckoutSessionBillingAddressCollection>
Describes whether Checkout should collect the customer’s billing address.
cancel_url: String
The URL the customer will be directed to if they decide to cancel payment and return to your website.
client_reference_id: Option<String>
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: Option<PaymentPagesCheckoutSessionConsent>
Results of consent_collection
for this session.
consent_collection: Option<PaymentPagesCheckoutSessionConsentCollection>
When set, provides configuration 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.
customer: Option<Expandable<Customer>>
The ID of the customer for this Session.
For Checkout Sessions in payment
or subscription
mode, Checkout
will create a new customer object based on information provided
during the payment flow unless an existing customer was provided when
the Session was created.
customer_creation: Option<CheckoutSessionCustomerCreation>
Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
customer_details: Option<PaymentPagesCheckoutSessionCustomerDetails>
The customer details including the customer’s tax exempt status and the customer’s tax IDs.
Only present on Sessions in payment
or subscription
mode.
customer_email: Option<String>
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 the payment flow is complete, use the customer
attribute.
expires_at: Timestamp
The timestamp at which the Checkout Session will expire.
line_items: List<CheckoutSessionItem>
The line items purchased by the customer.
livemode: bool
Has the value true
if the object exists in live mode or the value false
if the object exists in test mode.
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: 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.
mode: CheckoutSessionMode
The mode of the Checkout Session.
payment_intent: Option<Expandable<PaymentIntent>>
The ID of the PaymentIntent for Checkout Sessions in payment
mode.
payment_link: Option<Expandable<PaymentLink>>
The ID of the Payment Link that created this Session.
payment_method_options: Option<CheckoutSessionPaymentMethodOptions>
Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.
payment_method_types: Vec<String>
A list of the types of payment methods (e.g.
card) this Checkout Session is allowed to accept.
payment_status: CheckoutSessionPaymentStatus
The payment status of the Checkout Session, one of paid
, unpaid
, or no_payment_required
.
You can use this value to decide when to fulfill your customer’s order.
phone_number_collection: Option<PaymentPagesCheckoutSessionPhoneNumberCollection>
recovered_from: Option<String>
The ID of the original expired Checkout Session that triggered the recovery flow.
setup_intent: Option<Expandable<SetupIntent>>
The ID of the SetupIntent for Checkout Sessions in setup
mode.
shipping: Option<Shipping>
Shipping information for this Checkout Session.
shipping_address_collection: Option<PaymentPagesCheckoutSessionShippingAddressCollection>
When set, provides configuration for Checkout to collect a shipping address from a customer.
shipping_options: Vec<PaymentPagesCheckoutSessionShippingOption>
The shipping rate options applied to this Session.
shipping_rate: Option<Expandable<ShippingRate>>
The ID of the ShippingRate for Checkout Sessions in payment
mode.
status: Option<CheckoutSessionStatus>
The status of the Checkout Session, one of open
, complete
, or expired
.
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, but not Checkout Sessions in subscription
or setup
mode.
subscription: Option<Expandable<Subscription>>
The ID of the subscription for Checkout Sessions in subscription
mode.
success_url: String
The URL the customer will be directed to after the payment or subscription creation is successful.
tax_id_collection: Option<PaymentPagesCheckoutSessionTaxIdCollection>
total_details: Option<PaymentPagesCheckoutSessionTotalDetails>
Tax and discount details for the computed total amount.
url: Option<String>
The URL to the Checkout Session.
Redirect customers to this URL to take them to Checkout.
If you’re using Custom Domains, the URL will use your subdomain.
Otherwise, it’ll use checkout.stripe.com.
.
Implementations
sourceimpl CheckoutSession
impl CheckoutSession
sourcepub fn list(
client: &Client,
params: &ListCheckoutSessions<'_>
) -> Response<List<CheckoutSession>>
pub fn list(
client: &Client,
params: &ListCheckoutSessions<'_>
) -> Response<List<CheckoutSession>>
Returns a list of Checkout Sessions.
sourcepub fn create(
client: &Client,
params: CreateCheckoutSession<'_>
) -> Response<CheckoutSession>
pub fn create(
client: &Client,
params: CreateCheckoutSession<'_>
) -> Response<CheckoutSession>
Creates a Session object.
Examples found in repository?
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
async fn main() {
let secret_key = std::env::var("STRIPE_SECRET_KEY").expect("Missing STRIPE_SECRET_KEY in env");
let client = Client::new(secret_key);
let customer = Customer::create(
&client,
CreateCustomer {
name: Some("Alexander Lyon"),
email: Some("test@async-stripe.com"),
description: Some(
"A fake customer that is used to illustrate the examples in async-stripe.",
),
metadata: Some(
[("async-stripe".to_string(), "true".to_string())].iter().cloned().collect(),
),
..Default::default()
},
)
.await
.unwrap();
println!("created a customer at https://dashboard.stripe.com/test/customers/{}", customer.id);
// create a new exmaple project
let product = {
let mut create_product = CreateProduct::new("T-Shirt");
create_product.metadata =
Some([("async-stripe".to_string(), "true".to_string())].iter().cloned().collect());
Product::create(&client, create_product).await.unwrap()
};
// and add a price for it in USD
let price = {
let mut create_price = CreatePrice::new(Currency::USD);
create_price.product = Some(IdOrCreate::Id(&product.id));
create_price.metadata =
Some([("async-stripe".to_string(), "true".to_string())].iter().cloned().collect());
create_price.unit_amount = Some(1000);
create_price.expand = &["product"];
Price::create(&client, create_price).await.unwrap()
};
println!(
"created a product {:?} at price {} {}",
product.name.unwrap(),
price.unit_amount.unwrap() / 100,
price.currency.unwrap()
);
// finally, create a checkout session for this product / price
let checkout_session = {
let mut params =
CreateCheckoutSession::new("http://test.com/cancel", "http://test.com/success");
params.customer = Some(customer.id);
params.mode = Some(CheckoutSessionMode::Payment);
params.line_items = Some(vec![CreateCheckoutSessionLineItems {
quantity: Some(3),
price: Some(price.id.to_string()),
..Default::default()
}]);
params.expand = &["line_items", "line_items.data.price.product"];
CheckoutSession::create(&client, params).await.unwrap()
};
println!(
"created a {} checkout session for {} {:?} for {} {} at {}",
checkout_session.payment_status,
checkout_session.line_items.data[0].quantity.unwrap(),
match checkout_session.line_items.data[0].price.as_ref().unwrap().product.as_ref().unwrap()
{
Expandable::Object(p) => p.name.as_ref().unwrap(),
_ => panic!("product not found"),
},
checkout_session.amount_subtotal.unwrap() / 100,
checkout_session.line_items.data[0].price.as_ref().unwrap().currency.unwrap(),
checkout_session.url.unwrap()
);
}
Trait Implementations
sourceimpl Clone for CheckoutSession
impl Clone for CheckoutSession
sourcefn clone(&self) -> CheckoutSession
fn clone(&self) -> CheckoutSession
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for CheckoutSession
impl Debug for CheckoutSession
sourceimpl Default for CheckoutSession
impl Default for CheckoutSession
sourcefn default() -> CheckoutSession
fn default() -> CheckoutSession
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for CheckoutSession
impl<'de> Deserialize<'de> for CheckoutSession
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Object for CheckoutSession
impl Object for CheckoutSession
sourceimpl Serialize for CheckoutSession
impl Serialize for CheckoutSession
Auto Trait Implementations
impl RefUnwindSafe for CheckoutSession
impl Send for CheckoutSession
impl Sync for CheckoutSession
impl Unpin for CheckoutSession
impl UnwindSafe for CheckoutSession
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more