Projects

Last update

Projects

Better Auth + MercadoPago

Plugin that resolves the friction between authentication and billing, providing a type-safe abstraction layer for MercadoPago within Better Auth.

TypeScriptZodBiomeJSBetter AuthMercadoPagoTsup

The Payments Integration Problem

Integrating payment gateways often introduces immediate technical debt:

  • "Black Box" Webhooks: Untyped payloads that break at runtime.
  • Scattered Logic: Payment controllers mixed with business logic.
  • Desynchronization: User state in the DB doesn't match the state in the gateway.

The Solution: Infrastructure as Code

This plugin is not just a wrapper; it's a piece of infrastructure that standardizes how your application handles money.

Type-Safe Architecture

Using Zod and TypeScript, every interaction with the MercadoPago API is validated. If the payment schema changes, your build fails before it reaches production.

Design Principles

  1. Strict Decoupling: Billing logic lives isolated from product logic.
  2. Developer Experience (DX): Intelligent autocomplete for plans, subscriptions, and events.
  3. Unified Webhook Handler: A single endpoint to govern all payment events, with automatic cryptographic signature validation.

Technical Impact

  • Boilerplate Reduction: Eliminates +200 lines of repetitive integration code.
  • Security: Automatic validation of signatures and payloads.
  • Maintainability: Centralized updates to the MercadoPago SDK without touching product code.

Designed for teams that value robustness and security in their revenue flows.

On this page