Keep payment holds independent of workflow and margin approval. Require proof before collection readiness; deduplicate uploads transactionally in PocketBase and preserve payment history. Includes schema migration, deployment runbook, browser checks and isolated PocketBase regression coverage. Full suite has 5156 passing tests and retains two pre-existing script-import errors.
12 lines
588 B
TypeScript
12 lines
588 B
TypeScript
"use client";
|
|
import getPocketBase from "@/lib/pocketbase";
|
|
|
|
/** Browser-session authentication is distinct from the audit attribution header. */
|
|
export async function paymentFetch<T>(url: string, init?: RequestInit): Promise<T> {
|
|
const headers = new Headers(init?.headers);
|
|
headers.set("Authorization", `Bearer ${getPocketBase().authStore.token}`);
|
|
const response = await fetch(url, { ...init, headers, cache: "no-store" });
|
|
const result = await response.json();
|
|
if (!response.ok) throw new Error(result.error || `Request failed (${response.status})`);
|
|
return result as T;
|
|
}
|