UNPKG

@paydock/client-sdk

Version:

Paydock client sdk

101 lines 3.7 kB
import { ApiCheckoutInternal } from '../api/api-checkout-internal'; import { ApiInternal } from '../api/api-internal'; import type { Container } from '../components/container'; import type { IEventData } from '../components/iframe-event'; import { EventEmitter } from '../helper/event-emitter'; import type { InstructionDestroyable, InstructionHandleable } from './helpers/instruction-handler'; import type { InstructionModule } from './helpers/instruction-module'; export declare const EVENT: { PAYMENT_SUCCESSFUL: string; PAYMENT_FAILURE: string; PAYMENT_EXPIRED: string; }; interface IntentTokenPayload { env: string; intent_id: string; version: number; env_alias: string; whitelist_domains: string[]; } export interface InstructionResponse { event?: string; instruction_token?: string; next_instruction?: boolean; [key: string]: any; } /** * Class CheckoutButton transform usual button into checkout * * @constructor * * @param {string} selector - Selector of html element. * @param {string} intentToken - PayDock intent token * @example * var widget = new Checkout('#widget', 'intent_token'); **/ export declare class Checkout { protected selector: string; protected intentToken: string; protected debug: boolean; protected window: Window; protected eventEmitter: EventEmitter; protected container: Container; protected intentTokenPayload: IntentTokenPayload; protected api: ApiInternal; protected checkoutApi: ApiCheckoutInternal; protected instructions: InstructionModule; protected currentInstruction: InstructionDestroyable & InstructionHandleable; private checkoutVersionHandler; private timeoutTimer; private requestInFlight; private inTimeoutRange; private checkoutFinished; constructor(selector: string, intentToken: string, debug?: boolean); fetchInstruction(): void; finaliseCheckout(): void; private setupTimeoutTimer; private extractIntentTokenPayload; validateJWTWhitelistedDomains(whitelist_domains: string[]): boolean; private ready; private initContractVersion; private isTimeoutInstruction; private handleInstruction; private handleTimeoutInstructions; private getInstructionFromResponse; private extractInstructionPayloadFromResponse; private setEnv; /** * If the payment was successful, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * widget.onPaymentSuccessful((data) => { * console.log('Payment successful!'); * }); */ onPaymentSuccessful(handler: (data: IEventData) => void): () => void; /** * If the payment was not successful, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * widget.onPaymentError((err) => { * console.log('Payment not successful'); * }); */ onPaymentFailure(handler: (data: IEventData) => void): () => void; /** * If the payment was expired, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * widget.onPaymentInReview((data) => { * console.log('Payment in fraud review'); * }); */ onPaymentExpired(handler: (data: IEventData) => void): () => void; createWidgetStructure(): void; private changeLoadingSpinnerVisibility; } export {}; //# sourceMappingURL=checkout.d.ts.map