#dusk-_docs

1 messages ยท Page 1 of 1 (latest)

lavish forgeBOT
shut spruceBOT
#

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.

lavish forgeBOT
#

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

worn barn
#

Hi @foggy sable !

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

worn barn
#

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>
shut spruceBOT
midnight peak
#

๐Ÿ‘‹ stepping in here

#

Catching up

worn barn
#

Hi

midnight peak
#

The client secret is necessary to actually render the proper Embedded Component(s). Is that what you are asking?

worn barn
#

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 }}",
      });
midnight peak
#

Ah

#

All you really need to do is pass the clientSecret to the fetchClientSecret parameter within loadConnectAndInitialize

worn barn
midnight peak
#

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.

worn barn
#

This .html is in my backend ๐Ÿ˜…

midnight peak
#

Yeah that's fine

worn barn
midnight peak
#

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

worn barn
#

Thanks so much for the help, I should get back to you ssoon