Payments

Running a travel e-commerce platform requires collecting payments from your end customers. Finding and setting up a payments provider for travel can be a daunting task. We have partnered with Stripe to make this process as easy as possible.

Using the All Aboard Payments gateway you can accept payments from all major credit cards, Apple Pay, Google Pay, and more.

Creating a Payment

Payments are integrated in the API to make it easy to create a payment for a booking. Once you have created a booking and updated the passenger attributes (see booking ticktes and buying Rail Passes) you can create a Payment for the booking.

Example: Create a payment
graphql
mutation CreatePayment {
  createPayment(
    booking: "ea1ed2fe-8fd0-4e77-9789-1a4748fc72c5"
    successUrl: "https://example.com/success{order}"
    cancelUrl: "https://example.com/cancel"
  ) {
    url
  }
}
mutation CreatePayment {
  createPayment(
    booking: "250f0c42-0529-4258-ace1-8b1d6f0052cd"
    successUrl: "https://example.com/success{order}"
    cancelUrl: "https://example.com/cancel"
  ) {
    url
  }
}

The successUrl and cancelUrl are URLs that the customer will be redirected to after completing or cancelling the payment. The urls are processed as URI Templates (RFC 6570) substituting the order parameter.

In the above example this means that the {order} placeholder in the successUrl is substituted with the query parameter ?order=2292621a-529c-48ae-a5ba-d24c2495fe9b. You can use this to redirect the customer to a page where they can view their paid order.

Prefer WebSocket

When creating a Payment an Order is automatically created for you. If the booking includes train tickets they are prebooked when an order is created and so the request can be slow and is recommended to be done over WebSocket.

Handling Payment

The createPayment mutation returns a Payment object with a url field. You should redirect the customer to this URL to complete the payment.

The Browser Back Button

The user will be redirected to the cancelURL only if they cancel the payment from within the payment page. If they use the browser back button, they will come back to wherever they were before they were redirected to the payment page.

Due to technical restraints, with some ticketing providers a booking may only be used to create a single payment. If the user cancels the payment and then tries to create a new payment for the same booking, the request may fail. In this case you should create a new booking and start over.