New in Symfony 2.2: Payment related validators
![Avatar of Fabien Potencier](https://connect.symfony.com/api/images/4aed4f5d-e0cb-4320-902f-885fddaa7d15.png?format=28x28)
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
If you are developing an e-commerce solution based on Symfony2, you might want to validate a credit card number before sending it to your payment gateway. Doing so is very simple in Symfony 2.2 thanks to the Luhn algorithm and its implementation as a validator:
1 2 3 4 5 6 7 8 9 10 11
// src/Acme/SubscriptionBundle/Entity/Transaction.php
use Symfony\Component\Validator\Constraints as Assert;
class Transaction
{
/**
* @Assert\Luhn(message = "Please check your credit card number.")
*/
protected $cardNumber;
}
You can also check the card scheme thanks to
Symfony
.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments
![Avatar of Kirill](https://connect.symfony.com/api/images/fe64fe13-0878-461b-a75c-bf25a8f0b264.png?format=48x48)
![Avatar of Name](https://connect.symfony.com/api/images/fa2b2c2d-d31a-4ce6-a9bf-1fd615eea596.png?format=48x48)
![Avatar of Max Małecki](https://connect.symfony.com/api/images/14498c11-b8a1-4f8c-8ae3-b9b92e92241b.png?format=48x48)
![Avatar of Saša Stamenković](https://connect.symfony.com/api/images/263ba87b-8568-4a53-b543-5d14f1cbbfe0.png?format=48x48)
![Avatar of Saša Stamenković](https://connect.symfony.com/api/images/263ba87b-8568-4a53-b543-5d14f1cbbfe0.png?format=48x48)
![Avatar of Elodie IRDOR](https://connect.symfony.com/api/images/8e2e8a4b-f5b2-4fd6-9ac1-502f07ffcfb6.png?format=48x48)
![Avatar of Francis Hilaire](https://connect.symfony.com/api/images/f6c7557d-74f0-4595-8e0b-094ca261af4b.png?format=48x48)
![Avatar of abdelaziz ben ahmed](https://connect.symfony.com/api/images/4003f894-fec0-4794-8138-69725e946df5.png?format=48x48)
![Avatar of Pascal Borreli](https://connect.symfony.com/api/images/21c7abf2-a970-433e-be9a-d06fb9419d24.png?format=48x48)
![Avatar of Darren Black](https://connect.symfony.com/api/images/88560553-86a6-4b66-951e-598b7c444251.png?format=48x48)
![Avatar of Chang Long](https://connect.symfony.com/api/images/edbb38a0-9067-4078-99c2-8786c7a3eb05.png?format=48x48)
![Avatar of Francis Hilaire](https://connect.symfony.com/api/images/f6c7557d-74f0-4595-8e0b-094ca261af4b.png?format=48x48)
![Avatar of Michal Klik](https://connect.symfony.com/api/images/3a3449a6-4159-47f6-ac4e-b92e0186987d.png?format=48x48)
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.