mirror of
https://github.com/Such-Software/wowcheckout.git
synced 2026-10-17 05:51:45 +02:00
Minimal changes from upstream xmrcheckout to support Wownero: - Rate provider: Nonlogs WOW-BTC via Kraken BTC/USD - Subaddress derivation: Wownero network byte overrides (53/63/54) - Payment URI scheme: wownero: - Dockerfile: Wownero binaries from Codeberg - Display text: Monero→Wownero, XMR→WOW throughout UI - Default daemon: 192.168.88.235:34568 - Added wownero-logo.svg File and folder structure kept identical to upstream for easy sync.
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
"use server";
|
|
|
|
const apiBaseUrl = process.env.API_BASE_URL ?? "http://localhost:8000";
|
|
|
|
export type DonationState = {
|
|
error: string | null;
|
|
invoiceId: string | null;
|
|
};
|
|
|
|
export async function createDonationAction(
|
|
_prevState: DonationState,
|
|
formData: FormData
|
|
): Promise<DonationState> {
|
|
const donationsEnabled = process.env.NEXT_PUBLIC_DONATIONS_ENABLED === "true";
|
|
if (!donationsEnabled) {
|
|
return { error: "Donations are disabled.", invoiceId: null };
|
|
}
|
|
const amount = Number(formData.get("amount_xmr"));
|
|
if (Number.isNaN(amount) || amount <= 0) {
|
|
return { error: "Enter a valid WOW amount.", invoiceId: null };
|
|
}
|
|
|
|
const response = await fetch(`${apiBaseUrl}/api/core/donations`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ amount_xmr: amount }),
|
|
cache: "no-store",
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const detail = await response.json().catch(() => null);
|
|
const message = detail?.detail ?? "Unable to create a donation invoice.";
|
|
return { error: message, invoiceId: null };
|
|
}
|
|
|
|
const data = (await response.json()) as { id: string };
|
|
return { error: null, invoiceId: data.id };
|
|
}
|