> ## 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.

# PrimerHeadlessUniversalCheckoutRawDataManagerListener

## Overview

Set the `PrimerHeadlessUniversalCheckoutRawDataManagerListener` in order to receive different
callbacks from Primer SDK.

### onValidationChanged

```kotlin KOTLIN theme={"dark"}
fun onValidationChanged(isValid: Boolean, errors: List<PrimerInputValidationError>)
```

Returns whether the `rawData` set by [setRawData](/sdk/android/v2.x.x/primer-headless-checkout/raw-data-manager/setRawData) is valid, and all
the errors that occurred during validation.

#### Parameters

<Expandable title="Parameters" defaultOpen>
  <ResponseField name="isValid" type="Boolean" required>
    Returns `true` in case raw data is valid, otherwise `false`.
  </ResponseField>

  <ResponseField name="errors" type="List<PrimerInputValidationError>" required>
    Returns all of the validation errors for a raw data.

    <Expandable title="PrimerInputValidationError">
      <Expandable title="Properties">
        <ResponseField name="errorId" type="String" required>
          A unique error identifier.
        </ResponseField>

        <ResponseField name="description" type="String" required>
          An error description.
        </ResponseField>

        <ResponseField name="inputElementType" type="PrimerInputElementType" required>
          A input element associated with the error returned.
        </ResponseField>

        <ResponseField name="diagnosticsId" type="String" required>
          A unique diagnostics id for the given error.
        </ResponseField>
      </Expandable>
    </Expandable>
  </ResponseField>
</Expandable>

### onMetadataChanged

Returns metadata for the current data set by using the [setRawData](/sdk/android/v2.x.x/primer-headless-checkout/raw-data-manager/setRawData).
This synchronous callback provides immediate metadata updates based on internal SDK calculations.
Check the section below for the metadata types that can be returned.

```kotlin KOTLIN theme={"dark"}
fun onMetadataChanged(metadata: PrimerPaymentMethodMetadata)
```

#### Parameters

<Expandable title="Parameters" defaultOpen>
  <ResponseField name="metadata" type="PrimerPaymentMethodMetadata">
    <Expandable title="Direct Subclasses">
      <ResponseField name="PrimerCardMetadata">
        <Expandable title="Properties" defaultOpen>
          <ResponseField name="cardNetwork" type="CardNetwork.Type" required />

          <ResponseField name="CardNetwork.Type.OTHER">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.VISA">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.MASTERCARD">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.AMEX">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.DINERS_CLUB">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.DISCOVER">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.JCB">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.UNIONPAY">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.MAESTRO">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.ELO">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.MIR">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.HIPER">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.HIPERCARD">
            {}
          </ResponseField>

          <ResponseField name="CardNetwork.Type.CARTES_BANCAIRES">
            {}
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>

### onMetadataStateChanged

Returns metadata state for the current data set by using
the [setRawData](/sdk/android/v2.x.x/primer-headless-checkout/raw-data-manager/setRawData).

In contrast to `onMetadataChanged`, this callback involves internal asynchronous operations,
offering a broader and more accurate dataset that can be fetched remotely.
Its dynamic nature enables you to access the current state of SDK operations,
providing an opportunity to tailor the UI accordingly.

Check the section below for the metadata state types that can be returned.

```kotlin KOTLIN theme={"dark"}
fun onMetadataStateChanged(metadataState: PrimerPaymentMethodMetadataState)
```

#### Parameters

