Paypal Express Checkout is a great way to add or extend the checkout capabilities of an e-commerce store. Most e-commerce software bundles have support for this baked in, but when you’re working with a custom-built shopping cart and have to roll your own Express Checkout integration it can be a real bear. The PayPal developer documentation is fragmented and often contradictory, and it’s never entirely clear about what steps are required to setup a developer account. They also often refer to their services using different names. And their support system is slow and cumbersome.

Because of this, when I recently worked on an Express Checkout integration for a Panoptic Development client, it took us a lot longer than we expected. A lot of that additional time came from trying to workout a proper integration test suite that would exercise our custom integration points without actually needing to hit the PayPal servers with valid requests every time. It took a lot of trial and error, but in the end I was able to get these tests working by mocking some service calls and stubbing out methods from the PayPal SDK libraries we were using.

For anyone stuck in the same spot, I documented my efforts at StackOverflow: “How to configure integration test for PayPal Express Checkout using TestUnit in a Rails 2.3 app“. My current set of tests differ slightly from what is show there and I ended up refactoring quite a bit as I added new tests, but that question and answer should be a good starting point.

UPDATE

I’ve posted a gist of all of the moving parts of my current implementation of this:

Integration tests for PayPal Express Checkout using TestUnit in Rails 2.3