From 2c0dd7209813c97341acec2e93224716e207e5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 1 Dec 2026 11:20:29 -0300 Subject: [PATCH] fix: a Site order names no Mercado Pago account in Tiny again; Tiny did not find 977344550 (DTF-API-C) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tiny refused #196 (card) and #198 (Pix) with "Meio de pagamento não encontrado" on parcelas[0].meioPagamento.id. The payload is now the same as before 2026-12-01's Tiny change; both orders go through on their next try. Co-Authored-By: Claude Opus 5.5 --- app/tiny.py | 12 +++--------- tests/test_tiny.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/tiny.py b/app/tiny.py index 5cf27f9..4d4ea45 100644 --- a/app/tiny.py +++ b/app/tiny.py @@ -150,11 +150,9 @@ PICKUP_EXACT = 'retirar pessoalmente' _BOLETO = os.environ.get('TINY_RECEIPT_BOLETO', '').strip() RECEIPT_METHODS = {'pix': 919478952, 'card': 977460722, 'cash': 919478944, 'credit': 987762591, **({'faturado': int(_BOLETO)} if _BOLETO.isdigit() else {})} -# The account ("meio de pagamento") a Site payment lands in: MERCADO PAGO, the -# one the store's orders use (Marcus, 2026-12-01; not "MERCADO PAGO - NÃO -# USAR", 987326894). Only Pix and card paid on the Site, through Mercado Pago. -MERCADO_PAGO_ACCOUNT = 977344550 -SITE_PAID = ('pix', 'card') +# A Pix or card paid on the Site names no account ("meio de pagamento"): Tiny +# answered "Meio de pagamento não encontrado" to MERCADO PAGO, 977344550, the id +# Marcus gave on 2026-12-01 (DTF-API-C, #196 and #198), so it waits for his answer. PICKUP_CARRIER = 761565838 # Dropstar's answers: the financial category "DTF SITE" (RECEITAS, id sent on # 2026-10-26; it goes in pagamento.categoria, and replaced the store's @@ -673,10 +671,6 @@ def order_payload(payload, contact_id, today=None, product_id=None, shipping=Non account = setting('TINY_BOLETO_ACCOUNT') if method == 'faturado' and account.isdigit(): parcela['meioPagamento'] = {'id': int(account)} - # Paid on the Site: the money is in the Mercado Pago account. An order - # the team registered as paid outside (D-35) names no account. - elif method in SITE_PAID and not (payload.get('payment') or {}).get('outside'): - parcela['meioPagamento'] = {'id': MERCADO_PAGO_ACCOUNT} pedido['pagamento'].update({'formaRecebimento': {'id': received}, 'parcelas': [parcela]}) destination = order.get('destination') if destination: diff --git a/tests/test_tiny.py b/tests/test_tiny.py index fbd40e3..edd1a11 100644 --- a/tests/test_tiny.py +++ b/tests/test_tiny.py @@ -215,11 +215,11 @@ class TinyTests(FakeTinyCase): mock.patch.dict(tiny_module.RECEIPT_METHODS, {'faturado': 919478947}): pedido = order_payload({**PAID, 'payment': {'method': 'faturado'}}, 777, date(2026, 9, 24)) self.assertNotIn('meioPagamento', pedido['pagamento']['parcelas'][0]) - # A pix order never gets the boleto account: paid on the Site, it is - # the MERCADO PAGO one (Marcus, 2026-12-01). + # A pix order never gets the boleto account, nor any other: Tiny did + # not find MERCADO PAGO, 977344550 (DTF-API-C, 2026-12-01). with mock.patch.dict(os.environ, {'TINY_BOLETO_ACCOUNT': '977344551'}): pedido = order_payload({**PAID, 'payment': {'method': 'pix'}}, 777, date(2026, 9, 24)) - self.assertEqual(pedido['pagamento']['parcelas'][0]['meioPagamento'], {'id': 977344550}) + self.assertNotIn('meioPagamento', pedido['pagamento']['parcelas'][0]) def test_the_check_lists_ajuste_fino_by_its_sku(self): from app.tiny import check @@ -481,10 +481,9 @@ class TinyStatusTests(FakeTinyCase): self.assertEqual(pickup['transportador'], {'fretePorConta': 'R', 'id': PICKUP_CARRIER, 'formaEnvio': {'id': 77}, 'formaFrete': {'id': 771}}) self.assertEqual(pickup['dataPrevista'], '2026-09-25') - # Paid on the Site: the parcel lands in the MERCADO PAGO account (Marcus, 2026-12-01). + # Paid on the Site: the parcel names no account (DTF-API-C, 2026-12-01). self.assertEqual(pickup['pagamento'], {'categoria': {'id': CATEGORY}, 'formaRecebimento': {'id': RECEIPT_METHODS['pix']}, - 'parcelas': [{'dias': 0, 'data': '2026-09-24', 'valor': 84.72, 'formaRecebimento': {'id': RECEIPT_METHODS['pix']}, - 'meioPagamento': {'id': 977344550}}]}) + 'parcelas': [{'dias': 0, 'data': '2026-09-24', 'valor': 84.72, 'formaRecebimento': {'id': RECEIPT_METHODS['pix']}}]}) # The forma de recebimento ids: card stays the one Tiny accepts, 977460722; # 919478945, which Marcus named on 2026-12-01, is not enabled (DTF-API-C). self.assertEqual((RECEIPT_METHODS['pix'], RECEIPT_METHODS['card'], RECEIPT_METHODS['credit']), @@ -498,7 +497,7 @@ class TinyStatusTests(FakeTinyCase): 'formaFrete': {'id': frete}}, service) self.assertEqual(sent['dataPrevista'], '2026-10-02') self.assertEqual(sent['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['card']}) - self.assertEqual(sent['pagamento']['parcelas'][0]['meioPagamento'], {'id': 977344550}) + self.assertNotIn('meioPagamento', sent['pagamento']['parcelas'][0]) # Looked up once per service. self.assertEqual(self.calls.count(('GET', '/formas-envio/78')), 2) # A test order, or a carrier Tiny does not have: the order still goes, without them, @@ -519,7 +518,7 @@ class TinyStatusTests(FakeTinyCase): 1, thursday, shipping=self.tiny.shipping) self.assertEqual(pix['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['pix']}) self.assertEqual(pix['pagamento']['categoria'], {'id': CATEGORY}) - # Paid outside the site: not through Mercado Pago, so no account. + # Paid outside the site: no account either. self.assertNotIn('meioPagamento', pix['pagamento']['parcelas'][0]) self.assertNotIn('meioPagamento', counter['pagamento']['parcelas'][0]) # Dinheiro (Marcus, 2026-10-27) and the customer's credit, CREDITO