import './overlay.scss'; export interface InvoiceOverlayConfig { /** * Close Confirmo overlay after invoice status changes to ConfirmoOverlayInvoiceStatus.PAID */ closeAfterPaid?: boolean; /** * Specify delay after which the overlay should be automatically closed when payment complete (requires closeAfterPaid to be set to true) * @default 2000 */ closeAfterPaidTimeoutMs?: number; } declare enum ConfirmoOverlayInvoiceStatus { PREPARED = "prepared", ACTIVE = "active", CONFIRMING = "confirming", PAID = "paid", EXPIRED = "expired", ERROR = "error" } /** * Events fired from Public invoice view via window#postMessage API https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage * * A component using @confirmo/overlay can listen to InvoiceOverlayMessageEventData accordingly: * const overlay = Invoice.open(invoiceUrl); * window.addEventListener('message', (event) => { * if ( * invoiceUrl.includes(event.origin) && * event.data.action === ConfirmoOverlayMessageAction.CONFIRMO_OVERLAY_INVOICE_STATUS_CHANGE && * event.data.status === ConfirmoOverlayInvoiceStatus.PAID * ) { * // handle paid invoice (close overlay, redirect, etc.) * overlay.close(); * } * }); */ export declare enum ConfirmoOverlayMessageAction { /** * Event fired on "Back to Merchant" btn click */ CLOSE_CONFIRMO_OVERLAY = "CLOSE_CONFIRMO_OVERLAY", /** * Event fired on invoice status change */ CONFIRMO_OVERLAY_INVOICE_STATUS_CHANGE = "CONFIRMO_OVERLAY_INVOICE_STATUS_CHANGE" } export interface InvoiceOverlayMessageEventData { action: ConfirmoOverlayMessageAction; status?: ConfirmoOverlayInvoiceStatus; returnUrl?: string; } export declare class Invoice { private callback; private bodyOverflow; private confirmoMainFrame; /** * * @param {String} invoiceUrl * @param {Function} callback * @param {InvoiceOverlayConfig} overlayConfig */ private constructor(); /** * Opens Confirmo overlay * * @param {string} invoiceUrl - Url of invoice * @param {function} [callback] - Callback to call after closing Confirmo overlay * @param {InvoiceOverlayConfig} [overlayConfig] - Confirmo overlay configuration * * @example * * // URL of invoice created from REST API * const invoice_url = 'https://confirmo.demo/#/public/invoice/invv9e1rxdz8'; * * // Callback which is called when overlay was closed * const callback_fnc = () => alert('Overlay has been closed'); * * // Invoice overlay config * const overlayConfig = { * closeAfterPaid: true, * closeAfterPaidTimeoutMs: 2000, * }; * * Invoice.open(invoice_url, callback_fnc, overlayConfig); */ static open(invoiceUrl: string, callback?: Function, overlayConfig?: InvoiceOverlayConfig): Invoice; /** * Closes Confirmo overlay */ close(): void; } export {};