@paydock/client-sdk
Version:
Paydock client sdk
165 lines • 6.45 kB
TypeScript
import { type IAfterpayMeta, type IBamboraMeta, type IPayPalMeta, type IZipmoneyMeta } from "../components/param";
import { HttpRequestMethod, HttpRequestUrl } from '../shared/http';
/**
* List of available payment source types
*
* @type {object}
* @param {string} CARD=card
* @param {string} BANK_ACCOUNT=bank_account
* @param {string} CHECKOUT=checkout
*/
export declare const PAYMENT_TYPE: {
CARD: string;
GIFT_CARD: string;
BANK_ACCOUNT: string;
CHECKOUT: string;
BSB: string;
};
/**
* Purposes
* @type {object}
* @param {string} PAYMENT_SOURCE=payment_source
* @param {string} CARD_PAYMENT_SOURCE_WITH_CVV=card_payment_source_with_cvv
* @param {string} CARD_PAYMENT_SOURCE_WITHOUT_CVV=card_payment_source_without_cvv
* */
export declare enum PURPOSE {
PAYMENT_SOURCE = "payment_source",
CARD_PAYMENT_SOURCE_WITH_CVV = "card_payment_source_with_cvv",
CARD_PAYMENT_SOURCE_WITHOUT_CVV = "card_payment_source_without_cvv"
}
export interface IGeneral {
purpose: PURPOSE;
predefined_fields: IPredefinedFields;
defined_form_fields?: string[];
webhook_destination?: string;
success_redirect_url?: string;
error_redirect_url?: string;
meta?: IPayPalMeta;
label?: string;
dynamic_fields_position?: boolean;
}
export interface IPredefinedFields {
gateway_id: string;
type?: string;
card_scheme?: string;
card_processing_network?: string;
}
/**
* Class Configuration include methods for creating configuration token
* @constructor
*
* @example
* var config = new Configuration('gatewayId'); // short
*
* var config = new Configuration('gatewayId', 'bank_account', 'paymentSource'); // extend
*
* var config = new Configuration('not_configured'); // without gateway
*
* @param {string} [gatewayID=default] - gateway ID. By default or if put 'default', it will use the selected default gateway. If put 'not_configured', it won’t use gateway to create downstream token.
* @param {string} paymentType - Type of payment source which shows in widget form. Available parameters [PAYMENT_TYPE]{@link PAYMENT_TYPE}
* @param {string} purpose - Param which describes payment purpose. By default uses Available parameters [PURPOSE]{@link PURPOSE}
*/
declare class Configuration {
private configs;
private env;
static createEachToken(accessToken: string, configs: Configuration[]): Promise<string[]>;
private static addTokenInBase64;
/** @constructs */ constructor(gatewayID?: string, paymentType?: string, purpose?: PURPOSE);
/**
* Destination, where customer will receive all successful responses.
* Response will contain “data” object with “payment_source” or other parameters, in depending on 'purpose'
*
* @example
* config.setWebHookDestination('http://google.com');
*
* @param {string} url - Your endpoint for post request.
*/
setWebHookDestination(url: string): void;
/**
* URL to which the Customer will be redirected to after the success finish
*
* @example
* config.setSuccessRedirectUrl('google.com/search?q=success');
*
* @param {string} url
*/
setSuccessRedirectUrl(url: string): void;
/**
* URL to which the Customer will be redirected to if an error is triggered in the process of operation
*
* @example
* config.setErrorRedirectUrl('google.com/search?q=error');
*
* @param {string} url
*/
setErrorRedirectUrl(url: string): void;
/**
* Set list with widget form field, which will be shown in form. Also you can set the required validation for these fields
*
* @example
* config.setFormFields(['phone', 'email', 'first_name*']);
*
* @param {string[]} fields - name of fields which can be shown in a widget.
* If after a name of a field, you put “*”, this field will be required on client-side.
* (For validation, you can specify any fields, even those that are shown by default: card_number, expiration, etc... ) [FORM_FIELD]{@link FORM_FIELD}
*/
setFormFields(fields: string[]): void;
/**
* Method for setting meta information for checkout page
*
* @example
* config.setMeta({
brand_name: 'paydock',
reference: '15',
email: 'wault@paydock.com'
});
*
* @param {IPayPalMeta | IZipmoneyMeta | IAfterpayMeta | IBamboraMeta} object -
* data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IZipmoneyMeta]{@link IZipmoneyMeta} [IAfterpayMeta]{@link IAfterpayMeta} [IBamboraMeta]{@link IBamboraMeta}
*/
setMeta(meta: IPayPalMeta | IZipmoneyMeta | IAfterpayMeta | IBamboraMeta): 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
* config.setEnv('production');
* @param {string} env - sandbox, production
* @param {string} [alias] - Own domain alias
*/
setEnv(env: string, alias?: string): void;
/**
* Title for tab which can be set instead of default
*
* @example
* config.setLabel('custom label');
*
* @param {string} label - Text label for tab
*/
setLabel(label: string): void;
getEnv(): string;
/**
* createToken - method which exactly create payment one time token
*
* @example
* config.createToken('582035346f65cdd57ee81192d6e5w65w4e5',
* function (data) {
* console.log(data);
* }, function (error) {
* console.log(error);
* });
*
* @param {string} accessToken - Customer access token or public key which provided for each client
* @param {createToken~requestCallback} cb - The callback that handles the success response.
* @param {createToken~requestCallback} errorCb - The callback that handles the failed response.
*/
createToken(accessToken: string, cb: (token: string) => void, errorCb?: (error: any) => void): void;
getDefaultGateway<T>(accessToken: string, method: HttpRequestMethod, url: HttpRequestUrl): Promise<T>;
private send;
getConfigs(): IGeneral;
private getUrl;
private getDefaultGatewayUrl;
setGiftCardSchemeData(giftCardScheme: any, processingNetwork: any): void;
}
export { Configuration };
//# sourceMappingURL=configuration.d.ts.map