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()->create(
    items: [['id' => 'product_abc123', 'quantity' => 1]],
    redirectUrlSuccess: 'https://your-app.com/success',
    redirectUrlCanceled: 'https://your-app.com/canceled',
);

return redirect($checkout->links->checkoutUrl->href);

$checkout is a Vatly\API\Resources\Checkout — see vatly-api-php for the full resource shape.

Subscription checkouts

For subscriptions, use the subscribe() builder. Redirect URLs default to those in config/vatly.php so the call can be just one line:

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

return redirect($checkout->links->checkoutUrl->href);

Checkout with metadata

$checkout = $user->checkout()
    ->withMetadata(['campaign' => 'summer-2025'])
    ->create(
        items: [['id' => 'product_abc123', 'quantity' => 1]],
        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