import { Axios } from 'axios'; type ServerMode$1 = "Development" | "Production"; declare const MAX_IMAGE_SIZE_MB = 1; type AccountBalance = { balance: number; pendingIn: number; pendingOut: number; }; interface TropipayConfig { clientId: string; clientSecret: string; scopes?: string[]; serverMode?: ServerMode$1; customTropipayUrl?: string; } type TropipayCredentials = { clientId: string; clientSecret: string; }; type HookEventType = "transaction_completed" | "transaction_charged" | "transaction_guarded" | "user_signup" | "user_kyc" | "payment_in_state_change" | "payment_out_state_change" | "beneficiary_added" | "beneficiary_updated" | "beneficiary_deleted" | "transaction_new" | "transaction_preauthorized" | "transaction_pendingin" | "transaction_processing" | "transaction_error" | "transaction_bloqued" | "transaction_guarded_send" | "transaction_guarded_mediation" | "user_after_update" | "user_after_create" | "userDetail_after_create" | "userDetail_after_update" | "tpv_callback_ok" | "fraud_state_on_change"; type HookTargetType = "web" | "email"; interface UserHook { event: HookEventType; target: string; value: string; } interface UserHook { event: HookEventType; target: string; value: string; } interface UserHookSubscribed extends UserHook { createdAt: string; updatedAt: string; } interface UserHookSubscribed extends UserHook { createdAt: string; updatedAt: string; } /** * Interface for creating payment links/cards * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge */ interface PaymentLinkPayload { /** Account ID where the funds will be received if compatible */ accountId?: number; /** Reference code for the payment, preferred to be unique */ reference: string; /** Short description of the payment */ concept: string; /** Whether to mark this payment link as favorite */ favorite: boolean; /** Amount to charge in the specified currency */ amount: number; /** Currency code (EUR, USD, etc.) */ currency: string; /** Detailed description of the payment */ description: string; /** If true, the payment link can only be used once */ singleUse: boolean; /** Reason ID for the payment */ reasonId: number; /** Number of days until the payment link expires */ expirationDays: number; /** Language code for the payment page (en, es, etc.) */ lang: string; /** URL to redirect after successful payment */ urlSuccess: string; /** URL to redirect after failed payment */ urlFailed: string; /** Webhook URL for payment notifications */ urlNotification: string; /** Date when the service will be provided (ISO format) */ serviceDate: string; /** Client information for the payment */ client?: { /** Client's first name */ name?: string; /** Client's last name */ lastName?: string; /** Client's address */ address?: string; /** Client's phone number */ phone?: string; /** Client's email address */ email?: string; /** Client's country ID */ countryId?: number; /** Client's country ISO code */ countryIso?: string; /** Client's city */ city: string; /** Client's postal code */ postCode: string; /** Whether client accepted terms and conditions */ termsAndConditions: boolean; } | null; /** @deprecated If true, redirects directly to payment page */ directPayment: boolean; /** List of allowed payment methods */ paymentMethods?: string[]; /** Base64 encoded image for the payment page */ imageBase?: string; /** Whether to save the payment token for future use */ saveToken?: boolean; } interface PaymentLink extends PaymentLinkPayload { expirationDate: string; hasClient: boolean; updatedAt: string; createdAt: string; qrImage: string; shortUrl: string; paymentUrl: string; } interface MediationPaymentCardConfig { amount: number; currency: "EUR" | "USD"; concept: string; description: string; reference: string; singleUse: boolean; lang: string; productUrl?: string; buyer: null | any; seller: { sellerId?: number; type?: number; email?: string; }; feePercent?: number; feeFixed?: number; sendMail: boolean; } type LoginResponse = { access_token: string; refresh_token: string; token_type: "Bearer"; expires_in: number; scope: string; }; type LoginError = { error: string; }; type Country = { id: number; name: string; sepaZone: boolean; state: number; slug: string; slugn: number; callingCode: number; isDestination: boolean; isRisky: boolean; currentCurrency: string | null; createdAt: string; updatedAt: string; isFavorite: boolean; position: any; }; type Deposit = { id: number; accountNumber: string; alias: string; swift: string; type: number; country: number | null; firstName: string; default: null; state: number; userId: string; countryDestinationId: number; lastName: string; documentNumber: number; userRelationTypeId: number; city: string; postalCode: string; address: string; phone: string; checked: boolean; province: string; beneficiaryType: number; relatedUserId: null | string; currency: string; correspondent?: any; location: any; office: any; officeValue: any; paymentType: number; paymentEntityBeneficiaryId: number; paymentEntityAccountId: number; verified: any; paymentEntityInfo: any; documentTypeId: any; documentExpirationDate: Date; createdAt: Date; updatedAt: Date; countryDestination: Country; }; type AccountDeposits = { count: number; rows: Deposit[]; }; declare class TropipayHooks { private tropipay; constructor(tropipayInstance: Tropipay); /** * Subscribe a new hook * @param event String that represents the name of the event, * you must select from the list of available events, otherwise * it will not produce an error but it will not be executed. * For get full list of available events see endpoint * GET /api/v2/hook/events. * @param target String representing the type of event supported. * It is currently available: 'web' (allows to receive information in a url), * 'email' (allows to receive information in an email address). * @param value if the selected 'target' is email the value would be an * email address, likewise if the selected 'target' is 'web' the expected * value corresponds to a url that receives information through the * HTTP POST method. * @returns */ subscribe({ eventType, target, value, }: { eventType: HookEventType; target: "email" | "web"; value: string; }): Promise; /** * Get the subscribed hook info by his event type. * If no event type is passed, it will return * all subscribed hooks or empty Array if none exist. * @param eventType or no params for retrieving all hooks * @returns All subscribed hooks or empty Array if none exist. */ list(eventType?: HookEventType): Promise; update(eventType: HookEventType, target: "web" | "email", value: string): Promise; delete(eventType: HookEventType, target: string): Promise; events(): Promise; } declare class PaymentCard { private tropipay; constructor(tropipayInstance: Tropipay); /** * Create a paymentLink with the specified options. * @param payload PaymentLinkPayload Object. * @returns Promise or throws an Exception. * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge */ create(payload: PaymentLinkPayload): Promise; /** * Shows a list of stored paymentcards created by user. * This list includes active and closed paylinks * @returns Array of paymentlinks */ list(): Promise; /** * Retrieves a payment card with the specified ID. * * @param {string} id - The ID of the payment card to retrieve. * @return {Promise} A Promise that resolves to the payment card data. * @throws {Error} If an error occurs while retrieving the payment card. */ get(id: string): Promise; /** * Deletes a payment card with the specified ID. Its a LOGIC delete * so this will delete the paymentcard from paymentcard list and * disable shortUrl but not paymentUrl * @param {string} id - The ID of the payment card to delete. * @return {Promise} A Promise that resolves to the deleted payment card data. * @throws {Error} If an error occurs while deleting the payment card. */ delete(id: string): Promise; } declare class MediationPaymentCard { private tropipay; constructor(tropipayInstance: Tropipay); /** * (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options. * This allows a payment to be made to persons belonging or not to the TropiPay platform with the * particularity that the payment will be held in custody or retained until it is released with * the approval of the payer. * @param payload PaymentLinkPayload Object. * @returns Promise or throws an Exception. * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card */ create(payload: MediationPaymentCardConfig): Promise; } interface DepositAccountConfig { searchValue?: string; alias: string; userRelationTypeId: number; beneficiaryType: BeneficiaryType; searchBy?: number; accountNumber?: string; swift?: string; type: DepositAccountType; firstName?: string; lastName?: string; secondLastName?: string; countryDestinationId?: number; city?: string; postalCode?: number; address?: string; documentNumber?: string; phone?: string; province?: string; paymentType?: string; documentTypeId?: number; documentExpirationDate: string; } type INTERNAL = 1; type EXTERNAL = 2; type BeneficiaryType = INTERNAL | EXTERNAL; type DepositAccountType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11; declare class DepositAccounts { private tropipay; constructor(tropipayInstance: Tropipay); /** * List od all beneficiaries of this account * @returns Array of DepositAccounts */ list(): Promise; /** * Adds a new beneficiary to the user account. * @param payload * @returns */ create(depositAccountObj: DepositAccountConfig): Promise; /** * This returns details of a specific * Deposit Account (beneficiary) specified by its ID * @param id * @returns */ get(id: string): Promise; /** * Updates certain beneficiary data. * @param depositAccountObj * @returns */ update(depositAccountObj: Partial): Promise; /** * (UNTESTED) Deletes the beneficiary indicated by id * @param id * @returns */ delete(id: number): Promise; } interface PaymentMethod { slug: string; name: string; enabled: boolean; allowedCurrencies: string[]; } interface ServiceLimit { value: number | null; currency: string; } interface ServiceLimits { min: ServiceLimit; max: ServiceLimit; } interface Service { slug: string; enabled: boolean; allowed_currencies: string[]; limits: ServiceLimits; } interface TropiCard { } interface Account { id: number; accountNumber: string; userId: string; alias: string; balance: number; pendingIn: number; pendingOut: number; state: number; paymentEntityId: number; currency: string; type: number; createdAt: string; updatedAt: string; isDefault: boolean; groupId: number | null; TropiCards: TropiCard[]; services: Service[]; paymentMethods: PaymentMethod[]; } declare class Accounts { private tropipay; constructor(tropipayInstance: Tropipay); /** * List all accounts of the authenticated user * @returns Array of Account objects */ list(): Promise; } /** * Tropipayjs is a Typescript/Javascript library for the Tropipay API. * * @author Yosleivy Baez Acosta * */ type ServerMode = "Development" | "Production"; declare class Tropipay { readonly clientId: string; readonly clientSecret: string; readonly scopes: String[]; request: Axios; loginRequest: Axios; static accessToken: string | null; static refreshToken: string | null; static expiresIn: number | null; serverMode: ServerMode; hooks: TropipayHooks; paymentCards: PaymentCard; depositAccounts: DepositAccounts; mediationPaymentCard: MediationPaymentCard; accounts: Accounts; /** * Initializes a new instance of the Tropipay class. * * @param {TropipayConfig} config - The configuration object. */ constructor(config: TropipayConfig); login(): Promise; /** * Get the list of all supported countries by Tropipay. * @returns Array of Countries Data * @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list */ countries(): Promise; /** * Get user balance * @returns balance Object { balance: number, pendingIn: number, pendingOut: number } */ getBalance(): Promise; /** * Get the list of all detination countries supported by Tropipay. * Obtaining the list of valid countries to send funds to. Useful * when adding new beneficiaries to some user. * * @returns Array of Country Objects * @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries */ destinations(): Promise; /** * Get list of all the favorites payment links. * @returns Array of account Object or throws an error */ favorites(): Promise; /** * List all account movements. You can optionaly specify * offset and limit params for pagination. * @returns */ movements(offset?: number, limit?: number): Promise; /** * Return profile data for current Tropipay account. * @returns account object */ profile(): Promise; /** * Obtain current Tropipay conversion rate. For example USD to EUR * targetCurrency must be 'EUR' * @param originCurrency Target currency code supported by Tropipay. * @param targetCurrency Must be 'EUR'? (not documented by Tropipay) * @returns Conversion rate (number) * @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate */ rates(originCurrency: string, targetCurrency?: string): Promise; /** * (ONLY in Bussiness Accounts) * An escrow payment link. This allows a payment to be made to persons * belonging or not to the TropiPay platform with the particularity * that the payment will be held in custody or retained until it is * released with the approval of the payer. * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card * @param config Payload with the payment details */ createMediationPaymentCard(config: MediationPaymentCardConfig): Promise; } declare class ClientSideUtils { constructor(tropipayInstance: Tropipay); } declare class ServerSideUtils { private tropipay; constructor(tropipayInstance: Tropipay); /** * DEPRECATED Verify Topipay's signature on API V2 webhooks. * @deprecated This method is deprecated and will be removed in future versions. * Use the `verifySignatureV3` method from the `ServerSideUtils` class instead. * @param credentials Credential object or Tropipay instance * @param {String} originalCurrencyAmount * @param bankOrderCode * @param signature * @returns {Boolean} */ static verifySignature(credentials: { clientId: string; clientSecret: string; } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean; /** * Checks if the provided base64 string represents a square image. * * @param {string} base64String - The base64 string of the image * @return {Promise} A Promise that resolves to a boolean indicating whether the image is square */ static isBase64ImageSquare(base64String: string): Promise; /** * Takes a local file path and returns a base64 representation of the file content. * * @param {string} filepath - the path of the file to be converted to base64 * @return {Promise} a Promise that resolves to the base64 representation of the file content */ static fileToBase64(filepath: string): Promise; /** * Get the base64 representation of a remote file from the given URL. * * @param {string} url - the URL of the file * @return {Promise} the base64 representation of the file */ static getBase64FromFileUrl(url: string): Promise; /** * Check if the base64 string represents a valid image and has a valid size * * @param {string} base64Image - the base64 image to be validated * @return {Promise} the valid base64 image */ static isValidImage(base64Image: string): boolean; /** * Verify Topipay's signature on API V3 webhooks. * @param {string} originalCurrencyAmount * @param {string} bankOrderCode * @param {string} signature signaturev3 field to be verified * @returns {boolean} */ static verifySignatureV3(credentials: { clientId: string; clientSecret: string; } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean; } declare const SERVER_MODE: ServerMode$1; export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, MAX_IMAGE_SIZE_MB, MediationPaymentCardConfig, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, UserHook, UserHookSubscribed };