import { FiatCurrency } from "../currency/currencies"; import { ChainId, ChainType, PaymentMethod, PaymentRail, PayOrderMode, PayOrderStatus } from "./enums"; import { PayOrderEvent } from "./events"; import { CurrencyAmount, CurrencyBase, CurrencyWithAmount, FiatAmount, PaymentDataBase, PayOrder, PayOrderMetadata, QuoteWithCurrency } from "./model"; export type CreatePayOrderMode = PayOrderMode.SALE | PayOrderMode.DEPOSIT; export type OrderRequest = PayOrderParams & { mode: CreatePayOrderMode; }; export type PayOrderParams = { /** * Intent of the order. */ intent: PayOrderIntent; /** * Metadata to attach to the payOrder. */ metadata?: PayOrderMetadata; }; export type PayOrderQuoteParams = { wallet_address: string; chain_type: ChainType; chain_ids?: ChainId[]; }; export type PaymentDetailsParams = { payorder_id: string; payment_rail?: PaymentRail; source_currency?: CurrencyBase; refund_address?: string; quote_id?: string; }; export type PaymentDetails = { payorder_id: string; status: PayOrderStatus; data: PaymentDataBase; }; export type PaymentMethodAvailability = { method: PaymentMethod; available: boolean; reason?: string; minimum_amount?: FiatAmount; }; export type PaymentMethodsResponse = { methods: PaymentMethodAvailability[]; }; export type PayOrderIntent = { /** * Desired fulfillment asset. */ asset?: CurrencyBase; /** * Amount expected in order to fulfill the order. */ amount: IntentAmount; /** * Optional receiving address to fulfill the order to. If not provided, a settlement address will be selected. */ receiving_address?: string; }; export type IntentAmount = { /** * Intent token amount in human readable format (e.g. "10" for 10 tokens). */ token_amount?: number; /** * Intent fiat amount in human readable format (e.g. "10" for 10 USD). */ fiat?: { amount: number; unit: FiatCurrency; }; }; export type FeeBalance = { fiat: FiatCurrency; amount_cents: number; }; export type GetFeeBalancesResponse = FeeBalance; export type ClaimFeesRequest = { currency: CurrencyBase; recipient: string; metadata?: PayOrderMetadata; }; export type ClaimFeesResponse = { claim_order_id: string; source_transaction_hash: string; transaction_hash: string; source_chain_id: ChainId; currency: CurrencyAmount; }; export type EndorsementName = "base" | "sepa" | "spei" | "pix"; export type KYCLinkType = "individual" | "business"; export type KYCStatus = "not_started" | "incomplete" | "awaiting_questionnaire" | "awaiting_ubo" | "under_review" | "approved" | "rejected" | "paused" | "offboarded"; export type TOSStatus = "pending" | "approved"; export type KYCRejectionReason = { developer_reason: string; reason: string; created_at: string; }; export type KYCLinkRequest = { email: string; type: KYCLinkType; full_name?: string; endorsements?: EndorsementName[]; redirect_uri?: string; }; export type KYCLinkResponse = { id: string; type: KYCLinkType; customer_id?: string | null; full_name?: string | null; email: string; kyc_link: string; kyc_status: KYCStatus; rejection_reasons?: KYCRejectionReason[]; tos_link: string; tos_status: TOSStatus; created_at?: string | null; }; export type Pagination = { total_count: number; limit: number; offset: number; }; export type ResponseWithPagination = { data: PayOrder[]; pagination: Pagination; }; export type WebhookResponse = { id: string; url: string; webhook_secret?: string; subscription_events?: string[]; active: boolean; }; export type CreateWebhookRequest = { url: string; subscription_events?: string[]; }; export type UpdateWebhookRequest = { url?: string; subscription_events?: string[]; active?: boolean; }; export type SwapMode = "ExactIn" | "ExactOut"; export type CryptoSwapInput = { slippage_bps?: number; source_currency: CurrencyBase; sender_address?: string; }; export type SwapIntent = { payment_rail?: PaymentRail; destination_currency: CurrencyBase; amount: string; swap_mode: SwapMode; receiving_address?: string; crypto?: CryptoSwapInput; custom_fee_bps?: number; }; export type SwapQuoteRequest = { metadata?: PayOrderMetadata; intent: SwapIntent; }; export type SwapQuoteResponse = { input: QuoteWithBalance; output: CurrencyWithAmount; price_impact: number; providers?: string[]; slippage_bps?: number; swap_mode: SwapMode; }; export type RouteQuote = QuoteWithBalance & { quote_id: string; output: CurrencyWithAmount; price_impact: number; providers?: string[]; slippage_bps?: number; swap_mode: SwapMode; }; export type QuoteWithBalance = QuoteWithCurrency & { balance?: CurrencyAmount; }; export type OrderQuoteResponse = RouteQuote[]; export type SwapDataRequest = { metadata?: PayOrderMetadata; intent: SwapIntent; receiving_address: string; }; export type SwapDataResponse = PaymentDetails; export type WsConnectMessage = { type: "connect"; data: { api_key: string; }; }; export type WsSubscribeMessage = { type: "subscribe"; data: { order_id?: string | null; }; }; export type WsUnsubscribeMessage = { type: "unsubscribe"; data: { order_id?: string | null; }; }; export type WsClientMessage = WsConnectMessage | WsSubscribeMessage | WsUnsubscribeMessage; export type WsConnectedMessage = { type: "connected"; data: { status: "authenticated"; }; }; export type WsSubscriptionMessage = { type: "subscription"; data: { order_id?: string; scope: "order" | "organization"; status: "subscribed" | "unsubscribed"; }; }; export type WsEventMessage = { type: "event"; data: PayOrderEvent; }; export type WsErrorMessage = { type: "error"; data: { message: string; }; }; export type WsServerMessage = WsConnectedMessage | WsSubscriptionMessage | WsEventMessage | WsErrorMessage; export type OrderStatusSocket = { subscribe: (orderId: string) => void; subscribeOrg: () => void; unsubscribe: (orderId?: string) => void; unsubscribeOrg: () => void; onMessage: (callback: (msg: WsServerMessage) => void) => void; onOpen: (callback: () => void) => void; onClose: (callback: (event: CloseEvent) => void) => void; onError: (callback: (event: Event) => void) => void; close: () => void; };