M4trix Dev
M4trix Dev

Reputation: 2274

Stripe Payment Intent

I am trying to execute payment with Stripe using paymentIntent. I have read the following in the stripe website (link)

Create a PaymentIntent on your server with an amount and currency. Always decide how much to charge on the server side, a trusted environment, as opposed to the client. This prevents malicious customers from being able to choose their own prices.

I do not understand how I can decide how much to charge on the server side. My app has a series of items to buy and each item has a price app is a market place and the price list is in the client, so I decide how much to charge in the client...

Can anyone explain how I can decide how much to charge on the server? or what does it mean, maybe I miss the point?

Upvotes: 0

Views: 506

Answers (2)

Atif Hossain
Atif Hossain

Reputation: 63

For people who are still looking, you have to store the details of each product in your database and then send the product_id (or any information regarding the product) to the server. Then query the database for the prices of each item stored in your database to get the price. This information should always be in the backend and calculated in the backend itself.

Upvotes: 2

koopajah
koopajah

Reputation: 25552

You need to keep the PaymentIntent in sync with the item(s) your customer is ordering. If they can have a cart client-side where you add items you must be sending a request server-side to update the representation of their cart in your database or similar. At that point, you would calculate the total of the order and keep the PaymentIntent updated to reflect the correct total amount.

Upvotes: 0

Related Questions