<Expandable title="Parameters" defaultOpen>
  <ResponseField name="metadataState" type="PrimerPaymentMethodMetadataState">
    <Expandable title="Direct Subclasses">
      <ResponseField name="sealed class PrimerCardMetadataState">
        <Expandable title="States">
          <ResponseField name="Fetching">
            <Expandable title="Properties" defaultOpen>
              <ResponseField name="cardNumberEntryState" type="PrimerCardNumberEntryState" required>
                The state of card number entry triggered the metadata fetch.

                <Expandable title="Properties" defaultOpen>
                  <ResponseField name="cardNumber" type="String" required>
                    The entered card number.
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="Fetched">
            <Expandable title="Properties" defaultOpen>
              <ResponseField name="cardNumberEntryState" type="PrimerCardNumberEntryState" required>
                The state of card number entry triggered the metadata fetch.

                <Expandable title="Properties" defaultOpen>
                  <ResponseField name="cardNumber" type="String" required>
                    The entered card number.
                  </ResponseField>
                </Expandable>
              </ResponseField>

              <ResponseField name="cardNumberEntryMetadata" type="PrimerCardNumberEntryMetadata" required>
                Represents metadata for PrimerCardNumberEntry, including selectable
                (co-badged) and detected card networks.

                <Expandable title="Properties" defaultOpen>
                  <ResponseField name="selectableCardNetworks" type="PrimerCardNetworksMetadata?">
                    Selectable card networks for a given card number, will be null in case
                    card network is not co-badged.

                    <Expandable title="Properties">
                      <ResponseField name="items" type="List<PrimerCardNetwork>">
                        <Expandable title="PrimerCardNetwork">
                          <ResponseField name="cardNetwork" type="PrimerCardNetwork">
                            Represents a card network with metadata including display name, network type, and whether it is allowed.

                            <Expandable title="Properties">
                              <ResponseField name="network" type="CardNetwork.Type">
                                The type of card network (e.g., VISA, MASTERCARD).
                              </ResponseField>

                              <ResponseField name="displayName" type="String">
                                The human-readable name of the card network (e.g., Visa, Mastercard).
                              </ResponseField>

                              <ResponseField name="allowed" type="Boolean" required>
                                A boolean indicating whether this card network is allowed.
                              </ResponseField>
                            </Expandable>
                          </ResponseField>
                        </Expandable>
                      </ResponseField>

                      <ResponseField name="preferred" type="PrimerCardNetwork?">
                        <Expandable title="PrimerCardNetwork">
                          <ResponseField name="cardNetwork" type="PrimerCardNetwork">
                            Represents a card network with metadata including display name, network type, and whether it is allowed.

                            <Expandable title="Properties">
                              <ResponseField name="network" type="CardNetwork.Type">
                                The type of card network (e.g., VISA, MASTERCARD).
                              </ResponseField>

                              <ResponseField name="displayName" type="String">
                                The human-readable name of the card network (e.g., Visa, Mastercard).
                              </ResponseField>

                              <ResponseField name="allowed" type="Boolean" required>
                                A boolean indicating whether this card network is allowed.
                              </ResponseField>
                            </Expandable>
                          </ResponseField>
                        </Expandable>
                      </ResponseField>
                    </Expandable>
                  </ResponseField>

                  <ResponseField name="detectedCardNetworks" type="PrimerCardNetworksMetadata" required>
                    All detected card networks for a given card number.

                    <Expandable title="Properties">
                      <ResponseField name="items" type="List<PrimerCardNetwork>">
                        <Expandable title="PrimerCardNetwork">
                          <ResponseField name="cardNetwork" type="PrimerCardNetwork">
                            Represents a card network with metadata including display name, network type, and whether it is allowed.

                            <Expandable title="Properties">
                              <ResponseField name="network" type="CardNetwork.Type">
                                The type of card network (e.g., VISA, MASTERCARD).
                              </ResponseField>

                              <ResponseField name="displayName" type="String">
                                The human-readable name of the card network (e.g., Visa, Mastercard).
                              </ResponseField>

                              <ResponseField name="allowed" type="Boolean" required>
                                A boolean indicating whether this card network is allowed.
                              </ResponseField>
                            </Expandable>
                          </ResponseField>
                        </Expandable>
                      </ResponseField>

                      <ResponseField name="preferred" type="PrimerCardNetwork?">
                        <Expandable title="PrimerCardNetwork">
                          <ResponseField name="cardNetwork" type="PrimerCardNetwork">
                            Represents a card network with metadata including display name, network type, and whether it is allowed.

                            <Expandable title="Properties">
                              <ResponseField name="network" type="CardNetwork.Type">
                                The type of card network (e.g., VISA, MASTERCARD).
                              </ResponseField>

                              <ResponseField name="displayName" type="String">
                                The human-readable name of the card network (e.g., Visa, Mastercard).
                              </ResponseField>

                              <ResponseField name="allowed" type="Boolean" required>
                                A boolean indicating whether this card network is allowed.
                              </ResponseField>
                            </Expandable>
                          </ResponseField>
                        </Expandable>
                      </ResponseField>
                    </Expandable>
                  </ResponseField>

                  <ResponseField name="source" type="enum ValidationSource" required>
                    Enum class representing the source of validation for card metadata.

                    <Expandable title="cases" defaultOpen>
                      <ResponseField name="ValidationSource.REMOTE">
                        The data comes from Primer API.
                      </ResponseField>

                      <ResponseField name="ValidationSource.LOCAL_FALLBACK">
                        The data comes from the SDK if Primer's server fails to be reached.
                        This works similarly to LOCAL.
                      </ResponseField>

                      <ResponseField name="ValidationSource.LOCAL">
                        The data comes from the SDK, usually by levering the first few digits.
                      </ResponseField>
                    </Expandable>
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>

