#su.su_
1 messages · Page 1 of 1 (latest)
👋 again and how can I help you further?
IntegrationError: Missing value for Stripe(): apiKey should be a string.
I keep gettings this error, I want to know if I set it up correct...
const stripePromise = loadStripe(process.env.STRIPE_PUBLIC_TEST);
function CheckoutPage() {
const ClientSecret = `${process.env.STRIPE_PUBLIC_TEST}`;
const options = {
clientSecret: `${ClientSecret}`
}
return (
<div>
<Elements stripe={stripePromise} options={options}>
<PaymentForm />
</Elements>
</div>
);
}
export default CheckoutPage;
I saw on your documentation, but since I'm using next.js, I thought it might be different
You would want to log out what value in STRIPE_PUBLIC_TEST is that?
also ClientSecret should comes from backend, not process.env
that's the public key I put in the .env folder.
is clientSecret the secret key or another unique key?
No, it is the client secret of the PaymentIntent, which is generated on backend, each time a payment is made
Have you seen the Doc I shared earlier? It has a step to create PaymentIntent
yeah But i'm using react/next and I think it works differently
oh, can you do something like payment.client_secret?
It should be the same because flow. Not familiar with NextJS but this might help: https://vercel.com/guides/getting-started-with-nextjs-typescript-stripe
Well this is checkout so it's different, but generally you create PaymentIntent on the backend, similar to what they are doing in
const params: Stripe.Checkout.SessionCreateParams = {
So, let me try to get the front end working first. I set it like <PaymentElement/> right, and I just import it?
Yes
IntegrationError: Missing value for Stripe(): apiKey should be a string.``` does this refer to the secret and pblic key?
const stripePromise = loadStripe(process.env.STRIPE_PUBLIC_TEST); In my env file, I set it to a string. Is this correct?
yes, and that should be the Publishable Key, format pk_test_xxx
it still saying Missing value for Stripe(): apiKey should be a string.
probably you don't have that value? Did you put STRIPE_PUBLIC_TEST into your environment file?
Well it says "should be a string". I wonder what value it currently has
I defined it like this in my files, and in my env file i did :
STRIPE_PUBLIC_TEST= pk_test_51NC....
sure, so if you console.log(process.env.STRIPE_PUBLIC_TEST) do you see its value?
it comes back as undefined : Stripe Public Key: undefined
oh wait, i think I fixed it
I other debugging errors now
I GOT IT TO WORK!
Glad to hear!