Download the PHP package janwebdev/symfony-omnipay-bundle without Composer
On this page you can find all versions of the php package janwebdev/symfony-omnipay-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download janwebdev/symfony-omnipay-bundle
More information about janwebdev/symfony-omnipay-bundle
Files in janwebdev/symfony-omnipay-bundle
Package symfony-omnipay-bundle
Short Description Omnipay bundle for Symfony 4.4 / 5.x / 6.x
License MIT
Homepage https://github.com/colinodell/omnipay-bundle
Informations about the package symfony-omnipay-bundle
Symfony framework bundle for Omnipay library
The following bundle
is based on Omnipay package and its components.
It supports Symfony 4.4, 5.x, 6.x and PHP 7.4+, 8.0.x, 8.1.x
Installation
via Composer
Make sure it is enabled in ./config/bundles.php
file:
Usage
This bundle provides a new service called OmnipayManager
. It contains a single method get()
, which returns a fully-configured gateway. Use dependency injection to use service:
get()
receives payment integration name as string, as it is called in Omnipay package
You can then use these gateways like usual.
Note: Gateways are "cached" - calling get('Some_Gateway')
multiple times will always return the same object.
Configuration
Create config file ./config/packages/omnipay.yaml
or copy-paste from example.
Gateways can be configured in this file, i.e.:
For example, to configure the Stripe and PayPal Express gateways:
NOTE: Consider using parameters and/or ENV variables instead of storing credentials directly in your omnipay.yaml
file like that.
The method names should be whatever you'd typically pass into Omnipay::create()
.
The configuration settings vary per gateway - see
Configuring Gateways in the Omnipay documentation for more details.
Registering Custom Gateway
Custom gateways can be registered via the container by tagging them with omnipay.gateway
:
You can then obtain the fully-configured gateway by its alias:
Additional configuration and customization
Default gateway
Add default gateway key to your config:
You can now get default gateway instance:
Disabling gateways
If need to disable a gateway but want to keep all the configuration add disabled
key to the config:
MyGateway1
gateway will be skipped during gateway registration now.
Customizing Omnipay service
If you need specific gateway selection mechanism or need to get multiple gateways at once consider to extend
default bundle's Omnipay service. Create your custom App\Omnipay\MyService
class, extend it from base class and add custom getters.
For
example, you might want to get all gateways which implement some interface.
Now you should be able to get "card-saving"-aware gateways in your application:
Initialize gateways on registration
By default gateway is initialized only when you call get()
method. If you use custom getters (like
getCardSavingGateways
from example above) with $this->registeredGateways
inside you might want to initialize them
automatically during registration. Simply add appropriate config key:
Unit tests
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
All versions of symfony-omnipay-bundle with dependencies
php Version ^7.4|^8.0|^8.1
league/omnipay Version ^3
symfony/framework-bundle Version ^4.4||^5.4||^6
symfony/cache Version ^4.4||^5.4||^6