Switch to dark mode

Cost Centers

A cost center is a named billing setup on your sales agent. It sets the commercial terms of a booking and how the booking is paid. Every agent has a default cost center, which is used for any passenger you don't give another one. Cost centers are set per passenger, so one order can combine several of them, if that is enabled for your sales agent.

With cost centers you can have different commercial setups under one agent. You might have one cost center for your public website and another for a corporate client with negotiated rates, each with its own payment method.

What a cost center controls

A cost center has:

  • Commercial rates: the pricing of bookings made on the cost center.
  • Per-provider preferences: settings such as commercial contracts, corporate rates, commissions and price markup. They can differ between train operators within the same cost center.
  • Service fees: optional fees that you add on top of the ticket price. They are charged to the customer and forwarded to you in full. See Service Fees.
  • Payment methods: how orders on the cost center can be paid: wallet, payment gateway (Stripe) or invoice. See Payment Methods and API Scopes.

All Aboard sets up cost centers for you. Contact team@allaboard.eu to create or change one. In the API, cost centers are read-only: you can list them and choose which one a passenger is billed to.

Accessing cost centers

Read your cost centers from the SalesAgent that the getSalesAgent query returns. Each CostCenter has an id, a name, a default flag and a paymentMethod. If a cost center allows several payment methods, paymentMethod is the one with the highest priority. See Payment Methods and API Scopes.

graphql
query GetCostCenters {
  getSalesAgent {
    uid
    costCenters {
      id
      name
      default
      paymentMethod
    }
  }
}

Use the id to bill passengers to that cost center.

Selecting a cost center for an order

Without a cost center, an order is billed to the agent's default one. To use another, pass passengers to createBooking and set the cost center id on each passenger:

graphql
mutation CreateBooking {
  createBooking(
    offerIds: ["offer_e740y733k0r771r2n5a4p2s0z7"]
    passengers: [
      { type: ADULT, costCenter: { id: "costcenter_a4q363m054t3d6b1v7h6s1v405" } }
      { type: YOUTH, age: 22, costCenter: { id: "costcenter_a4q363m054t3d6b1v7h6s1v405" } }
    ]
  ) {
    id
  }
}

A passenger without a cost center is billed to the agent's default. A ticket booking can also split its passengers across several cost centers, with these rules:

  • Combining cost centers must be enabled for your sales agent. Contact team@allaboard.eu to enable it.
  • If any passenger has a non-default cost center, every passenger needs a cost center.
  • The cost centers must share a payment method, because an order is paid with a single method.
  • Each cost center needs its own contact person.

A rail pass booking always has a single cost center.

A booking that breaks these rules fails with MULTI_COST_CENTER_NOT_SUPPORTED, MIXED_COST_CENTER_SPECIFICATION or MIXED_PAYMENT_METHOD. An unknown cost center id fails with INVALID_ARGUMENT or COST_CENTER_NOT_AVAILABLE. See When a Cost Center Is Refused.

Booking for another sales agent

A sales agent can be given access to other sales agents. A travel agency, for example, can have access to the companies it books for. All Aboard sets this up on request. You then book on the other agent's cost centers, and the booking and the order belong to the agent whose cost center they are on.

Finding the agents you can book for

accessibleSalesAgents lists the sales agents you have access to, with their cost centers. Your own agent is never in the list, and getSalesAgent only returns your own. filter.query matches part of a name or a uid, ignoring case, with the best matches first. Sales agents whose orders are switched off are left out.

name is the sales agent's display name, such as the name of the company or agency. It is null until a name has been recorded, so show the uid instead when it is.

Example: Find a company's cost centers

