Card doctype#1282
Merged
Merged
Conversation
Google Ads rejects string values in cart data fields (price, revenue, shipping, tax), causing "Item price formatted incorrectly or missing" errors. Wrap .toFixed(2) calls with parseFloat() to ensure numeric types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…try type Add allowBoth prop to InputDocNumber so the credit card holder doc field accepts free input (no forced mask). Document type is inferred by digit count at submit time: 11 digits = CPF, 14 digits = CNPJ. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
leomp12
reviewed
Jun 12, 2026
Comment on lines
+40
to
+42
| if (this.allowBoth) return '[\\d]{11}|[\\d]{14}' | ||
| if (this.isCompany) return '[\\d]{2}\\..{15}' | ||
| return '[\\d]{3}\\..{10}' |
Member
There was a problem hiding this comment.
Nem sei se precisa ficar mudando pattern
Member
There was a problem hiding this comment.
Mas acho que não é problema também
| }, | ||
|
|
||
| cleaveOptions () { | ||
| if (this.allowBoth) return { blocks: [30] } |
Member
There was a problem hiding this comment.
Aqui vai deixar a visualização ruim, mas funciona...
Add cardDocAllowBoth prop to CreditCardForm defaulting to window.ecomCreditCardDocAllowBoth === true, keeping the original mask-by-registry-type behavior unless explicitly opted in. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
leomp12
approved these changes
Jun 17, 2026
leomp12
left a comment
Member
There was a problem hiding this comment.
No-op por padrão confirmado: is-company="!cardDocAllowBoth && isCompany" reduz a isCompany e allow-both fica false sem window.ecomCreditCardDocAllowBoth. Todos os ramos novos em InputDocNumber (placeholder/pattern/isInvalid/cleaveOptions) estão gated por allowBoth, e o caminho legado preserva comportamento idêntico (inclusive o replace(/D/g,'') movido para docNumberLegacy). Lint (standard) e build OK localmente.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clientes PJ (cadastro com CNPJ) não conseguiam pagar com cartão de crédito pessoal (CPF), pois o campo "Documento do titular" era renderizado com máscara e pattern derivados do registry_type do cadastro — forçando CNPJ para clientes jurídicos e CPF para físicos.
A correção adiciona o prop allowBoth ao componente InputDocNumber. Quando ativo, o campo:
exibe placeholder="CPF / CNPJ" sem máscara forçada;
aceita exatamente 11 ou 14 dígitos (pattern="[\d]{11}|[\d]{14}");
valida matematicamente como CPF (11 dígitos) ou CNPJ (14 dígitos) usando @brazilian-utils/brazilian-utils;
envia ao gateway apenas os dígitos puros (doc.replace(/\D/g, '')), que já é o comportamento existente do emitCardData.
O prop é utilizado exclusivamente em CreditCardForm.html. Os demais usos de InputDocNumber (AccountForm, LoginBlock) não são afetados.
Campo antes (cliente PJ, máscara CNPJ forçada):
placeholder CNPJ, pattern [\d]{2}..{15} — CPF pessoal rejeitado pelo browser.
Campo depois:
placeholder CPF / CNPJ, sem máscara — aceita ambos os tipos.
Payload validado em teste real com cliente PJ (registry_type: "j", buyer.doc_number com 14 dígitos) usando CPF pessoal no titular do cartão (payer.doc_number com 11 dígitos) — gateway recebeu e processou corretamente.