How to Add PayPal to your Website

Remay Villaester (May)
30.09.20
8 minute read

If you’re running a business, you’ll likely need to have an online platform for selling your goods: be that physical/digital products or some kind of services. Allowing your customers to browse and buy your goods online is essential for almost all businesses in the 21st century, since it’s a really powerful revenue channel and your clients will appreciate the convenience of being able to shop whenever and from wherever they want.

The easiest way to enable online purchases for your business is to use solutions known as payment gateways.

This article will guide you through the process of adding PayPal to your website and show you how you could save money on sales using TransferWise for Business.

What is a payment gateway?

In its simplest terms, payment gateway is a way to make and receive payments online. It’s a merchant service that is responsible for verifying the payment method, charging customers and transferring money between bank accounts.

There are many players to choose from in this industry: such as PayPal, Stripe, Adyen and many more - each providing their unique collection of features that would help you grow your business instead of worrying about how to handle transactions and money flow.

Why would you use a third party payment gateway?

Needless to say that developing, operating and maintaining that kind of service would take millions of dollars and years of effort. Smaller businesses, and especially startups, won’t have enough funds, time and manpower to pull it off. Which is why they should refer to a third party service that they could integrate into the system to start making and receiving payments almost hassle free!

Third party payment gateways could provide a variety of payment methods: from traditional credit cards to cryptocurrency - making the checkout experience as user-friendly as possible.

Apart from that, they provide a back office with strong analytical dashboards and means of generating reports, making payouts, doing cashbacks and many more!

Furthermore, they remove the hassle of being compliant to the policies and regulations of each region and country - they take care of things such as KYC, PCI, GDPR compliances, to name a few, and will store client information, transactions history in a secure way.

And should I mention that some of them are surprisingly easy to set up and could be up and running on your website in not only a matter of days, but hours! How crazy is that?

However, those services are not free. They are usually commission based, meaning that a payment gateway provider will take it’s cut from every transaction that your customers make. They’re usually within 3% of the amount + some fixed fee.

Meet PayPal

The competition is quite heated in the land of payment gateways, with lots of players offering all kinds of features, but there is one option that has been popular for over 20 years already, namely - PayPal. According to their website - PayPal is “The simpler, safer way to pay and get paid”.¹

PayPal has been the de facto standard in the industry for years and for a good reason: it’s feature-rich ecosystem that could support every business need, variety of payment methods, ease integration - all those points are making PayPal one of the strongest payment gateways there are, thus securing it’s position at the top of the industry. So we can rest assured that it’s not going away anytime soon.

Another thing that is very appealing about PayPal - is that it has an option of integrating the whole checkout process into your web sites. It just takes a couple of minutes of setup and your website will have the interface for the whole checkout process, without the need of developing it from scratch.

Paypal Commerce Platform

PayPal has a lot of products and solutions, but one of the most popular is its Commerce Platform.

PayPal Commerce Platform uses PayPal’s latest technologies, tools, services, financing and was designed for marketplaces and ecommerce solution providers.²

That platform is divided into three sub-platforms, each tailored for a particular business type:

  • PayPal Commerce platform for Business
  • PayPal Commerce platform for Marketplaces And Platforms
  • PayPal Commerce platform for Enterprise

In scope of this article, we’ll be touching some of the features of Commerce platform for Business

PayPal Commerce Platform for Business

According to PayPal’s documentation: “PayPal’s Commerce Platform for Business is a full-stack payment processing solution that helps you accept and make payments globally”.³

Speaking about that definition, what does “full-stack” mean in that context?

It simply means, that this platform provides a payment solution that covers the whole payment process - it provides the front end, which would be user interface for initiating payments, as well as back end which will be responsible for verifying client’s payment information, doing KYC, fraud checks and ultimately charging provided payment instrument and transferring money to your business account.

Commerce platform for Business supports two general types of operations:

  • Accept Payments
  • Make Payments

We’ll talk about accepting payments, namely: checkout

How to get started?

Before we start developing and testing our integration, we would need to create PayPal accounts, get API credentials and set up the sandbox account.

Step 1: Register PayPal accounts

For testing you would need to have two accounts - a buyer account and a merchant account

If you already have an account - you can skip this step

Otherwise, follow the link to create a PayPal account.

Step 2: Get API credentials

In order for your website to be able to communicate to PayPal’s API you need API credentials. They are Client ID and Secret key that will be used for authenticating the request from your account.

To obtain the credentials, follow these steps:

  1. Log in to PayPal Developer Dashboard with your account.
  2. Under the Dashboard menu, select My Apps & Credentials option.
  3. Go to the Sandbox tab to get credentials for testing the integration. After you test the integration out - switch to Live tab to get live credentials.
  4. Select Default Application under App Name column. This application should have been automatically created by PayPal when you registered your account. If you don’t see the default application - select Create App.

After following these steps, you should be at the Application page, which displays your API credentials: Client ID and Secret

Those credentials are used to get an access token from the API. The access token will be used to authorize you to use PayPal REST API server.