graphql
query AccessibleSalesAgents {
  accessibleSalesAgents(filter: { query: "acme" }, first: 25) {
    totalCount
    edges {
      node {
        uid
        name
        costCenters {
          id
          name
          default
          paymentMethod
        }
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

The list is paginated. totalCount is the number of sales agents that match the filter. A page holds 25 sales agents by default, and 100 at most. Get the next page with after set to pageInfo.endCursor. A cursor only works with the filter it came from.

Booking on their cost centers

Set one of the agent's cost centers on every passenger, as in Selecting a Cost Center for an Order. The booking is then made on that agent.

Set the cost center when you price the journey too. journeyOffer and combinedJourneyOffer price the passengers with their cost center, so the offers show what the booking will cost.

Example: Price a journey on another agent's cost center

graphql
subscription JourneyOffer {
  journeyOffer(
    journeyId: "b0840b3b-505e-4428-ad02-4ef56528cc10"
    passengers: [
      { type: ADULT, costCenter: { id: "costcenter_a4q363m054t3d6b1v7h6s1v405" } }
    ]
  ) {
    status
    itinerary {
      ... on SegmentCollection {
        offers {
          id
          price {
            amount
            currency
          }
        }
      }
    }
  }
}

All passengers in a booking must have cost centers from the same sales agent. To book people from two companies, make one booking for each.

The order is paid with a payment method of that agent's cost center. Your API key still needs the matching payment scope. See Payment Methods and API Scopes.

Who an order belongs to

An order's salesAgent is the agent whose cost center it is on. That agent is billed for it. createdBy.salesAgent is the agent that placed the order, which is you. createdBy.user is the signed-in user who placed it, if there was one.

graphql
query GetOrder {
  node(id: "order_e451s5s5e1m75064n3x147v306") {
    ... on Order {
      reference
      salesAgent {
        uid
        name
      }
      createdBy {
        salesAgent {
          uid
          name
        }
      }
    }
  }
}

When a cost center is refused

createBooking checks the cost centers on the passengers. The first cost center in the request decides which sales agent the booking is for. The booking fails with:

  • INVALID_ARGUMENT if that cost center doesn't exist.
  • UNAUTHORIZED if it belongs to a sales agent you have no access to.
  • FORBIDDEN if that sales agent's orders are switched off.
  • COST_CENTER_NOT_AVAILABLE if another passenger's cost center isn't one of that agent's, because it belongs to another sales agent or doesn't exist.

Pricing makes the same checks, but doesn't return these codes. A journey priced on a refused cost center has its legs in the status UNKNOWN, without offers. You only get the code from createBooking.

Payment methods and API scopes

Every cost center has one or more payment methods: wallet, payment gateway (Stripe) or invoice. To book on a cost center, your API key needs the payments:* scope for the payment method used. Otherwise the request fails:

Cost center payment method Required scope
Wallet live:payments:wallet / test:payments:wallet
Payment gateway (Stripe) live:payments:stripe / test:payments:stripe
Invoice live:payments:invoice / test:payments:invoice

If a cost center allows more than one method, an order uses the first one that the cost center allows and your key has the scope for, in this order: invoice, wallet, payment gateway. A key with only the payments:stripe scope therefore always pays through the payment gateway.

See API Scopes for the full list of scopes and how to choose them.

Embeds

Embeds run on public pages and need a restricted credential. See Configuring embeds safely.

Service fees

If you use the embeds, a cost center can have service fees. Like the rest of a cost center, they are set up by All Aboard on request. A service fee is added on top of the ticket price and charged to the customer at checkout, through the payment gateway. It is forwarded to you in full.

A cost center can have several fees. Each one is:

  • A fixed price per order: a flat amount added once per order.
  • A fixed price per ticket or pass: a flat amount for each offer or pass in the order that has a price. Free ones, such as a child's pass, don't count.
  • A percentage of the order value: a percentage of the order total.

The fee is calculated when the booking is priced, and shows up as the booking's ticketingFee.

Service fees are collected through the payment gateway, so they only apply to cost centers that use the Stripe payment method. They are paid out to you monthly. See Fees and Reconciliation for how they appear in your monthly reconciliation.

Configuring embeds safely

Anything you pass to an embed is visible to anyone who views the page. Which credential to pass depends on what the embed does.

Booking embeds

The Journey List, Offer Selection, Rail Pass List and Rail Pass Modal embeds let customers search and pay for a new booking. Give them a key that can only use the payment gateway:

  • Use an API key with only the base scope and *:payments:stripe, for example live and live:payments:stripe. The base scope is required for any request.
  • Do not give a public embed key orders:read, passenger_profiles:read, payments:wallet or payments:invoice.

With only those two scopes, customers can pay for their own bookings through the payment gateway. The key can't read your orders, and it can't create orders that are paid from your wallet or by invoice. The cost center the embed uses must have the payment gateway as a payment method, so that it matches the key.

Order management embeds

The Refund Manager embed works on an order that already exists, so it has to read and refund that order. A key with only the two scopes above can't do that, and an API key that can would reach every order on your sales agent. Pass an access token instead. You mint it on your server for that one order, and it expires on its own.

Never put an API key with orders:read on a public page.

API Scopes
Choosing scopes for your API keys.
Access Tokens
Order-bound credentials for public pages.
Payment Methods
How each payment flow works.
Fees and Reconciliation
Service fees and monthly settlement.
Embeds
Add All Aboard features to your website.