feat(billing): proveedores intercambiables (Mercado Pago en AR, Stripe en el resto)
- Puerto BillingProvider con adaptadores de Mercado Pago (/preapproval) y Stripe (Checkout en modo suscripción, fetch plano). El país elige proveedor solo para suscripciones nuevas; sync, cancel y webhook usan row.provider. - Migración add_billing_providers (provider, checkout_ref, ids genéricos). - fix: /authorized_payments/search respondía 400 "Invalid value for limit"; se pagina por offset sin limit. - fix: si falla la consulta de cobros, la sync guarda igual el estado de la suscripción (ya no queda PENDING tras autorizar) y reintenta los cobros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,12 +41,16 @@ export class ReconcileSubscriptions {
|
||||
const staleCutoff = new Date(now.getTime() - AUTHORIZED_STALE_MS);
|
||||
const rows = await db.billingSubscription.findMany({
|
||||
where: {
|
||||
mpPreapprovalId: { not: null },
|
||||
OR: [
|
||||
{ status: 'PENDING' },
|
||||
AND: [
|
||||
{ OR: [{ externalId: { not: null } }, { checkoutRef: { not: null } }] },
|
||||
{
|
||||
status: { in: ['AUTHORIZED', 'PAUSED'] },
|
||||
OR: [{ lastSyncedAt: null }, { lastSyncedAt: { lt: staleCutoff } }],
|
||||
OR: [
|
||||
{ status: 'PENDING' },
|
||||
{
|
||||
status: { in: ['AUTHORIZED', 'PAUSED'] },
|
||||
OR: [{ lastSyncedAt: null }, { lastSyncedAt: { lt: staleCutoff } }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user