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

1
async provide(props: AchManagerProps): Promise<StripeAchUserDetailsComponent | any>
typescript
copy

Parameters

props
AchManagerPropsRequired
Object that provides the payment menthod type and callback functions for handling steps, errors and validation.
Properties
paymentMethodType
stringRequired

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

onStep
(data: AchStep) => void

Called whenever the component emits a new step. This usually happens when calling start or submit or whenever the component collects data.

Parameters
A type representing the retrieved user details.
Properties
stepName
userDetailsRetrieved
The name of this component step.
firstName
stringRequired
The first name previously sent on client session creation.
lastName
stringRequired
The last name previously sent on client session creation.
emailAddress
stringRequired
The email address previously sent on client session creation.
A type representing the collected user details.
Properties
stepName
userDetailsCollected
The name of this component step.

This method will be called when an error occurs. It may return PrimerCheckoutData if the error occurs after the payment creation.

⚠️

Please note, that if you override this method, you must call the errorHandler to finalize the flow.

error
PrimerErrorRequired
Properties
errorId
StringRequired
A unique error identifier.
errorCode
String?
A unique error code.
description
StringRequired
A error description.
checkoutData
PrimerCheckoutData
Properties
payment
IPrimerCheckoutDataPayment
Properties
id
string
Primer's unique identifier for the payment.
orderId
string
Your order identifier as provided in the client session.
paymentFailureReason
PrimerPaymentErrorCode

Can be either payment-failed which is an error from the PSP side, or cancelled-by-customer which means the failure initiated on the customer side. I.e. cancelling a 3DS flow.

Custom information, that depends on the payment method.
Variations
Properties
expiresAt
StringRequired
couponCode
StringRequired
retailerName
StringRequired
Properties
expiresAt
StringRequired
qrCodeUrl
String?
qrCodeBase64
StringRequired
Properties
expiresAt
StringRequired
entity
StringRequired
reference
StringRequired
handler
PrimerErrorHandler
Methods
Call with your custom error message.
onInvalid
(data: PrimerInvalidComponentData<AchValidatableData>) => void
Called to indicate that the component data was considered invalid during validation.
Parameters

Interface that indicates that the data has been considered invalid after validation.

Properties
data
AchValidatableData
The data that failed validation.
Properties
The name of this component-validatable data.
value
string
The validated first name.
Properties
The name of this component-validatable data.
value
string
The validated last name.
Properties
The name of this component-validatable data.
value
string
The validated email address.
errors
PrimerValidationError[]

A list of PrimerValidationError explaining why the data is considered invalid.

Properties
errorId
string
A unique error identifier.
A error description.
A unique diagnostics id for the given error.
onValid
(data: PrimerValidComponentData<AchValidatableData>) => void
Called to indicate that the component data was successfully validated.
Parameters

Interface that indicates that the data has been successfully validated.

Properties
data
AchValidatableData
The successfully validated data.
Properties
The name of this component-validatable data.
value
string
The validated first name.
Properties
The name of this component-validatable data.
value
string
The validated last name.
Properties
The name of this component-validatable data.
value
string
The validated email address.
onValidating
(data: PrimerValidatingComponentData<AchValidatableData>) => void
Called to indicate that the component data is in the process of being validated.
Parameters

Interface that indicates that data is currently in the process of being validated.

Properties
data
AchValidatableData
The data being validated.
Properties
The name of this component-validatable data.
value
string
The validated first name.
Properties
The name of this component-validatable data.
value
string
The validated last name.
Properties
The name of this component-validatable data.
value
string
The validated email address.
onValidationError
(data: PrimerComponentDataValidationError<AchValidatableData>) => void
Called to indicated an error that occurred during component data validation.
Parameters

Interface that represents an error that occurred during the validation process.

Properties
data
AchValidatableData
The data for which an error ocurred during validation.
Properties
The name of this component-validatable data.
value
string
The validated first name.
Properties
The name of this component-validatable data.
value
string
The validated last name.
Properties
The name of this component-validatable data.
value
string
The validated email address.
error
PrimerError

The PrimerError that ocurred during the validation attempt.

Properties
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.
A unique diagnostics id for the given error.

Supported payment method types

Returns

An instance of a component, depending on the paymentMethodType:

Common API and available 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.

Supported types
API
Sets the customer's first name.

To validate the collected data, you can refer to the appropriate AchManagerProps callback functions.

Sets the customer's last name.

To validate the collected data, you can refer to the appropriate AchManagerProps callback functions.

Sets the customer's email address.

To validate the collected data, you can refer to the appropriate AchManagerProps callback functions.

Example

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
// 👇 Add thisconst achManagerProps: AchManagerProps = {    paymentMethodType: "STRIPE_ACH",    onStep: (data: AchStep) => {        switch (data.stepName) {            case "userDetailsRetrieved":                // Pre-populate your form with first name, last name and email address.                break;
            case "userDetailsCollected":                // Form can be hidden (eg.: pop the backstack). Start listening for DisplayStripeAchMandateAdditionalInfo events.                break;        }    },    onError: (error: PrimerError) => {        // An error that occurred during the component's operation.    },    onInvalid: (data: PrimerInvalidComponentData<AchValidatableData>) => {        // Data was considered invalid during validation.        switch(data.data.validatableDataName) {            case "firstName":                // ...                break;            case "lastName":                // ...                break;            case "emailAddress":                // ...                break;        }    },    onValid: (data: PrimerValidComponentData<AchValidatableData>) => {        // Data was successfully validated.        switch(data.data.validatableDataName) {            case "firstName":                // ...                break;            case "lastName":                // ...                break;            case "emailAddress":                // ...                break;        }    },    onValidating: (data: PrimerValidatingComponentData<AchValidatableData>) => {        // Data is in the process of being validated.        switch(data.data.validatableDataName) {            case "firstName":                // ...                break;            case "lastName":                // ...                break;            case "emailAddress":                // ...                break;        }    },    onValidationError: (data: PrimerComponentDataValidationError<AchValidatableData>) => {        // Error occurred during data validation.        switch(data.data.validatableDataName) {            case "firstName":                // ...                break;            case "lastName":                // ...                break;            case "emailAddress":                // ...                break;        }    },};const achManager = new AchManager();const stripeAchUserDetailsComponent: StripeAchUserDetailsComponent = await achManager.provide(achManagerProps);
typescript
copy