This commit is contained in:
2025-07-03 15:36:30 -03:00
parent ce1c1b367e
commit 208c43f398
18 changed files with 261 additions and 78 deletions

View File

@@ -20,26 +20,27 @@ order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
@event_source(data_class=EventBridgeEvent)
@logger.inject_lambda_context
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
"""Set to `PAID` if the status is `PENDING` and the total is zero."""
new_image = event.detail['new_image']
now_ = now()
with order_layer.transact_writer() as transact:
transact.update(
key=KeyPair(new_image['id'], '0'),
update_expr='SET #status = :status, update_date = :update_date',
update_expr='SET #status = :status, updated_at = :updated_at',
expr_attr_names={
'#status': 'status',
},
expr_attr_values={
':status': 'PAID',
':update_date': now_,
':updated_at': now_,
},
)
transact.put(
item={
'id': new_image['id'],
'sk': 'paid_date',
'create_date': now_,
'sk': 'paid_at',
'paid_at': now_,
}
)