update payment details

This commit is contained in:
2026-01-15 14:21:11 -03:00
parent 906dde027c
commit 5f53ffb4a7
7 changed files with 241 additions and 129 deletions

View File

@@ -44,21 +44,6 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
)
with dyn.transact_writer() as transact:
transact.delete(key=KeyPair(order_id, 'TRANSACTION'))
transact.update(
key=KeyPair(order_id, 'TRANSACTION#STATS'),
update_expr='SET #count = if_not_exists(#count, :zero) + :one, \
updated_at = :now',
expr_attr_names={
'#count': 'payment_attempts',
},
expr_attr_values={
':zero': 0,
':one': 1,
':now': now(),
},
)
if charge['success'] is True:
transact.update(
key=KeyPair(order_id, '0'),
@@ -97,4 +82,21 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
},
)
transact.delete(key=KeyPair(order_id, 'TRANSACTION'))
transact.update(
key=KeyPair(order_id, 'TRANSACTION#STATS'),
update_expr='SET #count = if_not_exists(#count, :zero) + :one, \
last_attempt_succeeded = :succeeded, \
updated_at = :now',
expr_attr_names={
'#count': 'payment_attempts',
},
expr_attr_values={
':succeeded': charge['success'],
':zero': 0,
':one': 1,
':now': now(),
},
)
return charge['success']