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 <noreply@anthropic.com>
This commit is contained in:
@@ -190,7 +190,8 @@ class PaymentMethod(StrictModel):
|
|||||||
# in the browser; the number never reaches this server.
|
# in the browser; the number never reaches this server.
|
||||||
token: str | None = Field(default=None, max_length=200)
|
token: str | None = Field(default=None, max_length=200)
|
||||||
payment_method_id: str | None = Field(default=None, max_length=40, pattern=r'^[a-z_]+$')
|
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)
|
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's document from the card form: for a card, the payer is
|
||||||
# the cardholder, not necessarily the company on the invoice.
|
# the cardholder, not necessarily the company on the invoice.
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ def run():
|
|||||||
# Debit cards are not taken, even sent around the payment page.
|
# Debit cards are not taken, even sent around the payment page.
|
||||||
customer.call('/payments/intent', {'quote_id': quote_id, 'method': {
|
customer.call('/payments/intent', {'quote_id': quote_id, 'method': {
|
||||||
'type': 'card', 'token': 'tok', 'payment_method_id': 'debvisa'}}, expected=422)
|
'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
|
# Starting a PIX twice returns the same one. A card in review blocks every
|
||||||
# further attempt, so one quote can never be charged twice.
|
# further attempt, so one quote can never be charged twice.
|
||||||
|
|||||||
@@ -574,8 +574,8 @@
|
|||||||
const mp=new window.MercadoPago(session.payment_public_key,{locale:'pt-BR'});
|
const mp=new window.MercadoPago(session.payment_public_key,{locale:'pt-BR'});
|
||||||
cardBrick=await mp.bricks().create('cardPayment','cardPaymentBrick',{
|
cardBrick=await mp.bricks().create('cardPayment','cardPaymentBrick',{
|
||||||
initialization:{amount:approved.total_cents/100, payer:{email:approved.customer.mail}},
|
initialization:{amount:approved.total_cents/100, payer:{email:approved.customer.mail}},
|
||||||
// Credit cards only: the store does not take debit.
|
// Credit cards only, in up to 3 installments, as Dropstar decided.
|
||||||
customization:{paymentMethods:{maxInstallments:12,types:{excluded:['debit_card']}},
|
customization:{paymentMethods:{maxInstallments:3,types:{excluded:['debit_card']}},
|
||||||
// The option above already names the card; the form's own title
|
// The option above already names the card; the form's own title
|
||||||
// ("crédito ou débito") would contradict it.
|
// ("crédito ou débito") would contradict it.
|
||||||
visual:{hideFormTitle:true,
|
visual:{hideFormTitle:true,
|
||||||
|
|||||||
Reference in New Issue
Block a user