This is a Laravel application designed for handling payment processing using multiple payment platforms. It includes functionality for creating payment links, updating transaction statuses, and integrating with PayPal and a sample payment provider.
- Payment Processing Application
- PHP ^8.3
- Laravel 11
- Composer
- Node.js & npm (for chore scripts)
- Create payment links using PayPal and a sample payment provider.
- Update transaction statuses.
- Event-driven architecture for handling transactions.
- Integration with PayPal for payment processing.
- Integration with a sample payment provider for demonstration purposes.
git clone https://github.com/sunray-eu/laravel-payment-service.git
cd laravel-payment-service
Install the necessary PHP and Node.js dependencies.
composer install
npm install
Copy the .env.example
to .env
and configure your environment variables.
cp .env.example .env
php artisan key:generate
Ensure you have a database configured in your .env
file and then run:
php artisan migrate
Start the application using the Laravel development server.
php artisan serve
- PaymentController: Handles the creation of payment links using various payment platforms.
- TransactionController: Handles transaction status updates.
- Transaction: Represents a transaction with attributes such as amount, currency, provider, user ID, status, and payment link.
The application defines routes in the api.php
file for handling user information, creating payment links, and updating transaction statuses.
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\TransactionController;
Route::middleware(['auth:api', 'scopes:create-transaction'])->group(function () {
Route::post('/create-payment-link', [PaymentController::class, 'createPaymentLink']);
});
Route::middleware(['auth:api', 'scopes:update-transaction'])->group(function () {
Route::post('/update-transaction-status', [TransactionController::class, 'updateStatus']);
});
- PayPalService: Handles interactions with PayPal's API for payment processing.
- SampleService: Handles interactions with a sample provider for payment processing.
- ConsumesExternalServices: Provides a method to make requests to external services.
- TransactionCreated: Event triggered when a transaction is created.
- TransactionStatusUpdated: Event triggered when a transaction status is updated.
- LogTransactionCreated: Listener that logs the creation of a transaction.
- LogTransactionStatusUpdated: Listener that logs the update of a transaction status.
- AppServiceProvider: Registers application services and bootstraps necessary services such as Passport and custom URL generation for password resets.
Contributions are welcome! Please create an issue or submit a pull request with your changes.
This project is licensed under the MIT License.
For any questions or support, please open an issue on the GitHub repository.