#Ludvig-react

1 messages · Page 1 of 1 (latest)

fair yarrow
#

I'm really not proficient at React unfortunately but as far as I know that's fine.

distant fulcrum
#

Okay. Yeah I was just wondering what the It should not be stored is defined as, since useState is a form of storing?

#

Thanks for your answer

fair yarrow
#

more like storing it in a database or persistently.

The security angle is that with the client_secret, and a publishable key(which is public so you can assume anyone can get), you can attempt a payment on an actual payment method/card for that corresponding PaymentIntent; so you should be a little selective in "distributing" the client_secret

#

moving it around in the context of state in a React app seems fine though, that's all just in memory in the browser, as I understand it

distant fulcrum
#

Thanks a lot for clarifying!

#

Before you close this issue, I might have one more question I'll just need to formulate

fair yarrow
#

sure thing

distant fulcrum
#

This doc https://stripe.com/docs/payments/payment-element/migration?integration-path=one-time&html-or-react=react#one-time-update-elements
is telling me to do this:

const stripePromise = loadStripe('pk_test_51HfivvBdFvXgNzqzRgyALfIw7diXwmUfx827a0JjUi07A9fqJXIvGJRrGPfjKeF7ja6EWmoqV3mgn5OTlgkDYguY005sEwaxNi');

const options = {
  clientSecret: '{{CLIENT_SECRET}}',
};

function App() {
  return (
    <Elements stripe={stripePromise} options={options}>
      <CheckoutForm />
    </Elements>
  );
};

How am I supposed to provide a client secret to <Elements> before it's even generated? I tried to do this but it seems to fail to render since it's just an empty string at first

error: Uncaught (in promise) IntegrationError: Invalid value for elements(): clientSecret should be a client secret of the form ${id}_secret_${secret}. You specified: .

#

Does it make sense?

fair yarrow
#

yeah, totally valid question and you're not the only person asking about that.

You need the client_secret to initialise the PaymentElement, which means you need it pretty early in loading the page.

distant fulcrum
#

Thanks a lot! I'll have a look.

full flame
#

@distant fulcrum are you all set here?