2 min. read
Categories: Technical
New Docs: Adding a payment gateway in Sylius

Adding a new payment gateway is one of the most common tasks when working with an eCommerce platform like Sylius. While our ecosystem already provides many payment integrations, including some of the most popular like PayPal and Stripe, there is plenty of local or niche gateways that need to be integrated. 

In order to make your life easier as a Sylius Developer, we have prepared a new Cookbook article: “How to integrate a Payment Gateway as a Plugin?” Kudos to our excellent Core Team Member Łukasz Chruściel, who prepared the new documentation. But let’s start with the basics.

Payments Architecture in Sylius

Sylius contains a component called “Payments”, which handles the data storage (like the history of payments, their statuses, amounts, etc.) and contains a thin layer for integrating the gateways.

The heavy lifting is currently done by Payum library, built by our friend Max Kotliar. Payum is PHP 7+ payment processing library. It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts, etc. It already provides a vast number of adapters that need a bit of glue to work with Sylius.

Plugin Development

Sometimes there is no ready adapter or you need to integrate one with Sylius. The best way to do this is to create a plugin. We provide a fantastic “PluginSkeleton” that you can just start from:

$ composer create-project sylius/plugin-skeleton SyliusMyGatewayPlugin

This command will create the whole boilerplate code that is the base of a plugin. From then you can start adding the code of the gateway. Did I mention that the skeleton includes the testing framework that allows you to run tests from inside of the plugin? No need to set up a separate “fake” project to do the testing. Thanks, Symfony!

If you are looking to build a plugin other than payment gateway, make sure to check out our Plugin Development Guide.

How to start?

Before you create your own payment plugin, please review the following lists and possibly re-use and improve an existing one. Zero waste!

In case you did not find a plugin you are looking for, then follow this cookbook.

Once you start working with it, make sure to let us know if you find it useful. All kind of feedback is much appreciated, including GitHub Pull Requests that could directly improve this documentation.

Want to learn more?

If you need professional guidance to better understand payment processing in Sylius, have a look at our online course program overview. Within 8 hours of specially designed video lessons, you will learn everything you need to know to start your first project or structure the experience you already have.

Take advantage of the maximum 40% PRE-SALE discount and buy your ticket until August 31!

 

Share:
Paweł Jędrzejewski
Self-taught developer and entrepreneur, who has built an entire career and business through Open Source technology. Speaker at international conferences. PHPers meetups co-organizer. Keen on helping other young entrepreneurs and companies who may want to follow a similar path.
More from our blog
Technical 2 min read 04.12.2024
Here’s everything you had to know about the first major release since 2017! Over 7 years after the first major release, on Nov 12, 2024, we have released Sylius 2.0.0. We had a great opportunity to announce it first at SyliusCon in Lyon, but now, as we are back to… Read More
2 min read 22.11.2024
The emotions start to settle after SyliusCon, and it’s time to reflect on this incredible milestone in our journey. Why a milestone? Because SyliusCon exceeded our expectations in every possible way. We broke attendance records and brought together the key figures of our community, numerous partners, freelancers, and simply all… Read More
Cloud 2 min read 17.06.2024
We are thrilled to announce that we just signed a strategic partnership with Platform.sh, and as a result, we are extending our offer with Sylius Cloud powered by Platform.sh. Platform.sh is a modern Platform-as-a-Service (PaaS) solution that allows businesses to leverage the cloud environment without losing access to the code… Read More
Comments