iOS SDK
- Installation
- Primer
- PrimerHeadlessUniversalCheckout
- Common objects
This method allows you get a new instance of StripeAchUserDetailsComponent
to initiate Stripe ACH payments.
public func provide<PrimerHeadlessAchComponent>(paymentMethodType: String) throws -> PrimerHeadlessAchComponent?
where PrimerCollectableData: Any, PrimerHeadlessStep: Any
Parameters
Hide Parameters
Hide Parameters
A unique string identifier for the payment method. Supported payment methods for current client session are returned in primerHeadlessUniversalCheckoutDidLoadAvailablePaymentMethods delegate method.
Type parameters
Hide Type Parameters
Hide Type Parameters
The type of the PrimerHeadlessAchComponent
implementation to
return.
Hide Supported types
Hide Supported types
Type | paymentMethodType |
---|---|
StripeAchUserDetailsComponent | STRIPE_ACH |
Returns
An instance of the passed generic type, which could be any of the following available components:
Hide Common API
Hide Common API
Hide Methods and Properties
Hide 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.
Error delegate will be triggered every time an error is thrown in the process.
func didReceiveError(error: PrimerError)
Hide Supported types
Hide Supported types
Hide API
Hide 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
.
Show enum ACHUserDetailsCollectableData
Show enum ACHUserDetailsCollectableData
Enum member representing the customer’s first name.
Hide Properties
Hide Properties
The string value for the customer’s first name.
Enum member representing the customer’s last name.
Hide Properties
Hide Properties
The string value for the customer’s last name.
Example:
func updateCollectedData(collectableData: ACHUserDetailsCollectableData)
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.
Show enum ACHUserDetailsStep
Show enum ACHUserDetailsStep
Enum member representing the retrieved user details.
Hide Properties
Hide Properties
The retrieved user details of type ACHUserDetails
previously sent on client session creation.
Enum member representing the event of collected user details.
Example:
func didReceiveStep(step: PrimerHeadlessStep) {
guard let step = step as? ACHUserDetailsStep else { return }
switch step {
case .retrievedUserDetails(let userDetails):
case .didCollectUserDetails:
}
}
Validation delegate will be triggered every time collected data is updated.
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
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.
Show enum PrimerValidationStatus
Show enum PrimerValidationStatus
Enum case representing the ongoing validation state. This indicates that the validation process is currently in progress.
Enum case representing a successful validation state. This indicates that the validation process has completed successfully and the data is valid.
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.
Hide Associated Value
Hide Associated Value
An array of PrimerValidationError
representing the specific validation errors found.
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):
}
}
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.
do {
manager = PrimerHeadlessUniversalCheckout.AchManager()
stripeAchComponent = try manager.provide(paymentMethodType: "STRIPE_ACH")
} catch {
// Catch errors here
}