spanu18 / laravel-pay
Multi-gateway payment processing for Laravel — Stripe, SumUp, Adyen, PayPal, Mollie, Klarna and more.
Fund package maintenance!
Requires
- php: ^8.3
- illuminate/http: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- psr/log: ^2.0|^3.0
- stripe/stripe-php: v19.3.0
- sumup/sumup-php: ^0.1.6
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^4.6||^5.0
- pestphp/pest-plugin-laravel: ^4.1||^5.0
- pestphp/pest-plugin-type-coverage: ^4.0||^5.0
- phpstan/extension-installer: ^1.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel Pay
Multi-gateway payment processing for Laravel. Laravel Pay provides a uniform interface over a large set of payment gateways so you can accept payments without rewriting your integration for each provider.
Installation
You can install the package via Composer:
composer require spanu18/laravel-pay
You may publish all of the package's resources at once:
php artisan vendor:publish --tag="laravel-pay"
Or, you may publish each resource individually:
Publishing the Configuration File
php artisan vendor:publish --tag="laravel-pay-config"
Publishing and Running the Migrations
php artisan vendor:publish --tag="laravel-pay-migrations"
php artisan migrate
Publishing the Views
php artisan vendor:publish --tag="laravel-pay-views"
Publishing the Translations
php artisan vendor:publish --tag="laravel-pay-lang"
Publishing the Public Assets
php artisan vendor:publish --tag="laravel-pay-assets"
Usage
Laravel Pay exposes a uniform contract over all supported gateways. Each gateway is a service in the container and implements PaymentGatewayInterface, so the calling code barely changes from gateway to gateway.
Resolve a gateway
use LaravelPay\LaravelPay\Gateways\Stripe; use LaravelPay\LaravelPay\Gateways\Sumup; // Gateway instances are resolved through the container/DI. $stripe = app(Stripe::class); $sumup = app(Sumup::class);
Create a payment
use LaravelPay\LaravelPay\DTO\MerchantAccount; use LaravelPay\LaravelPay\DTO\PayerContact; use LaravelPay\LaravelPay\DTO\PaymentRequest; $payment = new PaymentRequest( amount: 49.00, currency: 'EUR', to: new MerchantAccount( credentials: ['access_token' => '...'], // gateway-specific merchantId: 'acct_...', // gateway-specific ), locale: 'it-IT', purchaseCountry: 'IT', from: new PayerContact(name: 'Mario', email: 'mario@example.com'), orderRef: 42, ); $result = $sumup->createPayment($payment); if ($result->success) { // $result->clientSecret is a hosted checkout URL / client secret to // send to your front-end to redirect the payer. return redirect($result->clientSecret); }
Refund and inspect a checkout
$sumup->refundPayment($result->transactionId, $credentials, 49.00); $checkout = $sumup->getCheckout($result->transactionId, $credentials); if ($checkout && $checkout->status === 'paid') { // fulfill the order }
Configure gateways
Gateways read their credentials from the package config, which you publish and edit:
php artisan vendor:publish --tag="laravel-pay-config" # edit config/laravel-pay.php and set the env vars / keys for each gateway
Supported gateways
Adyen, Axerve, Binance Pay, Braintree, Coinbase, Edenred, Klarna, Mollie, Nexi, PayPal, Pluxee, Revolut, Satispay, Scalapay, Stripe, SumUp.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Thank you for considering contributing to Laravel Pay! Please review our contributing guide to get started.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
Laravel Pay is open-sourced software licensed under the MIT license.