JavaScript Fluent
JavaScript Fluent
Create checkouts and manage billing with @getvatly/fluent on your server.
Alpha — under active development. Every alpha release may include breaking changes. Pin exact versions during alpha.
Create checkouts and manage billing with @getvatly/fluent on your server.
Vatly is the European Merchant of Record for AI, software and digital products.
Install the tested alpha pair:
npm install --save-exact @getvatly/sdk@0.3.0-alpha.4 @getvatly/fluent@0.1.0-alpha.2
Start a subscription
Use a customer and plan from the key's storefront and mode. Check that the signed-in user owns the customer before calling this function:
import { VatlyClient } from '@getvatly/sdk';
import { Vatly } from '@getvatly/fluent';
export async function startSubscription(apiKey: string, customerId: string, planId: string) {
const vatly = new Vatly({
api: new VatlyClient({ apiKey }),
redirectUrlSuccess: 'https://app.example.com/billing/return',
redirectUrlCanceled: 'https://app.example.com/billing/canceled',
});
const checkout = await vatly.subscribe({ vatlyId: customerId })
.toPlan(planId)
.withQuantity(1)
.create();
return checkout.getUrl(); // Redirect the customer's browser to this URL.
}
Redirect to the returned URL. Use webhooks to confirm payment, not the return page.
For one-off purchases, use checkoutBuilder.
Guides
| Task | Guide |
|---|---|
| Set keys, redirects, and error handling | Configuration |
| Connect your database | Core concepts and storage |
| Link customers to your users | Customers and bindings |
| Sell products or start subscriptions | Checkouts |
| Swap, cancel, resume, or update billing | Subscriptions |
| Open invoice history and billing controls | Customer portal |
| Verify and process events | Webhooks |
| Read invoices, lines, and reversals | Orders |
| Test your integration | Testing |
For field details, see the API reference. The OpenAPI spec is also available for tooling.