Paypal Standard Payments Setup with IPN
This How-to will run through the steps to setup Paypal Standard Payments with IPN Notification.
I was having trouble and there was scattered information on the forums. Turns out the problem I had was simple and related to using the wrong URL for the IPN. Follow these steps and you should be able to get it up and running.
Note: so far I have only tested this on Paypal’s Sandbox (development area)
Note: so far nobody I have spoke to has successfully got this to work in Live mode. It does not change an order to ‘processing’ once payment has been confirmed by paypal. The order stays as ‘pending paypal payment’ and returns and ‘invalid IPN’ statement. This bug has been raised and remains unanswered by Magento
Update to above note: I dug into this issue and determined the reason why invoices weren’t being created for Paypal Standard on Magento 18.104.22.168: Paypal now posts back url encoded variables for the store emails. This caused the email address matching to fail (see screenshot from admin panel). I created a small module that overrides the Mage_Paypal_Model_Ipn model: http://classyllama.com/wp-content/uploads/CLS_Paypal.tgz Note that you also have to update the ipn address to /paypal/ipn/standard/ as noted below.
* Update to the above update, the ipn url varies depending on Magento version. The above is only valid for versions before 1.4 and I have updated below for the current ones. *
If your paypal account is well set-up and if the IPN doesn’t work (in your log if the postback_result is empty), it may be due to a buggy php version. Be sure to use at least php 5.2.13 (works fine with v5.2.17)
First, sign up for a Paypal Developer Account. Then under Test Accounts on the left create one buyer and one seller/premier (store) test account. The buyer account should have a fake credit card added to it and some money in the fake Paypal account.
Note: emails sent from the PayPal Sandbox testing environment don’t actually go to the designated email addresses. The “Test Email” link shows you all the messages that were sent and received by the test e-mail addresses.
In Magento let’s setup PayPal Standard.
Enter the Business/Store Name. The name you enter in this field is used when all the items in the Magento shopping cart are aggregated into a lump sum on the Paypal invoice (see below).
Enter the test e-mail address that you used for the seller/premier/business PayPal account representing your web store account in the Paypal Sandbox.
Turn on the Sandbox option to enable testing in the PayPal Sandbox (no real transactions). Note: you must be separately logged in to the Paypal sandbox environment during the entire testing period.
Add these settings:
- Enabled: Yes
- Payment Action: Sale (actual transfer of funds)
- New Order Status: Processing (the order will be paid instantly through Paypal)
- Transaction Type: select “Individual Item” to have all the items in the Magento shopping cart listed separately on the Paypal invoice, or “Aggregate Order” when you just want a lump sum for the whole order on the Paypal invoice.
Go back to your Paypal Developer Account and login if necessary. Click on to “Test Accounts”: Choose your “seller account” (this should be a premier account) Click the button to “Enter Sandbox Test Site” This will log you in as that user.
But in fact this is not important because magento passes the notify_url thru the API to Paypal and the notify_url parameter overrides the Paypal account IPN url. It is why if you have multiple websites on a single magento instance, it can work with one single Paypal account.
Note: the problem I had was that I was using the IPN Address with a ReWrite Search Engine friendly structure without URL Re-Write turned on in the Admin. To turn it on (or off) go to System–>Configuration–>General–>Web
If using URL ReWrite (Search Engine Friendly URLs) our IPN Url will be:
If your are not using URL ReWrites your address should be:
(I think this is correct, have not tried it fully)
Warning: Any HTTP password-protection on your website must be disabled in order for IPN to work. Disable the password protection in your .htaccess file to allow the IPN response to come through to your store from PayPal.
Go to Website Payments under Profile on the PayPal website. Setup your return URL as, (again if using URL Rewrites): http://www.storename.com/paypal/standard/success/ If your are not using URL Rewrites your address should be: (I think this is correct, have not tried it fully) http://www.storename.com/index.php/paypal/standard/success/
Same comment as for the notify_url, Magento passes thru the API to Paypal the return url. The paypal return parrameter overrides the Paypal account auto return url. If you are running multiple websites on a single magento instance, you can use a single Paypal account with auto return on. Just place whatever return url you want in the Paypal account, it will be overridden by the return parameter.
Observe that in PayPal, Auto Return is not the same as IPN (Instant Payment Notification). IPN is what PayPal uses to tell your store that the payment has gone through. Auto Return is the URL that PayPal sends your customer back to at your store after they have paid on PayPal’s website.
You don’t need to enable Payments Data Transfer in your Website Payment Preferences to integrate Magento with Paypal Standard Payments. If you do this anyway, you will get a so-called “identity token” from Paypal. This token isn’t used in the Magento/Paypal integration and you should ignore it.
Before you start testing your integration using the Paypal Sandbox, ensure that you are logged in to your Paypal Developer Account.
For your test orders, it may be convenient to use the same postal address that Paypal made up for your test buyer account. To pay for your test orders, you can log in to the test Paypal account and pay the Magento order from the balance. You may also want to test using the fake credit card number that you have been given for the test Paypal account. Use any CVC code, it isn’t verified in the sandbox.
Now when you complete an order, a Sales Order will be created with the Pending Status. If you check your Orders in Magento before submitting the PayPal payment, you will see this order status. But then, when you complete the PayPal Payment and are returned to the Checkout Complete page on Magento, your Order should move to Processing and an Invoice should be created showing the Order as Paid.
This way you should know if the payment was successfully made. As always, test this fully to make sure it is working: you don’t want to be fulfilling orders without the PayPal payments actually being made!
If an invoice is not created, but the Order history does display a line indicating “Received IPN verification”, then this means that PayPal indicated to Magento that the payment’s status was still pending (in this case, the PayPal IPN POST data field payment_status=”Pending”). Check to make sure that Payment Review is turned off in your seller settings on the PayPal website. In the PayPal Developer sandbox, this setting can be found to the right of your account listed on the Test Accounts page.
Once you’ve managed to get this to work, you may want to test all the various possible situations in the Magento end:
- Your customer checks out without registering as a member.
- Your customer is logged in as a member.
And the various ways to make a payment with Paypal:
- Your customer logs into the fake Paypal account and makes the payment from the balance.
- Your customer makes the payment using a credit card without creating or logging in to a Paypal account.
If you are having problems with Grand Totals or Total Paid showing as double or Orders are showing as Complete instead of Processing try the fix shown here