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
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
Technical 2 min read 11.06.2024
Abstract 1.12 released in Q4 2022 1.13 on Apr 23rd, 2024 (a year later than we anticipated while releasing 1.12) 3859 commits 23 contributors A stabilized Sylius API powered by API Platform It’s been a long and bumpy road. Having it behind our backs was a highway that led Sylius… Read More
Business Ecosystem News 2 min read 06.06.2024
Welcome to the May summary! As an open-source eCommerce framework, Sylius continues to evolve with significant contributions from our vibrant community and valuable product updates. Apart from describing the technical changes, we will also quickly summarize the Sylius Technical Fundamentals & Sylius Polish Community Meetup and eCommerce Day Kaunas, as… Read More
Comments