-
Notifications
You must be signed in to change notification settings - Fork 1
Mercado Pago integration
Note
This document assumes you've checked the official documentation for guidance. This is based on the information I need for my solution and should not be considered as the only one. There's details about POS, Stores that you are not described and can be required depending on the solution you choose
Since I already have listed my finding about Dynamic QR Code I'm not gonna do it again 😄 The details can be found here https://github.com/soat-fiap/FIAP.TechChallenge.ByteMeBurger/discussions/90#discussion-6774154
After some more investigation I figured there's another way to do the integration and that might fit better for my needs on the flow I'm planning for the application. 🔍
The steps I listed above is useful when you're integration with local stores. Which is in fact what this app is supposed to do, a self checkout totem. The problem with that approach is that I don't know in advance the payment Id to update on my system bringing some more complexity to the code since I'd have to filter events and fetch the payment Id if I really want it or could do less and only use the merchant order status and that's it.
Only when I found this thread on Mercado Pago discord server I realized the solution was right there.
you can create a Payment and set the payment method as pix this will create the QRCode for you and return the PaymentId which for integration purposes that's exactly what I need.
This is the way to go if you also want to suppor payment with Credit Card
🗺️
- Create Payment
- Save Payment Id on the database
- Return QRCode
- User executes the payment
- Webhook receives message with Payment Information
- Validate webhook hmac signature
- Get Payment by id
- Update Payment status on database
Here is my implementation of a filter to validate MercadoPago's messages (TODO https://github.com/soat-fiap/FIAP.TechChallenge.ByteMeBurger/issues/98)
Most of details can be found on Mercado Pago's documentation https://www.mercadopago.com.br/developers/pt/reference
You can use this website to test your webhook messages initially. It also allows you to forward the messages to your local machine https://webhook.site/
https://www.mercadopago.com.br/developers/en/docs/your-integrations/notifications/webhooks
curl --location 'http://localhost/webhook?type=payment&data_id=999998' \
--header 'x-signature: ts=123123,v1=123123123132' \
--header 'x-request-id: 4100f590-06c4-48aa-b143-1c02f7da6e11' \
--header 'Content-Type: application/json' \
--data '{
"action": "payment.update",
"api_version": "v1",
"data": {
"id": "999998"
},
"date_created": "2021-11-01T02:02:02Z",
"id": "123456",
"live_mode": false,
"type": "payment",
"user_id": 22222
}'
If you find yourself lost in this Wiki, don't worry, we're all lost together.
- What's the Tech Challenge
- DDD Artifacts
- Event Storming
- Architecture
- Integrations
- Business Requirements