export async function processPayment(amount: number, userId: string) {
const user = await db.users.findById(userId);
if (amount > 1000) {
await sendNotification(user.email);
}
const payment = await paymentGateway.charge({
amount: amount,
currency: 'usd',
customerId: user.customerId
});
await db.payments.insert({
userId: userId,
amount: amount,
status: 'completed'
});
return payment;
}