This website uses cookies to better the user experience of its visitors. Where applicable, this website uses a cookie control system, allowing users to allow or disallow the use of cookies on their computer/device on their first visit to the website. This complies with recent legislative requirements for websites to obtain explicit consent from users before leaving behind or reading files such as cookies on a user’s computer/device. To learn more click Cookie Policy.

Privacy preference center

Cookies are small files saved to a user’s computer/device hard drive that track, save, and store information about the user’s interactions and website use. They allow a website, through its server, to provide users with a tailored experience within the site. Users are advised to take necessary steps within their web browser security settings to block all cookies from this website and its external serving vendors if they wish to deny the use and saving of cookies from this website to their computer’s/device’s hard drive. To learn more click Cookie Policy.

Manage consent preferences

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Cookies list
Name _rg_session
Provider rubygarage.org
Retention period 2 days
Type First party
Category Necessary
Description The website session cookie is set by the server to maintain the user's session state across different pages of the website. This cookie is essential for functionalities such as login persistence, ensuring a seamless and consistent user experience. The session cookie does not store personal data and is typically deleted when the browser is closed, enhancing privacy and security.
Name m
Provider m.stripe.com
Retention period 1 year 1 month
Type Third party
Category Necessary
Description The m cookie is set by Stripe and is used to help assess the risk associated with attempted transactions on the website. This cookie plays a critical role in fraud detection by identifying and analyzing patterns of behavior to distinguish between legitimate users and potentially fraudulent activity. It enhances the security of online transactions, ensuring that only authorized payments are processed while minimizing the risk of fraud.
Name __cf_bm
Provider .pipedrive.com
Retention period 1 hour
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to support Cloudflare Bot Management. This cookie helps to identify and filter requests from bots, enhancing the security and performance of the website. By distinguishing between legitimate users and automated traffic, it ensures that the site remains protected from malicious bots and potential attacks. This functionality is crucial for maintaining the integrity and reliability of the site's operations.
Name _GRECAPTCHA
Provider .recaptcha.net
Retention period 6 months
Type Third party
Category Necessary
Description The _GRECAPTCHA cookie is set by Google reCAPTCHA to ensure that interactions with the website are from legitimate human users and not automated bots. This cookie helps protect forms, login pages, and other interactive elements from spam and abuse by analyzing user behavior. It is essential for the proper functioning of reCAPTCHA, providing a critical layer of security to maintain the integrity and reliability of the site's interactive features.
Name __cf_bm
Provider .calendly.com
Retention period 30 minutes
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to distinguish between humans and bots. This cookie is beneficial for the website as it helps in making valid reports on the use of the website. By identifying and managing automated traffic, it ensures that analytics and performance metrics accurately reflect human user interactions, thereby enhancing site security and performance.
Name __cfruid
Provider .calendly.com
Retention period During session
Type Third party
Category Necessary
Description The __cfruid cookie is associated with websites using Cloudflare services. This cookie is used to identify trusted web traffic and enhance security. It helps Cloudflare manage and filter legitimate traffic from potentially harmful requests, thereby protecting the website from malicious activities such as DDoS attacks and ensuring reliable performance for genuine users.
Name OptanonConsent
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonConsent cookie determines whether the visitor has accepted the cookie consent box, ensuring that the consent box will not be presented again upon re-entry to the site. This cookie helps maintain the user's consent preferences and compliance with privacy regulations by storing information about the categories of cookies the user has consented to and preventing unnecessary repetition of consent requests.
Name OptanonAlertBoxClosed
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonAlertBoxClosed cookie is set after visitors have seen a cookie information notice and, in some cases, only when they actively close the notice. It ensures that the cookie consent message is not shown again to the user, enhancing the user experience by preventing repetitive notifications. This cookie helps manage user preferences and ensures compliance with privacy regulations by recording when the notice has been acknowledged.
Name referrer_user_id
Provider .calendly.com
Retention period 14 days
Type Third party
Category Necessary
Description The referrer_user_id cookie is set by Calendly to support the booking functionality on the website. This cookie helps track the source of referrals to the booking page, enabling Calendly to attribute bookings accurately and enhance the user experience by streamlining the scheduling process. It assists in managing user sessions and preferences during the booking workflow, ensuring efficient and reliable operation.
Name _calendly_session
Provider .calendly.com
Retention period 21 days
Type Third party
Category Necessary
Description The _calendly_session cookie is set by Calendly, a meeting scheduling tool, to enable the meeting scheduler to function within the website. This cookie facilitates the scheduling process by maintaining session information, allowing visitors to book meetings and add events to their calendars seamlessly. It ensures that the scheduling workflow operates smoothly, providing a consistent and reliable user experience.
Name _gat_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _gat_UA-* cookie is a pattern type cookie set by Google Analytics, where the pattern element in the name contains the unique identity number of the Google Analytics account or website it relates to. This cookie is a variation of the _gat cookie and is used to throttle the request rate, limiting the amount of data collected by Google Analytics on high traffic websites. It helps manage the volume of data recorded, ensuring efficient performance and accurate analytics reporting.
Name _ga
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga cookie is set by Google Analytics to calculate visitor, session, and campaign data for the site's analytics reports. It helps track how users interact with the website, providing insights into site usage and performance.
Name _ga_*
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga_* cookie is set by Google Analytics to store and count page views on the website. This cookie helps track the number of visits and interactions with the website, providing valuable data for performance and user behavior analysis. It belongs to the analytics category and plays a crucial role in generating detailed usage reports for site optimization.
Name _gid
Provider rubygarage.org
Retention period 1 day
Type First party
Category Analytics
Description The _gid cookie is set by Google Analytics to store information about how visitors use a website and to create an analytics report on the website's performance. This cookie collects data on visitor behavior, including pages visited, duration of the visit, and interactions with the website, helping site owners understand and improve user experience. It is part of the analytics category and typically expires after 24 hours.
Name _dc_gtm_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _dc_gtm_UA-* cookie is set by Google Analytics to help load the Google Analytics script tag via Google Tag Manager. This cookie facilitates the efficient loading of analytics tools, ensuring that data on user behavior and website performance is accurately collected and reported. It is categorized under analytics and assists in the seamless integration and functioning of Google Analytics on the website.

