#aman-paymentintent-clientsecret

1 messages · Page 1 of 1 (latest)

leaden pilotBOT
queen plaza
#

Hi 👋

You need to use the PUBLISHABLE KEY when initializing Stripe.js

fringe copper
#

stripe = Stripe(publishKey)
elements = stripe.elements(secretKey)
I don't get any errors till here

#

elements.create('payment');

#

but when I create the payment element it shows the error

queen plaza
#

You are not creating the stripe.elements properly. you DO NOT use the secret key there

fringe copper
#

let me try this thanks

queen plaza
#

Sure thing. If you run into a problem just let me know specifically what part of the doc you are at

fringe copper
#

Uncaught IntegrationError: Invalid value for elements(): clientSecret should be a client secret of the form ${id}secret${secret}. You specified: {{clientSecretVal}}.
I am getting this error when I pass the secret as
const options = {
clientSecret: '{{clientSecretVal}}',
// Fully customizable with appearance API.
appearance: {/.../},
};

queen plaza
#

Okay you are just passing a string in for clientSecret. You need to replace that with the client_secret for the Payment Intent you create in your server-side code.

fringe copper
#

isn't that the key which looks like "sk_test_51MM"

queen plaza
#

No

#

You should never include that on your front-end code, ever

#

Which is what is described in the doc I linked you to

fringe copper
#

Ok, in the link it says client secret from payment intent, but to get the payment intent don't I need the payment method saved in stripe?

queen plaza
#

No

#

You create the Payment Intent on the server side first in this example

fringe copper
#

thanks

queen plaza
#

The Payment Intent client secret will look kind of like this: pi_3KnqXoIlCeH6bP8R1B9NT5ww_secret_YqgOOvZ4TkaJoRShvWxwFbrJN

#

But with different numbers/letters

leaden pilotBOT