feat: release design system engine, studio and component contracts

This commit is contained in:
Clintchiz committed 2026-10-19 13:09:03 +05:30
1 parent ff1065fb27
commit 3943b946d6
693 files changed
+175546 -3894

No files matched your search

+19 -8
View File
@@ -160,8 +160,8 @@ export async function signSandboxWebhook(payload: unknown, secret = "sandbox-sec
return { body, signature: await hmac(body, secret) };
}
async function jsonRequest(url: string, init: RequestInit) {
const response = await fetch(url, init);
async function jsonRequest(url: string, init: RequestInit, transport: typeof fetch = fetch) {
const response = await transport(url, init);
const data = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(`payment gateway request failed (${response.status})`);
return data as any;
@@ -342,6 +342,8 @@ export interface RazorpayConfig {
keySecret: string;
webhookSecret: string;
theme?: { color?: string };
/** Server-only request transport, scoped to this gateway instance. */
transport?: typeof fetch;
}
export interface RazorpayCheckoutResult {
orderId: string;
@@ -363,10 +365,18 @@ export async function verifyRazorpayCheckoutSignature(
export function razorpayGateway(config: RazorpayConfig): PaymentGateway<RazorpayConfig> {
const auth = `Basic ${btoa(`${config.keyId}:${config.keySecret}`)}`;
const request = (path: string, init: RequestInit = {}) =>
jsonRequest(`https://api.razorpay.com/v1${path}`, {
...init,
headers: { authorization: auth, "content-type": "application/json", ...(init.headers ?? {}) },
});
jsonRequest(
`https://api.razorpay.com/v1${path}`,
{
...init,
headers: {
authorization: auth,
"content-type": "application/json",
...(init.headers ?? {}),
},
},
config.transport,
);
return defineGateway({
id: "razorpay",
config,
@@ -412,12 +422,13 @@ export function razorpayGateway(config: RazorpayConfig): PaymentGateway<Razorpay
async refund(input) {
const row = await request(`/payments/${encodeURIComponent(input.intentRef)}/refund`, {
method: "POST",
headers: { "X-Razorpay-Idempotency": input.idempotencyKey },
headers: { "X-Refund-Idempotency": input.idempotencyKey },
body: JSON.stringify({ amount: input.amount, notes: { reason: input.reason } }),
});
return {
ref: row.id,
status: row.status === "processed" ? "succeeded" : "pending",
status:
row.status === "processed" ? "succeeded" : row.status === "failed" ? "failed" : "pending",
amount: row.amount,
raw: row,
};