B
B
beduin012022-02-02 21:19:32
Electronic commerce
beduin01, 2022-02-02 21:19:32

How to calculate the cost?

A question. The site issues an invoice to the user when buying goods.
On the one hand, it seems logical to have a JS part that shows the final cost, on the other hand, this is a potential security hole.

How right? After selecting goods, their cost is calculated on the server each time? And return the result? Or does it need to be duplicated somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-02-03
@vabka

If the formulas are simple and do not require a bunch of requests to third-party services, you can calculate at the front so that the user can immediately see the price.
If this is already an order being placed (with the calculation of delivery and other things), then let everything be considered on the backend.
And also, when paying, the amount should be formed only by the backend.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question