Skip to content

Testing Credit Card Module with Mercado Pago Mock #21

@n3wang

Description

@n3wang

the credit card payment be mocked to work as follows

https://www.mercadopago.com.mx/developers/en/docs/checkout-api-v2/overview

  • The front end such as done in wordpress
  • Then the front end will make a request to the backend to create the payment invoice and returns to front end the link with the mercado pago suit.
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"
Loading

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 state


Loading
Image

So here is what to mock

  • Create the proper endpoints on the erp to handle things as a backend, to confirm .e.g if you want the double confirmations of the pricing. and review that evertyhiing is on the backend (e.g. strict mode) Then erpnext in its own logic should be able to create the requests
  • Call from front end to Mercadopago to create the request
  • The response to be integrated with

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions