@waffo/waffo-node 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1063 -390
- package/dist/index.d.mts +1567 -4258
- package/dist/index.d.ts +1567 -4258
- package/dist/index.js +1128 -1597
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1105 -1560
- package/dist/index.mjs.map +1 -1
- package/package.json +28 -43
- package/README.ja.md +0 -588
- package/README.zh-CN.md +0 -588
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/config.ts","../src/types/network.ts","../src/types/webhook.ts","../src/types/iso.ts","../src/types/payment.ts","../src/types/order.ts","../src/types/refund.ts","../src/types/subscription.ts","../src/utils/rsa.ts","../src/utils/webhook.ts","../src/core/httpClient.ts","../src/core/webhook.ts","../src/resources/base.ts","../src/resources/order/resource.ts","../src/resources/refund/resource.ts","../src/resources/subscription/resource.ts","../src/resources/merchantconfig/resource.ts","../src/resources/paymethodconfig/resource.ts","../src/core/waffo.ts"],"names":["Environment","HttpStatusCode","WebhookEventType","WebhookResponseStatus","CountryCode","CurrencyCode","ProductName","SubscriptionProductName","UserTerminalType","OrderStatus","OrderActionType","PayMethodUserAccountType","CaptureMode","MerchantInitiatedMode","ThreeDsDecision","RefundStatus","SubscriptionStatus","PeriodType","SubscriptionUserTerminalType","CashierLanguage","SubscriptionPayMethodUserAccountType","SubscriptionOrderStatus","SubscriptionEventType","body"],"mappings":";;;AAsDO,IAAK,WAAA,qBAAAA,YAAAA,KAAL;AAEL,EAAAA,aAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,aAAA,YAAA,CAAA,GAAa,YAAA;AAJH,EAAA,OAAAA,YAAAA;AAAA,CAAA,EAAA,WAAA,IAAA,EAAA;AAkBL,IAAM,eAAA,GAA+C;AAAA,EAC1D,CAAC,0BAAsB,sCAAA;AAAA,EACvB,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AwB,IAAA,CAAK,UAAU,CAAA;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgCA,OAAO,eAAA,GAA2B;AAChC,IAAA,MAAM,OAAO,aAAA,EAAc;AAC3B,IAAA,OAAO;AAAA,MACL,YAAY,IAAA,CAAK,gBAAA;AAAA,MACjB,WAAW,IAAA,CAAK;AAAA,KAClB;AAAA,EACF;AACF","file":"index.mjs","sourcesContent":["/**\n * @fileoverview SDK Configuration Type Definitions\n * @module types/config\n *\n * Configuration types for the Waffo SDK:\n * - Environment settings (SANDBOX/PRODUCTION)\n * - SDK initialization configuration\n * - HTTP request options\n *\n * @see {@link Waffo} for SDK initialization\n * @see {@link HttpClient} for making API requests\n *\n * @example\n * import { Environment, WaffoConfig } from 'waffo-sdk';\n *\n * const config: WaffoConfig = {\n * apiKey: 'your-api-key',\n * privateKey: 'your-private-key',\n * environment: Environment.SANDBOX,\n * };\n */\n\nimport { Logger } from \"./logger\";\n\n// ============================================================\n// Environment Configuration\n// ============================================================\n\n/**\n * SDK runtime environment.\n *\n * - **SANDBOX**: Development and testing (no real transactions)\n * - **PRODUCTION**: Live transactions with real payments\n *\n * @enum {string}\n * @readonly\n *\n * @example\n * import { Environment } from 'waffo-sdk';\n *\n * // Use sandbox for testing\n * const waffo = new Waffo({\n * apiKey: 'test-key',\n * privateKey: 'test-private-key',\n * environment: Environment.SANDBOX,\n * });\n *\n * // Use production for live payments\n * const waffoProd = new Waffo({\n * apiKey: process.env.WAFFO_API_KEY,\n * privateKey: process.env.WAFFO_PRIVATE_KEY,\n * environment: Environment.PRODUCTION,\n * });\n */\nexport enum Environment {\n /** Sandbox testing environment */\n SANDBOX = \"sandbox\",\n /** Production environment for live transactions */\n PRODUCTION = \"production\",\n}\n\n/**\n * Maps environments to their API base URLs.\n *\n * | Environment | Base URL |\n * |-------------|----------|\n * | SANDBOX | https://api-sandbox.waffo.com/api/v1 |\n * | PRODUCTION | https://api.waffo.com/api/v1 |\n *\n * @constant\n * @type {Record<Environment, string>}\n */\nexport const EnvironmentUrls: Record<Environment, string> = {\n [Environment.SANDBOX]: \"https://api-sandbox.waffo.com/api/v1\",\n [Environment.PRODUCTION]: \"https://api.waffo.com/api/v1\",\n};\n\n/**\n * Maps environments to Waffo's RSA public keys.\n *\n * Used to verify API response signatures. Keys are Base64 encoded X509/SPKI DER format.\n * These are embedded in the SDK and updated when Waffo rotates their keys.\n *\n * @constant\n * @type {Record<Environment, string>}\n * @remarks To use a custom public key, provide it via the `waffoPublicKey` config option.\n */\nexport const EnvironmentPublicKeys: Record<Environment, string> = {\n [Environment.SANDBOX]:\n \"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAhAbK3dBDZdCaX/5cqlO8EYYL4M4DyigqAMoIaT6R0SuSENu279dHZ3JiS8JukHx/xg85T9S3wDNwnu8KDypcwi8TxNQKgBE4czgAJ5GFEdJ+jtUS1dK46gjJFUnUlavb3uMLJJ0xZZKH0B5GtKOq75MwHWtXLK3zQrPqZosXqdgZhfbV+7bXlQaABdPlqif/ybN1DRrvcWmNVLAgsRiQvu4QnDOTMafzrSsF5tf8Ud3gK+JhcJs50NsXLPZZSc6NryZoH++xmz8atp0dOrBKmsJkZRWjrH+aXDZZT1sZDlgsKBMoRPf6F+lztFOPerrhSE81Y5MFaAp8R/QicMGCPueLhlebjx1OF0oowUD9b7ggZ8LiYpaR4HT9OmDpsu6NMN7zNG81qo7vnKCyy//xdOkpr4bQsm581r312y1UUjaYTZTlqAe+qbGZmZ7zS+ra0uwS6zLoZOY1ToOwlJbTwRPx2epweJcRnJVueiS1fPxaAlQz+tuVtIGONmZ836aHAgMBAAE=\",\n [Environment.PRODUCTION]:\n \"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqVHKdn76r6IhRXxWihdy+AiG0tzVR8LjDXC+0WFdTkn05Ga7ZS0WC3MRpxgRsbBWDlEVZYPUBdrtAmQeZYD7rwKSKSTdd62eZxehDI8DCzNhxppbeMPBhMn72eQvB/RQl1qhP7HLZx9IyTC7EbWWO0zhhomzf0hQ2K7KXDFq9bSYdBGAzSg+kOQFP2eifON8qm4TuwlxNSdTcgRWa8cRwy9h9aLra1iaeFRx9k68KxIcK0ZiGbD6KiR1a2NtZuxjB6bTJ7N/ydfKqQY+wB1CTWIlvouW1qajYYGBAcde9JN6o6CiWz3sPt42312CF3+k+gQeiuofdXkzVlMryVivfwIDAQAB\",\n};\n\n// ============================================================\n// SDK Configuration\n// ============================================================\n\n/**\n * Configuration for initializing the Waffo SDK.\n *\n * **Required:**\n * - `apiKey` - Your API key from Waffo\n * - `privateKey` - Your merchant private key for signing requests\n *\n * **Optional:**\n * - `waffoPublicKey` - Override the built-in Waffo public key\n * - `environment` - API environment (defaults to PRODUCTION)\n * - `timeout` - Request timeout in milliseconds (defaults to 30000)\n * - `logger` - Logger instance for debugging\n *\n * @interface WaffoConfig\n *\n * @example\n * const config: WaffoConfig = {\n * apiKey: process.env.WAFFO_API_KEY!,\n * privateKey: process.env.WAFFO_PRIVATE_KEY!,\n * environment: Environment.PRODUCTION,\n * timeout: 60000,\n * logger: console,\n * };\n *\n * @see {@link Waffo} for SDK initialization\n * @see {@link Environment} for available environments\n */\nexport interface WaffoConfig {\n /** API key assigned by Waffo (required) */\n apiKey: string;\n /** Merchant private key, Base64 encoded PKCS8 DER format (required) */\n privateKey: string;\n /** Waffo's public key for response verification (defaults to built-in) */\n waffoPublicKey?: string;\n /** SDK runtime environment (defaults to PRODUCTION) */\n environment?: Environment;\n /** HTTP request timeout in milliseconds (defaults to 30000) */\n timeout?: number;\n /** Logger instance for debugging */\n logger?: Logger;\n}\n\n/**\n * Options for individual HTTP requests.\n *\n * Used when calling {@link HttpClient.post} directly.\n *\n * @interface RequestOptions\n * @template B - Request body type (defaults to `Record<string, unknown>`)\n *\n * @example\n * const options: RequestOptions<CreateOrderParams> = {\n * body: { paymentRequestId: '123', ... },\n * headers: { 'X-Custom-Header': 'value' },\n * };\n *\n * @see {@link HttpClient.post} for making HTTP requests\n */\nexport interface RequestOptions<B extends object = Record<string, unknown>> {\n /** Request body (will be JSON serialized and signed) */\n body?: B;\n /** Additional HTTP headers to include */\n headers?: Record<string, string>;\n}\n","/**\n * @fileoverview Common Network Type Definitions\n * @module types/network\n *\n * Common network-related types shared across HTTP client and webhook handling:\n * - HTTP status codes\n * - Signature header interface\n */\n\n// ============================================================\n// HTTP Status Codes\n// ============================================================\n\n/**\n * Standard HTTP status codes used in API responses.\n *\n * @enum {number}\n * @readonly\n *\n * @example\n * if (result.statusCode === HttpStatusCode.OK) {\n * console.log('Request successful');\n * } else if (result.statusCode === HttpStatusCode.REQUEST_TIMEOUT) {\n * console.log('Request timed out');\n * }\n */\nexport enum HttpStatusCode {\n OK = 200,\n BAD_REQUEST = 400,\n UNAUTHORIZED = 401,\n PAYMENT_REQUIRED = 402,\n FORBIDDEN = 403,\n NOT_FOUND = 404,\n METHOD_NOT_ALLOWED = 405,\n REQUEST_TIMEOUT = 408,\n INTERNAL_SERVER_ERROR = 500,\n NOT_IMPLEMENTED = 501,\n BAD_GATEWAY = 502,\n SERVICE_UNAVAILABLE = 503,\n GATEWAY_TIMEOUT = 504,\n}\n\n// ============================================================\n// Common Header Types\n// ============================================================\n\n/**\n * Common header structure containing RSA-SHA256 signature.\n *\n * Used in API responses and webhook requests/responses.\n *\n * @interface SignatureHeader\n */\nexport interface SignatureHeader {\n /** RSA-SHA256 signature (Base64 encoded) */\n \"X-SIGNATURE\": string;\n /** MIME type (typically \"application/json\") */\n \"Content-Type\": string;\n}\n","/**\n * @fileoverview Webhook Type Definitions\n * @module types/webhook\n *\n * Types for processing webhook notifications:\n * - Event types and response status enums\n * - Request/Response interfaces\n * - Handler types for processing notifications\n *\n * @see {@link WebhookHandler} for processing webhooks\n *\n * @example\n * import {\n * WebhookEventType,\n * WebhookResponseStatus,\n * WebhookHandlerOptions,\n * } from 'waffo-sdk';\n *\n * const options: WebhookHandlerOptions = {\n * onPayment: async (ctx) => {\n * console.log('Event:', ctx.eventType);\n * console.log('Notification:', ctx.notification);\n * },\n * };\n */\n\nimport { SignatureHeader } from \"./network\";\nimport { PaymentNotification } from \"./order\";\nimport { RefundNotification } from \"./refund\";\nimport {\n SubscriptionStatusNotification,\n SubscriptionPaymentNotification,\n} from \"./subscription\";\n\n// ============================================================\n// Webhook Enums\n// ============================================================\n\n/**\n * Type of webhook notification from Waffo.\n *\n * @enum {string}\n * @readonly\n */\nexport enum WebhookEventType {\n /** Payment order status change */\n PAYMENT_NOTIFICATION = \"PAYMENT_NOTIFICATION\",\n /** Refund status change */\n REFUND_NOTIFICATION = \"REFUND_NOTIFICATION\",\n /** Subscription status change */\n SUBSCRIPTION_STATUS_NOTIFICATION = \"SUBSCRIPTION_STATUS_NOTIFICATION\",\n}\n\n/**\n * Merchant webhook response status.\n *\n * - **SUCCESS**: Waffo stops retrying\n * - **FAILED/UNKNOWN**: Waffo retries within 24 hours\n *\n * @enum {string}\n * @readonly\n *\n * @example\n * // Return SUCCESS to acknowledge receipt\n * const response = buildWebhookResponse(WebhookResponseStatus.SUCCESS, privateKey);\n *\n * // Return FAILED to request retry\n * const response = buildWebhookResponse(WebhookResponseStatus.FAILED, privateKey);\n */\nexport enum WebhookResponseStatus {\n /** Successfully processed, no retry needed */\n SUCCESS = \"success\",\n /** Processing failed, Waffo will retry */\n FAILED = \"failed\",\n /** Unknown status, Waffo will retry */\n UNKNOWN = \"unknown\",\n}\n\n// ============================================================\n// Webhook Request/Response Types\n// ============================================================\n\n/**\n * Webhook request headers from Waffo.\n * @interface WebhookRequestHeader\n */\nexport interface WebhookRequestHeader {\n /** RSA-SHA256 signature for verification */\n \"X-SIGNATURE\": string;\n /** Optional MIME type */\n \"Content-Type\"?: string;\n}\n\n/**\n * Webhook response headers to send back to Waffo.\n * @type WebhookResponseHeader\n */\nexport type WebhookResponseHeader = SignatureHeader;\n\n/**\n * Webhook response body to send back to Waffo.\n * @interface WebhookResponseBody\n */\nexport interface WebhookResponseBody {\n /** Response status message */\n message: WebhookResponseStatus | string;\n}\n\n/**\n * Complete webhook response structure.\n *\n * @interface WebhookResponse\n *\n * @example\n * const response: WebhookResponse = buildSuccessResponse(privateKey);\n * res.set(response.header).json(response.body);\n */\nexport interface WebhookResponse {\n /** Response headers (includes X-SIGNATURE) */\n header: WebhookResponseHeader;\n /** Response body (includes status message) */\n body: WebhookResponseBody;\n}\n\n// ============================================================\n// Webhook Handler Types\n// ============================================================\n\n/**\n * Context passed to webhook handlers.\n *\n * @interface WebhookHandlerContext\n * @template T - The notification type\n *\n * @example\n * const handler: PaymentNotificationHandler = async (ctx) => {\n * console.log('Event type:', ctx.eventType);\n * console.log('Raw body:', ctx.rawBody);\n * console.log('Order status:', ctx.notification.result.orderStatus);\n * };\n */\nexport interface WebhookHandlerContext<T> {\n /** Parsed notification payload */\n notification: T;\n /** Original raw request body (for logging/debugging) */\n rawBody: string;\n /** Webhook event type */\n eventType: WebhookEventType;\n}\n\n/**\n * Handler for payment notifications.\n * @param context - Context with PaymentNotification\n */\nexport type PaymentNotificationHandler = (\n context: WebhookHandlerContext<PaymentNotification>,\n) => void | Promise<void>;\n\n/**\n * Handler for refund notifications.\n * @param context - Context with RefundNotification\n */\nexport type RefundNotificationHandler = (\n context: WebhookHandlerContext<RefundNotification>,\n) => void | Promise<void>;\n\n/**\n * Handler for subscription status notifications.\n * @param context - Context with SubscriptionStatusNotification\n */\nexport type SubscriptionStatusNotificationHandler = (\n context: WebhookHandlerContext<SubscriptionStatusNotification>,\n) => void | Promise<void>;\n\n/**\n * Handler for subscription payment notifications.\n * @param context - Context with SubscriptionPaymentNotification\n */\nexport type SubscriptionPaymentNotificationHandler = (\n context: WebhookHandlerContext<SubscriptionPaymentNotification>,\n) => void | Promise<void>;\n\n/**\n * Handler for webhook processing errors.\n * @param error - The error that occurred\n */\nexport type WebhookErrorHandler = (error: Error) => void | Promise<void>;\n\n/**\n * Options for configuring webhook handlers.\n *\n * @interface WebhookHandlerOptions\n *\n * @example\n * const options: WebhookHandlerOptions = {\n * onPayment: async (ctx) => {\n * await updateOrder(ctx.notification.result);\n * },\n * onRefund: async (ctx) => {\n * await processRefund(ctx.notification.result);\n * },\n * onSubscriptionStatus: async (ctx) => {\n * await updateSubscription(ctx.notification.result);\n * },\n * onSubscriptionPayment: async (ctx) => {\n * await recordPayment(ctx.notification.result);\n * },\n * onError: async (error) => {\n * console.error('Webhook error:', error);\n * },\n * };\n */\nexport interface WebhookHandlerOptions {\n /** Handler for payment notifications */\n onPayment?: PaymentNotificationHandler;\n /** Handler for refund notifications */\n onRefund?: RefundNotificationHandler;\n /** Handler for subscription status changes */\n onSubscriptionStatus?: SubscriptionStatusNotificationHandler;\n /** Handler for subscription recurring payments */\n onSubscriptionPayment?: SubscriptionPaymentNotificationHandler;\n /** Handler for processing errors */\n onError?: WebhookErrorHandler;\n}\n\n/**\n * Result from webhook handler.\n *\n * @interface WebhookHandlerResult\n *\n * @example\n * const result = await waffo.webhook.handle(body, signature, options);\n * if (result.success) {\n * res.set(result.response.header).json(result.response.body);\n * } else {\n * console.error('Webhook failed:', result.error);\n * res.set(result.response.header).json(result.response.body);\n * }\n */\nexport interface WebhookHandlerResult {\n /** Whether processing was successful */\n success: boolean;\n /** Signed response to send back to Waffo */\n response: WebhookResponse;\n /** Error message (only on failure) */\n error?: string;\n}\n","/**\n * @fileoverview ISO Standard Code Definitions\n * @module types/iso\n *\n * @description\n * This module contains ISO standard codes used throughout the SDK:\n *\n * - **{@link CountryCode}** - ISO 3166-1 alpha-3 country codes (e.g., USA, JPN, CHN)\n * - **{@link CurrencyCode}** - ISO 4217 currency codes (e.g., USD, JPY, EUR)\n *\n * These codes ensure international compatibility and standardization\n * for order creation, address information, and payment processing.\n *\n * @example\n * // Using country codes for user address\n * import { CountryCode, CurrencyCode } from 'waffo-sdk-nodejs';\n *\n * const orderParams = {\n * orderAmount: '1000',\n * orderCurrency: CurrencyCode.JPY,\n * userInfo: {\n * userCountry: CountryCode.JPN,\n * },\n * addressInfo: {\n * country: CountryCode.JPN,\n * city: 'Tokyo',\n * },\n * };\n *\n * @example\n * // Multi-currency support\n * const supportedCurrencies = [\n * CurrencyCode.USD,\n * CurrencyCode.EUR,\n * CurrencyCode.JPY,\n * CurrencyCode.GBP,\n * ];\n *\n * @see {@link CreateOrderParams} for order creation parameters\n * @see {@link AddressInfo} for address information structure\n */\n\n// ============================================================\n// Country Codes (ISO 3166-1 alpha-3)\n// ============================================================\n\n/**\n * ISO 3166-1 alpha-3 country codes.\n *\n * @description\n * Three-letter country codes following the ISO 3166-1 standard.\n * Use these codes for specifying user country and address information\n * in order creation and payment processing.\n *\n * Common codes:\n * - `USA` - United States of America\n * - `JPN` - Japan\n * - `CHN` - China\n * - `GBR` - United Kingdom\n * - `DEU` - Germany\n *\n * @example\n * // Specify user's country\n * const userInfo = {\n * userCountry: CountryCode.JPN,\n * userName: 'Taro Yamada',\n * };\n *\n * @example\n * // Specify shipping address country\n * const addressInfo = {\n * country: CountryCode.USA,\n * state: 'CA',\n * city: 'San Francisco',\n * address1: '123 Main St',\n * zipCode: '94102',\n * };\n *\n * @enum {string}\n * @readonly\n * @see https://www.iso.org/iso-3166-country-codes.html\n */\nexport enum CountryCode {\n AFG = \"AFG\", // Afghanistan\n ALB = \"ALB\", // Albania\n DZA = \"DZA\", // Algeria\n ASM = \"ASM\", // American Samoa\n AND = \"AND\", // Andorra\n AGO = \"AGO\", // Angola\n AIA = \"AIA\", // Anguilla\n ATA = \"ATA\", // Antarctica\n ATG = \"ATG\", // Antigua and Barbuda\n ARG = \"ARG\", // Argentina\n ARM = \"ARM\", // Armenia\n ABW = \"ABW\", // Aruba\n AUS = \"AUS\", // Australia\n AUT = \"AUT\", // Austria\n AZE = \"AZE\", // Azerbaijan\n BHS = \"BHS\", // Bahamas\n BHR = \"BHR\", // Bahrain\n BGD = \"BGD\", // Bangladesh\n BRB = \"BRB\", // Barbados\n BLR = \"BLR\", // Belarus\n BEL = \"BEL\", // Belgium\n BLZ = \"BLZ\", // Belize\n BEN = \"BEN\", // Benin\n BMU = \"BMU\", // Bermuda\n BTN = \"BTN\", // Bhutan\n BOL = \"BOL\", // Bolivia\n BES = \"BES\", // Bonaire, Sint Eustatius and Saba\n BIH = \"BIH\", // Bosnia and Herzegovina\n BWA = \"BWA\", // Botswana\n BVT = \"BVT\", // Bouvet Island\n BRA = \"BRA\", // Brazil\n IOT = \"IOT\", // British Indian Ocean Territory\n BRN = \"BRN\", // Brunei Darussalam\n BGR = \"BGR\", // Bulgaria\n BFA = \"BFA\", // Burkina Faso\n BDI = \"BDI\", // Burundi\n CPV = \"CPV\", // Cabo Verde\n KHM = \"KHM\", // Cambodia\n CMR = \"CMR\", // Cameroon\n CAN = \"CAN\", // Canada\n CYM = \"CYM\", // Cayman Islands\n CAF = \"CAF\", // Central African Republic\n TCD = \"TCD\", // Chad\n CHL = \"CHL\", // Chile\n CHN = \"CHN\", // China\n CXR = \"CXR\", // Christmas Island\n CCK = \"CCK\", // Cocos (Keeling) Islands\n COL = \"COL\", // Colombia\n COM = \"COM\", // Comoros\n COD = \"COD\", // Congo (Democratic Republic)\n COG = \"COG\", // Congo\n COK = \"COK\", // Cook Islands\n CRI = \"CRI\", // Costa Rica\n HRV = \"HRV\", // Croatia\n CUB = \"CUB\", // Cuba\n CUW = \"CUW\", // Curaçao\n CYP = \"CYP\", // Cyprus\n CZE = \"CZE\", // Czechia\n CIV = \"CIV\", // Côte d'Ivoire\n DNK = \"DNK\", // Denmark\n DJI = \"DJI\", // Djibouti\n DMA = \"DMA\", // Dominica\n DOM = \"DOM\", // Dominican Republic\n ECU = \"ECU\", // Ecuador\n EGY = \"EGY\", // Egypt\n SLV = \"SLV\", // El Salvador\n GNQ = \"GNQ\", // Equatorial Guinea\n ERI = \"ERI\", // Eritrea\n EST = \"EST\", // Estonia\n SWZ = \"SWZ\", // Eswatini\n ETH = \"ETH\", // Ethiopia\n FLK = \"FLK\", // Falkland Islands\n FRO = \"FRO\", // Faroe Islands\n FJI = \"FJI\", // Fiji\n FIN = \"FIN\", // Finland\n FRA = \"FRA\", // France\n GUF = \"GUF\", // French Guiana\n PYF = \"PYF\", // French Polynesia\n ATF = \"ATF\", // French Southern Territories\n GAB = \"GAB\", // Gabon\n GMB = \"GMB\", // Gambia\n GEO = \"GEO\", // Georgia\n DEU = \"DEU\", // Germany\n GHA = \"GHA\", // Ghana\n GIB = \"GIB\", // Gibraltar\n GRC = \"GRC\", // Greece\n GRL = \"GRL\", // Greenland\n GRD = \"GRD\", // Grenada\n GLP = \"GLP\", // Guadeloupe\n GUM = \"GUM\", // Guam\n GTM = \"GTM\", // Guatemala\n GGY = \"GGY\", // Guernsey\n GIN = \"GIN\", // Guinea\n GNB = \"GNB\", // Guinea-Bissau\n GUY = \"GUY\", // Guyana\n HTI = \"HTI\", // Haiti\n HMD = \"HMD\", // Heard Island and McDonald Islands\n VAT = \"VAT\", // Holy See\n HND = \"HND\", // Honduras\n HKG = \"HKG\", // Hong Kong\n HUN = \"HUN\", // Hungary\n ISL = \"ISL\", // Iceland\n IND = \"IND\", // India\n IDN = \"IDN\", // Indonesia\n IRN = \"IRN\", // Iran\n IRQ = \"IRQ\", // Iraq\n IRL = \"IRL\", // Ireland\n IMN = \"IMN\", // Isle of Man\n ISR = \"ISR\", // Israel\n ITA = \"ITA\", // Italy\n JAM = \"JAM\", // Jamaica\n JPN = \"JPN\", // Japan\n JEY = \"JEY\", // Jersey\n JOR = \"JOR\", // Jordan\n KAZ = \"KAZ\", // Kazakhstan\n KEN = \"KEN\", // Kenya\n KIR = \"KIR\", // Kiribati\n PRK = \"PRK\", // Korea (Democratic People's Republic)\n KOR = \"KOR\", // Korea (Republic)\n KWT = \"KWT\", // Kuwait\n KGZ = \"KGZ\", // Kyrgyzstan\n LAO = \"LAO\", // Lao People's Democratic Republic\n LVA = \"LVA\", // Latvia\n LBN = \"LBN\", // Lebanon\n LSO = \"LSO\", // Lesotho\n LBR = \"LBR\", // Liberia\n LBY = \"LBY\", // Libya\n LIE = \"LIE\", // Liechtenstein\n LTU = \"LTU\", // Lithuania\n LUX = \"LUX\", // Luxembourg\n MAC = \"MAC\", // Macao\n MDG = \"MDG\", // Madagascar\n MWI = \"MWI\", // Malawi\n MYS = \"MYS\", // Malaysia\n MDV = \"MDV\", // Maldives\n MLI = \"MLI\", // Mali\n MLT = \"MLT\", // Malta\n MHL = \"MHL\", // Marshall Islands\n MTQ = \"MTQ\", // Martinique\n MRT = \"MRT\", // Mauritania\n MUS = \"MUS\", // Mauritius\n MYT = \"MYT\", // Mayotte\n MEX = \"MEX\", // Mexico\n FSM = \"FSM\", // Micronesia\n MDA = \"MDA\", // Moldova\n MCO = \"MCO\", // Monaco\n MNG = \"MNG\", // Mongolia\n MNE = \"MNE\", // Montenegro\n MSR = \"MSR\", // Montserrat\n MAR = \"MAR\", // Morocco\n MOZ = \"MOZ\", // Mozambique\n MMR = \"MMR\", // Myanmar\n NAM = \"NAM\", // Namibia\n NRU = \"NRU\", // Nauru\n NPL = \"NPL\", // Nepal\n NLD = \"NLD\", // Netherlands\n NCL = \"NCL\", // New Caledonia\n NZL = \"NZL\", // New Zealand\n NIC = \"NIC\", // Nicaragua\n NER = \"NER\", // Niger\n NGA = \"NGA\", // Nigeria\n NIU = \"NIU\", // Niue\n NFK = \"NFK\", // Norfolk Island\n MKD = \"MKD\", // North Macedonia\n MNP = \"MNP\", // Northern Mariana Islands\n NOR = \"NOR\", // Norway\n OMN = \"OMN\", // Oman\n PAK = \"PAK\", // Pakistan\n PLW = \"PLW\", // Palau\n PSE = \"PSE\", // Palestine\n PAN = \"PAN\", // Panama\n PNG = \"PNG\", // Papua New Guinea\n PRY = \"PRY\", // Paraguay\n PER = \"PER\", // Peru\n PHL = \"PHL\", // Philippines\n PCN = \"PCN\", // Pitcairn\n POL = \"POL\", // Poland\n PRT = \"PRT\", // Portugal\n PRI = \"PRI\", // Puerto Rico\n QAT = \"QAT\", // Qatar\n ROU = \"ROU\", // Romania\n RUS = \"RUS\", // Russian Federation\n RWA = \"RWA\", // Rwanda\n REU = \"REU\", // Réunion\n BLM = \"BLM\", // Saint Barthélemy\n SHN = \"SHN\", // Saint Helena, Ascension and Tristan da Cunha\n KNA = \"KNA\", // Saint Kitts and Nevis\n LCA = \"LCA\", // Saint Lucia\n MAF = \"MAF\", // Saint Martin (French part)\n SPM = \"SPM\", // Saint Pierre and Miquelon\n VCT = \"VCT\", // Saint Vincent and the Grenadines\n WSM = \"WSM\", // Samoa\n SMR = \"SMR\", // San Marino\n STP = \"STP\", // Sao Tome and Principe\n SAU = \"SAU\", // Saudi Arabia\n SEN = \"SEN\", // Senegal\n SRB = \"SRB\", // Serbia\n SYC = \"SYC\", // Seychelles\n SLE = \"SLE\", // Sierra Leone\n SGP = \"SGP\", // Singapore\n SXM = \"SXM\", // Sint Maarten (Dutch part)\n SVK = \"SVK\", // Slovakia\n SVN = \"SVN\", // Slovenia\n SLB = \"SLB\", // Solomon Islands\n SOM = \"SOM\", // Somalia\n ZAF = \"ZAF\", // South Africa\n SGS = \"SGS\", // South Georgia and the South Sandwich Islands\n SSD = \"SSD\", // South Sudan\n ESP = \"ESP\", // Spain\n LKA = \"LKA\", // Sri Lanka\n SDN = \"SDN\", // Sudan\n SUR = \"SUR\", // Suriname\n SJM = \"SJM\", // Svalbard and Jan Mayen\n SWE = \"SWE\", // Sweden\n CHE = \"CHE\", // Switzerland\n SYR = \"SYR\", // Syrian Arab Republic\n TWN = \"TWN\", // Taiwan\n TJK = \"TJK\", // Tajikistan\n TZA = \"TZA\", // Tanzania\n THA = \"THA\", // Thailand\n TLS = \"TLS\", // Timor-Leste\n TGO = \"TGO\", // Togo\n TKL = \"TKL\", // Tokelau\n TON = \"TON\", // Tonga\n TTO = \"TTO\", // Trinidad and Tobago\n TUN = \"TUN\", // Tunisia\n TUR = \"TUR\", // Turkey\n TKM = \"TKM\", // Turkmenistan\n TCA = \"TCA\", // Turks and Caicos Islands\n TUV = \"TUV\", // Tuvalu\n UGA = \"UGA\", // Uganda\n UKR = \"UKR\", // Ukraine\n ARE = \"ARE\", // United Arab Emirates\n GBR = \"GBR\", // United Kingdom\n UMI = \"UMI\", // United States Minor Outlying Islands\n USA = \"USA\", // United States of America\n URY = \"URY\", // Uruguay\n UZB = \"UZB\", // Uzbekistan\n VUT = \"VUT\", // Vanuatu\n VEN = \"VEN\", // Venezuela\n VNM = \"VNM\", // Viet Nam\n VGB = \"VGB\", // Virgin Islands (British)\n VIR = \"VIR\", // Virgin Islands (U.S.)\n WLF = \"WLF\", // Wallis and Futuna\n ESH = \"ESH\", // Western Sahara\n YEM = \"YEM\", // Yemen\n ZMB = \"ZMB\", // Zambia\n ZWE = \"ZWE\", // Zimbabwe\n ALA = \"ALA\", // Åland Islands\n}\n\n// ============================================================\n// Currency Codes (ISO 4217)\n// ============================================================\n\n/**\n * ISO 4217 currency codes.\n *\n * @description\n * Three-letter currency codes following the ISO 4217 standard.\n * Use these codes for specifying order amounts and payment currencies.\n *\n * Common codes:\n * - `USD` - United States Dollar\n * - `EUR` - Euro\n * - `JPY` - Japanese Yen\n * - `GBP` - Pound Sterling\n * - `CNY` - Chinese Yuan\n *\n * Note: Currency codes determine the decimal precision for amounts.\n * For example, JPY has no decimal places, while USD has 2.\n *\n * @example\n * // Create an order with Japanese Yen\n * const orderParams = {\n * orderAmount: '1000', // 1000 JPY (no decimals)\n * orderCurrency: CurrencyCode.JPY,\n * };\n *\n * @example\n * // Create an order with US Dollars\n * const orderParams = {\n * orderAmount: '19.99', // $19.99\n * orderCurrency: CurrencyCode.USD,\n * };\n *\n * @example\n * // Validate supported currencies\n * function isSupportedCurrency(code: string): code is CurrencyCode {\n * return Object.values(CurrencyCode).includes(code as CurrencyCode);\n * }\n *\n * @enum {string}\n * @readonly\n * @see https://www.iso.org/iso-4217-currency-codes.html\n */\nexport enum CurrencyCode {\n AED = \"AED\", // United Arab Emirates Dirham\n AFN = \"AFN\", // Afghan Afghani\n ALL = \"ALL\", // Albanian Lek\n AMD = \"AMD\", // Armenian Dram\n ANG = \"ANG\", // Netherlands Antillean Guilder\n AOA = \"AOA\", // Angolan Kwanza\n ARS = \"ARS\", // Argentine Peso\n AUD = \"AUD\", // Australian Dollar\n AWG = \"AWG\", // Aruban Florin\n AZN = \"AZN\", // Azerbaijani Manat\n BAM = \"BAM\", // Bosnia and Herzegovina Convertible Mark\n BBD = \"BBD\", // Barbados Dollar\n BDT = \"BDT\", // Bangladeshi Taka\n BGN = \"BGN\", // Bulgarian Lev\n BHD = \"BHD\", // Bahraini Dinar\n BIF = \"BIF\", // Burundian Franc\n BMD = \"BMD\", // Bermudian Dollar\n BND = \"BND\", // Brunei Dollar\n BOB = \"BOB\", // Boliviano\n BOV = \"BOV\", // Bolivian Mvdol\n BRL = \"BRL\", // Brazilian Real\n BSD = \"BSD\", // Bahamian Dollar\n BTN = \"BTN\", // Bhutanese Ngultrum\n BWP = \"BWP\", // Botswana Pula\n BYN = \"BYN\", // Belarusian Ruble\n BZD = \"BZD\", // Belize Dollar\n CAD = \"CAD\", // Canadian Dollar\n CDF = \"CDF\", // Congolese Franc\n CHE = \"CHE\", // WIR Euro\n CHF = \"CHF\", // Swiss Franc\n CHW = \"CHW\", // WIR Franc\n CLF = \"CLF\", // Unidad de Fomento\n CLP = \"CLP\", // Chilean Peso\n CNY = \"CNY\", // Chinese Yuan\n COP = \"COP\", // Colombian Peso\n COU = \"COU\", // Unidad de Valor Real\n CRC = \"CRC\", // Costa Rican Colon\n CUC = \"CUC\", // Cuban Convertible Peso\n CUP = \"CUP\", // Cuban Peso\n CVE = \"CVE\", // Cape Verdean Escudo\n CZK = \"CZK\", // Czech Koruna\n DJF = \"DJF\", // Djiboutian Franc\n DKK = \"DKK\", // Danish Krone\n DOP = \"DOP\", // Dominican Peso\n DZD = \"DZD\", // Algerian Dinar\n EGP = \"EGP\", // Egyptian Pound\n ERN = \"ERN\", // Eritrean Nakfa\n ETB = \"ETB\", // Ethiopian Birr\n EUR = \"EUR\", // Euro\n FJD = \"FJD\", // Fiji Dollar\n FKP = \"FKP\", // Falkland Islands Pound\n GBP = \"GBP\", // Pound Sterling\n GEL = \"GEL\", // Georgian Lari\n GHS = \"GHS\", // Ghanaian Cedi\n GIP = \"GIP\", // Gibraltar Pound\n GMD = \"GMD\", // Gambian Dalasi\n GNF = \"GNF\", // Guinean Franc\n GTQ = \"GTQ\", // Guatemalan Quetzal\n GYD = \"GYD\", // Guyanese Dollar\n HKD = \"HKD\", // Hong Kong Dollar\n HNL = \"HNL\", // Honduran Lempira\n HRK = \"HRK\", // Croatian Kuna\n HTG = \"HTG\", // Haitian Gourde\n HUF = \"HUF\", // Hungarian Forint\n IDR = \"IDR\", // Indonesian Rupiah\n ILS = \"ILS\", // Israeli New Shekel\n INR = \"INR\", // Indian Rupee\n IQD = \"IQD\", // Iraqi Dinar\n IRR = \"IRR\", // Iranian Rial\n ISK = \"ISK\", // Icelandic Króna\n JMD = \"JMD\", // Jamaican Dollar\n JOD = \"JOD\", // Jordanian Dinar\n JPY = \"JPY\", // Japanese Yen\n KES = \"KES\", // Kenyan Shilling\n KGS = \"KGS\", // Kyrgyzstani Som\n KHR = \"KHR\", // Cambodian Riel\n KMF = \"KMF\", // Comoro Franc\n KPW = \"KPW\", // North Korean Won\n KRW = \"KRW\", // South Korean Won\n KWD = \"KWD\", // Kuwaiti Dinar\n KYD = \"KYD\", // Cayman Islands Dollar\n KZT = \"KZT\", // Kazakhstani Tenge\n LAK = \"LAK\", // Lao Kip\n LBP = \"LBP\", // Lebanese Pound\n LKR = \"LKR\", // Sri Lankan Rupee\n LRD = \"LRD\", // Liberian Dollar\n LSL = \"LSL\", // Lesotho Loti\n LYD = \"LYD\", // Libyan Dinar\n MAD = \"MAD\", // Moroccan Dirham\n MDL = \"MDL\", // Moldovan Leu\n MGA = \"MGA\", // Malagasy Ariary\n MKD = \"MKD\", // Macedonian Denar\n MMK = \"MMK\", // Myanmar Kyat\n MNT = \"MNT\", // Mongolian Tögrög\n MOP = \"MOP\", // Macanese Pataca\n MRU = \"MRU\", // Mauritanian Ouguiya\n MUR = \"MUR\", // Mauritian Rupee\n MVR = \"MVR\", // Maldivian Rufiyaa\n MWK = \"MWK\", // Malawian Kwacha\n MXN = \"MXN\", // Mexican Peso\n MXV = \"MXV\", // Mexican Unidad de Inversion\n MYR = \"MYR\", // Malaysian Ringgit\n MZN = \"MZN\", // Mozambican Metical\n NAD = \"NAD\", // Namibian Dollar\n NGN = \"NGN\", // Nigerian Naira\n NIO = \"NIO\", // Nicaraguan Córdoba\n NOK = \"NOK\", // Norwegian Krone\n NPR = \"NPR\", // Nepalese Rupee\n NZD = \"NZD\", // New Zealand Dollar\n OMR = \"OMR\", // Omani Rial\n PAB = \"PAB\", // Panamanian Balboa\n PEN = \"PEN\", // Peruvian Sol\n PGK = \"PGK\", // Papua New Guinean Kina\n PHP = \"PHP\", // Philippine Peso\n PKR = \"PKR\", // Pakistani Rupee\n PLN = \"PLN\", // Polish Zloty\n PYG = \"PYG\", // Paraguayan Guarani\n QAR = \"QAR\", // Qatari Riyal\n RON = \"RON\", // Romanian Leu\n RSD = \"RSD\", // Serbian Dinar\n RUB = \"RUB\", // Russian Ruble\n RWF = \"RWF\", // Rwandan Franc\n SAR = \"SAR\", // Saudi Riyal\n SBD = \"SBD\", // Solomon Islands Dollar\n SCR = \"SCR\", // Seychelles Rupee\n SDG = \"SDG\", // Sudanese Pound\n SEK = \"SEK\", // Swedish Krona\n SGD = \"SGD\", // Singapore Dollar\n SHP = \"SHP\", // Saint Helena Pound\n SLE = \"SLE\", // Sierra Leonean Leone\n SLL = \"SLL\", // Sierra Leonean Leone (old)\n SOS = \"SOS\", // Somali Shilling\n SRD = \"SRD\", // Surinamese Dollar\n SSP = \"SSP\", // South Sudanese Pound\n STN = \"STN\", // São Tomé and Príncipe Dobra\n SVC = \"SVC\", // Salvadoran Colón\n SYP = \"SYP\", // Syrian Pound\n SZL = \"SZL\", // Swazi Lilangeni\n THB = \"THB\", // Thai Baht\n TJS = \"TJS\", // Tajikistani Somoni\n TMT = \"TMT\", // Turkmenistan Manat\n TND = \"TND\", // Tunisian Dinar\n TOP = \"TOP\", // Tongan Paʻanga\n TRY = \"TRY\", // Turkish Lira\n TTD = \"TTD\", // Trinidad and Tobago Dollar\n TWD = \"TWD\", // New Taiwan Dollar\n TZS = \"TZS\", // Tanzanian Shilling\n UAH = \"UAH\", // Ukrainian Hryvnia\n UGX = \"UGX\", // Ugandan Shilling\n USD = \"USD\", // United States Dollar\n USN = \"USN\", // United States Dollar (Next day)\n UYI = \"UYI\", // Uruguay Peso en Unidades Indexadas\n UYU = \"UYU\", // Uruguayan Peso\n UYW = \"UYW\", // Unidad Previsional\n UZS = \"UZS\", // Uzbekistan Som\n VED = \"VED\", // Venezuelan Digital Bolívar\n VES = \"VES\", // Venezuelan Sovereign Bolívar\n VND = \"VND\", // Vietnamese Đồng\n VUV = \"VUV\", // Vanuatu Vatu\n WST = \"WST\", // Samoan Tala\n XAF = \"XAF\", // CFA Franc BEAC\n XAG = \"XAG\", // Silver (one troy ounce)\n XAU = \"XAU\", // Gold (one troy ounce)\n XBA = \"XBA\", // European Composite Unit\n XBB = \"XBB\", // European Monetary Unit\n XBC = \"XBC\", // European Unit of Account 9\n XBD = \"XBD\", // European Unit of Account 17\n XCD = \"XCD\", // East Caribbean Dollar\n XDR = \"XDR\", // Special Drawing Rights\n XOF = \"XOF\", // CFA Franc BCEAO\n XPD = \"XPD\", // Palladium (one troy ounce)\n XPF = \"XPF\", // CFP Franc\n XPT = \"XPT\", // Platinum (one troy ounce)\n XSU = \"XSU\", // Sucre\n XTS = \"XTS\", // Code reserved for testing\n XUA = \"XUA\", // ADB Unit of Account\n XXX = \"XXX\", // No currency\n YER = \"YER\", // Yemeni Rial\n ZAR = \"ZAR\", // South African Rand\n ZMW = \"ZMW\", // Zambian Kwacha\n ZWL = \"ZWL\", // Zimbabwean Dollar\n}\n","/**\n * @fileoverview Payment Related Enumeration Definitions\n * @module types/payment\n *\n * Payment-related enumerations shared across Order, Subscription, and Config resources:\n * - **{@link ProductName}** - Payment product types for acquiring API\n * - **{@link SubscriptionProductName}** - Product types for subscription API\n *\n * @see {@link PaymentInfo} for payment configuration\n * @see {@link CreateOrderParams} for order creation\n *\n * @example\n * import { ProductName } from 'waffo-sdk';\n *\n * const paymentInfo = {\n * productName: ProductName.ONE_TIME_PAYMENT,\n * payMethodName: 'DANA',\n * };\n */\n\n// ============================================================\n// Product Name Enums\n// ============================================================\n\n/**\n * Payment product type for acquiring API.\n *\n * @enum {string}\n * @readonly\n *\n * @example\n * paymentInfo: {\n * productName: ProductName.ONE_TIME_PAYMENT,\n * payMethodName: 'DANA',\n * }\n */\nexport enum ProductName {\n /** Standard payment with redirect flow */\n ONE_TIME_PAYMENT = \"ONE_TIME_PAYMENT\",\n /** Payment within mini program environment */\n MINI_PROGRAM_PAYMENT = \"MINI_PROGRAM_PAYMENT\",\n /** Card payment (requires PCI-DSS compliance) */\n DIRECT_PAYMENT = \"DIRECT_PAYMENT\",\n}\n\n/**\n * Payment product type for subscription API.\n *\n * @enum {string}\n * @readonly\n *\n * @example\n * paymentInfo: {\n * productName: SubscriptionProductName.SUBSCRIPTION,\n * payMethodName: 'ALIPAY_HK',\n * }\n */\nexport enum SubscriptionProductName {\n /** Web-based subscription signing */\n SUBSCRIPTION = \"SUBSCRIPTION\",\n /** Subscription within mini program */\n MINI_PROGRAM_SUBSCRIPTION = \"MINI_PROGRAM_SUBSCRIPTION\",\n}\n\n// ============================================================\n// Payment Method Type Constants (Reference)\n// ============================================================\n\n/**\n * Common payment method type values.\n *\n * These are example values for `payMethodType` field (string type).\n * Note: This list may be updated. Please refer to the latest API documentation.\n *\n * Example values:\n * - `\"EWALLET\"` - E-wallet payments (OVO, DANA, GoPay, etc.)\n * - `\"CREDITCARD\"` - Credit/Debit card payments\n * - `\"BANKTRANSFER\"` - Bank transfer / Virtual Account\n * - `\"ONLINE_BANKING\"` - Online banking payments\n * - `\"DIGITAL_BANKING\"` - Digital banking payments\n * - `\"OTC\"` - Over-the-counter payments\n * - `\"DEBITCARD\"` - Debit card payments\n *\n * @example\n * paymentInfo: {\n * payMethodType: 'EWALLET',\n * payMethodName: 'DANA',\n * }\n */\n\n/**\n * Common payment method name values.\n *\n * These are example values for `payMethodName` field (string type).\n * Note: This list may be updated. Please refer to the latest API documentation.\n *\n * Example E-wallets:\n * - `\"OVO\"` - OVO e-wallet (Indonesia)\n * - `\"DANA\"` - DANA e-wallet (Indonesia)\n * - `\"GOPAY\"` - GoPay e-wallet (Indonesia)\n * - `\"SHOPEEPAY\"` - ShopeePay e-wallet (Indonesia)\n * - `\"GCASH\"` - GCash e-wallet (Philippines)\n * - `\"ALIPAY_HK\"` - Alipay Hong Kong\n *\n * Example Credit Cards:\n * - `\"CC_VISA\"` - Visa credit card\n * - `\"CC_MASTERCARD\"` - Mastercard credit card\n *\n * Example Bank Transfer / Virtual Account:\n * - `\"VA_BCA\"` - BCA Virtual Account (Indonesia)\n * - `\"VA_BNI\"` - BNI Virtual Account (Indonesia)\n *\n * @example\n * paymentInfo: {\n * productName: ProductName.ONE_TIME_PAYMENT,\n * payMethodName: 'DANA',\n * }\n */\n","/**\n * @fileoverview Order Resource Type Definitions\n * @module types/order\n *\n * Type definitions for the Order resource (based on Waffo API JSON Schema).\n *\n * **Categories:**\n * - **Enums:** Order status, action types, payment modes\n * - **Request Interfaces:** Parameters for create, inquiry, cancel, refund, capture\n * - **Response Interfaces:** API response data structures\n * - **Webhook Interfaces:** Payment notification structures\n *\n * @see {@link OrderResource} for API methods\n * @see {@link CreateOrderParams} for order creation\n *\n * @example\n * import {\n * CreateOrderParams,\n * OrderStatus,\n * ProductName,\n * UserTerminalType,\n * } from 'waffo-sdk';\n *\n * const params: CreateOrderParams = {\n * paymentRequestId: 'req-123',\n * merchantOrderId: 'order-456',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * // ...\n * };\n */\n\nimport { WebhookEventType, WebhookRequestHeader } from \"./webhook\";\nimport { ProductName } from \"./payment\";\nimport { RiskUserType, RefundUserType } from \"./common\";\n\n// Re-export common types for convenience\nexport { RiskUserType, RefundUserType };\n\n// Re-export common types for convenience\nexport { ProductName };\n\n// ============================================================\n// Enums\n// ============================================================\n\n/**\n * User Terminal Type Enum\n *\n * @description\n * Identifies the terminal environment where the user initiates payment.\n *\n * @enum {string}\n * @readonly\n */\nexport enum UserTerminalType {\n // Web browser\n WEB = \"WEB\",\n // Native app\n APP = \"APP\",\n // Embedded page within wallet app (e.g., inside DANA App)\n IN_WALLET_APP = \"IN_WALLET_APP\",\n // Mini program environment\n IN_MINI_PROGRAM = \"IN_MINI_PROGRAM\",\n}\n\n/**\n * Order Status Enum\n *\n * @description\n * Identifies the current status of an order in the payment process.\n *\n * @enum {string}\n * @readonly\n */\nexport enum OrderStatus {\n // Payment in progress - Order created, waiting for payment channel processing\n PAY_IN_PROGRESS = \"PAY_IN_PROGRESS\",\n // Authorization required - User needs to be redirected to payment page for authorization\n AUTHORIZATION_REQUIRED = \"AUTHORIZATION_REQUIRED\",\n // Authorized waiting capture - In manualCapture mode, user authorized, waiting for merchant to call capture API\n AUTHED_WAITING_CAPTURE = \"AUTHED_WAITING_CAPTURE\",\n // Payment successful - Order payment completed\n PAY_SUCCESS = \"PAY_SUCCESS\",\n // Order closed - Order cancelled or expired\n ORDER_CLOSE = \"ORDER_CLOSE\",\n // Capture in progress - Executing fund capture\n CAPTURE_IN_PROGRESS = \"CAPTURE_IN_PROGRESS\",\n}\n\n/**\n * Order Action Type Enum\n *\n * @description\n * Indicates the redirect method for user to complete payment authorization.\n *\n * @enum {string}\n * @readonly\n */\nexport enum OrderActionType {\n // Web redirect - Use webUrl to open payment page in browser\n WEB = \"WEB\",\n // Deeplink redirect - Use deeplinkUrl to launch wallet app\n DEEPLINK = \"DEEPLINK\",\n}\n\n/**\n * Pay Method User Account Type Enum\n *\n * @description\n * User account type at the designated pay method.\n *\n * @enum {string}\n * @readonly\n */\nexport enum PayMethodUserAccountType {\n // Email account\n EMAIL = \"EMAIL\",\n // Phone number account\n PHONE_NO = \"PHONE_NO\",\n // Account ID\n ACCOUNT_ID = \"ACCOUNT_ID\",\n}\n\n/**\n * Capture Mode Enum\n *\n * @description\n * Capture mode for order payment.\n *\n * @enum {string}\n * @readonly\n */\nexport enum CaptureMode {\n // Manual capture - authorize first then capture later\n MANUAL_CAPTURE = \"manualCapture\",\n}\n\n/**\n * Merchant Initiated Mode Enum\n *\n * @description\n * MIT mode for merchant initiated transactions.\n *\n * @enum {string}\n * @readonly\n */\nexport enum MerchantInitiatedMode {\n // Scheduled MIT\n SCHEDULED = \"scheduled\",\n // Unscheduled MIT\n UNSCHEDULED = \"unscheduled\",\n}\n\n/**\n * 3DS Decision Enum\n *\n * @description\n * Merchant 3DS decision for card payments.\n *\n * @enum {string}\n * @readonly\n */\nexport enum ThreeDsDecision {\n // Force 3DS authentication\n FORCE = \"3DS_FORCE\",\n // Attempt 3DS authentication\n ATTEMPT = \"3DS_ATTEMPT\",\n // No 3DS authentication\n NO_3DS = \"NO_3DS\",\n}\n\n// ============================================================\n// Request Interfaces\n// ============================================================\n\n/**\n * Merchant Information Interface (Request Parameters)\n *\n * @description\n * Used to identify the merchant initiating the request.\n *\n * @interface MerchantInfo\n */\nexport interface MerchantInfo {\n // Merchant ID assigned by Waffo (max 64 characters)\n merchantId: string;\n // Sub-merchant ID assigned by Waffo (max 64 characters)\n subMerchantId?: string;\n}\n\n/**\n * User Information Interface (Request Parameters)\n *\n * @description\n * Basic information of the paying user, used for risk control and user identification.\n *\n * @interface UserInfo\n */\nexport interface UserInfo {\n // Unique user identifier in merchant's system (max 64 characters)\n userId: string;\n // User email address (max 64 characters)\n userEmail: string;\n // User phone number, format: +country code-number (max 16 characters)\n userPhone?: string;\n // Country code of the source of the user request\n userCountryCode?: string;\n // User terminal type: WEB, APP, IN_WALLET_APP, IN_MINI_PROGRAM\n userTerminal: UserTerminalType | string;\n // User first name (max 64 characters)\n userFirstName?: string;\n // User last name (max 64 characters)\n userLastName?: string;\n // User created time (ISO 8601 format, max 24 characters)\n userCreatedAt?: string;\n // User browser IP address (max 128 characters, required for direct card payment)\n userBrowserIp?: string;\n // User browser User-Agent (max 256 characters, required for direct card payment)\n userAgent?: string;\n}\n\n/**\n * Goods Information Interface (Request Parameters)\n *\n * @description\n * Product or service information associated with the order.\n *\n * @interface GoodsInfo\n */\nexport interface GoodsInfo {\n // Product ID in merchant's system (max 32 characters)\n goodsId?: string;\n // Product name, will be displayed on payment page (max 64 characters)\n goodsName: string;\n // Product category (max 32 characters)\n goodsCategory?: string;\n // Product detail page URL (max 128 characters, either this or appName is required)\n goodsUrl?: string;\n // App package name, applicable for virtual goods (max 32 characters, either this or goodsUrl is required)\n appName?: string;\n // SKU name (max 32 characters)\n skuName?: string;\n // Product unique price (max 16 characters)\n goodsUniquePrice?: string;\n // Product quantity\n goodsQuantity?: number | string;\n}\n\n/**\n * Address Information Interface (Request Parameters)\n *\n * @description\n * Shipping address information for the order, used for risk control and logistics.\n *\n * @interface AddressInfo\n */\nexport interface AddressInfo {\n // Detailed shipping address (max 256 characters)\n address?: string;\n // City (max 32 characters)\n city?: string;\n // Region/Province/State (max 32 characters)\n region?: string;\n // Postal code (max 16 characters)\n postcode?: string;\n // Shipping country code (max 16 characters)\n addressCountryCode?: string;\n}\n\n/**\n * Payment Method Properties Interface (Request Parameters)\n *\n * @description\n * Additional properties required for specific payment methods.\n *\n * @interface PayMethodProperties\n */\nexport interface PayMethodProperties {\n // Brazilian tax ID (CPF), required for Brazilian payment methods\n cpf?: string;\n // Card number prefix restriction, used to specify available card BIN range\n cardPrefix?: string;\n // Card prefix purpose\n cardPrefixPurpose?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Cashier Appearance Interface (Request Parameters)\n *\n * @description\n * Cashier UI appearance variables.\n *\n * @interface CashierAppearance\n */\nexport interface CashierAppearance {\n // Appearance variables\n variables?: {\n // Primary color\n colorPrimary?: string;\n // Background color\n colorBackground?: string;\n // Text color\n colorText?: string;\n [key: string]: string | undefined;\n };\n}\n\n/**\n * Card Information Interface (Request Parameters)\n *\n * @description\n * Card information for direct card payment, only applicable for PCI-DSS certified merchants.\n *\n * @interface CardInfo\n * @warning This interface involves sensitive card data, ensure PCI-DSS compliance\n */\nexport interface CardInfo {\n // Card number (max 24 characters)\n cardNumber: string;\n // Card expiry year, 4 digits (max 4 characters, e.g., \"2025\")\n cardExpiryYear: string;\n // Card expiry month, 2 digits (max 2 characters, e.g., \"10\")\n cardExpiryMonth: string;\n // Card CVV (max 4 characters)\n cardCvv: string;\n // Card holder name (max 128 characters)\n cardHolderName: string;\n // 3DS decision indicator: 3DS_FORCE, 3DS_ATTEMPT, NO_3DS\n threeDsDecision?: ThreeDsDecision | string;\n}\n\n/**\n * Payment Information Interface (Request Parameters)\n *\n * @description\n * Specify payment product, method, and mode.\n *\n * @interface PaymentInfo\n */\nexport interface PaymentInfo {\n // Payment product name: ONE_TIME_PAYMENT, MINI_PROGRAM_PAYMENT, DIRECT_PAYMENT\n productName: ProductName | string;\n /**\n * Payment type (max 256 characters)\n * Example values: \"EWALLET\", \"CREDITCARD\", \"BANKTRANSFER\", \"ONLINE_BANKING\", \"DIGITAL_BANKING\", \"OTC\", \"DEBITCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodType?: string;\n /**\n * Specific payment method (max 24 characters)\n * Example E-wallets: \"OVO\", \"DANA\", \"GOPAY\", \"SHOPEEPAY\", \"GCASH\", \"ALIPAY_HK\"\n * Example Credit Cards: \"CC_VISA\", \"CC_MASTERCARD\"\n * Example Bank Transfer: \"VA_BCA\", \"VA_BNI\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodName?: string;\n // Payment method country (ISO 3166-1 alpha-3)\n payMethodCountry?: string;\n // Payment method specific properties\n payMethodProperties?: PayMethodProperties | string;\n // User account type at pay method: EMAIL, PHONE_NO, ACCOUNT_ID\n payMethodUserAccountType?: PayMethodUserAccountType | string;\n // User account number at pay method (max 64 characters)\n payMethodUserAccountNo?: string;\n // Cashier language (IETF BCP 47 language tag, max 24 characters)\n cashierLanguage?: string;\n // Cashier UI appearance variables\n cashierAppearance?: CashierAppearance;\n // User payment access token from Waffo tokenization service (max 256 characters)\n userPaymentAccessToken?: string;\n // Capture mode: manualCapture\n captureMode?: CaptureMode | string;\n // MIT mode: scheduled, unscheduled\n merchantInitiatedMode?: MerchantInitiatedMode | string;\n}\n\n/**\n * Risk Data Interface (Request Parameters)\n *\n * @description\n * Auxiliary data for risk assessment.\n *\n * @interface RiskData\n */\nexport interface RiskData {\n // User type: Individual/Agent/Institution/Internal (max 24 characters)\n userType?: RiskUserType;\n // User category: Member/Non-Member (max 24 characters)\n userCategory?: string;\n // User legal name (max 128 characters)\n userLegalName?: string;\n // User display name (max 128 characters)\n userDisplayName?: string;\n // User registration IP (max 24 characters)\n userRegistrationIp?: string;\n // User last seen IP (max 24 characters)\n userLastSeenIp?: string;\n // Whether user is new: Yes/No (max 8 characters)\n userIsNew?: string;\n // Whether this is user's first purchase: Yes/No (max 8 characters)\n userIsFirstPurchase?: string;\n}\n\n/**\n * User Bank Information Interface (Request Parameters)\n *\n * @description\n * Bank account information for bank transfer and similar payment method refunds.\n *\n * @interface UserBankInfo\n */\nexport interface UserBankInfo {\n // Bank account number (max 64 characters)\n bankAccountNo: string;\n // Bank code (max 64 characters)\n bankCode: string;\n // Bank city (max 64 characters)\n bankCity?: string;\n // Bank branch name (max 64 characters)\n bankBranch?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Refund User Information Interface (Request Parameters)\n *\n * @description\n * User information required for refunds with specific payment methods.\n *\n * @interface RefundUserInfo\n */\nexport interface RefundUserInfo {\n // User type: INDIVIDUAL or BUSINESS\n userType?: RefundUserType;\n // User first name (max 64 characters)\n userFirstName?: string;\n // User last name (max 64 characters)\n userLastName?: string;\n // User email for refund communication (max 64 characters)\n userEmail?: string;\n // User bank account information\n userBankInfo?: UserBankInfo | string;\n // User phone number (max 16 characters)\n userPhone?: string;\n // User ID type (max 24 characters)\n userIDType?: string;\n // User ID number (max 64 characters)\n userIDNumber?: string;\n // User ID issue date (dd/mm/yyyy, max 12 characters)\n userIDIssueDate?: string;\n // User ID expiry date (dd/mm/yyyy, max 12 characters)\n userIDExpiryDate?: string;\n}\n\n/**\n * Create Order Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.order.create()`.\n *\n * @interface CreateOrderParams\n */\nexport interface CreateOrderParams {\n // Unique request ID generated by merchant for idempotency check (max 32 characters)\n paymentRequestId: string;\n // Merchant system order ID (max 64 characters)\n merchantOrderId: string;\n // Order currency code (ISO 4217)\n orderCurrency: string;\n // Order amount (string format)\n orderAmount: string;\n // Order description (max 128 characters)\n orderDescription: string;\n // User payment currency code (ISO 4217)\n userCurrency?: string;\n // Merchant information\n merchantInfo: MerchantInfo;\n // User information\n userInfo: UserInfo;\n // Goods information\n goodsInfo: GoodsInfo;\n // Shipping address information\n addressInfo?: AddressInfo;\n // Payment method information\n paymentInfo: PaymentInfo;\n // Card information for direct card payment\n cardInfo?: CardInfo;\n // ApplePay/GooglePay payment token data (max 8192 characters)\n PaymentTokenData?: string;\n // Request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n orderRequestedAt?: string;\n // Order expiry time (ISO 8601 format, max 24 characters)\n orderExpiredAt?: string;\n // Redirect URL after successful payment (max 512 characters)\n successRedirectUrl?: string;\n // Redirect URL after failed payment (max 512 characters)\n failedRedirectUrl?: string;\n // Redirect URL if user cancels payment (max 512 characters)\n cancelRedirectUrl?: string;\n // Async notification callback URL for payment result (max 256 characters)\n notifyUrl: string;\n // Risk control auxiliary data\n riskData?: RiskData;\n // Reserved extend info (max 128 characters or object)\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Inquiry Order Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.order.inquiry()`.\n *\n * @interface InquiryOrderParams\n */\nexport interface InquiryOrderParams {\n // Merchant original request ID (max 32 characters)\n paymentRequestId?: string;\n // Acquiring order ID generated by Waffo (max 32 characters)\n acquiringOrderId?: string;\n}\n\n/**\n * Cancel Order Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.order.cancel()`.\n *\n * @interface CancelOrderParams\n */\nexport interface CancelOrderParams {\n // Merchant original request ID (max 32 characters)\n paymentRequestId?: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId?: string;\n // Merchant ID (max 64 characters)\n merchantId: string;\n // Cancel request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n orderRequestedAt?: string;\n}\n\n/**\n * Order Refund Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.order.refund()`.\n *\n * @interface RefundOrderParams\n */\nexport interface RefundOrderParams {\n // Refund request ID generated by merchant (max 32 characters)\n refundRequestId: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Merchant refund order ID (max 64 characters)\n merchantRefundOrderId?: string;\n // Merchant ID (max 64 characters)\n merchantId: string;\n // Refund request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n requestedAt?: string;\n // Refund amount\n refundAmount: string;\n // Refund reason (max 24 characters)\n refundReason: string;\n // Refund notify callback URL (max 256 characters)\n refundNotifyUrl?: string;\n // Refund user information\n userInfo?: RefundUserInfo;\n // Reserved extend info (max 128 characters or object)\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Capture Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.order.capture()`.\n *\n * @interface CaptureOrderParams\n */\nexport interface CaptureOrderParams {\n // Merchant original request ID (max 32 characters)\n paymentRequestId?: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId?: string;\n // Merchant ID (max 64 characters)\n merchantId: string;\n // Capture request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n captureRequestedAt?: string;\n // Capture amount (partial or full)\n captureAmount: string;\n}\n\n// ============================================================\n// Response Interfaces\n// ============================================================\n\n/**\n * Order Action Data Interface (Response)\n *\n * @description\n * Payment data for merchant's custom checkout page.\n *\n * @interface OrderActionData\n */\nexport interface OrderActionData {\n // Payment expiry time (ISO 8601 format with millisecond precision)\n paymentExpiryTime?: string;\n // QR code content string (max 2048 characters)\n paymentQr?: string;\n // Payment code (max 256 characters)\n paymentCode?: string;\n // Barcode content string (max 512 characters)\n paymentBarCode?: string;\n // User payment currency\n paymentCurrency?: string;\n // User payment amount\n paymentAmount?: string;\n // User service fee amount\n userFeeAmount?: string;\n // User service fee currency\n userFeeCurrency?: string;\n // Exchange rate (max 64 characters)\n exchangeRate?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Order Action Interface (Response)\n *\n * @description\n * Returned when order status is AUTHORIZATION_REQUIRED.\n *\n * @interface OrderAction\n */\nexport interface OrderAction {\n // Action type: WEB or DEEPLINK\n actionType: OrderActionType | string;\n // Web payment page URL (max 1024 characters)\n webUrl?: string;\n // Deeplink URL (max 1024 characters)\n deeplinkUrl?: string;\n // Payment data for custom checkout page\n actionData?: OrderActionData;\n}\n\n/**\n * Merchant Information Interface (Response)\n *\n * @description\n * Merchant information associated with the order.\n *\n * @interface MerchantInfoResponse\n */\nexport interface MerchantInfoResponse {\n // Merchant ID (max 64 characters)\n merchantId: string;\n // Sub-merchant ID (max 64 characters)\n subMerchantId?: string;\n}\n\n/**\n * User Information Interface (Response)\n *\n * @description\n * User information associated with the order.\n *\n * @interface UserInfoResponse\n */\nexport interface UserInfoResponse {\n // User ID (max 64 characters)\n userId: string;\n // User email (max 64 characters)\n userEmail: string;\n // User phone (max 16 characters)\n userPhone?: string;\n // User country code\n userCountryCode?: string;\n // User terminal type\n userTerminal: UserTerminalType | string;\n // User first name (max 64 characters)\n userFirstName?: string;\n // User last name (max 64 characters)\n userLastName?: string;\n // User created time (max 24 characters)\n userCreatedAt?: string;\n // User browser IP (max 128 characters)\n userBrowserIp?: string;\n // User agent (max 256 characters)\n userAgent?: string;\n}\n\n/**\n * Goods Information Interface (Response)\n *\n * @description\n * Product information associated with the order.\n *\n * @interface GoodsInfoResponse\n */\nexport interface GoodsInfoResponse {\n // Product ID (max 32 characters)\n goodsId?: string;\n // Product name (max 64 characters)\n goodsName: string;\n // Product category (max 32 characters)\n goodsCategory?: string;\n // Product detail page URL (max 128 characters)\n goodsUrl?: string;\n // App package name (max 32 characters)\n appName?: string;\n // SKU name (max 32 characters)\n skuName?: string;\n // Product unique price (max 16 characters)\n goodsUniquePrice?: string;\n // Product quantity\n goodsQuantity?: number | string;\n}\n\n/**\n * Address Information Interface (Response)\n *\n * @description\n * Address information associated with the order.\n *\n * @interface AddressInfoResponse\n */\nexport interface AddressInfoResponse {\n // Detailed shipping address (max 256 characters)\n address?: string;\n // City (max 32 characters)\n city?: string;\n // Region/Province/State (max 32 characters)\n region?: string;\n // Postal code (max 16 characters)\n postcode?: string;\n // Shipping country code (max 16 characters)\n addressCountryCode?: string;\n}\n\n/**\n * Payment Method Response Data Interface (Response)\n *\n * @description\n * Specific data returned by payment channel.\n *\n * @interface PayMethodResponse\n */\nexport interface PayMethodResponse {\n // Transaction reference ID from payment channel (max 128 characters)\n payMethodRefId?: string;\n // Exchange rate (max 64 characters)\n exchangeRate?: string;\n // Unique user open ID assigned by pay method (max 128 characters)\n userOpenId?: string;\n // Masked card data (first 6 and last 4, max 32 characters)\n maskCardData?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Payment Information Interface (Response)\n *\n * @description\n * Payment method details for the order.\n *\n * @interface PaymentInfoResponse\n */\nexport interface PaymentInfoResponse {\n // Payment product name\n productName: ProductName | string;\n /**\n * Payment type (max 256 characters)\n * Example values: \"EWALLET\", \"CREDITCARD\", \"BANKTRANSFER\", \"ONLINE_BANKING\", \"DIGITAL_BANKING\", \"OTC\", \"DEBITCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodType: string;\n /**\n * Specific payment method (max 24 characters)\n * Example E-wallets: \"OVO\", \"DANA\", \"GOPAY\", \"SHOPEEPAY\", \"GCASH\", \"ALIPAY_HK\"\n * Example Credit Cards: \"CC_VISA\", \"CC_MASTERCARD\"\n * Example Bank Transfer: \"VA_BCA\", \"VA_BNI\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodName: string;\n // Payment method country code\n payMethodCountry?: string;\n // Payment method properties\n payMethodProperties?: PayMethodProperties | string;\n // Payment method response data\n payMethodResponse?: PayMethodResponse | string;\n // User account type at pay method\n payMethodUserAccountType?: PayMethodUserAccountType | string;\n // User account number at pay method (max 64 characters)\n payMethodUserAccountNo?: string;\n // Cashier language (max 24 characters)\n cashierLanguage?: string;\n // User selected pay option (max 24 characters)\n payOption?: string;\n // User payment access token (max 256 characters)\n userPaymentAccessToken?: string;\n // Capture mode\n captureMode?: CaptureMode | string;\n // MIT mode\n merchantInitiatedMode?: MerchantInitiatedMode | string;\n}\n\n/**\n * Order Failed Reason Interface (Response)\n *\n * @description\n * Error details when order fails.\n *\n * @interface OrderFailedReason\n */\nexport interface OrderFailedReason {\n // Failure error code (max 64 characters)\n orderFailedCode: string;\n // Failure reason description (max 256 characters)\n orderFailedDescription: string;\n}\n\n/**\n * Create Order Response Data Interface\n *\n * @description\n * Business data returned by `waffo.order.create()`.\n *\n * @interface CreateOrderData\n */\nexport interface CreateOrderData {\n // Merchant original request ID (max 32 characters)\n paymentRequestId: string;\n // Merchant order ID (max 64 characters)\n merchantOrderId: string;\n // Unique acquiring order ID generated by Waffo (max 32 characters)\n acquiringOrderId: string;\n // Current order status\n orderStatus: OrderStatus | string;\n // Next step action guide\n orderAction?: OrderAction;\n}\n\n/**\n * Order Inquiry Response Data Interface\n *\n * @description\n * Complete order details returned by `waffo.order.inquiry()`.\n *\n * @interface InquiryOrderData\n */\nexport interface InquiryOrderData {\n // Merchant original request ID (max 32 characters)\n paymentRequestId: string;\n // Merchant order ID (max 64 characters)\n merchantOrderId: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Current order status\n orderStatus: OrderStatus | string;\n // Order action\n orderAction?: OrderAction;\n // Order currency\n orderCurrency: string;\n // Order amount\n orderAmount: string;\n // User payment currency\n userCurrency?: string;\n // Final amount user paid\n finalDealAmount: string;\n // Order description (max 128 characters)\n orderDescription: string;\n // Merchant information\n merchantInfo: MerchantInfoResponse;\n // User information\n userInfo: UserInfoResponse;\n // Goods information\n goodsInfo?: GoodsInfoResponse;\n // Address information\n addressInfo?: AddressInfoResponse;\n // Payment information\n paymentInfo: PaymentInfoResponse;\n // Order request time (max 24 characters)\n orderRequestedAt: string;\n // Order expiry time (max 24 characters)\n orderExpiredAt?: string;\n // Order last updated time (max 24 characters)\n orderUpdatedAt: string;\n // Order completion time (max 24 characters)\n orderCompletedAt: string;\n // Order failure reason\n orderFailedReason?: OrderFailedReason | string;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Cancel Order Response Data Interface\n *\n * @description\n * Business data returned by `waffo.order.cancel()`.\n *\n * @interface CancelOrderData\n */\nexport interface CancelOrderData {\n // Merchant original request ID (max 32 characters)\n paymentRequestId: string;\n // Merchant order ID (max 64 characters)\n merchantOrderId: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Order status (ORDER_CLOSE after successful cancellation)\n orderStatus: OrderStatus.ORDER_CLOSE | string;\n}\n\n/**\n * Capture Response Data Interface\n *\n * @description\n * Business data returned by `waffo.order.capture()`.\n *\n * @interface CaptureOrderData\n */\nexport interface CaptureOrderData {\n // Merchant original request ID (max 32 characters)\n paymentRequestId: string;\n // Merchant order ID (max 64 characters)\n merchantOrderId: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Order status\n orderStatus: OrderStatus | string;\n}\n\n// ============================================================\n// Webhook Notification Interfaces\n// ============================================================\n\n/**\n * Payment Notification Result Interface\n *\n * @description\n * Payload for PAYMENT_NOTIFICATION webhook (one-time/direct payment).\n *\n * @interface PaymentNotificationResult\n */\nexport interface PaymentNotificationResult {\n // Merchant original request ID (max 32 characters)\n paymentRequestId: string;\n // Merchant order ID (max 64 characters)\n merchantOrderId: string;\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Order status\n orderStatus: OrderStatus | string;\n // Order action\n orderAction?: OrderAction;\n // Order currency\n orderCurrency: string;\n // Order amount\n orderAmount: string;\n // User payment currency\n userCurrency?: string;\n // Final amount user paid\n finalDealAmount: string;\n // Order description (max 128 characters)\n orderDescription: string;\n // Merchant information\n merchantInfo: MerchantInfoResponse;\n // User information\n userInfo: UserInfoResponse;\n // Goods information\n goodsInfo?: GoodsInfoResponse;\n // Address information\n addressInfo?: AddressInfoResponse;\n // Payment information\n paymentInfo: PaymentInfoResponse;\n // Order request time (max 24 characters)\n orderRequestedAt: string;\n // Order expiry time (max 24 characters)\n orderExpiredAt?: string;\n // Order last updated time (max 24 characters)\n orderUpdatedAt: string;\n // Order completion time (max 24 characters)\n orderCompletedAt: string;\n // Order failure reason\n orderFailedReason?: OrderFailedReason | string;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Payment Notification Interface\n *\n * @description\n * Webhook notification for payment order status changes.\n *\n * @interface PaymentNotification\n */\nexport interface PaymentNotification {\n // Event type - always PAYMENT_NOTIFICATION\n eventType: WebhookEventType.PAYMENT_NOTIFICATION;\n // Notification result data\n result: PaymentNotificationResult;\n}\n\n/**\n * Payment Webhook Request Interface\n *\n * @description\n * Full structure of payment notification webhook request from Waffo.\n *\n * @interface PaymentWebhookRequest\n */\nexport interface PaymentWebhookRequest {\n // Request headers containing X-SIGNATURE\n header: WebhookRequestHeader;\n // Request body containing notification data\n body: PaymentNotification;\n}\n","/**\n * @fileoverview Refund Resource Type Definitions\n * @module types/refund\n *\n * Type definitions for the Refund resource (based on Waffo API JSON Schema).\n *\n * **Categories:**\n * - **Enums:** Refund status states\n * - **Request Interfaces:** Parameters for refund inquiry\n * - **Response Interfaces:** Refund data structures\n * - **Webhook Interfaces:** Refund notification structures\n *\n * @see {@link RefundResource} for API methods\n * @see {@link RefundInquiryParams} for inquiry parameters\n *\n * @example\n * import { RefundStatus, RefundInquiryParams } from 'waffo-sdk';\n *\n * const params: RefundInquiryParams = {\n * refundRequestId: 'refund-123',\n * };\n */\n\nimport { WebhookEventType, WebhookRequestHeader } from \"./webhook\";\nimport { RefundUserType } from \"./common\";\n\n// ============================================================\n// Enums\n// ============================================================\n\n/**\n * Refund Status Enum\n *\n * @description\n * Identifies the current status of a refund request in the processing flow.\n *\n * @enum {string}\n * @readonly\n */\nexport enum RefundStatus {\n // Refund in progress - Request accepted, waiting for channel processing\n REFUND_IN_PROGRESS = \"REFUND_IN_PROGRESS\",\n // Partial refund successful - Order partially refunded, remaining refundable amount exists\n ORDER_PARTIALLY_REFUNDED = \"ORDER_PARTIALLY_REFUNDED\",\n // Full refund successful - Order fully refunded\n ORDER_FULLY_REFUNDED = \"ORDER_FULLY_REFUNDED\",\n // Refund failed - Refund processing failed, see refundFailedReason for details\n ORDER_REFUND_FAILED = \"ORDER_REFUND_FAILED\",\n}\n\n// ============================================================\n// Request Interfaces\n// ============================================================\n\n/**\n * Refund Inquiry Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.refund.inquiry()`.\n *\n * @interface RefundInquiryParams\n */\nexport interface RefundInquiryParams {\n // Refund request ID generated by merchant (max 32 characters)\n refundRequestId?: string;\n // Refund order ID generated by Waffo (max 32 characters)\n acquiringRefundOrderId?: string;\n}\n\n// ============================================================\n// Response Interfaces\n// ============================================================\n\n/**\n * Refund Failed Reason Interface (Response)\n *\n * @description\n * Error details when refund fails.\n *\n * @interface RefundFailedReason\n */\nexport interface RefundFailedReason {\n // Refund failure error code (max 64 characters)\n refundFailedCode: string;\n // Refund failure reason description (max 256 characters)\n refundFailedDescription: string;\n}\n\n/**\n * Refund User Bank Information Interface (Response)\n *\n * @description\n * Bank account information returned for bank transfer refunds.\n *\n * @interface RefundUserBankInfo\n */\nexport interface RefundUserBankInfo {\n // Recipient bank account number (max 64 characters)\n bankAccountNo: string;\n // Bank code (max 64 characters)\n bankCode: string;\n // Bank city (max 64 characters)\n bankCity?: string;\n // Bank branch (max 64 characters)\n bankBranch?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Refund User Information Interface (Response)\n *\n * @description\n * User information returned for specific payment method refunds.\n *\n * @interface RefundUserInfoResponse\n */\nexport interface RefundUserInfoResponse {\n // User type: INDIVIDUAL or BUSINESS\n userType?: RefundUserType;\n // User first name (max 64 characters)\n userFirstName?: string;\n // User last name (max 64 characters)\n userLastName?: string;\n // User email (max 64 characters)\n userEmail?: string;\n // User bank account information\n userBankInfo?: RefundUserBankInfo | string;\n // User phone number (max 16 characters)\n userPhone?: string;\n // User ID type (max 24 characters)\n userIDType?: string;\n // User ID number (max 64 characters)\n userIDNumber?: string;\n // User ID issue date (dd/mm/yyyy, max 12 characters)\n userIDIssueDate?: string;\n // User ID expiry date (dd/mm/yyyy, max 12 characters)\n userIDExpiryDate?: string;\n}\n\n/**\n * Create Refund Response Data Interface\n *\n * @description\n * Business data returned by `waffo.order.refund()`.\n *\n * @interface CreateRefundData\n */\nexport interface CreateRefundData {\n // Refund request ID generated by merchant (max 32 characters)\n refundRequestId: string;\n // Merchant system refund order ID (max 64 characters)\n merchantRefundOrderId?: string;\n // Waffo acquiring order ID of the original payment transaction (max 32 characters)\n acquiringOrderId: string;\n // Unique refund order ID generated by Waffo (max 32 characters)\n acquiringRefundOrderId: string;\n // Refund amount for this request\n refundAmount: string;\n // Current refund status\n refundStatus: RefundStatus | string;\n // Remaining refundable amount for this order\n remainingRefundAmount: string;\n}\n\n/**\n * Refund Inquiry Response Data Interface\n *\n * @description\n * Complete refund details returned by `waffo.refund.inquiry()`.\n *\n * @interface InquiryRefundData\n */\nexport interface InquiryRefundData {\n // Refund request ID generated by merchant (max 32 characters)\n refundRequestId: string;\n // Merchant system refund order ID (max 64 characters)\n merchantRefundOrderId?: string;\n // Waffo acquiring order ID of the original payment transaction (max 32 characters)\n acquiringOrderId: string;\n // Refund order ID generated by Waffo (max 32 characters)\n acquiringRefundOrderId: string;\n // Original payment request ID (max 32 characters)\n origPaymentRequestId: string;\n // Merchant requested refund amount\n refundAmount: string;\n // Current refund status\n refundStatus: RefundStatus | string;\n // Remaining refundable amount for this order\n remainingRefundAmount: string;\n // User payment currency\n userCurrency?: string;\n // User actual received refund amount\n finalDealAmount: string;\n // Refund reason description (max 32 characters)\n refundReason: string;\n // Refund requested time (max 24 characters)\n refundRequestedAt: string;\n // Refund updated time (max 24 characters)\n refundUpdatedAt: string;\n // Refund completion time (max 24 characters)\n refundCompletedAt: string;\n // Refund failure reason\n refundFailedReason?: RefundFailedReason | string;\n // User information\n userInfo?: RefundUserInfoResponse;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n}\n\n// ============================================================\n// Webhook Notification Interfaces\n// ============================================================\n\n/**\n * Refund Notification Result Interface\n *\n * @description\n * Payload for REFUND_NOTIFICATION webhook.\n *\n * @interface RefundNotificationResult\n */\nexport interface RefundNotificationResult {\n // Refund request ID generated by merchant (max 32 characters)\n refundRequestId: string;\n // Merchant system refund order ID (max 64 characters)\n merchantRefundOrderId?: string;\n // Waffo acquiring order ID of the original payment (max 32 characters)\n acquiringOrderId: string;\n // Waffo refund order ID (max 32 characters)\n acquiringRefundOrderId: string;\n // Original payment request ID (max 32 characters)\n origPaymentRequestId: string;\n // Refund amount\n refundAmount: string;\n // Refund status\n refundStatus: RefundStatus | string;\n // Remaining refundable amount for this order\n remainingRefundAmount: string;\n // User payment currency\n userCurrency?: string;\n // Final refunded amount the user receives\n finalDealAmount: string;\n // Refund reason (max 32 characters)\n refundReason: string;\n // Refund requested time (max 24 characters)\n refundRequestedAt: string;\n // Refund updated time (max 24 characters)\n refundUpdatedAt: string;\n // Refund completion time (max 24 characters)\n refundCompletedAt: string;\n // Refund failure reason\n refundFailedReason?: RefundFailedReason | string;\n // User information\n userInfo?: RefundUserInfoResponse;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Refund Notification Interface\n *\n * @description\n * Webhook notification for refund order status changes.\n *\n * @interface RefundNotification\n */\nexport interface RefundNotification {\n // Event type - always REFUND_NOTIFICATION\n eventType: WebhookEventType.REFUND_NOTIFICATION;\n // Notification result data\n result: RefundNotificationResult;\n}\n\n/**\n * Refund Webhook Request Interface\n *\n * @description\n * Full structure of refund notification webhook request from Waffo.\n *\n * @interface RefundWebhookRequest\n */\nexport interface RefundWebhookRequest {\n // Request headers containing X-SIGNATURE\n header: WebhookRequestHeader;\n // Request body containing notification data\n body: RefundNotification;\n}\n","/**\n * @fileoverview Subscription Resource Type Definitions\n * @module types/subscription\n *\n * Type definitions for the Subscription resource (based on Waffo API JSON Schema).\n *\n * **Categories:**\n * - **Enums:** Subscription status, period types, event types\n * - **Request Interfaces:** Parameters for create, inquiry, cancel, manage\n * - **Response Interfaces:** Subscription data structures\n * - **Webhook Interfaces:** Subscription notification structures\n *\n * @see {@link SubscriptionResource} for API methods\n * @see {@link CreateSubscriptionParams} for subscription creation\n *\n * @example\n * import {\n * CreateSubscriptionParams,\n * SubscriptionStatus,\n * PeriodType,\n * } from 'waffo-sdk';\n *\n * const params: CreateSubscriptionParams = {\n * subscriptionRequest: 'sub-123',\n * currency: 'USD',\n * amount: '9.99',\n * productInfo: {\n * description: 'Monthly Plan',\n * periodType: PeriodType.MONTHLY,\n * periodInterval: '1',\n * },\n * // ...\n * };\n */\n\nimport { WebhookRequestHeader } from \"./webhook\";\nimport { SubscriptionProductName } from \"./payment\";\nimport { RiskUserType } from \"./common\";\n\n// Re-export SubscriptionProductName for convenience\nexport { SubscriptionProductName };\n\n// ============================================================\n// Enums\n// ============================================================\n\n/**\n * Subscription Status Enum\n *\n * @description\n * Identifies the current status of a subscription.\n *\n * @enum {string}\n * @readonly\n */\nexport enum SubscriptionStatus {\n // Authorization required - User needs to complete subscription signing\n AUTHORIZATION_REQUIRED = \"AUTHORIZATION_REQUIRED\",\n // In progress - Subscription is being processed\n IN_PROGRESS = \"IN_PROGRESS\",\n // Active - Subscription is active and billing\n ACTIVE = \"ACTIVE\",\n // Closed - Subscription is closed\n CLOSE = \"CLOSE\",\n // Cancelled by merchant\n MERCHANT_CANCELLED = \"MERCHANT_CANCELLED\",\n // Cancelled by user\n USER_CANCELLED = \"USER_CANCELLED\",\n // Cancelled by channel\n CHANNEL_CANCELLED = \"CHANNEL_CANCELLED\",\n // Expired - Subscription has reached its end date or period limit\n EXPIRED = \"EXPIRED\",\n}\n\n/**\n * Period Type Enum\n *\n * @description\n * Billing period type for subscription.\n *\n * @enum {string}\n * @readonly\n */\nexport enum PeriodType {\n // Daily billing (for trial period only)\n DAILY = \"DAILY\",\n // Weekly billing\n WEEKLY = \"WEEKLY\",\n // Monthly billing\n MONTHLY = \"MONTHLY\",\n}\n\n/**\n * User Terminal Type Enum\n *\n * @description\n * Identifies the terminal environment where the user initiates subscription.\n *\n * @enum {string}\n * @readonly\n */\nexport enum SubscriptionUserTerminalType {\n // Web browser\n WEB = \"WEB\",\n // Native app\n APP = \"APP\",\n}\n\n/**\n * Cashier Language Enum\n *\n * @description\n * Supported cashier languages.\n *\n * @enum {string}\n * @readonly\n */\nexport enum CashierLanguage {\n // English (Hong Kong)\n EN_HK = \"en-HK\",\n // Traditional Chinese (Hong Kong)\n ZH_HANT_HK = \"zh-Hant-HK\",\n // Simplified Chinese (Hong Kong)\n ZH_HANS_HK = \"zh-Hans-HK\",\n}\n\n/**\n * Pay Method User Account Type Enum\n *\n * @description\n * User account type at the designated pay method.\n *\n * @enum {string}\n * @readonly\n */\nexport enum SubscriptionPayMethodUserAccountType {\n // Email account\n EMAIL = \"EMAIL\",\n // Phone number account\n PHONE_NO = \"PHONE_NO\",\n // Account ID\n ACCOUNT_ID = \"ACCOUNT_ID\",\n}\n\n/**\n * Subscription Order Status Enum\n *\n * @description\n * Status for subscription payment order.\n *\n * @enum {string}\n * @readonly\n */\nexport enum SubscriptionOrderStatus {\n // Payment successful\n PAY_SUCCESS = \"PAY_SUCCESS\",\n // Order closed\n ORDER_CLOSE = \"ORDER_CLOSE\",\n}\n\n/**\n * Subscription Event Type Enum\n *\n * @description\n * Event types for subscription webhook notifications.\n *\n * @enum {string}\n * @readonly\n */\nexport enum SubscriptionEventType {\n // Subscription status changed\n SUBSCRIPTION_STATUS_NOTIFICATION = \"SUBSCRIPTION_STATUS_NOTIFICATION\",\n // Subscription payment completed\n PAYMENT_NOTIFICATION = \"PAYMENT_NOTIFICATION\",\n}\n\n// ============================================================\n// Request Interfaces\n// ============================================================\n\n/**\n * Product Information Interface (Request Parameters)\n *\n * @description\n * Subscription billing product configuration.\n *\n * @interface ProductInfo\n */\nexport interface ProductInfo {\n // Product description (max 128 characters) - required\n description: string;\n // Billing period type: WEEKLY, MONTHLY - required\n periodType: PeriodType | string;\n // Billing interval (max 12 characters, WEEKLY:1-4, MONTHLY:1-12) - required\n periodInterval: string;\n // Total number of billing periods (max 24 characters, empty for unlimited, <= 3 years total)\n numberOfPeriod?: string;\n // Trial period amount (max 24 characters, >0, empty means no trial)\n trialPeriodAmount?: string;\n // Number of trial periods (max 12 characters)\n numberOfTrialPeriod?: string;\n // Trial period type: DAILY, WEEKLY, MONTHLY\n trialPeriodType?: PeriodType | string;\n // Trial period interval (max 12 characters)\n trialPeriodInterval?: string;\n}\n\n/**\n * Merchant Information Interface (Request Parameters)\n *\n * @description\n * Merchant information for subscription.\n *\n * @interface SubscriptionMerchantInfo\n */\nexport interface SubscriptionMerchantInfo {\n // Merchant ID assigned by Waffo (max 64 characters) - required\n merchantId: string;\n // Sub-merchant ID assigned by Waffo (max 64 characters)\n subMerchantId?: string;\n}\n\n/**\n * Subscription User Info Interface (Request Parameters)\n *\n * @description\n * User information for subscription.\n *\n * @interface SubscriptionUserInfo\n */\nexport interface SubscriptionUserInfo {\n // Unique user identifier in merchant's system (max 64 characters) - required\n userId: string;\n // User email address (max 64 characters) - required\n userEmail: string;\n // User terminal type: WEB, APP\n userTerminal?: SubscriptionUserTerminalType | string;\n // User phone number (max 16 characters, +CountryCode-MobileNo format)\n userPhone?: string;\n // User first name (max 64 characters)\n userFirstName?: string;\n // User last name (max 64 characters)\n userLastName?: string;\n // User creation time (max 24 characters, ISO 8601)\n userCreatedAt?: string;\n}\n\n/**\n * Subscription Goods Information Interface (Request Parameters)\n *\n * @description\n * Goods information for subscription.\n *\n * @interface SubscriptionGoodsInfo\n */\nexport interface SubscriptionGoodsInfo {\n // Unique goods ID (max 32 characters) - required\n goodsId: string;\n // Product name (max 64 characters) - required\n goodsName: string;\n // Product category (max 32 characters)\n goodsCategory?: string;\n // Product detail page URL (max 128 characters, either this or appName is required)\n goodsUrl?: string;\n // App package name (max 32 characters, either this or goodsUrl is required)\n appName?: string;\n // SKU name (max 32 characters)\n skuName?: string;\n // Goods unique price (max 16 characters)\n goodsUniquePrice?: string;\n // Goods quantity\n goodsQuantity?: number;\n}\n\n/**\n * Subscription Address Information Interface (Request Parameters)\n *\n * @description\n * Address information for subscription.\n *\n * @interface SubscriptionAddressInfo\n */\nexport interface SubscriptionAddressInfo {\n // Detailed shipping address (max 256 characters)\n address?: string;\n // City (max 32 characters)\n city?: string;\n // Region/Province/State (max 32 characters)\n region?: string;\n // Postal code (max 16 characters)\n postcode?: string;\n // Shipping country code (max 16 characters)\n addressCountryCode?: string;\n}\n\n/**\n * Subscription Payment Info Interface (Request Parameters)\n *\n * @description\n * Payment method configuration for subscription.\n *\n * @interface SubscriptionPaymentInfo\n */\nexport interface SubscriptionPaymentInfo {\n // Product name: SUBSCRIPTION, MINI_PROGRAM_SUBSCRIPTION - required\n productName: SubscriptionProductName | string;\n /**\n * Payment method type (max 256 characters)\n * Example values: \"EWALLET\", \"CREDITCARD\", \"DEBITCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodType?: string;\n /**\n * Specific payment method name (max 24 characters) - required\n * Example E-wallets: \"DANA\", \"GCASH\", \"ALIPAY_HK\"\n * Example Credit Cards: \"CC_VISA\", \"CC_MASTERCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodName: string;\n // Payment method properties\n payMethodProperties?: Record<string, unknown> | string;\n // User account type at pay method: EMAIL, PHONE_NO, ACCOUNT_ID\n payMethodUserAccountType?: SubscriptionPayMethodUserAccountType | string;\n // Cashier language\n cashierLanguage?: CashierLanguage | string;\n // User account number at pay method (max 64 characters)\n payMethodUserAccountNo?: string;\n // User access token (max 128 characters, required for MINI_PROGRAM_SUBSCRIPTION)\n payMethodUserAccessToken?: string;\n}\n\n/**\n * Risk Data Interface (Request Parameters)\n *\n * @description\n * Auxiliary data for risk assessment.\n *\n * @interface SubscriptionRiskData\n */\nexport interface SubscriptionRiskData {\n // User type (max 24 characters): Individual/Agent/Institution/Internal\n userType?: RiskUserType;\n // User category (max 24 characters): Member/Non-Member\n userCategory?: string;\n // User legal name (max 128 characters)\n userLegalName?: string;\n // User display name (max 128 characters)\n userDisplayName?: string;\n // User registration IP (max 24 characters)\n userRegistrationIp?: string;\n // User last seen IP (max 24 characters)\n userLastSeenIp?: string;\n // Whether user is new (max 8 characters): Yes/No\n userIsNew?: string;\n // Whether this is user's first purchase (max 8 characters): Yes/No\n userIsFirstPurchase?: string;\n}\n\n/**\n * Create Subscription Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.subscription.create()`.\n *\n * @interface CreateSubscriptionParams\n */\nexport interface CreateSubscriptionParams {\n // Unique request ID generated by merchant (max 32 characters) - required\n subscriptionRequest: string;\n // Merchant subscription plan ID assigned to this user (max 64 characters)\n merchantSubscriptionId?: string;\n // Subscription currency code (ISO 4217) - required\n currency: string;\n // Subscription amount per period - required\n amount: string;\n // User payment currency (when different from merchant currency)\n userCurrency?: string;\n // Subscription product/billing configuration - required\n productInfo: ProductInfo;\n // Merchant information - required\n merchantInfo: SubscriptionMerchantInfo;\n // User information - required\n userInfo: SubscriptionUserInfo;\n // Goods information - required\n goodsInfo: SubscriptionGoodsInfo;\n // Address information\n addressInfo?: SubscriptionAddressInfo;\n // Payment method information - required\n paymentInfo: SubscriptionPaymentInfo;\n // Request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n requestedAt?: string;\n // Redirect URL after successful subscription signing (max 256 characters)\n successRedirectUrl?: string;\n // Redirect URL after payment pre-verification fails (max 256 characters)\n failedRedirectUrl?: string;\n // Redirect URL after subscription payment is cancelled (max 256 characters)\n cancelRedirectUrl?: string;\n // Async notification URL for subscription status changes (max 256 characters) - required\n notifyUrl: string;\n // Merchant-side subscription management URL (max 256 characters, required for some pay methods)\n subscriptionManagementUrl?: string;\n // Risk control auxiliary data\n riskData?: SubscriptionRiskData;\n // Reserved extend info (max 128 characters or object)\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Inquiry Subscription Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.subscription.inquiry()`.\n *\n * @interface InquirySubscriptionParams\n */\nexport interface InquirySubscriptionParams {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest?: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId?: string;\n // Whether to return payment details: \"0\" = no, \"1\" = yes\n paymentDetails?: \"0\" | \"1\";\n}\n\n/**\n * Cancel Subscription Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.subscription.cancel()`.\n *\n * @interface CancelSubscriptionParams\n */\nexport interface CancelSubscriptionParams {\n // Waffo subscription ID (max 64 characters) - required\n subscriptionId: string;\n // Merchant ID (max 64 characters) - required\n merchantId: string;\n // Cancel request time (ISO 8601 format, max 24 characters), defaults to current time if not provided\n requestedAt?: string;\n}\n\n/**\n * Manage Subscription Request Parameters Interface\n *\n * @description\n * Request parameters for calling `waffo.subscription.manage()`.\n *\n * @interface ManageSubscriptionParams\n */\nexport interface ManageSubscriptionParams {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest?: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId?: string;\n}\n\n// ============================================================\n// Response Interfaces\n// ============================================================\n\n/**\n * Subscription Action Interface (Response)\n *\n * @description\n * Returned when subscription status is AUTHORIZATION_REQUIRED.\n *\n * @interface SubscriptionAction\n */\nexport interface SubscriptionAction {\n // Web URL for user to complete subscription signing (max 256 characters)\n webUrl: string;\n}\n\n/**\n * Product Info Response Interface (Response)\n *\n * @description\n * Subscription product configuration in response.\n *\n * @interface ProductInfoResponse\n */\nexport interface ProductInfoResponse {\n // Subscription product description (max 128 characters)\n description: string;\n // Billing period type: WEEKLY, MONTHLY\n periodType: PeriodType | string;\n // Billing interval (max 12 characters)\n periodInterval: string;\n // Total number of billing periods (max 24 characters)\n numberOfPeriod?: string;\n // Trial period amount (max 24 characters)\n trialPeriodAmount?: string;\n // Number of trial periods (max 12 characters)\n numberOfTrialPeriod?: string;\n // Subscription start date time (max 24 characters, ISO 8601)\n startDateTime?: string;\n // Subscription end date time (max 24 characters, ISO 8601)\n endDateTime?: string;\n // Next payment scheduled time (max 24 characters, ISO 8601)\n nextPaymentDateTime?: string;\n // Current billing period number (max 24 characters)\n currentPeriod?: string;\n}\n\n/**\n * Payment Detail Interface (Response)\n *\n * @description\n * Individual payment record within subscription.\n *\n * @interface PaymentDetail\n */\nexport interface PaymentDetail {\n // Waffo order ID for this payment (max 32 characters)\n acquiringOrderId: string;\n // Payment order currency\n orderCurrency: string;\n // Payment amount\n orderAmount: string;\n // Payment status: PAY_SUCCESS, ORDER_CLOSE\n orderStatus: SubscriptionOrderStatus | string;\n // Payment update time (max 24 characters, ISO 8601)\n orderUpdatedAt: string;\n // Billing period number (max 12 characters)\n period: string;\n}\n\n/**\n * Subscription Failed Reason Interface (Response)\n *\n * @description\n * Error details when subscription fails.\n *\n * @interface SubscriptionFailedReason\n */\nexport interface SubscriptionFailedReason {\n // Order failed code (max 64 characters)\n orderFailedCode: string;\n // Order failed description (max 256 characters)\n orderFailedDescription: string;\n}\n\n/**\n * Payment Method Response Interface (Response)\n *\n * @description\n * Payment method response data.\n *\n * @interface SubscriptionPayMethodResponse\n */\nexport interface SubscriptionPayMethodResponse {\n // Payment reference ID (max 128 characters)\n payMethodRefId?: string;\n // Exchange rate (max 64 characters)\n exchangeRate?: string;\n // User open ID (max 128 characters)\n userOpenId?: string;\n // Masked card data (max 32 characters)\n maskCardData?: string;\n // Additional properties\n [key: string]: string | undefined;\n}\n\n/**\n * Subscription Payment Info Response Interface (Response)\n *\n * @description\n * Payment method information in response.\n *\n * @interface SubscriptionPaymentInfoResponse\n */\nexport interface SubscriptionPaymentInfoResponse {\n // Product name: SUBSCRIPTION, MINI_PROGRAM_SUBSCRIPTION\n productName: SubscriptionProductName | string;\n /**\n * Payment method type (max 256 characters)\n * Example values: \"EWALLET\", \"CREDITCARD\", \"DEBITCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodType?: string;\n /**\n * Payment method name (max 24 characters)\n * Example E-wallets: \"DANA\", \"GCASH\", \"ALIPAY_HK\"\n * Example Credit Cards: \"CC_VISA\", \"CC_MASTERCARD\"\n * Note: This list may be updated. Please refer to the latest API documentation.\n */\n payMethodName: string;\n // Payment method properties\n payMethodProperties?: Record<string, unknown> | string;\n // Payment method response\n payMethodResponse?: SubscriptionPayMethodResponse | string;\n // User account type at pay method\n payMethodUserAccountType?: SubscriptionPayMethodUserAccountType | string;\n // User account number (max 64 characters)\n payMethodUserAccountNo?: string;\n // User access token (max 128 characters)\n payMethodUserAccessToken?: string;\n // Public user ID at pay method (max 128 characters)\n payMethodPublicUid?: string;\n}\n\n/**\n * Create Subscription Response Data Interface\n *\n * @description\n * Business data returned by `waffo.subscription.create()`.\n *\n * @interface CreateSubscriptionData\n */\nexport interface CreateSubscriptionData {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest: string;\n // Merchant subscription ID (max 64 characters)\n merchantSubscriptionId?: string;\n // Waffo generated subscription ID (max 64 characters)\n subscriptionId: string;\n // Payment method's subscription ID (max 64 characters)\n payMethodSubscriptionId?: string;\n // Current subscription status\n subscriptionStatus: SubscriptionStatus | string;\n // Action guide for user to complete signing\n subscriptionAction?: SubscriptionAction;\n}\n\n/**\n * Inquiry Subscription Response Data Interface\n *\n * @description\n * Business data returned by `waffo.subscription.inquiry()`.\n *\n * @interface InquirySubscriptionData\n */\nexport interface InquirySubscriptionData {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest: string;\n // Merchant subscription ID (max 64 characters)\n merchantSubscriptionId?: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId: string;\n // Current subscription status\n subscriptionStatus: SubscriptionStatus | string;\n // Subscription action\n subscriptionAction?: SubscriptionAction;\n // Subscription currency\n currency: string;\n // Subscription amount\n amount: string;\n // User payment currency\n userCurrency?: string;\n // Subscription product configuration\n productInfo: ProductInfoResponse;\n // Merchant information\n merchantInfo: SubscriptionMerchantInfo;\n // User information\n userInfo: SubscriptionUserInfo;\n // Goods information\n goodsInfo?: SubscriptionGoodsInfo;\n // Address information\n addressInfo?: SubscriptionAddressInfo;\n // Payment information\n paymentInfo: SubscriptionPaymentInfoResponse;\n // Merchant request time (max 24 characters)\n requestedAt: string;\n // Subscription last update time (max 24 characters)\n updatedAt: string;\n // Failed reason\n failedReason?: SubscriptionFailedReason | string;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n // Subscription management URL (max 256 characters)\n subscriptionManagementUrl?: string;\n // Payment history (returned when paymentDetails=\"1\")\n paymentDetails?: PaymentDetail[];\n}\n\n/**\n * Cancel Subscription Response Data Interface\n *\n * @description\n * Business data returned by `waffo.subscription.cancel()`.\n *\n * @interface CancelSubscriptionData\n */\nexport interface CancelSubscriptionData {\n // Waffo subscription ID (max 64 characters)\n subscriptionId: string;\n // Merchant original request ID (max 32 characters)\n subscriptionRequest: string;\n // Merchant subscription ID (max 64 characters)\n merchantSubscriptionId?: string;\n // Updated order status: CLOSE, MERCHANT_CANCELLED, CHANNEL_CANCELLED, EXPIRED\n orderStatus: SubscriptionStatus | string;\n}\n\n/**\n * Manage Subscription Response Data Interface\n *\n * @description\n * Business data returned by `waffo.subscription.manage()`.\n *\n * @interface ManageSubscriptionData\n */\nexport interface ManageSubscriptionData {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest: string;\n // Merchant subscription ID (max 64 characters)\n merchantSubscriptionId?: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId: string;\n // Generated management page URL (max 256 characters)\n managementUrl: string;\n // Expiration time of management URL (max 24 characters, ISO 8601, UTC)\n expiredAt: string;\n // Current subscription status\n subscriptionStatus: SubscriptionStatus | string;\n}\n\n/**\n * Subscription Info Interface (Response)\n *\n * @description\n * Subscription information in payment order response and webhook notifications.\n *\n * @interface SubscriptionInfo\n */\nexport interface SubscriptionInfo {\n // Subscription request ID (max 32 characters)\n subscriptionRequest: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId: string;\n // Which period the subscription payment belongs to (max 12 characters)\n period: string;\n}\n\n// ============================================================\n// Webhook Notification Interfaces\n// ============================================================\n\n/**\n * Subscription Status Notification Result Interface\n *\n * @description\n * Payload for SUBSCRIPTION_STATUS_NOTIFICATION webhook.\n *\n * @interface SubscriptionStatusNotificationResult\n */\nexport interface SubscriptionStatusNotificationResult {\n // Merchant original request ID (max 32 characters)\n subscriptionRequest: string;\n // Merchant subscription ID (max 64 characters)\n merchantSubscriptionId?: string;\n // Waffo subscription ID (max 64 characters)\n subscriptionId: string;\n // Updated subscription status\n subscriptionStatus: SubscriptionStatus | string;\n // Subscription action\n subscriptionAction?: SubscriptionAction;\n // Subscription currency\n currency: string;\n // Subscription amount\n amount: string;\n // User payment currency\n userCurrency?: string;\n // Subscription product configuration\n productInfo: ProductInfoResponse;\n // Merchant information\n merchantInfo: SubscriptionMerchantInfo;\n // User information\n userInfo: SubscriptionUserInfo;\n // Goods information\n goodsInfo?: SubscriptionGoodsInfo;\n // Address information\n addressInfo?: SubscriptionAddressInfo;\n // Payment information\n paymentInfo: SubscriptionPaymentInfoResponse;\n // Merchant request time (max 24 characters)\n requestedAt: string;\n // Subscription last update time (max 24 characters)\n updatedAt: string;\n // Failed reason\n failedReason?: SubscriptionFailedReason | string;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n // Subscription management URL (max 256 characters)\n subscriptionManagementUrl?: string;\n // Payment history\n paymentDetails?: PaymentDetail[];\n}\n\n/**\n * Subscription Payment Notification Result Interface\n *\n * @description\n * Payload for PAYMENT_NOTIFICATION webhook (subscription deduction).\n *\n * @interface SubscriptionPaymentNotificationResult\n */\nexport interface SubscriptionPaymentNotificationResult {\n // Waffo acquiring order ID (max 32 characters)\n acquiringOrderId: string;\n // Payment status: PAY_SUCCESS, ORDER_CLOSE\n orderStatus: SubscriptionOrderStatus | string;\n // Order currency\n orderCurrency: string;\n // Order amount\n orderAmount: string;\n // User payment currency\n userCurrency?: string;\n // Final amount user paid\n finalDealAmount: string;\n // Order description (max 128 characters)\n orderDescription: string;\n // Merchant information\n merchantInfo: SubscriptionMerchantInfo;\n // User information\n userInfo: SubscriptionUserInfo;\n // Goods information\n goodsInfo?: SubscriptionGoodsInfo;\n // Address information\n addressInfo?: SubscriptionAddressInfo;\n // Payment information\n paymentInfo: SubscriptionPaymentInfoResponse;\n // Subscription information\n subscriptionInfo: SubscriptionInfo;\n // Order request time (max 24 characters)\n orderRequestedAt: string;\n // Order update time (max 24 characters)\n orderUpdatedAt: string;\n // Order failed reason\n orderFailedReason?: SubscriptionFailedReason | string;\n // Extended info\n extendInfo?: string | Record<string, unknown>;\n}\n\n/**\n * Subscription Status Notification Interface\n *\n * @description\n * Webhook notification for subscription status changes.\n *\n * @interface SubscriptionStatusNotification\n */\nexport interface SubscriptionStatusNotification {\n // Event type - always SUBSCRIPTION_STATUS_NOTIFICATION\n eventType: SubscriptionEventType.SUBSCRIPTION_STATUS_NOTIFICATION;\n // Notification result data\n result: SubscriptionStatusNotificationResult;\n}\n\n/**\n * Subscription Payment Notification Interface\n *\n * @description\n * Webhook notification for subscription payment events (recurring billing).\n *\n * @interface SubscriptionPaymentNotification\n */\nexport interface SubscriptionPaymentNotification {\n // Event type - always PAYMENT_NOTIFICATION\n eventType: SubscriptionEventType.PAYMENT_NOTIFICATION;\n // Notification result data\n result: SubscriptionPaymentNotificationResult;\n}\n\n/**\n * Subscription Notification Union Type\n *\n * @description\n * Union type for all subscription webhook notifications.\n *\n * @typedef {SubscriptionStatusNotification | SubscriptionPaymentNotification} SubscriptionNotification\n */\nexport type SubscriptionNotification =\n | SubscriptionStatusNotification\n | SubscriptionPaymentNotification;\n\n/**\n * Subscription Status Webhook Request Interface\n *\n * @description\n * Full structure of subscription status notification webhook request from Waffo.\n *\n * @interface SubscriptionStatusWebhookRequest\n */\nexport interface SubscriptionStatusWebhookRequest {\n // Request headers containing X-SIGNATURE\n header: WebhookRequestHeader;\n // Request body containing notification data\n body: SubscriptionStatusNotification;\n}\n\n/**\n * Subscription Payment Webhook Request Interface\n *\n * @description\n * Full structure of subscription payment notification webhook request from Waffo.\n *\n * @interface SubscriptionPaymentWebhookRequest\n */\nexport interface SubscriptionPaymentWebhookRequest {\n // Request headers containing X-SIGNATURE\n header: WebhookRequestHeader;\n // Request body containing notification data\n body: SubscriptionPaymentNotification;\n}\n\n/**\n * Subscription Webhook Request Union Type\n *\n * @description\n * Union type for all subscription webhook requests.\n *\n * @typedef {SubscriptionStatusWebhookRequest | SubscriptionPaymentWebhookRequest} SubscriptionWebhookRequest\n */\nexport type SubscriptionWebhookRequest =\n | SubscriptionStatusWebhookRequest\n | SubscriptionPaymentWebhookRequest;\n","/**\n * @fileoverview RSA Cryptographic Utility Functions\n * @module utils/rsa\n *\n * Provides RSA cryptographic operations for the Waffo SDK:\n * - **{@link signForRSA}** - Sign data using RSA-SHA256\n * - **{@link verify}** - Verify RSA-SHA256 signatures\n * - **{@link createKeyPair}** - Generate new RSA key pairs\n *\n * **Key Formats:**\n * - Private keys: Base64 encoded PKCS8 DER format\n * - Public keys: Base64 encoded X509/SPKI DER format\n *\n * @see {@link HttpClient} for automatic request signing\n * @see {@link verifyWebhookSignature} for webhook verification\n *\n * @example\n * import { signForRSA, verify, createKeyPair } from 'waffo-sdk';\n *\n * // Generate a new key pair\n * const keys = createKeyPair();\n *\n * // Sign data\n * const data = JSON.stringify({ message: 'Hello' });\n * const signature = signForRSA(data, keys.PRIVATE_KEY_NAME);\n *\n * // Verify signature\n * const isValid = verify(data, signature, keys.PUBLIC_KEY_NAME);\n */\n\nimport crypto from \"crypto\";\n\n/**\n * RSA-SHA256 algorithm identifier.\n * @constant {string}\n * @internal\n */\nconst SIGN_ALGORITHMS = \"RSA-SHA256\";\n\n/**\n * Callback function for handling cryptographic errors.\n *\n * When provided to signing/verification functions, errors are passed\n * to this callback instead of causing the function to throw.\n *\n * @typedef {Function} ErrorHandler\n * @param {Error} error - The error that occurred\n *\n * @example\n * const signature = signForRSA(data, privateKey, 'utf8', (error) => {\n * console.error('Signing failed:', error.message);\n * });\n */\nexport type ErrorHandler = (error: Error) => void;\n\n/**\n * Signs a payload using RSA-SHA256 algorithm.\n *\n * Returns a Base64 encoded signature. Used internally by the SDK to sign\n * all outgoing API requests (included in `X-SIGNATURE` header).\n *\n * @param {string} body - Payload to sign (typically JSON serialized)\n * @param {string} privateKey - Private key (Base64 encoded PKCS8 DER format)\n * @param {string} [charSet='utf8'] - Character encoding ('utf8', 'ascii', 'latin1')\n * @param {ErrorHandler} [onError] - Optional error handler callback\n *\n * @returns {string | null} Base64 encoded signature, or `null` on failure\n *\n * @example\n * // Sign a JSON payload\n * const payload = JSON.stringify({ orderId: '123', amount: '100' });\n * const signature = signForRSA(payload, privateKey);\n *\n * if (signature) {\n * console.log('Signature:', signature);\n * }\n *\n * @example\n * // With error handling\n * const signature = signForRSA(payload, privateKey, 'utf8', (error) => {\n * console.error('Signing failed:', error.message);\n * });\n *\n * @see {@link verify} for signature verification\n * @see {@link createKeyPair} for generating key pairs\n */\nexport function signForRSA(\n body: string,\n privateKey: string,\n charSet: string = \"utf8\",\n onError?: ErrorHandler,\n): string | null {\n try {\n // Decode base64 private key (PKCS8 DER format)\n const privateKeyDer = Buffer.from(privateKey, \"base64\");\n\n // Convert PKCS8 DER to PEM format for Node.js crypto\n const privateKeyPem = `-----BEGIN PRIVATE KEY-----\\n${privateKeyDer\n .toString(\"base64\")\n .match(/.{1,64}/g)\n ?.join(\"\\n\")}\\n-----END PRIVATE KEY-----`;\n\n // Create signature instance\n const signature = crypto.createSign(SIGN_ALGORITHMS);\n\n // Update with body bytes using specified charset\n signature.update(body, charSet as BufferEncoding);\n\n const signed = signature.sign(privateKeyPem, \"base64\");\n\n return signed;\n } catch (e) {\n onError?.(e instanceof Error ? e : new Error(String(e)));\n return null;\n }\n}\n\n/**\n * Verifies an RSA-SHA256 signature.\n *\n * Returns `true` if the signature is valid. Used internally by the SDK\n * to verify API response and webhook notification signatures.\n *\n * @param {string} body - Original payload that was signed\n * @param {string} sign - Signature to verify (Base64 encoded)\n * @param {string} publicKey - Public key (Base64 encoded X509/SPKI DER format)\n * @param {string} [charSet='utf8'] - Character encoding (must match signing)\n * @param {ErrorHandler} [onError] - Optional error handler callback\n *\n * @returns {boolean} `true` if signature is valid, `false` otherwise\n *\n * @example\n * // Verify a signature\n * const isValid = verify(payload, signature, publicKey);\n *\n * if (isValid) {\n * console.log('Signature verified successfully');\n * } else {\n * console.log('Invalid signature');\n * }\n *\n * @example\n * // With error handling\n * const isValid = verify(payload, signature, publicKey, 'utf8', (error) => {\n * console.error('Verification error:', error.message);\n * });\n *\n * @see {@link signForRSA} for signature generation\n * @see {@link verifyWebhookSignature} for webhook verification\n */\nexport function verify(\n body: string,\n sign: string,\n publicKey: string,\n charSet: string = \"utf8\",\n onError?: ErrorHandler,\n): boolean {\n try {\n // Decode base64 public key (X509 DER format)\n const publicKeyDer = Buffer.from(publicKey, \"base64\");\n\n // Convert X509 DER to PEM format for Node.js crypto\n const publicKeyPem = `-----BEGIN PUBLIC KEY-----\\n${publicKeyDer\n .toString(\"base64\")\n .match(/.{1,64}/g)\n ?.join(\"\\n\")}\\n-----END PUBLIC KEY-----`;\n\n // Create verify instance\n const verifier = crypto.createVerify(SIGN_ALGORITHMS);\n\n // Update with body bytes using specified charset\n verifier.update(body, charSet as BufferEncoding);\n\n // Decode signature from base64\n const signatureBuffer = Buffer.from(sign, \"base64\");\n\n // Verify signature\n return verifier.verify(publicKeyPem, signatureBuffer);\n } catch (e) {\n onError?.(e instanceof Error ? e : new Error(String(e)));\n return false;\n }\n}\n\n/**\n * Generates a new 2048-bit RSA key pair for Waffo API authentication.\n *\n * **Generated Key Formats:**\n * - Private key: Base64 encoded PKCS8 DER format (for signing)\n * - Public key: Base64 encoded X509/SPKI DER format (for verification)\n *\n * **Usage:**\n * 1. Generate a key pair using this function\n * 2. Register the public key with Waffo via merchant dashboard\n * 3. Store the private key securely on your server\n * 4. Use the private key when initializing the SDK\n *\n * **Security Notes:**\n * - Never expose the private key in client-side code\n * - Store privately (environment variables, secrets manager)\n * - Use different keys for sandbox/production\n *\n * @returns {{ PRIVATE_KEY_NAME: string, PUBLIC_KEY_NAME: string }} Generated key pair\n *\n * @example\n * // Generate a new key pair\n * const keys = createKeyPair();\n *\n * console.log('Private Key (store securely):');\n * console.log(keys.PRIVATE_KEY_NAME);\n *\n * console.log('Public Key (register with Waffo):');\n * console.log(keys.PUBLIC_KEY_NAME);\n *\n * @example\n * // Use the generated private key with SDK\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: keys.PRIVATE_KEY_NAME,\n * });\n *\n * @see {@link Waffo.generateKeyPair} for static access via Waffo class\n */\nexport function createKeyPair(): {\n PRIVATE_KEY_NAME: string;\n PUBLIC_KEY_NAME: string;\n} {\n // Generate RSA key pair with 2048-bit modulus\n const { publicKey, privateKey } = crypto.generateKeyPairSync(\"rsa\", {\n modulusLength: 2048,\n publicKeyEncoding: {\n type: \"spki\",\n format: \"der\",\n },\n privateKeyEncoding: {\n type: \"pkcs8\",\n format: \"der\",\n },\n });\n\n // Encode keys to base64\n const keyMap: { PRIVATE_KEY_NAME: string; PUBLIC_KEY_NAME: string } = {\n PRIVATE_KEY_NAME: (privateKey as Buffer).toString(\"base64\"),\n PUBLIC_KEY_NAME: (publicKey as Buffer).toString(\"base64\"),\n };\n\n return keyMap;\n}\n","/**\n * @fileoverview Webhook Utility Functions\n * @module utils/webhook\n *\n * Utility functions for handling Waffo webhook notifications:\n * - **{@link verifyWebhookSignature}** - Verify incoming webhook signatures\n * - **{@link buildWebhookResponse}** - Build signed webhook responses\n * - **{@link buildSuccessResponse}** - Shorthand for success responses\n * - **{@link buildFailedResponse}** - Shorthand for failure responses\n * - **Type guard functions** - Check notification types\n *\n * **Webhook Flow:**\n * 1. Receive webhook POST request from Waffo\n * 2. Verify the X-SIGNATURE header\n * 3. Process the notification based on event type\n * 4. Return a signed response\n *\n * @see {@link WebhookEventType} for notification types\n * @see {@link WebhookResponseStatus} for response statuses\n *\n * @example\n * import {\n * verifyWebhookSignature,\n * buildSuccessResponse,\n * isPaymentNotification,\n * } from 'waffo-sdk';\n *\n * // In your webhook handler\n * const result = verifyWebhookSignature(body, signature, waffoPublicKey);\n * if (result.isValid && isPaymentNotification(result.notification)) {\n * // Process payment notification\n * await processPayment(result.notification);\n * return buildSuccessResponse(merchantPrivateKey);\n * }\n */\n\nimport { signForRSA, verify } from \"./rsa\";\nimport {\n // Webhook base types\n WebhookEventType,\n WebhookResponseStatus,\n WebhookResponse,\n WebhookResponseBody,\n // Order notification types\n PaymentNotification,\n // Refund notification types\n RefundNotification,\n // Subscription notification types\n SubscriptionNotification,\n SubscriptionStatusNotification,\n SubscriptionPaymentNotification,\n SubscriptionEventType,\n} from \"../types\";\n\n/**\n * Union type representing all webhook notification types from Waffo.\n *\n * Use type guard functions to narrow down the specific type:\n * - {@link isPaymentNotification} - Payment notifications\n * - {@link isRefundNotification} - Refund notifications\n * - {@link isSubscriptionStatusNotification} - Subscription status changes\n * - {@link isSubscriptionPaymentNotification} - Subscription payments\n *\n * @typedef {PaymentNotification | RefundNotification | SubscriptionNotification} AnyWebhookNotification\n */\nexport type AnyWebhookNotification =\n | PaymentNotification\n | RefundNotification\n | SubscriptionNotification;\n\n/**\n * Result of webhook signature verification.\n *\n * Contains verification status and parsed notification data.\n *\n * @interface WebhookVerificationResult\n *\n * @example\n * const result = verifyWebhookSignature(body, signature, publicKey);\n * if (result.isValid) {\n * console.log('Event type:', result.eventType);\n * console.log('Notification:', result.notification);\n * } else {\n * console.error('Verification failed:', result.error);\n * }\n */\nexport interface WebhookVerificationResult {\n /** Whether the signature verification passed */\n isValid: boolean;\n /** Parsed notification data (only when isValid is true) */\n notification?: AnyWebhookNotification;\n /** Event type from the notification (only when isValid is true) */\n eventType?: WebhookEventType;\n /** Error message (only when isValid is false) */\n error?: string;\n}\n\n/**\n * Verifies the signature of a webhook notification from Waffo.\n *\n * @param {string} requestBody - Raw request body string (JSON)\n * @param {string} signature - X-SIGNATURE header value from Waffo\n * @param {string} waffoPublicKey - Waffo's public key (Base64 encoded X509 DER)\n * @returns {WebhookVerificationResult} Verification result with parsed notification\n *\n * @example\n * // Express.js webhook handler\n * app.post('/webhook', (req, res) => {\n * const result = verifyWebhookSignature(\n * JSON.stringify(req.body),\n * req.headers['x-signature'],\n * waffoPublicKey\n * );\n *\n * if (!result.isValid) {\n * console.error('Invalid signature:', result.error);\n * return res.status(400).send('Invalid signature');\n * }\n *\n * console.log('Event type:', result.eventType);\n * console.log('Notification:', result.notification);\n *\n * // Process notification...\n * });\n *\n * @see {@link WebhookVerificationResult} for return type\n */\nexport function verifyWebhookSignature(\n requestBody: string,\n signature: string,\n waffoPublicKey: string,\n): WebhookVerificationResult {\n try {\n // Verify signature\n const isValid = verify(requestBody, signature, waffoPublicKey);\n\n if (!isValid) {\n return {\n isValid: false,\n error: \"Signature verification failed\",\n };\n }\n\n // Parse notification\n const notification = JSON.parse(requestBody) as AnyWebhookNotification;\n const eventType = notification.eventType as WebhookEventType;\n\n return {\n isValid: true,\n notification,\n eventType,\n };\n } catch (error) {\n return {\n isValid: false,\n error: `Failed to verify webhook: ${(error as Error).message}`,\n };\n }\n}\n\n/**\n * Builds a properly signed webhook response to send back to Waffo.\n *\n * @param {WebhookResponseStatus} status - Response status (SUCCESS, FAILED, UNKNOWN)\n * @param {string} merchantPrivateKey - Merchant's private key (Base64 encoded PKCS8 DER)\n * @returns {WebhookResponse} Complete response with signed header\n * @throws {Error} \"Failed to sign webhook response\" when signing fails\n *\n * @example\n * // Build and send response\n * const response = buildWebhookResponse(\n * WebhookResponseStatus.SUCCESS,\n * merchantPrivateKey\n * );\n *\n * res.set(response.header).json(response.body);\n *\n * @example\n * // With error status\n * const response = buildWebhookResponse(\n * WebhookResponseStatus.FAILED,\n * merchantPrivateKey\n * );\n * // Waffo will retry the notification\n *\n * @see {@link buildSuccessResponse} for shorthand success response\n * @see {@link buildFailedResponse} for shorthand failure response\n */\nexport function buildWebhookResponse(\n status: WebhookResponseStatus,\n merchantPrivateKey: string,\n): WebhookResponse {\n const body: WebhookResponseBody = {\n message: status,\n };\n\n const bodyString = JSON.stringify(body);\n const signature = signForRSA(bodyString, merchantPrivateKey);\n\n if (!signature) {\n throw new Error(\"Failed to sign webhook response\");\n }\n\n return {\n header: {\n \"Content-Type\": \"application/json\",\n \"X-SIGNATURE\": signature,\n },\n body,\n };\n}\n\n/**\n * Builds a success webhook response (shorthand).\n *\n * Use when the notification was successfully processed.\n * Equivalent to `buildWebhookResponse(WebhookResponseStatus.SUCCESS, merchantPrivateKey)`.\n *\n * @param {string} merchantPrivateKey - Merchant's private key (Base64 encoded PKCS8 DER)\n * @returns {WebhookResponse} Response with SUCCESS status\n * @throws {Error} \"Failed to sign webhook response\" when signing fails\n *\n * @example\n * // After successful processing\n * const response = buildSuccessResponse(merchantPrivateKey);\n * res.set(response.header).json(response.body);\n *\n * @see {@link buildFailedResponse} for failure responses\n */\nexport function buildSuccessResponse(\n merchantPrivateKey: string,\n): WebhookResponse {\n return buildWebhookResponse(\n WebhookResponseStatus.SUCCESS,\n merchantPrivateKey,\n );\n}\n\n/**\n * Builds a failed webhook response (shorthand).\n *\n * Use when notification processing failed (database error, validation error, etc.).\n * **Waffo will retry the notification within 24 hours using exponential backoff.**\n *\n * Equivalent to `buildWebhookResponse(WebhookResponseStatus.FAILED, merchantPrivateKey)`.\n *\n * @param {string} merchantPrivateKey - Merchant's private key (Base64 encoded PKCS8 DER)\n * @returns {WebhookResponse} Response with FAILED status\n * @throws {Error} \"Failed to sign webhook response\" when signing fails\n *\n * @example\n * // When processing fails\n * try {\n * await processNotification(notification);\n * return buildSuccessResponse(merchantPrivateKey);\n * } catch (error) {\n * console.error('Processing failed:', error);\n * return buildFailedResponse(merchantPrivateKey);\n * // Waffo will retry later\n * }\n *\n * @see {@link buildSuccessResponse} for success responses\n */\nexport function buildFailedResponse(\n merchantPrivateKey: string,\n): WebhookResponse {\n return buildWebhookResponse(WebhookResponseStatus.FAILED, merchantPrivateKey);\n}\n\n/**\n * Extracts the event type from a webhook notification.\n *\n * Accepts either a parsed notification object or raw JSON string.\n *\n * @param {AnyWebhookNotification | string} notification - Parsed object or raw JSON\n * @returns {WebhookEventType | undefined} Event type, or `undefined` if invalid\n *\n * @example\n * // From parsed notification\n * const eventType = getWebhookEventType(notification);\n * // => 'PAYMENT_NOTIFICATION'\n *\n * @example\n * // From raw JSON string\n * const eventType = getWebhookEventType(requestBody);\n *\n * switch (eventType) {\n * case WebhookEventType.PAYMENT_NOTIFICATION:\n * handlePayment(notification);\n * break;\n * case WebhookEventType.REFUND_NOTIFICATION:\n * handleRefund(notification);\n * break;\n * }\n *\n * @see {@link WebhookEventType} for available event types\n */\nexport function getWebhookEventType(\n notification: AnyWebhookNotification | string,\n): WebhookEventType | undefined {\n try {\n const parsed =\n typeof notification === \"string\"\n ? (JSON.parse(notification) as AnyWebhookNotification)\n : notification;\n\n return parsed.eventType as WebhookEventType;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Type guard: checks if notification is a payment notification.\n *\n * Payment notifications are sent when a one-time/direct payment order status changes.\n * When this returns `true`, TypeScript narrows the type to {@link PaymentNotification}.\n *\n * @param {AnyWebhookNotification} notification - Notification to check\n * @returns {boolean} `true` if payment notification\n *\n * @example\n * if (isPaymentNotification(notification)) {\n * // TypeScript knows this is PaymentNotification\n * const { orderStatus, acquiringOrderId } = notification.result;\n * console.log(`Order ${acquiringOrderId}: ${orderStatus}`);\n * }\n *\n * @see {@link PaymentNotification} for the notification structure\n */\nexport function isPaymentNotification(\n notification: AnyWebhookNotification,\n): notification is PaymentNotification {\n return notification.eventType === WebhookEventType.PAYMENT_NOTIFICATION;\n}\n\n/**\n * Type guard: checks if notification is a refund notification.\n *\n * Refund notifications are sent when a refund order status changes.\n * When this returns `true`, TypeScript narrows the type to {@link RefundNotification}.\n *\n * @param {AnyWebhookNotification} notification - Notification to check\n * @returns {boolean} `true` if refund notification\n *\n * @example\n * if (isRefundNotification(notification)) {\n * // TypeScript knows this is RefundNotification\n * const { refundStatus, refundAmount } = notification.result;\n * console.log(`Refund status: ${refundStatus}, amount: ${refundAmount}`);\n * }\n *\n * @see {@link RefundNotification} for the notification structure\n */\nexport function isRefundNotification(\n notification: AnyWebhookNotification,\n): notification is RefundNotification {\n return notification.eventType === WebhookEventType.REFUND_NOTIFICATION;\n}\n\n/**\n * Type guard: checks if notification is a subscription status notification.\n *\n * Subscription status notifications are sent when subscription status changes\n * (ACTIVE, MERCHANT_CANCELLED, CHANNEL_CANCELLED, EXPIRED).\n * When this returns `true`, TypeScript narrows the type to {@link SubscriptionStatusNotification}.\n *\n * @param {AnyWebhookNotification} notification - Notification to check\n * @returns {boolean} `true` if subscription status notification\n *\n * @example\n * if (isSubscriptionStatusNotification(notification)) {\n * // TypeScript knows this is SubscriptionStatusNotification\n * const { subscriptionStatus, subscriptionId } = notification.result;\n * console.log(`Subscription ${subscriptionId}: ${subscriptionStatus}`);\n * }\n *\n * @see {@link SubscriptionStatusNotification} for the notification structure\n */\nexport function isSubscriptionStatusNotification(\n notification: AnyWebhookNotification,\n): notification is SubscriptionStatusNotification {\n return (\n notification.eventType ===\n SubscriptionEventType.SUBSCRIPTION_STATUS_NOTIFICATION\n );\n}\n\n/**\n * Type guard: checks if notification is a subscription payment notification.\n *\n * Subscription payment notifications are sent when a recurring payment is processed.\n * **Note:** Uses the same `PAYMENT_NOTIFICATION` event type as regular payments,\n * but includes `subscriptionId` in the result to distinguish them.\n *\n * When this returns `true`, TypeScript narrows the type to {@link SubscriptionPaymentNotification}.\n *\n * @param {AnyWebhookNotification} notification - Notification to check\n * @returns {boolean} `true` if subscription payment notification\n *\n * @example\n * if (isSubscriptionPaymentNotification(notification)) {\n * // TypeScript knows this is SubscriptionPaymentNotification\n * const { orderStatus, subscriptionInfo } = notification.result;\n * console.log(`Period ${subscriptionInfo.period}: ${orderStatus}`);\n * }\n *\n * @see {@link SubscriptionPaymentNotification} for the notification structure\n * @see {@link isPaymentNotification} for regular payment notifications\n */\nexport function isSubscriptionPaymentNotification(\n notification: AnyWebhookNotification,\n): notification is SubscriptionPaymentNotification {\n // Subscription payment uses PAYMENT_NOTIFICATION same as acquiring\n // Check for subscriptionId in result to distinguish from acquiring payment\n return (\n notification.eventType === SubscriptionEventType.PAYMENT_NOTIFICATION &&\n \"subscriptionId\" in notification.result\n );\n}\n","/**\n * @fileoverview HTTP Client for Waffo API Communication\n * @module core/httpClient\n *\n * Low-level HTTP client for communicating with the Waffo Payment Platform API.\n *\n * **Features:**\n * - Request signing using RSA-SHA256 algorithm\n * - Response signature verification for integrity\n * - Automatic timeout handling with AbortController\n * - Error handling and response parsing\n *\n * This client is used internally by all resource classes but can also be\n * accessed directly via `waffo.httpClient` for custom API requests.\n *\n * @see {@link Waffo} for the main SDK class\n * @see {@link ApiResponse} for the response format\n *\n * @example\n * // Direct usage through Waffo instance\n * const result = await waffo.httpClient.post('/custom/endpoint', {\n * body: { customField: 'value' },\n * });\n * if (result.success) {\n * console.log('Response:', result.data);\n * }\n */\n\nimport {\n WaffoConfig,\n RequestOptions,\n ApiResponse,\n HttpStatusCode,\n Environment,\n EnvironmentUrls,\n EnvironmentPublicKeys,\n Logger,\n} from \"../types\";\nimport { signForRSA, verify } from \"../utils\";\n\n/**\n * Internal configuration for HttpClient after processing WaffoConfig.\n *\n * @interface HttpClientConfig\n * @internal\n */\ninterface HttpClientConfig {\n /** API key for X-API-KEY header authentication */\n apiKey: string;\n /** Merchant private key for request signing (Base64 encoded PKCS8 DER) */\n privateKey: string;\n /** Waffo public key for response verification (Base64 encoded X509 DER) */\n waffoPublicKey: string;\n /** Resolved API base URL for the environment */\n baseUrl: string;\n /** Request timeout in milliseconds */\n timeout: number;\n /** Optional logger instance for debugging */\n logger?: Logger;\n}\n\n/**\n * Low-level HTTP client for Waffo API communication.\n *\n * Handles all aspects of API communication:\n * - **Request Signing**: Automatically signs request bodies using RSA-SHA256\n * - **Response Verification**: Verifies response signatures for data integrity\n * - **Timeout Handling**: Uses AbortController for reliable timeout management\n * - **Error Handling**: Parses errors and wraps them in consistent response format\n *\n * @class HttpClient\n * @internal Primarily for internal SDK use\n *\n * @example\n * // Typically accessed through Waffo instance\n * const result = await waffo.httpClient.post<CustomResponse>('/custom/endpoint', {\n * body: { field: 'value' },\n * });\n *\n * @see {@link ApiResponse} for the response format\n * @see {@link RequestOptions} for request configuration\n */\nexport class HttpClient {\n /** @private */\n private config: HttpClientConfig;\n\n /**\n * Creates an HTTP client instance with the provided SDK configuration.\n *\n * Resolves environment-specific settings such as API base URL and public key.\n *\n * @param {WaffoConfig} config - Waffo SDK configuration object\n * @param {string} config.apiKey - API key assigned by Waffo\n * @param {string} config.privateKey - Merchant private key (Base64 encoded PKCS8 DER)\n * @param {string} [config.waffoPublicKey] - Waffo public key for response verification\n * @param {Environment} [config.environment=Environment.PRODUCTION] - API environment\n * @param {number} [config.timeout=30000] - Request timeout in milliseconds\n * @param {Logger} [config.logger] - Logger instance for debugging\n *\n * @example\n * const client = new HttpClient({\n * apiKey: 'your-api-key',\n * privateKey: 'your-private-key',\n * environment: Environment.SANDBOX,\n * });\n *\n * @see {@link WaffoConfig} for configuration options\n */\n constructor(config: WaffoConfig) {\n const environment = config.environment || Environment.PRODUCTION;\n\n this.config = {\n apiKey: config.apiKey,\n privateKey: config.privateKey,\n waffoPublicKey:\n config.waffoPublicKey || EnvironmentPublicKeys[environment],\n baseUrl: EnvironmentUrls[environment],\n timeout: config.timeout || 30000,\n logger: config.logger,\n };\n\n this.config.logger?.debug(\"[Waffo SDK] HttpClient initialized\", {\n environment,\n baseUrl: this.config.baseUrl,\n timeout: this.config.timeout,\n });\n }\n\n /**\n * Generates an RSA-SHA256 signature for the request body.\n *\n * @param {string} payload - Request body string to sign (JSON serialized)\n * @returns {string} Base64 encoded RSA-SHA256 signature\n * @throws {Error} \"Failed to generate RSA signature\" when signing fails\n * @private\n */\n private generateSignature(payload: string): string {\n const signature = signForRSA(payload, this.config.privateKey);\n if (!signature) {\n throw new Error(\"Failed to generate RSA signature\");\n }\n return signature;\n }\n\n /**\n * Verifies the RSA-SHA256 signature of the response body.\n *\n * Ensures the response has not been tampered with during transmission.\n *\n * @param {string} responseBody - Response body string (raw JSON)\n * @param {string} signature - X-SIGNATURE header value (Base64 encoded)\n * @returns {boolean} `true` if signature is valid, `false` otherwise\n * @private\n */\n private verifyResponseSignature(\n responseBody: string,\n signature: string,\n ): boolean {\n return verify(responseBody, signature, this.config.waffoPublicKey);\n }\n\n /**\n * Sends an HTTP POST request with automatic signing and verification.\n *\n * **Request Flow:**\n * 1. Serializes the request body to JSON\n * 2. Signs the request body using RSA-SHA256\n * 3. Sends the request with X-API-KEY and X-SIGNATURE headers\n * 4. Verifies the response signature using Waffo's public key\n * 5. Parses and returns the response in standardized format\n *\n * **Error Handling:**\n * - Network errors: `{ success: false, error: message }`\n * - Timeout: status code 408 (REQUEST_TIMEOUT)\n * - Invalid signature: returns error\n * - Business errors (code !== \"0\"): parsed and returned as errors\n *\n * @template T - Expected response data type\n * @template B - Request body type (must extend object)\n *\n * @param {string} endpoint - API endpoint path (e.g., '/order/create')\n * @param {RequestOptions<B>} [options={}] - Request options\n * @param {B} [options.body] - Request body object (will be JSON serialized)\n * @param {Record<string, string>} [options.headers] - Additional request headers\n *\n * @returns {Promise<ApiResponse<T>>} Response object with success status and data/error\n *\n * @example\n * // Make a POST request\n * const result = await httpClient.post<CreateOrderData>('/order/create', {\n * body: {\n * paymentRequestId: 'req-123',\n * merchantOrderId: 'order-456',\n * // ... other fields\n * },\n * });\n *\n * if (result.success) {\n * console.log('Order created:', result.data.acquiringOrderId);\n * } else {\n * console.error('Error:', result.error);\n * }\n *\n * @example\n * // Handle timeout errors\n * const result = await httpClient.post('/order/create', { body: params });\n * if (!result.success && result.statusCode === HttpStatusCode.REQUEST_TIMEOUT) {\n * console.log('Request timed out, please retry');\n * }\n *\n * @see {@link ApiResponse} for the response format\n * @see {@link RequestOptions} for request options\n */\n async post<T, B extends object = Record<string, unknown>>(\n endpoint: string,\n options: RequestOptions<B> = {},\n ): Promise<ApiResponse<T>> {\n const { body, headers = {} } = options;\n const payload = body ? JSON.stringify(body) : \"\";\n const signature = this.generateSignature(payload);\n const url = `${this.config.baseUrl}${endpoint}`;\n\n this.config.logger?.debug(\"[Waffo SDK] Sending request\", {\n method: \"POST\",\n url,\n body: body,\n });\n\n // Setup timeout using AbortController\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-KEY\": this.config.apiKey,\n \"X-SIGNATURE\": signature,\n ...headers,\n },\n body: payload || undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const statusCode = response.status as HttpStatusCode;\n const responseSignature = response.headers.get(\"X-SIGNATURE\");\n const responseBody = await response.text();\n\n this.config.logger?.debug(\"[Waffo SDK] Received response\", {\n statusCode,\n hasSignature: !!responseSignature,\n body: responseBody,\n });\n\n // Verify response signature\n if (!responseSignature) {\n this.config.logger?.warn(\n \"[Waffo SDK] Missing X-SIGNATURE in response headers\",\n );\n return {\n success: false,\n statusCode,\n error: \"Missing X-SIGNATURE in response headers\",\n };\n }\n\n const isValid = this.verifyResponseSignature(\n responseBody,\n responseSignature,\n );\n if (!isValid) {\n this.config.logger?.warn(\"[Waffo SDK] Invalid response signature\");\n return {\n success: false,\n statusCode,\n error: \"Invalid response signature\",\n };\n }\n\n // Parse response body - Waffo API returns { code, msg, data } format or raw data T\n let parsedBody: { code?: string; msg?: string; data?: T } | T | null =\n null;\n try {\n parsedBody = JSON.parse(responseBody);\n } catch {\n // If parsing fails, continue with generic error\n }\n\n // Helper to check if parsed body is Waffo API response format\n const isWaffoFormat = (\n body: typeof parsedBody,\n ): body is { code?: string; msg?: string; data?: T } => {\n return body !== null && typeof body === \"object\" && \"code\" in body;\n };\n\n if (!response.ok) {\n // Include detailed error message from API response\n const errorMsg =\n isWaffoFormat(parsedBody) && parsedBody.msg\n ? `[${parsedBody.code}] ${parsedBody.msg}`\n : `HTTP ${response.status}: ${response.statusText}`;\n this.config.logger?.error(\"[Waffo SDK] HTTP error\", {\n statusCode,\n error: errorMsg,\n });\n return {\n success: false,\n statusCode,\n error: errorMsg,\n };\n }\n\n // Check if response indicates business error (code !== \"0\")\n if (\n isWaffoFormat(parsedBody) &&\n parsedBody.code &&\n parsedBody.code !== \"0\"\n ) {\n const errorMsg = `[${parsedBody.code}] ${parsedBody.msg || \"Unknown error\"}`;\n this.config.logger?.error(\"[Waffo SDK] Business error\", {\n code: parsedBody.code,\n msg: parsedBody.msg,\n });\n return {\n success: false,\n statusCode,\n error: errorMsg,\n };\n }\n\n // Extract the actual business data from the nested structure\n const data = isWaffoFormat(parsedBody)\n ? parsedBody.data\n : (parsedBody as T);\n this.config.logger?.debug(\"[Waffo SDK] Request successful\", { data });\n return { success: true, statusCode, data };\n } catch (error) {\n clearTimeout(timeoutId);\n\n // Check for timeout (abort) error\n if (error instanceof Error && error.name === \"AbortError\") {\n this.config.logger?.error(\"[Waffo SDK] Request timeout\", {\n timeout: this.config.timeout,\n url,\n });\n return {\n success: false,\n statusCode: HttpStatusCode.REQUEST_TIMEOUT,\n error: `Request timeout after ${this.config.timeout}ms`,\n };\n }\n\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n this.config.logger?.error(\"[Waffo SDK] Request failed\", {\n error: errorMessage,\n url,\n });\n return {\n success: false,\n statusCode: HttpStatusCode.INTERNAL_SERVER_ERROR,\n error: errorMessage,\n };\n }\n }\n}\n","/**\n * @fileoverview Webhook Handler for Waffo Webhook Notifications\n * @module core/webhook\n *\n * Provides the WebhookHandler class for processing incoming webhook\n * notifications from the Waffo Payment Platform.\n *\n * **Features:**\n * - Signature verification using Waffo's public key\n * - Response signing using merchant's private key\n * - Event type routing to appropriate handlers\n * - Error handling and response formatting\n *\n * @see {@link Waffo} for the main SDK class\n * @see {@link WebhookHandlerOptions} for handler configuration\n *\n * @example\n * // Express.js webhook endpoint\n * app.post('/webhook', async (req, res) => {\n * const result = await waffo.webhook.handle(\n * JSON.stringify(req.body),\n * req.headers['x-signature'],\n * {\n * onPayment: async ({ notification }) => {\n * console.log('Payment:', notification.result.orderStatus);\n * },\n * onRefund: async ({ notification }) => {\n * console.log('Refund:', notification.result.refundStatus);\n * },\n * }\n * );\n * res.set(result.response.header).json(result.response.body);\n * });\n */\n\nimport {\n WaffoConfig,\n WebhookHandlerOptions,\n WebhookHandlerResult,\n WebhookResponseStatus,\n Environment,\n EnvironmentPublicKeys,\n} from \"../types\";\nimport {\n verifyWebhookSignature,\n buildWebhookResponse,\n isPaymentNotification,\n isRefundNotification,\n isSubscriptionStatusNotification,\n isSubscriptionPaymentNotification,\n} from \"../utils\";\n\n/**\n * Internal configuration for WebhookHandler.\n *\n * @interface WebhookHandlerInternalConfig\n * @internal\n */\ninterface WebhookHandlerInternalConfig {\n /** Merchant private key for signing responses (Base64 encoded PKCS8 DER) */\n privateKey: string;\n /** Waffo public key for verifying requests (Base64 encoded X509 DER) */\n waffoPublicKey: string;\n}\n\n/**\n * Handles incoming webhook notifications from the Waffo Payment Platform.\n *\n * **Features:**\n * - Signature verification using Waffo's public key\n * - Event routing to appropriate handlers based on event type\n * - Response signing using merchant's private key\n * - Consistent error handling and response formatting\n *\n * Accessed via `waffo.webhook` after SDK initialization.\n *\n * @class WebhookHandler\n *\n * @example\n * // Handle different notification types\n * const result = await waffo.webhook.handle(requestBody, signature, {\n * onPayment: async (ctx) => {\n * const { orderStatus, acquiringOrderId } = ctx.notification.result;\n * if (orderStatus === 'PAY_SUCCESS') {\n * await fulfillOrder(acquiringOrderId);\n * }\n * },\n * onRefund: async (ctx) => {\n * const { refundStatus, acquiringRefundOrderId } = ctx.notification.result;\n * await updateRefundStatus(acquiringRefundOrderId, refundStatus);\n * },\n * onSubscriptionStatus: async (ctx) => {\n * const { subscriptionStatus, subscriptionId } = ctx.notification.result;\n * await updateSubscription(subscriptionId, subscriptionStatus);\n * },\n * onError: async (error) => {\n * console.error('Webhook error:', error.message);\n * },\n * });\n *\n * @see {@link WebhookHandlerOptions} for handler configuration\n * @see {@link WebhookHandlerResult} for return type\n */\nexport class WebhookHandler {\n /** @private */\n private config: WebhookHandlerInternalConfig;\n\n /**\n * Creates a webhook handler instance.\n *\n * Initializes the handler with SDK configuration and resolves\n * environment-specific settings such as Waffo's public key.\n *\n * @param {WaffoConfig} config - Waffo SDK configuration object\n * @param {string} config.privateKey - Merchant private key (Base64 encoded PKCS8 DER)\n * @param {string} [config.waffoPublicKey] - Waffo public key for request verification\n * @param {Environment} [config.environment=Environment.PRODUCTION] - API environment\n *\n * @example\n * // Typically created automatically by Waffo SDK\n * const waffo = new Waffo(config);\n * // Access via: waffo.webhook\n *\n * @see {@link WaffoConfig} for configuration options\n */\n constructor(config: WaffoConfig) {\n const environment = config.environment || Environment.PRODUCTION;\n\n this.config = {\n privateKey: config.privateKey,\n waffoPublicKey:\n config.waffoPublicKey || EnvironmentPublicKeys[environment],\n };\n }\n\n /**\n * Processes an incoming webhook notification from Waffo.\n *\n * **Processing Flow:**\n * 1. Verifies the request signature using Waffo's public key\n * 2. Parses the notification and determines its type\n * 3. Routes to the appropriate handler based on event type\n * 4. Returns a signed response to acknowledge receipt\n *\n * **Supported Event Types:**\n * - `PAYMENT_NOTIFICATION` - Payment order status changes\n * - `REFUND_NOTIFICATION` - Refund status changes\n * - `SUBSCRIPTION_STATUS_NOTIFICATION` - Subscription status changes\n * - `PAYMENT_NOTIFICATION` with subscriptionId - Subscription payments\n *\n * @param {string} requestBody - Raw request body string (JSON)\n * @param {string} signature - X-SIGNATURE header value from Waffo\n * @param {WebhookHandlerOptions} options - Handler configuration options\n *\n * @returns {Promise<WebhookHandlerResult>} Result with success status and signed response\n *\n * @example\n * // Express.js endpoint\n * app.post('/webhook', async (req, res) => {\n * const result = await waffo.webhook.handle(\n * JSON.stringify(req.body),\n * req.headers['x-signature'],\n * {\n * onPayment: async ({ notification }) => {\n * const { orderStatus, acquiringOrderId } = notification.result;\n * await db.orders.updateStatus(acquiringOrderId, orderStatus);\n * },\n * onRefund: async ({ notification }) => {\n * const { refundStatus } = notification.result;\n * await db.refunds.update(notification.result);\n * },\n * onSubscriptionStatus: async ({ notification }) => {\n * await db.subscriptions.update(notification.result);\n * },\n * onSubscriptionPayment: async ({ notification }) => {\n * await db.payments.create(notification.result);\n * },\n * onError: async (error) => {\n * logger.error('Webhook error', error);\n * },\n * }\n * );\n *\n * // Return signed response to Waffo\n * res.set(result.response.header).json(result.response.body);\n * });\n *\n * @example\n * // Next.js API route\n * export async function POST(request: Request) {\n * const body = await request.text();\n * const signature = request.headers.get('x-signature') || '';\n *\n * const result = await waffo.webhook.handle(body, signature, {\n * onPayment: async (ctx) => { ... },\n * });\n *\n * return new Response(JSON.stringify(result.response.body), {\n * headers: result.response.header,\n * });\n * }\n *\n * @see {@link WebhookHandlerOptions} for handler configuration\n * @see {@link WebhookHandlerResult} for return type\n */\n async handle(\n requestBody: string,\n signature: string,\n options: WebhookHandlerOptions = {},\n ): Promise<WebhookHandlerResult> {\n const {\n onPayment,\n onRefund,\n onSubscriptionStatus,\n onSubscriptionPayment,\n onError,\n } = options;\n\n try {\n // Verify webhook signature\n const verificationResult = verifyWebhookSignature(\n requestBody,\n signature,\n this.config.waffoPublicKey,\n );\n\n if (!verificationResult.isValid) {\n const error = new Error(\n verificationResult.error || \"Signature verification failed\",\n );\n await onError?.(error);\n return {\n success: false,\n response: buildWebhookResponse(\n WebhookResponseStatus.FAILED,\n this.config.privateKey,\n ),\n error: verificationResult.error,\n };\n }\n\n const { notification, eventType } = verificationResult;\n\n if (!notification || !eventType) {\n const error = new Error(\"Invalid notification format\");\n await onError?.(error);\n return {\n success: false,\n response: buildWebhookResponse(\n WebhookResponseStatus.FAILED,\n this.config.privateKey,\n ),\n error: \"Invalid notification format\",\n };\n }\n\n // Route to appropriate handler based on event type\n if (isSubscriptionPaymentNotification(notification)) {\n // Subscription payment notification (uses PAYMENT_NOTIFICATION event type)\n await onSubscriptionPayment?.({\n notification,\n rawBody: requestBody,\n eventType,\n });\n } else if (isPaymentNotification(notification)) {\n // Regular payment notification\n await onPayment?.({\n notification,\n rawBody: requestBody,\n eventType,\n });\n } else if (isRefundNotification(notification)) {\n // Refund notification\n await onRefund?.({\n notification,\n rawBody: requestBody,\n eventType,\n });\n } else if (isSubscriptionStatusNotification(notification)) {\n // Subscription status notification\n await onSubscriptionStatus?.({\n notification,\n rawBody: requestBody,\n eventType,\n });\n }\n\n // Return success response\n return {\n success: true,\n response: buildWebhookResponse(\n WebhookResponseStatus.SUCCESS,\n this.config.privateKey,\n ),\n };\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n await onError?.(err);\n return {\n success: false,\n response: buildWebhookResponse(\n WebhookResponseStatus.FAILED,\n this.config.privateKey,\n ),\n error: err.message,\n };\n }\n }\n}\n","/**\n * @fileoverview Base Resource Class\n * @module resources/base\n *\n * Abstract base class for all API resource classes.\n * Defines common structure and dependencies shared by all resources.\n *\n * **Resource Inheritance:**\n * - {@link OrderResource} - Order operations\n * - {@link RefundResource} - Refund operations\n * - {@link SubscriptionResource} - Subscription operations\n * - {@link MerchantConfigResource} - Merchant config operations\n * - {@link PayMethodConfigResource} - Payment method config operations\n *\n * @internal For internal SDK use only\n */\n\nimport { HttpClient } from \"../core\";\n\n/**\n * Abstract base class for all API resources in the Waffo SDK.\n *\n * Provides common foundation for all resource classes:\n * - HTTP client reference for making API requests\n * - Base path configuration for API endpoints\n *\n * @abstract\n * @class BaseResource\n * @internal For internal SDK use only\n *\n * @see {@link OrderResource} for order operations\n * @see {@link RefundResource} for refund operations\n * @see {@link SubscriptionResource} for subscription operations\n */\nexport abstract class BaseResource {\n /**\n * HTTP client for making API requests with automatic signing.\n * @protected\n */\n protected client: HttpClient;\n\n /**\n * Base path for API endpoints (e.g., '/order', '/refund').\n * @protected\n */\n protected basePath: string;\n\n /**\n * Initializes the base resource with HTTP client and base path.\n *\n * @param {HttpClient} client - HTTP client instance\n * @param {string} basePath - Base path for API endpoints\n * @protected\n */\n constructor(client: HttpClient, basePath: string) {\n this.client = client;\n this.basePath = basePath;\n }\n}\n","/**\n * @fileoverview Order Resource Implementation\n * @module resources/order/resource\n *\n * Implements the Order resource class providing all order-related API operations.\n *\n * @see {@link OrderResource} for the main class\n * @see {@link CreateOrderParams} for order creation parameters\n *\n * @example\n * // Access via Waffo instance\n * const result = await waffo.order.create({\n * paymentRequestId: 'req-123',\n * merchantOrderId: 'order-456',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * // ... other required fields\n * });\n */\n\nimport { ApiResponse } from \"../../types\";\nimport { HttpClient } from \"../../core\";\nimport { BaseResource } from \"../base\";\nimport {\n CreateOrderParams,\n CreateOrderData,\n InquiryOrderParams,\n InquiryOrderData,\n CancelOrderParams,\n CancelOrderData,\n CaptureOrderParams,\n CaptureOrderData,\n RefundOrderParams,\n} from \"./types\";\nimport { CreateRefundData } from \"../refund/types\";\n\n/**\n * Order resource for all payment order operations.\n *\n * Provides methods for creating, querying, canceling, refunding,\n * and capturing payment orders.\n *\n * @class OrderResource\n * @extends BaseResource\n *\n * @example\n * // Create an order\n * const createResult = await waffo.order.create({ ... });\n *\n * // Query order status\n * const inquiryResult = await waffo.order.inquiry({\n * acquiringOrderId: createResult.data.acquiringOrderId,\n * });\n *\n * // Request a refund\n * const refundResult = await waffo.order.refund({\n * refundRequestId: 'refund-123',\n * acquiringOrderId: createResult.data.acquiringOrderId,\n * merchantId: 'M001',\n * refundAmount: '5.00',\n * refundReason: 'Customer request',\n * });\n */\nexport class OrderResource extends BaseResource {\n /**\n * Creates an Order resource instance.\n * @param {HttpClient} client - HTTP client instance\n */\n constructor(client: HttpClient) {\n super(client, \"/order\");\n }\n\n /**\n * Creates a new payment order.\n *\n * Supports multiple payment methods including e-wallet, credit card,\n * bank transfer, and more.\n *\n * @param {CreateOrderParams} params - Order creation parameters\n * @returns {Promise<ApiResponse<CreateOrderData>>} Order creation result\n *\n * @example\n * const result = await waffo.order.create({\n * paymentRequestId: 'req-' + Date.now(),\n * merchantOrderId: 'order-456',\n * orderCurrency: 'IDR',\n * orderAmount: '100000',\n * orderDescription: 'Product purchase',\n * merchantInfo: { merchantId: 'M001' },\n * userInfo: {\n * userId: 'U001',\n * userEmail: 'user@example.com',\n * userTerminal: 'WEB',\n * },\n * goodsInfo: {\n * goodsName: 'Premium Plan',\n * goodsUrl: 'https://example.com/product',\n * },\n * paymentInfo: {\n * productName: 'ONE_TIME_PAYMENT',\n * payMethodName: 'DANA',\n * },\n * notifyUrl: 'https://example.com/webhook',\n * successRedirectUrl: 'https://example.com/success',\n * });\n *\n * if (result.success) {\n * // Redirect user to payment page\n * const redirectUrl = result.data.orderAction?.webUrl;\n * }\n *\n * @see {@link CreateOrderParams} for all available parameters\n */\n async create(\n params: CreateOrderParams,\n ): Promise<ApiResponse<CreateOrderData>> {\n const body = {\n ...params,\n orderRequestedAt: params.orderRequestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CreateOrderData, CreateOrderParams>(\n `${this.basePath}/create`,\n { body },\n );\n }\n\n /**\n * Queries current order status and details.\n *\n * Provide either `paymentRequestId` or `acquiringOrderId` to identify the order.\n *\n * @param {InquiryOrderParams} params - Query parameters\n * @returns {Promise<ApiResponse<InquiryOrderData>>} Order details\n *\n * @example\n * // Query by acquiring order ID\n * const result = await waffo.order.inquiry({\n * acquiringOrderId: 'ACQ123456789',\n * });\n *\n * if (result.success) {\n * console.log('Order status:', result.data.orderStatus);\n * console.log('Amount:', result.data.orderAmount, result.data.orderCurrency);\n * }\n *\n * @example\n * // Query by payment request ID\n * const result = await waffo.order.inquiry({\n * paymentRequestId: 'req-123',\n * });\n *\n * @see {@link InquiryOrderData} for response structure\n */\n async inquiry(\n params: InquiryOrderParams,\n ): Promise<ApiResponse<InquiryOrderData>> {\n return this.client.post<InquiryOrderData, InquiryOrderParams>(\n `${this.basePath}/inquiry`,\n { body: params },\n );\n }\n\n /**\n * Cancels an unpaid order.\n *\n * Only orders with status `AUTHORIZATION_REQUIRED` or `PAY_IN_PROGRESS` can be canceled.\n *\n * @param {CancelOrderParams} params - Cancel parameters\n * @returns {Promise<ApiResponse<CancelOrderData>>} Cancellation result\n *\n * @example\n * const result = await waffo.order.cancel({\n * acquiringOrderId: 'ACQ123456789',\n * merchantId: 'M001',\n * });\n *\n * if (result.success) {\n * console.log('Order canceled:', result.data.orderStatus);\n * // => 'ORDER_CLOSE'\n * }\n *\n * @see {@link CancelOrderData} for response structure\n */\n async cancel(\n params: CancelOrderParams,\n ): Promise<ApiResponse<CancelOrderData>> {\n const body = {\n ...params,\n orderRequestedAt: params.orderRequestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CancelOrderData, CancelOrderParams>(\n `${this.basePath}/cancel`,\n { body },\n );\n }\n\n /**\n * Initiates a refund request for a paid order.\n *\n * Supports both full and partial refunds. Multiple partial refunds can be\n * made until the total refunded amount equals the original order amount.\n *\n * @param {RefundOrderParams} params - Refund parameters\n * @returns {Promise<ApiResponse<CreateRefundData>>} Refund request result\n *\n * @example\n * // Full refund\n * const result = await waffo.order.refund({\n * refundRequestId: 'refund-' + Date.now(),\n * acquiringOrderId: 'ACQ123456789',\n * merchantId: 'M001',\n * refundAmount: '100000',\n * refundReason: 'Customer request',\n * refundNotifyUrl: 'https://example.com/refund-webhook',\n * });\n *\n * if (result.success) {\n * console.log('Refund status:', result.data.refundStatus);\n * console.log('Remaining refundable:', result.data.remainingRefundAmount);\n * }\n *\n * @example\n * // Partial refund\n * const result = await waffo.order.refund({\n * refundRequestId: 'refund-partial-123',\n * acquiringOrderId: 'ACQ123456789',\n * merchantId: 'M001',\n * refundAmount: '50000', // Partial amount\n * refundReason: 'Partial refund',\n * });\n *\n * @see {@link CreateRefundData} for response structure\n */\n async refund(\n params: RefundOrderParams,\n ): Promise<ApiResponse<CreateRefundData>> {\n const body = {\n ...params,\n requestedAt: params.requestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CreateRefundData, RefundOrderParams>(\n `${this.basePath}/refund`,\n { body },\n );\n }\n\n /**\n * Captures an authorized payment (manualCapture mode only).\n *\n * Converts an authorization to an actual charge. Supports both\n * partial and full capture amounts.\n *\n * @param {CaptureOrderParams} params - Capture parameters\n * @returns {Promise<ApiResponse<CaptureOrderData>>} Capture result\n *\n * @example\n * // Full capture\n * const result = await waffo.order.capture({\n * acquiringOrderId: 'ACQ123456789',\n * merchantId: 'M001',\n * captureAmount: '100000', // Full authorized amount\n * });\n *\n * if (result.success) {\n * console.log('Capture status:', result.data.orderStatus);\n * }\n *\n * @example\n * // Partial capture\n * const result = await waffo.order.capture({\n * acquiringOrderId: 'ACQ123456789',\n * merchantId: 'M001',\n * captureAmount: '75000', // Capture less than authorized\n * });\n *\n * @see {@link CaptureOrderData} for response structure\n */\n async capture(\n params: CaptureOrderParams,\n ): Promise<ApiResponse<CaptureOrderData>> {\n const body = {\n ...params,\n captureRequestedAt: params.captureRequestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CaptureOrderData, CaptureOrderParams>(\n `${this.basePath}/capture`,\n { body },\n );\n }\n}\n","/**\n * @fileoverview Refund Resource Implementation\n * @module resources/refund/resource\n *\n * Implements the Refund resource class providing refund inquiry operations.\n *\n * @see {@link RefundResource} for the main class\n * @see {@link RefundInquiryParams} for inquiry parameters\n *\n * @example\n * // Query refund status\n * const result = await waffo.refund.inquiry({\n * refundRequestId: 'refund-123',\n * });\n */\n\nimport { ApiResponse } from \"../../types\";\nimport { HttpClient } from \"../../core\";\nimport { BaseResource } from \"../base\";\nimport { RefundInquiryParams, InquiryRefundData } from \"./types\";\n\n/**\n * Refund resource for querying refund status and details.\n *\n * Note: Refund creation is done through {@link OrderResource.refund}.\n *\n * @class RefundResource\n * @extends BaseResource\n *\n * @example\n * const result = await waffo.refund.inquiry({\n * acquiringRefundOrderId: 'REF123456789',\n * });\n *\n * if (result.success) {\n * console.log('Refund status:', result.data.refundStatus);\n * }\n */\nexport class RefundResource extends BaseResource {\n /**\n * Creates a Refund resource instance.\n * @param {HttpClient} client - HTTP client instance\n */\n constructor(client: HttpClient) {\n super(client, \"/refund\");\n }\n\n /**\n * Queries current refund status and details.\n *\n * Provide either `refundRequestId` or `acquiringRefundOrderId` to identify the refund.\n *\n * @param {RefundInquiryParams} params - Query parameters\n * @returns {Promise<ApiResponse<InquiryRefundData>>} Refund details\n *\n * @example\n * // Query by refund request ID\n * const result = await waffo.refund.inquiry({\n * refundRequestId: 'refund-123',\n * });\n *\n * if (result.success) {\n * const { refundStatus, refundAmount, remainingRefundAmount } = result.data;\n * console.log(`Status: ${refundStatus}`);\n * console.log(`Refunded: ${refundAmount}`);\n * console.log(`Remaining: ${remainingRefundAmount}`);\n * }\n *\n * @example\n * // Query by acquiring refund order ID\n * const result = await waffo.refund.inquiry({\n * acquiringRefundOrderId: 'REF123456789',\n * });\n *\n * @see {@link InquiryRefundData} for response structure\n */\n async inquiry(\n params: RefundInquiryParams,\n ): Promise<ApiResponse<InquiryRefundData>> {\n return this.client.post<InquiryRefundData, RefundInquiryParams>(\n `${this.basePath}/inquiry`,\n { body: params },\n );\n }\n}\n","/**\n * @fileoverview Subscription Resource Implementation\n * @module resources/subscription/resource\n *\n * Implements the Subscription resource class providing all subscription-related\n * API operations for recurring payments.\n *\n * @see {@link SubscriptionResource} for the main class\n * @see {@link CreateSubscriptionParams} for subscription creation parameters\n *\n * @example\n * // Create a subscription\n * const result = await waffo.subscription.create({\n * subscriptionRequest: 'sub-req-123',\n * currency: 'USD',\n * amount: '9.99',\n * productInfo: {\n * description: 'Monthly Premium',\n * periodType: 'MONTHLY',\n * periodInterval: '1',\n * },\n * // ... other required fields\n * });\n */\n\nimport { ApiResponse } from \"../../types\";\nimport { HttpClient } from \"../../core\";\nimport { BaseResource } from \"../base\";\nimport {\n CreateSubscriptionParams,\n CreateSubscriptionData,\n InquirySubscriptionParams,\n InquirySubscriptionData,\n CancelSubscriptionParams,\n CancelSubscriptionData,\n ManageSubscriptionParams,\n ManageSubscriptionData,\n} from \"./types\";\n\n/**\n * Subscription resource for recurring payment operations.\n *\n * Provides methods for creating, querying, canceling, and managing subscriptions.\n *\n * @class SubscriptionResource\n * @extends BaseResource\n *\n * @example\n * // Full subscription lifecycle\n * const createResult = await waffo.subscription.create({ ... });\n * const inquiryResult = await waffo.subscription.inquiry({\n * subscriptionId: createResult.data.subscriptionId,\n * });\n * const cancelResult = await waffo.subscription.cancel({\n * subscriptionId: createResult.data.subscriptionId,\n * merchantId: 'M001',\n * });\n */\nexport class SubscriptionResource extends BaseResource {\n /**\n * Creates a Subscription resource instance.\n * @param {HttpClient} client - HTTP client instance\n */\n constructor(client: HttpClient) {\n super(client, \"/subscription\");\n }\n\n /**\n * Creates a new subscription signing request for recurring payments.\n *\n * After creation, redirect the user to the signing URL to authorize\n * the recurring payment agreement.\n *\n * @param {CreateSubscriptionParams} params - Subscription creation parameters\n * @returns {Promise<ApiResponse<CreateSubscriptionData>>} Subscription creation result\n *\n * @example\n * const result = await waffo.subscription.create({\n * subscriptionRequest: 'sub-' + Date.now(),\n * currency: 'HKD',\n * amount: '99.00',\n * productInfo: {\n * description: 'Premium Monthly Plan',\n * periodType: 'MONTHLY',\n * periodInterval: '1',\n * numberOfPeriod: '12', // 12 months\n * },\n * merchantInfo: { merchantId: 'M001' },\n * userInfo: {\n * userId: 'U001',\n * userEmail: 'user@example.com',\n * },\n * goodsInfo: {\n * goodsId: 'PREMIUM-PLAN',\n * goodsName: 'Premium Plan',\n * goodsUrl: 'https://example.com/plan',\n * },\n * paymentInfo: {\n * productName: 'SUBSCRIPTION',\n * payMethodName: 'ALIPAY_HK',\n * },\n * notifyUrl: 'https://example.com/webhook',\n * successRedirectUrl: 'https://example.com/success',\n * });\n *\n * if (result.success) {\n * // Redirect user to subscription signing page\n * const signingUrl = result.data.subscriptionAction?.webUrl;\n * }\n *\n * @see {@link CreateSubscriptionData} for response structure\n */\n async create(\n params: CreateSubscriptionParams,\n ): Promise<ApiResponse<CreateSubscriptionData>> {\n const body = {\n ...params,\n requestedAt: params.requestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CreateSubscriptionData, CreateSubscriptionParams>(\n `${this.basePath}/create`,\n { body },\n );\n }\n\n /**\n * Queries subscription details and optionally payment history.\n *\n * @param {InquirySubscriptionParams} params - Query parameters\n * @returns {Promise<ApiResponse<InquirySubscriptionData>>} Subscription details\n *\n * @example\n * // Query subscription status\n * const result = await waffo.subscription.inquiry({\n * subscriptionId: 'SUB123456789',\n * });\n *\n * if (result.success) {\n * console.log('Status:', result.data.subscriptionStatus);\n * console.log('Next payment:', result.data.productInfo.nextPaymentDateTime);\n * }\n *\n * @example\n * // Query with payment history\n * const result = await waffo.subscription.inquiry({\n * subscriptionId: 'SUB123456789',\n * paymentDetails: '1', // Include payment history\n * });\n *\n * if (result.success && result.data.paymentDetails) {\n * result.data.paymentDetails.forEach(payment => {\n * console.log(`Period ${payment.period}: ${payment.orderStatus}`);\n * });\n * }\n *\n * @see {@link InquirySubscriptionData} for response structure\n */\n async inquiry(\n params: InquirySubscriptionParams,\n ): Promise<ApiResponse<InquirySubscriptionData>> {\n return this.client.post<InquirySubscriptionData, InquirySubscriptionParams>(\n `${this.basePath}/inquiry`,\n { body: params },\n );\n }\n\n /**\n * Cancels an active subscription.\n *\n * Once canceled, no further recurring payments will be processed.\n *\n * @param {CancelSubscriptionParams} params - Cancel parameters\n * @returns {Promise<ApiResponse<CancelSubscriptionData>>} Cancellation result\n *\n * @example\n * const result = await waffo.subscription.cancel({\n * subscriptionId: 'SUB123456789',\n * merchantId: 'M001',\n * });\n *\n * if (result.success) {\n * console.log('Subscription canceled:', result.data.orderStatus);\n * // => 'MERCHANT_CANCELLED'\n * }\n *\n * @see {@link CancelSubscriptionData} for response structure\n */\n async cancel(\n params: CancelSubscriptionParams,\n ): Promise<ApiResponse<CancelSubscriptionData>> {\n const body = {\n ...params,\n requestedAt: params.requestedAt ?? new Date().toISOString(),\n };\n return this.client.post<CancelSubscriptionData, CancelSubscriptionParams>(\n `${this.basePath}/cancel`,\n { body },\n );\n }\n\n /**\n * Generates a temporary management URL for users to manage their subscription.\n *\n * The URL allows users to view subscription details and cancel if needed.\n * The URL expires after a certain period (check `expiredAt` in response).\n *\n * @param {ManageSubscriptionParams} params - Management parameters\n * @returns {Promise<ApiResponse<ManageSubscriptionData>>} Management URL and expiration\n *\n * @example\n * const result = await waffo.subscription.manage({\n * subscriptionId: 'SUB123456789',\n * });\n *\n * if (result.success) {\n * console.log('Management URL:', result.data.managementUrl);\n * console.log('Expires at:', result.data.expiredAt);\n * // Send URL to user via email or display in app\n * }\n *\n * @see {@link ManageSubscriptionData} for response structure\n */\n async manage(\n params: ManageSubscriptionParams,\n ): Promise<ApiResponse<ManageSubscriptionData>> {\n return this.client.post<ManageSubscriptionData, ManageSubscriptionParams>(\n `${this.basePath}/manage`,\n { body: params },\n );\n }\n}\n","/**\n * @fileoverview Merchant Config Resource Implementation\n * @module resources/merchantconfig/resource\n *\n * Implements the Merchant Config resource class providing merchant\n * configuration inquiry operations.\n *\n * @see {@link MerchantConfigResource} for the main class\n * @see {@link MerchantConfigInquiryParams} for inquiry parameters\n *\n * @example\n * const result = await waffo.merchantConfig.inquiry({\n * merchantId: 'M001',\n * });\n */\n\nimport { ApiResponse } from \"../../types\";\nimport { HttpClient } from \"../../core\";\nimport { BaseResource } from \"../base\";\nimport {\n MerchantConfigInquiryParams,\n MerchantConfigInquiryData,\n} from \"./types\";\n\n/**\n * Merchant configuration resource for querying transaction limits.\n *\n * Use this to retrieve daily limits, remaining limits, and\n * per-transaction limits for a merchant.\n *\n * @class MerchantConfigResource\n * @extends BaseResource\n *\n * @example\n * const result = await waffo.merchantConfig.inquiry({ merchantId: 'M001' });\n * if (result.success) {\n * console.log('Daily limit:', result.data.totalDailyLimit);\n * console.log('Remaining:', result.data.remainingDailyLimit);\n * }\n */\nexport class MerchantConfigResource extends BaseResource {\n /**\n * Creates a Merchant Config resource instance.\n * @param {HttpClient} client - HTTP client instance\n */\n constructor(client: HttpClient) {\n super(client, \"/merchantconfig\");\n }\n\n /**\n * Queries merchant configuration including transaction limits.\n *\n * @param {MerchantConfigInquiryParams} params - Query parameters\n * @returns {Promise<ApiResponse<MerchantConfigInquiryData>>} Merchant configuration\n *\n * @example\n * const result = await waffo.merchantConfig.inquiry({\n * merchantId: 'M001',\n * });\n *\n * if (result.success) {\n * const { totalDailyLimit, remainingDailyLimit, transactionLimit } = result.data;\n *\n * // Limits are returned as currency -> value maps\n * console.log('Daily limit (USD):', totalDailyLimit?.['USD']);\n * console.log('Remaining (USD):', remainingDailyLimit?.['USD']);\n * console.log('Per transaction (USD):', transactionLimit?.['USD']);\n * }\n *\n * @see {@link MerchantConfigInquiryData} for response structure\n */\n async inquiry(\n params: MerchantConfigInquiryParams,\n ): Promise<ApiResponse<MerchantConfigInquiryData>> {\n return this.client.post<\n MerchantConfigInquiryData,\n MerchantConfigInquiryParams\n >(`${this.basePath}/inquiry`, { body: params });\n }\n}\n","/**\n * @fileoverview Pay Method Config Resource Implementation\n * @module resources/paymethodconfig/resource\n *\n * Implements the Pay Method Config resource class providing payment method\n * configuration inquiry operations.\n *\n * @see {@link PayMethodConfigResource} for the main class\n * @see {@link PayMethodConfigInquiryParams} for inquiry parameters\n *\n * @example\n * const result = await waffo.payMethodConfig.inquiry({\n * merchantId: 'M001',\n * });\n */\n\nimport { ApiResponse } from \"../../types\";\nimport { HttpClient } from \"../../core\";\nimport { BaseResource } from \"../base\";\nimport {\n PayMethodConfigInquiryParams,\n PayMethodConfigInquiryData,\n} from \"./types\";\n\n/**\n * Payment method configuration resource for querying available methods.\n *\n * Use this to retrieve available payment methods, their current status,\n * and scheduled maintenance windows.\n *\n * @class PayMethodConfigResource\n * @extends BaseResource\n *\n * @example\n * const result = await waffo.payMethodConfig.inquiry({ merchantId: 'M001' });\n * if (result.success) {\n * const availableMethods = result.data.payMethodDetails.filter(\n * m => m.currentStatus === '1'\n * );\n * }\n */\nexport class PayMethodConfigResource extends BaseResource {\n /**\n * Creates a Pay Method Config resource instance.\n * @param {HttpClient} client - HTTP client instance\n */\n constructor(client: HttpClient) {\n super(client, \"/paymethodconfig\");\n }\n\n /**\n * Queries available payment methods and their status.\n *\n * @param {PayMethodConfigInquiryParams} params - Query parameters\n * @returns {Promise<ApiResponse<PayMethodConfigInquiryData>>} Payment method details\n *\n * @example\n * const result = await waffo.payMethodConfig.inquiry({\n * merchantId: 'M001',\n * });\n *\n * if (result.success) {\n * result.data.payMethodDetails.forEach(method => {\n * const status = method.currentStatus === '1' ? 'Available' : 'Unavailable';\n * console.log(`${method.payMethodName} (${method.country}): ${status}`);\n *\n * // Check maintenance windows\n * if (method.fixedMaintenanceRules?.length) {\n * console.log(' Maintenance:', method.fixedMaintenanceRules);\n * }\n * });\n * }\n *\n * @example\n * // Filter available e-wallet methods\n * const ewallets = result.data.payMethodDetails.filter(\n * m => m.currentStatus === '1' && m.productName === 'ONE_TIME_PAYMENT'\n * );\n *\n * @see {@link PayMethodConfigInquiryData} for response structure\n */\n async inquiry(\n params: PayMethodConfigInquiryParams,\n ): Promise<ApiResponse<PayMethodConfigInquiryData>> {\n return this.client.post<\n PayMethodConfigInquiryData,\n PayMethodConfigInquiryParams\n >(`${this.basePath}/inquiry`, { body: params });\n }\n}\n","/**\n * @fileoverview Waffo SDK Main Entry Point\n * @module core/waffo\n *\n * Provides the main SDK class for interacting with the Waffo Payment Platform.\n *\n * **Supported Operations:**\n * - Order management (create, inquiry, cancel, refund, capture)\n * - Refund status inquiry\n * - Subscription management (create, inquiry, cancel, manage)\n * - Merchant and payment method configuration inquiry\n *\n * @see {@link WaffoConfig} for SDK configuration options\n * @see {@link OrderResource} for order operations\n * @see {@link SubscriptionResource} for subscription operations\n *\n * @example\n * // Initialize the SDK\n * import { Waffo, Environment } from 'waffo-sdk';\n *\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: 'your-base64-encoded-private-key',\n * environment: Environment.SANDBOX,\n * });\n *\n * // Create a payment order\n * const result = await waffo.order.create({\n * paymentRequestId: 'req-123',\n * merchantOrderId: 'order-456',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * // ... other required fields\n * });\n */\n\nimport { WaffoConfig, KeyPair } from \"../types\";\nimport { HttpClient } from \"./httpClient\";\nimport { WebhookHandler } from \"./webhook\";\nimport {\n OrderResource,\n RefundResource,\n SubscriptionResource,\n MerchantConfigResource,\n PayMethodConfigResource,\n} from \"../resources\";\nimport { createKeyPair } from \"../utils\";\n\n/**\n * Main SDK class for the Waffo Payment Platform.\n *\n * Provides a unified interface for all payment operations with automatic\n * RSA-SHA256 request signing and response verification.\n *\n * **Features:**\n * - Order operations: create, inquiry, cancel, refund, capture\n * - Refund inquiry\n * - Subscription management: create, inquiry, cancel, manage\n * - Configuration queries: merchant limits, payment methods\n *\n * @class Waffo\n *\n * @example\n * // Basic SDK initialization\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: 'base64-encoded-pkcs8-private-key',\n * environment: Environment.PRODUCTION,\n * });\n *\n * @example\n * // Create and query an order\n * const createResult = await waffo.order.create({ ... });\n * if (createResult.success) {\n * const inquiryResult = await waffo.order.inquiry({\n * acquiringOrderId: createResult.data.acquiringOrderId,\n * });\n * }\n *\n * @example\n * // Handle webhooks\n * const result = await waffo.webhook.handle(requestBody, signature, {\n * onPayment: async (ctx) => {\n * console.log('Payment received:', ctx.notification.result.orderStatus);\n * },\n * });\n *\n * @see {@link WaffoConfig} - Configuration options\n * @see {@link OrderResource} - Order operations\n * @see {@link SubscriptionResource} - Subscription operations\n */\nexport class Waffo {\n /**\n * Order resource for payment processing operations.\n *\n * **Available methods:**\n * - `create()` - Create a new payment order\n * - `inquiry()` - Query order status and details\n * - `cancel()` - Cancel an unpaid order\n * - `refund()` - Request a refund for a paid order\n * - `capture()` - Capture an authorized payment (manualCapture mode)\n *\n * @type {OrderResource}\n * @readonly\n *\n * @example\n * const result = await waffo.order.create({\n * paymentRequestId: 'req-123',\n * merchantOrderId: 'order-456',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * orderDescription: 'Product purchase',\n * merchantInfo: { merchantId: 'M001' },\n * userInfo: { userId: 'U001', userEmail: 'user@example.com', userTerminal: 'WEB' },\n * goodsInfo: { goodsName: 'Product', goodsUrl: 'https://example.com/product' },\n * paymentInfo: { productName: 'ONE_TIME_PAYMENT', payMethodName: 'DANA' },\n * notifyUrl: 'https://example.com/webhook',\n * });\n *\n * @see {@link OrderResource}\n */\n public readonly order: OrderResource;\n\n /**\n * Refund resource for querying refund status.\n *\n * **Available methods:**\n * - `inquiry()` - Query refund status by refundRequestId or acquiringRefundOrderId\n *\n * @type {RefundResource}\n * @readonly\n *\n * @example\n * const result = await waffo.refund.inquiry({\n * refundRequestId: 'refund-req-123',\n * });\n * if (result.success) {\n * console.log('Refund status:', result.data.refundStatus);\n * }\n *\n * @see {@link RefundResource}\n */\n public readonly refund: RefundResource;\n\n /**\n * Subscription resource for recurring payment operations.\n *\n * **Available methods:**\n * - `create()` - Create a new subscription signing request\n * - `inquiry()` - Query subscription status and payment history\n * - `cancel()` - Cancel an active subscription\n * - `manage()` - Generate a temporary management URL for users\n *\n * @type {SubscriptionResource}\n * @readonly\n *\n * @example\n * const result = await waffo.subscription.create({\n * subscriptionRequest: 'sub-req-123',\n * currency: 'USD',\n * amount: '9.99',\n * productInfo: {\n * description: 'Monthly subscription',\n * periodType: 'MONTHLY',\n * periodInterval: '1',\n * },\n * // ... other required fields\n * });\n *\n * @see {@link SubscriptionResource}\n */\n public readonly subscription: SubscriptionResource;\n\n /**\n * Merchant configuration resource for querying transaction limits.\n *\n * **Available methods:**\n * - `inquiry()` - Query daily limits, remaining limits, and transaction limits\n *\n * @type {MerchantConfigResource}\n * @readonly\n *\n * @example\n * const result = await waffo.merchantConfig.inquiry({\n * merchantId: 'M001',\n * });\n * if (result.success) {\n * console.log('Daily limit:', result.data.totalDailyLimit);\n * }\n *\n * @see {@link MerchantConfigResource}\n */\n public readonly merchantConfig: MerchantConfigResource;\n\n /**\n * Payment method configuration resource for querying available methods.\n *\n * **Available methods:**\n * - `inquiry()` - Query available payment methods, status, and maintenance schedules\n *\n * @type {PayMethodConfigResource}\n * @readonly\n *\n * @example\n * const result = await waffo.payMethodConfig.inquiry({\n * merchantId: 'M001',\n * });\n * if (result.success) {\n * result.data.payMethodDetails.forEach(method => {\n * console.log(`${method.payMethodName}: ${method.currentStatus === '1' ? 'Available' : 'Unavailable'}`);\n * });\n * }\n *\n * @see {@link PayMethodConfigResource}\n */\n public readonly payMethodConfig: PayMethodConfigResource;\n\n /**\n * Low-level HTTP client for direct API requests.\n *\n * All requests are automatically signed and responses are verified.\n * Use this for custom endpoints not covered by the resource classes.\n *\n * @type {HttpClient}\n * @readonly\n *\n * @example\n * // Make a custom API request\n * const result = await waffo.httpClient.post('/custom/endpoint', {\n * body: { customField: 'value' },\n * });\n *\n * @see {@link HttpClient}\n */\n public readonly httpClient: HttpClient;\n\n /**\n * Webhook handler for processing incoming notifications from Waffo.\n *\n * Use `handle()` method to process webhook notifications with custom handlers.\n *\n * @type {WebhookHandler}\n * @readonly\n *\n * @example\n * // Express.js webhook endpoint\n * app.post('/webhook', async (req, res) => {\n * const result = await waffo.webhook.handle(\n * JSON.stringify(req.body),\n * req.headers['x-signature'],\n * {\n * onPayment: async (ctx) => {\n * await updateOrderStatus(ctx.notification.result);\n * },\n * onRefund: async (ctx) => {\n * await processRefund(ctx.notification.result);\n * },\n * }\n * );\n * res.set(result.response.header).json(result.response.body);\n * });\n *\n * @see {@link WebhookHandler}\n */\n public readonly webhook: WebhookHandler;\n\n /**\n * Creates a new Waffo SDK instance.\n *\n * Initializes the SDK with the provided configuration. The SDK automatically\n * selects the appropriate API endpoint and public key based on the environment.\n *\n * @param {WaffoConfig} config - SDK configuration object\n * @param {string} config.apiKey - API key assigned by Waffo (required)\n * @param {string} config.privateKey - Merchant private key, Base64 encoded PKCS8 DER format (required)\n * @param {string} [config.waffoPublicKey] - Waffo public key for response verification (optional)\n * @param {Environment} [config.environment=Environment.PRODUCTION] - API environment (optional)\n * @param {number} [config.timeout=30000] - Request timeout in milliseconds (optional)\n * @param {Logger} [config.logger] - Logger instance for debugging (optional)\n *\n * @throws {Error} When API key or private key is missing or invalid\n *\n * @example\n * // Production configuration\n * const waffo = new Waffo({\n * apiKey: process.env.WAFFO_API_KEY,\n * privateKey: process.env.WAFFO_PRIVATE_KEY,\n * environment: Environment.PRODUCTION,\n * });\n *\n * @example\n * // Sandbox configuration with debugging\n * const waffo = new Waffo({\n * apiKey: 'sandbox-api-key',\n * privateKey: 'sandbox-private-key',\n * environment: Environment.SANDBOX,\n * timeout: 60000,\n * logger: console,\n * });\n *\n * @see {@link WaffoConfig} for configuration options\n * @see {@link Environment} for available environments\n */\n constructor(config: WaffoConfig) {\n this.httpClient = new HttpClient(config);\n this.webhook = new WebhookHandler(config);\n\n // Mount resources\n this.order = new OrderResource(this.httpClient);\n this.refund = new RefundResource(this.httpClient);\n this.subscription = new SubscriptionResource(this.httpClient);\n this.merchantConfig = new MerchantConfigResource(this.httpClient);\n this.payMethodConfig = new PayMethodConfigResource(this.httpClient);\n }\n\n /**\n * Generates a new 2048-bit RSA key pair for API signing and verification.\n *\n * **Generated key formats:**\n * - Private key: Base64 encoded PKCS8 DER format (for signing requests)\n * - Public key: Base64 encoded X509/SPKI DER format (for verification)\n *\n * **Usage:**\n * 1. Generate a key pair using this method\n * 2. Register the public key with Waffo via merchant dashboard\n * 3. Store the private key securely on your server\n * 4. Use the private key when initializing the SDK\n *\n * @static\n * @returns {KeyPair} Object containing the generated key pair\n *\n * @example\n * // Generate a new key pair\n * const keys = Waffo.generateKeyPair();\n * console.log('Private Key:', keys.privateKey);\n * console.log('Public Key:', keys.publicKey);\n *\n * // Use the private key to initialize SDK\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: keys.privateKey,\n * });\n *\n * @see {@link KeyPair} for the return type structure\n */\n static generateKeyPair(): KeyPair {\n const keys = createKeyPair();\n return {\n privateKey: keys.PRIVATE_KEY_NAME,\n publicKey: keys.PUBLIC_KEY_NAME,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/config/environment.ts","../src/errors/waffo-error.ts","../src/errors/waffo-unknown-status-error.ts","../src/errors/index.ts","../src/utils/rsa-utils.ts","../src/types/config/waffo-config.ts","../src/types/config/index.ts","../src/core/waffo-http-client.ts","../src/types/api-response.ts","../src/net/default-http-transport.ts","../src/core/webhook-handler.ts","../src/resources/base-resource.ts","../src/resources/order-resource.ts","../src/resources/subscription-resource.ts","../src/resources/refund-resource.ts","../src/resources/merchant-config-resource.ts","../src/resources/pay-method-config-resource.ts","../src/waffo.ts","../src/index.ts"],"names":["Environment","RsaUtils","WebhookEventType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAGY,WAAA,CAAA,CAUC;AAbb,IAAA,gBAAA,GAAA,KAAA,CAAA;AAAA,EAAA,iCAAA,GAAA;AAGO,IAAK,WAAA,qBAAAA,YAAAA,KAAL;AAEL,MAAAA,aAAA,SAAA,CAAA,GAAU,SAAA;AAEV,MAAAA,aAAA,YAAA,CAAA,GAAa,YAAA;AAJH,MAAA,OAAAA,YAAAA;AAAA,IAAA,CAAA,E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CAAA;AAAA,IACvF;AACA,IAAA,OAAO,IAAA,CAAK,eAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,eAAA,GAA2C;AACzC,IAAA,IAAI,CAAC,KAAK,gBAAA,EAAkB;AAC1B,MAAA,IAAA,CAAK,gBAAA,GAAmB,IAAI,uBAAA,CAAwB,IAAA,CAAK,YAAY,mBAAmB,CAAA;AAAA,IAC1F;AACA,IAAA,OAAO,IAAA,CAAK,gBAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgCA,OAAA,GAA0B;AACxB,IAAA,OAAO,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA,GAAyB;AACvB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AACF;;;ACxKA,WAAA,EAAA;AAaA,gBAAA,EAAA;AACA,+BAAA,EAAA;AAwFA,cAAA,EAAA","file":"index.mjs","sourcesContent":["/**\n * Waffo API environment.\n */\nexport enum Environment {\n /** Sandbox environment for testing */\n SANDBOX = 'SANDBOX',\n /** Production environment for live transactions */\n PRODUCTION = 'PRODUCTION',\n}\n\n/**\n * Base URLs for each environment.\n */\nexport const EnvironmentBaseUrl: Record<Environment, string> = {\n [Environment.SANDBOX]: 'https://api-sandbox.waffo.com/api/v1',\n [Environment.PRODUCTION]: 'https://api.waffo.com/api/v1',\n};\n","/**\n * Base error class for client-side errors in the Waffo SDK.\n *\n * This error is thrown for configuration errors, serialization failures,\n * signature errors, and other client-side issues.\n *\n * @example\n * ```typescript\n * try {\n * const response = await waffo.order().create(params);\n * } catch (error) {\n * if (error instanceof WaffoError) {\n * console.error(`Error [${error.errorCode}]: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class WaffoError extends Error {\n /** Error code identifying the type of error */\n readonly errorCode: string;\n\n /** The underlying error that caused this error, if any */\n readonly cause?: Error;\n\n /**\n * Creates a new WaffoError.\n *\n * @param errorCode - The error code (e.g., \"S0003\" for signing failure)\n * @param message - Human-readable error message\n * @param cause - The underlying error that caused this error\n */\n constructor(errorCode: string, message: string, cause?: Error) {\n super(message);\n this.name = 'WaffoError';\n this.errorCode = errorCode;\n this.cause = cause;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, WaffoError);\n }\n }\n\n /**\n * Returns a string representation of the error.\n */\n override toString(): string {\n return `[${this.errorCode}] ${this.message}`;\n }\n}\n\n/**\n * Error codes used by WaffoError.\n */\nexport const WaffoErrorCode = {\n /** Invalid public key */\n INVALID_PUBLIC_KEY: 'S0002',\n /** Failed to sign data */\n SIGN_FAILED: 'S0003',\n /** Response signature verification failed */\n VERIFY_FAILED: 'S0004',\n /** Request serialization failed */\n SERIALIZE_FAILED: 'S0005',\n /** Unexpected error */\n UNEXPECTED: 'S0006',\n /** Invalid private key */\n INVALID_PRIVATE_KEY: 'S0007',\n} as const;\n","/**\n * Error thrown when the payment status is unknown due to network errors\n * or server issues.\n *\n * **IMPORTANT**: When this error is thrown for a payment request,\n * you MUST NOT assume the payment failed. The payment may have been processed\n * successfully. Always use the inquiry API to check the actual payment status.\n *\n * @example\n * ```typescript\n * try {\n * const response = await waffo.order().create(params);\n * } catch (error) {\n * if (error instanceof WaffoUnknownStatusError) {\n * // Payment may have been processed - check status\n * const inquiry = await waffo.order().inquiry({\n * paymentRequestId: params.paymentRequestId\n * });\n * // Handle based on inquiry result\n * }\n * }\n * ```\n */\nexport class WaffoUnknownStatusError extends Error {\n /** Error code for network errors */\n static readonly CODE_NETWORK_ERROR = 'S0001';\n\n /** Error code for unknown server status */\n static readonly CODE_UNKNOWN_STATUS = 'E0001';\n\n /** Error code identifying the type of error */\n readonly errorCode: string;\n\n /** The underlying error that caused this error, if any */\n readonly cause?: Error;\n\n /**\n * Creates a new WaffoUnknownStatusError.\n *\n * @param errorCode - The error code (e.g., \"S0001\" for network error)\n * @param message - Human-readable error message\n * @param cause - The underlying error that caused this error\n */\n constructor(errorCode: string, message: string, cause?: Error) {\n super(message);\n this.name = 'WaffoUnknownStatusError';\n this.errorCode = errorCode;\n this.cause = cause;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, WaffoUnknownStatusError);\n }\n }\n\n /**\n * Returns a string representation of the error.\n */\n override toString(): string {\n return `[${this.errorCode}] ${this.message}`;\n }\n}\n","export { WaffoError, WaffoErrorCode } from './waffo-error';\nexport { WaffoUnknownStatusError } from './waffo-unknown-status-error';\n","import * as crypto from 'crypto';\nimport { WaffoError, WaffoErrorCode } from '../errors';\n\n/**\n * RSA cryptographic utilities for signing and verification.\n *\n * Uses SHA256withRSA algorithm with 2048-bit key size.\n *\n * **Key Formats:**\n * - Private Key: PKCS#8 DER encoded, Base64 string\n * - Public Key: X.509 SubjectPublicKeyInfo DER encoded, Base64 string\n *\n * **Security Best Practices:**\n *\n * When verifying Waffo's response signature fails:\n * 1. Stop sending new transactions to Waffo until the issue is resolved\n * 2. Investigate the cause and contact Waffo support\n * 3. Note: Waffo may have already processed your request, but you failed to\n * process the response due to signature verification failure\n */\nexport namespace RsaUtils {\n const ALGORITHM = 'RSA-SHA256';\n const KEY_SIZE = 2048;\n\n /**\n * Result of key pair generation.\n */\n export interface KeyPairResult {\n /** Base64 encoded PKCS8 private key */\n privateKey: string;\n /** Base64 encoded X509 public key */\n publicKey: string;\n }\n\n /**\n * Signs data using RSA-SHA256.\n *\n * @param data - The data to sign (UTF-8 string)\n * @param base64PrivateKey - Base64 encoded PKCS8 private key\n * @returns Base64 encoded signature\n * @throws WaffoError if signing fails (S0003)\n *\n * @example\n * ```typescript\n * const signature = RsaUtils.sign('{\"amount\":\"100.00\"}', privateKey);\n * ```\n */\n export function sign(data: string, base64PrivateKey: string): string {\n try {\n const privateKeyBuffer = Buffer.from(base64PrivateKey, 'base64');\n const signer = crypto.createSign(ALGORITHM);\n signer.update(data, 'utf8');\n\n const signature = signer.sign({\n key: privateKeyBuffer,\n format: 'der',\n type: 'pkcs8',\n });\n\n return signature.toString('base64');\n } catch (error) {\n throw new WaffoError(\n WaffoErrorCode.SIGN_FAILED,\n `Failed to sign data: ${error instanceof Error ? error.message : String(error)}`,\n error instanceof Error ? error : undefined\n );\n }\n }\n\n /**\n * Verifies a signature using RSA-SHA256.\n *\n * @param data - The original data (UTF-8 string)\n * @param base64Signature - Base64 encoded signature\n * @param base64PublicKey - Base64 encoded X509 public key\n * @returns true if signature is valid, false otherwise\n *\n * @example\n * ```typescript\n * const isValid = RsaUtils.verify(responseBody, signature, waffoPublicKey);\n * if (!isValid) {\n * // Handle signature verification failure\n * }\n * ```\n */\n export function verify(\n data: string,\n base64Signature: string,\n base64PublicKey: string\n ): boolean {\n try {\n const publicKeyBuffer = Buffer.from(base64PublicKey, 'base64');\n const signatureBuffer = Buffer.from(base64Signature, 'base64');\n\n const verifier = crypto.createVerify(ALGORITHM);\n verifier.update(data, 'utf8');\n\n return verifier.verify(\n {\n key: publicKeyBuffer,\n format: 'der',\n type: 'spki',\n },\n signatureBuffer\n );\n } catch {\n // Invalid key or signature format - return false instead of throwing\n return false;\n }\n }\n\n /**\n * Validates a Base64 encoded PKCS8 private key.\n *\n * This method attempts to parse the key to ensure it's a valid RSA private key.\n * Use this at startup to fail fast if the private key is invalid.\n *\n * @param base64PrivateKey - Base64 encoded PKCS8 private key\n * @throws WaffoError if the key is invalid (S0007)\n *\n * @example\n * ```typescript\n * // Validate at initialization\n * RsaUtils.validatePrivateKey(config.privateKey);\n * ```\n */\n export function validatePrivateKey(base64PrivateKey: string): void {\n if (!base64PrivateKey || base64PrivateKey.trim() === '') {\n throw new WaffoError(\n WaffoErrorCode.INVALID_PRIVATE_KEY,\n 'Private key is null or empty'\n );\n }\n\n try {\n const keyBuffer = Buffer.from(base64PrivateKey, 'base64');\n crypto.createPrivateKey({\n key: keyBuffer,\n format: 'der',\n type: 'pkcs8',\n });\n } catch (error) {\n if (error instanceof WaffoError) throw error;\n\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes('bad base64')) {\n throw new WaffoError(\n WaffoErrorCode.INVALID_PRIVATE_KEY,\n 'Invalid private key: not valid Base64 encoding',\n error instanceof Error ? error : undefined\n );\n }\n throw new WaffoError(\n WaffoErrorCode.INVALID_PRIVATE_KEY,\n `Invalid private key: ${message}`,\n error instanceof Error ? error : undefined\n );\n }\n }\n\n /**\n * Validates a Base64 encoded X509 public key.\n *\n * This method attempts to parse the key to ensure it's a valid RSA public key.\n * Use this at startup to fail fast if the public key is invalid.\n *\n * @param base64PublicKey - Base64 encoded X509 public key\n * @throws WaffoError if the key is invalid (S0002)\n *\n * @example\n * ```typescript\n * // Validate at initialization\n * RsaUtils.validatePublicKey(config.waffoPublicKey);\n * ```\n */\n export function validatePublicKey(base64PublicKey: string): void {\n if (!base64PublicKey || base64PublicKey.trim() === '') {\n throw new WaffoError(\n WaffoErrorCode.INVALID_PUBLIC_KEY,\n 'Public key is null or empty'\n );\n }\n\n try {\n const keyBuffer = Buffer.from(base64PublicKey, 'base64');\n crypto.createPublicKey({\n key: keyBuffer,\n format: 'der',\n type: 'spki',\n });\n } catch (error) {\n if (error instanceof WaffoError) throw error;\n\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes('bad base64')) {\n throw new WaffoError(\n WaffoErrorCode.INVALID_PUBLIC_KEY,\n 'Invalid public key: not valid Base64 encoding',\n error instanceof Error ? error : undefined\n );\n }\n throw new WaffoError(\n WaffoErrorCode.INVALID_PUBLIC_KEY,\n `Invalid public key: ${message}`,\n error instanceof Error ? error : undefined\n );\n }\n }\n\n /**\n * Generates a new RSA key pair for testing or merchant key generation.\n *\n * @returns A new KeyPairResult containing Base64 encoded keys\n *\n * @example\n * ```typescript\n * const keyPair = RsaUtils.generateKeyPair();\n * console.log('Private Key:', keyPair.privateKey);\n * console.log('Public Key:', keyPair.publicKey);\n * ```\n */\n export function generateKeyPair(): KeyPairResult {\n try {\n const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {\n modulusLength: KEY_SIZE,\n publicKeyEncoding: {\n type: 'spki',\n format: 'der',\n },\n privateKeyEncoding: {\n type: 'pkcs8',\n format: 'der',\n },\n });\n\n return {\n privateKey: privateKey.toString('base64'),\n publicKey: publicKey.toString('base64'),\n };\n } catch (error) {\n throw new WaffoError(\n WaffoErrorCode.SIGN_FAILED,\n `Failed to generate key pair: ${error instanceof Error ? error.message : String(error)}`,\n error instanceof Error ? error : undefined\n );\n }\n }\n}\n","import { Environment } from './environment';\nimport type { HttpTransport } from '../../net/http-transport';\nimport { RsaUtils } from '../../utils/rsa-utils';\n\n/**\n * Logger interface for SDK debugging.\n */\nexport interface WaffoLogger {\n debug(message: string, ...args: unknown[]): void;\n info(message: string, ...args: unknown[]): void;\n warn(message: string, ...args: unknown[]): void;\n error(message: string, ...args: unknown[]): void;\n}\n\n/**\n * Configuration for the Waffo SDK.\n *\n * @example\n * ```typescript\n * const config: WaffoConfig = {\n * apiKey: 'your-api-key',\n * privateKey: 'base64-private-key',\n * waffoPublicKey: 'base64-public-key',\n * environment: Environment.SANDBOX,\n * merchantId: 'your-merchant-id',\n * };\n *\n * const waffo = new Waffo(config);\n * ```\n */\nexport interface WaffoConfig {\n /** API key provided by Waffo */\n apiKey: string;\n\n /** Merchant's private key for signing requests (Base64 encoded PKCS8) */\n privateKey: string;\n\n /** Waffo's public key for verifying responses (Base64 encoded X509) */\n waffoPublicKey: string;\n\n /** API environment (SANDBOX or PRODUCTION) */\n environment: Environment;\n\n /**\n * Merchant ID (required).\n * This will be automatically injected into requests that require merchantId.\n */\n merchantId: string;\n\n /** Connect timeout in milliseconds (default: 10000) */\n connectTimeout?: number;\n\n /** Read timeout in milliseconds (default: 30000) */\n readTimeout?: number;\n\n /** Optional logger for debugging */\n logger?: WaffoLogger;\n\n /**\n * Custom HTTP transport implementation.\n * If not set, the SDK uses the default fetch-based transport.\n */\n httpTransport?: HttpTransport;\n}\n\n/**\n * Environment variable names for configuration.\n */\nexport const WaffoConfigEnvVars = {\n API_KEY: 'WAFFO_API_KEY',\n PRIVATE_KEY: 'WAFFO_PRIVATE_KEY',\n PUBLIC_KEY: 'WAFFO_PUBLIC_KEY',\n MERCHANT_ID: 'WAFFO_MERCHANT_ID',\n ENVIRONMENT: 'WAFFO_ENVIRONMENT',\n} as const;\n\n/**\n * Default timeout values.\n */\nexport const WaffoConfigDefaults = {\n CONNECT_TIMEOUT: 10000,\n READ_TIMEOUT: 30000,\n} as const;\n\n/**\n * Creates and validates a WaffoConfig.\n *\n * @param config - Configuration options\n * @returns Validated configuration with defaults applied\n * @throws WaffoError if required fields are missing or keys are invalid\n *\n * @example\n * ```typescript\n * const config = createWaffoConfig({\n * apiKey: 'your-api-key',\n * privateKey: 'base64-private-key',\n * waffoPublicKey: 'base64-public-key',\n * environment: Environment.SANDBOX,\n * });\n * ```\n */\nexport function createWaffoConfig(config: WaffoConfig): WaffoConfig {\n // Validate required fields\n if (!config.apiKey) {\n throw new Error('apiKey is required');\n }\n if (!config.privateKey) {\n throw new Error('privateKey is required');\n }\n if (!config.waffoPublicKey) {\n throw new Error('waffoPublicKey is required');\n }\n if (!config.environment) {\n throw new Error('environment is required (SANDBOX or PRODUCTION)');\n }\n if (!config.merchantId) {\n throw new Error('merchantId is required');\n }\n\n // Validate keys\n RsaUtils.validatePrivateKey(config.privateKey);\n RsaUtils.validatePublicKey(config.waffoPublicKey);\n\n return {\n ...config,\n connectTimeout: config.connectTimeout ?? WaffoConfigDefaults.CONNECT_TIMEOUT,\n readTimeout: config.readTimeout ?? WaffoConfigDefaults.READ_TIMEOUT,\n };\n}\n\n/**\n * Creates a WaffoConfig from environment variables.\n *\n * Required environment variables:\n * - WAFFO_API_KEY\n * - WAFFO_PRIVATE_KEY\n * - WAFFO_PUBLIC_KEY\n * - WAFFO_ENVIRONMENT (SANDBOX or PRODUCTION)\n *\n * Optional:\n * - WAFFO_MERCHANT_ID\n *\n * @returns Configuration from environment variables\n * @throws Error if required environment variables are not set\n *\n * @example\n * ```typescript\n * // Set environment variables:\n * // export WAFFO_API_KEY=your-api-key\n * // export WAFFO_PRIVATE_KEY=base64-private-key\n * // export WAFFO_PUBLIC_KEY=base64-public-key\n * // export WAFFO_ENVIRONMENT=SANDBOX\n *\n * const config = WaffoConfig.fromEnv();\n * ```\n */\nexport function fromEnv(): WaffoConfig {\n const getEnv = (name: string, required = true): string => {\n const value = process.env[name];\n if (required && (!value || value.trim() === '')) {\n throw new Error(`Required environment variable ${name} is not set`);\n }\n return value || '';\n };\n\n const apiKey = getEnv(WaffoConfigEnvVars.API_KEY);\n const privateKey = getEnv(WaffoConfigEnvVars.PRIVATE_KEY);\n const waffoPublicKey = getEnv(WaffoConfigEnvVars.PUBLIC_KEY);\n const envStr = getEnv(WaffoConfigEnvVars.ENVIRONMENT);\n const merchantId = getEnv(WaffoConfigEnvVars.MERCHANT_ID);\n\n const environment = envStr.toUpperCase() as Environment;\n if (environment !== Environment.SANDBOX && environment !== Environment.PRODUCTION) {\n throw new Error(\n `Invalid ${WaffoConfigEnvVars.ENVIRONMENT} value: ${envStr}. Must be SANDBOX or PRODUCTION`\n );\n }\n\n return createWaffoConfig({\n apiKey,\n privateKey,\n waffoPublicKey,\n environment,\n merchantId,\n });\n}\n","export { Environment, EnvironmentBaseUrl } from './environment';\nexport type { WaffoConfig, WaffoLogger } from './waffo-config';\nexport {\n WaffoConfigEnvVars,\n WaffoConfigDefaults,\n createWaffoConfig,\n fromEnv,\n} from './waffo-config';\nexport type { RequestOptions } from './request-options';\n","import type { WaffoConfig, WaffoLogger, RequestOptions } from '../types/config';\nimport { EnvironmentBaseUrl, WaffoConfigDefaults } from '../types/config';\nimport { ApiResponse } from '../types/api-response';\nimport type { HttpTransport } from '../net/http-transport';\nimport { DefaultHttpTransport } from '../net/default-http-transport';\nimport { RsaUtils } from '../utils/rsa-utils';\nimport { WaffoErrorCode } from '../errors/waffo-error';\nimport { WaffoUnknownStatusError } from '../errors/waffo-unknown-status-error';\n\n// HTTP Headers\nconst HEADER_API_KEY = 'x-api-key';\nconst HEADER_SIGNATURE = 'x-signature';\nconst HEADER_API_VERSION = 'x-api-version';\nconst HEADER_SDK_VERSION = 'x-sdk-version';\nconst HEADER_CONTENT_TYPE = 'content-type';\nconst CONTENT_TYPE_JSON = 'application/json';\n\n// Version info\nconst API_VERSION = '1.0.0';\nconst SDK_VERSION = 'waffo-node/1.0.0';\n\n/**\n * HTTP client for making requests to the Waffo API.\n *\n * Handles:\n * - Request signing with merchant's private key\n * - Response signature verification with Waffo's public key\n * - MerchantId auto-injection\n * - Error handling and timeout management\n */\nexport class WaffoHttpClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly privateKey: string;\n private readonly waffoPublicKey: string;\n private readonly merchantId: string;\n private readonly connectTimeout: number;\n private readonly readTimeout: number;\n private readonly logger?: WaffoLogger;\n private readonly httpTransport: HttpTransport;\n\n constructor(config: WaffoConfig) {\n this.baseUrl = EnvironmentBaseUrl[config.environment];\n this.apiKey = config.apiKey;\n this.privateKey = config.privateKey;\n this.waffoPublicKey = config.waffoPublicKey;\n this.merchantId = config.merchantId;\n this.connectTimeout = config.connectTimeout ?? WaffoConfigDefaults.CONNECT_TIMEOUT;\n this.readTimeout = config.readTimeout ?? WaffoConfigDefaults.READ_TIMEOUT;\n this.logger = config.logger;\n this.httpTransport = config.httpTransport ?? new DefaultHttpTransport();\n }\n\n /**\n * Sends a POST request to the Waffo API.\n *\n * @param path - API endpoint path (e.g., \"/order/create\")\n * @param request - Request body\n * @param options - Per-request options\n * @returns API response\n * @throws WaffoUnknownStatusError for network errors or unknown status\n */\n async post<T extends object, R>(\n path: string,\n request: T,\n options?: RequestOptions\n ): Promise<ApiResponse<R>> {\n const url = this.baseUrl + path;\n const effectiveConnectTimeout = options?.connectTimeout ?? this.connectTimeout;\n const effectiveReadTimeout = options?.readTimeout ?? this.readTimeout;\n\n try {\n // Auto-inject merchantId if configured\n this.injectMerchantIdIfNeeded(request);\n\n // Serialize request\n const requestBody = JSON.stringify(request);\n\n // Sign the request\n const signature = RsaUtils.sign(requestBody, this.privateKey);\n\n this.logger?.debug(`Request URL: ${url}`);\n this.logger?.debug(`Request Body: ${requestBody}`);\n\n // Build and send HTTP request\n const httpResponse = await this.httpTransport.send({\n url,\n method: 'POST',\n headers: {\n [HEADER_CONTENT_TYPE]: CONTENT_TYPE_JSON,\n [HEADER_API_KEY]: this.apiKey,\n [HEADER_SIGNATURE]: signature,\n [HEADER_API_VERSION]: API_VERSION,\n [HEADER_SDK_VERSION]: SDK_VERSION,\n },\n body: requestBody,\n connectTimeout: effectiveConnectTimeout,\n readTimeout: effectiveReadTimeout,\n });\n\n this.logger?.debug(`Response Status: ${httpResponse.statusCode}`);\n this.logger?.debug(`Response Body: ${httpResponse.body}`);\n\n // Verify response signature\n const responseSignature = httpResponse.headers[HEADER_SIGNATURE];\n if (responseSignature) {\n const isValid = RsaUtils.verify(\n httpResponse.body,\n responseSignature,\n this.waffoPublicKey\n );\n if (!isValid) {\n this.logger?.error('Response signature verification failed');\n return ApiResponse.error(\n WaffoErrorCode.VERIFY_FAILED,\n 'Response signature verification failed'\n );\n }\n }\n\n // Parse response\n const response = this.parseResponse<R>(httpResponse.body);\n\n // Check for E0001 (unknown status)\n if (response.code === 'E0001') {\n throw new WaffoUnknownStatusError(\n WaffoUnknownStatusError.CODE_UNKNOWN_STATUS,\n response.getMessage() ?? 'Unknown status from server'\n );\n }\n\n return response;\n } catch (error) {\n // Re-throw WaffoUnknownStatusError\n if (error instanceof WaffoUnknownStatusError) {\n throw error;\n }\n\n // Handle network errors\n if (this.isNetworkError(error)) {\n this.logger?.error('Network error', error);\n throw new WaffoUnknownStatusError(\n WaffoUnknownStatusError.CODE_NETWORK_ERROR,\n `Network error, payment status unknown: ${error instanceof Error ? error.message : String(error)}`,\n error instanceof Error ? error : undefined\n );\n }\n\n // Handle serialization errors\n if (error instanceof SyntaxError) {\n this.logger?.error('JSON serialization error', error);\n return ApiResponse.error(\n WaffoErrorCode.SERIALIZE_FAILED,\n `Request serialization failed: ${error.message}`\n );\n }\n\n this.logger?.error('Unexpected error', error);\n return ApiResponse.error(\n WaffoErrorCode.UNEXPECTED,\n `Unexpected error: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n /**\n * Parses the API response body.\n */\n private parseResponse<R>(responseBody: string): ApiResponse<R> {\n try {\n const parsed = JSON.parse(responseBody) as {\n code?: string;\n msg?: string;\n data?: R;\n };\n\n const { code, msg, data } = parsed;\n\n if (code === '0') {\n return ApiResponse.success(data);\n } else {\n return ApiResponse.error(code ?? 'UNKNOWN', msg);\n }\n } catch (error) {\n this.logger?.error('Failed to parse response', error);\n return ApiResponse.error(\n 'C0001',\n `Failed to parse response: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n /**\n * Auto-injects merchantId into the request if configured.\n */\n private injectMerchantIdIfNeeded<T extends object>(request: T): void {\n if (!this.merchantId) return;\n\n const req = request as Record<string, unknown>;\n\n // Check merchantInfo.merchantId\n if (\n typeof req.merchantInfo === 'object' &&\n req.merchantInfo !== null &&\n !('merchantId' in req.merchantInfo && (req.merchantInfo as Record<string, unknown>).merchantId)\n ) {\n (req.merchantInfo as Record<string, unknown>).merchantId = this.merchantId;\n }\n // Check top-level merchantId\n else if ('merchantId' in req && !req.merchantId) {\n req.merchantId = this.merchantId;\n }\n }\n\n /**\n * Checks if the error is a network-related error.\n */\n private isNetworkError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n\n const message = error.message.toLowerCase();\n return (\n error.name === 'AbortError' ||\n message.includes('timeout') ||\n message.includes('econnrefused') ||\n message.includes('enotfound') ||\n message.includes('network') ||\n message.includes('socket') ||\n message.includes('connection')\n );\n }\n}\n","/**\n * Generic API response wrapper.\n *\n * All API responses are wrapped in this class for consistent handling.\n *\n * @example\n * ```typescript\n * const response = await waffo.order().create(params);\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * console.log('Order ID:', data?.acquiringOrderId);\n * } else {\n * console.error(`Error [${response.code}]: ${response.getMessage()}`);\n * }\n * ```\n */\nexport class ApiResponse<T> {\n /** Response code. \"0\" indicates success, other values indicate errors. */\n readonly code: string;\n\n /** Response data (present when code is \"0\") */\n readonly data?: T;\n\n /** Error message (present when code is not \"0\") */\n readonly message?: string;\n\n private constructor(code: string, data?: T, message?: string) {\n this.code = code;\n this.data = data;\n this.message = message;\n }\n\n /**\n * Creates a successful response.\n *\n * @param data - The response data\n */\n static success<T>(data?: T): ApiResponse<T> {\n return new ApiResponse('0', data);\n }\n\n /**\n * Creates an error response.\n *\n * @param code - The error code\n * @param message - The error message\n */\n static error<T>(code: string, message?: string): ApiResponse<T> {\n return new ApiResponse<T>(code, undefined, message);\n }\n\n /**\n * Checks if the response indicates success.\n *\n * @returns true if the response code is \"0\"\n */\n isSuccess(): boolean {\n return this.code === '0';\n }\n\n /**\n * Gets the response data.\n *\n * @returns The response data, or undefined if the response is an error\n */\n getData(): T | undefined {\n return this.data;\n }\n\n /**\n * Gets the error message.\n *\n * @returns The error message, or undefined if the response is successful\n */\n getMessage(): string | undefined {\n return this.message;\n }\n\n /**\n * Gets the response code.\n *\n * @returns The response code\n */\n getCode(): string {\n return this.code;\n }\n\n /**\n * Gets the response data or throws an error.\n *\n * @returns The response data\n * @throws Error if the response is not successful or data is undefined\n */\n getDataOrThrow(): T {\n if (!this.isSuccess()) {\n throw new Error(`[${this.code}] ${this.message ?? 'API error'}`);\n }\n if (this.data === undefined) {\n throw new Error('Response data is undefined');\n }\n return this.data;\n }\n}\n","import type { HttpTransport } from './http-transport';\nimport type { HttpRequest } from './http-request';\nimport type { HttpResponse } from './http-response';\n\n/**\n * Default HTTP transport implementation using Node.js native fetch.\n *\n * Requires Node.js 18+ for native fetch support.\n *\n * Features:\n * - TLS 1.2+ enforced by default\n * - Separate connectTimeout and readTimeout\n * - Proper error handling for network errors\n *\n * Timeout behavior:\n * - connectTimeout: Maximum time to establish connection and receive response headers\n * - readTimeout: Maximum time to read the response body after connection is established\n *\n * @example\n * ```typescript\n * const transport = new DefaultHttpTransport();\n * const response = await transport.send({\n * url: 'https://api.example.com/endpoint',\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: '{\"key\":\"value\"}',\n * connectTimeout: 10000,\n * readTimeout: 30000,\n * });\n * ```\n */\nexport class DefaultHttpTransport implements HttpTransport {\n /**\n * Sends an HTTP request using native fetch.\n *\n * @param request - The HTTP request to send\n * @returns The HTTP response\n * @throws Error if the request fails (network error, timeout, etc.)\n */\n async send(request: HttpRequest): Promise<HttpResponse> {\n // Create abort controller for connection phase\n const connectController = new AbortController();\n let connectTimeoutId: ReturnType<typeof setTimeout> | undefined;\n let readTimeoutId: ReturnType<typeof setTimeout> | undefined;\n let timeoutPhase: 'connect' | 'read' = 'connect';\n\n try {\n // Phase 1: Connection timeout - applies to fetch() until we get response headers\n connectTimeoutId = setTimeout(() => {\n connectController.abort();\n }, request.connectTimeout);\n\n const response = await fetch(request.url, {\n method: request.method,\n headers: request.headers,\n body: request.body,\n signal: connectController.signal,\n });\n\n // Connection established, clear connect timeout\n clearTimeout(connectTimeoutId);\n connectTimeoutId = undefined;\n\n // Phase 2: Read timeout - applies to reading the response body\n timeoutPhase = 'read';\n const readController = new AbortController();\n readTimeoutId = setTimeout(() => {\n readController.abort();\n }, request.readTimeout);\n\n // Read response body with read timeout\n // Note: We need to race between body reading and timeout\n // since response.text() doesn't accept AbortSignal directly\n const body = await Promise.race([\n response.text(),\n new Promise<never>((_, reject) => {\n readController.signal.addEventListener('abort', () => {\n reject(new Error('AbortError'));\n });\n }),\n ]);\n\n clearTimeout(readTimeoutId);\n readTimeoutId = undefined;\n\n // Extract headers (convert to lowercase keys)\n const headers: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n headers[key.toLowerCase()] = value;\n });\n\n return {\n statusCode: response.status,\n headers,\n body,\n };\n } catch (error) {\n // Re-throw with more descriptive message\n if (error instanceof Error) {\n if (error.name === 'AbortError' || error.message === 'AbortError') {\n const timeout = timeoutPhase === 'connect' ? request.connectTimeout : request.readTimeout;\n throw new Error(`Request ${timeoutPhase} timeout after ${timeout}ms`);\n }\n throw error;\n }\n throw new Error(`HTTP request failed: ${String(error)}`);\n } finally {\n if (connectTimeoutId) clearTimeout(connectTimeoutId);\n if (readTimeoutId) clearTimeout(readTimeoutId);\n }\n }\n}\n","import type { WaffoConfig, WaffoLogger } from '../types/config';\nimport { RsaUtils } from '../utils/rsa-utils';\n\n/**\n * Webhook event types sent by Waffo.\n */\nexport enum WebhookEventType {\n PAYMENT_NOTIFICATION = 'PAYMENT_NOTIFICATION',\n REFUND_NOTIFICATION = 'REFUND_NOTIFICATION',\n SUBSCRIPTION_STATUS_NOTIFICATION = 'SUBSCRIPTION_STATUS_NOTIFICATION',\n SUBSCRIPTION_PAYMENT_NOTIFICATION = 'SUBSCRIPTION_PAYMENT_NOTIFICATION',\n SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION',\n}\n\n/**\n * Result of webhook handling.\n */\nexport interface WebhookResult {\n /** Whether the webhook was processed successfully */\n success: boolean;\n /** Response body to send back to Waffo */\n responseBody: string;\n /** Signature for the response body */\n responseSignature: string;\n /** Error message if processing failed */\n error?: string;\n}\n\n/**\n * Base notification interface.\n */\nexport interface BaseNotification {\n eventType: string;\n}\n\n/**\n * Payment notification from Waffo.\n */\nexport interface PaymentNotification extends BaseNotification {\n eventType: 'PAYMENT_NOTIFICATION';\n acquiringOrderId?: string;\n merchantOrderId?: string;\n paymentRequestId?: string;\n orderStatus?: string;\n orderAmount?: string;\n orderCurrency?: string;\n finalDealAmount?: string;\n [key: string]: unknown;\n}\n\n/**\n * Refund notification from Waffo.\n */\nexport interface RefundNotification extends BaseNotification {\n eventType: 'REFUND_NOTIFICATION';\n acquiringRefundOrderId?: string;\n refundRequestId?: string;\n refundStatus?: string;\n refundAmount?: string;\n [key: string]: unknown;\n}\n\n/**\n * Subscription status notification from Waffo.\n */\nexport interface SubscriptionStatusNotification extends BaseNotification {\n eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';\n subscriptionId?: string;\n subscriptionStatus?: string;\n [key: string]: unknown;\n}\n\n/**\n * Subscription payment notification from Waffo.\n */\nexport interface SubscriptionPaymentNotification extends BaseNotification {\n eventType: 'SUBSCRIPTION_PAYMENT_NOTIFICATION';\n subscriptionId?: string;\n acquiringOrderId?: string;\n orderStatus?: string;\n [key: string]: unknown;\n}\n\n/**\n * Subscription period changed notification from Waffo.\n */\nexport interface SubscriptionPeriodChangedNotification extends BaseNotification {\n eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';\n subscriptionId?: string;\n [key: string]: unknown;\n}\n\n// Handler types\ntype PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;\ntype RefundHandler = (notification: RefundNotification) => void | Promise<void>;\ntype SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;\ntype SubscriptionPaymentHandler = (notification: SubscriptionPaymentNotification) => void | Promise<void>;\ntype SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;\n\n/**\n * Webhook handler for processing Waffo webhook notifications.\n *\n * @example\n * ```typescript\n * // Setup handler\n * const handler = waffo.webhook()\n * .onPayment((notification) => {\n * console.log('Payment:', notification.orderStatus);\n * })\n * .onRefund((notification) => {\n * console.log('Refund:', notification.refundStatus);\n * });\n *\n * // Process webhook (e.g., in Express.js)\n * app.post('/webhook', async (req, res) => {\n * const body = req.body.toString();\n * const signature = req.headers['x-signature'];\n * const result = await handler.handleWebhook(body, signature);\n *\n * res.setHeader('X-SIGNATURE', result.responseSignature);\n * res.status(200).send(result.responseBody);\n * });\n * ```\n */\nexport class WebhookHandler {\n private readonly waffoPublicKey: string;\n private readonly privateKey: string;\n private readonly logger?: WaffoLogger;\n\n private paymentHandler?: PaymentHandler;\n private refundHandler?: RefundHandler;\n private subscriptionStatusHandler?: SubscriptionStatusHandler;\n private subscriptionPaymentHandler?: SubscriptionPaymentHandler;\n private subscriptionPeriodChangedHandler?: SubscriptionPeriodChangedHandler;\n\n constructor(config: WaffoConfig) {\n this.waffoPublicKey = config.waffoPublicKey;\n this.privateKey = config.privateKey;\n this.logger = config.logger;\n }\n\n /**\n * Registers a handler for payment notifications.\n */\n onPayment(handler: PaymentHandler): this {\n this.paymentHandler = handler;\n return this;\n }\n\n /**\n * Registers a handler for refund notifications.\n */\n onRefund(handler: RefundHandler): this {\n this.refundHandler = handler;\n return this;\n }\n\n /**\n * Registers a handler for subscription status notifications.\n */\n onSubscriptionStatus(handler: SubscriptionStatusHandler): this {\n this.subscriptionStatusHandler = handler;\n return this;\n }\n\n /**\n * Registers a handler for subscription payment notifications.\n */\n onSubscriptionPayment(handler: SubscriptionPaymentHandler): this {\n this.subscriptionPaymentHandler = handler;\n return this;\n }\n\n /**\n * Registers a handler for subscription period changed notifications.\n */\n onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this {\n this.subscriptionPeriodChangedHandler = handler;\n return this;\n }\n\n /**\n * Processes a webhook notification.\n *\n * @param body - The raw webhook body\n * @param signature - The X-SIGNATURE header value\n * @returns Result with response body and signature\n */\n async handleWebhook(body: string, signature: string): Promise<WebhookResult> {\n try {\n // Verify signature\n if (!signature) {\n this.logger?.warn('Missing webhook signature');\n return this.createFailedResult('Missing signature');\n }\n\n const isValid = RsaUtils.verify(body, signature, this.waffoPublicKey);\n if (!isValid) {\n this.logger?.error('Invalid webhook signature');\n return this.createFailedResult('Invalid signature');\n }\n\n // Parse and route event\n const parsed = JSON.parse(body) as BaseNotification;\n const eventType = parsed.eventType as WebhookEventType;\n\n switch (eventType) {\n case WebhookEventType.PAYMENT_NOTIFICATION:\n if (this.paymentHandler) {\n await this.paymentHandler(parsed as PaymentNotification);\n }\n break;\n\n case WebhookEventType.REFUND_NOTIFICATION:\n if (this.refundHandler) {\n await this.refundHandler(parsed as RefundNotification);\n }\n break;\n\n case WebhookEventType.SUBSCRIPTION_STATUS_NOTIFICATION:\n if (this.subscriptionStatusHandler) {\n await this.subscriptionStatusHandler(parsed as SubscriptionStatusNotification);\n }\n break;\n\n case WebhookEventType.SUBSCRIPTION_PAYMENT_NOTIFICATION:\n if (this.subscriptionPaymentHandler) {\n await this.subscriptionPaymentHandler(parsed as SubscriptionPaymentNotification);\n }\n break;\n\n case WebhookEventType.SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION:\n if (this.subscriptionPeriodChangedHandler) {\n await this.subscriptionPeriodChangedHandler(parsed as SubscriptionPeriodChangedNotification);\n }\n break;\n\n default:\n this.logger?.warn(`Unknown webhook event type: ${eventType}`);\n return this.createFailedResult(`Unknown event type: ${eventType}`);\n }\n\n return this.createSuccessResult();\n } catch (error) {\n this.logger?.error('Error handling webhook', error);\n return this.createFailedResult(\n `Error handling webhook: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n /**\n * Verifies a webhook signature.\n *\n * @param body - The raw webhook body\n * @param signature - The X-SIGNATURE header value\n * @returns true if signature is valid\n */\n verifySignature(body: string, signature: string): boolean {\n return RsaUtils.verify(body, signature, this.waffoPublicKey);\n }\n\n /**\n * Builds a success response with signature.\n */\n buildSuccessResponse(): { body: string; signature: string } {\n const body = JSON.stringify({ status: 'success' });\n const signature = RsaUtils.sign(body, this.privateKey);\n return { body, signature };\n }\n\n /**\n * Builds a failed response with signature.\n */\n buildFailedResponse(message: string): { body: string; signature: string } {\n const body = JSON.stringify({ status: 'failed', message });\n const signature = RsaUtils.sign(body, this.privateKey);\n return { body, signature };\n }\n\n private createSuccessResult(): WebhookResult {\n const { body, signature } = this.buildSuccessResponse();\n return {\n success: true,\n responseBody: body,\n responseSignature: signature,\n };\n }\n\n private createFailedResult(error: string): WebhookResult {\n const { body, signature } = this.buildFailedResponse(error);\n return {\n success: false,\n responseBody: body,\n responseSignature: signature,\n error,\n };\n }\n}\n","import { WaffoHttpClient } from '../core/waffo-http-client';\n\n/**\n * Base class for API resources.\n */\nexport abstract class BaseResource {\n protected readonly httpClient: WaffoHttpClient;\n protected readonly basePath: string;\n\n constructor(httpClient: WaffoHttpClient, basePath: string) {\n this.httpClient = httpClient;\n this.basePath = basePath;\n }\n\n /**\n * Gets the full path for an endpoint.\n *\n * @param endpoint - The endpoint (e.g., \"/create\")\n * @returns Full path (e.g., \"/order/create\")\n */\n protected getPath(endpoint: string): string {\n return this.basePath + endpoint;\n }\n}\n","import { BaseResource } from './base-resource';\nimport { ApiResponse } from '../types/api-response';\nimport type { RequestOptions } from '../types/config';\nimport type {\n CreateOrderParams,\n CreateOrderData,\n InquiryOrderParams,\n InquiryOrderData,\n CancelOrderParams,\n CancelOrderData,\n RefundOrderParams,\n RefundOrderData,\n CaptureOrderParams,\n CaptureOrderData,\n} from '../types/order';\n\n/**\n * Order resource for managing payment orders.\n *\n * @example\n * ```typescript\n * // Create an order\n * const response = await waffo.order().create({\n * paymentRequestId: 'unique-request-id',\n * merchantOrderId: 'order-123',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * orderDescription: 'Test order',\n * notifyUrl: 'https://example.com/webhook',\n * userInfo: {\n * userId: 'user-123',\n * userEmail: 'user@example.com',\n * },\n * paymentInfo: {\n * productName: 'Test Product',\n * },\n * });\n *\n * if (response.isSuccess()) {\n * console.log('Order created:', response.getData());\n * }\n * ```\n */\nexport class OrderResource extends BaseResource {\n private static readonly PATH_CREATE = '/create';\n private static readonly PATH_INQUIRY = '/inquiry';\n private static readonly PATH_CANCEL = '/cancel';\n private static readonly PATH_REFUND = '/refund';\n private static readonly PATH_CAPTURE = '/capture';\n\n /**\n * Creates a new payment order.\n *\n * @param params - Order creation parameters\n * @param options - Optional request options\n * @returns API response with order data\n * @throws WaffoUnknownStatusError for network errors\n */\n async create(\n params: CreateOrderParams,\n options?: RequestOptions\n ): Promise<ApiResponse<CreateOrderData>> {\n return this.httpClient.post<CreateOrderParams, CreateOrderData>(\n this.getPath(OrderResource.PATH_CREATE),\n params,\n options\n );\n }\n\n /**\n * Queries an existing order.\n *\n * @param params - Order inquiry parameters\n * @param options - Optional request options\n * @returns API response with order data\n * @throws WaffoUnknownStatusError for network errors\n */\n async inquiry(\n params: InquiryOrderParams,\n options?: RequestOptions\n ): Promise<ApiResponse<InquiryOrderData>> {\n return this.httpClient.post<InquiryOrderParams, InquiryOrderData>(\n this.getPath(OrderResource.PATH_INQUIRY),\n params,\n options\n );\n }\n\n /**\n * Cancels an existing order.\n *\n * @param params - Order cancellation parameters\n * @param options - Optional request options\n * @returns API response with cancellation result\n * @throws WaffoUnknownStatusError for network errors\n */\n async cancel(\n params: CancelOrderParams,\n options?: RequestOptions\n ): Promise<ApiResponse<CancelOrderData>> {\n return this.httpClient.post<CancelOrderParams, CancelOrderData>(\n this.getPath(OrderResource.PATH_CANCEL),\n params,\n options\n );\n }\n\n /**\n * Refunds an existing order.\n *\n * @param params - Order refund parameters\n * @param options - Optional request options\n * @returns API response with refund result\n * @throws WaffoUnknownStatusError for network errors\n */\n async refund(\n params: RefundOrderParams,\n options?: RequestOptions\n ): Promise<ApiResponse<RefundOrderData>> {\n return this.httpClient.post<RefundOrderParams, RefundOrderData>(\n this.getPath(OrderResource.PATH_REFUND),\n params,\n options\n );\n }\n\n /**\n * Captures an authorized order.\n *\n * @param params - Order capture parameters\n * @param options - Optional request options\n * @returns API response with capture result\n * @throws WaffoUnknownStatusError for network errors\n */\n async capture(\n params: CaptureOrderParams,\n options?: RequestOptions\n ): Promise<ApiResponse<CaptureOrderData>> {\n return this.httpClient.post<CaptureOrderParams, CaptureOrderData>(\n this.getPath(OrderResource.PATH_CAPTURE),\n params,\n options\n );\n }\n}\n","import { BaseResource } from './base-resource';\nimport { ApiResponse } from '../types/api-response';\nimport type { RequestOptions } from '../types/config';\nimport type {\n CreateSubscriptionParams,\n CreateSubscriptionData,\n InquirySubscriptionParams,\n InquirySubscriptionData,\n CancelSubscriptionParams,\n CancelSubscriptionData,\n ManageSubscriptionParams,\n ManageSubscriptionData,\n SubscriptionChangeParams,\n SubscriptionChangeData,\n SubscriptionChangeInquiryParams,\n SubscriptionChangeInquiryData,\n} from '../types/subscription';\n\n/**\n * Subscription resource for managing recurring payments.\n *\n * @example\n * ```typescript\n * // Create a subscription\n * const response = await waffo.subscription().create({\n * subscriptionRequestId: 'unique-request-id',\n * merchantSubscriptionId: 'sub-123',\n * orderCurrency: 'USD',\n * orderAmount: '9.99',\n * orderDescription: 'Monthly subscription',\n * notifyUrl: 'https://example.com/webhook',\n * productInfo: {\n * productId: 'product-123',\n * productName: 'Premium Plan',\n * periodType: 'MONTH',\n * periodValue: 1,\n * },\n * userInfo: {\n * userId: 'user-123',\n * userEmail: 'user@example.com',\n * },\n * paymentInfo: {\n * productName: 'Premium Plan',\n * },\n * });\n *\n * if (response.isSuccess()) {\n * console.log('Subscription created:', response.getData());\n * }\n * ```\n */\nexport class SubscriptionResource extends BaseResource {\n private static readonly PATH_CREATE = '/create';\n private static readonly PATH_INQUIRY = '/inquiry';\n private static readonly PATH_CANCEL = '/cancel';\n private static readonly PATH_MANAGE = '/manage';\n private static readonly PATH_CHANGE = '/change';\n private static readonly PATH_CHANGE_INQUIRY = '/change/inquiry';\n\n /**\n * Creates a new subscription.\n *\n * @param params - Subscription creation parameters\n * @param options - Optional request options\n * @returns API response with subscription data\n * @throws WaffoUnknownStatusError for network errors\n */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions\n ): Promise<ApiResponse<CreateSubscriptionData>> {\n return this.httpClient.post<CreateSubscriptionParams, CreateSubscriptionData>(\n this.getPath(SubscriptionResource.PATH_CREATE),\n params,\n options\n );\n }\n\n /**\n * Queries an existing subscription.\n *\n * @param params - Subscription inquiry parameters\n * @param options - Optional request options\n * @returns API response with subscription data\n * @throws WaffoUnknownStatusError for network errors\n */\n async inquiry(\n params: InquirySubscriptionParams,\n options?: RequestOptions\n ): Promise<ApiResponse<InquirySubscriptionData>> {\n return this.httpClient.post<InquirySubscriptionParams, InquirySubscriptionData>(\n this.getPath(SubscriptionResource.PATH_INQUIRY),\n params,\n options\n );\n }\n\n /**\n * Cancels an existing subscription.\n *\n * @param params - Subscription cancellation parameters\n * @param options - Optional request options\n * @returns API response with cancellation result\n * @throws WaffoUnknownStatusError for network errors\n */\n async cancel(\n params: CancelSubscriptionParams,\n options?: RequestOptions\n ): Promise<ApiResponse<CancelSubscriptionData>> {\n return this.httpClient.post<CancelSubscriptionParams, CancelSubscriptionData>(\n this.getPath(SubscriptionResource.PATH_CANCEL),\n params,\n options\n );\n }\n\n /**\n * Manages an existing subscription (pause, resume, update).\n *\n * @param params - Subscription management parameters\n * @param options - Optional request options\n * @returns API response with management result\n * @throws WaffoUnknownStatusError for network errors\n */\n async manage(\n params: ManageSubscriptionParams,\n options?: RequestOptions\n ): Promise<ApiResponse<ManageSubscriptionData>> {\n return this.httpClient.post<ManageSubscriptionParams, ManageSubscriptionData>(\n this.getPath(SubscriptionResource.PATH_MANAGE),\n params,\n options\n );\n }\n\n /**\n * Changes (upgrades/downgrades) an existing subscription.\n *\n * This method allows changing an active subscription to a new plan with different\n * pricing, billing period, or other terms. The remaining amount from the original\n * subscription can be applied to the new subscription.\n *\n * @param params - Subscription change parameters\n * @param options - Optional request options\n * @returns API response with change result\n * @throws WaffoUnknownStatusError for network errors\n *\n * @example\n * ```typescript\n * const response = await waffo.subscription().change({\n * subscriptionRequest: 'new-request-id',\n * originSubscriptionRequest: 'original-request-id',\n * remainingAmount: '50.00',\n * currency: 'HKD',\n * requestedAt: new Date().toISOString(),\n * notifyUrl: 'https://example.com/webhook',\n * productInfoList: [{\n * description: 'Premium Monthly',\n * periodType: 'MONTH',\n * periodInterval: '1',\n * amount: '199.00',\n * }],\n * userInfo: { userId: 'user-123', userEmail: 'user@example.com' },\n * goodsInfo: { goodsId: 'premium', goodsName: 'Premium Plan' },\n * paymentInfo: { productName: 'SUBSCRIPTION' },\n * });\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * if (data?.subscriptionChangeStatus === 'AUTHORIZATION_REQUIRED') {\n * // Redirect user to authorization URL\n * const webUrl = JSON.parse(data.subscriptionAction || '{}').webUrl;\n * }\n * }\n * ```\n */\n async change(\n params: SubscriptionChangeParams,\n options?: RequestOptions\n ): Promise<ApiResponse<SubscriptionChangeData>> {\n return this.httpClient.post<SubscriptionChangeParams, SubscriptionChangeData>(\n this.getPath(SubscriptionResource.PATH_CHANGE),\n params,\n options\n );\n }\n\n /**\n * Queries the status of a subscription change.\n *\n * Use this method to check the current status of a subscription change operation,\n * especially after network errors or when status is uncertain.\n *\n * @param params - Change inquiry parameters\n * @param options - Optional request options\n * @returns API response with change inquiry data\n *\n * @example\n * ```typescript\n * const response = await waffo.subscription().changeInquiry({\n * subscriptionRequest: 'new-request-id',\n * originSubscriptionRequest: 'original-request-id',\n * });\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * console.log('Change status:', data?.subscriptionChangeStatus);\n * }\n * ```\n */\n async changeInquiry(\n params: SubscriptionChangeInquiryParams,\n options?: RequestOptions\n ): Promise<ApiResponse<SubscriptionChangeInquiryData>> {\n try {\n return await this.httpClient.post<SubscriptionChangeInquiryParams, SubscriptionChangeInquiryData>(\n this.getPath(SubscriptionResource.PATH_CHANGE_INQUIRY),\n params,\n options\n );\n } catch (error) {\n // For inquiry operations, catch unknown status errors and return error response\n if (error && typeof error === 'object' && 'errorCode' in error) {\n return ApiResponse.error('E0001', String((error as { message?: string }).message || 'Unknown error'));\n }\n throw error;\n }\n }\n}\n","import { BaseResource } from './base-resource';\nimport { ApiResponse } from '../types/api-response';\nimport type { RequestOptions } from '../types/config';\nimport type { InquiryRefundParams, InquiryRefundData } from '../types/refund';\n\n/**\n * Refund resource for querying refund status.\n *\n * Note: To initiate a refund, use `waffo.order().refund()` instead.\n *\n * @example\n * ```typescript\n * // Query refund status\n * const response = await waffo.refund().inquiry({\n * refundRequestId: 'refund-request-123',\n * });\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * console.log('Refund status:', data?.refundStatus);\n * }\n * ```\n */\nexport class RefundResource extends BaseResource {\n private static readonly PATH_INQUIRY = '/inquiry';\n\n /**\n * Queries the status of a refund.\n *\n * @param params - Refund inquiry parameters\n * @param options - Optional request options\n * @returns API response with refund data\n * @throws WaffoUnknownStatusError for network errors\n */\n async inquiry(\n params: InquiryRefundParams,\n options?: RequestOptions\n ): Promise<ApiResponse<InquiryRefundData>> {\n return this.httpClient.post<InquiryRefundParams, InquiryRefundData>(\n this.getPath(RefundResource.PATH_INQUIRY),\n params,\n options\n );\n }\n}\n","import { BaseResource } from './base-resource';\nimport { ApiResponse } from '../types/api-response';\nimport type { RequestOptions } from '../types/config';\nimport type {\n InquiryMerchantConfigParams,\n InquiryMerchantConfigData,\n} from '../types/merchant';\n\n/**\n * Merchant config resource for querying merchant configuration.\n *\n * @example\n * ```typescript\n * // Query merchant config\n * const response = await waffo.merchantConfig().inquiry({\n * merchantId: 'merchant-123',\n * });\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * console.log('Merchant status:', data?.merchantStatus);\n * console.log('Supported currencies:', data?.supportedCurrencies);\n * }\n * ```\n */\nexport class MerchantConfigResource extends BaseResource {\n private static readonly PATH_INQUIRY = '/inquiry';\n\n /**\n * Queries merchant configuration.\n *\n * @param params - Merchant config inquiry parameters\n * @param options - Optional request options\n * @returns API response with merchant config data\n * @throws WaffoUnknownStatusError for network errors\n */\n async inquiry(\n params: InquiryMerchantConfigParams,\n options?: RequestOptions\n ): Promise<ApiResponse<InquiryMerchantConfigData>> {\n return this.httpClient.post<InquiryMerchantConfigParams, InquiryMerchantConfigData>(\n this.getPath(MerchantConfigResource.PATH_INQUIRY),\n params,\n options\n );\n }\n}\n","import { BaseResource } from './base-resource';\nimport { ApiResponse } from '../types/api-response';\nimport type { RequestOptions } from '../types/config';\nimport type {\n InquiryPayMethodConfigParams,\n InquiryPayMethodConfigData,\n} from '../types/merchant';\n\n/**\n * Pay method config resource for querying available payment methods.\n *\n * @example\n * ```typescript\n * // Query available payment methods\n * const response = await waffo.payMethodConfig().inquiry({\n * merchantId: 'merchant-123',\n * });\n *\n * if (response.isSuccess()) {\n * const data = response.getData();\n * data?.payMethods?.forEach(method => {\n * console.log(`${method.payMethodName}: ${method.payMethodStatus}`);\n * });\n * }\n * ```\n */\nexport class PayMethodConfigResource extends BaseResource {\n private static readonly PATH_INQUIRY = '/inquiry';\n\n /**\n * Queries available payment methods.\n *\n * @param params - Pay method config inquiry parameters\n * @param options - Optional request options\n * @returns API response with pay method config data\n * @throws WaffoUnknownStatusError for network errors\n */\n async inquiry(\n params: InquiryPayMethodConfigParams,\n options?: RequestOptions\n ): Promise<ApiResponse<InquiryPayMethodConfigData>> {\n return this.httpClient.post<InquiryPayMethodConfigParams, InquiryPayMethodConfigData>(\n this.getPath(PayMethodConfigResource.PATH_INQUIRY),\n params,\n options\n );\n }\n}\n","import type { WaffoConfig } from './types/config';\nimport { WaffoHttpClient } from './core/waffo-http-client';\nimport { WebhookHandler } from './core/webhook-handler';\nimport { OrderResource } from './resources/order-resource';\nimport { SubscriptionResource } from './resources/subscription-resource';\nimport { RefundResource } from './resources/refund-resource';\nimport { MerchantConfigResource } from './resources/merchant-config-resource';\nimport { PayMethodConfigResource } from './resources/pay-method-config-resource';\n\n/**\n * Main entry point for the Waffo SDK.\n *\n * @example\n * ```typescript\n * import { Waffo, Environment } from '@waffo/waffo-node';\n *\n * // Create SDK instance\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: 'your-base64-private-key',\n * waffoPublicKey: 'waffo-base64-public-key',\n * environment: Environment.SANDBOX,\n * merchantId: 'your-merchant-id', // required, auto-injected into requests\n * });\n *\n * // Create an order\n * const response = await waffo.order().create({\n * paymentRequestId: 'unique-request-id',\n * merchantOrderId: 'order-123',\n * orderCurrency: 'USD',\n * orderAmount: '10.00',\n * orderDescription: 'Test order',\n * notifyUrl: 'https://example.com/webhook',\n * userInfo: {\n * userId: 'user-123',\n * userEmail: 'user@example.com',\n * },\n * paymentInfo: {\n * productName: 'Test Product',\n * },\n * });\n *\n * if (response.isSuccess()) {\n * console.log('Order created:', response.getData());\n * } else {\n * console.error('Failed:', response.getCode(), response.getMessage());\n * }\n * ```\n */\nexport class Waffo {\n private readonly config: WaffoConfig;\n private readonly httpClient: WaffoHttpClient;\n\n // Lazy-initialized resources\n private _order?: OrderResource;\n private _subscription?: SubscriptionResource;\n private _refund?: RefundResource;\n private _merchantConfig?: MerchantConfigResource;\n private _payMethodConfig?: PayMethodConfigResource;\n\n /**\n * Creates a new Waffo SDK instance.\n *\n * @param config - SDK configuration\n */\n constructor(config: WaffoConfig) {\n this.config = config;\n this.httpClient = new WaffoHttpClient(config);\n }\n\n /**\n * Creates a Waffo SDK instance from environment variables.\n *\n * Required environment variables:\n * - WAFFO_API_KEY\n * - WAFFO_PRIVATE_KEY\n * - WAFFO_PUBLIC_KEY\n * - WAFFO_ENVIRONMENT (SANDBOX or PRODUCTION)\n *\n * Optional environment variables:\n * - WAFFO_MERCHANT_ID\n * - WAFFO_CONNECT_TIMEOUT\n * - WAFFO_READ_TIMEOUT\n *\n * @returns Waffo SDK instance\n */\n static fromEnv(): Waffo {\n const { WaffoConfig } = require('./types/config');\n return new Waffo(WaffoConfig.fromEnv());\n }\n\n /**\n * Returns the order resource for managing payment orders.\n *\n * @returns Order resource\n */\n order(): OrderResource {\n if (!this._order) {\n this._order = new OrderResource(this.httpClient, '/order');\n }\n return this._order;\n }\n\n /**\n * Returns the subscription resource for managing recurring payments.\n *\n * @returns Subscription resource\n */\n subscription(): SubscriptionResource {\n if (!this._subscription) {\n this._subscription = new SubscriptionResource(this.httpClient, '/subscription');\n }\n return this._subscription;\n }\n\n /**\n * Returns the refund resource for querying refund status.\n *\n * @returns Refund resource\n */\n refund(): RefundResource {\n if (!this._refund) {\n this._refund = new RefundResource(this.httpClient, '/refund');\n }\n return this._refund;\n }\n\n /**\n * Returns the merchant config resource.\n *\n * @returns Merchant config resource\n */\n merchantConfig(): MerchantConfigResource {\n if (!this._merchantConfig) {\n this._merchantConfig = new MerchantConfigResource(this.httpClient, '/merchant/config');\n }\n return this._merchantConfig;\n }\n\n /**\n * Returns the pay method config resource.\n *\n * @returns Pay method config resource\n */\n payMethodConfig(): PayMethodConfigResource {\n if (!this._payMethodConfig) {\n this._payMethodConfig = new PayMethodConfigResource(this.httpClient, '/paymethod/config');\n }\n return this._payMethodConfig;\n }\n\n /**\n * Creates a webhook handler for processing Waffo webhook notifications.\n *\n * @returns Webhook handler\n *\n * @example\n * ```typescript\n * // Setup webhook handler\n * const handler = waffo.webhook()\n * .onPayment((notification) => {\n * console.log('Payment:', notification.orderStatus);\n * })\n * .onRefund((notification) => {\n * console.log('Refund:', notification.refundStatus);\n * })\n * .onSubscriptionStatus((notification) => {\n * console.log('Subscription:', notification.subscriptionStatus);\n * });\n *\n * // In Express.js route handler\n * app.post('/webhook', async (req, res) => {\n * const body = req.body.toString();\n * const signature = req.headers['x-signature'] as string;\n * const result = await handler.handleWebhook(body, signature);\n *\n * res.setHeader('X-SIGNATURE', result.responseSignature);\n * res.status(200).send(result.responseBody);\n * });\n * ```\n */\n webhook(): WebhookHandler {\n return new WebhookHandler(this.config);\n }\n\n /**\n * Returns the current configuration.\n *\n * @returns SDK configuration (with sensitive data)\n */\n getConfig(): WaffoConfig {\n return this.config;\n }\n}\n","/**\n * Waffo Node.js SDK\n *\n * Official Node.js SDK for integrating with Waffo Payment Services.\n *\n * @packageDocumentation\n * @example\n * ```typescript\n * import { Waffo, Environment } from '@waffo/waffo-node';\n *\n * const waffo = new Waffo({\n * apiKey: 'your-api-key',\n * privateKey: 'your-base64-private-key',\n * waffoPublicKey: 'waffo-base64-public-key',\n * environment: Environment.SANDBOX,\n * });\n *\n * const response = await waffo.order().create({ ... });\n * ```\n */\n\n// Main SDK class\nexport { Waffo } from './waffo';\n\n// Configuration\nexport {\n Environment,\n EnvironmentBaseUrl,\n WaffoConfigDefaults,\n type WaffoConfig,\n type WaffoLogger,\n type RequestOptions,\n} from './types/config';\n\n// API Response\nexport { ApiResponse } from './types/api-response';\n\n// Errors\nexport { WaffoError, WaffoErrorCode } from './errors/waffo-error';\nexport { WaffoUnknownStatusError } from './errors/waffo-unknown-status-error';\n\n// Core\nexport {\n WaffoHttpClient,\n WebhookHandler,\n WebhookEventType,\n type WebhookResult,\n type BaseNotification,\n type PaymentNotification,\n type RefundNotification,\n type SubscriptionStatusNotification,\n type SubscriptionPaymentNotification,\n type SubscriptionPeriodChangedNotification,\n} from './core';\n\n// Resources\nexport {\n OrderResource,\n SubscriptionResource,\n RefundResource,\n MerchantConfigResource,\n PayMethodConfigResource,\n} from './resources';\n\n// Order types\nexport type {\n CreateOrderParams,\n CreateOrderData,\n InquiryOrderParams,\n InquiryOrderData,\n CancelOrderParams,\n CancelOrderData,\n RefundOrderParams,\n RefundOrderData,\n CaptureOrderParams,\n CaptureOrderData,\n OrderStatus,\n RefundStatus,\n UserInfo,\n PaymentInfo,\n MerchantInfo,\n GoodsInfo,\n AddressInfo,\n CardInfo,\n RiskData,\n RefundUserInfo,\n} from './types/order';\n\n// Subscription types\nexport type {\n CreateSubscriptionParams,\n CreateSubscriptionData,\n InquirySubscriptionParams,\n InquirySubscriptionData,\n CancelSubscriptionParams,\n CancelSubscriptionData,\n ManageSubscriptionParams,\n ManageSubscriptionData,\n SubscriptionStatus,\n SubscriptionManageAction,\n PeriodType,\n ProductInfo,\n SubscriptionUserInfo,\n SubscriptionPaymentInfo,\n SubscriptionMerchantInfo,\n} from './types/subscription';\n\n// Refund types\nexport type {\n InquiryRefundParams,\n InquiryRefundData,\n RefundFailedReason,\n} from './types/refund';\n\n// Merchant types\nexport type {\n InquiryMerchantConfigParams,\n InquiryMerchantConfigData,\n InquiryPayMethodConfigParams,\n InquiryPayMethodConfigData,\n PayMethodInfo,\n} from './types/merchant';\n\n// Network types\nexport type { HttpTransport, HttpRequest, HttpResponse } from './net';\n\n// Utils\nexport { RsaUtils } from './utils/rsa-utils';\n"]}
|