Skip to main content

Requirements

Before installing Eufaturo Billing, ensure your system meets these requirements:
  • PHP: 8.4 or higher
  • Laravel: 12.0 or higher
  • Database: MySQL 8.0+ (PostgreSQL support coming soon)
  • Composer: Latest version
  • pdo_mysql
  • mbstring
  • json
  • bcmath (for precise money calculations)

Installation Steps

1. Install the Core Package

Install the core billing package via Composer:
composer require eufaturo/billing

2. Publish Configuration & Migrations

Publish the package configuration and migrations:
# Publish everything
php artisan vendor:publish --tag=billing

# Or publish individually
php artisan vendor:publish --tag=billing-config
php artisan vendor:publish --tag=billing-migrations

3. Run Migrations

Run the database migrations to create the billing tables:
php artisan migrate
This will create the following tables with the billing_ prefix:
  • billing_currencies
  • billing_payment_gateways
  • billing_payment_methods
  • billing_gateway_references
  • billing_products
  • billing_product_plans
  • billing_features
  • billing_subscriptions
  • billing_orders
  • billing_transactions
  • And more…
All billing tables use the billing_ prefix to avoid conflicts with your application tables.

4. Configure Billable Entity

In your AppServiceProvider, configure how the package resolves the billable entity (customer):
app/Providers/AppServiceProvider.php
use Eufaturo\Billing\Billing;

public function boot(): void
{
    Billing::resolveBillableUsing(function () {
        // Return the authenticated user or company
        return auth()->user();
    });
}
For team/company-based billing:
Billing::resolveBillableUsing(function () {
    return auth()->user()?->activeCompany ?? auth()->user();
});
For subdomain-based applications:
Billing::resolveBillableUsing(function () {
    return Company::where('subdomain', request()->getHost())->firstOrFail();
});

5. Make Your Model Billable

Add the Billable trait and implement BillableInterface on your model:
app/Models/User.php
use Eufaturo\Billing\Billable;
use Eufaturo\Billing\BillableInterface;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements BillableInterface
{
    use Billable;

    public function getBillableId(): string
    {
        return (string) $this->id;
    }

    public function getBillableName(): string
    {
        return $this->name;
    }

    public function getBillableEmail(): string
    {
        return $this->email;
    }
}
Any Eloquent model can be billable - User, Company, Team, Organization, etc.

Install a Payment Gateway

Choose and install at least one payment gateway package:

Stripe

composer require eufaturo/billing-stripe

Eupago

composer require eufaturo/billing-eupago

Configure Gateway

Use the interactive Artisan command to configure your gateway:
php artisan billing:gateway:install stripe
This will:
  1. Prompt for API credentials (secret key, publishable key, etc.)
  2. Allow UI customization (colors, fonts, theme)
  3. Install default payment methods (card, SEPA, etc.)
  4. Store configuration in database
Gateway configuration is stored in the database, not in config files. This allows runtime configuration changes without deployment.

Optional: Install UI Package

For a pre-built checkout UI, install one of our official frontend packages:
Install the Livewire checkout package:
composer require eufaturo/billing-checkout-livewire
Publish the views and assets:
php artisan vendor:publish --tag=billing-checkout-views
php artisan vendor:publish --tag=billing-checkout-assets
Features:
  • Real-time form validation
  • Customizable Blade templates
  • Alpine.js for interactivity
  • Zero JavaScript build step required
Both official UI packages are production-ready, fully tested, and actively maintained by the Eufaturo team.

Verify Installation

Create a test to verify everything is working:
use Eufaturo\Billing\Billing;

// In a route or controller
Route::get('/test-billing', function () {
    $billable = Billing::getBillable();

    return response()->json([
        'billable_id' => $billable->getBillableId(),
        'billable_name' => $billable->getBillableName(),
    ]);
});

Next Steps

Troubleshooting

Make sure you’ve run composer dump-autoload and the package is properly installed.
composer dump-autoload
Ensure your database connection is configured correctly in .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
Make sure you’ve configured the billable resolver in your AppServiceProvider:
Billing::resolveBillableUsing(fn() => auth()->user());