Skip to content

Card doctype#1282

Open
vitorrgg wants to merge 2 commits into
masterfrom
card_doctype
Open

Card doctype#1282
vitorrgg wants to merge 2 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...

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