feat: the Site takes credit card and PIX only, no debit

Dropstar does not take debit cards, and Mercado Pago never enabled debit on
the account, so a customer who chose "Cartão de débito" met an error. The
payment page offers credit card and PIX, the card form accepts only credit
cards, and the server refuses a debit method sent around the page. The
adapter still knows how to pay by debit, should it be offered again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-05 15:27:45 -03:00
parent ac1d8743b1
commit 43d9a3c637
3 changed files with 15 additions and 7 deletions

View File

@@ -439,7 +439,8 @@
// Paying: card (the default, paid on this page) or PIX (paid on its own page).
async function escolhaPagamento(quote, version) {
const session=await ready;
const opcoes=[...(session.payment_public_key?[['credito','Cartão de crédito'],['debito','Cartão de débito']]:[]),['pix','PIX']];
// Credit card and PIX: the store does not take debit cards.
const opcoes=[...(session.payment_public_key?[['credito','Cartão de crédito']]:[]),['pix','PIX']];
let escolhido=opcoes[0][0];
const grupo=node('div',null,'metodos');
grupo.setAttribute('role','radiogroup'); grupo.setAttribute('aria-label','Forma de pagamento');
@@ -454,7 +455,7 @@
async function pinta() {
radios.forEach(el=>el.setAttribute('aria-checked',String(el.dataset.metodo===escolhido)));
unmountCard(); area.replaceChildren(); message('');
if (escolhido!=='pix') { await showCard(quote.approved, area, version, escolhido); return; }
if (escolhido!=='pix') { await showCard(quote.approved, area, version); return; }
area.append(node('p','Clique em Pagar para gerar o QR code do PIX.','pagNota'));
button('Pagar',async event=>{
if (!cartOk()) { await refresh(); return; }
@@ -550,7 +551,7 @@
function unmountCard() {
if (cardBrick) { try { cardBrick.unmount(); } catch(_) {} cardBrick=null; }
}
async function showCard(approved, into, version, tipo) {
async function showCard(approved, into, version) {
const holder=node('div');
holder.id='cardPaymentBrick';
const espera=node('div',null,'skel skelBloco');
@@ -564,10 +565,8 @@
const mp=new window.MercadoPago(session.payment_public_key,{locale:'pt-BR'});
cardBrick=await mp.bricks().create('cardPayment','cardPaymentBrick',{
initialization:{amount:approved.total_cents/100, payer:{email:approved.customer.mail}},
// Each option takes only its kind of card; debit is paid at once.
customization:{paymentMethods:tipo==='debito'
? {maxInstallments:1,types:{excluded:['credit_card']}}
: {maxInstallments:12,types:{excluded:['debit_card']}},
// Credit cards only: the store does not take debit.
customization:{paymentMethods:{maxInstallments:12,types:{excluded:['debit_card']}},
// The option above already names the card; the form's own title
// ("crédito ou débito") would contradict it.
visual:{hideFormTitle:true,