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
Parameters
A unique string identifier for the payment method. Supported payment methods for current client session are returned in primerHeadlessUniversalCheckoutDidLoadAvailablePaymentMethods delegate method.
Type parameters
The type of the PrimerHeadlessAchComponent
implementation to return.
Supported types
Type | paymentMethodType |
---|---|
StripeAchUserDetailsComponent | STRIPE_ACH |
Returns
An instance of the passed generic type, which could be any of the following available components:
Common API
Methods and Properties
Call submit
function in order to process collected data and move component to next state.
1
func didReceiveError(error: PrimerError)
Supported types
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
Properties
Properties
Properties
Example:
1
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.
enum ACHUserDetailsStep
Enum member representing the retrieved user details.
Properties
The retrieved user details of type ACHUserDetails
previously sent on client session creation.
Properties
The first name previously sent on client session creation.
The last name previously sent on client session creation.
The email address previously sent on client session creation.
Example:
1234567
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.
1
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.
enum PrimerValidationStatus
Associated Value
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): }}
Example
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}