Vatly
Php

Subscriptions

Vatly PHP SDK - Subscriptions

Subscriptions are created automatically when a customer completes a checkout for a subscription plan. You can then manage the subscription lifecycle through the API.

The Subscription Resource

Below you'll find all properties for the Vatly Subscription resource.

Properties

NameTypeDescription
idstringUnique identifier for the subscription (subscription_...).
resourcestringResource type, always subscription.
customerIdstringID of the customer who owns this subscription.
subscriptionPlanIdstringID of the subscription plan this subscription is based on.
testmodeboolWhether this subscription is in test mode.
namestringName of the subscription (from the plan).
descriptionstringDescription of the subscription.
billingAddressAddressCustomer's billing address for this subscription.
basePriceMoneyPrice per billing cycle before taxes.
quantityintNumber of subscription units (e.g. seats).
intervalstringBilling interval unit: day, week, month, or year.
intervalCountintNumber of interval units between billing cycles.
statusstringThe subscription status (see Subscription statuses).
startedAtstringWhen the subscription started (ISO 8601).
endedAtstring | nullWhen the subscription ended (ISO 8601).
canceledAtstring | nullWhen the subscription was canceled (ISO 8601).
renewedAtstring | nullWhen the subscription was last renewed (ISO 8601).
renewedUntilstring | nullCurrent billing period end date (ISO 8601).
nextRenewalAtstring | nullWhen the next renewal will be attempted (ISO 8601). Null if canceled or ended.
trialUntilstring | nullWhen the trial period ends (ISO 8601). Null if not in trial or trial has ended.
mandateMandate | nullPayment method on file (method, maskedIdentifier). Null when the subscription has no mandate yet.
linksSubscriptionLinksHATEOAS links to related resources (self, customer).

Retrieve a subscription

GET /v1/subscriptions/:id

Retrieve a subscription by its ID.

$subscription = $vatly->subscriptions->get('subscription_abc123');

echo $subscription->status;
echo $subscription->subscriptionPlanId;

if ($subscription->isActive()) {
    echo 'Subscription is active';
}

List all subscriptions

GET /v1/subscriptions

Retrieve a paginated list of all subscriptions.

Optional attributes

NameTypeDescription
limitintegerThe number of subscriptions to return (default: 10, max: 100).
startingAfterstringA cursor for pagination.
customerIdstringFilter by customer ID.
$subscriptions = $vatly->subscriptions->list();

foreach ($subscriptions as $subscription) {
    echo $subscription->id . ': ' . $subscription->status;
}

// Filter by customer
$subscriptions = $vatly->subscriptions->list([
    'customerId' => 'customer_abc123',
]);

Update a subscription

PATCH /v1/subscriptions/:id

Change a subscription's plan, quantity and/or price. At least one of subscriptionPlanId, quantity, or price is required.

Optional attributes

NameTypeDescription
subscriptionPlanIdstringSwitch to a new plan (subscription_plan_...). Must match the subscription's testmode.
quantityintThe new total quantity (e.g. number of seats). This sets the quantity to the given value — it is not added to the current quantity.
pricearrayOverride the recurring price: ['value' => '99.99', 'currency' => 'EUR']. The currency must match the subscription's currency. Provide price alone to change the price in place, or combine it with subscriptionPlanId to switch plans at a custom price (overriding the new plan's default).
prorateboolProrate charges for the partial billing period (default true).
applyImmediatelyboolApply the change now (true) or at the end of the current period (false, default).
invoiceImmediatelyboolGenerate and charge a proration invoice immediately. Only applies when applyImmediately and prorate are both true.
anchorstring | nullSet the billing anchor to a specific date (YYYY-MM-DD, UTC). Cannot be combined with resetAnchor.
resetAnchorboolReset the billing anchor to now. Cannot be combined with anchor.
trialUntilstring | nullExtend or set a trial until this date (ISO 8601). Cannot be combined with anchor.
// Change the quantity (new total) and pass a custom idempotency key.
$subscription = $vatly->subscriptions->update('subscription_123', [
    'quantity' => 2,
], [
    'idempotencyKey' => 'subscription-update-123',
]);

// Switch plan at a custom price (currency must match the subscription).
$subscription = $vatly->subscriptions->update('subscription_123', [
    'subscriptionPlanId' => 'subscription_plan_Wt5mNvBxKw7YcZaEjLhR',
    'price' => ['value' => '99.99', 'currency' => 'EUR'],
    'applyImmediately' => true,
]);

If you already have a Subscription resource instance, set the key on the client before calling the resource method:

$vatly->setIdempotencyKey('subscription-update-123');

$subscription->update([
    'quantity' => 2,
]);

If you do not provide a custom key, the SDK generates one automatically for the PATCH request.


Cancel a subscription

DELETE /v1/subscriptions/:id

Cancel a subscription. The subscription will remain active until the end of the current billing period.

$subscription = $vatly->subscriptions->cancel('subscription_abc123');

// Subscription is now on grace period until current period ends
echo $subscription->status;        // 'on_grace_period'
echo $subscription->renewedUntil;  // Current billing period end

Resume a subscription

POST /v1/subscriptions/:id/resume

Reverse a pending cancellation while the subscription is still on its grace period. Once a subscription has fully ended it cannot be resumed.

$subscription = $vatly->subscriptions->resume('subscription_abc123');

echo $subscription->status; // 'active'

If you already have a Subscription resource instance:

$subscription->resume();

Subscription statuses

StatusDescription
activeSubscription is active and will renew
createdSubscription has been created but not yet started
trialSubscription is in trial period
on_grace_periodSubscription is canceled but still active until the period ends
pausedSubscription is temporarily paused
canceledSubscription has been canceled

Helper methods

The Subscription object provides convenient helper methods.

$subscription->isActive();         // true if status is 'active'
$subscription->isTrial();          // true if status is 'trial'
$subscription->isOnGracePeriod();  // true if status is 'on_grace_period'
$subscription->isCanceled();       // true if status is 'canceled'
Copyright © 2026