shaanid / paypal-package
A PayPal integration package for Laravel.
v1.0.0
2026-02-07 18:46 UTC
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0|^12.0
- srmklive/paypal: ^3.0
Requires (Dev)
- fakerphp/faker: ^1.23
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
README
A production-standard Laravel package for PayPal REST API integration, featuring robust error handling, transaction persistence, and audit logging.
🚀 Features
- Service-Oriented Architecture: Decoupled payment logic.
- Database Persistence: Automatic tracking of every transaction (Pending, Completed, Canceled, Failed).
- Audit Logging: Full traceability of API requests and responses.
- Action Pattern: Clean, testable, and reusable business logic.
- Ready-to-use UI: Modern, responsive checkout interface.
🛠️ Installation
-
Install via Composer: (Since this is currently a local package, you would typically add it to your
repositoriesincomposer.json)"repositories": [ { "type": "path", "url": "../path-to-your-package" } ]
Then run:
composer require shaanid/paypal-package
-
Publish Configuration and Views:
php artisan vendor:publish --provider="Shaanid\PayPal\PayPalServiceProvider" -
Environment Configuration: Add your PayPal credentials to your
.envfile:PAYPAL_MODE=sandbox PAYPAL_SANDBOX_CLIENT_ID=your_client_id PAYPAL_SANDBOX_CLIENT_SECRET=your_client_secret PAYPAL_CURRENCY=USD
-
Run Migrations:
php artisan migrate
📁 Usage
The package automatically registers the following routes:
GET /paypal: The checkout index page.POST /paypal/process: Handles order creation and redirection to PayPal.GET /paypal/success: Handles successful payment capture.GET /paypal/cancel: Handles payment cancellation.
Overriding Logic
You can use the Actions and Services provided by the package in your own controllers:
use Shaanid\PayPal\Actions\CreatePayPalOrderAction; use Shaanid\PayPal\DTOs\PaymentData; public function checkout(CreatePayPalOrderAction $action) { $data = new PaymentData(amount: '20.00', currency: 'USD', userId: auth()->id()); $approvalLink = $action->execute($data->toCollection()); return redirect()->away($approvalLink); }
📝 License
This project is open-sourced software licensed under the MIT license.