#dxdx_embedded-checkout-blank
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- dxdx_api, 2 hours ago, 6 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1261017332256473110
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi ๐
IDK what that first section of code is supposed to be doing but lets start with the basics.
You are trying to get an embedded Checkout page working, correct?
yes, correct.
the first part of the code is calling an api internally which creates the stripe checkout session and returns the client secret. Initially it returned url to redirect the user to, but I dont want that behaviour.
Okay can you share the creation request for that Checkout session?
pub async fn create_setup_session(
db: web::Data<DatabaseConnection>,
stripe: web::Datastripe::Client,
session: Session,
config: web::Data<Config>,
return_id: web::Path<Uuid>,
) -> impl Responder {
let user_id = match get_user_from_session(&session) {
Ok(id) => id,
Err(r) => return r,
};
let user = match UserStripeID::find_by_id(user_id).execute(&db).await {
Ok(Some(user)) => user,
Ok(None) => return HttpResponse::NotFound().finish(),
Err(e) => return server_error!(e, "failed to load user stripe account"),
};
let customer_id = match CustomerId::from_str(&user.stripe_id) {
Ok(id) => id,
Err(e) => return server_error!(e, "invalid stripe id"),
};
let return_url = format!(
"{}/return/{}",
config.ui.base_url, return_id
);
let params = CreateCheckoutSession {
mode: Some(CheckoutSessionMode::Setup),
ui_mode: Some(stripe::CheckoutSessionUiMode::Embedded),
currency: Some(Currency::GBP),
customer: Some(customer_id),
return_url: Some(&return_url),
..Default::default()
};
let checkout_session = match CheckoutSession::create(&stripe, params).await {
Ok(checkout_session) => {
println!(
"Checkout Session client_secret: {:?}",
checkout_session.client_secret
);
checkout_session
}
Err(e) => return server_error!(e, "failed to create checkout session"),
};
match checkout_session.client_secret {
Some(client_secret) => HttpResponse::Ok().body(client_secret),
None => server_error!("checkout session client secret is missing"),
}
}
Can you share an API request ID for this? It will start with req_
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
one moment, i don't have access to the dashboard. Since i'm doing a UI-only integration i'd have to ask.
Okay looking
That looks correct to me
So my first step woud be log the clientSecret value once it reaches your react page and make sure it's what you expect before you pass it to the EmbeddedCheckoutProvider
i have confirmed the clientSecret is logged and set correctly but the form is still not embedded .
Is there something noticeably wrong with the API logic that creates the session?
logic here
Hi there ๐ jumping in as my teammate needs to step away soon. If you're able to create the Checkout Session successfully, which seems to be the case if you're getting the ID and client secret, then I think we need to look for a frontend problem.
Do you have a publicly accessible test site where I can see the behavior you're describing?
Oh okay, thanks for stepping in. I dont have a publicly accessible site yet* but i can share the code if that is any good?
It might be.
If you can't share a site, can you check your browser console logs to see if any errors are being thrown there when the checkout session isn't displayed?
dxdx_embedded-checkout-blank
Please pass a publishable key instead.
r v3:1
```
this is the error in the console.
Gotcha, sounds like you're including your secret key in your client side code, which should be avoided as that exposes your secret key to users of your site. You should be using your publishable API key client-side.
From your Stripe dashboard:
https://dashboard.stripe.com/test/apikeys
(that link is for your testmode keys, you'd need to flip the test mode toggle to see your livemode keys instead)
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.