Skip to content

Commit

Permalink
fix(mercadopago): Setting X-Idempotency-Key on transaction with ord…
Browse files Browse the repository at this point in the history
…er ID
  • Loading branch information
leomp12 committed Jan 20, 2025
1 parent ffa3cad commit 77941d5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/apps/mercadopago/src/mp-create-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default async (appData: AppModuleBody) => {
},
},
external_reference: String(params.order_number),
transaction_amount: params.amount.total,
transaction_amount: Math.round(params.amount.total * 100) / 100,
description: `Pedido #${params.order_number} de ${buyer.fullname}`.substring(0, 60),
payment_method_id: paymentMethodId,
token,
Expand Down Expand Up @@ -161,9 +161,10 @@ export default async (appData: AppModuleBody) => {
const headers = {
Authorization: `Bearer ${process.env.MERCADOPAGO_TOKEN}`,
'Content-Type': 'application/json',
'X-Idempotency-Key': orderId,
};
if (deviceId) {
Object.assign(headers, { 'X-meli-session-id': deviceId });
headers['X-Meli-Session-Id'] = deviceId;
}
// https://www.mercadopago.com.br/developers/pt/reference/payments/_payments/post
const { data } = await axios({
Expand Down

0 comments on commit 77941d5

Please sign in to comment.