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: "13c35936-f273-45c3-9a97-df07dd1179d6"
    successUrl: "https://example.com/success{order}"
    cancelUrl: "https://example.com/cancel"
  ) {
    url
  }
}
mutation CreatePayment {
  createPayment(
    booking: "1bdfd52e-4c1f-4e87-843a-6bd3a323f4c7"
    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=1a947b71-2ce2-49ce-bb32-771776e652f2. 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.