-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to CheckoutSession? #178
Comments
Hi! Yes, it is a string but See here: https://docs.rs/stripe-rust/0.12.3/src/stripe/ids.rs.html#121 Luckily CheckoutSessionItem {
id: CheckoutSessionItemId::from_str("val"),
...
} This is so we can provide errors when you provide an invalid ID for certain types, as some have required prefixes. |
My problem with let client = stripe::Client::new(dotenv!("STRIPE_SECRET"));
let price = Price::retrieve(&client, &PriceId::from_str(dotenv!("STRIPE_PRICE_ID"))?, &[]).await.unwrap();
let mut line_items = List::default();
line_items.data.push(CheckoutSessionItem {
amount_total: None,
amount_subtotal: None,
currency: Currency::EUR,
description: "Subscription".to_string(),
id: CheckoutSessionItemId::from_str("yearly")?,
price,
quantity: Some(1),
taxes: None,
});
let session = CheckoutSession {
billing_address_collection: None,
cancel_url: "/api/v1/payment/cancel".to_string(),
client_reference_id: Some(user.id),
customer: None,
customer_email: Some(user_obj.email),
display_items: None,
id: None,
line_items,
livemode: false,
locale: None,
metadata: Metadata::new(),
mode: Some(CheckoutSessionMode::Subscription),
payment_intent: None,
payment_method_types: vec!["card".to_string()],
setup_intent: None,
shipping: None,
shipping_address_collection: None,
submit_type: None,
subscription: None,
success_url: "/api/v1/payment/success".to_string(),
}; |
It looks like the As an example, see how the PaymentIntent works: https://docs.rs/stripe-rust/0.12.3/stripe/struct.PaymentIntent.html#method.create or the CheckoutSession in the async-stripe fork: https://docs.rs/async-stripe/latest/stripe/struct.CheckoutSession.html |
I've been reading through the source trying to figure it out. Got stuck on the
stripe::CheckoutSessionItem::id
:I found this:
stripe-rs/src/ids.rs
Line 487 in 624c972
👆 in the source typed as a
String
but trying to set a String as theid
above gives:Any insight would be greatly appreciated.
Thank you 🙇🏻♂️
The text was updated successfully, but these errors were encountered: