Vatly
Laravel

Checkouts

Vatly Laravel Package - Checkouts

Checkouts redirect your customer to Vatly's hosted payment page. After payment, the customer is redirected back to your application.

Creating a checkout

$checkout = $user->checkout()
    ->withItems(collect(['product_abc123']))
    ->create(
        redirectUrlSuccess: 'https://your-app.com/success',
        redirectUrlCanceled: 'https://your-app.com/canceled',
    );

// Redirect the customer
return redirect($checkout->url);

Subscription checkouts

For subscriptions, use the subscribe() method which provides a fluent builder:

$checkout = $user->subscribe()
    ->toPlan('subscription_plan_monthly')
    ->create();

return redirect($checkout->url);

Checkout with metadata

$checkout = $user->checkout()
    ->withItems(collect(['product_abc123']))
    ->withMetadata(['campaign' => 'summer-2025'])
    ->create(
        redirectUrlSuccess: 'https://your-app.com/success',
        redirectUrlCanceled: 'https://your-app.com/canceled',
    );

How it works

The checkout flow:

  1. Your app creates a checkout session via the Vatly API (customer is created automatically if needed)
  2. The customer is redirected to Vatly's hosted payment page
  3. After payment, the customer returns to your redirectUrlSuccess
  4. Vatly sends a webhook to confirm the payment (see Webhooks)
  5. If this was a new customer, the customer ID is synced to your local database via webhook

The redirect URLs default to the values in your vatly.php config but can be overridden per checkout.

Copyright © 2026