From c3599a70b525ac3091f5a393dacd8f5e2e882472 Mon Sep 17 00:00:00 2001 From: quantiom Date: Thu, 4 Aug 2022 15:12:09 -0400 Subject: [PATCH 1/3] Remove faulty invalid transaction check --- pages/api/validateStatus.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pages/api/validateStatus.ts b/pages/api/validateStatus.ts index fd17274..f833c52 100644 --- a/pages/api/validateStatus.ts +++ b/pages/api/validateStatus.ts @@ -54,13 +54,6 @@ export default async function handler( return; } - // If transaction doesn't exist, expire it on CoinPayments (in case it's been cancelled) - const key = getTransactionRedisKey(txn_id); - if (!(await get(key))) { - res.status(400).json({ error: "Invalid transaction!" }); - return; - } - // Generate giftcard if applicable const cardObj = status === "2" || status === "100" @@ -72,6 +65,8 @@ export default async function handler( : undefined; // Update status + const key = getTransactionRedisKey(txn_id); + redisClient.set( key, JSON.stringify({ From eb1eb6cc92c71636c409f48b062c307b0b9bf1a9 Mon Sep 17 00:00:00 2001 From: quantiom Date: Thu, 4 Aug 2022 15:12:34 -0400 Subject: [PATCH 2/3] Fix giftcard creation not being awaited --- pages/api/validateStatus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/validateStatus.ts b/pages/api/validateStatus.ts index f833c52..e8b95e1 100644 --- a/pages/api/validateStatus.ts +++ b/pages/api/validateStatus.ts @@ -58,7 +58,7 @@ export default async function handler( const cardObj = status === "2" || status === "100" ? { - card: generateGiftcard( + card: await generateGiftcard( (await convertCurrency(amount as any, "USD", currency)).toString() ), } From efdcde66da565d425ee9ff84b50ec20c209a340f Mon Sep 17 00:00:00 2001 From: quantiom Date: Thu, 4 Aug 2022 15:14:42 -0400 Subject: [PATCH 3/3] Fix currency not being converted correctly --- pages/api/validateStatus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/validateStatus.ts b/pages/api/validateStatus.ts index e8b95e1..eb06dfa 100644 --- a/pages/api/validateStatus.ts +++ b/pages/api/validateStatus.ts @@ -59,7 +59,7 @@ export default async function handler( status === "2" || status === "100" ? { card: await generateGiftcard( - (await convertCurrency(amount as any, "USD", currency)).toString() + (await convertCurrency(amount as any, currency, "USD")).toString() ), } : undefined;