feat: add subscription API endpoints and grace period job - M3 (refs #55)
API Endpoints (all authenticated): - GET /api/subscriptions - current subscription status - POST /api/subscriptions/checkout - create Stripe subscription - POST /api/subscriptions/cancel - schedule cancellation at period end - POST /api/subscriptions/reactivate - cancel pending cancellation - PUT /api/subscriptions/payment-method - update payment method - GET /api/subscriptions/invoices - billing history Grace Period Job: - Daily cron at 2:30 AM to check expired grace periods - Downgrades to free tier when 30-day grace period expires - Syncs tier to user_profiles.subscription_tier Email Templates: - payment_failed_immediate (first failure) - payment_failed_7day (7 days before grace ends) - payment_failed_1day (1 day before grace ends) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -323,4 +323,32 @@ export class StripeClient {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List invoices for a customer
|
||||
*/
|
||||
async listInvoices(customerId: string): Promise<any[]> {
|
||||
try {
|
||||
logger.info('Listing Stripe invoices', { customerId });
|
||||
|
||||
const invoices = await this.stripe.invoices.list({
|
||||
customer: customerId,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
logger.info('Stripe invoices retrieved', {
|
||||
customerId,
|
||||
count: invoices.data.length
|
||||
});
|
||||
|
||||
return invoices.data;
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to list Stripe invoices', {
|
||||
customerId,
|
||||
error: error.message,
|
||||
code: error.code,
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user