Skip to main content
The Payment Sessions API is a unified solution designed to streamline payment processing for merchants.

Key Features

  • Flexible Payment Flows: Handle one-time payments, first-time setup payments for subscriptions, and repeat charges with minimal effort.
  • Branded Checkout Experience: Redirect your customers to a secure, customizable checkout page to complete their transactions.
  • Seamless Recurring Payments: Use saved payment methods for a series of transactions initiated and completed without customer interaction.

Benefits

  • Simplicity: Manage various payment scenarios with a single API.
  • Customizability: Tailor the payment experience to fit your brand.
  • Scalability: Support a variety of payment methods and grow your business globally.

How It Works

1

Create a Payment Session

Start by creating a payment session with all necessary details like amount, currency, and payment type.
2

Redirect if Required

  • For payments, where the customer is present, redirect them to the checkout page provided in the session_url to complete the payment.
  • For recurring payments, where the customer is not present, use the customer’s saved payment method for processing the payment without any customer interaction.
3

Track Payment Status

Monitor the status of your payments in real-time using webhooks or API calls.


Session Type

The API supports three distinct types of payment sessions to uniformly handle both customer-present and customer-not-present payments, as follows:
  • one_time: A one-time payment, where the customer is present in the flow and completes the payment in real-time. This session type also offers the flexibility to save the customer’s payment method for future use during other payments where the customer is present in the flow.
  • first_in_series: The first payment in a series, where the customer is present in the flow, allowing the customer to authorise and save their payment method for future payments where the customer is not present in the flow. This authorisation is referred to as a mandate. This session type is typically used to set up recurring payments, such as subscriptions or installment plans.
  • next_in_series: A next payment in a series, where the customer is not present in the flow, using a previously saved payment method and relying on an existing mandate. This session type is fully programmatic, requires no customer interaction, and is ideal for recurring payments like monthly subscriptions or utility bills.

A mandate is an authorisation that allows a merchant to initiate future payments when the customer is not present in the flow.

The following table summarises the differences:
one_timefirst_in_seriesnext_in_series
Primary PurposeOne-time payment by the customer.First payment to set up future automatic payments.Next payment in a series.
Customer InteractionRequired (customer is present).Required (customer is present).Not required (customer is absent).
Saving Payment MethodOptional (for customer present use).Mandatory (for customer absent use).Not applicable (uses saved method).
Mandate CreationNo mandate created.Mandate created for future payments.Relies on an existing mandate.
Payment FlowCustomer completes via Checkout page.Customer completes via Checkout page.Payment processed programmatically.
ExamplesOne-off purchase with the option to save for future purchases.Subscription setup or installment plan.Monthly subscription charge or utility bill.

Use Cases

There are multiple possible scenarios, each tailored to specific customer and merchant interactions. Below are some examples:
  • Scenario: A one-time payment where the customer is present, and the payment method is not saved for future use.
  • Use Case: Customers making a one-time purchase without any desire to save their payment method for future use.
  • Session Type: one_time
  • Behavior:
    • The customer completes the payment via the hosted Checkout page.
    • The payment method is not saved because the save_payment_method option is set to never.
  • Example: Buying a product or service without storing the card for future payments.
  • Scenario: A one-time payment where the customer is present, and the payment method is only saved for future payments where the customer is present.
  • Use Case: Customers who want to reuse their payment method for other purchases initiated by them in the future.
  • Session Type: one_time
  • Behavior:
    • The customer completes the payment via the hosted Checkout page.
    • The payment method is saved for use when the customer is present and the save_payment_method option is set to always or prompt.
  • Example: Purchasing a product and saving the card for future use during checkout.
  • Scenario: The first payment in a series where the customer is present, and the payment method is saved with a mandate for future payments.
  • Use Case: Merchants setting up recurring payments for subscriptions or installment plans.
  • Session Type: first_in_series
  • Behavior:
    • The customer completes the initial payment via the hosted Checkout page.
    • A mandate is created authorising future payments that occur when the customer is not present.
  • Example: Signing up for a monthly subscription with an initial payment.
  • Scenario: A follow-up payment where the customer is not present, using a payment method saved in a previous first_in_series session.
  • Use Case: A merchant initiates a recurring payment based on an existing mandate.
  • Session Type: next_in_series
  • Behavior:
    • No customer interaction is required.
    • The payment is processed programmatically using the saved payment method and existing mandate.
  • Example: Charging a subscription fee each month.


