Welcome to WebmasterWorld Guest from 54.205.74.11

Forum Moderators: coopster & jatar k

delete from mysql if leaving page?

   
5:03 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,
I am doing an online booking with payment paypal.
The choises I have is to first insert the booking, then send the id to paypal and verify if paid, if not paid I would delete that id from the database.
Or I could better only calculate, send all the vars to paypal and if paid insert the booking, however not sure if that is possible as there would be many vars to send to paypal.

If I choose option one, to insert the booking before payment and then delete if not sucessfully paid, I will have a problem I cant think of any idea how to solve.
What if somebody click on buy now button, go to paypal however they just close the window or navegate to another page or site, then how cand I delete the booking I just inserted?
Any ideas and/or recomendations?
Also if I have to do the booking before payment, any good captcha to make sure its not a robot filling in the bookingform?
Thanks
7:21 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did some work with PayPal a while ago and ran into something similar. I used an interstitial confirm/proceed-to-payment page to allow recording the essentials of the transaction before sending the user to PayPal for payment. Then I used the IPN notification to update the status of the transaction - completed or otherwise.

It does mean having some incomplete transactions in your database, but you can always include some clean-up code in the IPN callback script or anywhere routine maintenance is performed.
8:22 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I used an interstitial confirm/proceed-to-payment page to allow recording the essentials of the transaction before sending the user to PayPal for payment.

Not sure I understand, do you mean record all the vars such as arrivaldate, hour, taxi needed etc? Or do you mean just a confirmation page?
What I am afraid of that once they enter paypal they dont like the method and decide to not continue.

Maybe I could add all details to a temporary database without doing the bookings, send the id to paypal, get the id and then just do the booking just passing the details from a table to another and do the email or pdf file as a confirmation.

However the risk of doing the booking after payment is even is very low is that the owner can block for his own use or another cliente can book at the same time and the payment has already been done.
9:19 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Essentially you need a state diagram, where a booking runs trough on certain paths and keep (in a field somewhere appropriate in your datamodel) in what state the booking is.
10:30 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Essentially you need a state diagram, where a booking runs trough on certain paths and keep (in a field somewhere appropriate in your datamodel) in what state the booking is.


Yes, I can put it as unpaid, however how do I delete the booking if they leave the page?
Or do you mean that I do the booking, i.e block the property as unavailable but with state unpaid?
That way I need to manually check and delete the booking, dont like that to much.
Or do you mean something else?

Thanks
11:37 pm on Dec 7, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The concept of a state diagram in the manner I was referencing:
have a number of well defined states (e.g. free, booked but unpaid, paid, abandoned booking, ...)
And a number of well defined ways to transit from one to the other, that have a trigger to cause it.

The trigger can easily be a timeout (e.g. if it's not paid within 2 hours we release the hold on a room.)
all you do is run a query every once in a while (e.g. every 5 minutes to seek those that are too long in a state with a timeout and change their state. Doing this can be done in either a script from a cron job, or either in an include you run off of your site that checks to see when the last time the "maintenance" was, and quickly do it before proceeding.
10:55 am on Dec 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm, thanks, didnt thought about cron jobs, however I always hear they take or can take much cpua. I am on a shared host so I need to be careful with that.
With timeout you mean before get timeout in paypal I guess.
Also not fancy of letting something unbooked as booked for 2 hours nor less either.
No other way?
Only cron job or what I said to do the booking after payment with the risk that maybe a refund must be done.

Just entered cpanel and it says this, and I have no clue of Linux:
Warning: You need to have a good knowledge of Linux commands before you can use cron jobs effectively. Check your script with your hosting administrator before adding a cron job.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month