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

# Checkout data

> The payment result types and the client session object that Primer Checkout passes to your app.

> [!WARNING]
>
> Primer Checkout React Native SDK is currently in **beta** (v3.0.0-beta.1).
> The API is subject to change before the stable release.

Primer Checkout passes the payment result and the client session to your app as plain objects. This page describes their types and fields. Every type is exported from `'@primer-io/react-native'` as a type, for example `import type { PaymentOutcome } from '@primer-io/react-native'`. The code blocks below show the shape of each type, not code to copy.

| Type | Where you get it |
| - | - |
| [`PaymentOutcome`](#paymentoutcome) | `usePrimerCheckout().paymentOutcome` |
| [`CheckoutData`](#checkoutdata) | `onCheckoutComplete(checkoutData)`, `onError(error, checkoutData)`, and `data` of a `PaymentOutcome` |
| [`ClientSession`](#clientsession) | `usePrimerCheckout().clientSession`, and `settings.headlessUniversalCheckoutCallbacks.onClientSessionUpdate` |
| [`CheckoutPaymentMethodData`](#checkoutpaymentmethoddata) | `onBeforePaymentCreate(data, handler)` |

## PaymentOutcome

The outcome of the most recent payment attempt. Initialization failures go to `usePrimerCheckout().error` instead.

```tsx theme={"dark"}
type PaymentOutcome =
  | { status: 'success'; data: CheckoutData }
  | { status: 'pending'; data: CheckoutData }
  | { status: 'error'; error: PrimerError; data: CheckoutData | null };
```

| `status` | Fields | Description |
| - | - | - |
| `'success'` | `data: CheckoutData` | A payment was created and not reported as failed. |
| `'pending'` | `data: CheckoutData` | A Stripe ACH payment that is authorized and waits for settlement. |
| `'error'` | `error: PrimerError`, `data: CheckoutData \| null` | The attempt failed. `data` holds the checkout data that came with the error, if any. See [`PrimerError`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-error). |

`paymentOutcome` is `null` before the first attempt and after you call `clearPaymentOutcome()` from [`usePrimerCheckout`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout).

```tsx theme={"dark"}
import { useEffect } from 'react';
import { usePrimerCheckout } from '@primer-io/react-native';
import type { PaymentOutcome } from '@primer-io/react-native';

function describeOutcome(outcome: PaymentOutcome): string {
  switch (outcome.status) {
    case 'success':
      return `Paid, payment ${outcome.data.payment?.id ?? 'unknown'}`;
    case 'pending':
      return 'Payment authorized, waiting for settlement';
    case 'error':
      return `Payment failed [${outcome.error.errorId}]`;
  }
}

export function OutcomeLogger() {
  const { paymentOutcome } = usePrimerCheckout();

  useEffect(() => {
    if (paymentOutcome) {
      console.log(describeOutcome(paymentOutcome));
    }
  }, [paymentOutcome]);

  return null;
}
```

See [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md) for the full flow.

## CheckoutData

Data about the payment that the native SDK sends with a result. `onCheckoutComplete` receives it when a payment is created.

```tsx theme={"dark"}
type CheckoutData = {
  payment?: CheckoutDataPayment;
  additionalInfo?: CheckoutAdditionalInfo;
};
```

| Field | Type | Description |
| - | - | - |
| `payment` | `CheckoutDataPayment \| undefined` | The payment that was created. |
| `additionalInfo` | `CheckoutAdditionalInfo \| undefined` | Extra information some payment methods send with the result. Its `additionalInfoName` field names the kind of information. |

### CheckoutAdditionalInfo

`CheckoutAdditionalInfo` and `MultibancoCheckoutAdditionalInfo` are exported as types. The same types are passed to `onCheckoutPending` and `onCheckoutAdditionalInfo` in `settings.headlessUniversalCheckoutCallbacks`.

```tsx theme={"dark"}
type CheckoutAdditionalInfo = {
  additionalInfoName: string;
};

type MultibancoCheckoutAdditionalInfo = {
  additionalInfoName: 'MultibancoCheckoutAdditionalInfo';
  expiresAt?: string;
  entity?: string;
  reference?: string;
};
```

Check `additionalInfoName` before you read the fields of a specific type.

### CheckoutDataPayment

```tsx theme={"dark"}
type CheckoutDataPayment = {
  id?: string;
  orderId?: string;
  status?: 'SUCCESS' | 'FAILED' | 'PENDING';
  paymentFailureReason?: 'payment-failed' | 'cancelled-by-customer';
};
```

| Field | Type | Description |
| - | - | - |
| `id` | `string \| undefined` | The Primer payment ID. |
| `orderId` | `string \| undefined` | The order ID of the payment. |
| `status` | `'SUCCESS' \| 'FAILED' \| 'PENDING' \| undefined` | Payment status, when the native SDK sends it. |
| `paymentFailureReason` | `'payment-failed' \| 'cancelled-by-customer' \| undefined` | Failure reason, when the native SDK sends it. |

## ClientSession

The client session the native SDK loaded for your `clientToken`. Read it from `usePrimerCheckout().clientSession`. It is `null` until the native SDK first sends the session, and it updates when the session changes, for example after a billing address is set. Always handle `null`.

```tsx theme={"dark"}
type ClientSession = {
  customerId?: string;
  orderId?: string;
  currencyCode?: string;
  totalAmount?: number;
  lineItems?: LineItem[];
  orderDetails?: Order;
  customer?: Customer;
  checkoutModules?: { type: string; options?: Record<string, boolean> }[];
};
```

| Field | Type | Description |
| - | - | - |
| `customerId` | `string \| undefined` | Customer ID from the client session. |
| `orderId` | `string \| undefined` | Order ID from the client session. |
| `currencyCode` | `string \| undefined` | ISO 4217 currency code, for example `'EUR'`. |
| `totalAmount` | `number \| undefined` | Order total in minor units, for example `1050` for €10.50. |
| `lineItems` | [`LineItem[]`](#lineitem) `\| undefined` | The order's line items. |
| `orderDetails` | [`Order`](#order) `\| undefined` | The order's country and shipping details. |
| `customer` | [`Customer`](#customer) `\| undefined` | Customer details and addresses. |
| `checkoutModules` | `{ type: string; options?: Record<string, boolean> }[] \| undefined` | Checkout modules of the session with their options, for example `BILLING_ADDRESS` with one flag per address field, or `CARD_INFORMATION` with `cardHolderName`. Primer Checkout reads them to decide which billing address fields and whether the cardholder name field to show. |

Every field is optional, because each depends on how you created the client session.

To format `totalAmount`, use `formatCurrency` from [`usePrimerLocalization`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/use-primer-localization). See [Client session](https://primer.io/docs/checkout/client-session.md) for how to create the session on your server.

### LineItem

| Field | Type | Description |
| - | - | - |
| `itemId` | `string \| undefined` | Your ID for the item. |
| `itemDescription` | `string \| undefined` | Description of the item. |
| `amount` | `number \| undefined` | Unit amount in minor units. |
| `discountAmount` | `number \| undefined` | Discount on the item, in minor units. |
| `quantity` | `number \| undefined` | Number of units. |

### Order

| Field | Type | Description |
| - | - | - |
| `countryCode` | `string \| undefined` | The order's ISO 3166-1 alpha-2 country code. |
| `shipping` | `{ amount?: number; methodId?: string; methodName?: string; methodDescription?: string } \| undefined` | The selected shipping method and its amount in minor units. |

### Customer

| Field | Type | Description |
| - | - | - |
| `emailAddress` | `string \| undefined` | Email address. |
| `mobileNumber` | `string \| undefined` | Phone number. |
| `firstName`, `lastName` | `string \| undefined` | Customer name. |
| `billingAddress` | [`Address`](#address) `\| undefined` | Billing address. |
| `shippingAddress` | [`Address`](#address) `\| undefined` | Shipping address. |

### Address

| Field | Type | Description |
| - | - | - |
| `firstName`, `lastName` | `string \| undefined` | Name on the address. |
| `addressLine1`, `addressLine2` | `string \| undefined` | Street address. |
| `postalCode` | `string \| undefined` | Postal or ZIP code. |
| `city` | `string \| undefined` | City. |
| `state` | `string \| undefined` | State, province or region. |
| `countryCode` | `string \| undefined` | ISO 3166-1 alpha-2 country code. |

### Usage

```tsx theme={"dark"}
import { Text } from 'react-native';
import { usePrimerCheckout, usePrimerLocalization } from '@primer-io/react-native';

export function OrderSummary() {
  const { clientSession } = usePrimerCheckout();
  const { formatCurrency } = usePrimerLocalization();

  if (clientSession?.totalAmount == null || !clientSession.currencyCode) {
    return null;
  }

  return (
    <Text>
      Items: {clientSession.lineItems?.length ?? 0},{' '}
      {formatCurrency(clientSession.totalAmount, clientSession.currencyCode)}
    </Text>
  );
}
```

## CheckoutPaymentMethodData

Passed to `onBeforePaymentCreate`, the prop of [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider), before the payment is created.

| Field | Type | Description |
| - | - | - |
| `paymentMethod` | `string` | The payment method type, for example `'PAYMENT_CARD'`. |

## See also

> [card] [usePrimerCheckout](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout.md)
>
> `paymentOutcome`, `clientSession` and `clearPaymentOutcome()`

> [card] [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md)
>
> Route your UI on the payment result

> [card] [PrimerError](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-error.md)
>
> The error in a failed outcome

> [card] [PrimerCheckoutProvider](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider.md)
>
> The callbacks that receive checkout data


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.