cviebrock / laravel-mangopay
Laravel/Lumen wrapper for the office Mangopay SDK library
Installs: 68 573
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 4
Forks: 8
Open Issues: 0
Requires
- php: ^7.3|^8.0
- illuminate/support: ^8.0|^9.0
- mangopay/php-sdk-v2: ^3.1
Requires (Dev)
- limedeck/phpunit-detailed-printer: ^6.0
- orchestra/testbench: ^6.5|^7.0
- phpunit/phpunit: ^9.4
README
This package makes it easier (hopefully!) to integrate the official Mangopay SDK into your Laravel and Lumen applications.
⚠️ This Package Will Be Abandoned
Due to several factors, including the fact that I no longer use Mangopay, I will be ceasing development on this package. If you are interested in taking over this project, please reach out to me here in the Issues board.
Installation
Depending on your version of Laravel, you should install a different version of the package. NOTE: As of version 6.0, the package's version should match the Laravel version.
Laravel
-
Install the package via composer:
composer require cviebrock/laravel-mangopay
After updating composer, the package will automatically register its service provider.
-
Publish the configuration file:
php artisan vendor:publish --provider="Cviebrock\LaravelMangopay\ServiceProvider"
-
Finally, generate the required temporary directories:
php artisan mangopay:mkdir
Lumen
-
Install the package via composer:
composer require cviebrock/laravel-mangopay:^6.0
-
Copy the configuration file to your
config
folder and enable everything inbootstrap/app.php
:$app->configure('mangopay'); $app->register(Cviebrock\LaravelMangopay\ServiceProvider::class);
-
Generate the required temporary directories:
php artisan mangopay:mkdir
Configuration
This package supports authentication configuration through the services configuration file located
in config/services.php
. Add the following block to that file, and set the appropriate
values in your .env
file:
'mangopay' => [ 'env' => env('MANGOPAY_ENV', 'sandbox'), // or "production" 'key' => env('MANGOPAY_KEY'), // your Mangopay client ID 'secret' => env('MANGOPAY_SECRET'), // your Mangopay client password ],
The configuration file you can publish to config/mangopay.php
provides additional
properties that can be passed to the MangopayAPI object when it is instantiated. In
most cases, you won't need to change anything here, so you can choose to not publish this
configuration, or have it simply return an empty array.
If you do use this file, see the SDK documentation for the various properties that can be set
(basically any public property on the MangoPay\Libraries\Configuration
class).
Usage
All this package really does is make instantiating the MangopayAPI
easy by
putting the configuration into Laravel/Lumen's config system.
Using it is now as easy as injecting Mangopay into your controller, and then
using it the same way you would use the MangopayAPI
class:
class MyController extends Illuminate\Routing\Controller { /** * @var \MangoPay\MangoPayApi */ private $mangopay; public function __construct(\MangoPay\MangoPayApi $mangopay) { $this->mangopay = $mangopay; } public function doStuff($someId) { // get some user by id $john = $this->mangopay->Users->Get($someId); // change and update some of his data $john->LastName .= " - CHANGED"; $this->mangopay->Users->Update($john); // get his bank accounts $pagination = new MangoPay\Pagination(1, 10); // get 1st page, 10 items per page $accounts = $this->mangopay->Users->GetBankAccounts($john->Id, $pagination); // etc. } }
Bugs, Suggestions and Contributions
Thanks to everyone who has contributed to this project! Special thanks to JetBrains for their Open Source License Program ... and the excellent PHPStorm IDE, of course!
Please use Github for reporting bugs, and making comments or suggestions.
See CONTRIBUTING.md for how to contribute changes.
Copyright and License
laravel-mangopay was written by Colin Viebrock and released under the MIT License. See LICENSE.md file for details.
Copyright (c) 2016 Colin Viebrock