Hello. Faced with the problem. I'm doing a website for booking hotel rooms. Theoretically, the script should work like this:
- The person comes to the website
- The script checks the availability and dates, and shows them to
- People choose booking date and room and presses to pay
- The script checks for free these rooms
- If the rooms are still empty, script writes to database entry with the date of the reservation number, customer data, etc.
- The person goes to the payment page of the booking (on Yandex cash, for example)
Now 3 scenario
- The man paid for the room and it swung back to the site congratulations on booking
- The man closed the page of payment (not paid)
- People idle for 10 minutes (not paid)
I probably need to clarify the 5th paragraph. This is done to ensure that no one else was able to book on these dates the room until our man pays it.
Well, the problem is how to delete a record from the database, if the person is not paid for your booking?
cron is not an option. If you set the script execution every 10 minutes, it is likely that people will reserve rooms on the 8th or 9th minute. That is, until the person is paid, the records from the database was removed, which is not good.
I imagine it this way: on the 5th item in the database is written to another string, such as: paid? Yes/no. And after the 5th paragraph, 10 minutes should trigger a script that will check the record in the database for the presence in the column "paid", "no", and deletes the entire row if they are.
How is this implemented? Prompt where to dig?