update payment details
This commit is contained in:
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user