Skip to content

Commit 95a1df0

Browse files
SPIRIT-0: fix retry for insert payment in session result
1 parent b162a3d commit 95a1df0

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

libs/modules/order/use-cases/get-order-from-session-result.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ export const getOrderFromSessionResult = async (
9393
undefined;
9494
let updateUserAction: ReturnType<typeof getUpdateUserAction> | undefined =
9595
undefined;
96+
let incrementUserVersionAction:
97+
| ReturnType<typeof getIncrementUserVersionAction>
98+
| undefined = undefined;
9699
if (cartId) {
97100
deleteCartAction = getDeleteCartAction(cartId);
98101
if (userId) {
@@ -107,7 +110,7 @@ export const getOrderFromSessionResult = async (
107110
}
108111

109112
if (userId) {
110-
await getIncrementUserVersionAction(userId).run();
113+
incrementUserVersionAction = getIncrementUserVersionAction(userId);
111114
}
112115

113116
const [, , [order]] = await runBatchOperation(
@@ -117,6 +120,7 @@ export const getOrderFromSessionResult = async (
117120
deleteCartAction,
118121
insertCartAction,
119122
updateUserAction,
123+
incrementUserVersionAction,
120124
);
121125

122126
if (!order) {

libs/modules/order/use-cases/payment/utils/retry-payment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const MAX_RETRIES = 3;
22
const ONE_INCREMENT = 1;
33
const MIN_RETRIES = 0;
4-
export const withRetry = <T, K>(
4+
export const withRetry = async <T, K>(
55
args: T,
66
callBack: (args: T) => Promise<K>,
77
retries: number = MIN_RETRIES,
88
): Promise<K> => {
99
try {
10-
return callBack(args);
10+
return await callBack(args);
1111
} catch (error) {
1212
if (retries < MAX_RETRIES) {
1313
return withRetry(args, callBack, retries + ONE_INCREMENT);

0 commit comments

Comments
 (0)