You can make this request by any means you’d like and in any programming language, but for simplicity of testing, let’s use cURL utility

However, If you are using Windows, you might not have cURL utility by default.
In that case either use different method (Postman/script/etc) or refer to this article on how to set it up for Windows.

curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token
-H "Accept: application/json"
-H "Accept-Language: en_US"
-u "CLIENT_ID:SECRET"
-d "grant_type=client_credentials"

Change placeholders CLIENT_ID and SECRET respectively to Client ID and Secret that you got from the Application page

If it was successful, PayPal will respond with status code 200 OK and will return some information, which will contain access_token and expires_in (number of seconds for which the token would be valid).

If Client ID or Secret are incorrect - the server will respond with 401 Unauthorized.

Server will respond with 401 Unauthorized in case your access token has expired. If that’s the case - you would need get a new token by authenticating again using your Client ID and Secret

Step 3: Get Sandbox account information

Sandbox accounts come in handy in testing your integration and making purchases and payments without affecting real money.

To get account information, do:

  1. Log in to PayPal Developer Dashboard with your account.
  2. Under Sandbox, select Accounts
  3. Find your sandbox account under Account Name
  4. Under Manage Accounts, select … (three dot) button for your personal account
  5. Press on View/Edit account. Here you can see your email ID and system-generated password
  6. Repeat same steps for your business account
  7. You can login to the Sandbox environment using these credentials

This sandbox environment portal would be the place where you could see all your transactions in the sandbox environment

Add PayPal checkout

Once you have created your account - you could start adding PayPal checkout to your website

Step 1: Add payment buttons

To easily accept payments on your website, add the PayPal JavaScript SDK code to the checkout page.

  1. Copy the code to your checkout HTML file.
  2. Replace with you Client ID,
  3. The code above will set the currency to USD. If you want to override or customise it or any other property, please refer to PayPal JavaScript SDK
  4. Refresh the page and voilà, you should see payment buttons

You can now start testing purchases.

Step 2: Test Purchases with PayPal buttons

We have a PayPal sandbox environment configured and PayPal buttons added on our website, so we can start testing purchases and check how money moves from one account to another.

Test as a buyer

  1. Press on PayPal button on your website
  2. Login using your personal sandbox account
  3. Complete a purchase with PayPal balance

Confirm that money left buyer account

  1. Log into Sandbox portal using your personal sandbox account
  2. In Recent Activity section, you should see that money left buyer’s account

Confirm that merchant received the money

  1. Log into Sandbox portal using your business sandbox account
  2. In the Recent Activity section, you should see that money was received (NB! You’ll see that you’ve received less than you send. It is because PayPal took it’s fees from the transaction)

Going Live

After you have tested the integration and feel confident enough to go live you’d need to:

  1. Change the URL for all API calls from https://api.sandbox.paypal.com to https://api.paypal.com
  2. Create live REST API app (refer to Step 2 of Getting Started section of the article)
  3. Change all Sandbox client id references in the website code to Live client id

Next steps

This is how you can add a simple integration with PayPal to your website.

For more information please refer to PayPal’s Developer Documentation

How to save money on your sales

If your business operates internationally, you’re most likely to deal with payments in different currencies and have to convert between currencies from time to time. This is where you could employ a partner for exchanging currencies. One very obvious detail that you need to consider when looking for a partner is the exchange rate. A lot of companies set their own exchange rates to cover the conversion cost and/or earn profit adding 2 - 4% fee on every transaction.

The good news is that there are services like TransferWise that offer real exchange rates with no mark-up for a small and transparent fee that is up to 14x cheaper than PayPal.

Here are some benefits you can take advantage of using TransferWise:

  1. Instant transfer to most currencies
  2. Batch Payment of up to 1000 recipients all at the real exchange rate perfect for paying suppliers and contractors abroad.
  3. Modernized and powerful API to help automate most financial transactions like payouts and accounts receivables.
  4. Multi-currency account that allows you to receive payments in EUR, USD, AUD, NZD, HUF and GBP for free.
  5. Multi-currency debit card for faster international payments with no exchange rate mark-up.
  6. Seamless integration with Quickbooks and Xero to ease tax reconciliation.

With these benefits, you could save 3 - 4% on conversion charges alone which means more profit for your business.

Start saving today with TransferWise

Sources:

  1. PayPal website
  2. PayPal Commerce Platform
  3. PayPal developer document

This publication is provided for general information purposes only and is not intended to cover every aspect of the topics with which it deals. It is not intended to amount to advice on which you should rely. You must obtain professional or specialist advice before taking, or refraining from, any action on the basis of the content in this publication. The information in this publication does not constitute legal, tax or other professional advice from TransferWise Limited or its affiliates. Prior results do not guarantee a similar outcome. We make no representations, warranties or guarantees, whether express or implied, that the content in the publication is accurate, complete or up to date.

TransferWise is the smart, new way to send money abroad.

Find out more

Tips, news and updates for your location