sequenceDiagram
participant FE as Frontend
participant API as ERP API (/orders,/checkout)
participant OMS as ERP Orders/Invoices
participant MP as Mercado Pago
FE->>API: POST /orders (cart, buyer)
API->>OMS: Create draft order/invoice
API->>MP: POST /checkout/preferences (access_token)
MP-->>API: preference_id, init_point
API-->>FE: {preference_id, init_point}
FE->>MP: Redirect to init_point (payment UI)
MP-->>FE: Return to back_urls (success/pending/failure)
MP-->>API: Webhook { type: "payment", data.id }
API->>MP: GET /v1/payments/{id}
MP-->>API: status=approved|pending|rejected, external_reference
API->>OMS: Update order/invoice status
API-->>FE: (optional) FE polls /orders/{id} for final state
the credit card payment be mocked to work as follows
https://www.mercadopago.com.mx/developers/en/docs/checkout-api-v2/overview
sequenceDiagram participant FE as Frontend (web/app) participant BE as Backend API participant ERP as ERP participant MP as Mercado Pago FE->>BE: POST /orders (carrito/cliente) BE->>ERP: Crear Pedido/Factura borrador BE->>MP: Crear Preference/Order (access_token) MP-->>BE: preference_id / init_point BE-->>FE: {preference_id, init_point} FE->>MP: Inicia pago (Brick/SDK o redirect con preference_id) MP-->>FE: Resultado UI (return a back_urls) MP-->>BE: Webhook (topic: payments/orders) BE->>MP: GET /payments/{id} o /merchant_orders/{id} MP-->>BE: Detalle estado (approved/pending/rejected) BE->>ERP: Marcar factura/pedido según estado BE-->>FE: (opcional) Poll/consulta estado para mostrar "Pago aprobado"if the backend and erp are the same (e.g. ) headless
sequenceDiagram participant FE as Frontend participant API as ERP API (/orders,/checkout) participant OMS as ERP Orders/Invoices participant MP as Mercado Pago FE->>API: POST /orders (cart, buyer) API->>OMS: Create draft order/invoice API->>MP: POST /checkout/preferences (access_token) MP-->>API: preference_id, init_point API-->>FE: {preference_id, init_point} FE->>MP: Redirect to init_point (payment UI) MP-->>FE: Return to back_urls (success/pending/failure) MP-->>API: Webhook { type: "payment", data.id } API->>MP: GET /v1/payments/{id} MP-->>API: status=approved|pending|rejected, external_reference API->>OMS: Update order/invoice status API-->>FE: (optional) FE polls /orders/{id} for final stateSo here is what to mock