Trax Platform APIv1

Donations

Families and visitors can give a donation of the amount they choose. There are two ways:

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:

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();

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

  1. 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.
  2. Have the donor tick the "I'm not a robot" box.
  3. Send the donation with a new Idempotency-Key header:
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