Skip to content
Logo Theodo

Add online payment on your Symfony project in half a day

Ivann Morice4 min read


As a way of getting incomes from your web application you often need to setup a way for your user to pay through your website.
Usually thanks to a form where your user will fill it’s banking information.

It may sounds like a big feature to implement but existing tools really ease the task.
On my project we’ve tried two of the main ones available : Stripe and Paybox.
And here’s how we quickly did it.

How to quickly setup Stripe on your app

Stripe provides an easy to setup REST API to allow secure online payment on your web app.

I’ve tried it on a Symfony 2.8 project and in half a day I was able to send and visualize test payment on the stripe dashboard.

First you need to create an account on Stripe which will give you access to the stripe dashboard where you can see all the transaction made.
With the creation of your account stripe provides you a test API key.

Then add in your composer require

  "require": {
  "stripe/stripe-php": "4.*"

and your API keys in your config.yml and start implementing the service which fits your needs.

To start making transaction you need to deal with the authentication to the Stripe API thanks to your API keys and to create a \Stripe\Charge object :

  "amount" = round($price * 100),
  "currency" = "usd",
  "customer" = $customerId)

Stripe provides a standard online payment form but you can make your own custom one without any issue.
In that case you need to deal with Stripe tokenification, which add another security layer.
It’s usually done by a javascript script on the page of your form.

You can also directly install one of several Symfony bundle already implementing a service and a formType for the payment with javascript tokenification.
Which is a nice and quick way to do a proof of concept on the matter.


Stripe has an IRC channel where people quickly help you.
Feel free to contact them when encountering technical issue.

How to setup Paybox

Paybox is the French counterpart of Stripe, it’s less easy to setup and less developper friendly but it still provides a complete online payment solution in one day or so.

Why Paybox over Stripe ?

- You have better price on Paybox
- A big client can easily have a good price with a fix fee over a percntage for stripe.
- Paybox is a french solution so you can easily interact with them, call their technical support

How to quickly install it

You can install a Paybox bundle with composer.
I’ve chosen this one as the read me is explicit enough and close to the Paybox documentation.

composer require lexik/paybox-bundle

Then follow the read me on github to implement your online payment service.

Like Stripe, Paybox provides a dev and a prod environment.
On the dev environment you can simulate payment with fake credit card.


The online documentation is not always updated (we had some issues with correct request according to the documentation which triggered wrong http response).

You also have to choose one offer of Paybox among the three available and each offer works differently with different request.

In case of issue don’t hesitate to directly call their technical support.

Which one to choose

We’ve already covered the fact that Stripe is easier to implement than Pyabox


Both Solutions allow Visa, MasterCard and AmericanExpress and a large variety of other payment method.
Paybox offer is centralized on France so if your client want to charge customer outside of France you’d rather use Stripe.


Stripe charges you a flat rate of 2.9% + 30¢ per successful charge as long as you’re doing under $1 million in volume per year.
Whereas Paybox offers you a monthly subscription (around 200€ TTC with 100 free transactions and then fix a fee of 0,85€ per transaction).
Note that you can bargain better prices with both solution.

As a result I would recommend using Paybox if your client needs a payment solution that involves numerous transaction and big amounts.
On the other hand if your client only want to have a quick online payment solution on a single project, it would be better to go for stripe.

Liked this article?