Need help with laravel-omnipay?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

barryvdh
147 Stars 40 Forks MIT License 46 Commits 10 Opened issues

Description

Omnipay ServiceProvider for Laravel

Services available

!
?

Need anything else?

Contributors list

# 2,081
PHP
CSS
Laravel
chatbot...
15 commits
# 614,563
PHP
3 commits
# 226,799
PHP
CSS
Laravel
Shell
3 commits
# 135,116
PHP
Laravel
JavaScr...
revisio...
1 commit
# 89,197
PHP
Laravel
laravel...
laravel...
1 commit
# 449
Nuxt.js
nuxt-mo...
vuex
framewo...
1 commit
# 693,989
PHP
1 commit
# 337,090
PHP
1 commit

Omnipay for Laravel

This is a package to integrate Omnipay with Laravel. You can use it to easily manage your configuration, and use the Facade to provide shortcuts to your gateway.

Installation

Require this package with composer.

$ composer require barryvdh/laravel-omnipay

Pre Laravel 5.5: After updating composer, add the ServiceProvider to the providers array in config/app.php

'Barryvdh\Omnipay\ServiceProvider',

You need to publish the config for this package. A sample configuration is provided. The defaults will be merged with gateway specific configuration.

$ php artisan vendor:publish --provider=Barryvdh\Omnipay\ServiceProvider

To use the Facade (

Omnipay::purchase()
instead of
App::make(
omnipay
)->purchase()
), add that to the facades array.
'Omnipay' => 'Barryvdh\Omnipay\Facade',

When calling the Omnipay facade/instance, it will create the default gateway, based on the configuration. You can change the default gateway by calling

Omnipay::setDefaultGateway('My\Gateway')
. You can get a different gateway by calling
Omnipay::gateway('My\Cass')

Examples

$params = [
    'amount' => $order->amount,
    'issuer' => $issuerId,
    'description' => $order->description,
    'returnUrl' => URL::action('[email protected]', [$order->id]),
];

$response = Omnipay::purchase($params)->send();

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

Besides the gateway calls, there is also a shortcut for the creditcard:

$formInputData = [
    'firstName' => 'Bobby',
    'lastName' => 'Tables',
    'number' => '4111111111111111',
];

$card = Omnipay::CreditCard($formInputData);

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.