fix: trustProxy for webhook IP validation, filter expired payments, remove dead code
This commit is contained in:
@@ -39,6 +39,7 @@ const origin = (process.env.CORS_ORIGIN ?? '')
|
|||||||
const fastify = Fastify({
|
const fastify = Fastify({
|
||||||
logger: true,
|
logger: true,
|
||||||
bodyLimit: getMaxUploadBodyBytes(),
|
bodyLimit: getMaxUploadBodyBytes(),
|
||||||
|
trustProxy: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
await fastify.register(cors, {
|
await fastify.register(cors, {
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ export async function registerUserPaymentRoutes(fastify) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const existingPayment = await prisma.payment.findFirst({
|
const existingPayment = await prisma.payment.findFirst({
|
||||||
where: { orderId: id, status: { in: ['pending', 'waiting_for_capture'] } },
|
where: {
|
||||||
|
orderId: id,
|
||||||
|
status: { in: ['pending', 'waiting_for_capture'] },
|
||||||
|
OR: [{ expiresAt: null }, { expiresAt: { gt: new Date() } }],
|
||||||
|
},
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -56,7 +60,7 @@ export async function registerUserPaymentRoutes(fastify) {
|
|||||||
const receipt = buildReceipt({
|
const receipt = buildReceipt({
|
||||||
orderItems: order.items,
|
orderItems: order.items,
|
||||||
deliveryFeeCents: order.deliveryFeeCents,
|
deliveryFeeCents: order.deliveryFeeCents,
|
||||||
userEmail: userEmail || 'noemail@example.com',
|
userEmail: userEmail,
|
||||||
})
|
})
|
||||||
|
|
||||||
let result
|
let result
|
||||||
|
|||||||
Reference in New Issue
Block a user