ONLINE COURSE -20% PRE-SALE

Blog

Welcome to our blog, where we share news related to Sylius and post about technology & eCommerce.

Paweł Jędrzejewski
27.08.2019 | 2 mins read

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!

 

PRE-SALE €490 €389
until September 30
Getting started with Sylius
Online course (8h)

Paweł Jędrzejewski
See my roles

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.

Be the first to find out about new posts. Join to our newsletter!