diff --git a/.changeset/fix-mercadopago-amount.md b/.changeset/fix-mercadopago-amount.md new file mode 100644 index 00000000..df539959 --- /dev/null +++ b/.changeset/fix-mercadopago-amount.md @@ -0,0 +1,5 @@ +--- +"@godaddy/react": patch +--- + +Fix MercadoPago amount conversion from minor units to major units. The SDK expects amounts in major units (e.g., 90.00 BRL) but we were sending minor units (e.g., 9000 cents). diff --git a/packages/react/src/components/checkout/payment/checkout-buttons/mercadopago/mercadopago.tsx b/packages/react/src/components/checkout/payment/checkout-buttons/mercadopago/mercadopago.tsx index 29ea7781..dfc9b657 100644 --- a/packages/react/src/components/checkout/payment/checkout-buttons/mercadopago/mercadopago.tsx +++ b/packages/react/src/components/checkout/payment/checkout-buttons/mercadopago/mercadopago.tsx @@ -3,6 +3,7 @@ import React, { useCallback, useLayoutEffect, useState } from 'react'; import { useFormContext } from 'react-hook-form'; import { useCheckoutContext } from '@/components/checkout/checkout'; import { useDraftOrderTotals } from '@/components/checkout/order/use-draft-order'; +import { formatCurrency } from '@/components/checkout/utils/format-currency'; import { PaymentProvider, useConfirmCheckout, @@ -96,7 +97,15 @@ export function MercadoPagoCheckoutButton() { } else { // Create new brick const renderBrick = async () => { - const total = totals?.total?.value || 0; + // Convert from minor units (cents) to major units + const total = parseFloat( + formatCurrency({ + amount: totals?.total?.value || 0, + currencyCode: totals?.total?.currencyCode || 'USD', + inputInMinorUnits: true, + returnRaw: true, + }) + ); try { const container = document.getElementById(elementId);