Setting up PayPal standard payments with IPN for Magento

Update @ 2010/08/27

Seems like the PayPal IPN url has changed in 1.4. The url is now in http://www.yourstore.com/paypal/ipn/standard/
For more information, please see this thread. Thanks to chrisandy for pointing this out!

—–

On a project I’m doing with a good friend, Sebastian Kraaijenzank. We’re setting up a Magento Commerce shop. The shop was coming along quite nice and we started adding products. In Denmark, you have to get your webshop approved before starting accepting payments via credit cards. This was a problem for us. First of all, this process can take months, if you’re unlucky. We decided to start out with PayPal payments. Here’s how to get started.

Okay, we’re going to set up a couple of things to get started. Both in Magento admin panel and PayPal.

  1. Setting up Magento
  2. Setting up PayPal
  3. Known problems and fix

Let’s get started!

1. Setting up Magento

First thing we gotta do is setup PayPal Standard.

Go to System -> Configuration -> PayPal Accounts

The field “Business 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.

The field “Business Account”. Type in the e-mail. you use to sign in with, on your PayPal Business account.

Optional: Set the “Sandbox flag” to “True”, if you’re testing this in sandbox mode.

Next up, go to: System -> Configuration –> Payment Methods –> PayPal Standard

Start out by enabling the payment method; set “Enabled” to “Yes”.

Now if you want PayPal to capture the money when to order is placed, choose “Sale” for “Payment Action”. If you want to control when the money is actually captured, set it to “Authorization”. This will only validate the credit card and let you decide when the money will be captured. We choose this option, because you’re only allowed to capture the money when the order is sent by mail.
Note: you will need to log in to your PayPal account in order to actually capture the money. But Magento will automatically be notified.

Select an option for “New order state”. It’s totally your call.

The “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.

That was about it for Magento. Let’s have a look at your PayPal account.

2. Setting up PayPal

First, we need to enable IPN (Instant Payment Notifications). In order to do this, log in to your PayPal account and choose My Account -> Profile ->Instant Payment Notification Preferences

Click the “Edit IPN Settings” button and put in this url in the field:

  • http://www.your-magento-shop-url.com/paypal/standard/ipn/
  • http://www.your-magento-shop-url.com/paypal/ipn/standard/
    Please see the update on top of this page

And of course, you need to enable the feature.

You might also want your customers to be automatically redirected to your shop, when they have completed the payment. To do this, go to Website Payments in My Account -> Profile. Check the “On” button and put in this URL in the field:

  • http://www.your-magento-shop-url.com/paypal/standard/success/

That’s about everything. Your shop is now PayPal ready. However, you might experiencing some problems regarding double Grand Totals and Total Paid, or the order show as Completed instead of the selected value. Read on!

3. Known problems and fix

As mentioned above, some might be having problems with double Grand Totals and Total Paid, or the order show as Completed instead of the selected value. If that is the case you need to modify a core file. It’s a bug; yaiks!

Open the file:

  • /app/code/core/Mage/Paypal/Model/Standard.php

On line 149 you should see the following:

  • return false;

Change this to

  • return true;

On line 423, edit this line:

  • Mage_Sales_Model_Order::STATE_COMPLETED, true,

Instead, it should be:

  • Mage_Sales_Model_Order::STATE_PROCESSING, $newOrderStatus,

Done!

Yep, it’s true! You’re actually finished! If you got any problems or questions, feel free to comment!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • MySpace

6 Comments to “Setting up PayPal standard payments with IPN for Magento”

  1. online clothes shop 18 February 2010 at 4:47 am #

    I been looking for a fix for that..Thanks man!!

  2. molecule 15 April 2010 at 6:59 am #

    Thanks for this Mark, I’ve been trying to fix that for months!

  3. borde stole møbler 21 June 2010 at 5:29 pm #

    Is it posible to get the paypal standard window to open in Dainsh every time, i’m having a lot of problems with this.

  4. Mark Kordon 29 June 2010 at 9:03 am #

    Yes, it is possible via the lc/country parameter. I’m not sure how to do this in Magento, but it sure is possible by adding the lc parameter or the country parameter.

    Are you sure it’s not possible to change property in the PayPal admin interface?

  5. chrisandy 26 August 2010 at 6:13 pm #

    Great tips Mark – I was just wondering – have you come across any fixes for web payments standard in 1.4.1 of Magento – that system is completely broken in in that version? Customer details do not get sent to Paypal from Magento.

  6. Mark Kordon 27 August 2010 at 8:48 am #

    Hi. Please see this thread. Sounds like this is your problem. I’m updating my post! Thanks for the heads up!


Leave a Reply