Skip to content

PesepayElementBase

What every element can do: mount, update, focus, clear and send events. create() does not mount, so you can set an element up before its container exists. Each element’s page lists the events it sends.

Your page cannot read what the customer typed: card details stay in Pesepay’s frame. Pass the element to confirmCardPayment() to pay.

export interface PesepayElementBase<Events extends ElementEventMap = ElementEventMap, Options = BaseElementOptions>
NameTypeDescription
elementTypeElementTypeThe kind of element.
blur(): void;

Removes focus from the element.

clear(): void;

Clears what the customer has entered.

destroy(): void;

Unmounts and releases everything. The element cannot be reused.

focus(): void;

Moves focus into the element.

mount(target: string | HTMLElement): void;

Renders into a CSS selector or an element. Throws if the target is missing.

ParameterType
targetstring | HTMLElement
off<K extends keyof Events>(type: K, handler?: (event: Events[K]) => void): this;

Omitting the handler removes every listener for that event.

ParameterType
typeK
handler?(event: Events[K]) => void
on<K extends keyof Events>(type: K, handler: (event: Events[K]) => void): this;

Adds a listener. Returns the element, so calls chain.

ParameterType
typeK
handler(event: Events[K]) => void
once<K extends keyof Events>(type: K, handler: (event: Events[K]) => void): this;

Adds a listener that runs once. Returns the element, so calls chain.

ParameterType
typeK
handler(event: Events[K]) => void
unmount(): void;

Removes the element from the DOM. It can be mounted again.

update(options: Partial<Options>): void;

Changes some options. Options you leave out keep their values.

ParameterType
optionsPartial<Options>