1234567891011
createPaymentMethodManager( type: string): Promise< | ICardPaymentMethodManager | INativePaymentMethodManager | IRedirectPaymentMethodManager | IFormWithRedirectPaymentMethodManager | IKlarnaPaymentMethodManager | IAchPaymentMethodManager | null>
There are five types of manager that can be returned by this function,
depending on the type
provided as first argument:
Card, Native, Redirect, Form With Redirect, Klarna Payment Method and ACH.
In case the the type specified is not supported, the function will return null
instead.
Card
1234
createPaymentMethodManager( type: "PAYMENT_CARD", options?: PaymentMethodManagerOptions): Promise<ICardPaymentMethodManager | null>
Create an instance of the ICardPaymentMethodManager
, which can be used to manage credit card payments.
Parameters
Options to configure the payment method manager.
Properties
Called when the card metadata changes. Takes a CardMetadata
object as its argument.
CardMetadata
Deprecated: Use onCardNetworksChange instead
Allowed card networks for credit card payments, one of CardNetwork.
Deprecated: Use onCardNetworksChange instead
An array of CardNetwork. Reduces to one or zero elements as more digits on the card number are input.
Called when Headless Checkout detects new card networks from the card number entered by the user.
Makes available an event
of type CardNetworkChangeEvent
.
CardNetworkChangeEvent
All the detected card networks, including the ones that are not allowed.
Use the following snippet to get the card network that should be presented to the user:
detectedCardNetworks.preferred ?? detectedCardNetworks.items[0]
CardNetworks
An array of the card networks.
CardNetworkDetails
Whether or not the card network is allowed, according to orderedAllowedCardNetworks
passed in the Client Session.
The first allowed card network in items
.
In case no network is allowed, undefined
.
CardNetworkDetails
Whether or not the card network is allowed, according to orderedAllowedCardNetworks
passed in the Client Session.
In case the card has zero or only one network that is allowed, undefined
. Otherwise, all the allowed cards.
Use this to show the card networks the user can choose from in the case of a co-badged cards.
CardNetworks
An array of the card networks.
CardNetworkDetails
Whether or not the card network is allowed, according to orderedAllowedCardNetworks
passed in the Client Session.
The first allowed card network in items
.
In case no network is allowed, undefined
.
CardNetworkDetails
Whether or not the card network is allowed, according to orderedAllowedCardNetworks
passed in the Client Session.
Values
This happens when less than 8 digits are entered in the cardnumber field.
Headless Checkout retrieved the card networks using static information bundled with the SDK. This information can only identify international cards.
This happens when 8 digits or more are entered in the cardnumber field.
Headless Checkout retrieved the card networks using Primer's BIN data.
This happens when Headless Checkout fails to contact Primer's BIN data.
Falls back to the static information bundled with the SDK (see LOCAL
).
Called when card network information is being fetched from Primer's servers.
Will only trigger when event.source === 'REMOTE'
in onCardNetworksChange
.
Returns
A promise that resolves to an instance of ICardPaymentMethodManager
or null
.
ICardPaymentMethodManager
Create an object with three hosted inputs: cardNumberInput
, expiryInput
, and cvvInput
.
HostedInputs
See HeadlessHostedInput.
See HeadlessHostedInput.
See HeadlessHostedInput.
Validation
An array of objects containing information about any input validation errors that occurred during the validation process.
InputValidationError
The type of error that occurred.
Possible values:
cardNameRequired
: cardholder's name is not provided.cardNameContainsNumbers
: cardholder's name contains numbers.cardNameLength
: cardholder's name does not match the expected length (minimum: 2, maximum: 45 characters).cardNameContainsInvalidCharacters
: cardholder's name contains characters that are not supported (only Latin characters are allowed).cardRequired
: card number is not provided.unsupportedCardType
: provided card number does not match the allowed card networks.cardIncomplete
: provided card number does not match the expected length.cardInvalid
: provided card number is invalid. Additional details might be available in themessage
field.cvvRequired
: card's security code (CVV) is not provided.cvvIncomplete
: card's security code (CVV) does not match the expected length (minimum: 3 characters).cvvInvalid3
: card's security code (CVV) does not match the expected length (exact: 3 characters).cvvInvalid4
: card's security code (CVV) does not match the expected length (exact: 4 characters).expiryRequired
: card's expiry date is not provided.cardExpired
: card has expired.expiryMonthInvalid
: expiry date's month is invalid.expiryYearInvalid
: expiry date's year is invalid.
Native
123
createPaymentMethodManager( type: "PAYPAL" | "GOOGLE_PAY" | "APPLE_PAY",): Promise<INativePaymentMethodManager | null>
Create an instance of the INativePaymentMethodManager
, which can be used to manage native payment methods like
PayPal, Google Pay, and Apple Pay.
Parameters
Returns
A promise that resolves to an instance of INativePaymentMethodManager
or null
.
An interface for creating a native payment method button.
INativePaymentMethodManager
Create a native payment method button. Returns a HeadlessPaymentMethodButton.
Redirect
123
createPaymentMethodManager( type: PaymentMethodType,): Promise<IRedirectPaymentMethodManager | null>
Create an instance of the IRedirectPaymentMethodManager
, which can be used to manage redirect-based payment
methods.
Parameters
The type of redirect-based payment method to manage, one of PaymentMethodType (except ADYEN_IDEAL
).
Returns
A promise that resolves to an instance of IRedirectPaymentMethodManager
or null
.
IRedirectPaymentMethodManager
Form With Redirect
1234
createPaymentMethodManager( type: "ADYEN_IDEAL", options?: FormWithRedirectPaymentMethodManagerOptions): Promise<IFormWithRedirectPaymentMethodManager | null>;
Create an instance of the IFormWithRedirectPaymentMethodManager
, which can be used to manage redirect-based payment methods which also require an extra form and user interaction.
Parameters
Options to set up the payment method.
Properties
Called when the payment method configuration changes. The properties contained on the payload
object depends on the payment method, for example, bankIssuers
will be defined when the payment method is ADYEN_IDEAL
.
Returns
A promise that resolves to an instance of IFormWithRedirectPaymentMethodManager
or null
.
IFormWithRedirectPaymentMethodManager
Set up the payment method loading the configuration, which will be provided through the onConfigurationLoad
callback.
Validates the submitted payload, if the submitted payload is invalid it returns the validation errors, otherwise, if the payload is valid, it will start the redirect payment flow.
The payload to be submitted type T
depends on the payment method, an example of this type can be the BankIssuer
for the ADYEN_IDEAL
payment method:
Klarna
1234
createPaymentMethodManager( type: "KLARNA", options?: KlarnaPaymentMethodManagerOptions): Promise<IKlarnaPaymentMethodManager | null>
Create an instance of the IKlarnaPaymentMethodManager
, which can be used to manage Klarna specific payment methods which also require an extra form and user interaction.
Parameters
Options to configure the payment method manager.
Properties
Properties
Returns
A promise that resolves to an instance of IKlarnaPaymentMethodManager
or null
.
IKlarnaPaymentMethodManager
Properties
Properties
ACH
1234
createPaymentMethodManager( type: "STRIPE_ACH", options?: AchPaymentMethodManagerOptions): Promise<IAchPaymentMethodManager | null>
Create an instance of the IAchPaymentMethodManager
, which can be used to manage ACH payment methods which also require an extra form and the mandate confirmation.
Parameters
Options to configure the payment method manager.
Properties
Stripe Publishable Key, used to interact with Stripe's SDK and collect the bank account details, necessary for the STRIPE_ACH
payment method. The Publishable Key can be found in the Stripe Dashboard API keys.
Returns
A promise that resolves to an instance of IAchPaymentMethodManager
or null
.
IAchPaymentMethodManager
Submits and validates the customer data starting the ACH payment method flow.
When the payment method is STRIPE_ACH
, the required data T
is:
12345
interface StripeAchFormData { firstName: stringl; lastName: string; emailAddress: string}
When the payment method is STRIPE_ACH
, displays the Stripe UI to collect the bank account details.
Throws an error if the start
method didn't run successfully or wasn't called before.
Submits the mandate confirmation. Should be triggered by a "Confirm" button next to the mandate text.
Throws an error if the methods start
and collectBankAccountDetails
weren't successfully called before.