Am I correct in my understanding that I can only pass-through one custom variable from a form I create to PayPal using IPN?
I have my IPN script up and running with no issues. However, upon payment notification I need to store information input by the user from a form on my site into a MySQL database.
In this specific case its for a sports league registration form. The user fills out info regarding their team (i.e. Team name, League, ect..) then pays the league fee via PayPal. Upon verification I'd like to store their team name, the league they're signing up for and other info I need to collect in my database. But since I can only pass-through one custom variable from my form through the PayPal IPN process, I'm a bit stumped.
I've read other posts about storing the info immediately in the database, then marking it 'paid' upon verification. However, how could I accomplish this since when the user clicks Pay Now, the form action performed is the PayPal payment process (as opposed to an insert statement I create). Where would I perform a database INSERT with the posted form information?
Tips or advice would be appreciated!
However, how could I accomplish this since when the user clicks Pay Now, the form action performed is the PayPal payment process (as opposed to an insert statement I create). Where would I perform a database INSERT with the posted form information?
Perform the INSERT before sending the customer to PayPal. Before that, define a unique random key for the transaction. Put that key
into the database record that's being inserted and
pass it to PayPal's IPN.
Once notification comes back from PayPal, you can use the key to identify the record (with all the info already in it) and mark it paid.
Related
I have a website where I want the form data to be submitted only if I know the customer has paid via the PayPal button. Right now I have it at the point where they can pay and I verify it (via IPN) and that's about it.
I'm looking for some ideas on the best way to approach this? I was thinking that when the IPN verifies I can insert a column into the DB saying "paid" and store some information in the session. You can then only access the form if that data is in the session. Once the form has been completed I can update the status from "paid" to "completed" and remove the session data. I would remove the session data because a customer can pay as many times as they like with different form data each time.
Any other ideas? Also, this isn't a site where you would log in.
To sum it up, I want the customer to pay first (and I know they paid) then fill out a form.
If you don't have any login mechanism, I would request an email aswell when paying, Store the email + paymentID (unique PK) in the DB, when payment comes back through IPN, email the customer with a secret passkey, you can only move forward with that passkey.
In my opinion sessions are a problem to use for paying user. what happens if that user's computer crashs right after he paid. He has no way to access his product. An email + secret passkey would enable him to
I have a custom store where I'm selling a single product (as a gift), I need to be able to store the recipients address (different from paypal users), a message for the gift and the name they want their gift to be from (if any).
I'd really like to capture the data on this page:
http://sendvalentinesflowers.co.uk/responsive-buy-rose.html
It appears that the standard buttons don't allow this much data to be passed/stored along side a transaction. I'm just wondering how this HAS to be done with IPN? I'm looking for the simplest way to do it.
I would save all of the information in your local database as "pending" prior to sending the user over to PayPal for payment. You can include the invoice parameter in your PayPal code and set the value to the record ID of your local record.
This invoice value will be returned in IPN so you can pull the data back out and process it as necessary, and also update the existing record's payment status according to the current IPN.
I'm seeking some guidance from people with experience in building ecommerce sites. This is actually my first time integrating with a payment gateway.
My implementation is actually a very basic booking system, where user places selects a date and number of tickets to book, clicks checkout and comes to a order confirmation screen, and then upon clicking submit again, user is brought to 3rd party payment gateway.
The 3rd party payment gateway url expects a post submission, containing a few mandatory fields for their api, one of which is a orderID to identify the order.
This is what I'm doing:
Unique order is generated when the ticket booking page is loaded.
User chooses what date he want, # of tickets, and clicks submit.
Data is validated, and then saved to a bookings table in db, while the user is brought to the confirmation page, presenting him/her with the details they have chosen and the price.
User clicks checkout, and the form is submitted to the 3rd party payment gateway url, user is brought to their page as well to complete payment.
Payment is completed, user is brought to our success page, payment gateway also posts details of transaction to a url of our choice which captures the transaction details, and saves it into a orders database.
So is that feasible ? My questions are:
Should unique order ID be generated as soon as ticket booking page is loaded ?
Should I have a booking database that saves bookings on the confirmation page ? What is user never clicks submit, then i'd eventually have a long list of records.. of course we could create some functionality to clean up the table, but is this common practice ?
Should I have a temporary booking database as mentioned above, as well as a completed transaction database that only captures transaction details from the payment gateway ? (Regardless of successful/failed)
Q1. Should unique order ID be generated as soon as ticket booking page is loaded ?
Ans: No, you should not do it at the time of load. Rather, should do it when the final submit is made for the 3rd Party payment gateway.
Q2. Should I have a booking database that saves bookings on the confirmation page ? What is user never clicks submit, then i'd eventually have a long list of records.. of course we could create some functionality to clean up the table, but is this common practice ?
Ans: Submit the form to your php script and make entry in the database only after submit is clicked. Then you can submit the form to the 3rd party from your php script once the enty has been made into your database.
Q3. Should I have a temporary booking database as mentioned above, as well as a completed transaction database that only captures transaction details from the payment gateway ? (Regardless of successful/failed)
Ans: Not required if followed what mentioned in answer for q2 above.
Hope this helps.
I'm trying to write an IPN that, upon successful transaction, modifies a database entry (like as to increment a currency (like Envato does for their prepaid deposits)).
I've looked over the IPN variables a few times and I can't figure out how to track a user transaction, except for the payer's email (but this relies on the fact that the registered account's email is the same as the payer email (which is not always true).
I'd like to track it using an account ID, but while the IPN will reply with a custom variable, I can't transmit a dynamic variable (using the Buy Now button) for it to send back (like an account ID).
My question is, how can I send a dynamic variable with these buttons or track it an already established way?
You can transmit custom data via Paypal. Look at the custom variable.
So the scenario is this:
user logs in;
in the page which is before payment page, you either have hidden input having custom field set to user id or form it dynamically with Javascript;
custom field is not even shown to the payer when he/she confirms the payment;
when transaction happens, custom field is stored (so you can always look it up in Paypal website);
IPN notification sends you the custom field value (amongst other ones) which you can use for identifying the user.
I have got similar scenario working on a production system.
I've implemented a paypal transaction before but this one has a twist that I'm not quite sure what's the best way to handle it.
The basic idea is I want to create an account for the user when he provides some details and makes a payment via PayPal. Until BOTH the user details are filled out correctly AND the payment is made correctly, I shouldn't create an account for the user.
The setup I've done before was simply a paypal button that the user clicks, makes a payment, and gets forwarded back to just a generic page "your order will be processed and shipped" so there was no pre-order form involved.
This one is different though because
before PayPal, I need to collect initial user data
after PayPal, I need to create the new user account and use in it the user data collected from the pre-paypal form
I'm sure there's a logical way to implement this, but I'm not quite sure what's the flow I should follow to do it.
I use the Zend framework by the way, which shouldn't matter but just in case Zend has an easier way to help me with what I'm trying to do.
I do the following (though I do this in ASP.NET):
User fills out form
Info is saved in Order table in db with a unique invoice number
Invoice number is passed to PayPal, along with the IPN Notify URL, when you do the redirect
User is sent to Paypal to pay and then comes back to a generic Success page
Behind the scenes, Paypal makes a call to the IPN Notify url once processing is complete. This page receives your invoice number which PP returns with its call, and then does the account creation processing for that order after retrieving the details from the db. [This is a page with no UI, since only PP is hitting it.]
An email is sent from that process which notifies the customer that their account has been created and gives them the details.
This is a simplified version of the process, but hits the highlights. You can check out PayPal's page about IPN, and do a search on google for IPN integration with PHP.