Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions pages/api/validateStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,19 @@ 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"
? {
card: generateGiftcard(
(await convertCurrency(amount as any, "USD", currency)).toString()
card: await generateGiftcard(
(await convertCurrency(amount as any, currency, "USD")).toString()
),
}
: undefined;

// Update status
const key = getTransactionRedisKey(txn_id);

redisClient.set(
key,
JSON.stringify({
Expand Down