Donations
Families and visitors can give a donation of the amount they choose. There are two ways:
- Signed in: a
donationline in the cart (Cart and checkout guide). The gift is on the family's account, and checkout charges it with anything else in the cart. - Without signing in:
POST …/donations, below. No account is involved; the receipt is emailed to the donor.
Options
Donation options
GET https://api.nfocus.solutions/v1/portals/riverbend/north/donations/options → 200 OK, JSON
curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/donations/options'JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/donations/options');
const data = await response.json();C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/donations/options");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();GET …/donations/options is public. It answers:
enabled:falsewhen the organization takes no donations online (then every donation call answers409 donations-off);minimumCentsandmaximumCents: the amounts accepted ($1.00 to $10,000.00 by default; nFocus sets each portal's maximum);minimumCardPaymentCents: the portal's smallest card payment. A gift without signing in is one card payment, so it must be at least this too (else422 below-minimum-payment); in a cart, the whole payment must be;greetingContentKey: the organization's greeting for the donation page, forGET …/content/{key}(Portal guide);captchaSiteKey: the reCAPTCHA v2 site key for the "I'm not a robot" box;designations: where a gift can go (below).
No convenience fee is charged on a donation, in the cart or on its own.
Designated gifts
A donor can choose where a gift goes. Send designation: { kind, id } on the cart's donation line
(POST …/cart/items, also in a guest cart), on PATCH …/cart/items/{id}, or on POST …/donations:
kind |
id |
Where it comes from |
|---|---|---|
location |
The location's id | designations in the options, or GET …/locations |
sponsorship |
The sponsorship option's id | designations in the options, or GET …/content?kind=sponsorships |
activity, activityGroup |
The activity's or group's id | The catalog (GET …/activities) |
Where a gift can go
GET https://api.nfocus.solutions/v1/portals/riverbend/central/donations/options → 200 OK, JSON
curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/donations/options'JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/donations/options');
const data = await response.json();C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/donations/options");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();- Amounts: a sponsorship option with a fixed amount (
amountCents) is the gift's amount, soamountCentsmay be left out; any other amount is refused. A range (minimumCentstomaximumCents) bounds the amount. The portal's own limits always apply, so an option wholly outside them isn't offered. - Refused: a target of another portal, an unpublished option or anything not found answers
400 designation-not-found, with the field inerrors. A wrong amount answers400onamountCents(when adding) or422 donation-amount(when changing a line). - Changing or removing it:
PATCH …/cart/items/{id}with anotherdesignation, or{}to remove it. A line'sdesignationshows the target'snamenow; it is null when the target is gone (unpublished or deleted), and checkout then answers409 designation-changeduntil the family changes the line. - On the order and receipt: the donation line carries
designation(kind,id,name), and the receipt email and PDF print it as "Donation, designated to Harbor Youth Center (Sponsor a young person)", with the name the target had at the time of the gift. - In Trax: the designation is kept with the order in the platform, not in the Trax money records: those are the same as for any donation. Staff see it in the support lookup.
A designation that isn't this portal's
POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items → 400, problem details
curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json' \
-d '{"kind": "donation", "amountCents": 2500, "designation": {"kind": "sponsorship", "id": "00000000-0000-0000-0000-000000000000"}}'JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_access_token',
'Content-Type': 'application/json',
},
body: JSON.stringify({"kind": "donation", "amountCents": 2500, "designation": {"kind": "sponsorship", "id": "00000000-0000-0000-0000-000000000000"}}),
});
const data = await response.json();C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
{"kind": "donation", "amountCents": 2500, "designation": {"kind": "sponsorship", "id": "00000000-0000-0000-0000-000000000000"}}
""", System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();Giving without signing in
- Get a client token for the card form from
GET …/donations/client-token(public). Turn the card into a one-time nonce with the gateway's hosted fields, as at checkout. - Have the donor tick the "I'm not a robot" box.
- Send the donation with a new
Idempotency-Keyheader:
POST …/donations
Idempotency-Key: 3f0c…
{
"amountCents": 2500,
"donor": {
"firstName": "Robin", "lastName": "Example", "email": "robin@example.test",
"street1": "12 Example Way", "city": "Springfield", "stateProvince": "OH", "postalCode": "43004",
"phone": "555-0142"
},
"nonce": "…",
"captchaToken": "…"
}
A donation without an Idempotency-Key
POST https://api.nfocus.solutions/v1/portals/riverbend/north/donations → 400, problem details
curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/donations' \
-H 'Content-Type: application/json' \
-d '{"amountCents": 2500}'JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/donations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({"amountCents": 2500}),
});
const data = await response.json();C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nfocus.solutions/v1/portals/riverbend/north/donations");
request.Content = new StringContent("""
{"amountCents": 2500}
""", System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();Every donor field is required, up to 50 characters each (the email up to 254). The answer is 201 with the
confirmation: one donation line, what was paid, the card's type and last four digits, and the receipt number.
What happens to the donor's details: the name, address and phone go on the payment, as the organization's staff screens show them. The email is used once, to send the receipt, and isn't stored anywhere else. Repeating the request with the same key returns the first answer and charges nothing again.
| Status | code |
What to do |
|---|---|---|
201 |
Show the confirmation | |
400 |
invalid-request |
Fix the field named in errors |
400 |
designation-not-found |
Choose another designation (see Designated gifts) |
400 |
captcha-failed |
Reset the box, let the donor tick it again, and retry with a new key |
402 |
payment-declined |
The card was declined: ask for another card |
409 |
donations-off, payments-unavailable |
The organization takes no donations, or no card payments, online right now |
422 |
below-minimum-payment |
The amount is below the smallest card payment |
429 |
rate-limited |
Too many tries from this address, or at this portal, in the last minute |
502 |
payment-unavailable |
The payment service didn't answer; nothing was charged |
What changed from the legacy portal
- The amount is checked against the organization's limits on the server, and nothing in the amount comes from the browser.
- The organization's donations switch is enforced on the server, including for donors who aren't signed in.
- No convenience fee on any donation; legacy added one on the standalone page only.
- A donation in the cart is on the receipt (legacy's receipt PDF left it out).
- Anonymous donations are rate-limited per address and per portal, and a receipt is sent only after the card is charged.