Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-mercadopago-amount.md
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Loading