G
G
Gucciprado13372021-07-12 02:34:13
WordPress
Gucciprado1337, 2021-07-12 02:34:13

How to take away the balance from the client with the selected php html tariff plan?

There is a table that contains the user's balance - this is user_wallet, for example. There is a page for opening a deposit and you need to make sure that at the selected rate, funds are taken from the client and added to the history - this is another page where the history of deposits will be. How can this be implemented, what to refer to, to do through the usual minus from funds, or to use other functions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alice, 2021-07-12
@Gucciprado1337

In your store, when you buy something, do they take money away through a minus or by other means? This is a simple arithmetic operation, do not complicate.

R
rPman, 2021-07-12
@rPman

It all depends on what logic the tariff plan has.
If these are lump-sum payments, then by itself you deduct the required amount in fact, calculating it either in advance, at the time of the conclusion of the contract (so that it does not happen that when updating the logic, previous contracts suddenly start taking a different amount), so they implement, incl. periodic payments - once a day / month.
If payment is based on time for use, then a function for calculating the cost from time is needed and it is necessary to change the logic for controlling the end of funds by adding a call to this function (for example, at the beginning of the interval and with any changes on the account, we calculate the maximum usage time), as well as its call at the end of the usage time interval. Be careful, this method is probably the most correct when implemented, but it requires careful calculation and accounting for intersecting payment intervals (i.e. two intervals are launched simultaneously, if you count the cost of each at the start without taking into account the neighboring one, then you can drive the account into a minus, allowing you to use the services for free)

A
acwartz, 2021-07-12
@acwartz

How it's done is your problem. The main thing is that the user would not have questions about where the money disappeared, and most importantly - why without his knowledge and consent.
You draw him an info page with "From your balance equal to = XXX, N money will be debited for service Z, while commission A money is taken. When you click "confirm", you do the math with the balance, form a transaction for the amount of debited funds in the history, commit the changes and the balance is new and the record in the history is greater.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question