Collecting user data before PayPal purchase - php

I've ran into a problem. Basically, I have a website that users can hire someone to tutor them. Each tutor has a small profile with a video, bio and rating. The user fills out a form with information such as their name, email and the most important one which is the date and timeslot (Dropdown) they want. When they fill out this information they can then click "Buy Now" which is a PayPal button I've setup. There are no variables here, each time slot is the same price all round.
The problem I'm having is I don't know how to collect the user information when the PayPal button is clicked. Can I pass this timeslot to PayPal who then return it to me? I can set up simple form that will send this information to me in an email, however I don't know how I can trigger that PHP script when the PayPal buy now button is pressed.
Any help? I've been Googling for a while, I can't seem to find anything! Maybe I'm wording it wrong. Anyway, hope you guys can assist.

I would save all of the info in your database prior to sending the user over to PayPal. That way you can include the invoice number (or record ID) in the invoice parameter in payment requests.
If you're working with Payments Standard the parameter is called invoice. If you're working with the Express Checkout API it's called INVNUM.

Hi you can use Ajax in this situation. The ajax will prevent the redirect of the form to paypal for awhile but executes another process in which you will save and capture the information of the form to your database. After the process the redirection to paypal payment method will continue.
You can view this good tutorial in here.
http://anytch.com/save-html-form-post-to-database-before-redirect-to-paypal/

Related

How online shopping works in this case?

I would like to create a web form for the buyer to fill and then a direction to Paypal to pay the item, then comeback to the page and if the purchase is approved it submits the form and wait send me an email with its details.
I know how to create the form but front-end, and also I know how to send a php email to submit the form. But what about the payment part ?!
Can someone explain me how it works.
Is it possible to create something like this?
Any tutorial or similar example, links would be useful.
Look into the Paypal API
https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside
When the user successfully completes the transaction the result is sent back to the page, you then check if the result was successful, if so onwards with whatever code.

Submit a form before redirecting to paypal

I have a site that provides guide tours. Each tour has it owns price depending the people that will participate.
The user has to fill the form, then the server has to validate the form and then sent an email to the client and to the agent office with the details of the booked tour (preferred day, how many people etc) and then redirect the user to paypal to pay.
The problem is that the Buy now button that paypal provides has his own form with some hidden fields so two forms on same page.
I found tree solutions but I don't know what is best.
When user press submit, do the validation , send the emails and then redirect the user to a page that has a button that says something like 'Proceed to paying' that submits the paypal form with the giver price in the hidden fields
When the user press the submit button an ajax call been made at server to validate the form and send the emails and then on success submit the paypal form.
When user press submit, do the validation , send the emails and then the server submits the form to paypal
I am reading a couple of hours finding the best solution to this problem. What is the most secure , efficient and won't create problems to the user.
Sorry for my English
Assuming you have a fair knowledge of web development (since you are talking about forms, sessions, etc.), I'd recommend using PayPal Express Checkout APIs. What you are trying to do is very common. And here's how I would do it:
User enters tour information in a form on page-1, and hits the "submit" button.
Your server receives the call, validates the form and calls SetExpressCheckout with PAYMENTACTION set to "Authorization". This is just like "booking a hotel room" or a "rental car". You are just asking the user to authorize payment at this moment; not charging him yet.
The API returns you a token. You store this token along with tour information in your backend database; and mark this particular "booking" as say "booking request received".
You redirect the user to paypal.com (and pass that token in the URL) to "authorize" the payment.
Once the user completes authorization, paypal redirects the user to your website (the "success page" or the "return URL" as it's called in paypal terminology).
You update your database entry with the status say "payment authorized". At this point you email the user and the agent.
Agent validates and makes sure that there is still room available in the tour, etc. and let's you know that the user is all set.
At this point you call the DoCapture API using that token. This actually "captures" the payment. And you update the database entry with the status "payment processed". You can also send another email to the user confirming the payment and the booking.
At any stage if there's a drop off (say the user never completed authorization), you'd know from your database, and you can send a follow up email to the user. Or if he authorized but later the agent says there's no space on that particular tour, you could again follow up with the user for next available date, or void the payment, etc.
Yes, this means that it's "more coding"... but then you get "more flexibility" and hopefully you'll be able to reduce drop offs.
Hope this helps. Here's the documentation for express checkout: https://cms.paypal.com/cms_content/CA/en_US/files/developer/PP_ExpressCheckout_IntegrationGuide.pdf. There are Java, PHP, etc. SDKs available for this to help merchants integrate quickly.
You'd create sort of a confirmation page with all the values of the PayPal form but using <input type="hidden" balal /> rather than <input type="text" balal />
Try to break up the process instead of having the whole transaction sitting on that "Buy Now" button. Perhaps create a basic cart system on your website, then allow users to checkout which then will send the contents of their cart using hidden inputs to PayPal.
This way will allow you to match users to bookings.

How can I link PayPal PDT transaction to specific order?

I see many examples of how to display transaction information to a user with PDT. I cannot find a way to associate a Paypal payment with a specified ID so that when the transaction is completed, I can update that ID in the database as paid.
How am I supposed to get an ID that I specify back from Paypal so I know what the payment is for? I cannot use the email address or name or anything else. It must be an ID that I specify.
I see some people using item_number, but I am using a Paypal encrypted button so I cannot add on form variables to post to Paypal when the user clicks the pay now button.
I see this on websites all the time, so I know there must be some way to do this. I just can't find it anywhere...
Thank you
Most often people encrypt their own buttons and use either the custom field which gets sent pack to you, or the item number field. Look into how to encrypt your own buttons with PHP.
PayPal offers a sample in their SDK which can be found here.
I stumbled upon this excellent piece that succinctly lays out how to make dynamic encrypted paypal buttons. It is just what I needed. Thanks for pointing me in the right direction!
http://www.stellarwebsolutions.com/en/articles/paypal_button_encryption_php.php

Passing variable values over to paypal's cart for payment

I have created a basket where a user can add to and update etc. This basket has been built based on what product the user adds to cart obviously. The product itself is grabbed from the database and displayed in a table in the basket. How do I use Paypal from here? I now want a button called 'pay' that the user can click and then it takes them to Paypal to pay. But I want the details of the items to be displayed in Paypal.
I have signed up to paypals web standard payment. Obviously I don't need their add to cart buttons since I have got my own cart. I think I just need the buy button but as mentioned, I am not sure how to get products over to Paypal.
Can somebody explain what I need to do please
This broad of a topic is generally best suited with a quick Google search. Basically, find a paypal form (perhaps through Paypal's button builder) and edit the form's values to suit your needs. This can be accomplished with php or javascript quite easily (PHP is a bit safer as it limits tampering). Then users send the form :)
You can also create a link such ashttps://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=$business which will do the same as the full form (add all of the fields you want to send, of course).
Give it a shot - if you have more specific questions, post back with clarifications.

click pay now in paypal page update my database too

I have a table to store my credit from user has been paid.
credit
+id
+amount
My goal is when you user click on button pay now in paypal page I have abiltity to update my table the amount field.
Anybody know the ways to do this,
thanks
EDIT: look at this code
http://www.micahcarrick.com/04-19-2005/php-paypal-ipn-integration-class.html
If the button goes off to PayPal, you'll need to intercept the request first, either with AJAX, or send to a PHP script, and then send on through to PayPal.
PayPal's Instant Payment Notification protocol is usually what's used to do this.

Categories