Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 628ed34d73 | |||
| 9da0520eb6 | |||
| c38d647c48 |
@@ -340,7 +340,7 @@ jobs:
|
|||||||
name: Update Infra Image Tags
|
name: Update Infra Image Tags
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [docker]
|
needs: [docker]
|
||||||
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push'
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|||||||
@@ -130,17 +130,7 @@ invoicesRouter.get("/:id", async (c) => {
|
|||||||
db.select().from(invoiceTipSplits).where(eq(invoiceTipSplits.invoiceId, id)),
|
db.select().from(invoiceTipSplits).where(eq(invoiceTipSplits.invoiceId, id)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let cardLast4: string | null = null;
|
return c.json({ ...invoice, lineItems, tipSplits });
|
||||||
let paymentStatus: string | null = null;
|
|
||||||
if (invoice.stripePaymentIntentId) {
|
|
||||||
const details = await getPaymentIntentDetails(invoice.stripePaymentIntentId);
|
|
||||||
if (details) {
|
|
||||||
cardLast4 = details.cardLast4;
|
|
||||||
paymentStatus = details.paymentStatus;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.json({ ...invoice, lineItems, tipSplits, cardLast4, paymentStatus });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save tip splits for an invoice (replaces existing splits)
|
// Save tip splits for an invoice (replaces existing splits)
|
||||||
@@ -460,6 +450,9 @@ invoicesRouter.post(
|
|||||||
if (invoice.status !== "paid") {
|
if (invoice.status !== "paid") {
|
||||||
return c.json({ error: "Refund only allowed on paid invoices" }, 422);
|
return c.json({ error: "Refund only allowed on paid invoices" }, 422);
|
||||||
}
|
}
|
||||||
|
if (!invoice.stripePaymentIntentId) {
|
||||||
|
return c.json({ error: "No Stripe payment intent found for this invoice" }, 422);
|
||||||
|
}
|
||||||
|
|
||||||
return await db.transaction(async (tx) => {
|
return await db.transaction(async (tx) => {
|
||||||
if (body.idempotencyKey) {
|
if (body.idempotencyKey) {
|
||||||
@@ -472,25 +465,17 @@ invoicesRouter.post(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let refundId: string;
|
const result = await processRefund(id, body.amountCents);
|
||||||
|
if (!result) return c.json({ error: "Refund failed" }, 500);
|
||||||
if (invoice.stripePaymentIntentId) {
|
|
||||||
const result = await processRefund(id, body.amountCents);
|
|
||||||
if (!result) return c.json({ error: "Refund failed" }, 500);
|
|
||||||
refundId = result.refundId;
|
|
||||||
} else {
|
|
||||||
// Manual refund — no Stripe call needed
|
|
||||||
refundId = `manual_${id}_${Date.now()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
await tx.insert(refunds).values({
|
await tx.insert(refunds).values({
|
||||||
invoiceId: id,
|
invoiceId: id,
|
||||||
stripeRefundId: refundId,
|
stripeRefundId: result.refundId,
|
||||||
idempotencyKey: body.idempotencyKey ?? null,
|
idempotencyKey: body.idempotencyKey ?? null,
|
||||||
amountCents: body.amountCents ?? null,
|
amountCents: body.amountCents ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return c.json({ refundId });
|
return c.json({ refundId: result.refundId });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -291,6 +291,35 @@ const [showRefundDialog, setShowRefundDialog] = useState(false);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function issueRefund() {
|
||||||
|
const amountCents = refundType === "partial"
|
||||||
|
? Math.round(parseFloat(refundAmount) * 100)
|
||||||
|
: undefined;
|
||||||
|
if (refundType === "partial" && (!amountCents || amountCents <= 0)) {
|
||||||
|
setError("Enter a valid refund amount");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSaving(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/invoices/${invoice.id}/refund`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(amountCents ? { amountCents } : {}),
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
const err = (await res.json()) as { error?: string };
|
||||||
|
throw new Error(err.error ?? `HTTP ${res.status}`);
|
||||||
|
}
|
||||||
|
setShowRefundDialog(false);
|
||||||
|
onUpdated();
|
||||||
|
} catch (e: unknown) {
|
||||||
|
setError(e instanceof Error ? e.message : "Failed to issue refund");
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (loading) return <Modal onClose={onClose}><p style={{ padding: "1rem" }}>Loading…</p></Modal>;
|
if (loading) return <Modal onClose={onClose}><p style={{ padding: "1rem" }}>Loading…</p></Modal>;
|
||||||
|
|
||||||
const tipCentsCalc = Math.round(parseFloat(tipStr) * 100) || 0;
|
const tipCentsCalc = Math.round(parseFloat(tipStr) * 100) || 0;
|
||||||
@@ -487,7 +516,7 @@ const [showRefundDialog, setShowRefundDialog] = useState(false);
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div style={{ display: "flex", gap: "0.5rem", justifyContent: "flex-end" }}>
|
<div style={{ display: "flex", gap: "0.5rem", justifyContent: "flex-end" }}>
|
||||||
{invoice.status === "paid" && !invoice.stripeRefundId && isManager && (
|
{invoice.status === "paid" && invoice.stripePaymentIntentId && !invoice.stripeRefundId && isManager && (
|
||||||
<button onClick={() => setShowRefundDialog(true)} style={{ ...btnStyle, color: "#fff", backgroundColor: "#7c3aed", borderColor: "#7c3aed" }}>
|
<button onClick={() => setShowRefundDialog(true)} style={{ ...btnStyle, color: "#fff", backgroundColor: "#7c3aed", borderColor: "#7c3aed" }}>
|
||||||
Refund
|
Refund
|
||||||
</button>
|
</button>
|
||||||
@@ -530,14 +559,6 @@ const [showRefundDialog, setShowRefundDialog] = useState(false);
|
|||||||
setRefunding(true);
|
setRefunding(true);
|
||||||
setRefundError(null);
|
setRefundError(null);
|
||||||
try {
|
try {
|
||||||
if (refundType === "partial") {
|
|
||||||
const parsed = parseFloat(refundAmount);
|
|
||||||
if (isNaN(parsed) || parsed <= 0) {
|
|
||||||
setRefundError("Please enter a valid amount greater than zero.");
|
|
||||||
setRefunding(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const body = refundType === "partial" ? { amountCents: Math.round(parseFloat(refundAmount) * 100) } : {};
|
const body = refundType === "partial" ? { amountCents: Math.round(parseFloat(refundAmount) * 100) } : {};
|
||||||
const res = await fetch(`/api/invoices/${invoice.id}/refund`, {
|
const res = await fetch(`/api/invoices/${invoice.id}/refund`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -565,7 +586,8 @@ const [showRefundDialog, setShowRefundDialog] = useState(false);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Modal>
|
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ export function CustomerPortal() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Main Content */}
|
{/* Main Content */}
|
||||||
<main className="flex-1 min-h-screen overflow-hidden">
|
<main className="flex-1 min-h-screen overflow-x-hidden">
|
||||||
<div className="hidden md:flex items-center justify-between px-8 py-4 border-b border-stone-200 bg-white">
|
<div className="hidden md:flex items-center justify-between px-8 py-4 border-b border-stone-200 bg-white">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-lg font-semibold text-stone-800">
|
<h1 className="text-lg font-semibold text-stone-800">
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function BillingPaymentsInner({ sessionId, readOnly }: BillingPaymentsProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex gap-2 flex-wrap overflow-x-auto">
|
<div className="flex gap-2 flex-wrap">
|
||||||
{([
|
{([
|
||||||
{ id: "invoices" as const, label: "Invoices", icon: DollarSign },
|
{ id: "invoices" as const, label: "Invoices", icon: DollarSign },
|
||||||
{ id: "payment" as const, label: "Payment Methods", icon: CreditCard },
|
{ id: "payment" as const, label: "Payment Methods", icon: CreditCard },
|
||||||
|
|||||||
@@ -119,10 +119,3 @@ uri
|
|||||||
database-url
|
database-url
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
|
||||||
Auth secret name — always use groombook-auth (sealed secret name)
|
|
||||||
*/}}
|
|
||||||
{{- define "groombook.authSecretName" -}}
|
|
||||||
{{- printf "%s" "groombook-auth" }}
|
|
||||||
{{- end }}
|
|
||||||
|
|||||||
@@ -50,27 +50,6 @@ spec:
|
|||||||
- name: OIDC_AUDIENCE
|
- name: OIDC_AUDIENCE
|
||||||
value: {{ .Values.api.env.oidcAudience | quote }}
|
value: {{ .Values.api.env.oidcAudience | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.api.env.internalBaseUrl }}
|
|
||||||
- name: OIDC_INTERNAL_BASE
|
|
||||||
value: {{ .Values.api.env.internalBaseUrl | quote }}
|
|
||||||
{{- end }}
|
|
||||||
- name: BETTER_AUTH_URL
|
|
||||||
value: {{ .Values.api.env.betterAuthUrl | quote }}
|
|
||||||
- name: OIDC_CLIENT_ID
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "groombook.authSecretName" . }}
|
|
||||||
key: OIDC_CLIENT_ID
|
|
||||||
- name: OIDC_CLIENT_SECRET
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "groombook.authSecretName" . }}
|
|
||||||
key: OIDC_CLIENT_SECRET
|
|
||||||
- name: BETTER_AUTH_SECRET
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "groombook.authSecretName" . }}
|
|
||||||
key: BETTER_AUTH_SECRET
|
|
||||||
- name: DATABASE_URL
|
- name: DATABASE_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ api:
|
|||||||
corsOrigin: ""
|
corsOrigin: ""
|
||||||
oidcIssuer: ""
|
oidcIssuer: ""
|
||||||
oidcAudience: groombook
|
oidcAudience: groombook
|
||||||
betterAuthUrl: ""
|
|
||||||
internalBaseUrl: ""
|
|
||||||
port: "3000"
|
port: "3000"
|
||||||
service:
|
service:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
|
|||||||
+1
-1
Submodule infra updated: b667a3f005...d9486dbfb1
Reference in New Issue
Block a user