
Meses Sin Intereses API Integration: Architecture and Data Model
If you are adding Mexican installments to a checkout, the hard part is not the button. A solid meses sin intereses API integration has to answer questions the UI never shows: which plans can this order get, which plan did the bank actually approve, what did that plan cost you, and what happens when a webhook arrives twice or a customer asks for a refund. This guide covers the system behind it: the data model, the two-step confirmation flow, webhook handling, margin rules and the mistakes that show up in production.
The examples use Stripe because its documentation for Mexico is public and detailed, but the architecture applies to any processor. If you need the business side first (what each plan costs and how to set it up in a store), read our guide to offering meses sin intereses in an online store.
How installments look from the system's side
Before designing anything, pin down the facts your code depends on. According to Stripe's Mexico installments documentation:
- Installments are only supported for Stripe Mexico accounts, and the payment method must be a credit card issued in Mexico.
- They work through the Payment Intents and Payment Methods APIs, Checkout, Invoicing, Payment Element and Payment Links.
- In a Stripe-hosted payment UI, the installments option only appears after the customer enters a supported card number.
- The doc lists default minimum transaction amounts and an additional fee per plan length, on top of the standard card fee: 3 months (300 MXN, 5%), 6 months (600 MXN, 7.5%), 9 months (900 MXN, 10%), 12 months (1,200 MXN, 12.5%), 18 months (1,800 MXN, 17.5%) and 24 months (2,400 MXN, 22.5%). The same percentages appear on Stripe's local payment methods pricing page. Check both pages before you hardcode anything, because fees change.
Stripe's installments overview adds the most important point for your ledger: you receive the full amount (minus the fee) as with a normal charge, and the customer's bank collects the money over time. So you are not building a credit system. You are building a pricing and eligibility layer on top of a single card charge.
That has three consequences:
- Eligibility depends on the card, which you only know after the customer enters it. Your flow needs a step between "card entered" and "payment confirmed".
- Cost depends on the plan chosen, so you only know the margin at confirmation time.
- The plan is part of the payment record, not the order. One order can have several payment attempts with different plans.
A data model that survives audits
Keep three concerns separate: your plan rules, what was offered, and what was charged.
-- Your business rules: which plans you are willing to offer
CREATE TABLE installment_plan_rules (
id BIGSERIAL PRIMARY KEY,
months SMALLINT NOT NULL, -- 3, 6, 9, 12...
min_amount_cents BIGINT NOT NULL, -- your minimum, >= processor minimum
max_amount_cents BIGINT,
fee_bps INTEGER NOT NULL, -- 500 = 5.00%, copied from processor pricing
active BOOLEAN NOT NULL DEFAULT true,
valid_from TIMESTAMPTZ NOT NULL,
valid_to TIMESTAMPTZ
);
-- One row per attempt to pay an order
CREATE TABLE payment_attempts (
id BIGSERIAL PRIMARY KEY,
order_id BIGINT NOT NULL REFERENCES orders(id),
provider TEXT NOT NULL, -- 'stripe'
provider_intent_id TEXT UNIQUE,
amount_cents BIGINT NOT NULL,
currency CHAR(3) NOT NULL,
status TEXT NOT NULL, -- created | requires_plan | processing | succeeded | failed
offered_plans JSONB, -- snapshot of plans shown to the buyer
selected_months SMALLINT, -- what the buyer chose (null = single payment)
charged_months SMALLINT, -- what the processor reports on the charge
fee_bps_snapshot INTEGER, -- rule in force when the buyer confirmed
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE processed_webhook_events (
event_id TEXT PRIMARY KEY,
received_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
Design notes:
- Store money as integers in minor units. Stripe's API takes amounts in the smallest currency unit, and integer math avoids rounding drift when you compute fees.
- Version the rules with
valid_from/valid_toinstead of updating rows. When finance asks why an order from last quarter had a 12-month option, you can answer. - Snapshot the fee at confirmation. Never recompute historical margin from today's rule table.
- Keep
selected_monthsandcharged_monthsseparate. The first is what your UI sent. The second is what the processor confirms on the charge. If they differ, that is a bug or an edge case you want to see.
Two layers of eligibility
A plan is shown only if it passes both your rules and the processor's check for that specific card. Compute the intersection on the server, never in the browser.
type Plan = { count: number; interval: 'month'; type: 'fixed_count' };
function plansToOffer(
orderCents: number,
processorPlans: Plan[], // from the processor, card-specific
rules: PlanRule[], // active rules from your DB
cart: CartLine[]
): Plan[] {
if (cart.some(l => l.excludedFromInstallments)) return [];
return processorPlans.filter(p => {
const rule = rules.find(r => r.months === p.count);
if (!rule) return false; // you don't offer it
if (orderCents < rule.minAmountCents) return false;
if (rule.maxAmountCents && orderCents > rule.maxAmountCents) return false;
return true;
});
}
Your own rules exist because the processor's minimums don't account for your margin. A product with a thin margin may not survive a long-plan fee even if the bank would approve it. Stripe also lets you configure the monthly plans and per-plan minimum and maximum amounts in the Dashboard, and that configuration applies to all your installments integrations. Pick one source of truth. One workable pattern is to keep the Dashboard permissive and enforce margin rules in your code, where they are versioned and tested.
The two-step confirmation flow
With the Payment Intents API, the flow documented by Stripe goes like this: collect the card on the client, create the PaymentIntent with installments enabled, read the plans available for that card, let the customer choose, then confirm with the chosen plan.
// Step 1: server, after the client sends a PaymentMethod id
const intent = await stripe.paymentIntents.create(
{
amount: order.totalCents,
currency: 'mxn',
payment_method: paymentMethodId,
payment_method_options: { card: { installments: { enabled: true } } },
metadata: { order_id: String(order.id), attempt_id: String(attempt.id) },
},
{ idempotencyKey: `pi-create-${attempt.id}` }
);
const available = intent.payment_method_options.card.installments.available_plans;
const offered = plansToOffer(order.totalCents, available, rules, order.lines);
await savePlansOffered(attempt.id, intent.id, offered); // status = requires_plan
return { intentId: intent.id, plans: offered };
// Step 2: server, after the customer picks a plan (or none)
const attempt = await loadAttempt(attemptId);
const chosen = attempt.offered_plans.find(p => p.count === body.months) ?? null;
if (body.months && !chosen) throw new Error('Plan not offered for this attempt');
await markProcessing(attempt.id, chosen?.count ?? null, feeFor(chosen));
const confirmed = await stripe.paymentIntents.confirm(
attempt.provider_intent_id,
{ payment_method_options: { card: { installments: { plan: chosen } } } },
{ idempotencyKey: `pi-confirm-${attempt.id}` }
);
Points to note:
- Validate the plan against the server-side snapshot. The client only sends a number of months. Never accept a plan object from the browser and pass it through.
- Tie idempotency keys to the attempt, not to the request. A double click or a retry after a timeout returns the same result instead of creating a second charge. Stripe documents this in its idempotent requests reference.
- Handle 3D Secure. The confirm call can return a status that needs customer action. Your step 2 must hand that back to the client, not mark the order as failed.
- Hosted alternative. If you use Checkout instead, Stripe notes that installments only work in payment mode, not setup or subscription mode. That rules installments out for recurring billing through Checkout.
Webhooks: the charge is the source of truth
The response to confirm is useful for UX, but the order should move to "paid" only from a webhook. Network timeouts, closed tabs and 3D Secure redirects all mean your synchronous path may never finish.
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
let event;
try {
event = stripe.webhooks.constructEvent(req.body, req.headers['stripe-signature'], secret);
} catch {
return res.status(400).end();
}
const inserted = await db.query(
'INSERT INTO processed_webhook_events (event_id) VALUES ($1) ON CONFLICT DO NOTHING',
[event.id]
);
if (inserted.rowCount === 0) return res.status(200).end(); // duplicate
if (event.type === 'payment_intent.succeeded') {
const pi = await stripe.paymentIntents.retrieve(event.data.object.id, { expand: ['latest_charge'] });
const plan = pi.latest_charge.payment_method_details.card.installments?.plan ?? null;
await markSucceeded(pi.metadata.attempt_id, plan?.count ?? null);
}
res.status(200).end();
});
Rules for this handler:
- Verify the signature against the raw body, as described in Stripe's webhook docs. Parsing the JSON first breaks verification.
- Deduplicate by event ID, in the same transaction as the state change if you can. Stripe can deliver the same event more than once.
- Read the plan from the charge, not from your own
selected_months. Store it incharged_monthsand alert when the two differ. - Make state transitions one-way. A late
payment_failedmust not overwritesucceeded. Guard updates withWHERE status IN (...).
Margin, display and reconciliation
Once charged_months and fee_bps_snapshot are stored, margin per order is simple arithmetic you can run in SQL. Two choices need an explicit decision from the business, and your code should make them configurable rather than implicit:
- Absorb or pass on the fee. If you raise the price for installment buyers, the amount changes after the card is entered. So you must update the PaymentIntent amount before confirmation, and the price shown must match what is charged. Keep the decision in a rule, not in scattered
ifstatements. - Monthly amount display. "12 x $X" is a number you calculate, but the customer goes by their bank statement. Label it as approximate and round consistently.
For reconciliation, pull balance transactions from the processor and join on provider_intent_id. Compare the fee you expected from fee_bps_snapshot with the fee the processor actually charged. A mismatch usually means pricing changed and your rule table did not.
Refunds, disputes and commissions
Refunds deserve their own design review. The bank and the processor decide how a refund affects an installment plan on the customer's statement. Read your processor's current documentation on refunds and disputes for installment payments before you promise customers anything. On your side, record refunds as separate ledger entries linked to the attempt. Also decide whether your margin reports treat the installment fee as recoverable or as a sunk cost.
This matters a lot in network marketing. If your store pays commissions to distributors, the compensation engine needs a clear rule: does an installments order count toward volume when it is paid, and what happens to that volume after a refund? Because the merchant receives the full amount up front, a common approach is to credit volume at payment and reverse it on refund, but that is a policy choice your compensation plan has to state. On a network marketing platform with store, compensation plans and payments, these rules live in one place. When they are split between a store plugin and a separate commissions spreadsheet, refunded installment orders are where the numbers drift.
Supporting more than one processor
Some stores run two processors for redundancy or coverage. If you do, define a small interface around the concepts above instead of leaking one provider's object shapes into your domain:
interface InstallmentsProvider {
createAttempt(order: Order, paymentMethodToken: string): Promise<{ ref: string; plans: number[] }>;
confirm(ref: string, months: number | null): Promise<ConfirmResult>;
parseWebhook(raw: Buffer, headers: Headers): Promise<NormalizedEvent | null>;
}
The trade-off: an abstraction lets you switch or add providers, but it hides features that exist only in one of them. Keep the interface narrow (months as a number, amounts in cents, a normalized event) and accept provider-specific code in the adapters. If the abstraction grows as large as the providers' APIs, you have built a third payment API to maintain. When this layer starts touching ERP, invoicing and commissions, it is usually a custom software project rather than a plugin setting.
Common mistakes
- Hardcoding fees and minimums in the frontend.
- Trusting the plan sent by the browser.
- Marking orders paid from the
confirmresponse instead of a webhook. - No idempotency key on create and confirm.
- Recomputing past margin with current fees.
- Ignoring 3D Secure states in the installments flow.
- Assuming installments work for subscriptions.
Implementation checklist
- Rules table with versioned plans, minimums and fees in basis points
- Server-side intersection of your rules and card-specific plans
- Offered plans snapshotted per attempt
- Idempotency keys on every create and confirm call
- Webhook signature verification on the raw body
- Event ID deduplication and one-way status transitions
charged_monthsread from the charge and compared toselected_months- Reconciliation job comparing expected and actual fees
- Written policy for refunds, fees and commission volume
- Test cases for single payment, each plan, 3DS and duplicate webhooks
Frequently asked questions
Can I offer meses sin intereses on subscriptions?
Not through Stripe Checkout. Stripe's documentation says installments only work in payment mode, not setup or subscription mode. Treat installments as a feature for one-time purchases.
Do I receive the money monthly?
No. According to Stripe, you receive the full amount minus the fee, as with a normal charge, and the customer's bank collects over time. Your ledger records one payment.
Where should plan minimums live, in the Dashboard or in my code?
Pick one source of truth. One workable pattern is to keep the processor configuration permissive and enforce margin-based minimums in versioned server-side rules, so you can test and audit them.
Comments
No comments yet. Be the first to share what you think.


