Triggering an action after Paypal Buy-Now purchase is complete - paypal

I've got a web application with a form where users can sign up for a seminar. The process is currently as follows:
Register for seminar
Registration success page with Paypal Buy-Now button to make payment
Paypal payment
Registration completion page
At present, emails are sent to the admin and the user at step 2 after registering confirming their registration. This needs to be changed so that the emails are actually sent in step 4, after payment has been made.
The application is built in ASP.NET, and all of the code to send emails, etc is all done. I'm curious as to what is the best way to trigger a process on the main website using the users details after they have completed the Paypal payment process.
From what I can see, there are the following options:
Store the data in the session. When the user returns to the registration completion page, retrieve the information and send the emails. My concern with this is that I've worked on a project in the past implementing this and it never worked very well, with the session getting lost.
Store the data in the database. Have the Paypal redirect include the transaction details in the querystring to the return page, which can retrieve the registration details using the email address and send the emails. However, this may not work if the email address used on Paypal is different from the one used to register (which is quite likely in this scenario).
Post all the details to Paypal, so that they are included in the transaction. Downsides: Won't send confirmation email to the user, only the admin (and assuming that the Paypal email address is the same as the email to which payment notifications should be sent). Also not sure if this can be used with hosted buttons.
I'm sure this is a common problem, and any advice would be appreciated. Thanks.

Use paypal instant payment notification
When the order is placed on your site, put it into a db table, with whatever you need to record. I then have an OrderId (from the db table) that I pass to paypal as an 'invoice' field, this gets passed back via ipn with a payment status etc.

Related

Returning a PIN after a successful payment

I'm currently trying to implement a mechanism whereby i can return a customer to a success page containing an activated PIN allowing access to a piece of software. The process is a straight forward PIN purchase without any kind of user accounts or login system involved.
I have the payment buttons and IPN script in place and working fine, but this only allows me to email the PIN after a successful payment via the IPN script, since of course the two sessions are completely separate to maintain security.
My problem with this is that i can't be sure the customer has access to the same email they used to pay with via Paypal. I had the idea of asking the user to enter which email they would like the PIN sent to prior to the Paypal redirection and then sending it as a custom value.. but then came visions of a mammoth backlog of support emails where users have entered the wrong email. I would really like to be able to redirect to a success page containing the PIN.
Thanks in advance.
I would recommend using the Express Checkout API. The payer experience is very similar to standard payment buttons, however, the user is always guaranteed to return back to your site, so you can display whatever you want on your final page.
That documentation can be a little scary, but it's really just a matter of utilizing 3 API calls.
SetExpressCheckout - This is used to setup a new transaction and will return a token that you'll append to the end of a redirect URL to PayPal. The user is sent to PayPal, they login and agree to pay, and are then sent back the ReturnURL that you specify in this request.
GetExpressCheckoutDetails - Now back on your site/application, you use this API to obtain information about the buyer like their shipping address, address status, payer status, payer ID, etc. You will need the Payer ID for the final API call.
DoExpressCheckoutPayment - This is very similar to the SetExpressCheckout request, but no transaction is completed until this call is completed. Only then does the money move.
Again, those final calls are done on your site so you can use the API response data to update your database and display details on the final page however you want to.
Keep in mind that payments could still be pending for one reason or another, so you'll want to check the status (returned in the DECP response) and display appropriate information on the final page.
IPN's will still be triggered with Express Checkout so you can adjust the IPN script to handle pending payments or anything else you may want to automate outside the checkout flow.
If you happen to be working with PHP my class library for PayPal will make these calls very quick and easy for you.

PayPal IPN Adding your own data onto IPN message

I have integrated PayPal into my website and have the IPN system working successfully. The problem I have now is that unless the PayPal email is the same as the one they used to register on my site, I have no idea who the person is.
I would like to add on my own data to the IPN message such as AccountID=10 or AccountName="SomeName" so that I can identify who the person is for my own user base since it is selling of virtual goods and privileges and not shipping to some address. Can this be done?
You certainly can send many parameters such as invoice parameter with your Paypal IPN request and get it returned with IPN response.
Full parameters list is available here:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/
You could also make this a non-issue by setting it up so your customers use their PayPal login credentials to log into your site. Have a look at the following documentation:
https://developer.paypal.com/webapps/developer/docs/integration/direct/identity/log-in-with-paypal/

Proper way of storing user info during PayPal Checkout payment process

I have a registration website. Tickets can be purchased through PayPal Checkout, but of course in this case users are redirected to PayPal.com to pay there.
Problem: I don't want to write anything in my website's database before payment is complete. I want to write everything when users are back to my website from PayPal checkout page.
Question: what is the proper way of storing user info and purchase info during PayPal Checkout payment process? Is PHP session variables the right, professional response to this problem? Or is there a more reliable solution?
The recommended method would be to use Instant Payment Notification (IPN). It will POST transaction data to a listener script that you build which can receive that data and then update your database, send out email notifications, etc. in real-time.
IPN is separate from your actual checkout flow, though. It's just a script that sits there listening for data to hit it, and PayPal pushes data to it in real-time as transactions hit your account.
Here's an IPN template I built years ago that would get you up-and-running very quickly.

Send Paypal IPN to a secondary email (NOT the primary) How?

My developer is trying to get the instant payment notifications for one of my web products to be sent to a secondary email, not the primary Paypal one. But no luck so far -it keeps getting sent to my primary email. I'd like some help on how to get it sent to a secondary email account?
Thank you
Your email address doesn't have anything to do with where the IPN gets sent. You basically have 2 options for configuring IPN.
1) Log in to the PayPal account that is receiving the payments, go into the profile, and then into Instant Payment Notification Preferences. Enable it, and add the URL to your IPN listener. This will now act as a default IPN listener so every transaction that hits your PayPal account will send an IPN to this URL.
2) If you include a notify URL in your button code or API calls this will override what you have setup in your profile. If you need to send IPN's for a specific button or API call to a secondary IPN listener you can just add that URL to the notify value for the request and that's where the IPN's will go.
If you need IPN's to hit multiple scripts you might want to take a look at this article I wrote awhile back about daisy-chaining PayPal IPN scripts.

Send an e-mail to PayPal buyer

I'm introducing PayPal Digital Goods for Express Checkout on a web site. For an user who is logged in, a valid checkout results in an update in the user's profile on the website, which in order allows to access more content.
The owner wants to add support for clients which aren't yet logged in to the web site. We handled this by introducing a landing page with an unique URL, which the user is redirected to after payment and which can be used to create a new account or mark an existing account as paid. If the user doesn't want to do this immediately, the URL of the landing page is persistent and bookmarkable.
However, in case the client doesn't want to log-in immediately and fails to bookmark their unique link, we'd want to additionally send a confirmation e-mail which would contain the link.
Paypal sends a receipt e-mail to the buyer right after purchase. Can I somehow insert additional message for the client in that e-mail?
If not, is there any other PayPal API feature which would let me send a message to the client's e-mail registered with PayPal?
Unfortunately you won't be able add or modify the content in the email message sent by Paypal. They lock down those type of things for security purposes.
However, you can send your own confirmation email once you receive notification that the payment has been completed. Whether you are using PHP or another server side language, you should be able to collect the email address from the variables returned by PayPal and send a custom email using the mail function. Since you create a custom landing page for the user, you can simply send it from here.