From 44cb6ccc16f6a7110e87b23953c83af566eacc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 7 Oct 2026 15:00:00 -0300 Subject: [PATCH] feat: credit card payments in up to 3 installments Dropstar sells in up to 3 installments. The card form offers no more, and the server refuses a payment asking for more. Co-Authored-By: Claude Opus 5.5 --- app/core/models.py | 3 ++- tests/payment_test.py | 3 +++ web/checkout.js | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/core/models.py b/app/core/models.py index a125a4a..b50f43b 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -190,7 +190,8 @@ class PaymentMethod(StrictModel): # in the browser; the number never reaches this server. token: str | None = Field(default=None, max_length=200) payment_method_id: str | None = Field(default=None, max_length=40, pattern=r'^[a-z_]+$') - installments: int = Field(default=1, ge=1, le=12, strict=True) + # Up to 3, as Dropstar sells; the card form offers no more. + installments: int = Field(default=1, ge=1, le=3, strict=True) issuer_id: str | None = Field(default=None, max_length=40) # The cardholder's document from the card form: for a card, the payer is # the cardholder, not necessarily the company on the invoice. diff --git a/tests/payment_test.py b/tests/payment_test.py index f716f0b..26c35be 100644 --- a/tests/payment_test.py +++ b/tests/payment_test.py @@ -61,6 +61,9 @@ def run(): # Debit cards are not taken, even sent around the payment page. customer.call('/payments/intent', {'quote_id': quote_id, 'method': { 'type': 'card', 'token': 'tok', 'payment_method_id': 'debvisa'}}, expected=422) + # At most 3 installments. + customer.call('/payments/intent', {'quote_id': quote_id, 'method': { + 'type': 'card', 'token': 'tok', 'payment_method_id': 'visa', 'installments': 4}}, expected=422) # Starting a PIX twice returns the same one. A card in review blocks every # further attempt, so one quote can never be charged twice. diff --git a/web/checkout.js b/web/checkout.js index 55a00b7..3ff4cff 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -574,8 +574,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}}, - // Credit cards only: the store does not take debit. - customization:{paymentMethods:{maxInstallments:12,types:{excluded:['debit_card']}}, + // Credit cards only, in up to 3 installments, as Dropstar decided. + customization:{paymentMethods:{maxInstallments:3,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,