Laravel

Getting Started

Vatly Laravel Package - Getting Started

Getting Started

Vatly Laravel provides a Cashier-like integration for Vatly billing in your Laravel application. It handles subscriptions, checkouts, customers, webhooks, and payment method updates.

Requirements

  • PHP 8.2+
  • Laravel 11 or 12
  • A Vatly API key

Installation

composer require vatly/vatly-laravel:v0.2.0-alpha.1

Note: This is an alpha release. Pin to an exact version to avoid breaking changes.

Configuration

Publish the config file:

php artisan vendor:publish --tag=vatly-config

Add your credentials to .env:

VATLY_KEY=test_xxxxxxxxxxxxxxxxxxxx
VATLY_WEBHOOK_SECRET=your-webhook-secret
VATLY_REDIRECT_URL_SUCCESS=https://your-app.com/checkout/success
VATLY_REDIRECT_URL_CANCELED=https://your-app.com/checkout/canceled

Available config options

KeyEnv variableDefault
api_keyVATLY_KEY(required)
api_urlVATLY_API_URLhttps://api.vatly.com
api_versionVATLY_API_VERSIONv1
webhook_secretVATLY_WEBHOOK_SECRET(required for webhooks)
testmodeVATLY_TESTMODEfalse
billable_modelVATLY_BILLABLE_MODELApp\Models\User
redirect_url_successVATLY_REDIRECT_URL_SUCCESS(required for checkouts)
redirect_url_canceledVATLY_REDIRECT_URL_CANCELED(required for checkouts)

Database setup

Publish and run the migrations:

php artisan vendor:publish --tag=vatly-billable-migrations
php artisan vendor:publish --tag=vatly-migrations
php artisan migrate

This creates:

  • A vatly_id column on your users table
  • A vatly_subscriptions table
  • A vatly_webhook_calls table

Billable model

Add the Billable trait and implement BillableInterface on your User model:

use Vatly\Laravel\Contracts\BillableInterface;
use Vatly\Laravel\Billable;

class User extends Authenticatable implements BillableInterface
{
    use Billable;
}

This gives your User model access to all Vatly billing methods: customer management, subscriptions, checkouts, and orders.

Copyright © 2026