Trax Platform APIv1

Cart and checkout

A signed-in family builds a cart on the server, then checks out once: registrations, charges and today's card payment happen together, or not at all. Most calls here need the family's access token. The cart belongs to the sign-in at one portal, so a family that opens the site on another device sees the same cart. A visitor who hasn't signed in yet can start a guest cart, which joins the family's cart at sign-in (below).

The server prices everything. A cart stores what the family chose (who, which activity, which charge, how much to pay today) and nothing else. Every read prices it again from the organization's data: fees, installments, program discounts, minimums, seats, eligibility and the convenience fee. Never send a price, a fee or a discount; the API ignores them.

A cart read can show the catalog (fees, seats left, activity waivers) as it was up to 30 seconds ago. Checkout always uses current data and counts the seats again, so nobody is charged an old price: if anything changed, checkout answers 409 with the cart as it is now (see "Checkout").

Before signing in: the guest cart

A visitor can pick programs before they have an account or have signed in. Start a guest cart once, keep its token, and send the token back with each guest cart call:

Start a guest cart before signing in

POST https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart → 201, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart', {
  method: 'POST',
});
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/guest-cart");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

The answer (201) holds token, expiresUtc and the empty cart. The token is shown only once.

A guest cart lasts 30 days after its last change unless the organization sets another length (cart.guestCartDays in GET …/config).

Add a program to the guest cart (no attendee yet)

