Skip to content

Card doctype#1282

Merged
leomp12 merged 4 commits into
masterfrom
card_doctype
Jun 17, 2026
Merged

Card doctype#1282
leomp12 merged 4 commits into
masterfrom
card_doctype

Conversation

@vitorrgg

Copy link
Copy Markdown
Member

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.

image

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.

ecomplus-bot and others added 2 commits April 16, 2026 18:41
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>
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}'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nem sei se precisa ficar mudando pattern

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mas acho que não é problema também

},

cleaveOptions () {
if (this.allowBoth) return { blocks: [30] }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 leomp12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leomp12 leomp12 merged commit 36c8607 into master Jun 17, 2026
5 checks passed
@leomp12 leomp12 deleted the card_doctype branch June 17, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants