UNPKG

@paydock/client-sdk

Version:

Paydock client sdk

85 lines 3.87 kB
import { Container } from '../components/container'; import { EventEmitter } from '../helper/event-emitter'; import { type IOnCancelEventData, type IOnErrorEventData, type IOnSuccessEventData, type IPayPalSavePaymentSourceWidget, type PayPalSavePaymentSourceWidgetConfig } from './paypal-save-payment-source.interfaces'; /** * PayPal Save Payment Source Widget constructor * * @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget. * @param {string} publicKey - PayDock users public key. * @param {string} gatewayId - PayDock's PayPal gatewayId. * @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles. * * @example * var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id'); */ declare class PayPalSavePaymentSourceWidget { protected container: Container; protected service: IPayPalSavePaymentSourceWidget; protected eventEmitter: EventEmitter; /** @constructs */ constructor(selector: string, publicKey: string, gatewayId: string, config?: PayPalSavePaymentSourceWidgetConfig); /** * The final method after configuring the PayPalSavePaymentSource Widget to * start the load process. */ load(): void; /** * Current method can change environment. By default environment = sandbox. * Also we can change domain alias for this environment. By default domain_alias = paydock.com * * @example * payPalSavePaymentSourceWidget.setEnv('production'); * @param {string} env - sandbox, production * @param {string} [alias] - Own domain alias */ setEnv(env: string, alias?: string): void; /** * Callback for onSuccess method. * * @callback OnSuccessCallback * @param {IOnSuccessEventData} data */ /** * If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully')); * * @param {OnSuccessCallback} [callback] - Function to be called when the result is successful. */ onSuccess(callback?: (data: IOnSuccessEventData) => void): () => void; /** * Callback for onError method. * * @callback OnErrorCallback * @param {IOnErrorEventData} data */ /** * If in the process for obtaining the setup token fails, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred')); * * @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow. */ onError(callback?: (data: IOnErrorEventData) => void): () => void; /** * Callback for onCancel method. * * @callback OnCancelCallback * @param {IOnCancelEventData} data */ /** * If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called. * Important: Do not perform thread blocking operations in callback such as window.alert() calls. * * @example * payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled')); * * @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled. */ onCancel(callback?: (data?: IOnCancelEventData) => void): () => void; } export { PayPalSavePaymentSourceWidget }; //# sourceMappingURL=paypal-save-payment-source.d.ts.map