/** * Purchase Service * Handles purchase/checkout operations */ import { BaseService } from './BaseService'; import { PurchaseRequest, PurchaseResponse, PurchaseOptions, TokenPurchaseRequest, TokenPurchaseResponse, TokenPurchaseOptions } from '../types'; /** * Service for purchase/checkout operations */ export declare class PurchaseService extends BaseService { /** * Create a purchase transaction (simplified API) * * The Purchase API is used to initiate a payment transaction between a customer * and a merchant through PayWay. Once called, the customer is redirected to PayWay's * hosted checkout page, bottom sheet, or modal popup where they can complete the payment. * * @param options - Purchase options * @returns Purchase response with checkout URL or HTML * @throws {PayWayError} If request fails or validation errors occur * * @example * const result = await purchaseService.purchase({ * amount: 10.00, * currency: 'USD', * items: [{ name: 'Product 1', quantity: 1, price: 10.00 }], * returnUrl: 'https://example.com/callback' * }); */ purchase(options: PurchaseOptions): Promise; /** * Create purchase transaction (low-level API) * * The API returns different response types based on payment_option: * * **JSON Response (Content-Type: application/json)** * - When: payment_option = 'abapay_khqr_deeplink' * - Returns: { status: { code, message, tran_id }, qr_string, abapay_deeplink, checkout_qr_url } * * **HTML Response (Content-Type: text/html)** * - When: payment_option = 'cards', 'abapay_khqr', 'alipay', 'wechat', etc. * - Returns: Complete HTML checkout page (...) * - Usage: Redirect user to PayWay URL or render HTML in iframe/webview * * @param params - Full request parameters * @returns Purchase response (JSON or HTML) * @throws {PayWayError} If API request fails */ createPurchase(params: PurchaseRequest): Promise; /** * Purchase using token (simplified API) * * This API supports both card tokens (Card on File) and account tokens (Account on File). * Use the tokens obtained from linking APIs to process payments without requiring * the customer to re-enter their card or account details. * * @param options - Token purchase options * @returns Token purchase response with payment status * @throws {PayWayError} If request fails or validation errors occur * * @example * const result = await purchaseService.purchaseWithToken({ * amount: 50.00, * ctid: 'customer-123', * pwt: 'token-from-linking-api', * items: [{ name: 'Product 1', quantity: 1, price: 50.00 }] * }); */ purchaseWithToken(options: TokenPurchaseOptions): Promise; /** * Create token purchase transaction (low-level API) * * @param params - Full token purchase request parameters * @returns Token purchase response with payment status * @throws {PayWayError} If API request fails */ createTokenPurchase(params: TokenPurchaseRequest): Promise; }