Integrates Omnipay 3 with Symfony 2+

Installs: 17 267

Dependents: 0

Suggesters: 0

Security: 0

Stars: 10

Watchers: 7

Forks: 10

Open Issues: 0


v3.0 2020-01-22 18:06 UTC

This package is not auto-updated.

Last update: 2023-01-30 22:27:10 UTC


This bundle integrates the Omnipay payment processing library into Symfony2.

This bundle supports Omnipay 3


To install via Composer, add the following to your composer.json file:

    "require": {
        "xola/omnipay-bundle": "^3"

Add the bundle to your application kernel.

// app/AppKernel.php
public function registerBundles()
    return array(
        // ...
        new Xola\OmnipayBundle\OmnipayBundle(),
        // ...


(Optional) In the Omnipay library, you would programmatically set parameters required by a gateway. With this bundle, it's possible to configure these parameters in your Symfony config files.

# app/config/password_dev.yml
    # Custom gateway
    omnipay.my_custom_key.apiKey: myGatewayKey
    omnipay.my_custom_key.gateway: MyGateway

    # Default Stripe gateway
    omnipay.stripe_default.apiKey: myApiKey
    omnipay.stripe_default.gateway: Stripe

    # Gateway for Stripe Canada account
    omnipay.stripe_canada.apiKey: myStripeCanadaApiKey
    omnipay.stripe_canada.gateway: Stripe

    # Authorize.NET AIM
    omnipay.authorize_net_aim.transactionKey: myTransactionKey
    omnipay.authorize_net_aim.gateway: AuthorizeNet_AIM

In the sample configuration above, my_custom_key is a unique key you define for each of your gateways. omnipay.my_custom_name.gateway is the class name for a Omnipay gateway driver (e.g. Stripe). You may choose to define multiple keys for the same Omnipay gateway with different credentials. In the above configuration, we have configured two gateway definitions for Stripe -- both use the Stripe Omnipay driver, however, they each use a different set of credentials.


Use the new omnipay service to create gateway object:

    // From within a controller. This will return an instance `\Omnipay\Stripe`. `stripe_default` is the key as
    // specified in the config.
    $gateway = $this->get('omnipay')->get('stripe_default');

    // From within a controller. This will return an instance of `\Omnipay\MyGateway` as specified in
    // `omnipay.my_custom_name.gateway`
    $gateway = $this->get('omnipay')->get('my_custom_name');

The rest is identical to how you would normally use Omnipay

$formData = ['number' => '4242424242424242', 'expiryMonth' => '11', 'expiryYear' => '2018', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
} else {
    // payment failed: display message to customer
    echo $response->getMessage();

The gateway classes which are returned are already initialized with the parameters defined in the config files.