Trax Platform APIv1

Saved cards

A signed-in person can keep up to 10 cards at the organization's payment gateway and pay with one at checkout. The cards belong to the person who signs in (not the whole household), at this portal's merchant. They are the same saved cards the current Trax portal shows.

The API never sends a card number or the gateway's token for a card. Each saved card has an id, and that is all you send back.

Listing the cards

The signed-in person's saved cards

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

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

GET …/payment-methods answers items and maximum (10). Each card has:

Saving a card

  1. Show the card form with a token from GET …/payments/client-token (Cart and checkout guide, "The card form").
  2. Turn the card into a one-time nonce with the hosted fields (vault: false; the API saves it).
  3. Send the nonce, a name and the billing details:
POST …/payment-methods
Authorization: Bearer {access token}
{
  "nonce": "…",
  "name": "Camp card",
  "makeDefault": false,
  "billing": {
    "firstName": "Avery", "lastName": "Rivera",
    "street1": "1 Main Street", "city": "Springfield", "stateProvince": "OH", "postalCode": "43004"
  }
}

Saving a card without its nonce or a name

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

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

The gateway checks the card with its bank before saving it, so a card that would be declined isn't saved (402 card-declined). The same card can be saved twice. The answer is 201 with the card. A person's first card becomes their default.

Renaming, re-entering, the default

Each sign-in may enter 10 cards an hour (saving or re-entering). Past that the answer is 429 rate-limited; renaming still works.

Deleting a card

Deleting a card that isn't yours

DELETE https://api.nfocus.solutions/v1/portals/riverbend/north/payment-methods/999999 → 404, problem details

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

DELETE …/payment-methods/{id} answers 204. While the card pays a payment plan or a scheduled automatic payment (inUse), the answer is 409 payment-method-in-use: change the card on the plan (PUT …/payment-plan/payment-method, Payment plans guide) or on each automatic payment (PUT …/automatic-payments/{id}/payment-method, Automatic payments guide) first. A finished or cancelled plan lets go of the card when it is deleted.

Trax tells the family before a saved card expires: saving a card, or re-entering it with a new expiry date, schedules the reminder for five days before the end of its expiry month, and deleting the card withdraws it. Trax sends it, not this API.

Paying with a saved card

At checkout, send payment.paymentMethodId instead of payment.nonce, with the billing name and address as usual. To keep a card entered at checkout, send "saveCard": true (and optionally "cardName") with its nonce. The Cart and checkout guide has the details.

Status code What to do
400 invalid-request Fix the field named in errors
402 card-declined The card failed the bank's check: ask for another card
404 payment-method-not-found No saved card with this id is yours here: list the cards again
409 payment-method-in-use Change the card on the plan or automatic payment, then delete it
409 payment-methods-limit The person keeps 10 cards: delete one first
409 saved-cards-unavailable Cards can't be saved for this person yet; take the card for each payment instead
409 payments-unavailable The organization takes no card payments online
429 rate-limited Too many cards entered in the last hour
502 payment-unavailable The payment service didn't answer; try again shortly

saved-cards-unavailable while the move from the current portal goes on: the gateway files each person's cards under an id that the current Trax portal makes. Until this API can make the same id, it saves a card only for a person who already has a card saved in the current portal (it finds the id from that card). In development and tests every person can save cards.

In development and tests the stand-in gateway keeps saved cards in memory, so restarting the API forgets them (they are then hidden until saved again). The nonces of the Cart and checkout guide work here too: the declining ones fail the bank's check.

What changed from the current portal