How to check the initial message sent to paypal? - paypal

I need to match the user who triggered the initial Http message sent to paypal, to the IPN i'm receiving on my backend when the transaction is completed. Since Paypal is unaware of my user database I'm looking for some kind of transaction ID.
the thing is, when a user clicks on a paypal hosted button, Paypal opens another window and processes the buyer login and every other payment steps there.
I've had a look at the URL of that new Paypal window and there is nothing there that will also be stated on the IPN.
Is there a way to check the initial http message sent to paypal from my frontend?

You can use the custom parameter to pass your own unique ID into the payment request. This would then be returned in the same custom parameter included in IPN.
The field is literally called custom and you can pass anything you want in it up to 256 characters.
You should be able to add it as an additional hidden field in your HTML form for the hosted button. If it doesn't pass as expected that way, though, you'll need to use a non-hosted button.

Related

Relation between payment made with createbutton api and ipn message

Our customers sends their requests for our products via email. Their requests are saved in our database and after we check their requests, we want to send them an email which contains the paypal payment link. To execute this, I am using BMCreateButton method of ButtonManager API of Paypal.
https://developer.paypal.com/docs/classic/api/button-manager/BMCreateButton_API_Operation_NVP/
This method returns EMAILLINK parameter and I am using this parameter in the email to redirect to user to paypal payment page. This method also returns HOSTEDBUTTONID and I am saving this parameter and EMAILLINK parameter to the database to make a relation between the email link(hostedbuttonid) and the user request.
For the payment notifications, I think my only choice is IPN of Paypal. I developed a page to handle the IPN messages from paypal and it works fine but the problem arises when I want to relate between the payment information with the email link that was sent to the customer. I mean I want to know for which request this payment was made. IPN message does not return any information about the HOSTEDBUTTONID. It returns btn_id(different than the HOSTEDBUTTONID), txn_id and ipn_track_id but none of them is useful to relate the customer request( or email sent) with the payment.
Do you have any suggestion about my issue? Or do you think I should use another way for sending the payment email to the user instead of BMCreateButton method of ButtonManager API.
In the BMCreateButton call, where you're setting up the standard PayPal variables for the button, add the CUSTOM parameter. Within that you can pass any value you want (up to 256 char.) and then that same value will come back in the IPN so you can relate it accordingly.
If you have a specific Order ID you could use the INVOICE field instead, and that would come back in IPN as well.

Can Paypal Payments Standard accept a value and pass it along to the webpage users are redirected to after successful payment?

I am setting up Paypal Payments Standard for a website; I am using the Buy Now button that, when clicked, takes the user to Paypal for them to enter their payment information.
Now here's the rub - when the user makes a successful payment, I want to send them to a partner website and I want to pass along the key they just purchased.
So in a nutshell there would be this interaction:
User visits my site and a Buy Now form is generated with a hidden field like so (along with the other requisite Paypal-specific fields): <input type="hidden" name="key" value="xxx" />
The user clicks the Buy Now button and is taken to Paypal.
a. If they cancel the purchase they are returned to my website. (Ideally in this case the key value would not be included in the return URL.)
b. If the payment is successful the user is redirected to www.someothersite.com/payment.aspx and in either a POST or the querystring the key that was in the hidden field is passed along.
I am aware that such a scenario could be handled using the Paypal API via the Payments Professional product (rather than the Standard product), but that's not an option for a variety of reasons.
Thanks
You could add the value to the return URL you include in the button code, and that would work (usually), but it's not recommended...because of the usually part.
Even if you have Auto-Return enabled in your PayPal account there is no guarantee that your user will actually make it there. You'll end up with people closing their browser before the redirect, for example, so they'll never see the final page and any code on that page won't get run for that order.
Instead, you need to use Instant Payment Notification (IPN). This will be triggered every time no matter what, and you can process the data in the IPN however you need to: send email notifications to parties involved, updating databases, hit 3rd party web service API's, etc.
So you'll actually use your own basic return URL similar to your own cancel URL, and use IPN to handle post-order processing.

PayPal IPN notify and success URL params

I'm implementing a simple Buy Now button and I'm using IPN (not PDT) to verify the transaction.
A thing that bugs me is that I don't understand how come only after I set the notify_url field to the button I also get the transaction variables to the success URL, as GET params. It would seem normal to be the other way around.
Since the user could or could not choose to "return to the merchant's website" there's not way I should rely on that data. It does however seem to be identical to the one sent to the notify URL.
Some clarification would help. Thanks!
I know what you mean, after the user has finished paying and chooses to return to the sellers website (button in paypal page) they are redirected to your thankyou page.
I don't think it used to do this back in 2009 but now paypal will issue the redirect with all sorts of parameters in the url query string.
I'm just ignoring this information and relying on the backend IPN post which is verifiable by paypal
In my previous experience with IPN, I defined the location of the notify URL in the control panel. Once the payment is processed, PayPal sends a POST notification to this URL independent of any user behavior.
In any case, even if you define the notify_url parameter in the button, I believe PayPal will still send the payment notification seperate from the user behavior - they spawn a new process to send the data. As to why they are using a GET rather than a POST, that is odd behavior. However, in your IPN script you should still have logic that verifies the call with PayPal before you continue processing.

Paypal IPN Message

i have included the payment system in my site using paypal.
in paypal, i have choose the payment message service as IPN.
Now i have some question about the flow my site, i don't how to handle it.
1) Now If the user name called "A" had paid for some service and at the same time user name called "B" is also making payment, How about I came to know that which user had paid for the service? [ means what should i include in my payment flow to know about the user? should i add the user id with my item name and then get that id from that item name in IPN message url]
2) What time is taken by IPN message, bcz last time when i was checking my payment module then i don't know when my message was sent by paypal, but it was certainly taken time say more 3 - 5 min, now what should i do to get the payment status immediately bcz in my site i want that, as soon as user had paid then that service should start immediately.
EDIT: Can i include any custom data with my payment. Bcz in IPN message sent by paypal, their is one filed called "custom" sent by the paypal so to add that if i have to include that file in my payment form.
1.)
there are custom HTML transaction variables that can be set for things like this and you will have to name the input tag accordingly. There would be two input elements for each custom field that you want to save. One for the field name and one for the field value.
These tags are on0, on1, or on2 for the custom field names and os0, os1, and os2 for the custom field values.
I would send on0 with a value of "UserID" and os0 the actual ID.
These values will be represented in the IPN as follows:
os0 is represented as option_selection1
on0 is represented as option_name1
Here's the info on PayPal's Parameters
2.) They are almost always within 5 minutes, but I have heard that from time to time there can be periods where this might be significantly more. You can always create a PDT success page that digests the same info that would be in the IPN message. This would be your return page from the paypal site and all your data would be included in the request. Just make sure you keep track of you still use the IPN in case the transaction succeeds but the user never makes it back to your site. I like using both methods so you can customize the welcome back to your site for the user based on their transaction. And if you doing that and have all the info you need, might as well process the order as well.

Triggering an action after Paypal Buy-Now purchase is complete

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.