Overview

Set the PrimerHeadlessUniversalCheckoutRawDataManagerDelegate in order to receive different callbacks from your RawDataManager.

primerRawDataManager(_:dataIsValid:)

Returns whether the rawData set is valid, and all the errors that occurred during validation.

1
func primerRawDataManager(_ rawDataManager: PrimerHeadlessUniversalCheckout.RawDataManager, dataIsValid isValid: Bool, errors: [Error]?)
swift
copy

Parameters

rawDataManager
PrimerHeadlessUniversalCheckout.RawDataManager
The instance of the raw data manager calling this delegate method
Whether the data is valid
errors
Array<Error>
The errors that occured during the validation

primerRawDataManager(_:willFetchMetadataForState:)

Called when we begin to fetch metadata forthe current rawData. Changing rawData triggers this callback. Some time after this is called, primerRawDataManager(_:didReceiveMetadata:forState:) will be called with the relevant metadata for the state.

Use this method to indicate to the user that metadata is being fetched; for example, by showing a loading spinner or other UI until the metadata has been returned.

12
func primerRawDataManager(_ rawDataManager: PrimerHeadlessUniversalCheckout.RawDataManager,                          willFetchMetadataForState state: PrimerValidationState)
swift
copy

Parameters

rawDataManager
PrimerHeadlessUniversalCheckout.RawDataManager
The instance of the raw data manager calling this delegate method.
state
PrimerValidationState

An object containing the state that triggered the metadata fetch. For example, for card number entry, this will be an instance of PrimerCardNumberEntryState

Implementations

Used when rawData is set to PrimerCardData

Properties
cardNumber
StringRequired

The card number set on rawData that triggered the metadata fetch

primerRawDataManager(_:didReceiveMetadata:forState:)

Called when new validation metadata relating to the current validation state is received. This will always be called some time after primerRawDataManager(_:willFetchMetadataForState:) is called.

Use this method to query new validation metadata, add informational UI, or allow the user to add additional payment information required to make a payment.

123
func primerRawDataManager(_ rawDataManager: PrimerHeadlessUniversalCheckout.RawDataManager,                          didReceiveMetadata metadata: PrimerPaymentMethodMetadata,                          forState state: PrimerValidationState)
swift
copy

Parameters

rawDataManager
PrimerHeadlessUniversalCheckout.RawDataManager
The instance of the raw data manager calling this delegate method.
metadata
PrimerPaymentMethodMetadata

An object containing metadata for the relevant state also returned with this method.

Implementations

Used when rawData is set to PrimerCardData

Properties
cardNumber
StringRequired

The card number set on rawData that triggered the metadata fetch

state
PrimerValidationState

An object containing the state that triggered the metadata fetch. For example, for card number entry, this will be an instance of PrimerCardNumberEntryState

Implementations
Card network metadata including selectable card networks and detected card networks.
Properties
source
PrimerCardValidationSourceRequired
Enum value indicating the source of the validation.
cases
Indicates that remote validation occurred using Primer APIs.
Indicates that remote validation was attempted but could not be completed, causing a fallback to local validation.
Indicates that the validation occurred locally, usually leveraging the first few digits of the card number.
selectableCardNetworks
PrimerCardNetworksMetadata?
Card networks for the given card number that can be selected by the user prior to payment. This will be null in the case that a network is co-badged, or we are unable to remotely validate the given card number.
Properties
items
[PrimerCardNetwork]Required
cardNetwork
PrimerCardNetwork
Represents a card network and includes metadata about that network relative to a specific card BIN.
network
CardNetworkRequired

An enum value for the card network (e.g. .visa, .mastercard)

displayName
StringRequired
The human-readable name of the card network (e.g., Visa, Mastercard).
allowed
BoolRequired
A boolean indicating whether this card network is allowed.
preferred
PrimerCardNetwork?
The preferred card network. Use this to pre-select a network if there are multiple.
network
CardNetworkRequired

An enum value for the card network (e.g. .visa, .mastercard)

displayName
StringRequired
The human-readable name of the card network (e.g., Visa, Mastercard).
allowed
BoolRequired
A boolean indicating whether this card network is allowed.
detectedCardNetworks
PrimerCardNetworksMetadataRequired
All detected card networks for the given card number. This will include networks even if they are not merchant-supported.
Properties
items
[PrimerCardNetwork]Required
cardNetwork
PrimerCardNetwork
Represents a card network and includes metadata about that network relative to a specific card BIN.
network
CardNetworkRequired

An enum value for the card network (e.g. .visa, .mastercard)

displayName
StringRequired
The human-readable name of the card network (e.g., Visa, Mastercard).
allowed
BoolRequired
A boolean indicating whether this card network is allowed.
preferred
PrimerCardNetwork?
The preferred card network. Use this to pre-select a network if there are multiple.
network
CardNetworkRequired

An enum value for the card network (e.g. .visa, .mastercard)

displayName
StringRequired
The human-readable name of the card network (e.g., Visa, Mastercard).
allowed
BoolRequired
A boolean indicating whether this card network is allowed.

primerRawDataManager(_:metadataDidChange:)

⚠️

This method is deprecated. Please use primerRawDataManager(_:willFetchMetadataForState:) and primerRawDataManager(_:didReceiveMetadata:forState:).

Returns validation metadata for the current validation state, triggered by using rawData. Check the section below for the metadata types that can be returned.

1
func primerRawDataManager(_ rawDataManager: PrimerHeadlessUniversalCheckout.RawDataManager, metadataDidChange metadata: [String: Any]?)
swift
copy

Parameters

rawDataManager
PrimerHeadlessUniversalCheckout.RawDataManager
The instance of the raw data manager calling this delegate method.
metadata
Dictionary<String:Any>
The metadata associated