fix: the Mercado Pago payer is the order's customer, with document and name, for PIX and card (checkout item 2)
All checks were successful
Build and deploy / Validate source (push) Successful in 1m42s
Build and deploy / Integration suite on a real stack (push) Successful in 8m39s
Build and deploy / Secret scan and release gate (push) Successful in 12s
Build and deploy / Publish images (push) Successful in 2m12s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m42s
Build and deploy / Integration suite on a real stack (push) Successful in 8m39s
Build and deploy / Secret scan and release gate (push) Successful in 12s
Build and deploy / Publish images (push) Successful in 2m12s
Marcus, 2026-11-18: finance reconciles the payment by the customer and the invoice is issued to them; half the payments showed 999.999.999-99 and no name. The payer now always carries the order's CPF or CNPJ, the first and last name from the order and the e-mail. The card form's document is no longer sent by the Site nor used (the cardholder's data travel in the card token); the field stays accepted for pages loaded before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,22 @@ PIX_MINUTES = 30
|
||||
BRASILIA = timezone(timedelta(hours=-3))
|
||||
|
||||
|
||||
def payer(customer):
|
||||
"""Who pays, as Dropstar's finance reconciles it and the invoice is issued
|
||||
(Marcus, 2026-11-18): the customer's own CPF or CNPJ from the order, with
|
||||
their name and e-mail, for PIX and card alike, never a placeholder such
|
||||
as 999.999.999-99. The card form's document is not the payer: the
|
||||
cardholder's data travel inside the card token."""
|
||||
document = customer['cnpj']
|
||||
who = {'email': customer['mail'],
|
||||
'identification': {'type': 'CPF' if len(document) == 11 else 'CNPJ', 'number': document}}
|
||||
names = (customer.get('name') or '').split()
|
||||
if names:
|
||||
who['first_name'] = names[0]
|
||||
who['last_name'] = ' '.join(names[1:]) or names[0]
|
||||
return who
|
||||
|
||||
|
||||
class MercadoPagoPayment:
|
||||
name = 'mercadopago'
|
||||
|
||||
@@ -76,9 +92,7 @@ class MercadoPagoPayment:
|
||||
body = {'transaction_amount': float(Decimal(total_cents) / 100),
|
||||
'description': f'DTF - cotação {quote_id[:8]}',
|
||||
'external_reference': quote_id,
|
||||
'payer': {'email': customer['mail'],
|
||||
'identification': {'type': 'CPF' if len(customer['cnpj']) == 11 else 'CNPJ',
|
||||
'number': customer['cnpj']}}}
|
||||
'payer': payer(customer)}
|
||||
if self.notification_url:
|
||||
body['notification_url'] = self.notification_url
|
||||
expires_at = None
|
||||
@@ -93,9 +107,6 @@ class MercadoPagoPayment:
|
||||
# it; asking it of every card was refused as a rule (10113).
|
||||
if method['payment_method_id'].startswith('deb'):
|
||||
body['three_d_secure_mode'] = 'optional'
|
||||
if method.get('payer_document_type') and method.get('payer_document'):
|
||||
body['payer']['identification'] = {'type': method['payer_document_type'],
|
||||
'number': method['payer_document']}
|
||||
# No issuer_id: Mercado Pago takes the issuer from the card number.
|
||||
# The form's suggestion was refused for its own test cards
|
||||
# (10111, "the issuer does not have the BIN configured").
|
||||
|
||||
Reference in New Issue
Block a user