Laravel Omnipay

ignited/laravel-omnipay image

Laravel Omnipay stats

Downloads
823.8K
Stars
496
Open Issues
0
Forks
98

View on GitHub →

Integrates Omnipay with Laravel and provides an easy configuration.

Omnipay for Laravel & Lumen

Integrates the Omnipay PHP library with Laravel to make Configuring multiple payment tunnels a breeze!

Installation

Include the laravel-omnipay package as a dependency in your composer.json:

composer require ignited/laravel-omnipay "3.*"

Note: You don't need to include the omnipay/common in your composer.json - it has already been included laravel-omnipay.

Install Required Providers

Now just include each gateway as you require, to included PayPal for example:

composer require omnipay/paypal "3.*"

Alternatively you can include every gateway by the following:

composer require omnipay/omnipay "3.*"

Note: this requires a large amount of composer work as it needs to fetch each seperate repository. This is not recommended.

Configuration

You can publish the configuration files using the vendor:publish command.

php artisan vendor:publish --provider="Ignited\LaravelOmnipay\LaravelOmnipayServiceProvider" --tag=config

Once you have published the configuration files, you can add your gateway options to the config file in config/laravel-omnipay.php.

PayPal Express Example

Here is an example of how to configure password, username and, signature with paypal express checkout driver

...
'gateways' => [
'paypal' => [
'driver' => 'PayPal_Express',
'options' => [
'username' => 'coolusername',
'password' => 'strongpassword',
'signature' => '',
'solutionType' => '',
'landingPage' => '',
'headerImageUrl' => '',
'brandName' => 'Your app name',
'testMode' => true
]
],
]
...

Usage

$cardInput = [
'number' => '4444333322221111',
'firstName' => 'MR. WALTER WHITE',
'expiryMonth' => '03',
'expiryYear' => '16',
'cvv' => '333',
];
 
$card = Omnipay::creditCard($cardInput);
 
$response = Omnipay::purchase([
'amount' => '100.00',
'returnUrl' => 'http://bobjones.com/payment/return',
'cancelUrl' => 'http://bobjones.com/payment/cancel',
'card' => $cardInput
])->send();
 
dd($response->getMessage());

This will use the gateway specified in the config as default.

However, you can also specify a gateway to use.

Omnipay::setGateway('paypal');
 
$response = Omnipay::purchase([
'amount' => '100.00',
'card' => $cardInput
])->send();
 
dd($response->getMessage());

In addition you can make an instance of the gateway.

$gateway = Omnipay::gateway('paypal');

Installation on Other Frameworks

Lumen

For Lumen add the following in your bootstrap/app.php

$app->register(Ignited\LaravelOmnipay\LumenOmnipayServiceProvider::class);

Copy the laravel-omnipay.php file from the config directory to config/laravel-omnipay.php

And also add the following to bootstrap/app.php

$app->configure('laravel-omnipay');

Guzzle

If you are using Guzzle 6 you need to require the following package.

composer require php-http/guzzle6-adapter

Guzzle 7 now implements a PSR http client compliant adapter. So there is no need to include this.

License

This package is open-sourced software licensed under the MIT license.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Ignited Laravel Omnipay Related Articles

HTTP Query Method Support in Laravel 13.19 image

HTTP Query Method Support in Laravel 13.19

Read article
In-Memory Eloquent Models with Truffle image

In-Memory Eloquent Models with Truffle

Read article
Queue-Wide Inspection Methods in Laravel 13.8.0 image

Queue-Wide Inspection Methods in Laravel 13.8.0

Read article
Redis Cluster Support for Queues in Laravel 13.5.0 image

Redis Cluster Support for Queues in Laravel 13.5.0

Read article
PestPHP Intellisense in Laravel VS Code Extension v1.7.0 image

PestPHP Intellisense in Laravel VS Code Extension v1.7.0

Read article
Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps image

Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps

Read article
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Typesense Search logo

Typesense Search

Typesense is an open source, blazing-fast search engine, optimized for helping you build delightful search experiences for your sites and apps. Natively integrated with Laravel Scout.

Typesense Search
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech