Spree Commerce

Try It Now

PayPal Express Extension

Posted on July 29, 2013 by Ryan Bigg

We’ve noticed recently that a lot of people have been wanting to use Spree and PayPal Express Checkout together and that those people have been coming against problems when they attempt to do so with the more recent versions of Spree.

Over the years, the codebase for this extension has grown and grown and grown, and as a consequence has gotten extremely messy. When we attempt to fix an issue in this codebase, it’s confusing and there’s no testing “safety net” in place to make sure that our changes are a) correct and b) not going to break anything else. In addition to this, our experience with PayPal itself has been… less than fun. APIs behaving differently between testing and live, situations where transactions would work in one instance and not another and so on. Hence we’ve been reluctant to do any work on this extension for fear of further issues.

It’s really a terrible thing to have an officially supported extension for such a major part of shopping carts on the web and have that officially supported extension not work. When it doesn’t work, people get upset, and when people get upset, we get upset.

So to put an end to this upset-ness, we’re working on a new and improved Spree PayPal Express extension aptly called “better_spree_paypal_express”. This extension does a couple of things differently.

Firstly, it doesn’t hack the CheckoutController class to make things work. Instead, there is a completely separate controller within the extension called PaypalController which deals with interacting with PayPal. The CheckoutController is left to its own devices.

Secondly, it uses PayPal’s own Merchant SDK library, rather than Active Merchant’s own code. This way, we can be sure that whatever happens to PayPal’s API, they’ll hopefully update this gem and we don’t have to wait for a patch to land in Active Merchant.

With just these two minor differences, the amount of code in the extension has been cut down and it’s extremely easy to test walking through a Spree checkout with it. Because the code’s cleaner, the barrier to entry is much lower in order for people to be able to figure out what’s going on within the extension. If there’s a problem with the extension, then submitting a patch should be fairly easy.

We’re currently looking for people to give the extension a try in place of the current `spree_paypal_express` extension. If you’re looking for PayPal Express Checkout support with Spree, please try out this extension. If you find any problems with this extension, please report them on the repo’s issue page.