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.
Related
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.
I recently converted from basic Paypal payments to Chained Payments...and I have a few questions if you guys would be so kind to help out.
First, when I setup a PayRequest, I also create an order record in the database. Previously with my basic Paypal implementation, I passed that OrderId in the custom field as part of the form post to Paypal. I would then get that OrderId back in the IPN handler and use it to mark the order as paid or whatever based on the response from Paypal IPN.
Now I am wondering what is a good unique value for my locally created order? Should I use the paykey to look up the order on the IPN callback? Or should I just set the trackingId property of the PayRequest to be the order id and pick up in the IPN callback Request object?
Secondly, there is a returnUrl and ipnNotificationUrl for the PayRequest. Should the returnUrl process the IPN callback or does the ipnNotificationUrl only should do that?
The reason why I ask is because the return url must be able to show the buyer the status of their payment and the transaction info, the same data that I get in the IPN callback.
Thanks for the input guys, once I get these two minor details ironed out, I'll be good to go!
I would add your record ID into the tracking ID parameter of the Pay request like you mentioned. That way you'll get it back in your IPN similar to what you're doing with the custom parameter now.
The IPN notification URL is what you want to set in order to trigger IPNs for the Pay request. You do not want to use the same URL for return because then the script would actually run twice.
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.
I've recently wrote my IPN listener script to manage purchases for my website. Whenever a user submits a payment, there is a custom hidden field with their USER ID as the value. I know that to identify if the message is a REFUND, it'll have the post parameters:
reason_code = refund
Now my question is, when PayPal notifies my IPN listener of the refunded item, will it still send the exact same post data (including my custom field so I can manage the user accordingly due to thei) that was sent when they purchased the item?
I hope I made my message clear and that it's not too confusing.
Thank you.
Yes, when you issue a refund you will receive the same custom variable back in the refund that you passed over when you charged the buyer. It will have the same value that you set. I also just tested this to make sure there were no issues with this feature, and it is working as it should.
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.