How to protect my PayPal IPN handler in Joomla? - joomla

I'm developing small website which sells digital goods using Joomla. On my website, after confirming the customer's payment, we have to calculate some private information for him.
Hence, we have to prevent someone who didn't pay from visiting our PayPal IPN handler.
Now I have a nice IPN handler code for Joomla, which was written by Mr. Oleksandr Balyuk.
I think, using this code, I can describe my calculation process in Joomla.
But I've one question.
How can I prevent someone who didn't pay from browsing my IPN handler?

PayPal gives you the ability to confirm that an IPN came from them (As opposed to a spoofed IPN from a malicious user).
You simply need to post the entire contents of the received IPN back to PayPal, and you will receive a response that says VERIFIED if the IPN is authentic, or INVALID if even one character is different.
Check out page 16-17 of the IPN guide for more info:
https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

Related

Issue regarding paypal IPN in codeignitor

I am integrating PayPal payment gateway in my code ignitor website. and I am using this ref
https://www.codexworld.com/paypal-payment-gateway-integration-in-codeigniter/
All things are successfully done but payments transaction data is not saved into the database.
I have set the IPN URL in the sandbox business account. And in the IPN history page, It showing IPN was sent successfully. but IPN data not received on my website.
I also test IPN using the IPN simulator. When I put my base URL like https://www.earlyyearz.com/ then IPN was sent successfully. but when I give the path of my IPN function
https://www.earlyyearz.com/payments/ipn then it was saying IPN not sent.
does anyone can help me to fix this.
thanks in advance.
Add logging to your IPN function so you can see what is happening when it receives the data. If your IPN function does not respond with an HTTP 200-level status, PayPal will mark the IPN as not having been received.
IPN is an extremely old service that was not designed for modern web integrations. If this is a new integration, first ask yourself why you are using IPN to begin with (you shouldn't need it for a normal PayPal checkout with server API captures)
But if you really do need asynchronous notifications (again, you shouldn't need them), use webhooks instead of IPN.

Joomla AEC issue with Paypal, possibly IPN

I installed the Joomla AEC Version 1.0, Revision 5149.
I have set up plans and everything in this matter, if user clicks on the create an account system will ask user to select the plan. Then user clicks on buy now, she goes through Paypal, Purchase get made (Subscription with 3 days free trial) then user get redirected back to the site which all works fine.
My problem is user will see the message that says "Thank you for your registration. Our system will now await your payment. You will receive an e-mail once our system has processed your request. ". site will never get the clearance from Paypal. I havent put any custom custom URL or anything like that.
Also site is in the staging. so the URL starts with http://staging.domainanme.com
Not sure if this will cause an issue.
Thanks
With AEC it is quite simple with a Paypal Subscriptions processor. You just need to put in the email address of your account at:
Processors -> Paypal Subscritions -> Business ID
Not sure if that will be the same with 1.0 as this is based on 1.2.
If you have a valid account that's all you need. Of course make sure you have assigned the processor to your plan.
So if this all checks out one other thing you can try. If you were using the paypal account before with some other domain then switch to staging.domainname.com then you might want to try adding the Alternate IPN Notification Domain. Find this at:
Processors -> Paypal Subscritions ->Alternate IPN Notification Domain
In here put exactly http://staging.domainname.com
UPDATE:
The problem is Paypal communication then. First remove the Alternate IPN Notification Domain setting in AEC that I suggested. That was just for testing.
Either Paypal email is not confirmed so the communication fails or the communication can't be established.
Assuming you are using Paypal Standard, go to Paypal and login. Check in this order:
Click on Profile. Does the email have "unconfirmed" beside the email? If it does then that's your problem.
Go to Profile -> My selling tools -> Instant payment notifications. Click update on the far right. Enable it and add a new notification url. It should look like: http://www.yoursite.com/index.php?option=com_acctexp&task=paypal_subscriptionnotification
Just another thought. Paypal doesn't enable Paypal subscriptions when you sign up for Paypal Standard. I can't remember exactly when/how that was done but I remember that a separate step was needed. That could also be the cause of this issue.

Paypal IPN failing with a Magento site and another different side - collisions

Have a workign Magento 1.7 live site, its Paypal has been fine until recently when another site got attached to the PayPal account it uses.
This other site does not use IPN (Magento site uses PayPal Website Standard payments). However, I think it is that the other site triggers a IPN notification that goes to the default URL , which is of course set to the livesite's /paypal/ipn/ URL IPN listener.
I have found this thread on a different site http://www.magentocommerce.com/boards/errors.php/viewthread/285840/ where some solutoins are given but it seems very inconclusive. What is the recommended way to fix this issue?
1) write dummy script IPN to catch nonIPN Calls and respond with something
2) turn off IPN in paypal account, since Magento may send its own ones anyway (?)
3) Other solution?
thanks for any advice!
Do not set actual IPn url in your paypal account.
IPN url should be posted to paypal( Generally is posted in Magento ) so will result in IPNs to these payment received on stated IPN url.
If you set Magento IPN URL in paypal IPN value then when payment is received by another cart added and if that cart is not posting IPN url when payment related request is posted then IPN will be delivered to URL defined in IPN value on Paypal.
Your assumption is correct in that if you have IPN configured in your PayPal account it will catch transactions from anything that hits your PayPal account whether it came from Magento or not.
You can indeed disable IPN in the PayPal account and specify an IPN URL with individual payment requests to PayPal. This is done using NotifyURL in API requests or notify_url in standard buttons.
I'm pretty sure Magento is already doing this by default, but you should probably check. If it's not you can extend the Magento PayPal module to include this so that you don't have to set it in the PayPal account, which again would get hit for ALL transactions.

