How To Test WordPress Plugins With PayPal Sandbox

How To Test WordPress Plugins With PayPal Sandbox

Virtually all WordPress plugins that collect payments, from e-commerce stores to fundraising, offer integration with a PayPal product.

Testing this integration prior to launch means setting up the PayPal Sandbox and this, like PayPal itself, can be a little confusing.

In this article, we’ll look at how to create a PayPal sandbox environment and where to find the data that the majority of PayPal supporting WordPress plugins ask for.

Image consisting of the WordPress and PayPal logos
Finding the right settings for testing plugins with the PayPal Sandbox can be confusing

The PayPal ecosystem consists of 3 environments:

  1. Live PayPal – this where real money changes hands
  2. Sandbox – provides a replica live environment for testing but without funds exchange and without live data (only sandbox accounts and transactions exist in this environment)
  3. Developer portal – provides management of sandbox accounts and access to testing features such as the Instant Payment Notification simulator

In order to test a plugin with PayPal, you need to:

  1. Create an account on the PayPal Developer Portal
  2. Create the necessary Sandbox accounts in the Developer Portal
  3. Configure your plugin to use the Sandbox environment

It is important to remember that Sandbox data and live PayPal data are completely separate. You cannot use a live PayPal account for testing a plugin configured to use the Sandbox PayPal gateway and you cannot use a Sandbox account if your plugin is configured to use the live gateway.

The unfortunate upshot of this is that whilst you can certainly test your plugin, you will have to reconfigure it after testing to point to the live PayPal environment, so you will have to test it again with a live account just to be sure that it has been configured correctly.

Step 1 : Create A Developer Account

Go to the PayPal Developer Portal and either log in (if you have an existing PayPal account then you can use these credentials) or register a new account.

Step 2 : Create Test User Accounts

To view your existing accounts, or create new ones, click on Applications and then on Sandbox accounts.

Screenshot of the Sandbox accounts screen in the the PayPal Developer Portal
The Business account is automatically created for you.

You’ll find that it has already created a Business PayPal account for you. This is your Sandbox merchant account and is will be the account that provides all the configuration details for the plugin and where you’ll see all your test transaction details.

When you test your plugin, you’ll want to use a test user account for testing making purchases. To create a new account, click on the New Account button and complete the details in the form.

Screenshot of the create new account form
Create as many test accounts with as many variations as you need

As you can see, you can set up the account with a range of features, including the type of credit card. How many accounts you set up will depend on how many variations you feel you need to test.

A good rule of thumb is that too much testing is barely enough.

Step 3 : Configure Your Plugin To Use The Sandbox Environment

This is where it can get a little confusing as the configuration requirements depend on how the plugin you are testing integrates with PayPal.

Generally, though, the plugin settings page will contain some combination of the following:

PayPal Mode

Screengrab of the PayPal Mode Settings
Use Sandbox mode for testing

Most plugins that support a PayPal gateway will allow you to select whether you want to operate in Live or Sandbox mode. Obviously, for testing you want to select Sandbox.

PayPal Email Address

If the plugin is using PayPal Simple Payment then it will ask for an email address. You need to enter the email address of the Sandbox business account that was automatically set up for you when you logged into the developer portal.

You can see this email when you go to Applications > Sandbox accounts.

PayPal Merchant Account ID

This field is usually requested when the plugin is using the Payments Standard gateway and requires the Merchant ID for the Sandbox business account.

Unfortunately, this data is not available in the Developer Portal, so you’ll need to log into the PayPal Sandbox site using the Sandbox business account credentials.

The Sandbox site can be confusing as it will show you logged in at the top of the page but you still need to log in with the Sandbox business account to get to the information.

Once logged in, click on Profile > My Business Info.

As you can see, there’s a range of data there, all of it fake but all of it updateable. The Merchant account ID is nearer the bottom of the list.

Screenshot of the test account data
The test account profile contains essential data. Change the name whilst you are here.

While you are here you might want to change the name of the account (to your business name) so that the PayPal payment screens look a bit more realistic.

PayPal Site

This is actually quite important. Ensure that the country selected is the same as the country in the business account address.

PayPal API Credentials

If your plugin uses the PayPal API to access the PayPal gateway then it will ask for an username, a password and a signature.

These details can be found back in the Developer Portal:

  1. Go to Applications > Sandbox accounts
  2. Click on the arrow next to the business account and then on profile
  3. Click on API Credentials
Screenshot of the API credentials
All the details for testing “classic” API calls to PayPal

Simply cut and paste the details into the plugin configuration form.

Ready For Testing

It’s a good idea, even with a premium plugin, to test as many scenarios as you can prior to launching especially when there is a payment process involved. Hopefully, this post will have covered how to access all the data you need to enable you test the PayPal integration with your plugin.

And, of course, when you’ve done testing, don’t forget to reconfigure your plugin to use the live PayPal environment.