From 48af32d9fcea86ee3d6788291479f3d625245cff Mon Sep 17 00:00:00 2001 From: wuweixin Date: Fri, 19 Jul 2019 06:52:33 +0800 Subject: [PATCH 01/14] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a892071..4f45453 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ Pre Laravel 5.5: After updating composer, add the ServiceProvider to the provide 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 + $ 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. From 45700d571cb4d326f2ad34300fedc8238abb28f1 Mon Sep 17 00:00:00 2001 From: Ammon Casey Date: Thu, 10 Oct 2019 14:31:38 -1000 Subject: [PATCH 02/14] Laravel 6 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 99611b0..3c61d61 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "illuminate/support": "^5", + "illuminate/support": "^5|^6.0", "league/omnipay": "~3.0" }, "autoload": { From 6da6494f4f248ecd030445027da0c44d3b97711c Mon Sep 17 00:00:00 2001 From: Remco Speekenbrink <98remco@gmail.com> Date: Sat, 4 Jan 2020 00:52:12 +0100 Subject: [PATCH 03/14] Code cleanup and PSR-2 compatible Cleanup the code and follow PSR-2 guidelines --- .gitignore | 1 + config/omnipay.php | 51 +++++++++++++++++++++++++++++------------ src/Facade.php | 10 ++++---- src/GatewayManager.php | 11 ++++----- src/ServiceProvider.php | 5 ++-- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 5826402..72726d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.idea /vendor composer.phar composer.lock diff --git a/config/omnipay.php b/config/omnipay.php index aafb7cf..5856e56 100644 --- a/config/omnipay.php +++ b/config/omnipay.php @@ -1,21 +1,42 @@ 'PayPal_Express', + /* + |-------------------------------------------------------------------------- + | Default Gateway + |-------------------------------------------------------------------------- + | + | Here you can specify the gateway that the facade should use by default. + | + */ + 'gateway' => env('OMNIPAY_GATEWAY', 'PayPal_Express'), - /** The default settings, applied to all gateways */ - 'defaults' => array( - 'testMode' => false, - ), + /* + |-------------------------------------------------------------------------- + | Default settings + |-------------------------------------------------------------------------- + | + | Here you can specify default settings for gateways. + | + */ + 'defaults' => [ + 'testMode' => env('OMNIPAY_TESTMODE', false), + ], - /** Gateway specific parameters */ - 'gateways' => array( - 'PayPal_Express' => array( - 'username' => '', - 'landingPage' => array('billing', 'login'), - ), - ), + /* + |-------------------------------------------------------------------------- + | Gateway specific settings + |-------------------------------------------------------------------------- + | + | Here you can specify gateway specific settings. + | + */ + 'gateways' => [ + 'PayPal_Express' => [ + 'username' => env('OMNIPAY_PAYPAL_USERNAME'), + 'landingPage' => ['billing', 'login'], + ], + ], -); +]; diff --git a/src/Facade.php b/src/Facade.php index 7c29890..7a64d06 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -2,8 +2,8 @@ use Omnipay\Common\CreditCard; -class Facade extends \Illuminate\Support\Facades\Facade { - +class Facade extends \Illuminate\Support\Facades\Facade +{ /** * @param array $parameters * @return CreditCard @@ -16,6 +16,8 @@ public static function creditCard($parameters = null) /** * {@inheritDoc} */ - protected static function getFacadeAccessor() { return 'omnipay'; } - + protected static function getFacadeAccessor() + { + return 'omnipay'; + } } diff --git a/src/GatewayManager.php b/src/GatewayManager.php index 90ef29a..dbe438a 100644 --- a/src/GatewayManager.php +++ b/src/GatewayManager.php @@ -2,8 +2,8 @@ use Omnipay\Common\GatewayFactory; -class GatewayManager{ - +class GatewayManager +{ /** * The application instance. * @@ -45,7 +45,7 @@ public function gateway($class = null) { $class = $class ?: $this->getDefaultGateway(); - if(!isset($this->gateways[$class])){ + if (!isset($this->gateways[$class])) { $gateway = $this->factory->create($class, null, $this->app['request']); $gateway->initialize($this->getConfig($class)); $this->gateways[$class] = $gateway; @@ -61,7 +61,7 @@ protected function getConfig($name) { return array_merge( $this->defaults, - $this->app['config']->get('omnipay.gateways.'.$name, array()) + $this->app['config']->get('omnipay.gateways.'.$name, []) ); } @@ -95,7 +95,6 @@ public function setDefaultGateway($name) */ public function __call($method, $parameters) { - return call_user_func_array(array($this->gateway(), $method), $parameters); + return call_user_func_array([$this->gateway(), $method], $parameters); } - } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index dfdac1c..b06d2d9 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -2,7 +2,8 @@ use Omnipay\Common\GatewayFactory; -class ServiceProvider extends \Illuminate\Support\ServiceProvider { +class ServiceProvider extends \Illuminate\Support\ServiceProvider +{ /** * Indicates if loading of the provider is deferred. @@ -21,7 +22,7 @@ public function register() $configPath = __DIR__ . '/../config/omnipay.php'; $this->publishes([$configPath => config_path('omnipay.php')]); - $this->app->singleton('omnipay',function ($app){ + $this->app->singleton('omnipay', function ($app) { $defaults = $app['config']->get('omnipay.defaults', array()); return new GatewayManager($app, new GatewayFactory, $defaults); }); From 86a53ecf875dac02096f69f25f456c77b302fede Mon Sep 17 00:00:00 2001 From: Remco Speekenbrink <98remco@gmail.com> Date: Sat, 4 Jan 2020 00:53:00 +0100 Subject: [PATCH 04/14] Update README.md update readme with markdown codeblock syntax and typehinting aswell as making it non Laravel 5 specific. --- readme.md | 76 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/readme.md b/readme.md index 4f45453..c8a8996 100644 --- a/readme.md +++ b/readme.md @@ -1,25 +1,33 @@ -## Omnipay for Laravel 5 +## 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 in your composer.json and run composer update (or run `composer require barryvdh/laravel-omnipay:0.3.x` directly): - - "barryvdh/laravel-omnipay": "0.3.*@dev" +Require this package in your composer.json and run composer update (or run `composer require barryvdh/laravel-omnipay` directly): +```php +"barryvdh/laravel-omnipay": "0.3.*" +``` + Pre Laravel 5.5: After updating composer, add the ServiceProvider to the providers array in config/app.php - 'Barryvdh\Omnipay\ServiceProvider', +```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' +``` +$ 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', +```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')`. @@ -27,30 +35,36 @@ 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('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(); - } +```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: - $formInputData = array( - 'firstName' => 'Bobby', - 'lastName' => 'Tables', - 'number' => '4111111111111111', - ); - $card = Omnipay::CreditCard($formInputData); +```php +$formInputData = [ + 'firstName' => 'Bobby', + 'lastName' => 'Tables', + 'number' => '4111111111111111', +]; + +$card = Omnipay::CreditCard($formInputData); +``` From 468ce95d322a1ee8c2c4197b90a5854cbfe17734 Mon Sep 17 00:00:00 2001 From: Remco Speekenbrink <98remco@gmail.com> Date: Sat, 4 Jan 2020 12:10:03 +0100 Subject: [PATCH 05/14] Update README Update readme to no longer include any version suggestions as discussed in !29 --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index c8a8996..1b121c2 100644 --- a/readme.md +++ b/readme.md @@ -5,10 +5,10 @@ You can use it to easily manage your configuration, and use the Facade to provid ## Installation -Require this package in your composer.json and run composer update (or run `composer require barryvdh/laravel-omnipay` directly): +Require this package with composer. -```php -"barryvdh/laravel-omnipay": "0.3.*" +``` +$ composer require barryvdh/laravel-omnipay ``` Pre Laravel 5.5: After updating composer, add the ServiceProvider to the providers array in config/app.php From 2d8d8c0dc07a1b87d9194c9e7f41e4c51a26b69b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 9 Mar 2020 10:25:03 +0100 Subject: [PATCH 06/14] allow Laravel 7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3c61d61..d42c1cb 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "illuminate/support": "^5|^6.0", + "illuminate/support": "^5|^6|^7", "league/omnipay": "~3.0" }, "autoload": { From f9b425d413c701e679b08a3f0b0ef10d469fc078 Mon Sep 17 00:00:00 2001 From: sahin Date: Mon, 9 Mar 2020 13:56:39 +0300 Subject: [PATCH 07/14] readme vendor publish error fixed --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1b121c2..352bbf1 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ Pre Laravel 5.5: After updating composer, add the ServiceProvider to the provide 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' +$ 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. From 7ab80fc032ab5b6126768338ce3c4eecff0fb694 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 21 Sep 2020 17:07:03 +0200 Subject: [PATCH 08/14] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d42c1cb..01a3457 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "illuminate/support": "^5|^6|^7", + "illuminate/support": "^5|^6|^7|^8", "league/omnipay": "~3.0" }, "autoload": { From d41a6a8a6cb19e6b6b5a72efe2acbf3c178161fe Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 22 Sep 2020 10:13:39 -0600 Subject: [PATCH 09/14] Add support for Laravel 8 (#35) From d15e510cb53e7afacec55c08b9431c65cd2d0942 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Fri, 4 Feb 2022 13:54:01 -0500 Subject: [PATCH 10/14] Bump dependencies for Laravel 9 (#40) --- composer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 01a3457..1fd5844 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,10 @@ { "name": "barryvdh/laravel-omnipay", "description": "Omnipay Service Provider for Laravel", - "keywords": ["laravel", "omnipay"], + "keywords": [ + "laravel", + "omnipay" + ], "license": "MIT", "authors": [ { @@ -10,7 +13,7 @@ } ], "require": { - "illuminate/support": "^5|^6|^7|^8", + "illuminate/support": "^5|^6|^7|^8|^9.0", "league/omnipay": "~3.0" }, "autoload": { From 11a77db622f0b2cb911249b6afb646a5132a0837 Mon Sep 17 00:00:00 2001 From: keatliang2005 <473990+keatliang2005@users.noreply.github.com> Date: Sun, 10 Mar 2024 03:17:16 +0800 Subject: [PATCH 11/14] Laravel 10 support (#43) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1fd5844..25bab4c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "illuminate/support": "^5|^6|^7|^8|^9.0", + "illuminate/support": "^5|^6|^7|^8|^9.0|^10.0", "league/omnipay": "~3.0" }, "autoload": { From 9c5af9e20cfe893704fab62acaf4b982415fc45e Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 9 Mar 2024 20:17:46 +0100 Subject: [PATCH 12/14] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 25bab4c..6aadabe 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "illuminate/support": "^5|^6|^7|^8|^9.0|^10.0", + "illuminate/support": "^5|^6|^7|^8|^9|^10|^11", "league/omnipay": "~3.0" }, "autoload": { From 11f29f641040f76f9d11bada1d4b3df7b2ce2b62 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 25 Feb 2025 11:44:00 +0100 Subject: [PATCH 13/14] Support Laravel 12 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6aadabe..0f1385a 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ } ], "require": { - "illuminate/support": "^5|^6|^7|^8|^9|^10|^11", + "php": "^8.1", + "illuminate/support": "^9|^10|^11|^12", "league/omnipay": "~3.0" }, "autoload": { From 5b89dae0ef8188f44d405dc85fd468656eeeb86a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 18 Apr 2025 17:03:34 +0200 Subject: [PATCH 14/14] Add $factory property --- src/GatewayManager.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/GatewayManager.php b/src/GatewayManager.php index dbe438a..bc419d5 100644 --- a/src/GatewayManager.php +++ b/src/GatewayManager.php @@ -11,6 +11,9 @@ class GatewayManager */ protected $app; + /** @var GatewayFactory */ + protected $factory; + /** * The registered gateways */