This method allows you get a new instance of StripeAchUserDetailsComponent to initiate Stripe ACH payments.

12
public func provide<PrimerHeadlessAchComponent>(paymentMethodType: String) throws -> PrimerHeadlessAchComponent?        where PrimerCollectableData: Any, PrimerHeadlessStep: Any
swift
copy

Parameters

paymentMethodType
StringRequired

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

Type parameters

PrimerHeadlessAchComponent
PrimerCollectableData, PrimerHeadlessStepRequired

The type of the PrimerHeadlessAchComponent implementation to return.

Supported types

Returns

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

Common API
PrimerHeadlessAchComponent
Implemented by all components
Methods and Properties
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.

errorDelegate
PrimerHeadlessErrorableDelegate
Error delegate will be triggered every time an error is thrown in the process.
1
func didReceiveError(error: PrimerError)
swift
copy
Supported types
StripeAchUserDetailsComponent
PrimerHeadlessAchComponent where Data == ACHUserDetailsCollectableData, Step == ACHUserDetailsStep
API

Update component with collected data by passing an enum representing collectable data. 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 validationDelegate and receive the validation status when it's updated.

In case of ACH, the Data will be of type ACHUserDetailsCollectableData.

enum ACHUserDetailsCollectableData
Enum member representing the customer's first name.
Properties
value
<String>
The string value for the customer's first name.
Enum member representing the customer's last name.
Properties
value
<String>
The string value for the customer's last name.
Enum member representing the customer's email address.
Properties
value
<String>
The string value for the customer's email address.

Example:

1
func updateCollectedData(collectableData: ACHUserDetailsCollectableData)
swift
copy
stepDelegate
ACHUserDetailsStep

Whenever start or submit methods are called, stepDelegate will trigger the next step in case the call to the mentioned method was successful.

In the case of STRIPE_ACH, the steps will be of type ACHUserDetailsStep.

ACHUserDetailsStep is an enum holding different output data for specific steps.

enum ACHUserDetailsStep

Enum member representing the retrieved user details.

Properties
details
ACHUserDetails

The retrieved user details of type ACHUserDetails previously sent on client session creation.

Properties
firstName
String

The first name previously sent on client session creation.

lastName
String

The last name previously sent on client session creation.

The email address previously sent on client session creation.

Enum member representing the event of collected user details.

Example:

1234567
func didReceiveStep(step: PrimerHeadlessStep) {    guard let step = step as? ACHUserDetailsStep else { return }    switch step {    case .retrievedUserDetails(let userDetails):    case .didCollectUserDetails:    }}
swift
copy
validationDelegate
PrimerHeadlessValidatableDelegate

Validation delegate will be triggered every time collected data is updated.

1
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
swift
copy

In the case of STRIPE_ACH, the data will be of type ACHUserDetailsCollectableData.

PrimerValidationStatus is an enum that represents the different validation statuses in the Primer SDK. It helps to communicate the state of validation for a particular process, providing clear categorization of validation states.

enum PrimerValidationStatus
validating
ACHUserDetailsCollectableData
Enum case representing the ongoing validation state. This indicates that the validation process is currently in progress.
valid
ACHUserDetailsCollectableData
Enum case representing a successful validation state. This indicates that the validation process has completed successfully and the data is valid.
invalid
ACHUserDetailsCollectableData
Enum case representing an unsuccessful validation state due to validation errors. This indicates that the validation process has completed but has found one or more errors in the data.
Associated Value
errors
[PrimerValidationError]
An array of `PrimerValidationError` representing the specific validation errors found.
error
ACHUserDetailsCollectableData
Enum case representing an error state due to an unexpected issue. This indicates that an unexpected error has occurred during the validation process.
Associated Value
error
PrimerError
A `PrimerError` representing the unexpected error that occurred.
123456789
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?) {    guard let data = data as? ACHUserDetailsCollectableData else { return }    switch validationStatus {    case .validating:    case .valid:    case .invalid(errors: let errors):    case .error(error: let error):    }}
swift
copy

Example

Although the component focuses on collecting user details pertaining to ACH, it also kicks off the tokenization and payment processes. Because of this, it should be kept in memory until the checkout is completed.

Ensure that the screen implementing this component is not dismissed until the payment is finished, as the component returned by the manager is optional. As a result, having a weak reference to it will stop the entire payment flow if the screen is dismissed prematurely.

123456
do {    manager = PrimerHeadlessUniversalCheckout.AchManager()    stripeAchComponent = try manager.provide(paymentMethodType: "STRIPE_ACH")} catch {    // Catch errors here}
swift
copy