POST https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items → 200 OK, JSON

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items' \
  -H 'X-Trax-Guest-Cart: gc_your_guest_cart_token' \
  -H 'Content-Type: application/json' \
  -d '{"kind": "activity", "activityId": 3 }'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items', {
  method: 'POST',
  headers: {
    'X-Trax-Guest-Cart': 'gc_your_guest_cart_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"kind": "activity", "activityId": 3 }),
});
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/guest-cart/items");
request.Headers.Add("X-Trax-Guest-Cart", "gc_your_guest_cart_token");
request.Content = new StringContent("""
    {"kind": "activity", "activityId": 3 }
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

POST …/guest-cart/items takes three kinds of line, none with a personId:

Paying toward an account's charges needs an account, so a charge line is a 400. DELETE …/guest-cart/items/{id} removes a line.

The guest cart, priced now

GET https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart' \
  -H 'X-Trax-Guest-Cart: gc_your_guest_cart_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart', {
  headers: {
    'X-Trax-Guest-Cart': 'gc_your_guest_cart_token',
  },
});
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/guest-cart");
request.Headers.Add("X-Trax-Guest-Cart", "gc_your_guest_cart_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Removing a guest cart line that isn't there

DELETE https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items/00000000-0000-0000-0000-000000000000 → 404, problem details

curl
curl -s -X DELETE 'https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items/00000000-0000-0000-0000-000000000000' \
  -H 'X-Trax-Guest-Cart: gc_your_guest_cart_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items/00000000-0000-0000-0000-000000000000', {
  method: 'DELETE',
  headers: {
    'X-Trax-Guest-Cart': 'gc_your_guest_cart_token',
  },
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Delete, "https://api.nfocus.solutions/v1/portals/riverbend/north/guest-cart/items/00000000-0000-0000-0000-000000000000");
request.Headers.Add("X-Trax-Guest-Cart", "gc_your_guest_cart_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

What a guest cart shows.

What is checked now, and what waits for an attendee.

Status code When
400 invalid-request A field is missing, or the line has a personId or is a charge
404 guest-cart-not-found No token, or a token that is unknown, expired, already merged or from another portal (the answer is the same for each)
404 activity-not-found, membership-not-found Not offered at this portal
409 already-in-cart, cart-full, donations-off The same activity or membership is already a line; the cart has 50 lines; the portal takes no donations
422 not-eligible The line can't be registered now (problems says why)
429 rate-limited Too many guest carts or changes from one address in an hour

Signing in: merging the guest cart

Right after the family signs in, call POST …/cart/merge with their access token and the guest token. The guest cart's lines join the family's cart.

Merging a guest cart that has expired or doesn't exist

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/merge → 404, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/merge' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'X-Trax-Guest-Cart: gc_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/merge', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'X-Trax-Guest-Cart': 'gc_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
  },
});
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/merge");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Headers.Add("X-Trax-Guest-Cart", "gc_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

The answer holds four fields:

After a merge the guest token stops working. A retry with the same token, by the same family, returns the same answer and adds nothing twice. Delete the token from storage once the merge answers.

Choosing who attends

Merged activity and membership lines have no attendee (person: null). Each shows the problem attendee-needed, and canCheckOut stays false until every line has one. Ask the family who attends, and send it:

PATCH …/cart/items/{itemId}
{ "personId": 1052 }

GET …/activities/{id}/eligibility lists each household member with the reasons they can or can't attend, so offer only the members who can.

The attendee is checked as an add is:

Once a line has an attendee, it keeps them (409 attendee-already-set): to change who attends, remove the line and add it again. The same PATCH can also carry payCents.

Choosing who attends a line that isn't in the cart

PATCH https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000 → 404, problem details

curl
curl -s -X PATCH 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"personId": 1234}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"personId": 1234}),
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Patch, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"personId": 1234}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Reading the cart

The signed-in family's cart, priced now

GET https://api.nfocus.solutions/v1/portals/riverbend/north/cart → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/cart");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Amounts are integer cents.

Field Meaning
lines[].totalCents What the line will charge (a registration) or what is still owed (a payment toward a charge)
lines[].minimumCents The least the family may pay today on the line
lines[].payCents What the family pays today on the line
lines[].laterCents What stays on the account, due at each installment's due date
lines[].installments Each installment: its price, its price after a discount, its minimum, its due date and what today's payment puts on it
lines[].registration enroll or waitlist (see below); null when the line can't be registered
lines[].problems Why the line can't be checked out, with the same codes as eligibility (Household and eligibility guide), plus attendee-needed for a line merged from a guest cart, and already-in-cart for a line that repeats an earlier one (two requests sent at once can both add it: remove the extra line)
lines[].hold The seat the line holds while the family checks out (see "Seat holds"), or null
lines[].notices What changed on the line since the family last saw it, in plain words (see "Change notices")
subtotalCents What the lines pay today
convenienceFeeCents The portal's convenience fee on today's payment
totalCents What checkout charges the card: subtotal plus convenience fee
creditCents Credit on the account. It's shown for information; checkout doesn't spend it
canCheckOut true when the cart has lines and none has a problem
automaticPayments true where the organization pays later installments automatically: laterCents then goes on automatic payments, and checkout needs a saved card (below)
laterSchedule What checkout would leave for later, one entry per date: date, amountCents, paidBy and processingFee (see "Later payments")
savedForLater Lines saved for later, priced now for information (see "Save for later"); not in the totals
reminders offered (the organization sends reminder emails) and optedIn (this sign-in asked for them); see "Reminder emails"

Show totalCents as the amount to pay, and send it back at checkout (below).

Adding a registration

POST …/cart/items with a member of the household and an activity:

{ "kind": "activity", "activityId": 41, "personId": 1052 }

The answer is the whole cart, priced again. A line is refused when it can't be registered as things stand:

Status code When
400 invalid-request A field is missing
404 member-not-found, activity-not-found The person isn't in the household, or the activity isn't published at this portal
409 already-in-cart The same member and activity are already a line
422 not-eligible The member can't register; problems lists why (age, grade, membership, window, …)

A registration line without a member

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": "activity", "activityId": 3 }'
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": "activity", "activityId": 3 }),
});
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": "activity", "activityId": 3 }
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

A past-due balance doesn't stop a line from being added, because the family can pay it in the same cart (below). The line shows a balance-due problem until the cart covers the balance. A missing membership that can be bought online doesn't stop it either: add the membership for the line (Memberships guide).

Memberships are lines too (kind: "membership"), on their own or for an activity line; see the Memberships guide.

Group sessions and hierarchy levels are ordinary lines: add one line per session (the session ids are in the catalog listing's sessions). Each session has its own fee and seats. For a hierarchy, add the parent activity before its options: an option needs its parent registered already or in the same cart. The parent can't be removed while one of its options for the same member is in the cart (409 has-dependents).

Seats count across the cart. When the cart holds more people than an activity has seats left, the extra lines go to the waitlist (registration: "waitlist", $0) if the activity has one, or show the full problem. An option whose parent would go to the waitlist can't be registered (parent-full).

Later payments

laterSchedule says what checkout would leave for later and how it gets paid, one entry per date, so the page can show "$133.80 today, then $120.00 on February 1 and March 1". Each entry has date, amountCents, paidBy and processingFee. paidBy is one of:

processingFee is true where that payment adds the organization's processing fee when it runs. The fee isn't in amountCents.

Paying less today is the choice of payCents on each line (from its minimum). Setting up a payment plan stays on the Payment plans guide's endpoints.

Seat holds

Once the family chooses who attends a registration that would enroll, the line holds its seat for a few minutes while they finish checking out. A seat is held when the line is added with a member, or when a member is chosen for a line that had none. Other families, the catalog and checkout all count a held seat as taken.

lines[].hold Meaning
expiresUtc When the hold ends
secondsLeft The seconds left as the server counts them: base a countdown on this, not on the device's clock
extensionsLeft How many more times the hold can be extended
extensionMinutes How many minutes one extension adds

GET …/config gives the portal's settings in cart:

Extending a hold. POST …/cart/items/{itemId}/hold/extend adds extensionMinutes to the hold and answers with the cart. It is refused with 409 hold-extension-limit when no extensions are left, and with 409 hold-not-active when the line holds no seat now (the hold ended, or none was taken).

Extending the hold of a line that isn't in the cart

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/hold/extend → 404, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/hold/extend' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/hold/extend', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/00000000-0000-0000-0000-000000000000/hold/extend");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

When a hold ends. A seat is let go:

After it expires, the line stays in the cart without a seat and is priced again on every read: a registration while seats are left, otherwise the waitlist or full. Nothing takes a new hold for it; check out soon.

When every seat left is held. The activity is full for now:

Not waitlist lines, memberships or unlimited activities. Holds are only for seats that run out.

Holds are the online portal's. Staff enrolling people in Trax don't see them. Checkout still counts the real seats at the last moment. Holds rank by when they were taken, so when a staff enrollment takes a seat that was held, only the latest hold loses its seat: that family's line shows the waitlist (or full), and a checkout already under way answers 409 cart-changed, with the waitlist offered where there is one.

One seat per member. A member holds at most one seat in an activity, however many requests arrive at once.

Save for later

A family can move a registration or a membership out of this order without losing it. POST …/cart/items/{itemId}/save-for-later answers with the cart:

Saving a line for later that isn't in the cart

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/save-for-later → 404, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/save-for-later' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/save-for-later', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/00000000-0000-0000-0000-000000000000/save-for-later");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

What saving does.

POST …/cart/items/{itemId}/move-to-cart brings a line back. It is checked as an add, and so are the memberships that come back with an activity:

When it comes back, it goes to the end of the cart and holds a seat again with fresh extensions. If its price changed while it was saved, it shows a price-changed notice. A line merged from a guest cart and saved before its attendee was chosen comes back still needing one (attendee-needed): choose who attends as for any merged line.

Moving back a saved line that isn't in the cart

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/move-to-cart → 404, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/move-to-cart' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000/move-to-cart', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/00000000-0000-0000-0000-000000000000/move-to-cart");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Change notices

Every cart read compares each line with how the family last saw it: when it was added, when its attendee was chosen, when it was saved for later, or when the family last acknowledged its notices. Each change becomes a notice in lines[].notices, with a code and a plain-language message.

code When message
price-changed The line's price changed (oldCents, newCents) "Price changed from $35.00 to $40.00 since you added it."
now-waitlisted It was a registration, and now goes to the waitlist "Now on the waitlist. The class filled after you added it. You pay nothing unless a spot opens."
now-full It was a registration, and the activity is now full with no waitlist "This class filled after you added it."
registration-closed Registration closed since it was added "Registration closed after you added this."
spot-opened It was waitlisted, and now it can register "A spot opened. This is now a registration, not the waitlist."
hold-expired Its seat hold ran out "Hold ended. Check out soon; the spot is not saved."
merged-from-guest It came from the guest cart "Added before you signed in."

Registrations get every kind. Memberships get only price-changed, and payments and donations get none, since the family chose those amounts. A code the front end doesn't know: show its message.

Notices stay until the family has seen them. POST …/cart/notices/ack with { "itemIds": [ … ] } clears those lines' notices; {} clears every line's. It answers with the cart, and another cart's line ids answer 404 cart-item-not-found.

Clearing the notices the family has seen, on every line

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/notices/ack → 200 OK, JSON

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/notices/ack' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/notices/ack', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
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/notices/ack");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Reminder emails

Where the organization offers them (cart.remindersOffered in GET …/config), a family can ask to be emailed if they leave without checking out. They are off until the family asks:

PUT …/cart/reminders
{ "optIn": true }

The answer is the cart, with reminders: { "offered": true, "optedIn": true }. { "optIn": false } turns them off; asking where they aren't offered is 409 reminders-off.

Turning reminder emails off for this cart

PUT https://api.nfocus.solutions/v1/portals/riverbend/north/cart/reminders → 200 OK, JSON

curl
curl -s -X PUT 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/reminders' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"optIn": false}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/reminders', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"optIn": false}),
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Put, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/reminders");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"optIn": false}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

When a reminder goes:

At most two go out each time the cart fills up again. Nothing goes to a guest cart, an empty cart or one that was checked out.

What it says. The email goes to the address the family signs in with, from the organization:

It holds no prices, form answers or other personal details.

Stopping them. Every reminder carries a one-click unsubscribe (RFC 8058 List-Unsubscribe with List-Unsubscribe-Post), which mail apps show as an "Unsubscribe" button. Its footer link opens a page on the API with one "Stop cart reminders" button; opening the page alone changes nothing. Both turn reminders off for that sign-in at this portal. A link works for 90 days and only for its own cart (400 unsubscribe-token-invalid otherwise).

A one-click unsubscribe with a link that isn't valid

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart-reminders/unsubscribe?token=not-a-valid-token → 400, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart-reminders/unsubscribe?token=not-a-valid-token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart-reminders/unsubscribe?token=not-a-valid-token', {
  method: 'POST',
});
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-reminders/unsubscribe?token=not-a-valid-token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Today's payment

A registration's fee can have installments. By default the family pays the whole price today, or the minimum when the organization prefers that. The family can choose any amount from the minimum to the total:

PATCH …/cart/items/{itemId}
{ "payCents": 6000 }

An amount outside that range is 422 pay-amount with minimumCents and totalCents. Today's payment covers each installment's minimum first, then the rest in order; whatever isn't paid today is charged now and due later.

Changing a line that isn't in the cart

PATCH https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000 → 404, problem details

curl
curl -s -X PATCH 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"payCents": 2500}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"payCents": 2500}),
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Patch, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items/00000000-0000-0000-0000-000000000000");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"payCents": 2500}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

A program discount the family's account holds appears as discount on the line, with each installment's price after it. It comes from the organization's settings. It is applied the same way at checkout, so the price shown is the price charged.

A waitlisted line costs nothing: nothing is charged now, and the organization charges the fee if a seat opens.

Paying the account balance ("Pay Now")

Unpaid charges the family can pay

GET https://api.nfocus.solutions/v1/portals/riverbend/north/account/charges → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/account/charges' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/account/charges', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/account/charges");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

GET …/account/charges lists the account's unpaid charges, oldest due first, with pastDue for the ones already due. Add one to the cart to pay it:

{ "kind": "charge", "chargeId": 8811 }

The whole balance of the charge is paid by default; any amount above zero up to it can be chosen with PATCH. Pay Now lines and registrations share one card payment.

Paying an amount. For "Another amount: goes toward the oldest charges first", send the amount:

POST …/cart/pay-amount
{ "amountCents": 4000 }

The cart's payment lines are set to cover exactly that amount, oldest charges first (the order of GET …/account/charges): each charge in full until the last, which takes what is left. Charges the amount doesn't reach leave the cart; registrations, memberships and donations aren't touched. The amount must be at least one cent and at most what the account's charges owe (422 pay-amount, with totalCents).

Paying an amount of nothing toward the balance

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/pay-amount → 422, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/pay-amount' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"amountCents": 0}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/pay-amount', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"amountCents": 0}),
});
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/pay-amount");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"amountCents": 0}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

A charge that a later payment-plan or automatic payment will pay carries scheduledPayment (kind: plan or automatic) and can be paid now: that payment lets go of what is paid, and becomes smaller or goes (Payment plans and Automatic payments guides). A payment that runs within about a day holds its charges: they aren't offered. If one starts running after the line was added, the line shows charge-not-found, and a checkout already under way stops before the card is charged (409 cart-changed). GET …/account/balance gives the charges each Pay Now button adds (Account guide).

After a checkout, the family's automatic payments and payment plan follow it: what is left for later goes on automatic payments where the organization uses them (below), and otherwise joins the plan's months.

Some activities don't allow registering while the account has a past-due balance. Their lines show balance-due with the amount still past due after what the cart pays. Add the past-due charges and pay them in full, and the problem goes away.

On a parent-portal-only site, registrations are refused (parent-portal-only) and balance payments go through.

A donation

A donation below the minimum

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": 50}'
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": 50}),
});
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": 50}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

A cart can hold one donation, of an amount the family chooses within the limits GET …/donations/options gives ($1.00 to $10,000.00 by default):

{ "kind": "donation", "amountCents": 2500 }

It is paid in full today, never brings or adds to the convenience fee, and is on the receipt. Change the amount with PATCH …/cart/items/{itemId} and payCents. An amount outside the limits is 400 (adding) or 422 donation-amount (changing); a portal that takes no donations answers 409 donations-off. A cart with only a donation checks out like any other, with the card. Donations are allowed on parent-portal-only sites. Giving without signing in is in the Donations guide.

Forms and waivers

Before checkout, each member with a registration or a membership in the cart goes through the forms step:

GET …/cart/forms says what each member needs and what is still missing. Checkout refuses with 409 forms-incomplete until every member is complete.

The forms step for everyone in the cart

GET https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/cart/forms");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

For each member in people:

Show one page per member. Prefill it from GET …/cart/forms/people/{personId}: for every field on the member's forms, the answer saved in the step, or else the stored value (an SSN only masked), and the step's signatures with their strokes (pass them to Signature Pad's fromData()). Save the page:

PUT /v1/portals/riverbend/north/cart/forms/people/5012
Authorization: Bearer {access token}
Content-Type: application/json

{
  "definitionHashes": { "41": "{participant form hash}", "57": "{activity form hash}" },
  "answers": { "person.medicalNotes": "Mild asthma", "person.swim": "1" },
  "acceptedWaivers": [ { "kind": "activity", "id": 12, "textHash": "{the waiver's textHash}" } ],
  "signatures": [ { "signatureId": "{the element's signatureId}", "printedName": "Pat Example", "strokes": [ … ] } ]
}

A forms step for a member with nothing in the cart

PUT https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms/people/1234 → 404, problem details

curl
curl -s -X PUT 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms/people/1234' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"answers": {}, "acceptedWaivers": []}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms/people/1234', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"answers": {}, "acceptedWaivers": []}),
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Put, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/forms/people/1234");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"answers": {}, "acceptedWaivers": []}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();
problems[].code Meaning
forms-not-saved The member's step hasn't been saved, or it expired (steps are kept for 24 hours after the last save)
answers-needed Some answers don't pass; see errors
form-changed The organization changed a form since the step was saved: load it again, check the answers and save
form-not-renderable A form needs a field the API can't show yet. The family can't check out until the organization changes the form
waiver-not-accepted A waiver isn't ticked
waiver-changed A waiver's text changed since it was ticked
signature-needed A required signature isn't signed (signatureId names it)

At checkout the API checks every member's step again. If all are complete, it does four things:

Removing a member's last line also deletes their step. Saved steps are encrypted, and only the login that saved them can read them.

Checkout

POST …/checkout with an Idempotency-Key header, the total the family was shown, the "I'm not a robot" answer and the card:

POST /v1/portals/riverbend/north/checkout
Authorization: Bearer {access token}
Idempotency-Key: 6f1c0a8e-1f7b-4c51-9a55-3f0f5c2c7e41
Content-Type: application/json

{
  "expectedTotalCents": 6330,
  "captchaToken": "{the reCAPTCHA answer}",
  "payment": {
    "nonce": "{payment method nonce from the card form}",
    "firstName": "Avery",
    "lastName": "Rivera",
    "street1": "1 Main Street",
    "city": "Springfield",
    "stateProvince": "OH",
    "postalCode": "43004",
    "phone": "(555) 201-0000"
  }
}

Checkout without an Idempotency-Key

POST https://api.nfocus.solutions/v1/portals/riverbend/north/checkout → 400, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/checkout' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"expectedTotalCents": 0}'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/checkout', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"expectedTotalCents": 0}),
});
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/checkout");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"expectedTotalCents": 0}
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

A successful checkout answers 201 with the order: what was registered (enroll or waitlist), charged and paid, the receipt number and the card's type and last four digits (with paymentMethodId when it is a saved card). Checked-out lines leave the cart.

Status code What to do
201 Show the confirmation
400 invalid-request Fix the field named in errors (a missing key, total, reCAPTCHA answer or card detail)
400 captcha-failed The reCAPTCHA answer was refused or has expired. Reset the box, let the family tick it again, and retry
402 payment-declined The card was declined; nothing was registered. Ask for another card and use a new key
409 cart-empty, cart-changed, price-changed Show the cart in the answer (cart) and let the family check it again
409 forms-incomplete Show forms (as GET …/cart/forms returns it) and send the family back to the members still missing something
409 checkout-in-progress The first request with this key is still running; check the family's registrations (GET …/registrations) before retrying
409 payments-unavailable The organization isn't taking payments online right now
409 saved-card-needed Later installments are paid automatically: pay with a saved card, or save this one (saveCard)
409 saved-cards-unavailable, payment-methods-limit saveCard can't be used here, or the person already keeps 10 cards; nothing was charged. Pay without saving
422 idempotency-key-reused, below-minimum-payment Use a new key; or the payment is below the organization's minimum
502 payment-unavailable The payment service didn't answer; nothing was charged. Retry with a new key (with saveCard, use the card it names if there is one)
503 captcha-unavailable Google couldn't check the reCAPTCHA answer; nothing was charged. Reset the box and retry shortly
503 documents-unavailable A member's signed forms couldn't be drawn as a PDF just now; nothing was recorded or charged. Retry shortly with the same key

Seats are counted again at the last moment. If one was taken after the family pressed "Pay", the card is released at once and the answer is 409 cart-changed, showing for example that the line would now go to the waitlist.

The card form

GET …/payments/client-token gives the card form a token for the payment gateway's hosted card fields (Braintree braintree-web Hosted Fields). The family types the card into fields served by the gateway, and the form gives you the one-time nonce to send as payment.nonce. Ask for a new token each time you show the form. When the organization doesn't take card payments online the answer is 409 payments-unavailable.

Include a cardholder name field and pass it when you tokenize (cardholderName, with vault: false). It is printed on the receipt and kept with the payment; without it, the payer's name from payment is used.

A client token for the card form

GET https://api.nfocus.solutions/v1/portals/riverbend/north/payments/client-token → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/payments/client-token' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/payments/client-token', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/payments/client-token");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

In development and tests the token is a placeholder (fake-client-token) and the nonces above stand in for a card.

The confirmation and receipt

GET …/orders/{id} returns the same order later (for a confirmation page that reloads). Only the family that placed the order can read it.

An order id that isn't yours

GET https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA → 404, problem details

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/orders/AAAAAAAAAAAAAAAAAAAAAA");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Every checkout sends one email to the account's primary holder: what was registered (or waitlisted), what was paid toward the balance, what was paid today and what is still due. After a card payment the receipt is attached as a PDF with the receipt number, the card used and the balance after the payment. The email is sent shortly after the checkout; a problem sending it never undoes the checkout.

GET …/orders/{id}/receipt.pdf returns the same PDF at any time, for a "Download receipt" link. An order with no card payment has no receipt (404 receipt-not-found).

The receipt of an order that isn't yours

GET https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA/receipt.pdf → 404, problem details

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA/receipt.pdf' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/orders/AAAAAAAAAAAAAAAAAAAAAA/receipt.pdf', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
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/orders/AAAAAAAAAAAAAAAAAAAAAA/receipt.pdf");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

What changed from the current portal