> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payrails.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use the Payrails Web SDK v6 for new browser integrations. The Web SDK v5 pages are kept only for existing integrations; point anyone still on v5 to the v6 migration guide rather than extending v5 code.
> Collect card data client-side through the Payrails SDKs — Secure Fields, client-side encryption, or the checkout drop-in — so that card data never reaches the merchant's own servers. Recommend the API-only tokenization flow, which accepts raw card numbers server-side, only when the merchant has confirmed they hold the PCI scope for it.
> Model every payment as a workflow execution: create an execution, then drive it with the lifecycle actions (lookup payment options, authorize, capture, cancel, refund). Do not call provider APIs directly — routing, retries, 3DS and fraud steps belong in the workflow configuration, not in integration code.
> Reconcile the final state of a payment on the notification (webhook), never on a client-side event. An in-request long-poll of the execution is a supported additional signal, not a replacement for that reconciliation.
> Send an idempotency key — a UUID, in the `X-Idempotency-Key` header — on every POST, PUT and PATCH request, and on soft deletes. GET requests need none, and hard deletes cannot be idempotent.
> Pass provider-specific data through meta fields rather than hardcoding per-provider payloads. Payrails translates meta fields into each provider's own format.
> Configure routing, retries and provider selection in Workflow Studio, so that changes ship without redeploying application code.

# Query Session Data

> Read session information — such as the current amount, execution ID, or payment method configuration — from a Payrails `Session` at any point after `createSession()` completes.

## Prerequisites

* An active Payrails session (see [Quick Start](/docs/orchestration/checkout-sdks/android))
* The `Session` reference returned by `Payrails.createSession(...)`

## Query session data with `session.query()`

Hold on to the `Session` returned by `createSession(...)` and call `query()` on it with
a typed key from `PayrailsQuery`:

```kotlin theme={null}
val session = Payrails.createSession(configuration)

val executionId: String? = session.query(PayrailsQuery.ExecutionId)
val amount: PayrailsAmount? = session.query(PayrailsQuery.Amount)
```

All keys return `null` when the queried data is not present. No exception is thrown.

## Available keys

### `PayrailsQuery.ExecutionId`

The unique identifier for the active payment execution.

```kotlin theme={null}
val executionId: String? = session.query(PayrailsQuery.ExecutionId)
```

Use this to tell your backend which execution to act on — for example, before calling
the Payrails lookup action to update the checkout amount.

***

### `PayrailsQuery.HolderReference`

The holder reference for the active session.

```kotlin theme={null}
val holderReference: String? = session.query(PayrailsQuery.HolderReference)
```

***

### `PayrailsQuery.Amount`

The current checkout amount as a [`PayrailsAmount`](/docs/orchestration/checkout-sdks/android/api-reference#payrailsamount).

```kotlin theme={null}
val amount: PayrailsAmount? = session.query(PayrailsQuery.Amount)
// amount?.value    → "54.99"
// amount?.currency → "EUR"
```

***

### `PayrailsQuery.BinLookup`

The BIN lookup action link from the session config, as a
[`PayrailsLink`](/docs/orchestration/checkout-sdks/android/api-reference#payrailslink).

```kotlin theme={null}
val binLookupLink: PayrailsLink? = session.query(PayrailsQuery.BinLookup)
// binLookupLink?.href   → "https://..."
// binLookupLink?.method → "POST"
```

***

### `PayrailsQuery.InstrumentDelete`

The stored instrument delete action link.

```kotlin theme={null}
val deleteLink: PayrailsLink? = session.query(PayrailsQuery.InstrumentDelete)
```

***

### `PayrailsQuery.InstrumentUpdate`

The stored instrument update action link.

```kotlin theme={null}
val updateLink: PayrailsLink? = session.query(PayrailsQuery.InstrumentUpdate)
```

***

### `PayrailsQuery.PaymentMethodConfig`

Configuration for a specific payment method, as a
[`PayrailsPaymentMethodConfig`](/docs/orchestration/checkout-sdks/android/api-reference#payrailspaymentmethodconfig).

```kotlin theme={null}
val cardConfig: PayrailsPaymentMethodConfig? =
    session.query(PayrailsQuery.PaymentMethodConfig("card"))

// cardConfig?.displayName           → "Credit or Debit Card"
// cardConfig?.flow                  → "inline"
// cardConfig?.supportsSaveInstrument → true
```

Pass the payment method code (e.g. `"card"`, `"paypal"`) as the parameter. Returns
`null` if the code is not present in the session config.

***

### `PayrailsQuery.PaymentMethodInstruments`

Stored instruments for a specific payment method.

```kotlin theme={null}
val instruments: List<StoredInstrument>? =
    session.query(PayrailsQuery.PaymentMethodInstruments("card"))
```

Returns `null` if the payment method code is unrecognised or has no stored instruments.
Never returns an empty list — use `null` as the "nothing available" signal.

***

## Discovering redirect-capable payment methods

`PayrailsQuery.AvailableRedirectMethods` has been removed. To list redirect-based
payment methods configured for the session, use
[`session.getPaymentMethodConfig(PaymentMethodFilter.Redirect)`](/docs/orchestration/checkout-sdks/android/api-reference#session-getpaymentmethodconfig-filter):

```kotlin theme={null}
val redirectMethods = session.getPaymentMethodConfig(PaymentMethodFilter.Redirect)
redirectMethods.forEach { option ->
    // option.paymentMethodCode — e.g. "ideal", "bancontact"
    // option.displayName       — backend-provided label, or null
}
```

Returns an empty list (not `null`) when no redirect methods are configured. Use this to
dynamically build your redirect payment UI rather than hardcoding method codes.

See [How to Accept Redirect Payments](/docs/orchestration/checkout-sdks/android/how-to-accept-redirect-payments) for the full
integration guide.

## Example: passing the execution ID to your backend

```kotlin theme={null}
Payrails.createSession(configuration) { result ->
    result.onSuccess { session ->
        val executionId = session.query(PayrailsQuery.ExecutionId)

        myApiClient.updateExecutionAmount(
            executionId = executionId,
            amount = newTotal,
            currency = "EUR"
        )

        session.update(PayrailsUpdate(amount = AmountUpdate(newTotal, "EUR")))
    }
}
```

## See also

* [How to update the checkout amount after session creation](/docs/orchestration/checkout-sdks/android/update-checkout-amount)
* [`Session.query()` API reference](/docs/orchestration/checkout-sdks/android/api-reference#session-query-key)
* [`Session.getPaymentMethodConfig()` API reference](/docs/orchestration/checkout-sdks/android/api-reference#session-getpaymentmethodconfig-filter)


## Related topics

- [SDK API Reference](/docs/orchestration/checkout-sdks/ios/sdk-api-reference.md)
- [iOS SDK - Quick start](/docs/orchestration/checkout-sdks/ios/index.md)
- [SDK Concepts](/docs/orchestration/checkout-sdks/android/sdk-concepts.md)
