/** * Purchase/Checkout Types */ import { Currency, PurchaseType, PaymentOption, ViewType, QRItem, PayerInfo } from './common.types'; /** * Purchase request parameters */ export interface PurchaseRequest { /** Request timestamp in UTC format YYYYMMDDHHmmss */ req_time: string; /** Merchant ID */ merchant_id: string; /** Transaction ID */ tran_id: string; /** Transaction amount */ amount: number; /** Currency (USD or KHR) */ currency?: Currency; /** Buyer's first name */ firstname?: string; /** Buyer's last name */ lastname?: string; /** Buyer's email */ email?: string; /** Buyer's phone */ phone?: string; /** Transaction type (purchase or pre-auth) */ type?: PurchaseType; /** Payment method option */ payment_option?: PaymentOption; /** Items as Base64 encoded JSON string */ items?: string; /** Shipping fee */ shipping?: number; /** Return URL as Base64 encoded string */ return_url?: string; /** Cancel URL */ cancel_url?: string; /** Skip success page (0 or 1) */ skip_success_page?: number; /** Continue success URL */ continue_success_url?: string; /** Return deeplink as Base64 encoded JSON string */ return_deeplink?: string; /** Custom fields as Base64 encoded JSON string */ custom_fields?: string; /** Return parameters as Base64 encoded JSON string */ return_params?: string; /** View type for payment page */ view_type?: ViewType; /** Payment gate (0 for checkout service) */ payment_gate?: number; /** Payout as Base64 encoded JSON string */ payout?: string; /** Additional params as Base64 encoded JSON string */ additional_params?: string; /** Payment lifetime in minutes */ lifetime?: number; /** Google Pay token */ google_pay_token?: string; /** HMAC SHA-512 hash */ hash: string; } /** * Purchase options for simplified API */ export interface PurchaseOptions { /** Transaction amount */ amount: number; /** Currency (USD or KHR) */ currency?: Currency; /** Custom transaction ID (optional, auto-generated if not provided) */ tranId?: string; /** Array of items */ items?: QRItem[]; /** Payer information */ payer?: PayerInfo; /** Shipping fee */ shipping?: number; /** Return URL for payment callback */ returnUrl?: string; /** Cancel URL */ cancelUrl?: string; /** Skip success page */ skipSuccessPage?: boolean; /** Continue success URL */ continueSuccessUrl?: string; /** Custom fields */ customFields?: Record; /** Return parameters */ returnParams?: Record; /** Payout distribution */ payout?: Array<{ acc: string; amt: number; }>; /** Payment lifetime in minutes */ lifetime?: number; /** Purchase type */ purchaseType?: PurchaseType; /** Payment option */ paymentOption?: PaymentOption; /** View type */ viewType?: ViewType; /** Return deeplink configuration */ returnDeeplink?: { ios_scheme?: string; android_scheme?: string; }; /** Additional parameters */ additionalParams?: Record; /** Google Pay token */ googlePayToken?: string; /** Payment gate */ paymentGate?: number; } /** * Purchase response status */ export interface PurchaseResponseStatus { /** Status code ('0' for success, other codes for errors) */ code: string; /** Status message */ message: string; /** Transaction ID */ tran_id: string; } /** * Purchase response */ export interface PurchaseResponse { /** Response status (for JSON responses) */ status?: PurchaseResponseStatus; /** QR string (when using abapay_khqr_deeplink) */ qr_string?: string; /** ABA Pay deeplink (when using abapay_khqr_deeplink) */ abapay_deeplink?: string; /** Checkout QR URL (when using abapay_khqr_deeplink) */ checkout_qr_url?: string; /** HTML content for hosted view */ html?: string; /** Transaction ID (for HTML responses) */ tran_id?: string; } /** * Token purchase request parameters (Card on File / Account on File) */ export interface TokenPurchaseRequest { /** Request timestamp in UTC format YYYYMMDDHHmmss */ req_time: string; /** Merchant ID */ merchant_id: string; /** Transaction ID */ tran_id: string; /** Consumer token (your internal customer ID) */ ctid: string | null; /** PayWay-issued token (card or account token) */ pwt: string | null; /** Buyer's first name */ firstname?: string; /** Buyer's last name */ lastname?: string; /** Buyer's email */ email?: string; /** Buyer's phone */ phone?: string; /** Transaction type (purchase or pre-auth) */ type?: PurchaseType; /** Items as Base64 encoded JSON string */ items?: string; /** Shipping fee */ shipping?: number; /** Transaction amount (exclude shipping fee) */ amount: number; /** Currency (USD or KHR) */ currency?: Currency; /** Return URL as Base64 encoded string */ return_url?: string; /** Custom fields as Base64 encoded JSON string */ custom_fields?: string; /** Return parameters */ return_params?: string; /** Payout as Base64 encoded JSON string */ payout?: string; /** HMAC SHA-512 hash */ hash: string; } /** * Token purchase options for simplified API */ export interface TokenPurchaseOptions { /** Transaction amount (exclude shipping fee) */ amount: number; /** Consumer token (your internal customer ID) */ ctid: string | null; /** PayWay-issued token (card or account token from linking) */ pwt: string | null; /** Custom transaction ID (optional, auto-generated if not provided) */ tranId?: string; /** Currency (USD or KHR) */ currency?: Currency; /** Array of items */ items?: QRItem[]; /** Payer information */ payer?: PayerInfo; /** Shipping fee */ shipping?: number; /** Transaction type (purchase or pre-auth) */ type?: PurchaseType; /** Return URL for payment callback */ returnUrl?: string; /** Custom fields */ customFields?: Record; /** Return parameters */ returnParams?: string; /** Payout distribution */ payout?: Array<{ acc: string; amt: number; }>; } /** * Token purchase payment status */ export interface TokenPurchasePaymentStatus { /** Status (0 or '0' for success) - API returns number, but may vary by implementation */ status: number | string; /** Status code ('CDA00' for success) */ code: string; /** Description message */ description: string; /** PayWay transaction ID */ pw_tran_id: string; } /** * Token purchase response */ export interface TokenPurchaseResponse { /** Your transaction ID */ tran_id: string; /** Payment status object */ payment_status: TokenPurchasePaymentStatus; } /** * Token purchase error response */ export interface TokenPurchaseErrorResponse { /** Error status object */ status: { /** Error code (see error code mapping) */ code: string; /** Error message */ message: string; }; }