shaanid/paypal-package

A PayPal integration package for Laravel.

Maintainers

Package info

github.com/shaanid/paypal-package

pkg:composer/shaanid/paypal-package

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-02-07 18:46 UTC

This package is auto-updated.

Last update: 2026-03-07 19:03:42 UTC


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

  1. Install via Composer: (Since this is currently a local package, you would typically add it to your repositories in composer.json)

    "repositories": [
        {
            "type": "path",
            "url": "../path-to-your-package"
        }
    ]

    Then run:

    composer require shaanid/paypal-package
  2. Publish Configuration and Views:

    php artisan vendor:publish --provider="Shaanid\PayPal\PayPalServiceProvider"
  3. Environment Configuration: Add your PayPal credentials to your .env file:

    PAYPAL_MODE=sandbox
    PAYPAL_SANDBOX_CLIENT_ID=your_client_id
    PAYPAL_SANDBOX_CLIENT_SECRET=your_client_secret
    PAYPAL_CURRENCY=USD
  4. 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.