Integration guides
Connect a real donation to central checkout
Collect configured donor fields and let Server determine currency, fees, eligibility and confirmed contributions.
Before you start
- An actual public fundraising campaign open to contributions.
- The campaign currency, amount constraints, donor fields and permitted public totals.
- Approved test authorization and the existing protected Web client, or a separately approved Organization integration.
Read the cause and donation requirements
Display the actual campaign, beneficiary where public and an amount in its existing selling currency. Collect only supported donor fields and respect anonymity choices.
Never relabel a donation into display currency, reveal private donors or fill an absent goal with a fabricated total. Server validates the contribution and fees.
Keep protection on the existing Web route
The Web flow starts POST /api/public/donate through fetchPublicFlow("/donate", ...). Existing preparation adds browser context and a stable attempt; Server refuses missing context and applies abuse controls.
A bare script or external plugin cannot replace this with fake fingerprints. Use an approved protected integration or the real campaign page. The repository helper is not a published browser package.
Pass the donation to server-owned checkout
The inert sample accepts validated input and an explicit approved-test flag; rendering the documentation sends nothing. Keep the same attempt on uncertain results and avoid repeated submissions.
Open the returned checkout.sparkglim.net authorization_url. Checkout returns the visitor according to its configured result; Server records contributions. Add no frontend verification, polling, optimistic raised total or invented confirmation.
'use client';
import { fetchPublicFlow } from '@/lib/server-backend/public-api';
type Input = { campaign_id: string; amount: number; phone_number?: string; email?: string; donor_name?: string; anonymous?: boolean; custom_data?: Record<string, unknown>; client_attempt_id: string; return_path: string };
let requestStarted = false;
export async function initializeApprovedTest(input: Input, approvedTest: boolean) {
if (!approvedTest || requestStarted) return null;
requestStarted = true;
const response = await fetchPublicFlow('/donate', {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(input)
});
const result = await response.json();
if (!response.ok || result.success !== true) throw new Error(result.error || 'Checkout unavailable');
if (typeof result.data?.authorization_url !== 'string') throw new Error('No paid checkout URL returned');
const target = new URL(result.data.authorization_url);
if (target.origin !== 'https://checkout.sparkglim.net' || target.username || target.password) throw new Error('Invalid checkout URL');
window.location.assign(target.href);
return target.href;
}Check your integration
- Test amount/contact validation and supported anonymity using approved fixtures.
- Keep campaign currency unchanged and hidden totals private.
- Confirm checkout navigation and return context without submitting a live donation.