PayPal with Ruby on Rails - Everything You Need to Know about Benefits, Integration and Possible Solutions

Photo of Michał Olejniczak

Michał Olejniczak

Updated Feb 27, 2024 • 24 min read
StockSnap_EMMNK1Y3VH.jpg

PayPal is the most popular online payment processor globally, covering 75 percent of the market.

It operates in more than 200 countries and has 210-million active accounts. For many customers, it is the preferred and very often the only payment method they use when buying online. It’s safe and relatively easy to implement. It has some downsides, though. Thus, before setting up your account, you should weigh all the pros and cons.

How Does PayPal Work?

It’s best to think about PayPal as a payment solution provider. If you sell goods or services online, PayPal allows you to accept online payments and offers a wide range of services to help you with your business.

PayPal sets you up with a business account where you collect payments and withdraw money from your bank account. In its core, PayPal is responsible for online payment processing. It manages payments from clients paying with PayPal as a payment method. It also handles transactions from credit and debit cards, standing in as a middleman between your business and the customer’s credit card company.

PayPal acts as the so-called payment aggregator. It pools the business accounts of many customers into one, therefore, balancing the risk and allowing you to start instantly without the burden of additional financial scrutiny.

What PayPal Has to Offer

PayPal Express Checkout

PayPal Express Checkout is a solution for those who have a payment solution already in place and just want to add PayPal as a payment method to support the large base of customers paying through Paypal. You add a PayPal payment button to your site, handling the Paypal payment process. Paypal provides you with a code sample that can start you off right away but is flexible and can be configured either on the frontend or backend.

The customer doesn’t leave your site. A pop up appears where the user just needs to log in to his/her account and accept the payment. The solution integrates with all the popular checkout/shopping cart solutions out there. The cost is a percentage of the amount plus a flat fee per transaction with no monthly payments.

PayPal Payments Standard

PayPal Payments Standard allows you to accept debit cards, credit cards and Paypal payments. It is a choice for merchants who do not have a payment solution implemented in their app. Customers are routed to PayPal’s site to enter their payment information before finishing the transaction. The cost is the same as in Express Checkout.

PayPal Payments Pro

PayPal Payments Pro enables direct payments by debit and credit cards. You can handle the entire checkout process on your site, design it as you want to, with no need to redirect customers to the PayPal’s site. If you plan to receive some orders over the phone, it also allows you to use the Virtual Terminal, a feature to submit user orders yourself. Transaction costs are the same as in the plans mentioned above, but there is an additional monthly fee of $30.

Recurring Payments

Recurring payments are definitely a solution that many online enterprises require nowadays. For example, if you want to add subscription payments to your online service, PayPal also has you covered. However, you need to have either PayPal Payments Pro or Virtual Terminal in place. It will also cost you an additional $10 per month.

Benefits of PayPal

Brand Recognition

PayPal is the most popular payment processor in the world. It’s a trusted brand that has been on the market for a long time.

Market Scope

Operating in 200+ countries, Paypal is the most widely used online payment processor globally. If you plan to operate in a country that is not served by Braintree, Stripe or other online payment providers, or you want to expand to more markets, it’s probably your best choice.

Customer Base

210 million active accounts, according to Paypal, is a user base not to be overlooked. That base also accounts for clients using solely PayPal as a payment method. Not offering their preferred solution means that you may be losing on an opportunity to serve a big part of your market.

Safety

Compliance with the rules and legal obligations make PayPal a trusted partner for your business. Using PayPal as a payment solution provider helps you with the burden of making your business PCI compliant. With products such as PayPal Express Checkout, you may be subject to less severe yearly assessments.

Transparent Payment Terms

You pay 2.9% + $0.30 for every transaction, which is close to the average for the biggest online payment processors but still gives you a clear cost overview without any hidden fees. It is worth noting that additional features, such as PayPal Payments Pro or Recurring Payments, come with a price tag. If you’re a shop selling items with an average value below $10, PayPal can offer you an attractive 5% + $0.05 commission.

Broad Solution Portfolio

There is a large number of additional features that PayPal provides, such as online invoicing or the virtual terminal - both of which you can tailor to your needs.

Easy Setup

By being a payment aggregator and supporting multiple development platforms, Paypal allows you to start accepting payments in no time.

Downsides of PayPal

Not That Suited for Developers

Stripe, for example, is much more flexible in terms of development and customisation. It was built mostly for developers. By comparison, as mentioned in the section about implementation, PayPal could give you a hard time at first because of its modest documentation and inadequate developer kit maintenance.

Risk of Freezing Your Accounts

As with all payment aggregators, weak financial verification on setting up your account comes at a cost. There is always a risk that funds on your account will be frozen if PayPal considers your transactions as unusual.

Credit Card Data Portability

Having to switch to another payment solution provider in the future may be an issue if you will have restrictions on migrating the credit card data of your clients. That’s a big problem with PayPal which does not support credit card data portability comparing to Stripe which lets you export the data and helps you along the way.

Relatively High Cost

Looking at the additional $10 a month on recurring services on top of a $30 monthly payment for PayPal Payments Pro, one might wonder if it could be a little bit cheaper - especially that Stripe does not charge you anything for similar features.

