#dowabes219
1 messages · Page 1 of 1 (latest)
It sounds like you didn't actually a client secret
I see you are fetching the Payment Intent, but you're using clientSecret, which is a variable that has no client secret in it. You would likely need to do something like const elements = stripe.elements({r.data.clientSecret})
this code from the tutorial
https://youtu.be/tCSbCk5j3Tk?t=698
In this episode, you'll learn how to accept a one-time payment with a custom form using Python on the server and the Stripe Payment Element on the client. The Payment Element enables you to collect several different payment method types from cards and bank accounts to wallets and buy-now-pay-later payment methods.
Presenter
CJ Avilla - De...
why it works there?
Or use const { clientSecret } = await response.json();
but why it works in the video?
That video might be outdated
I'd recommend using this instead: https://stripe.com/docs/payments/quickstart?client=html
replace
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}).then(r => r.json())```
to it?
Yup
where is url to /create-payment-intent?
could you provide me full code?
That's an endpoint on your server
I am newbie in JS
The example I provided above has the full code
You should be able to literally copy and paste almost the entire thing to get it running
const {publishableKey} = await fetch('/config').then(r => r.json())
const stripe = Stripe(publishableKey)
// const {clientSecret} = await fetch('/create-payment-intent', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// }
// }).then(r => r.json())
const { clientSecret } = await response.json();
const elements = stripe.elements({clientSecret})
const paymentElement = elements.create('payment')
paymentElement.mount('#payment-element')
})```
what is response?
I don't understand the question. What do you mean?
could you provide me full workable JS code example?
THere's on in the page I linked you to
What does your code look like after copy/pasting the examples?
I download the entire code and it works now
how to test payment with a fake credit card?