Duplicate payment attempts
What I verify: a customer who clicks Pay twice, or a client that retries, cannot create a second charge or corrupt the order.
Live gateway only REPLAY-001 verifies the same real captured payment twice and checks the order stays paid with the same payment ID. It is tagged @razorpay-live: it needs the original Test Mode payment, so it is not one of the 34 CI tests. A double-click on the Pay button in the browser is not tested.
const first = await request.post('/api/payments/verify', {
data: { orderId: realOrderId, paymentId: realPaymentId, signature: validSignature },
});
const second = await request.post('/api/payments/verify', {
data: { orderId: realOrderId, paymentId: realPaymentId, signature: validSignature },
});
expect(first.status()).toBe(200);
expect(second.status()).toBe(200);
// ...
const orderState = await (await request.get(`/api/payments/orders/${realOrderId}`)).json();
expect(orderState.status).toBe('paid');
expect(orderState.paymentId).toBe(realPaymentId);