add retries to order

This commit is contained in:
2026-01-15 19:58:57 -03:00
parent ca52384b53
commit 466936acf4
9 changed files with 402 additions and 273 deletions

View File

@@ -62,5 +62,13 @@ def payment_retries(
},
cond_expr='attribute_not_exists(sk)',
)
transact.update(
key=KeyPair(order_id, 'TRANSACTION#STATS'),
update_expr='SET updated_at = :now REMOVE last_attempt_succeeded',
expr_attr_values={
':now': now(),
},
cond_expr='attribute_exists(sk)',
)
return JSONResponse(status_code=HTTPStatus.CREATED)

View File

@@ -32,7 +32,13 @@ def test_payment_retries(
)
assert r['statusCode'] == HTTPStatus.CREATED
r = dynamodb_persistence_layer.collection.get_item(
r = dynamodb_persistence_layer.collection.get_items(
KeyPair('4b23f6f5-5377-476b-b1de-79427c0295f6', 'TRANSACTION')
+ KeyPair(
'4b23f6f5-5377-476b-b1de-79427c0295f6',
'TRANSACTION#STATS',
rename_key='stats',
)
)
assert r['credit_card']['number'] == '4111111111111111'
assert 'last_attempt_succeeded' not in r['stats']

View File

@@ -30,6 +30,7 @@
// file: tests/routes/orders/test_payment_retries.py
{"id": "4b23f6f5-5377-476b-b1de-79427c0295f6", "sk": "0", "installments": 3}
{"id": "4b23f6f5-5377-476b-b1de-79427c0295f6", "sk": "INVOICE", "invoice_id": "123"}
{"id": "4b23f6f5-5377-476b-b1de-79427c0295f6", "sk": "TRANSACTION#STATS", "last_attempt_succeeded": false}
// Indicies
// CNPJs