Larapay — a powerful Laravel extension with 2 core functionalities: 1) abstract interface for any payment gateway; 2) accounting system for your users.
This package can be installed as a Composer dependency.
$ composer require nxmad/larapay
If you don't use auto-discovery (or your Laravel version < 5.5), add the ServiceProvider to the providers
array in config/app.php
Nxmad\Larapay\LarapayServiceProvider::class,
Publish default configuration file larapay.php
$ php artisan vendor:publish
// Setup transaction for user
// Actually, you can use any Entity (Model) instead of User
// Transaction can have positive and negative amount
$transaction = $request->user()->setup(- $amount, $description);
// Check if the user can afford this order
if ($transaction->affordable() || $request->user()->canAfford($transaction)) {
// do some logic...
// and then save the transaction as sucessfull
// this way:
$transaction->makeSuccessful();
// or this way:
$transaction(Transaction::STATE_SUCCESSFUL);
} else {
// Otherwise redirect user to the payment gateway (for .e.g)
$gateway = payments('paypal');
// There are 3 ways of interact with payment gateway:
// Redirect (GET), POST form and any custom behavior you can define by yourself
return $gateway->interact($transaction);
}
Please see Wiki for more examples.
You can add your gateway implementation to this list by creating an issue.
Gateway | Composer package | Maintainer |
---|---|---|
Unitpay | nxmad/larapay-unitpay | Alex Balatsky |
WebMoney | nxmad/larapay-webmoney | Alex Balatsky |
Qiwi.com P2P | nxmad/larapay-qiwi-p2p | Alex Balatsky |
Yandex.Money P2P | nxmad/larapay-yandex-money-p2p | Alex Balatsky |
Since 1.0
$ composer test
The MIT License (MIT). Please see License File for more information.