I am making a event hosting website using php as backend language.So in this site we are showing various kind of events. So when user comes to our site he/she can register on the site and after registering he/she can browse through the events of their choices. Now they can buy a ticket for any event in which they want to participate.
To make the payment process I have integrated paypal api. So when a user will click on Buy Ticket button on any event and he/she will be redirected to paypal portal to proceed for payment.
I also need to store the info in my database that whom has made successful payments for which event. But the problem I am facing is that when someone returns from paypal after making successful or may be unsuccessful payment then the session variable in which I have stored the userid, that variables becomes empty. Now if I don't know the userid who have done the transaction, then how I can store the user with the transaction to the database.
I know that on various shopping sites same kind of functionality must be implemented but I want to know how people implement this with paypal.
You can integrate the IPN function(which is PayPal's service) to fix the issue.
IPN(Instant Payment Notification) is a PayPal feature that sends messages about payments (and other transactional events) directly from PayPal to your website(s)' back-end systems.
Logic: While a payment received on your PayPal account, PayPal will send IPN message to your IPN script almost at the same time. After receiving the IPN , your system can refer the IPN message to do the subsequent processing- update payment status into your system or send email etc. But the follow-up actions need to be integrated by your system(Including send email system). This process is complex, but it is the only way to achieve your marketing goal.
Following and the IPN integration guide.
Please kindly refer them.
https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/
IPN code samples:
https://github.com/paypal/ipn-code-samples
IPN variables:
Thanks.