This method allows you get a new instance of a PrimerHeadlessMainComponent implementation.

12
@Throws(SdkUninitializedException::class, UnsupportedPaymentMethodException::class)fun <T : PrimerHeadlessMainComponent<out PrimerCollectableData, out PrimerHeadlessStep>> provide(paymentMethodType: String): T
kotlin
copy

Parameters

paymentMethodType
StringRequired

A unique string identifier for the payment method. Supported payment methods for current client session are returned in onAvailablePaymentMethodsLoaded callback.

Type parameters

T
PrimerHeadlessMainComponent<out PrimerCollectableData, out PrimerHeadlessStep>Required

The type of the PrimerHeadlessMainComponent implementation to return.

Supported types
TypepaymentMethodType
BanksComponentADYEN_IDEAL

Returns

An instance of the passed generic type T, which could be any of the following available components:

Common API and available components
PrimerHeadlessMainComponent
Implemented by all components
Common API
Initialize the component by calling the start function. This method should be called only once.

Call submit function in order to process collected data and move component to next state.

Get a Flow of PrimerError objects that represent errors emitted by this component. Subscribers can observe and handle errors using this Flow.

Supported types
BanksComponent
PrimerHeadlessMainComponent<BanksCollectableData, BanksStep>
API

Update component with collected data by passing implementations of sealed interface. This method can be called at any point, even if you have only partially collected data. To validate the partially collected data, you can refer to the componentValidationStatus and receive the validation status when it's updated.

sealed interface BanksCollectableData
Data class representing representing the collected bank list filter.
Properties
query
String
A string representing the query by which the bank list should be filtered.
Data class representing representing the collected bank id.
Properties
id
String
The id of the bank to use when processing the payment.

BanksStep is a class holding different output data for specific steps. Whenever start or submit methods are called, componentStep will trigger the next step in case the call to the mentioned method was successful.

sealed interface BanksStep
Object signifing that the list of available banks is in the process of being loaded.
A data class representing the step of emitting the list of available banks.
Properties
banks
List<IssuingBank>
The list of available banks.
Properties
id
StringRequired
String representing the bank id.
name
StringRequired
String representing the bank name.
disabled
BooleanRequired
Boolean indicating whether the bank is disabled or not.
iconUrl
StringRequired
A string representing the icon url.

The PrimerValidationStatus interface encompasses a range of validation statuses.

sealed interface PrimerValidationStatus
Indicates that data is currently in the process of being validated.
Properties
collectableData
BanksCollectableData

The data being validated.

Indicates that the data has successfully been validated.
Properties
collectableData
BanksCollectableData

The successfully validated data.

Indicates that the data has been considered invalid after validation.
Properties
validationErrors
List<PrimerValidationError>

List of PrimerValidationError objects that represent data validation errors emitted by this component.

Properties
errorId
StringRequired
A unique error identifier.
description
StringRequired
A error description.
diagnosticsId
StringRequired
A unique diagnostics id for the given error.
collectableData
BanksCollectableData

The data that failed validation.

Represents the status when an error occurred during the validation process.
Properties
error
PrimerError

The specific PrimerError that occurred during validation.

errorId
StringRequired
A unique error identifier.
errorCode
String?
A unique error code.
description
StringRequired
A error description.
A recovery suggestion for the given error. In case it's present, use it to try to recover from error.
diagnosticsId
StringRequired
A unique diagnostics id for the given error.
collectableData
BanksCollectableData

The data for which the error occurred.

Throws

An exception that will be thrown in case the SDK was not initialized properly. Before calling any of the manager's method, the SDK must be initialized using start method.

An exception that will be thrown in case the initialization of the manager has been done using unsupported paymentMethodType - PrimerHeadlessMainComponent combination. Supported payment methods for current client session are returned in onAvailablePaymentMethodsLoaded callback. See Supported types for the supported combinations.

Example

1234567
class CheckoutActivity : AppCompatActivity() {  // 👇 Add this  private val banksComponent by lazy {    PrimerHeadlessUniversalCheckoutComponentWithRedirectManager(viewModelStoreOwner = this)            .provide(paymentMethodType = "ADYEN_IDEAL")  }}
kotlin
copy