#dusk-_docs
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.
- dusk-_api, 51 minutes ago, 64 messages
- dusk-_docs, 10 hours ago, 9 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1237835729086971994
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi @foggy sable !
Heyo! ๐
Client secrets aren't intended to be stored/cached, so using that method is the recommended workflow
What's the use-case here?
I might be misunderstanding your question though, so do feel free to be a bit more verbose
One sec
I want to use the embeddable component in my Flutter app but since there's no direct support, my approach is to make a request to the backend which returns me the html. Now, my backend will do something like this in the backend route:
async def render_stripe_onboarding(public_key: str, client_secret) -> str:
return await _render_template(
"stripe_onboarding.html", {"stripe_public_key": public_key, "stripe_client_secret": client_secret}
)
and the html looks like this
<head>
<script src="https://connect-js.stripe.com/v1.0/connect.js" async></script>
<script>
window.StripeConnect = window.StripeConnect || {};
const fetchClientSecret = () => {
return "{{ stripe_public_key }}";
}
StripeConnect.onLoad = () => {
const stripeConnectInstance = StripeConnect.init({
// This is the publishable API key.
publishableKey: "{{ stripe_public_key }}",
fetchClientSecret: fetchClientSecret,
});
const payments = stripeConnectInstance.create('payments');
document.body.appendChild(payments);
};
</script>
</head>
<body>
<h1>Payments</h1>
<div id="container"></div>
<div id="error" hidden>Something went wrong!</div>
</body>
Hi
The client secret is necessary to actually render the proper Embedded Component(s). Is that what you are asking?
fetchClientSecret
is this function required?
Or can I hardcode the secret someway
Like instead of this
const stripeConnectInstance = StripeConnect.init({
// This is the publishable API key.
publishableKey: "{{ stripe_public_key }}",
fetchClientSecret: fetchClientSecret,
});
can I do something like where I just directly pass the client secret into my .html and pass in the appropriate variables through my backend renderer
const stripeConnectInstance = StripeConnect.init({
// This is the publishable API key.
publishableKey: "{{ stripe_public_key }}",
clientSecret: "{{ stripe_public_key }}",
});
Ah
All you really need to do is pass the clientSecret to the fetchClientSecret parameter within loadConnectAndInitialize
Because in the example here https://docs.stripe.com/connect/get-started-connect-embedded-components#load-and-initialize-connect.js
The example calls the backend route
You don't actually have to do that via a function that runs from your client
Right
So if you have access to it in your frontend then it will work.
This .html is in my backend ๐
Yeah that's fine
Okay, I'll try this and get back to you!
As long as you have access to the client secret when you call loadConnectAndInitialize() then it should work
Yep try it out and let me know if it errors
Thanks so much for the help, I should get back to you ssoon