Recurring Payments
Azotte's recurring payment system enables automated subscription billing with flexible scheduling, dunning management, and revenue optimization.
Subscription Models
Fixed Recurring
- Monthly: Standard monthly billing cycles
- Quarterly: Every 3 months billing
- Annual: Yearly subscription charges
- Custom: Define custom billing intervals
Usage-Based Billing
- Metered: Pay per usage metrics
- Tiered: Progressive pricing tiers
- Volume: Bulk pricing discounts
- Hybrid: Combination of fixed + usage
Flexible Scheduling
- Pro-rata: Mid-cycle adjustments
- Anniversary: Customer-specific billing dates
- Calendar: Fixed calendar dates
- Business Days: Skip weekends/holidays
Subscription Lifecycle
Creation & Setup
interface Subscription {
id: string;
customer_id: string;
plan_id: string;
status: 'active' | 'paused' | 'cancelled' | 'past_due';
billing_cycle: 'monthly' | 'quarterly' | 'annual';
start_date: Date;
next_billing_date: Date;
amount: number;
currency: string;
}
State Transitions
Payment Collection
Automatic Retries
- Smart retry logic based on failure reasons
- Configurable retry intervals and attempts
- Payment method updating and optimization
Dunning Management
interface DunningConfig {
max_attempts: number;
retry_intervals: number[]; // days
email_notifications: boolean;
webhook_notifications: boolean;
grace_period_days: number;
}
Payment Method Updates
- Automatic card updating services
- Customer self-service portal
- Email notifications for expiring cards
Pricing & Discounts
Promotional Pricing
- Free Trials: 14-day, 30-day trials
- Discount Coupons: Percentage or fixed amount
- Grandfather Pricing: Legacy plan protection
- Volume Discounts: Multi-seat pricing
Price Changes
interface PriceChange {
subscription_id: string;
new_price: number;
effective_date: Date;
proration_policy: 'immediate' | 'next_cycle' | 'none';
customer_notification: boolean;
}
Revenue Recognition
Accounting Integration
- Deferred Revenue: Proper revenue recognition
- Proration Calculations: Mid-cycle changes
- Tax Handling: Regional tax compliance
- Refund Processing: Automated refund calculations
Reporting & Analytics
- Monthly Recurring Revenue (MRR)
- Annual Recurring Revenue (ARR)
- Churn rate analysis
- Customer Lifetime Value (CLV)
Webhook Events
Subscription Events
{
"event": "subscription.created",
"data": {
"subscription_id": "sub_123",
"customer_id": "cus_456",
"status": "active",
"plan": {
"id": "plan_basic",
"amount": 2999,
"interval": "monthly"
}
}
}
Payment Events
payment.succeededpayment.failedpayment.retry_scheduledinvoice.created
Customer Communications
Email Notifications
- Payment confirmations
- Failed payment alerts
- Upcoming renewal notices
- Plan change confirmations
Self-Service Portal
- View billing history
- Update payment methods
- Change subscription plans
- Download invoices
API Examples
Create Subscription
const subscription = await azotte.subscriptions.create({
customer_id: 'cus_123',
plan_id: 'plan_basic',
payment_method: 'pm_456',
start_date: '2024-01-01',
trial_period_days: 14
});
Update Subscription
await azotte.subscriptions.update('sub_123', {
plan_id: 'plan_premium',
proration_behavior: 'create_prorations'
});
Cancel Subscription
await azotte.subscriptions.cancel('sub_123', {
at_period_end: true,
cancellation_reason: 'customer_request'
});
Advanced Features
Subscription Pausing
- Temporary subscription holds
- Automatic resumption scheduling
- Pro-rated billing adjustments
Plan Migrations
- Seamless plan upgrades/downgrades
- Custom migration rules
- Proration handling
Multi-Product Subscriptions
- Bundle multiple products
- Individual product management
- Flexible pricing combinations
Testing
Test Scenarios
- Successful recurring payments
- Failed payment handling
- Dunning management flow
- Plan changes and cancellations
Webhook Testing
// Test webhook endpoint
const testWebhook = {
url: 'https://myapp.com/webhooks/azotte',
events: ['subscription.*', 'payment.*']
};
Next Steps
- Learn about Payment Methods
- Understand Payment Lifecycle
- Explore Campaign Engine