#Berci

1 messages · Page 1 of 1 (latest)

leaden wedgeBOT
stoic wedge
#

Hi there. What issue are you having specifically?

dull aspen
#

Hi!

#

So I want to modify the amount in the paymentintent.create script with a variable from another script

#

How can I do that?

#

Like when someone chooses a product and presses buy button, it creates a paymentintent with the product's price

stoic wedge
#

Where is the amount variable coming from? What script?

dull aspen
#

From another script, I want to set the choosen option's id for the amount

#

So when it's choosed and a specific buy button is pressed, create a paymentintent with this id's value

stoic wedge
#

You'd just need to pass it in the body of the POST request

#

And grab that in your backend code

dull aspen
#

I don't have a lot coding experience, can you show me a code for that?

stoic wedge
#

But that's not a very secure way of doing things since the request can be tampered with

stoic wedge
#

Unfortunately we can't code an integration for you or teach concepts. We are just here to help developers with their Stripe-related API questions. I recommend you learn the basics first

#

But you need to learn the coding basics first

dull aspen
#

I'm trying to make it for hours

#

At least can you tell a concept how to do it?

stoic wedge
#

Which part? You just want to know how to pass an amount in a request body?

dull aspen
#

yes

#

and why it's unsafe

stoic wedge
#

It's not necessarily unsafe. You can do it that way, but you're going to want to do server side validation

#

ie only create the payment intent if they pass an amount that is valid/what you're expecting

dull aspen
#

I see

stoic wedge
dull aspen
#

And with that, first I should make a server side validation?

#

I should make it in a different script or in the server.js script?

stoic wedge
#

How you structure your code is up to you

#

Again, we can't really teach the basics in here