maxts / omnipay-bundle
Omnipay bundle for Symfony
Requires
- php: >=5.4.0
- omnipay/common: ~2.0
- symfony/framework-bundle: ~2.3
Requires (Dev)
- omnipay/omnipay: ~2.0
- phpunit/phpunit: ~3.7
This package is not auto-updated.
Last update: 2025-01-10 19:46:26 UTC
README
Simple bundle for implementing Omnipay in your Symfony application.
Install
Via Composer
$ composer require colinodell/omnipay-bundle
Enable the bundle in your AppKernel.php
:
new ColinODell\OmnipayBundle\OmnipayBundle(),
Usage
This bundle provides a new service called Omnipay
. It contains a single method get()
, which returns a fully-configured gateway for you to use:
$stripe = $this->get('omnipay')->get('Stripe'); $paypal = $this->get('omnipay')->get('PayPal_Express');
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
Gateways can be configured in your app/config/config.yml
file
omnipay: methods: # Your config goes here
For example, to configure the Stripe and PayPal Express gateways:
omnipay: methods: Stripe: apiKey: sk_test_BQokikJOvBiI2HlWgH4olfQ2 PayPal_Express: username: test-facilitator_api1.example.com password: 3MPI3VB4NVQ3XSVF signature: 6fB0XmM3ODhbVdfev2hUXL2x7QWxXlb1dERTKhtWaABmpiCK1wtfcWd. testMode: false solutionType: Sole landingPage: Login
NOTE: You should probably consider using parameters instead of storing credentials directly in your config.yml
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 Gateways
Custom gateways can be registered via the container by tagging them with omnipay.gateway
:
# services.yml services: my.test.gateway: class: Path\To\MyTestGateway tags: - { name: omnipay.gateway, alias: MyTest } # config.yml omnipay: methods: # Reference the gateway alias here MyTest: apiKey: abcd1234!@#
You can then obtain the fully-configured gateway by its alias:
$this->get('omnipay')->get('MyTest');
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email colinodell@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.