- Add Stripe and Mercado Pago providers for handling subscriptions. - Create billing repository and access services for managing billing records. - Implement webhook handlers for processing events from Stripe and Mercado Pago. - Add routes for checkout, canceling subscriptions, and retrieving billing status. - Introduce billing status management with appropriate state transitions. - Create tests for billing functionalities including webhook idempotency and provider resolution. - Document the billing module architecture, environment variables, and API endpoints.
23 lines
573 B
TypeScript
23 lines
573 B
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
|
|
/**
|
|
* Helper that replicates the mapWebhookTypeToStatus logic
|
|
* used in webhook business files for testability.
|
|
*/
|
|
export function mapWebhookTypeToStatus(
|
|
eventType: 'activated' | 'updated' | 'payment_failed' | 'cancelled'
|
|
): 'ACTIVE' | 'PAST_DUE' | 'CANCELED' | null {
|
|
switch (eventType) {
|
|
case 'activated':
|
|
return 'ACTIVE';
|
|
case 'updated':
|
|
return 'ACTIVE';
|
|
case 'payment_failed':
|
|
return 'PAST_DUE';
|
|
case 'cancelled':
|
|
return 'CANCELED';
|
|
default:
|
|
return null;
|
|
}
|
|
}
|