Billing
Stripe-poweredStripe-powered subscriptions and payments
Complete billing infrastructure for SaaS applications. Manage subscriptions, handle payments, implement usage-based pricing, and provide customer self-service portals. Powered by Stripe with full webhook handling and revenue analytics.
Overview
Pricing
Usage
Docs
Examples
Create Subscriptionsubscribe.ts
typescript
import { sylphx } from '@sylphx/sdk'
// Create a subscription for a user
const subscription = await sylphx.billing.createSubscription({
userId: 'user_123',
priceId: 'price_pro_monthly',
trialDays: 14,
})
console.log('Subscription ID:', subscription.id)
console.log('Status:', subscription.status)Report Usageusage.ts
typescript
// Report usage for metered billing
await sylphx.billing.reportUsage({
subscriptionId: 'sub_123',
quantity: 1000, // API calls used
timestamp: new Date(),
})Customer Portalportal.ts
typescript
// Generate customer portal link
const { url } = await sylphx.billing.createPortalSession({
customerId: 'cus_123',
returnUrl: 'https://app.example.com/settings',
})
// Redirect user to Stripe-hosted portal
window.location.href = urlLooking for more examples?
View on GitHub