Repository: barryvdh/laravel-omnipay
Branch: master
Commit: c7282d335f8b
Files: 8
Total size: 8.7 KB
Directory structure:
gitextract_np4t_39x/
├── .gitignore
├── LICENSE
├── composer.json
├── config/
│ └── omnipay.php
├── readme.md
└── src/
├── Facade.php
├── GatewayManager.php
└── ServiceProvider.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/.idea
/vendor
composer.phar
composer.lock
.DS_Store
================================================
FILE: LICENSE
================================================
Copyright (C) 2014 Barry vd. Heuvel
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: composer.json
================================================
{
"name": "barryvdh/laravel-omnipay",
"description": "Omnipay Service Provider for Laravel",
"keywords": [
"laravel",
"omnipay"
],
"license": "MIT",
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"require": {
"php": "^8.1",
"illuminate/support": "^9|^10|^11|^12|^13",
"league/omnipay": "~3.0"
},
"autoload": {
"psr-4": {
"Barryvdh\\Omnipay\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
},
"laravel": {
"providers": [
"Barryvdh\\Omnipay\\ServiceProvider"
],
"aliases": {
"Omnipay": "Barryvdh\\Omnipay\\Facade"
}
}
},
"minimum-stability": "dev"
}
================================================
FILE: config/omnipay.php
================================================
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Gateway
|--------------------------------------------------------------------------
|
| Here you can specify the gateway that the facade should use by default.
|
*/
'gateway' => env('OMNIPAY_GATEWAY', 'PayPal_Express'),
/*
|--------------------------------------------------------------------------
| Default settings
|--------------------------------------------------------------------------
|
| Here you can specify default settings for gateways.
|
*/
'defaults' => [
'testMode' => env('OMNIPAY_TESTMODE', false),
],
/*
|--------------------------------------------------------------------------
| Gateway specific settings
|--------------------------------------------------------------------------
|
| Here you can specify gateway specific settings.
|
*/
'gateways' => [
'PayPal_Express' => [
'username' => env('OMNIPAY_PAYPAL_USERNAME'),
'landingPage' => ['billing', 'login'],
],
],
];
================================================
FILE: readme.md
================================================
## Omnipay for Laravel
This is a package to integrate [Omnipay](https://github.com/omnipay/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
```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.
```php
'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
```php
$params = [
'amount' => $order->amount,
'issuer' => $issuerId,
'description' => $order->description,
'returnUrl' => URL::action('PurchaseController@return', [$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:
```php
$formInputData = [
'firstName' => 'Bobby',
'lastName' => 'Tables',
'number' => '4111111111111111',
];
$card = Omnipay::CreditCard($formInputData);
```
================================================
FILE: src/Facade.php
================================================
<?php namespace Barryvdh\Omnipay;
use Omnipay\Common\CreditCard;
class Facade extends \Illuminate\Support\Facades\Facade
{
/**
* @param array $parameters
* @return CreditCard
*/
public static function creditCard($parameters = null)
{
return new CreditCard($parameters);
}
/**
* {@inheritDoc}
*/
protected static function getFacadeAccessor()
{
return 'omnipay';
}
}
================================================
FILE: src/GatewayManager.php
================================================
<?php namespace Barryvdh\Omnipay;
use Omnipay\Common\GatewayFactory;
class GatewayManager
{
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
*/
protected $app;
/** @var GatewayFactory */
protected $factory;
/**
* The registered gateways
*/
protected $gateways;
/**
* The default settings, applied to every gateway
*/
protected $defaults;
/**
* Create a new Gateway manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @param \Omnipay\Common\GatewayFactory $factory
* @param array
*/
public function __construct($app, GatewayFactory $factory, $defaults = array())
{
$this->app = $app;
$this->factory = $factory;
$this->defaults = $defaults;
}
/**
* Get a gateway
*
* @param string The gateway to retrieve (null=default)
* @return \Omnipay\Common\GatewayInterface
*/
public function gateway($class = null)
{
$class = $class ?: $this->getDefaultGateway();
if (!isset($this->gateways[$class])) {
$gateway = $this->factory->create($class, null, $this->app['request']);
$gateway->initialize($this->getConfig($class));
$this->gateways[$class] = $gateway;
}
return $this->gateways[$class];
}
/**
* Get the configuration, based on the config and the defaults.
*/
protected function getConfig($name)
{
return array_merge(
$this->defaults,
$this->app['config']->get('omnipay.gateways.'.$name, [])
);
}
/**
* Get the default gateway name.
*
* @return string
*/
public function getDefaultGateway()
{
return $this->app['config']['omnipay.gateway'];
}
/**
* Set the default gateway name.
*
* @param string $name
* @return void
*/
public function setDefaultGateway($name)
{
$this->app['config']['omnipay.gateway'] = $name;
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array([$this->gateway(), $method], $parameters);
}
}
================================================
FILE: src/ServiceProvider.php
================================================
<?php namespace Barryvdh\Omnipay;
use Omnipay\Common\GatewayFactory;
class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$configPath = __DIR__ . '/../config/omnipay.php';
$this->publishes([$configPath => config_path('omnipay.php')]);
$this->app->singleton('omnipay', function ($app) {
$defaults = $app['config']->get('omnipay.defaults', array());
return new GatewayManager($app, new GatewayFactory, $defaults);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('omnipay');
}
}
gitextract_np4t_39x/
├── .gitignore
├── LICENSE
├── composer.json
├── config/
│ └── omnipay.php
├── readme.md
└── src/
├── Facade.php
├── GatewayManager.php
└── ServiceProvider.php
SYMBOL INDEX (13 symbols across 3 files)
FILE: src/Facade.php
class Facade (line 5) | class Facade extends \Illuminate\Support\Facades\Facade
method creditCard (line 11) | public static function creditCard($parameters = null)
method getFacadeAccessor (line 19) | protected static function getFacadeAccessor()
FILE: src/GatewayManager.php
class GatewayManager (line 5) | class GatewayManager
method __construct (line 34) | public function __construct($app, GatewayFactory $factory, $defaults =...
method gateway (line 47) | public function gateway($class = null)
method getConfig (line 63) | protected function getConfig($name)
method getDefaultGateway (line 76) | public function getDefaultGateway()
method setDefaultGateway (line 87) | public function setDefaultGateway($name)
method __call (line 99) | public function __call($method, $parameters)
FILE: src/ServiceProvider.php
class ServiceProvider (line 5) | class ServiceProvider extends \Illuminate\Support\ServiceProvider
method register (line 20) | public function register()
method provides (line 36) | public function provides()
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (10K chars).
[
{
"path": ".gitignore",
"chars": 53,
"preview": "/.idea\n/vendor\ncomposer.phar\ncomposer.lock\n.DS_Store\n"
},
{
"path": "LICENSE",
"chars": 1060,
"preview": "Copyright (C) 2014 Barry vd. Heuvel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthi"
},
{
"path": "composer.json",
"chars": 887,
"preview": "{\n \"name\": \"barryvdh/laravel-omnipay\",\n \"description\": \"Omnipay Service Provider for Laravel\",\n \"keywords\": [\n "
},
{
"path": "config/omnipay.php",
"chars": 1165,
"preview": "<?php\n\nreturn [\n\n /*\n |--------------------------------------------------------------------------\n | Default Ga"
},
{
"path": "readme.md",
"chars": 2003,
"preview": "## Omnipay for Laravel\n\nThis is a package to integrate [Omnipay](https://github.com/omnipay/omnipay) with Laravel.\nYou c"
},
{
"path": "src/Facade.php",
"chars": 443,
"preview": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\CreditCard;\n\nclass Facade extends \\Illuminate\\Support\\Facades\\Faca"
},
{
"path": "src/GatewayManager.php",
"chars": 2390,
"preview": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\GatewayFactory;\n\nclass GatewayManager\n{\n /**\n * The applica"
},
{
"path": "src/ServiceProvider.php",
"chars": 924,
"preview": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\GatewayFactory;\n\nclass ServiceProvider extends \\Illuminate\\Support"
}
]
About this extraction
This page contains the full source code of the barryvdh/laravel-omnipay GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (8.7 KB), approximately 2.3k tokens, and a symbol index with 13 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.