feat(billing): implement billing module with Stripe and Mercado Pago integration
- 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.
This commit is contained in:
36
apps/backend/test/billing/provider-resolver.test.ts
Normal file
36
apps/backend/test/billing/provider-resolver.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { mercadopagoBillingProvider } from '@/modules/billing/providers/mercadopago.provider';
|
||||
import { stripeBillingProvider } from '@/modules/billing/providers/stripe.provider';
|
||||
import { resolveProviderByCountry } from '@/modules/billing/services/provider-resolver.service';
|
||||
|
||||
describe('provider-resolver', () => {
|
||||
it('returns MERCADOPAGO for country AR', () => {
|
||||
const provider = resolveProviderByCountry('AR');
|
||||
expect(provider).toBe(mercadopagoBillingProvider);
|
||||
});
|
||||
|
||||
it('returns STRIPE for country BR', () => {
|
||||
const provider = resolveProviderByCountry('BR');
|
||||
expect(provider).toBe(stripeBillingProvider);
|
||||
});
|
||||
|
||||
it('returns STRIPE for country US', () => {
|
||||
const provider = resolveProviderByCountry('US');
|
||||
expect(provider).toBe(stripeBillingProvider);
|
||||
});
|
||||
|
||||
it('returns STRIPE for null country', () => {
|
||||
const provider = resolveProviderByCountry(null);
|
||||
expect(provider).toBe(stripeBillingProvider);
|
||||
});
|
||||
|
||||
it('returns STRIPE for empty country', () => {
|
||||
const provider = resolveProviderByCountry('');
|
||||
expect(provider).toBe(stripeBillingProvider);
|
||||
});
|
||||
|
||||
it('returns STRIPE for any other ISO code', () => {
|
||||
const provider = resolveProviderByCountry('CL');
|
||||
expect(provider).toBe(stripeBillingProvider);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user