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: "bb5964ec-c6eb-44ea-8c77-8e84419d526a"
    successUrl: "https://example.com/success{order}"
    cancelUrl: "https://example.com/cancel"
  ) {
    url
  }
}
mutation CreatePayment {
  createPayment(
    booking: "2c663c2f-b5b4-40d7-8de2-609b78f76ace"
    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=bd4a5f58-cc76-4506-8424-891a4adfb3a8. 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.