UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

70 lines (69 loc) 2.71 kB
import { ComponentChild } from 'preact'; import EventEmitter from './EventEmitter'; import Core from '../core'; import { BaseElementProps, PaymentData } from './types'; import { RiskData } from '../core/RiskModule/RiskModule'; import { Resources } from '../core/Context/Resources'; import { AnalyticsInitialEvent, SendAnalyticsObject } from '../core/Analytics/types'; declare class BaseElement<P extends BaseElementProps> { readonly _id: string; props: P; state: any; protected static defaultProps: {}; _node: any; _component: any; eventEmitter: EventEmitter; protected readonly _parentInstance: Core; protected resources: Resources; protected constructor(props: P); /** * Executed during creation of any payment element. * Gives a chance to any paymentMethod to format the props we're receiving. */ protected formatProps(props: P): P; /** * Executed on the `data` getter. * Returns the component data necessary for the /payments request * * TODO: Replace 'any' by type PaymentMethodData<T> - this change requires updating all payment methods, * properly adding the type of the formatData function */ protected formatData(): any; protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent): any; protected submitAnalytics(analyticsObj?: SendAnalyticsObject): any; protected setState(newState: object): void; /** * Returns the component payment data ready to submit to the Checkout API * Note: this does not ensure validity, check isValid first */ get data(): PaymentData | RiskData; render(): ComponentChild | Error; /** * Mounts an element into the dom * @param domNode - Node (or selector) where we will mount the payment element * @returns this - the payment element instance we mounted */ mount(domNode: HTMLElement | string): this; /** * Updates props, resets the internal state and remounts the element. * @param props - props to update * @returns this - the element instance */ update(props: P): this; /** * Unmounts an element and mounts it again on the same node i.e. allows mount w/o having to pass a node. * Should be "private" & undocumented (although being a public function is useful for testing). * Left in for legacy reasons */ remount(component?: any): this; /** * Unmounts a payment element from the DOM */ unmount(): this; /** * Unmounts an element and removes it from the parent instance * For "destroy" type cleanup - when you don't intend to use the component again */ remove(): void; } export default BaseElement;