### onBinDataAvailable

Called when the SDK detects BIN data from the card number entered by the user.
This callback provides detailed information about the card including issuer details and card attributes.
It delivers BIN data independently from the metadata state callbacks and has a default no-op implementation, so overriding it is optional.

```kotlin KOTLIN theme={"dark"}
fun onBinDataAvailable(binData: PrimerPaymentMethodBinData)
```

#### Parameters

<Expandable title="Parameters" defaultOpen>
  <ResponseField name="binData" type="PrimerPaymentMethodBinData">
    <Expandable title="Direct Subclasses">
      <ResponseField name="PrimerBinData">
        <Expandable title="Properties" defaultOpen>
          <ResponseField name="preferred" type="PrimerCardBinData?">
            The recommended card network to use, based on the order specified in `orderedAllowedCardNetworks` in the Client Session. `null` if no network is allowed or data is not yet resolved.

            <Expandable title="PrimerCardBinData Properties">
              <ResponseField name="network" type="CardNetwork.Type" required>
                A value that represents the card network in Primer's systems.
              </ResponseField>

              <ResponseField name="displayName" type="String" required>
                A human-readable name for the card network (e.g., "Visa", "Mastercard").
              </ResponseField>

              <ResponseField name="issuerCountryCode" type="String" required>
                The ISO 3166-1 alpha-2 country code of the card issuer.
              </ResponseField>

              <ResponseField name="issuerName" type="String?">
                The name of the card issuer (e.g., bank name).
              </ResponseField>

              <ResponseField name="accountFundingType" type="String" required>
                The type of account funding (e.g., "CREDIT", "DEBIT", "PREPAID").
              </ResponseField>

              <ResponseField name="prepaidReloadableIndicator" type="String" required>
                Indicates whether a prepaid card is reloadable.
              </ResponseField>

              <ResponseField name="productUsageType" type="String" required>
                The usage type of the card product (e.g., "CONSUMER", "COMMERCIAL").
              </ResponseField>

              <ResponseField name="productCode" type="String" required>
                The product code assigned by the card network.
              </ResponseField>

              <ResponseField name="productName" type="String" required>
                The product name assigned by the card network (e.g., "Visa Signature").
              </ResponseField>

              <ResponseField name="issuerCurrencyCode" type="String?">
                The ISO 4217 currency code associated with the card issuer.
              </ResponseField>

              <ResponseField name="regionalRestriction" type="String" required>
                Regional restrictions that apply to the card.
              </ResponseField>

              <ResponseField name="accountNumberType" type="String" required>
                The type of account number (e.g., "PAN", "TOKEN").
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="alternatives" type="List<PrimerCardBinData>" required>
            All detected card networks, including ones that are not allowed. For co-badged cards, this list contains multiple networks.
          </ResponseField>

          <ResponseField name="status" type="PrimerBinDataStatus" required>
            The status of the BIN data retrieval.

            <Expandable title="Values" defaultOpen>
              <ResponseField name="COMPLETE">
                This happens when 8 digits or more are entered in the card number field. The SDK retrieved the BIN data using Primer's BIN data service, providing the most accurate information including issuer details.
              </ResponseField>

              <ResponseField name="PARTIAL">
                This happens when fewer than 8 digits are entered in the card number field, or when the SDK fails to contact Primer's BIN data service. The SDK retrieved the card networks using static information bundled with the SDK. This can only identify international card networks and does not include issuer details.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="firstDigits" type="String?">
            The first digits (BIN prefix) of the card number, when available.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>
