diff --git a/common/api.js b/common/api.js index 3f05d17..aa905f0 100644 --- a/common/api.js +++ b/common/api.js @@ -939,11 +939,19 @@ var default_api = 'https://api.global-interaction.com/'; ]); } - function normalizeAmountUsd(value) { - var amount = Number(value || 0); + function normalizeFormattedNumber(value) { + // Yumi legacy commodity responses can serialize large numeric values with + // thousands separators (for example, "27,600,000"). Normalizing at the + // adapter boundary preserves the server's numeric value before display + // and order payload fields independently fall back to zero. + var amount = Number(String(value || 0).replace(/,/g, '')); return Number.isFinite(amount) && amount > 0 ? amount : 0; } + function normalizeAmountUsd(value) { + return normalizeFormattedNumber(value); + } + function decimalToMinor(value) { return Math.round(normalizeAmountUsd(value) * 100); } @@ -1042,8 +1050,10 @@ var default_api = 'https://api.global-interaction.com/'; options = options || {}; var products = (options.commodity || options.products || []).map( function (item) { - var content = Number(item.content || 0); - var awardContent = Number( + // Coin quantities use the same formatter because Yumi returns + // content as a comma-formatted string while the UI expects a number. + var content = normalizeFormattedNumber(item.content); + var awardContent = normalizeFormattedNumber( item.awardContent || item.award_content || 0 ); var amountUsd = normalizeAmountUsd(