Is PayPal a Good Solution for Startups?

If something makes PayPal attractive for startups, it’s PayPal’s client base and reach - pure and simple. Opening your startup to the large base of people paying through Paypal certainly gives you a good reason to look into PayPal as a payment solution provider.

Implementing PayPal in Ruby on Rails

Different Gems for Different Solutions

To ease the implementation of PayPal payment solutions in Rails, PayPal provides developers with its official core library for Ruby. The core development kit is composed of a set of gems responsible for incorporating different payment features into your application.

In order to create and process PayPal payments, developers will need the PayPal-Ruby-SDK gem. This tool can be used if you’ve settled for the PayPal Payments Standard and want to accept PayPal payments and credit card payments by redirecting users to the PayPal’s site.

The development of direct credit or debit card payments and recurring payments is handled in the Merchant-SDK-Ruby gem. Unfortunately, Rails 4+ is not supported, and the library is not in a rapid development - to say the least. That’s a pity as the gem covers a lot of PayPal’s key functionalities.

Alternative Solutions for PayPal Payments Pro Implementation

To manage recurring payments or direct credit payments, PayPal offers a set of APIs. Using a direct approach and developing a solution to communicate between your app and PayPal’s API is always a viable alternative.

ActiveMerchant gem is another possible option. It is a simple interface that allows developers to access many payment gateway APIs and can be used in Ruby on Rails web applications. In the readme and wiki page of the library, you can find out what features of PayPal Express Checkout and Paypal Payments Pro are supported. It is maintained by Shopify and Spreedly teams with over 400 contributes, which makes it a stable and reliable solution.

The last noteworthy alternative is Braintree, a company acquired by PayPal in 2013. The service is promoted as a complementary offering to PayPal standard features. It is also mentioned in PayPal’s API documentation as the favoured solution for accepting credit card payments. There is much more to Braintree than credit card payments, and using this provider with web applications is a topic out of the scope of this article but you should definitely consider it when thinking about payment solutions for your business.

Digging Deeper into Paypal-Ruby-SDK

At the first sight, the Paypal-Ruby-SDK gems readme looks limited. The examples in the readme will give an overview on how to implement basic payment management in Ruby: creating, executing and retrieving payments. The installation and configuration is straightforward. The readme section will provide developers with everything they need to get things started in Rails. PayPal’s API documentation will help them along the way. Before starting to code, developers will need to create a PayPal developer account. From there, they will be able to create and retrieve credentials for the live and sandbox accounts. In the readme of the gem, there is also a sample directory that contains far more examples of particular feature implementations. You can find there information on how to create PayPal invoices, manage notifications or handle payouts.

Thoughts on Implementing PayPal Payments in Rails

Implementing basic PayPal payments in Ruby is not that complicated but considering the modest library documentation, it’s easy to experience some bumps in the road. Additionally, to adapt the implementation to Rails, some code structuring is needed. However, an experienced developer should not have a problem with this.

Payment Testing - Why Is It Important and How It’s Done in PayPal

The Sandbox

Before going live with your payment solution, you will probably want to test the implementation. In order to do that, you need an appropriate environment setup that imitates the real-life interaction between our application and PayPal but uses the test data. PayPal provides this through the PayPal Sandbox.

Steps

PayPal automatically creates your first personal sandbox account when you sign up for a developer account. The Sandbox Testing Guide gives you an in-depth walkthrough of the process, but it is important to keep in mind several things when testing with Paypal.

You will need to have a sandbox account for each entity represented in a particular transaction. In the case of a simple payment solution, you will need to be set up with a buyer account representing the buyer and a facilitator account - a business account representing the seller. The facilitator account will be used as your account in the the testing environment when testing payments. By replacing respective credentials with the ones provided in the sandbox section of your application, payment will be ready for testing. Any request sent to PayPal will be handled in the sandbox business account. The sandbox buyer account will allow you to log in as a prospective user and make a payment.

Monitoring Test Data

On the sandbox account page, you will be able to log into the particular accounts and track transaction exactly as you would do on live accounts.

Other

Some features are not possible to test in the sandbox environment, e.g. issuing monthly statements and storing shipping preferences. Developers may also find some problems during testing. For instance, credit card payment testing may be troublesome as fake card numbers used for testing are not easy to find in PayPal’s documentation. However, sites that generate test credit card numbers should help in that case. It also takes some effort to align the configuration of the sandbox environment with the live one, which is essential to fully simulate the real-life experience.

How to Choose the Right Payment Processor?

Choosing the right technology for receiving payments in your store or SaaS platform might require an in-depth research on options that are available on the market. First thing you should do is sketch your needs along with the specifications of your business. How many payments do you plan to receive? What’s the value of an average transaction? What’s your technical experience? Do you need recurring payments? And what markets do you want to address? Answering these questions will help you make the right choice on a payment provider.

If you still hesitate, we can help you pick the best fit for your needs. Drop us a message and get the details.

Tags

Photo of Michał Olejniczak

More posts by this author

Michał Olejniczak

Michał is fascinated by the elegance of Ruby language. After graduating IT Technology in Poznań, he...

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by: