import { InvoiceOverlayConfig } from '../overlay/overlay'; import './button.scss'; /** * Payment button types */ export declare enum PaymentButtonType { /** * Simple payment button */ SIMPLE = "SIMPLE", /** * Payment button with amount and currency inputs */ AMOUNT_SELECTOR = "AMOUNT_SELECTOR", /** * Donation button */ DONATION = "DONATION" } export interface ConfirmoButtonValues { /** * Amount to pay */ merchantAmount?: number | string; /** * Payment currency */ merchantCurrency?: string; /** * Name of the product */ productName?: string; /** * Description of the product */ productDescription?: string; /** * Merchant reference */ reference?: string; /** * Return url used after payment proceeds */ returnUrl?: string; /** * Customer currency of the button */ customerCurrency?: string; /** * If true, the invoice is displayed in an overlay */ overlay?: boolean; } export interface ConfirmoButtonConfig { /** * id of element where button will be rendered */ id?: string; /** * element where button will be rendered */ element?: Element; /** * payment button id */ paymentButtonId: string; /** * Your Merchant ID assigned by Confirmo */ merchantId: string; /** * Payment button URL */ url?: string; /** * @internal */ apiUrl?: string; /** * type of payment button. * * Default value is SIMPLE. */ buttonType?: PaymentButtonType; /** * Payment button values */ values?: ConfirmoButtonValues; } /** * Confirmo payment button */ export declare class PaymentButton { private callback; private static cachedCurrencies; private readonly element; private readonly values; private readonly config; private readonly images; private readonly overlayConfig; /** * Initialize new payment button * * @param {ConfirmoButtonConfig} args Button configuration * @param {Function} callback Callback function called when overlay closed (relevant only if args.values.overlay set to true) * @param {InvoiceOverlayConfig} overlayConfig Config for invoice overlay (relevant only if args.values.overlay set to true) * @return PaymentButton * @example * * const button = PaymentButton.initialize({ * id: 'bp-simple-button', * paymentButtonId: 'pbt16354asde', * buttonType: 'SIMPLE', * values: { * merchantAmount: 100, * merchantCurrency: 'LTC', * productName: 'Some cool product', * productDescription: 'Simple description', * reference: 'merchantRef', * returnUrl: 'https://my-cool-eshop.com/?q=this+is+return+url' * } * }, () => { * console.log('Overlay has been closed!'); * }, * { * closeAfterPaid: true, * closeAfterPaidTimeoutMs: 2000, * }); */ static initialize(args: ConfirmoButtonConfig, callback?: Function, overlayConfig?: InvoiceOverlayConfig): PaymentButton; /** * PaymentButton constructor * * @param {ConfirmoButtonConfig} args * @param {Function} callback * @param {InvoiceOverlayConfig} overlayConfig */ private constructor(); private getCurrenciesUrl; private getInvoiceUrl; private addOverlayFormListener; private getButtonImage; private validateArguments; private loadCurrencies; private selectedCurrency; private getHtml; private shouldAddHiddenInput; /** * Remove the button HTML */ remove(): void; }