Answer the question
In order to leave comments, you need to log in
How to deal with payment on the site?
I am creating a commercial project.
It is necessary to make sure that the user can replenish the balance in his personal account.
The question is how to do it?
All payment systems have a success url, which is redirected to after payment.
This is useful if you are selling a specific product, you can insert a link to a file hosting service, etc.
But how to make a balance replenishment?
You need to know the user ID, you need to know the amount for which the purchase was made, and so on, but you can’t stuff variables into the success url, and the user can go to such urls as much as he wants and wind up money for himself.
Ps sorry for the possibly noob topic and explanation, but this is the first time I've come across this and I really don't understand how to solve such a trivial problem.
Answer the question
In order to leave comments, you need to log in
The user cannot know the address of your handler, the payment server turns to the address of the handler after a certain event. The docks always indicate how to protect yourself from scam, from ip filtering to encryption.
It is also always possible to set a custom parameter, in your case, go to users in your system, the value of the parameter will be transferred by the payment server to your handler.
Success URL is just the address of the page to which the user will be redirected after the payment. On this page, you can display the status of the transaction, because your handler should already have received data.
1) You make a record in your database: user P wants to replenish the balance in the amount of N. The record must have an ID.
2) Redirect the user to the payment form for the amount N, also passing in the hidden ID field (this form is usually with the payment system).
3) After payment, the payment system will notify you that the payment by ID has passed (by calling the URL you specified). For security, you can check in your script that the call came from the payment system by, for example, checking by IP (sometimes it is specified when connecting to the payment). Either the payment will transmit the secret code, or in some other way (again, it depends on the payment).
4) You mark the transaction with the ID passed to you as completed in the database and give the user money in your system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question