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: "3b39d66b-085e-4cf2-b0bb-bedec353b357"
    successUrl: "https://example.com/success{order}"
    cancelUrl: "https://example.com/cancel"
  ) {
    url
  }
}
mutation CreatePayment {
  createPayment(
    booking: "5e941af0-69ec-4728-935f-559f781087fb"
    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=5768e702-9728-4d95-841a-da78267f6ba0. 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.