Integrate PayPal Payment Gateway

This guide will show you how to create an integration with PayPal and OptimizeCheckouts.  The guide is broken down into two parts - creating the integration and testing the integration.

Below we'll show you how to setup and test using the PayPal Sandbox.
If you need to connect PayPal in live mode just click here

Setting up & Testing the PayPal Sandbox for testing: 

(Part 1) Create & Integrate PayPal App

In the first stage of this process, we will create a PayPal App and link this to your OptimizeCheckouts site to ensure that payments.

Creating the app

In order to start testing OP Checkouts with PayPal you need to create a sandbox account. You can create one by following instructions on PayPal developer’s site.

You can create a sandbox account using your personal PayPal account. No need for business accounts when testing.

Once the sandbox account is created, as well as merchant and buyer accounts and their credentials, you have to create a sandbox application which will be connected with your OP Checkouts site. 

When creating the sandbox app, make sure that its “type” is set to “Merchant”.

After creating the app click on its name to view the details. Here you’ll need to copy client ID, and secret. These are the credentials required by OP Checkouts in order to be able to create products, plans and make orders (one time fee purchases) and subscriptions.

Copy client ID and secret and paste them in your OP Checkouts / Settings / Payment Gateways screen ( http://example.com/wp-admin/admin.php?page=op-checkouts-settings). 

Below the “Save” button you’ll see a Sandbox URL which needs to be copied. On the bottom of the PayPal app details screen, there is a section for webhooks. You need to create one and set the aforementioned copied Sandbox URL and select “All events”.

Adding the webhook

Once you have connected your Paypal sandbox account/live account, you will need to add a webhook that will tell PayPal to notify your site when some event occurs (like subscription approved, or cancels, or order is refunded). Without setting the webhook, your site will not work properly.

To do this, copy your webhook URL from below the fields where you entered your client id and secret.

Go to the Paypal Developer applications screen - and click on your app under the REST API apps.

On the next screen, scroll to the bottom and you'll find a section called "Sandbox Webhooks" for sandbox apps and "Live Webhooks" for Live apps.

Click "Add Webhook" and on the next screen paste your webhook from OptimizeCheckouts into the Webhook URL field. Select "All events" and scroll down to save.

(Part 2) Testing Your Integration

In this part of the guide we will show you how to test your integration with OptimizeCheckouts and Paypal

Setting up Your Sandbox Testing Accounts

PayPal should automatically create personal and business sandbox accounts you can use for testing.  

You can access these by clicking on "Accounts" on the left side menu when inside the Sandbox developer dashboard - or go here.

You can get the credentials for these accounts by clicking on the 3 dots and then click view/edit account.

Save the Business and Personal credentials to a doc as you'll need these in a moment...

Before testing purchases make sure that your sandbox account can accept multiple currencies and that you’ve added all currencies that you are planning to use. If you do not do this, then some transactions (subscription) will be left in pending mode until you’ve approved it.

Log in to https://www.sandbox.paypal.com/businessmanage/preferences/payments with the sandbox Business account (the one selected when creating the app) and make sure to "Allow payments sent to me in the currency I do not hold" to one of the "Yes" options.

On the page https://www.sandbox.paypal.com/businessmanage/account/money you can add additional currencies which you plan to use.

If you have trouble logging into your sandbox account - check generated accounts here and edit merchant one and check (or change) the password.

Enabling PayPal integration per product

Go to your product settings page and select “Payment Gateways”. There, enable PayPal integration. By default, each product will have it disabled.

Setting Up PayPal Live Mode:

Once you have tested your checkout forms in Paypal Sandbox mode with everything working, then you are ready to connect the PayPal Live account to your site. 

First, go to this URL: https://developer.paypal.com/developer/applications/

Click on "Live"

Then click "Create App"

Create a name for your app (note: you can not use "paypal" in the app name), and then click "Create App" button:

On the next screen you'll be able to copy your Client and Secret keys which you can then paste into the PayPal settings under "Checkouts > Settings > Payment Gateways > PayPal > PayPal Live"

Before you click the save button, copy the "Live Webhook URL" and then go back to the PayPal screen and scroll down past the API keys. You'll need to use that URL to create a new webhook: 

Now add the webhook URL here after clicking "Add Webhook"
Make sure to check the box "All Events" below the Webhook URL field.

Then scroll down and click the save button:

Now you can go back to your WordPress site admin > Checkouts PayPal screen and click the "Save" button.

Next, just make sure you change your Product to "live" modes here: 

Now you can take payments LIVE with PayPal.

If you need further guidance on using PayPal or run into any issues setting things up, please reach out to our team and we'll be glad to help.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.