12345678
createPaymentMethodManager(  type: string): Promise<  | ICardPaymentMethodManager  | INativePaymentMethodManager  | IRedirectPaymentMethodManager  | null>
ts
copy

There are three types of manager that can be returned by this function, depending on the type provided as first argument: Card, Native and Redirect.

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>
ts
copy

Create an instance of the ICardPaymentMethodManager, which can be used to manage credit card payments.

Parameters

type"PAYMENT_CARD"

When it matches this type, a manager for card payment methods will be returned.

optionsobject

Options to configure the payment method manager.

Properties

onCardMetadataChange(metadata: CardMetadata) => void

Called when the card metadata changes. Takes a CardMetadata object as its argument.

CardMetadata

typeCardNetwork | null

Allowed card networks for credit card payments, one of CardNetwork.

possibleTypesstring[]

Reduces to one or zero as more digits on the card number are input.

cvvLengthnumber

Usually 3 digits, but can sometimes be 4.

cardNumberLengthnumber

Represents the length of the card number for the given card type.

Returns

Promise<ICardPaymentMethodManager | null>

A promise that resolves to an instance of ICardPaymentMethodManager or null.

ICardPaymentMethodManager

createHostedInputs() => HostedInputs

Create an object with three hosted inputs: cardNumberInput, expiryInput, and cvvInput.
HostedInputs

cardNumberInputIHeadlessHostedInput

The headless hosted input for the card number.

See HeadlessHostedInput.

expiryInputIHeadlessHostedInput

The headless hosted input for the expiry date.

See HeadlessHostedInput.

cvvInputIHeadlessHostedInput

The headless hosted input for the CVV.

See HeadlessHostedInput.

setCardholderName(cardholderName: string) => void

Set the name of the cardholder.

removeHostedInputs() => void

Remove the hosted inputs.

submit() => Promise<void>

Create a payment method based on the current values after tokenization. Returns a Promise that resolves when the payment has been created.

validate() => Promise<Validation>

Validate the state of the payment method. Returns a Promise that resolves with a Validation object.

reset() => void

Reset the hosted fields to their initial state.

Native

123
createPaymentMethodManager(    type: "PAYPAL" | "GOOGLE_PAY" | "APPLE_PAY",): Promise<INativePaymentMethodManager | null>
ts
copy

Create an instance of the INativePaymentMethodManager, which can be used to manage native payment methods like PayPal, Google Pay, and Apple Pay.

Parameters

type"PAYPAL" | "GOOGLE_PAY" | "APPLE_PAY"

The type of native payment method to manage.

Returns

Promise<INativePaymentMethodManager | null>

A promise that resolves to an instance of INativePaymentMethodManager or null. An interface for creating a native payment method button.

INativePaymentMethodManager

createButton() => IHeadlessPaymentMethodButton

Create a native payment method button. Returns a HeadlessPaymentMethodButton.

Redirect

123
createPaymentMethodManager(    type: PaymentMethodType,): Promise<IRedirectPaymentMethodManager | null>
ts
copy

Create an instance of the IRedirectPaymentMethodManager, which can be used to manage redirect-based payment methods.

Parameters

typePaymentMethodType

The type of redirect-based payment method to manage, one of PaymentMethodTypes.

Returns

Promise<IRedirectPaymentMethodManager | null>

A promise that resolves to an instance of IRedirectPaymentMethodManager or null.

IRedirectPaymentMethodManager

start() => Promise<void>

Start the redirect payment flow.

addEventListener(event: EventTypes, callback: EventListener) => void

Add an event listener to the button.

EventTypes"blur" | "change" | "click" | "close" | "error" | "focus"

EventListener(event?: Event) => void