feat(payment): verify Razorpay checkout callbacks

This commit is contained in:
Clintchiz committed 2026-08-28 09:35:30 +05:30
1 parent b1064d442a
commit 10771f1a2b
4 files changed
+36 -2

No files matched your search

+17
View File
@@ -343,6 +343,23 @@ export interface RazorpayConfig {
webhookSecret: string;
theme?: { color?: string };
}
export interface RazorpayCheckoutResult {
orderId: string;
paymentId: string;
signature: string;
}
/** Verify the signed result returned by Razorpay Standard Checkout. */
export async function verifyRazorpayCheckoutSignature(
result: RazorpayCheckoutResult,
keySecret: string,
) {
if (!result.orderId || !result.paymentId || !result.signature || !keySecret) return false;
return equal(
result.signature.toLowerCase(),
await hmac(`${result.orderId}|${result.paymentId}`, keySecret),
);
}
export function razorpayGateway(config: RazorpayConfig): PaymentGateway<RazorpayConfig> {
const auth = `Basic ${btoa(`${config.keyId}:${config.keySecret}`)}`;
const request = (path: string, init: RequestInit = {}) =>