diff --git a/src/utils/__tests__/withdraw.utils.test.ts b/src/utils/__tests__/withdraw.utils.test.ts index 5da97f3f4..da08bd091 100644 --- a/src/utils/__tests__/withdraw.utils.test.ts +++ b/src/utils/__tests__/withdraw.utils.test.ts @@ -79,6 +79,9 @@ describe('Withdraw Utilities', () => { // Should keep existing + prefix ['+5511999999999', '+5511999999999'], ['+551199999999', '+551199999999'], + // Should strip separators even when the + prefix is already present + ['+55-11-99999-9999', '+5511999999999'], + ['+55 11 99999 9999', '+5511999999999'], // Should not modify non-phone formats ['12345678901', '12345678901'], // CPF ['12345678901234', '12345678901234'], // CNPJ diff --git a/src/utils/withdraw.utils.ts b/src/utils/withdraw.utils.ts index 9130416c6..bde51d4dc 100644 --- a/src/utils/withdraw.utils.ts +++ b/src/utils/withdraw.utils.ts @@ -212,10 +212,11 @@ export const isPixPhoneNumber = (pixKey: string): boolean => { */ export const normalizePixPhoneNumber = (pixKey: string): string => { const cleaned = pixKey.replace(/[\s-]/g, '') - if (isPixPhoneNumber(cleaned) && !cleaned.startsWith('+')) { - return '+' + cleaned - } - return pixKey + if (!isPixPhoneNumber(cleaned)) return pixKey + // Always return the separator-free +55 form. The old code returned the raw + // input untouched when it already started with '+', so inputs like + // '+55-11-99999-9999' kept their separators and stayed non-canonical. + return cleaned.startsWith('+') ? cleaned : '+' + cleaned } /**