How do I turn off PayPal IPN in Magento?

When people make a successful payment with PAyPal in my Magento webshop it automatically creates an invoice with unique invoice number. For bookkeeping reasons, I have to disable it.
I've been searching for a few weeks now but I still haven't found the solution for this problem. What I know so far is that this is caused by IPN. The problem is I don't know how to turn this off without damaging my shop or paypal payments.
Some more specs:
- Version: Magento 1.6.2.0
- Standard paypal
Files containing IPN:
www/app/code/core/Mage/Paypal/controllers
"Turning it Off" is sort of vague, but there's no configuration setting on the Magento side that will allow you to accept PayPal standard payments using the IPN system but not create invoices. You're looking at writing custom code to do this. Here are some starting points.
PayPal IPN works with a callback URL. That is, once PayPal has processed a payment, it fetches a specific URL from Magento with a specific set of data in the post field. Then, based on this information, appropriate action is taken (an invoice is created, a credit is issued, etc.). So the quickest way to achieve your goal would be to change the IPN URL in your PayPal configuration. This means PayPal is still notifying a URL, but not the Magento URL, and an invoice never gets created.
If that doesn't work or has unacceptable side effects, here's the code points you're interested in. Assuming you're using a standard Magento PayPal setup with an IPN URL configured at
http://yourstore.example.com/paypal/ipn/
Magento will handles this request with the indexAction method in
#File: app/code/core/Mage/Paypal/controllers/IpnController.php
public function indexAction()
{
if (!$this->getRequest()->isPost()) {
return;
}
try {
$data = $this->getRequest()->getPost();
Mage::getModel('paypal/ipn')->processIpnRequest($data, new Varien_Http_Adapter_Curl());
} catch (Exception $e) {
Mage::logException($e);
}
}
The business logic for this method (including your invoice creation) starts in the paypal/ipn model. In a standard system this resolves to the class at
#File: app/code/core/Mage/Paypal/Model/Ipn.php
class Mage_Paypal_Model_Ipn
{
....
}
Trace the code from here to find the method you'll want to rewrite and implement your desired functionality changes (not creating an invoice). Your best bet will be setting up a PayPal developer sandbox account so you can repeatedly hit the URL until you've traced your code to the right spot.
Good luck!
instead of hacking your core Magento files, just turn off IPN within PayPal.
By default, there are three states for PayPal IPN:
On
Off
Disabled
The first option will let you specify an IPN URL within your PayPal Profile, and you'll have access to 'IPN History' under the 'History' tab. All IPN data for your account will be sent to the URL you specified, unless you override it with notify_url / NOTFIFYURL on a per-transaction basis.
The second option will turn IPN off on your account, but you can still use it by setting notify_url / NOTIFYURL on a per-transaction basis. This is what Magento uses.
The third option will stop generating IPN messages for your account, even if your shopping cart (Magento, in this case) specifically asks for IPN messages by sending notify_url / NOTIFYURL. No IPN messages will be delivered whatsoever.
To set IPN to 'Disabled', first set it to 'On' in your PayPal account and provde a URL to an IPN address (though this can be any address, just enter http://www.google.com/ for example).
Once enabled, look for the option stating 'Stop receiving IPN messages (Disable)'. Use this to disable IPN altogether.
Source:-https://lastdropofink.co.uk/tools/magento/magento-paypal-ipn/
If I got you right, you should change Payment Action to Authorization for your paypal payment method. See more info there:
http://www.magentocommerce.com/knowledge-base/entry/setting-up-paypal-for-your-magento-store#1.1
Or, instead of hacking your core Magento files, just turn off IPN within PayPal.
By default, there are three states for PayPal IPN:
On
Off
Disabled
The first option will let you specify an IPN URL within your PayPal Profile, and you'll have access to 'IPN History' under the 'History' tab. All IPN data for your account will be sent to the URL you specified, unless you override it with notify_url / NOTFIFYURL on a per-transaction basis.
The second option will turn IPN off on your account, but you can still use it by setting notify_url / NOTIFYURL on a per-transaction basis. This is what Magento uses.
The third option will stop generating IPN messages for your account, even if your shopping cart (Magento, in this case) specifically asks for IPN messages by sending notify_url / NOTIFYURL. No IPN messages will be delivered whatsoever.
To set IPN to 'Disabled', first set it to 'On' in your PayPal account and provde a URL to an IPN address (though this can be any address, just enter http://www.google.com/ for example).
Once enabled, look for the option stating 'Stop receiving IPN messages (Disable)'. Use this to disable IPN altogether.
What I’ve been really surprised by over the past few weeks is the number of sites that don’t actually have this turned on and it’s just not limited to self-builds even the really expensive Magento builds are missing this out this as a step.
Turning on the PayPal Instant Payment Notification (IPN for short) is an excellent idea as means that when a customer pays for an item using PayPal then the payment information will be updated on the Magento order details in the administration panel.
It only takes a few moments to enable and I’ll show you how to enable IPN for your Magento site below. This will mean that when you receive an order via PayPal Express for example, you can actually see the transaction details in Magento and if you’re using eSellerPro and have the eSellerPro Connector enabled for sales order processing, your order & payment details will match up automatically.
Setting this up won’t take more than a few moments and here are 6 simple steps to do this:
1 Login to PayPal
2 Hover on “Profile” and select “My Selling Preferences”
3 Halfway down the page, click on “Update” next to “Instant payment notifications”
Now enter the following details:
Notification URL – This is simply http://your-magento-store.com/paypal/ipn/ replacing “your-magento-store.com” with your website address. <= This is the part that normally trips everyone up as they’re not sure what to enter here.
IPN messages – Set this to “Receive IPN messages (Enabled)”
Press Save
That’s it job done.
To test whether IPN is working or not is dead simple, just make a test transaction through your website (you will need a secondary PayPal account for this) and a few minutes later, check on the order in your Magento admin panel has been updated with the PayPal transaction details.
To help you, I have put to images below, the image on the left has no IPN details, the image on the right does.

Magento, PayPal, and PayPal IPN - no event fired when an order is successfully placed

My module needs to know when a success checkout has occurred. So, in accordance with what I have read in various places, I listen out for the events checkout_onepage_controller_success_action and checkout_multipage_controller_success_action. That's fine, when I pay with a dummy credit card on my dev site, one of the above events is fired. But I wondered what happens if I pay with PayPal, so I said up a PayPal dev sandbox to test it out. Examining the http traffic, I saw that a notify_url was sent to PayPal when the order was placed. That was promising - when the paypal/ipn action is called from PayPal, the PayPal module will, if a 'completed' status is received, fire the checkout _xxx_controller_success_action - right? Wrong.
My module relies on knowing when an order is successfully placed, so I am looking for advice on the best way to tackle this issue please.
I'll just add a little bit about my environment here in case it is relevant.
I am running Magento 1.4.2.0 on my laptop. When using PayPal Standard, a notify_url is sent to PayPal which overrides any set up in the PayPal account. I am testing from my laptop, so the notify URL passed to PayPal is not accessible from the PayPal sandbox. So I changed the notify_url to point to an accessible JSP that just printed out the notification it received. I then give that parameter string to a little Java program I run on my machine which posts it to the original notify_url (.../index.php/paypal/ipn).
Thank you.
This is an old post but still a relevant question. We successfully used event checkout_onepage_controller_success_action (which is used by Magento core GoogleAnalytics extension) to observe successful PayPal Express orders (and also checkout onepage orders). Event sales_order_payment_pay did NOT fire for new orders.
I was having the same trouble - try using the sales_order_payment_pay event instead - it worked nicely for me

Resources