import Client from '../base'; import { PaymentProvider, AccountType, EmailCollectionMode, EmailNotifications, SupportedCard } from '../shared'; /** In-flight payment */ export interface Charge { charge_id: string; /** The amount of the charge, in pence. */ amount: number; /** Amount including all surcharges, in pence. */ total_amount: number; /** Processing fee in pence. Only available depending on payment service provider. */ fee: number; /** Amount including all surcharges and less all fees, in pence. Only available depending on payment service provider. */ net_amount: number; description: string; reference: string; payment_provider: PaymentProvider; card_brand?: string; gateway_transaction_id?: string; email?: string; } interface GatewayAccount { gateway_account_id: number; payment_provider: PaymentProvider; type: AccountType; description: string; service_name: string; analytics_id: string; corporate_credit_card_surcharge_amount: number; corporate_debit_card_surcharge_amount: number; corporate_prepaid_credit_card_surcharge_amount: number; corporate_prepaid_debit_card_surcharge_amount: number; allow_apple_pay: boolean; allow_google_pay: boolean; block_prepaid_cards: boolean; /** Gateway account has 3ds enabled */ toggle_3ds: boolean; allow_zero_amount: boolean; integration_version_3ds: number; allow_moto: boolean; email_collection_mode?: EmailCollectionMode; email_notifications: EmailNotifications; } interface StripeCredentials { stripe_account_id: string; } interface Credentials { merchant_id: string; username: string; } export interface GatewayAccountFrontend extends GatewayAccount { credentials: StripeCredentials | Credentials; live: boolean; /** Gateway account has 3ds enabled */ requires3ds: boolean; sendPayerIpAddressToGateway: boolean; version: number; } export interface GatewayAccountAPI extends GatewayAccount { /** Gateway account has 3ds enabled */ toggle_3ds: boolean; } /** * Convenience methods for accessing resource endpoints for the Connector * service. */ export default class Connector extends Client { constructor(baseUrl: string); charges: { /** * Fetch an in-flight payment * @param id - Charge external ID * @returns In-flight payment object */ retrieve(id: string): Promise; }; accounts: { /** * Internal API view for gateway account * @param id - Gateway account ID * @returns Gateway account object */ retrieveAPI(id: number): Promise; /** * Frontend view for gateway account * @param id - Gateway account ID * @returns Gateway account object */ retrieveFrontend(id: number): Promise; /** * Fetch Stripe credentials map for a given gateway account. If the gateway * account doesn't have Stripe credentials this route will return not found. * @param id - Gateway account ID * @returns Stripe credentials for a requested gateway account */ retrieveStripeCredentials(id: number): Promise; /** * List all supported account types currently enabled by the specified gateway * account * @param id - Gateway account ID * @returns List of card types supported by this gateway account */ listCardTypes(id: number): Promise; list(filters?: ListGatewayAccountsRequest): Promise; /** * Create a new gateway account * @param params - Gateway account details * @returns The created gateway account object */ create(params: CreateGatewayAccountRequest): Promise; /** * Update an existing gateway account. The patch endpoint for accounts only * accepts one operation. The patch endpoint for accounts will respond with * an empty success response * @param id - Gateway account ID * @param params - keys to update on the gateway account * @returns The updated gateway account object */ update(id: number, params: UpdateGatewayAccountAllowMotoRequest | UpdateGatewayAccountBlockPrepaidCardsRequest | UpdateGatewayAccountNotifySettingsRequest): Promise; }; cardTypes: { /** * List all card types supported by the platform * @returns List of card types */ list(): Promise; }; } interface NotifySettings { api_token: string; template_id: string; refund_issued_template_id: string; } interface UpdateGatewayAccountBlockPrepaidCardsRequest { block_prepaid_cards: boolean; } interface UpdateGatewayAccountNotifySettingsRequest { notify_settings: NotifySettings; } interface UpdateGatewayAccountAllowMotoRequest { allow_moto: boolean; } interface CreateGatewayAccountRequest { type: AccountType; payment_provider: PaymentProvider; service_name: string; description: string; credentials?: Credentials | StripeCredentials; analytics_id?: string; requires_3ds?: boolean; } interface ListCardTypesResponse { card_types: SupportedCard[]; } interface ListGatewayAccountsRequest { moto_enabled?: boolean; apple_pay_enabled?: boolean; google_pay_enabled?: boolean; requires_3ds?: boolean; type?: AccountType; payment_provider?: PaymentProvider; } interface ListGatewayAccountsResponse { accounts: GatewayAccount[]; } /** * Connector only responds with the directly parsed gateway account entity rather * than any of the api/ frontend formats */ interface CreateGatewayAccountResponse { type: AccountType; service_name: string; description: string; requires_3ds: boolean; analytics_id?: string; gateway_account_id?: string; } export {};