/** * Common Types for PayWay SDK */ /** * PayWay client configuration */ export interface PayWayConfig { /** Merchant ID provided by ABA Bank (or set PAYWAY_MERCHANT_ID env var) */ merchantId?: string; /** API key provided by ABA Bank (or set PAYWAY_API_KEY env var) */ apiKey?: string; /** RSA public key for encryption (or set PAYWAY_RSA_PUBLIC_KEY env var) */ rsaPublicKey?: string; /** Base URL for PayWay API (or set PAYWAY_BASE_URL env var) */ baseURL?: string; /** Alias for baseURL */ baseUrl?: string; /** Enable sandbox mode */ sandbox?: boolean; /** Enable debug mode to log all requests and responses */ debug?: boolean; } /** * Currency type */ export type Currency = 'USD' | 'KHR'; /** * Purchase type */ export type PurchaseType = 'purchase' | 'pre-auth'; /** * Payment option for checkout */ export type PaymentOption = 'cards' | 'abapay_khqr' | 'abapay_khqr_deeplink' | 'alipay' | 'wechat' | 'google_pay'; /** * View type for payment page */ export type ViewType = 'hosted_view' | 'popup'; /** * Item in a transaction */ export interface QRItem { /** Item name */ name: string; /** Quantity */ quantity: number; /** Price per unit */ price: number; } /** * Payer information */ export interface PayerInfo { /** First name */ firstName?: string; /** Last name */ lastName?: string; /** Email address */ email?: string; /** Phone number */ phone?: string; } /** * Exchange rate request parameters */ export interface ExchangeRateRequest { /** Request timestamp in UTC format YYYYMMDDHHmmss */ req_time: string; /** Merchant ID */ merchant_id: string; /** HMAC SHA-512 hash */ hash: string; } /** * Currency exchange rate */ export interface CurrencyRate { /** Sell rate (KHR per unit of foreign currency) */ sell: string; /** Buy rate (KHR per unit of foreign currency) */ buy: string; } /** * Exchange rates for all supported currencies */ export interface ExchangeRateData { /** Australian Dollar */ aud: CurrencyRate; /** Singapore Dollar */ sgd: CurrencyRate; /** Euro */ eur: CurrencyRate; /** British Pound Sterling */ gbp: CurrencyRate; /** Malaysian Ringgit */ myr: CurrencyRate; /** Thai Baht */ thb: CurrencyRate; /** Hong Kong Dollar */ hkd: CurrencyRate; /** Chinese Yuan */ cny: CurrencyRate; /** Canadian Dollar */ cad: CurrencyRate; /** South Korean Won */ krw: CurrencyRate; /** Japanese Yen */ jpy: CurrencyRate; /** Vietnamese Dong */ vnd: CurrencyRate; } /** * Exchange rate response */ export interface ExchangeRateResponse { /** Response status */ status: { /** Status code: '00' = Success, '1' = Wrong hash, '26' = Invalid merchant */ code: string; /** Status message */ message: string; }; /** Exchange rates for all currencies */ exchange_rates: ExchangeRateData; } /** * Payout distribution */ export interface PayoutInfo { /** Merchant ID to receive payout */ merchant_id: string; /** Amount to distribute */ amount: number; } /** * Return deeplink configuration for payment results */ export interface ReturnDeeplink { /** Deeplink for successful payment */ success?: string; /** Deeplink for failed payment */ fail?: string; /** Deeplink for cancelled payment */ cancel?: string; } /** * Mobile app deeplink configuration */ export interface MobileDeeplink { /** iOS app scheme */ ios_scheme?: string; /** Android app scheme */ android_scheme?: string; } /** * PayWay error codes */ export declare enum PayWayErrorCode { INVALID_HASH = "01", INVALID_MERCHANT = "02", INVALID_API_KEY = "03", INVALID_AMOUNT = "10", INVALID_CURRENCY = "11", INVALID_TRANSACTION_ID = "12", MISSING_REQUIRED_FIELD = "13", TRANSACTION_NOT_FOUND = "20", TRANSACTION_EXPIRED = "21", TRANSACTION_ALREADY_PROCESSED = "22", SYSTEM_ERROR = "99" }