[
  {
    "path": ".gitignore",
    "content": "/.idea\n/vendor\ncomposer.phar\ncomposer.lock\n.DS_Store\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (C) 2014 Barry vd. Heuvel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"barryvdh/laravel-omnipay\",\n    \"description\": \"Omnipay Service Provider for Laravel\",\n    \"keywords\": [\n        \"laravel\",\n        \"omnipay\"\n    ],\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Barry vd. Heuvel\",\n            \"email\": \"barryvdh@gmail.com\"\n        }\n    ],\n    \"require\": {\n        \"php\": \"^8.1\",\n        \"illuminate/support\": \"^9|^10|^11|^12|^13\",\n        \"league/omnipay\": \"~3.0\"\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"Barryvdh\\\\Omnipay\\\\\": \"src/\"\n        }\n    },\n    \"extra\": {\n        \"branch-alias\": {\n            \"dev-master\": \"0.3-dev\"\n        },\n        \"laravel\": {\n            \"providers\": [\n                \"Barryvdh\\\\Omnipay\\\\ServiceProvider\"\n            ],\n            \"aliases\": {\n                \"Omnipay\": \"Barryvdh\\\\Omnipay\\\\Facade\"\n            }\n        }\n    },\n    \"minimum-stability\": \"dev\"\n}\n"
  },
  {
    "path": "config/omnipay.php",
    "content": "<?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default Gateway\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify the gateway that the facade should use by default.\n    |\n    */\n    'gateway' => env('OMNIPAY_GATEWAY', 'PayPal_Express'),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default settings\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify default settings for gateways.\n    |\n    */\n    'defaults' => [\n        'testMode' => env('OMNIPAY_TESTMODE', false),\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Gateway specific settings\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify gateway specific settings.\n    |\n    */\n    'gateways' => [\n        'PayPal_Express' => [\n            'username' => env('OMNIPAY_PAYPAL_USERNAME'),\n            'landingPage' => ['billing', 'login'],\n        ],\n    ],\n\n];\n"
  },
  {
    "path": "readme.md",
    "content": "## Omnipay for Laravel\n\nThis is a package to integrate [Omnipay](https://github.com/omnipay/omnipay) with Laravel.\nYou can use it to easily manage your configuration, and use the Facade to provide shortcuts to your gateway.\n\n## Installation\n\nRequire this package with composer.\n\n```\n$ composer require barryvdh/laravel-omnipay\n```\n    \nPre Laravel 5.5: After updating composer, add the ServiceProvider to the providers array in config/app.php\n\n```php\n'Barryvdh\\Omnipay\\ServiceProvider',\n```\n\nYou need to publish the config for this package. A sample configuration is provided. The defaults will be merged with gateway specific configuration.\n\n```\n$ php artisan vendor:publish --provider=Barryvdh\\Omnipay\\ServiceProvider\n```\n\nTo use the Facade (`Omnipay::purchase()` instead of `App::make(`omnipay`)->purchase()`), add that to the facades array.\n\n```php\n'Omnipay' => 'Barryvdh\\Omnipay\\Facade',\n```\n\nWhen calling the Omnipay facade/instance, it will create the default gateway, based on the configuration.\nYou can change the default gateway by calling `Omnipay::setDefaultGateway('My\\Gateway')`.\nYou can get a different gateway by calling `Omnipay::gateway('My\\Cass')`\n\n## Examples\n\n```php\n$params = [\n    'amount' => $order->amount,\n    'issuer' => $issuerId,\n    'description' => $order->description,\n    'returnUrl' => URL::action('PurchaseController@return', [$order->id]),\n];\n\n$response = Omnipay::purchase($params)->send();\n\nif ($response->isSuccessful()) {\n    // payment was successful: update database\n    print_r($response);\n} elseif ($response->isRedirect()) {\n    // redirect to offsite payment gateway\n    return $response->getRedirectResponse();\n} else {\n    // payment failed: display message to customer\n    echo $response->getMessage();\n}\n```\n\nBesides the gateway calls, there is also a shortcut for the creditcard:\n\n```php\n$formInputData = [\n    'firstName' => 'Bobby',\n    'lastName' => 'Tables',\n    'number' => '4111111111111111',\n];\n\n$card = Omnipay::CreditCard($formInputData);\n```\n"
  },
  {
    "path": "src/Facade.php",
    "content": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\CreditCard;\n\nclass Facade extends \\Illuminate\\Support\\Facades\\Facade\n{\n    /**\n     * @param  array  $parameters\n     * @return CreditCard\n     */\n    public static function creditCard($parameters = null)\n    {\n        return new CreditCard($parameters);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    protected static function getFacadeAccessor()\n    {\n        return 'omnipay';\n    }\n}\n"
  },
  {
    "path": "src/GatewayManager.php",
    "content": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\GatewayFactory;\n\nclass GatewayManager\n{\n    /**\n     * The application instance.\n     *\n     * @var \\Illuminate\\Foundation\\Application\n     */\n    protected $app;\n\n    /** @var GatewayFactory  */\n    protected $factory;\n\n    /**\n     * The registered gateways\n     */\n    protected $gateways;\n\n    /**\n     * The default settings, applied to every gateway\n     */\n    protected $defaults;\n\n    /**\n     * Create a new Gateway manager instance.\n     *\n     * @param  \\Illuminate\\Foundation\\Application $app\n     * @param  \\Omnipay\\Common\\GatewayFactory $factory\n     * @param  array\n     */\n    public function __construct($app, GatewayFactory $factory, $defaults = array())\n    {\n        $this->app = $app;\n        $this->factory = $factory;\n        $this->defaults = $defaults;\n    }\n\n    /**\n     * Get a gateway\n     *\n     * @param  string  The gateway to retrieve (null=default)\n     * @return \\Omnipay\\Common\\GatewayInterface\n     */\n    public function gateway($class = null)\n    {\n        $class = $class ?: $this->getDefaultGateway();\n\n        if (!isset($this->gateways[$class])) {\n            $gateway = $this->factory->create($class, null, $this->app['request']);\n            $gateway->initialize($this->getConfig($class));\n            $this->gateways[$class] = $gateway;\n        }\n\n        return $this->gateways[$class];\n    }\n\n    /**\n     * Get the configuration, based on the config and the defaults.\n     */\n    protected function getConfig($name)\n    {\n        return array_merge(\n            $this->defaults,\n            $this->app['config']->get('omnipay.gateways.'.$name, [])\n        );\n    }\n\n    /**\n     * Get the default gateway name.\n     *\n     * @return string\n     */\n    public function getDefaultGateway()\n    {\n        return $this->app['config']['omnipay.gateway'];\n    }\n\n    /**\n     * Set the default gateway name.\n     *\n     * @param  string  $name\n     * @return void\n     */\n    public function setDefaultGateway($name)\n    {\n        $this->app['config']['omnipay.gateway'] = $name;\n    }\n\n    /**\n     * Dynamically call the default driver instance.\n     *\n     * @param  string  $method\n     * @param  array   $parameters\n     * @return mixed\n     */\n    public function __call($method, $parameters)\n    {\n        return call_user_func_array([$this->gateway(), $method], $parameters);\n    }\n}\n"
  },
  {
    "path": "src/ServiceProvider.php",
    "content": "<?php namespace Barryvdh\\Omnipay;\n\nuse Omnipay\\Common\\GatewayFactory;\n\nclass ServiceProvider extends \\Illuminate\\Support\\ServiceProvider\n{\n\n    /**\n     * Indicates if loading of the provider is deferred.\n     *\n     * @var bool\n     */\n    protected $defer = false;\n\n    /**\n     * Register the service provider.\n     *\n     * @return void\n     */\n    public function register()\n    {\n        $configPath = __DIR__ . '/../config/omnipay.php';\n        $this->publishes([$configPath => config_path('omnipay.php')]);\n        \n        $this->app->singleton('omnipay', function ($app) {\n            $defaults = $app['config']->get('omnipay.defaults', array());\n            return new GatewayManager($app, new GatewayFactory, $defaults);\n        });\n    }\n\n    /**\n     * Get the services provided by the provider.\n     *\n     * @return array\n     */\n    public function provides()\n    {\n        return array('omnipay');\n    }\n}\n"
  }
]