A quick overview of the differences between these scenarios are as follows:
ScenarioSession TypeCustomer InteractionSaving Payment MethodExamples
One-off payment without savingone_timeRequired (customer-present)NoBuying a product one time.
One-off payment with savingone_timeRequired (customer-present)Yes (for future customer-present use)Purchasing and saving card for later.
Setup for future paymentsfirst_in_seriesRequired (customer-present)Yes (for future customer-not-present use)Signing up for a subscription.
Recurring paymentnext_in_seriesNot required (customer-not-present)Uses previously saved payment methodMonthly subscription charge.

Status

The status field of a payment session represents the current stage in the payment session lifecycle:
The session is currently in progress.
  • For one_time and first_in_series: The session remains in an active state while the customer is interacting with the Checkout page via the session_url. In the event of a failed payment, the session remains in an active state to allow a customer to make another payment attempt. In the event of a successful payment, the session transitions into a completed state.
  • For next_in_series: The session is briefly in an active state while the payment is being processed without customer interaction using a saved payment method. In the event of both successful and failed payments, the session transitions into a completed state.
The payment status (payment_status) will reflect the outcome of the payment, either paid or unpaid. If the payment status is paid the payment_id field represents the associated payment.
The session has completed.
  • For one_time and first_in_series: The session has completed with the customer having completed the payment flow. This typically implies the payment was successful, but should be verified by interrogating the payment status (payment_status) as described below.
  • For next_in_series: The session has completed without customer interaction using a saved payment method, but the payment may have either suceeded or failed. The status should verified by interrogating the payment status field (payment_status) as described below.
The payment status (payment_status) will reflect the outcome of the payment, either paid or unpaid. If the payment status is paid the payment_id field represents the associated payment.
The session expired due to inactivity or a timeout.
  • For one_time and first_in_series: The customer did not complete the checkout process in time.
  • For next_in_series: Not applicable.
The session was explicitly cancelled by the customer or merchant.
  • For one_time and first_in_series: The customer or merchant chose to cancel the payment.
  • For next_in_series: Not applicable
The transitions below ensure that the payment session lifecycle is fully traceable and supports retries where appropriate:
From StateTo StateConditionDescription
activecompletedPayment was successful.The session completed successfully, and the payment was successful. The payment status (payment_status) will reflect the outcome of the payment as paid.
activeactivePayment failed.The session remains in an active state after a failed payment to allow the customer to make another payment attempt.
activeexpiredThe session timed out due to inactivity.The session expired because the customer didn’t complete the payment or the authorization timed out.
activecancelledThe session was explicitly cancelled by the customer or merchant.The session was cancelled during checkout or before the programmatic payment was processed.
From StateTo StateConditionDescription
activecompletedPayment was successful.The session completed successfully, and the payment was successful. The payment status (payment_status) will reflect the outcome of the payment as paid.
activecompletedPayment failed.The session completed successfully, however the payment failed. The payment status (payment_status) will reflect the outcome of the payment as unpaid.

Webhooks

The state of the payment session can be tracked by consuming webhook events. The event will contain a payment_session object that includes, amongst other fields, the created_at, updated_at and payment_id fields. Where applicable the customer_id and payment_method_id fields, that are needed for a subsequent (next_in_series) payment, is also included, and is sometimes referred to as a token. The payment session events are:
  • payment_session.created: Indicates a payment session was created successfully and can be used to initiate the payment process. See the payment_session.created event for more information.
  • payment_session.updated: Indicates a payment session was updated successfully and can be used for tracking the status of the payment session. See the payment_session.updated event for more information.