customer fund management system design in shopping websites

A newbie website programmer may thinks it easy to handle the customer’s fund. Consider a buyer buys a goods/service from a seller on your website. Most likely he will handle the fund of the buyer and seller as follows:

$buyer->money-=$price;
$seller->money+=$price;

This is very risky. The seller may withdraw his money immediately, leaving no time for the buyer to cancel his order. If the goods is a kind of service that lasts for some time, the above code will form a prepaid. In most cases, it is proved that postpaid is more safe and more comfortable for both buyer and seller. But you should not do the above code at the end of the service term, which would be unfair to the seller. The correct way to deal with the transfer of fund is using another variable to freeze some money of the buyer at the buying time.

$buyer->money-=$price;
$buyer->frozenmoney+=$price;

Now the buyer cannot withdraw or use the frozen part of his money to buy other goods. But the seller is not getting the money at the moment. When the time comes near the end of the service term, the system should update the money of the buyer and seller as follows:

$buyer->frozenmoney-=$price;
$seller->money+=$price;

The update can be done automatically using a cron job.

 

Posted in

Comments are closed, but trackbacks and pingbacks are open.