How to Integrate PayPal Express into Spree Commerce

  • 14903 views
  • 5 minutes
Kirill S.

Kirill S.

Ruby/JS Developer

Sviatoslav A.

Sviatoslav A.

Copywriter

Share

In this article we’re going to show you how to integrate the PayPal Express Checkout payment gateway into an ecommerce project, using the example of Medshop Express. Medshop is an online store built on the Spree content management system (CMS).

The Spree CMS has many pre-installed plugins for payment gateways. However, Spree’s standard PayPal gateway is restricted to credit card payments only. That is, the option for direct payments from a user's PayPal account is unavailable in the default PayPal gateway. We had to add the PayPal Express Checkout extension to our project to facilitate all types of payments via PayPal on Medshop.

Before you integrate PayPal Express into Spree, you first need a PayPal Sandbox account. To create your own PayPal Sandbox account, follow this tutorial – Creating Sandbox Test Accounts. You'll need to use this account for testing purposes. Don’t forget to create several test profiles, including a buyer account. For our project, we used version 4.2.7 of the Ruby on Rails framework. We also run our project on one of the latest versions of Spree: 3-0-stable.

PayPal Express Checkout uses the Merchant Ruby Software Development Kit, which we expected be deprecated soon. But the message about its deprecation was removed recently from GitHub. This is great news, as you can now feel free to install PayPal Express in Rails!

Now let's move on to the PayPal Express Checkout integration with Spree!

Step 1. Install the Spree PayPal Express Gem

Since Spree’s developers recommend that we use the better_spree_paypal_express library for our PayPal gateway, we should go ahead and install it. Open the Gemfile for your project and enter the following line of code:

Note that the branch is 3-0-stable in our project. But if you have Spree 2.4.10 or 3.1.0, then type the appropriate version number for your setup.

There are also two commands that you have to run in order to install the better_spree_paypal_express gem.

This command will download and install all better_spree_paypal_express files necessary for our Spree project.

The next command will run necessary migrations:

Once this step is also completed, just restart the server.

The first step in integrating PayPal Express Checkout into Spree is completed!

Step 2. Set up PayPal Express in the Spree Admin Panel

Now you need to log in to the Spree admin panel. If your Spree admin panel shows the navigation panel in full, find the CONFIGURATIONS button. Click on it to open the menu and select Payment Methods. If this panel is collapsed, hover over the wrench icon and select Payment Methods from the pop-up window.

Spree admin panel

You are now on the Payment Methods tab, so click on the button + New Payment Method, which is located in the top-right corner of the admin panel.

First, choose an appropriate provider from the list. Note that Spree has a standard Spree::Gateway::PayPalGateway provider, but this isn't the one we need to add. Choose the Spree::Gateway::PayPalExpress provider instead.

Add PayPal Express Checkout payment method in Spree

Now, you need to edit the payment method for PayPal. First, log in to your Developer PayPal account and go to Account Details. There, open the API Credentials tab and just copy-paste your Username, Password, and Signature details from PayPal into the first three fields under the PROVIDER field in the Spree admin panel. Note that the PayPal API credentials for Username should be entered in the LOGIN field in the Spree admin panel.

Add a payment method name, which will be shown to your customers. As you can see, we simply entered PayPal. You can enter any name you want. It's recommended, however, to keep it short. The payment method description is optional.

Edit PayPal Express  in Spree

Since we use our sandbox account for testing purposes, the SERVER field should be set to Sandbox. But when you're ready to test PayPal Express Checkout for production, change this field to LIVE.

If you have a logo for PayPal Express, enter the absolute URL into the field LOGOURL. You can also change the name for the payment method and add or delete the description.

There are other options to edit in this page.

Edit PayPal payment method in Spree

Check the Test Mode box if you are only testing the application. When you are working with the production version of Spree, then disable this mode. The DISPLAY property lets you decide whether the PayPal Express Checkout payment method is available for the user.

There is also an AUTO CAPTURE feature. By setting the AUTO CAPTURE feature to Yes or No, you can turn on or off automatic capturing for the current payment methods. In our project, we set AUTO CAPTURE to Yes for PayPal Express, which allows automatic withdrawal of funds from the client's credit card. The other two options are No and Default; if you choose No, then you will have to capture each payment manually in the Spree admin panel. When you need to override this function for PayPal Express, open the file with the subclasses for the payment methods and set the auto_capture? function to false:

At last, you can activate and deactivate the PayPal Express payment method in the "Editing Payment Method / PayPal" tab.

This is how we integrated the PayPal Express Checkout gateway into Spree. As you can see, the procedure is very simple, but you get valuable functionality in the end. Your website customers will definitely be pleased with the option to pay directly from their PayPal accounts.

CONTENTS

Authors:

Kirill S.

Kirill S.

Ruby/JS Developer

Sviatoslav A.

Sviatoslav A.

Copywriter

Be the first user to rate this article!

Nay
So-so
Not bad
Good
Wow
0 rating, average 0 out of 5

Share article with

Comments (0)

There are no comments yet

Leave a comment

Subscribe via email and know it all first!