Skip to content

A payment session is an in-progress payment transaction. It is a temporary, time-limited context created when a client initiates a payment flow.

It becomes a secure, stateful environment for completing a payment transaction. Instead of passing sensitive payment data on every request, the payment session persists transaction details. This includes the amount, currency, payment methods, and status. It exposes only the payment session identifier to the client. This reduces the risk of data exposure.

A payment session is used only with Flute Elements or Flute Checkout. The paymentSessionType field records which one:

  • A Flute Checkout session is for Flute's own hosted payment page. Create one with POST /v2/payment-sessions/checkout, then redirect the customer to the returned checkoutUrl.
  • A Flute Elements session is for a merchant-built UI using the Flute Elements SDK. Create one with POST /v2/payment-sessions/elements, then initialize the SDK with the returned paymentSessionId.

Both creation endpoints return the same session object, and so does retrieving one.

The following is a common workflow for using a payment session.

  • Create the payment session, as a Flute Checkout or a Flute Elements session.
  • Connect through Flute Elements or Flute Checkout. This may include selecting a payment method, applying discounts or promotions, authorizing the payment, and capturing the funds. Many of these individual steps will be transparent to the client when using Flute Elements or Flute Checkout.

At each step, the payment session holds the transaction state. This means each step can update the session without resubmitting the full transaction data. If the client navigates away but later returns, the session can be retrieved by its identifier with GET /v2/payment-sessions/{{paymentSessionId}}. The flow resumes from its last state.

The paymentSessionStatus field tracks where the session stands. The session ends in one of these statuses:

  • Completed. The payment, or the vault for a SaveMethod session, succeeded. paymentSessionResult carries what it produced: the saved payment method, the charged transaction, or both.
  • Failed. A payment attempt on the session failed. Create a new session to retry.
  • Cancelled. The merchant canceled the session with POST /v2/payment-sessions/{{paymentSessionId}}/cancel, while it was still Created. A new session must be started to try again.
  • Expired. The session's expiresOn passed while it was still Created. A payment submitted just before expiresOn can still move an Expired session to Completed or Failed.