#dxdx_embedded-checkout-blank

1 messages ยท Page 1 of 1 (latest)

pure copperBOT
cedar dragonBOT
#

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.

pure copperBOT
#

๐Ÿ‘‹ 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.

terse hamlet
#

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?

ivory juniper
#

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.

terse hamlet
#

Okay can you share the creation request for that Checkout session?

ivory juniper
#

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"),
}

}

terse hamlet
ivory juniper
#

one moment, i don't have access to the dashboard. Since i'm doing a UI-only integration i'd have to ask.

terse hamlet
#

Okay in that case nevermind

#

Can you share the Checkout session ID?

ivory juniper
#

yes

#

cs_test_c1i4nDHM2RNDZjw0NVQZU3r6DbchIlzwWEz9NvTq4fjkPJMPeI5IiRQPcE

terse hamlet
#

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

ivory juniper
#

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?

sonic canyon
#

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?

ivory juniper
#

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?

sonic canyon
#

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?

pure copperBOT
#

dxdx_embedded-checkout-blank

ivory juniper
#
          Please pass a publishable key instead.
    r v3:1
```
#

this is the error in the console.

sonic canyon
#

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.

ivory juniper
#

Whew, thanks!!

#

one moment. Where do i grab this value?

sonic canyon