laravelpay/foundation is a Laravel package for larapay is a payment gateway package for laravel.
It currently has 0 GitHub stars and 16 downloads on Packagist.
Install it with composer require laravelpay/foundation.
Discover more Laravel packages by laravelpay
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Pay is a lightweight package for Laravel that allows you to easily integrate payment gateways into your application.
| Gateway | Install Command | | ------------- | ------------- | | PayPal | php artisan gateway:install laravelpay/gateway-paypal | | PayPal IPN | php artisan gateway:install laravelpay/gateway-paypal-ipn | | Stripe | php artisan gateway:install laravelpay/gateway-stripe | | Mollie | php artisan gateway:install laravelpay/gateway-mollie | | Tebex | php artisan gateway:install laravelpay/gateway-tebex | | BitPave | php artisan gateway:install laravelpay/gateway-bitpave | | PayByLink | php artisan gateway:install laravelpay/gateway-paybylink |
| Gateway | Install Command | | ------------- | ------------- | | PayPal Subscriptions | php artisan gateway:install laravelpay/subscriptions-paypal | | Stripe Subscriptions | php artisan gateway:install laravelpay/subscriptions-stripe |
To install the package, use Composer:
composer require laravelpay/foundation dev-main
Laravel Pay allows you to install gateways based on your needs. The command below allows you to install one of our default gateways.
php artisan gateway:install
To install custom gateways, you may pass it in the argument and the GitHub owner/repo i.e php artisan gateway:install laravelpay/gateway-paypal-ipn
You can create multiple configurations for each gateway. Below is an example of how you might set up the PayPal gateway.
php artisan gateway:setup
Below is an example of how you might use the package in your Laravel application.
use LaraPay\Framework\Payment;
Route::get('/macbook/purchase', function () {
$payment = Payment::create([
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
]);
return $payment->payWith('paypal');
}
In the payWith() method, pass the id or alias of the gateway.
This package comes with a built-in method that allows you to generate temporary links that redirect the user to make the payment.
use LaraPay\Framework\Payment;
$payment = Payment::create([
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
]);
// laravel-pay generates a temporary payment link for the gateway
$link = $payment->generateLinkForGateway('paypal'); // http://laravel.app/payments/pay/awFlSUrsmKsoVtLHQBzLziFFnqoSsXt6
return redirect($link);
After a user completes a payment, you may want to execute some code to fulfill the users order. This can be done using Payment Handlers.
namespace App\PaymentHandlers;
LaraPay\Framework\Interfaces\PaymentHandler;
class MacbookPaymentHandler extends PaymentHandler
{
public function onPaymentCompleted($payment)
{
// execute code when payment is completed
}
}
use LaraPay\Framework\Payment;
use App\PaymentHandlers\MacbookPaymentHandler;
$payment = Payment::create([
'user_id' => 1,
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
'handler' => MacbookPaymentHandler::class,
]);
You may want to attach specific payments to specific users. You can do so by passing the user id when the payment is created
use LaraPay\Framework\Payment;
$payment = Payment::create([
'user_id' => 1,
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
]);
The user can be retrieved later when the payment is completed using $payment->user
Custom data can be passed when the payment is being created
use LaraPay\Framework\Payment;
$payment = Payment::create([
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
'data' => [
'order_id' => 1,
],
]);
Define the URL where the user should be redirected to in the event that the payment gets cancelled or is successfully completed.
use LaraPay\Framework\Payment;
$payment = Payment::create([
'amount' => 2000,
'currency' => 'USD',
'description' => 'Macbook Pro',
'success_url' => route('your-success-route'),
'cancel_url' => route('your-cancel-route'),
]);
This package includes support for some subscription based gateways. This system works similarly to normal payments.
use LaraPay\Framework\Subscription;
Route::get('/plans/basic/subscribe', function () {
$subscription = Subscription::create([
'name' => 'Basic Plan',
'amount' => 2000,
'currency' => 'USD',
'frequency' => 30, // The frequency (in days) on which the subscription will be charged. 7 is weekly, 30 monthly, 365 yearly
]);
return $subscription->subscribeWith('paypal');
}
If you have any questions or issues, please create a new issue in the project repository on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.