-
Hello, I'm currently developing a custom module to integrate NexoPOS with the Mercado Pago payment system. The goal is to enable POS users to initiate payments directly via Mercado Pago Point devices from within the system. While I’ve successfully registered the payment method using the ns-payment-methods hook and created a service class to handle the HTTP request to the Mercado Pago API, I still have a few uncertainties regarding the proper flow: How to correctly define and trigger the payment event within the POS when the user selects the Mercado Pago option. How to capture the finalized order data (such as order ID, total, and customer info) at the right moment to construct and send the payload to Mercado Pago’s /payment-intents endpoint. Any documentation, guidance, or examples on handling custom payment method integrations and hooking into the correct POS lifecycle events would be greatly appreciated. Thank you for your support! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey there, glad to have you there. 1 - Well, there is no proper way to trigger a payment event while just selecting a payment gateway. For NexoPOS, the payment is triggered when the order is being saved or after the order has been saved. We need to have the order created before we can proceed. In your scenario, I don't think it's an option. While clicking on Mercado Payment, we should trigger a payment and find a way to attach it to the order. 2 - NexoPOS triggers two event depending of the nature of the order:
3 - How i would have done this: If i have to make the payment before submitting the order on NexoPOS, what i will do is create a table where i store references of payments. Let's say we'll name that table "payment_references" with "reference_id", "amount" and "order_id" as column. Now when we do select the Mercato payment and submit the payment, we create an entry, but the order_id) is null as the order is not yet created. We'll make sure of the "POS.order" on the frontend, to add the reference to the current order. const reference = await createPaymetnReference(); // the reference object should actually have the reference created.
const order = POS.order.getValue();
order.payment_reference_id = reference.id. When the order is submitted, it's submitted with that reference. we now need to handle the attachment of the order to the payment. You'll use OrderBeforeCreatedEvent or OrderBeforeUpdatedEvent to get the current payload, which includes that reference. You'll then store that reference for a single use on the session, and on your listener that catch OrderAfterCreatedEvent or OrderAfterUpdatedEvent, you can now retrieve the order and the reference to update the "payment_references" with the order id. Not sure if that makes any sense. Good luck |
Beta Was this translation helpful? Give feedback.
Hey there, glad to have you there.
1 - Well, there is no proper way to trigger a payment event while just selecting a payment gateway. For NexoPOS, the payment is triggered when the order is being saved or after the order has been saved. We need to have the order created before we can proceed. In your scenario, I don't think it's an option. While clicking on Mercado Payment, we should trigger a payment and find a way to attach it to the order.
2 - NexoPOS triggers two event depending of the nature of the order:
3 - How i would have done this:
If i have to make…