feat: Site orders carry DTF-<n> as Tiny's numeroPedidoEcommerce
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m47s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m47s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s
Dropstar asked on 2026-10-23 for the Kanban number in numeroPedidoEcommerce. It goes there on every order now, next to numeroOrdemCompra, which the resend check still searches. Tiny's v3 model takes the e-commerce block without a channel id; TINY_ECOMMERCE_ID adds one and can now be set in the stack. The supervised test order reads the number back from Tiny and fails if Tiny did not keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,9 @@ sum, 1,30 m = 1 × "1 metro" + 1 × "30 cm", at the price the customer paid.
|
||||
Idempotency: the outbox may deliver the same event more than once. Every order
|
||||
carries numeroOrdemCompra = "DTF-<order number>", and before creating one the
|
||||
customer's recent orders are searched for that number, so a second delivery
|
||||
finds the first order instead of creating another.
|
||||
finds the first order instead of creating another. The same number goes in
|
||||
numeroPedidoEcommerce (Dropstar, 2026-10-23), which n8n reads as
|
||||
numero_ecommerce.
|
||||
|
||||
Customer notices: the client sends WhatsApp messages from Tiny's order
|
||||
situação (Tiny webhook -> their middleware -> n8n), on Aprovado, Pronto para
|
||||
@@ -499,9 +501,11 @@ def order_payload(payload, contact_id, today=None, product_id=None, shipping=Non
|
||||
pedido['enderecoEntrega'] = {**address(destination), 'enderecoNro': destination['number'],
|
||||
'nomeDestinatario': destination['recipient']}
|
||||
del pedido['enderecoEntrega']['numero']
|
||||
# The channel id is optional in Tiny's v3 model; TINY_ECOMMERCE_ID adds it.
|
||||
pedido['ecommerce'] = {'numeroPedidoEcommerce': purchase_order(payload['number'])}
|
||||
ecommerce = os.environ.get('TINY_ECOMMERCE_ID', '')
|
||||
if ecommerce.isdigit():
|
||||
pedido['ecommerce'] = {'id': int(ecommerce), 'numeroPedidoEcommerce': purchase_order(payload['number'])}
|
||||
pedido['ecommerce']['id'] = int(ecommerce)
|
||||
return pedido
|
||||
|
||||
|
||||
|
||||
@@ -198,11 +198,19 @@ def pedido(orders, payload, confirm, out, wait=time.sleep):
|
||||
out(f'FALHA: a busca por {tiny.purchase_order(payload["number"])} não encontrou o pedido. '
|
||||
'Um reenvio criaria um duplicado; o 2º envio não foi feito.')
|
||||
return False
|
||||
# What Tiny kept of the e-commerce number, read back from the order.
|
||||
wanted = tiny.purchase_order(payload['number'])
|
||||
shop = orders.request('GET', f"/pedidos/{first['tiny_id']}").get('ecommerce') or {}
|
||||
out(f"E-commerce no Tiny: numeroPedidoEcommerce {shop.get('numeroPedidoEcommerce') or '(vazio)'}" +
|
||||
(f" · canal {shop.get('nome') or '?'} (id {shop['id']})" if shop.get('id') else ' · sem canal'))
|
||||
numbered = shop.get('numeroPedidoEcommerce') == wanted
|
||||
if not numbered:
|
||||
out(f'FALHA: o Tiny não guardou {wanted} em numeroPedidoEcommerce.')
|
||||
second = orders.deliver('teste-integracao', payload)
|
||||
out(f"2º envio: {second['status']} · Tiny id {second['tiny_id']}")
|
||||
passed = second['status'] == 'already-created' and second['tiny_id'] == first['tiny_id']
|
||||
out('OK: o reenvio encontrou o mesmo pedido.' if passed else 'FALHA: o reenvio não devolveu o mesmo pedido.')
|
||||
return passed
|
||||
found_again = second['status'] == 'already-created' and second['tiny_id'] == first['tiny_id']
|
||||
out('OK: o reenvio encontrou o mesmo pedido.' if found_again else 'FALHA: o reenvio não devolveu o mesmo pedido.')
|
||||
return numbered and found_again
|
||||
finally:
|
||||
# Whatever happened above, the test order does not stay open.
|
||||
cancelar(orders, first['tiny_id'], out)
|
||||
|
||||
Reference in New Issue
Block a user