@waffo/waffo-node 2.2.0 → 2.3.0

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/dist/index.d.ts CHANGED
@@ -170,1230 +170,1283 @@ interface RequestOptions {
170
170
  }
171
171
 
172
172
  /**
173
- * Webhook event types sent by Waffo.
174
- */
175
- declare enum WebhookEventType {
176
- PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
177
- REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
178
- SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
179
- SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
180
- }
181
- /**
182
- * Result of webhook handling.
173
+ * Subscription-related type definitions.
174
+ *
175
+ * Note: Full type definitions should be generated from openapi.json.
176
+ * These are placeholder interfaces for the SDK structure.
183
177
  */
184
- interface WebhookResult {
185
- /** Whether the webhook was processed successfully */
186
- success: boolean;
187
- /** Response body to send back to Waffo */
188
- responseBody: string;
189
- /** Signature for the response body */
190
- responseSignature: string;
191
- /** Error message if processing failed */
192
- error?: string;
193
- }
194
178
  /**
195
- * Base notification interface.
179
+ * Create subscription request parameters.
196
180
  */
197
- interface BaseNotification {
198
- eventType: string;
181
+ interface CreateSubscriptionParams {
182
+ /**
183
+ * Subscription request ID sent from Merchant (max 32 characters).
184
+ * Used for idempotent check.
185
+ */
186
+ subscriptionRequest: string;
187
+ merchantSubscriptionId: string;
188
+ currency: string;
189
+ amount: string;
190
+ notifyUrl: string;
191
+ productInfo: ProductInfo;
192
+ userInfo: SubscriptionUserInfo;
193
+ paymentInfo: SubscriptionPaymentInfo;
194
+ merchantInfo?: SubscriptionMerchantInfo;
195
+ goodsInfo?: {
196
+ goodsId: string;
197
+ goodsName: string;
198
+ goodsCategory?: string;
199
+ goodsUrl?: string;
200
+ goodsQuantity?: number;
201
+ [key: string]: unknown;
202
+ };
203
+ successRedirectUrl?: string;
204
+ failedRedirectUrl?: string;
205
+ cancelRedirectUrl?: string;
206
+ subscriptionManagementUrl?: string;
207
+ requestedAt?: string;
208
+ extendInfo?: string;
209
+ /**
210
+ * Order expiry time (ISO 8601 format, max 24 characters).
211
+ */
212
+ orderExpiredAt?: string;
213
+ [key: string]: unknown;
199
214
  }
200
215
  /**
201
- * Payment notification result payload (21 fields).
216
+ * Create subscription response data.
202
217
  */
203
- interface PaymentNotificationResult {
204
- paymentRequestId?: string;
205
- merchantOrderId?: string;
206
- acquiringOrderId?: string;
207
- orderStatus?: string;
208
- orderAction?: string;
209
- orderCurrency?: string;
210
- orderAmount?: string;
211
- userCurrency?: string;
212
- finalDealAmount?: string;
213
- orderDescription?: string;
214
- merchantInfo?: Record<string, unknown>;
215
- userInfo?: Record<string, unknown>;
216
- goodsInfo?: Record<string, unknown>;
217
- addressInfo?: Record<string, unknown>;
218
- paymentInfo?: Record<string, unknown>;
219
- orderRequestedAt?: string;
220
- orderExpiredAt?: string;
221
- orderUpdatedAt?: string;
222
- orderCompletedAt?: string;
223
- orderFailedReason?: Record<string, unknown>;
224
- extendInfo?: string;
218
+ interface CreateSubscriptionData {
219
+ subscriptionRequest?: string;
220
+ merchantSubscriptionId?: string;
221
+ subscriptionId?: string;
222
+ subscriptionStatus?: SubscriptionStatus;
223
+ subscriptionAction?: string;
225
224
  [key: string]: unknown;
226
225
  }
227
226
  /**
228
- * Refund notification result payload (17 fields).
227
+ * Inquiry subscription request parameters.
229
228
  */
230
- interface RefundNotificationResult {
231
- refundRequestId?: string;
232
- merchantRefundOrderId?: string;
233
- acquiringOrderId?: string;
234
- acquiringRefundOrderId?: string;
235
- origPaymentRequestId?: string;
236
- refundAmount?: string;
237
- refundStatus?: string;
238
- remainingRefundAmount?: string;
239
- userCurrency?: string;
240
- finalDealAmount?: string;
241
- refundReason?: string;
242
- refundRequestedAt?: string;
243
- refundUpdatedAt?: string;
244
- refundCompletedAt?: string;
245
- refundFailedReason?: Record<string, unknown>;
246
- userInfo?: Record<string, unknown>;
247
- extendInfo?: string;
229
+ interface InquirySubscriptionParams {
230
+ subscriptionRequest?: string;
231
+ subscriptionId?: string;
232
+ merchantInfo?: SubscriptionMerchantInfo;
248
233
  [key: string]: unknown;
249
234
  }
250
235
  /**
251
- * Subscription notification result payload (20 fields).
252
- * Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
236
+ * Inquiry subscription response data.
253
237
  */
254
- interface SubscriptionNotificationResult {
238
+ interface InquirySubscriptionData {
255
239
  subscriptionRequest?: string;
256
240
  merchantSubscriptionId?: string;
257
241
  subscriptionId?: string;
258
- subscriptionStatus?: string;
242
+ payMethodSubscriptionId?: string;
243
+ subscriptionStatus?: SubscriptionStatus;
259
244
  subscriptionAction?: string;
260
245
  currency?: string;
261
- amount?: string;
262
246
  userCurrency?: string;
263
- productInfo?: Record<string, unknown>;
264
- merchantInfo?: Record<string, unknown>;
265
- userInfo?: Record<string, unknown>;
266
- goodsInfo?: Record<string, unknown>;
267
- addressInfo?: Record<string, unknown>;
268
- paymentInfo?: Record<string, unknown>;
269
- requestedAt?: string;
270
- updatedAt?: string;
271
- failedReason?: Record<string, unknown>;
272
- extendInfo?: string;
273
- subscriptionManagementUrl?: string;
274
- paymentDetails?: Record<string, unknown>[];
247
+ amount?: string;
248
+ productInfo?: ProductInfo;
275
249
  [key: string]: unknown;
276
250
  }
277
251
  /**
278
- * Payment notification from Waffo.
252
+ * Cancel subscription request parameters.
279
253
  */
280
- interface PaymentNotification extends BaseNotification {
281
- eventType: 'PAYMENT_NOTIFICATION';
282
- result?: PaymentNotificationResult;
254
+ interface CancelSubscriptionParams {
255
+ subscriptionId?: string;
256
+ merchantId?: string;
257
+ requestedAt?: string;
283
258
  [key: string]: unknown;
284
259
  }
285
260
  /**
286
- * Refund notification from Waffo.
261
+ * Cancel subscription response data.
287
262
  */
288
- interface RefundNotification extends BaseNotification {
289
- eventType: 'REFUND_NOTIFICATION';
290
- result?: RefundNotificationResult;
263
+ interface CancelSubscriptionData {
264
+ subscriptionRequest?: string;
265
+ merchantSubscriptionId?: string;
266
+ subscriptionId?: string;
267
+ subscriptionStatus?: SubscriptionStatus;
291
268
  [key: string]: unknown;
292
269
  }
293
270
  /**
294
- * Subscription status notification from Waffo.
271
+ * Manage subscription request parameters.
295
272
  */
296
- interface SubscriptionStatusNotification extends BaseNotification {
297
- eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
298
- result?: SubscriptionNotificationResult;
273
+ interface ManageSubscriptionParams {
274
+ subscriptionId: string;
275
+ merchantId: string;
276
+ action: SubscriptionManageAction;
277
+ newAmount?: string;
278
+ newPeriodType?: PeriodType;
279
+ newPeriodValue?: number;
280
+ requestedAt?: string;
299
281
  [key: string]: unknown;
300
282
  }
301
283
  /**
302
- * Subscription period changed notification from Waffo.
284
+ * Manage subscription response data.
303
285
  */
304
- interface SubscriptionPeriodChangedNotification extends BaseNotification {
305
- eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
306
- result?: SubscriptionNotificationResult;
286
+ interface ManageSubscriptionData {
287
+ subscriptionId?: string;
288
+ subscriptionStatus?: SubscriptionStatus;
307
289
  [key: string]: unknown;
308
290
  }
309
- type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
310
- type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
311
- type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
312
- type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
313
- type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
314
291
  /**
315
- * Webhook handler for processing Waffo webhook notifications.
316
- *
317
- * @example
318
- * ```typescript
319
- * // Setup handler
320
- * const handler = waffo.webhook()
321
- * .onPayment((notification) => {
322
- * console.log('Payment:', notification.result?.orderStatus);
323
- * })
324
- * .onRefund((notification) => {
325
- * console.log('Refund:', notification.result?.refundStatus);
326
- * });
327
- *
328
- * // Process webhook (e.g., in Express.js)
329
- * app.post('/webhook', async (req, res) => {
330
- * const body = req.body.toString();
331
- * const signature = req.headers['x-signature'];
332
- * const result = await handler.handleWebhook(body, signature);
333
- *
334
- * res.setHeader('X-SIGNATURE', result.responseSignature);
335
- * res.status(200).send(result.responseBody);
336
- * });
337
- * ```
292
+ * Subscription status enum.
293
+ * Based on openapi.json SubscriptionInquiryResponse.subscriptionStatus.
338
294
  */
339
- declare class WebhookHandler {
340
- private readonly waffoPublicKey;
341
- private readonly privateKey;
342
- private readonly logger?;
343
- private paymentHandler?;
344
- private refundHandler?;
345
- private subscriptionStatusHandler?;
346
- private subscriptionPaymentHandler?;
347
- private subscriptionPeriodChangedHandler?;
348
- constructor(config: WaffoConfig);
295
+ type SubscriptionStatus = 'AUTHORIZATION_REQUIRED' | 'IN_PROGRESS' | 'ACTIVE' | 'CLOSE' | 'MERCHANT_CANCELLED' | 'USER_CANCELLED' | 'CHANNEL_CANCELLED' | 'EXPIRED';
296
+ /**
297
+ * Subscription manage action enum.
298
+ */
299
+ type SubscriptionManageAction = 'PAUSE' | 'RESUME' | 'UPDATE_AMOUNT' | 'UPDATE_PERIOD';
300
+ /**
301
+ * Period type enum.
302
+ * Values: DAILY, WEEKLY, MONTHLY
303
+ */
304
+ type PeriodType = 'DAILY' | 'WEEKLY' | 'MONTHLY';
305
+ /**
306
+ * Product information for subscription.
307
+ * Based on openapi.json ProductInfo schema.
308
+ */
309
+ interface ProductInfo {
349
310
  /**
350
- * Registers a handler for payment notifications.
311
+ * Subscription product description (max 128 characters).
312
+ * Often appearing to user when asking user's confirmation.
351
313
  */
352
- onPayment(handler: PaymentHandler): this;
314
+ description: string;
353
315
  /**
354
- * Registers a handler for refund notifications.
316
+ * Subscription product period type: DAILY, WEEKLY, MONTHLY.
355
317
  */
356
- onRefund(handler: RefundHandler): this;
318
+ periodType: PeriodType;
357
319
  /**
358
- * Registers a handler for subscription status notifications.
320
+ * Period interval (max 12 characters).
321
+ * - DAILY: 1-365
322
+ * - WEEKLY: 1-4
323
+ * - MONTHLY: 1-12
359
324
  */
360
- onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
325
+ periodInterval: string;
361
326
  /**
362
- * Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
363
- * Only called when onSubscriptionStatus handler is not registered.
327
+ * Number of billing periods until subscription ends (max 24 characters).
328
+ * Empty means no defined end period.
364
329
  */
365
- onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
330
+ numberOfPeriod?: string;
366
331
  /**
367
- * Registers a handler for subscription period changed notifications.
332
+ * Trial period amount (max 24 characters).
368
333
  */
369
- onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
334
+ trialPeriodAmount?: string;
370
335
  /**
371
- * Processes a webhook notification.
372
- *
373
- * @param body - The raw webhook body
374
- * @param signature - The X-SIGNATURE header value
375
- * @returns Result with response body and signature
336
+ * Number of trial periods (max 12 characters).
376
337
  */
377
- handleWebhook(body: string, signature: string): Promise<WebhookResult>;
338
+ numberOfTrialPeriod?: string;
378
339
  /**
379
- * Verifies a webhook signature.
380
- *
381
- * @param body - The raw webhook body
382
- * @param signature - The X-SIGNATURE header value
383
- * @returns true if signature is valid
340
+ * Trial period type: DAILY, WEEKLY, MONTHLY.
341
+ * If omitted, uses periodType value by default.
384
342
  */
385
- verifySignature(body: string, signature: string): boolean;
343
+ trialPeriodType?: PeriodType;
386
344
  /**
387
- * Builds a success response with signature.
345
+ * Trial period interval (max 12 characters).
346
+ * If omitted, uses periodInterval value by default.
388
347
  */
389
- buildSuccessResponse(): {
390
- body: string;
391
- signature: string;
392
- };
348
+ trialPeriodInterval?: string;
393
349
  /**
394
- * Builds a failed response with signature.
350
+ * When the subscription starts (ISO 8601 format).
395
351
  */
396
- buildFailedResponse(message: string): {
397
- body: string;
398
- signature: string;
399
- };
400
- private createSuccessResult;
401
- private createFailedResult;
402
- }
403
-
404
- /**
405
- * Generic API response wrapper.
406
- *
407
- * All API responses are wrapped in this class for consistent handling.
408
- *
409
- * @example
410
- * ```typescript
411
- * const response = await waffo.order().create(params);
412
- *
413
- * if (response.isSuccess()) {
414
- * const data = response.getData();
415
- * console.log('Order ID:', data?.acquiringOrderId);
416
- * } else {
417
- * console.error(`Error [${response.code}]: ${response.getMessage()}`);
418
- * }
419
- * ```
420
- */
421
- declare class ApiResponse<T> {
422
- /** Response code. "0" indicates success, other values indicate errors. */
423
- readonly code: string;
424
- /** Response data (present when code is "0") */
425
- readonly data?: T;
426
- /** Error message (present when code is not "0") */
427
- readonly message?: string;
428
- private constructor();
352
+ startDateTime?: string;
429
353
  /**
430
- * Creates a successful response.
431
- *
432
- * @param data - The response data
354
+ * When the subscription ends (ISO 8601 format).
433
355
  */
434
- static success<T>(data?: T): ApiResponse<T>;
356
+ endDateTime?: string;
435
357
  /**
436
- * Creates an error response.
437
- *
438
- * @param code - The error code
439
- * @param message - The error message
358
+ * When the next payment is due (ISO 8601 format).
440
359
  */
441
- static error<T>(code: string, message?: string): ApiResponse<T>;
360
+ nextPaymentDateTime?: string;
442
361
  /**
443
- * Checks if the response indicates success.
444
- *
445
- * @returns true if the response code is "0"
362
+ * Current billing period number.
446
363
  */
447
- isSuccess(): boolean;
364
+ currentPeriod?: string;
365
+ [key: string]: unknown;
366
+ }
367
+ /**
368
+ * User information for subscription.
369
+ */
370
+ interface SubscriptionUserInfo {
371
+ userId: string;
372
+ userEmail: string;
373
+ userPhone?: string;
374
+ userFirstName?: string;
375
+ userLastName?: string;
376
+ userCountryCode?: string;
377
+ userBrowserIp?: string;
378
+ userAgent?: string;
379
+ [key: string]: unknown;
380
+ }
381
+ /**
382
+ * Payment information for subscription.
383
+ */
384
+ interface SubscriptionPaymentInfo {
385
+ productName: string;
386
+ payMethodType?: string;
387
+ payMethodName?: string;
388
+ [key: string]: unknown;
389
+ }
390
+ /**
391
+ * Merchant information for subscription.
392
+ */
393
+ interface SubscriptionMerchantInfo {
394
+ merchantId: string;
395
+ subMerchantId?: string;
396
+ [key: string]: unknown;
397
+ }
398
+ /**
399
+ * Subscription information in payment order response and webhook notifications.
400
+ */
401
+ interface SubscriptionInfo {
448
402
  /**
449
- * Gets the response data.
450
- *
451
- * @returns The response data, or undefined if the response is an error
403
+ * Subscription request ID (max 32 characters).
404
+ * @deprecated Use merchantRequest instead for consistency with OpenAPI spec.
452
405
  */
453
- getData(): T | undefined;
406
+ subscriptionRequest?: string;
454
407
  /**
455
- * Gets the error message.
456
- *
457
- * @returns The error message, or undefined if the response is successful
408
+ * Merchant request ID (max 32 characters).
409
+ * Same as subscriptionRequest, aligned with OpenAPI specification.
458
410
  */
459
- getMessage(): string | undefined;
411
+ merchantRequest?: string;
460
412
  /**
461
- * Gets the response code.
462
- *
463
- * @returns The response code
413
+ * Waffo subscription ID (max 64 characters).
464
414
  */
465
- getCode(): string;
415
+ subscriptionId?: string;
466
416
  /**
467
- * Gets the response data or throws an error.
468
- *
469
- * @returns The response data
470
- * @throws Error if the response is not successful or data is undefined
417
+ * Which period the subscription payment belongs to (max 12 characters).
471
418
  */
472
- getDataOrThrow(): T;
419
+ period?: string;
420
+ [key: string]: unknown;
473
421
  }
474
-
475
422
  /**
476
- * HTTP client for making requests to the Waffo API.
477
- *
478
- * Handles:
479
- * - Request signing with merchant's private key
480
- * - Response signature verification with Waffo's public key
481
- * - MerchantId auto-injection
482
- * - Error handling and timeout management
423
+ * Subscription change status values.
483
424
  */
484
- declare class WaffoHttpClient {
485
- private readonly baseUrl;
486
- private readonly apiKey;
487
- private readonly privateKey;
488
- private readonly waffoPublicKey;
489
- private readonly merchantId;
490
- private readonly connectTimeout;
491
- private readonly readTimeout;
492
- private readonly logger?;
493
- private readonly httpTransport;
494
- constructor(config: WaffoConfig);
425
+ type SubscriptionChangeStatus = 'IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'SUCCESS' | 'CLOSED';
426
+ /**
427
+ * Product information for subscription change operations.
428
+ * Contains billing period settings for the new subscription plan.
429
+ */
430
+ interface SubscriptionChangeProductInfo {
495
431
  /**
496
- * Sends a POST request to the Waffo API.
497
- *
498
- * @param path - API endpoint path (e.g., "/order/create")
499
- * @param request - Request body
500
- * @param options - Per-request options
501
- * @returns API response
502
- * @throws WaffoUnknownStatusError for network errors or unknown status
432
+ * Product description (max 128 characters).
503
433
  */
504
- post<T extends object, R>(path: string, request: T, options?: RequestOptions): Promise<ApiResponse<R>>;
434
+ description: string;
505
435
  /**
506
- * Parses the API response body.
436
+ * Billing period type: DAILY, WEEKLY, MONTHLY.
507
437
  */
508
- private parseResponse;
438
+ periodType: PeriodType;
509
439
  /**
510
- * Auto-injects merchantId into the request if configured.
440
+ * Subscription amount for this product (max 12 characters).
511
441
  */
512
- private injectMerchantIdIfNeeded;
442
+ amount: string;
513
443
  /**
514
- * Checks if the error is a network-related error.
444
+ * Billing interval (max 12 characters).
515
445
  */
516
- private isNetworkError;
517
- }
518
-
519
- /**
520
- * Base class for API resources.
521
- */
522
- declare abstract class BaseResource {
523
- protected readonly httpClient: WaffoHttpClient;
524
- protected readonly basePath: string;
525
- constructor(httpClient: WaffoHttpClient, basePath: string);
446
+ periodInterval: string;
526
447
  /**
527
- * Gets the full path for an endpoint.
528
- *
529
- * @param endpoint - The endpoint (e.g., "/create")
530
- * @returns Full path (e.g., "/order/create")
448
+ * Total number of billing periods (max 24 characters, empty for unlimited).
531
449
  */
532
- protected getPath(endpoint: string): string;
533
- }
534
-
535
- /**
536
- * Order-related type definitions.
537
- *
538
- * Note: Full type definitions should be generated from openapi.json.
539
- * These are placeholder interfaces for the SDK structure.
540
- */
541
- /**
542
- * Create order request parameters.
543
- */
544
- interface CreateOrderParams {
545
- paymentRequestId: string;
546
- merchantOrderId: string;
547
- orderCurrency: string;
548
- orderAmount: string;
549
- orderDescription: string;
550
- notifyUrl: string;
551
- userInfo: UserInfo;
552
- paymentInfo: PaymentInfo;
553
- merchantInfo?: MerchantInfo;
554
- goodsInfo?: GoodsInfo;
555
- addressInfo?: AddressInfo;
556
- cardInfo?: CardInfo;
557
- riskData?: RiskData;
558
- userCurrency?: string;
559
- successRedirectUrl?: string;
560
- failedRedirectUrl?: string;
561
- cancelRedirectUrl?: string;
562
- orderRequestedAt?: string;
563
- orderExpiredAt?: string;
564
- extendInfo?: string;
565
- metadata?: string;
450
+ numberOfPeriod?: string;
451
+ /**
452
+ * Trial period amount (max 24 characters).
453
+ */
454
+ trialPeriodAmount?: string;
455
+ /**
456
+ * Number of trial periods (max 12 characters).
457
+ */
458
+ numberOfTrialPeriod?: string;
459
+ /**
460
+ * Trial period type: DAILY, WEEKLY, MONTHLY.
461
+ */
462
+ trialPeriodType?: PeriodType;
463
+ /**
464
+ * Trial period interval (max 12 characters).
465
+ */
466
+ trialPeriodInterval?: string;
566
467
  [key: string]: unknown;
567
468
  }
568
469
  /**
569
- * Create order response data.
470
+ * Subscription change request parameters.
570
471
  */
571
- interface CreateOrderData {
572
- paymentRequestId?: string;
573
- merchantOrderId?: string;
574
- acquiringOrderId?: string;
575
- orderStatus?: OrderStatus;
576
- orderAction?: string;
577
- [key: string]: unknown;
578
- }
579
- /**
580
- * Inquiry order request parameters.
581
- */
582
- interface InquiryOrderParams {
583
- paymentRequestId?: string;
584
- acquiringOrderId?: string;
585
- merchantInfo?: MerchantInfo;
472
+ interface SubscriptionChangeParams {
473
+ /**
474
+ * New unique request ID for this change (max 32 characters).
475
+ */
476
+ subscriptionRequest: string;
477
+ /**
478
+ * New merchant subscription plan ID (max 64 characters).
479
+ */
480
+ merchantSubscriptionId?: string;
481
+ /**
482
+ * Original subscription request ID to be changed (max 32 characters).
483
+ */
484
+ originSubscriptionRequest: string;
485
+ /**
486
+ * Remaining amount from the original subscription (max 24 characters).
487
+ */
488
+ remainingAmount: string;
489
+ /**
490
+ * Subscription currency code (ISO 4217).
491
+ */
492
+ currency: string;
493
+ /**
494
+ * User payment currency (when different from merchant currency).
495
+ */
496
+ userCurrency?: string;
497
+ /**
498
+ * Request time (ISO 8601 format). Auto-injected if not provided.
499
+ */
500
+ requestedAt?: string;
501
+ /**
502
+ * Redirect URL after successful subscription change.
503
+ */
504
+ successRedirectUrl?: string;
505
+ /**
506
+ * Redirect URL after failed subscription change.
507
+ */
508
+ failedRedirectUrl?: string;
509
+ /**
510
+ * Async notification URL for change notifications.
511
+ */
512
+ notifyUrl: string;
513
+ /**
514
+ * Redirect URL after user cancels.
515
+ */
516
+ cancelRedirectUrl?: string;
517
+ /**
518
+ * Merchant-side subscription management URL.
519
+ */
520
+ subscriptionManagementUrl?: string;
521
+ /**
522
+ * Reserved extend info (JSON format).
523
+ */
524
+ extendInfo?: string;
525
+ /**
526
+ * Order expiry time (ISO 8601 format).
527
+ */
528
+ orderExpiredAt?: string;
529
+ /**
530
+ * New subscription product information list.
531
+ */
532
+ productInfoList: SubscriptionChangeProductInfo[];
533
+ /**
534
+ * Merchant information.
535
+ */
536
+ merchantInfo?: SubscriptionMerchantInfo;
537
+ /**
538
+ * User information.
539
+ */
540
+ userInfo: SubscriptionUserInfo;
541
+ /**
542
+ * Goods information.
543
+ */
544
+ goodsInfo: {
545
+ goodsId: string;
546
+ goodsName: string;
547
+ goodsCategory?: string;
548
+ goodsUrl?: string;
549
+ appName?: string;
550
+ skuName?: string;
551
+ goodsUniquePrice?: string;
552
+ goodsQuantity?: number;
553
+ [key: string]: unknown;
554
+ };
555
+ /**
556
+ * Address information.
557
+ */
558
+ addressInfo?: {
559
+ address?: string;
560
+ city?: string;
561
+ region?: string;
562
+ postcode?: string;
563
+ addressCountryCode?: string;
564
+ [key: string]: unknown;
565
+ };
566
+ /**
567
+ * Payment method information.
568
+ */
569
+ paymentInfo: SubscriptionPaymentInfo;
570
+ /**
571
+ * Risk control auxiliary data.
572
+ */
573
+ riskData?: {
574
+ userType?: string;
575
+ userCategory?: string;
576
+ userLegalName?: string;
577
+ userDisplayName?: string;
578
+ userRegistrationIp?: string;
579
+ userLastSeenIp?: string;
580
+ userIsNew?: string;
581
+ userIsFirstPurchase?: string;
582
+ [key: string]: unknown;
583
+ };
586
584
  [key: string]: unknown;
587
585
  }
588
586
  /**
589
- * Inquiry order response data.
587
+ * Subscription change response data.
590
588
  */
591
- interface InquiryOrderData {
592
- paymentRequestId?: string;
593
- merchantOrderId?: string;
594
- acquiringOrderId?: string;
595
- orderStatus?: OrderStatus;
596
- orderCurrency?: string;
597
- orderAmount?: string;
598
- finalDealAmount?: string;
589
+ interface SubscriptionChangeData {
599
590
  /**
600
- * Refund expiry time (ISO 8601 format).
591
+ * Original subscription request ID that was changed.
601
592
  */
602
- refundExpiryAt?: string;
593
+ originSubscriptionRequest?: string;
594
+ /**
595
+ * New subscription request ID after the change.
596
+ */
597
+ subscriptionRequest?: string;
598
+ /**
599
+ * Merchant's new subscription plan ID.
600
+ */
601
+ merchantSubscriptionId?: string;
602
+ /**
603
+ * Current status of the subscription change.
604
+ */
605
+ subscriptionChangeStatus?: SubscriptionChangeStatus;
606
+ /**
607
+ * Action guide for user to complete authorization.
608
+ * When subscriptionChangeStatus = AUTHORIZATION_REQUIRED, contains webUrl.
609
+ */
610
+ subscriptionAction?: string;
611
+ /**
612
+ * New Waffo subscription ID.
613
+ */
614
+ subscriptionId?: string;
603
615
  [key: string]: unknown;
604
616
  }
605
617
  /**
606
- * Cancel order request parameters.
618
+ * Subscription change inquiry request parameters.
607
619
  */
608
- interface CancelOrderParams {
609
- paymentRequestId?: string;
610
- acquiringOrderId?: string;
611
- merchantInfo?: MerchantInfo;
612
- orderRequestedAt?: string;
620
+ interface SubscriptionChangeInquiryParams {
621
+ /**
622
+ * Original subscription request ID that was changed.
623
+ */
624
+ originSubscriptionRequest: string;
625
+ /**
626
+ * New subscription request ID after the change.
627
+ */
628
+ subscriptionRequest: string;
613
629
  [key: string]: unknown;
614
630
  }
615
631
  /**
616
- * Cancel order response data.
632
+ * Subscription change inquiry response data.
617
633
  */
618
- interface CancelOrderData {
619
- paymentRequestId?: string;
620
- merchantOrderId?: string;
621
- acquiringOrderId?: string;
622
- orderStatus?: OrderStatus;
634
+ interface SubscriptionChangeInquiryData {
635
+ /**
636
+ * New subscription request ID after the change.
637
+ */
638
+ subscriptionRequest?: string;
639
+ /**
640
+ * Original subscription request ID that was changed.
641
+ */
642
+ originSubscriptionRequest?: string;
643
+ /**
644
+ * Merchant's new subscription plan ID.
645
+ */
646
+ merchantSubscriptionId?: string;
647
+ /**
648
+ * New Waffo subscription ID.
649
+ */
650
+ subscriptionId?: string;
651
+ /**
652
+ * Current status of the subscription change.
653
+ */
654
+ subscriptionChangeStatus?: SubscriptionChangeStatus;
655
+ /**
656
+ * Action guide for user authorization.
657
+ */
658
+ subscriptionAction?: string;
659
+ /**
660
+ * Remaining amount from the original subscription.
661
+ */
662
+ remainingAmount?: string;
663
+ /**
664
+ * Subscription currency (ISO 4217).
665
+ */
666
+ currency?: string;
667
+ /**
668
+ * User payment currency.
669
+ */
670
+ userCurrency?: string;
671
+ /**
672
+ * Request time.
673
+ */
674
+ requestedAt?: string;
675
+ /**
676
+ * Subscription management URL.
677
+ */
678
+ subscriptionManagementUrl?: string;
679
+ /**
680
+ * Extended info.
681
+ */
682
+ extendInfo?: string;
683
+ /**
684
+ * Order expiry time.
685
+ */
686
+ orderExpiredAt?: string;
687
+ /**
688
+ * Product information list.
689
+ */
690
+ productInfoList?: SubscriptionChangeProductInfo[];
691
+ /**
692
+ * Merchant information.
693
+ */
694
+ merchantInfo?: SubscriptionMerchantInfo;
695
+ /**
696
+ * User information.
697
+ */
698
+ userInfo?: SubscriptionUserInfo;
699
+ /**
700
+ * Goods information.
701
+ */
702
+ goodsInfo?: {
703
+ goodsId?: string;
704
+ goodsName?: string;
705
+ goodsCategory?: string;
706
+ goodsUrl?: string;
707
+ appName?: string;
708
+ skuName?: string;
709
+ goodsUniquePrice?: string;
710
+ goodsQuantity?: number;
711
+ [key: string]: unknown;
712
+ };
713
+ /**
714
+ * Address information.
715
+ */
716
+ addressInfo?: {
717
+ address?: string;
718
+ city?: string;
719
+ region?: string;
720
+ postcode?: string;
721
+ addressCountryCode?: string;
722
+ [key: string]: unknown;
723
+ };
724
+ /**
725
+ * Payment information.
726
+ */
727
+ paymentInfo?: SubscriptionPaymentInfo;
623
728
  [key: string]: unknown;
624
729
  }
730
+
625
731
  /**
626
- * Refund order request parameters.
732
+ * Webhook event types sent by Waffo.
627
733
  */
628
- interface RefundOrderParams {
629
- refundRequestId: string;
630
- paymentRequestId?: string;
631
- acquiringOrderId?: string;
632
- merchantRefundOrderId?: string;
633
- merchantInfo?: MerchantInfo;
634
- refundAmount: string;
635
- refundReason?: string;
636
- requestedAt?: string;
637
- notifyUrl?: string;
638
- userInfo?: RefundUserInfo;
639
- extendInfo?: string;
640
- [key: string]: unknown;
734
+ declare enum WebhookEventType {
735
+ PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
736
+ REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
737
+ SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
738
+ SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
641
739
  }
642
740
  /**
643
- * Refund order response data.
741
+ * Result of webhook handling.
644
742
  */
645
- interface RefundOrderData {
646
- refundRequestId?: string;
647
- merchantRefundOrderId?: string;
648
- acquiringOrderId?: string;
649
- acquiringRefundOrderId?: string;
650
- refundAmount?: string;
651
- refundStatus?: RefundStatus$1;
652
- remainingRefundAmount?: string;
653
- [key: string]: unknown;
743
+ interface WebhookResult {
744
+ /** Whether the webhook was processed successfully */
745
+ success: boolean;
746
+ /** Response body to send back to Waffo */
747
+ responseBody: string;
748
+ /** Signature for the response body */
749
+ responseSignature: string;
750
+ /** Error message if processing failed */
751
+ error?: string;
654
752
  }
655
753
  /**
656
- * Capture order request parameters.
754
+ * Base notification interface.
657
755
  */
658
- interface CaptureOrderParams {
659
- paymentRequestId?: string;
660
- acquiringOrderId?: string;
661
- merchantId: string;
662
- captureAmount?: string;
663
- [key: string]: unknown;
756
+ interface BaseNotification {
757
+ eventType: string;
664
758
  }
665
759
  /**
666
- * Capture order response data.
760
+ * Payment notification result payload (21 fields).
667
761
  */
668
- interface CaptureOrderData {
762
+ interface PaymentNotificationResult {
669
763
  paymentRequestId?: string;
670
764
  merchantOrderId?: string;
671
765
  acquiringOrderId?: string;
672
- orderStatus?: OrderStatus;
673
- [key: string]: unknown;
674
- }
675
- /**
676
- * Order status enum.
677
- */
678
- type OrderStatus = 'PAY_IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'AUTHED_WAITING_CAPTURE' | 'PAY_SUCCESS' | 'ORDER_CLOSE' | 'CAPTURE_IN_PROGRESS';
679
- /**
680
- * Refund status enum.
681
- */
682
- type RefundStatus$1 = 'REFUND_IN_PROGRESS' | 'ORDER_PARTIALLY_REFUNDED' | 'ORDER_FULLY_REFUNDED' | 'ORDER_REFUND_FAILED';
683
- /**
684
- * User information.
685
- */
686
- interface UserInfo {
687
- userId: string;
688
- userEmail: string;
689
- userPhone?: string;
690
- userFirstName?: string;
691
- userLastName?: string;
692
- userCreatedAt?: string;
693
- userTerminal?: string;
694
- userCountryCode?: string;
695
- userBrowserIp?: string;
696
- userAgent?: string;
766
+ orderStatus?: string;
767
+ orderAction?: string;
768
+ orderCurrency?: string;
769
+ orderAmount?: string;
770
+ userCurrency?: string;
771
+ finalDealAmount?: string;
772
+ orderDescription?: string;
773
+ merchantInfo?: Record<string, unknown>;
774
+ userInfo?: Record<string, unknown>;
775
+ goodsInfo?: Record<string, unknown>;
776
+ addressInfo?: Record<string, unknown>;
777
+ paymentInfo?: Record<string, unknown>;
778
+ orderRequestedAt?: string;
779
+ orderExpiredAt?: string;
780
+ orderUpdatedAt?: string;
781
+ orderCompletedAt?: string;
782
+ orderFailedReason?: Record<string, unknown>;
783
+ extendInfo?: string;
697
784
  /**
698
- * User receipt URL (max 256 characters).
785
+ * The associated subscription info.
699
786
  */
700
- userReceiptUrl?: string;
787
+ subscriptionInfo?: SubscriptionInfo;
788
+ /**
789
+ * Refund expiry time (ISO 8601 format).
790
+ */
791
+ refundExpiryAt?: string;
792
+ /**
793
+ * The address of the merchant page to redirect to when user cancels the payment.
794
+ */
795
+ cancelRedirectUrl?: string;
701
796
  [key: string]: unknown;
702
797
  }
703
798
  /**
704
- * Payment information.
799
+ * Refund notification result payload (17 fields).
705
800
  */
706
- interface PaymentInfo {
707
- productName: string;
708
- payMethodType?: string;
709
- payMethodName?: string;
710
- payMethodProperties?: string;
801
+ interface RefundNotificationResult {
802
+ refundRequestId?: string;
803
+ merchantRefundOrderId?: string;
804
+ acquiringOrderId?: string;
805
+ acquiringRefundOrderId?: string;
806
+ origPaymentRequestId?: string;
807
+ refundAmount?: string;
808
+ refundStatus?: string;
809
+ remainingRefundAmount?: string;
810
+ userCurrency?: string;
811
+ finalDealAmount?: string;
812
+ refundReason?: string;
813
+ refundRequestedAt?: string;
814
+ refundUpdatedAt?: string;
815
+ refundCompletedAt?: string;
816
+ refundFailedReason?: Record<string, unknown>;
817
+ userInfo?: Record<string, unknown>;
818
+ extendInfo?: string;
819
+ /**
820
+ * Refund source. Possible values: MERCHANT, RDR, ETHOCA.
821
+ */
822
+ refundSource?: string;
711
823
  [key: string]: unknown;
712
824
  }
713
825
  /**
714
- * Merchant information.
826
+ * Subscription notification result payload (20 fields).
827
+ * Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
715
828
  */
716
- interface MerchantInfo {
717
- merchantId: string;
718
- subMerchantId?: string;
829
+ interface SubscriptionNotificationResult {
830
+ subscriptionRequest?: string;
831
+ merchantSubscriptionId?: string;
832
+ subscriptionId?: string;
833
+ /**
834
+ * Payment method's subscription id.
835
+ */
836
+ payMethodSubscriptionId?: string;
837
+ subscriptionStatus?: string;
838
+ subscriptionAction?: string;
839
+ currency?: string;
840
+ amount?: string;
841
+ userCurrency?: string;
842
+ productInfo?: Record<string, unknown>;
843
+ merchantInfo?: Record<string, unknown>;
844
+ userInfo?: Record<string, unknown>;
845
+ goodsInfo?: Record<string, unknown>;
846
+ addressInfo?: Record<string, unknown>;
847
+ paymentInfo?: Record<string, unknown>;
848
+ requestedAt?: string;
849
+ updatedAt?: string;
850
+ failedReason?: Record<string, unknown>;
851
+ extendInfo?: string;
852
+ subscriptionManagementUrl?: string;
853
+ paymentDetails?: Record<string, unknown>[];
719
854
  [key: string]: unknown;
720
855
  }
721
856
  /**
722
- * Goods information.
857
+ * Payment notification from Waffo.
723
858
  */
724
- interface GoodsInfo {
725
- goodsId?: string;
726
- goodsName?: string;
727
- goodsCategory?: string;
728
- goodsUrl?: string;
729
- appName?: string;
730
- skuName?: string;
731
- goodsUniquePrice?: string;
732
- goodsQuantity?: number;
859
+ interface PaymentNotification extends BaseNotification {
860
+ eventType: 'PAYMENT_NOTIFICATION';
861
+ result?: PaymentNotificationResult;
733
862
  [key: string]: unknown;
734
863
  }
735
864
  /**
736
- * Address information.
865
+ * Refund notification from Waffo.
737
866
  */
738
- interface AddressInfo {
739
- address?: string;
740
- city?: string;
741
- region?: string;
742
- postcode?: string;
743
- addressCountryCode?: string;
867
+ interface RefundNotification extends BaseNotification {
868
+ eventType: 'REFUND_NOTIFICATION';
869
+ result?: RefundNotificationResult;
744
870
  [key: string]: unknown;
745
871
  }
746
872
  /**
747
- * Card information.
873
+ * Subscription status notification from Waffo.
748
874
  */
749
- interface CardInfo {
750
- cardNumber?: string;
751
- cardExpiryYear?: number;
752
- cardExpiryMonth?: number;
753
- cardCvv?: string;
754
- cardHolderName?: string;
755
- threeDsDecision?: string;
875
+ interface SubscriptionStatusNotification extends BaseNotification {
876
+ eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
877
+ result?: SubscriptionNotificationResult;
756
878
  [key: string]: unknown;
757
879
  }
758
880
  /**
759
- * Risk data.
881
+ * Subscription period changed notification from Waffo.
760
882
  */
761
- interface RiskData {
762
- userType?: string;
763
- userCategory?: string;
764
- userLegalName?: string;
765
- userDisplayName?: string;
766
- userRegistrationIp?: string;
767
- userLastSeenIp?: string;
768
- userIsNew?: string;
769
- userIsFirstPurchase?: string;
883
+ interface SubscriptionPeriodChangedNotification extends BaseNotification {
884
+ eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
885
+ result?: SubscriptionNotificationResult;
770
886
  [key: string]: unknown;
771
887
  }
888
+ type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
889
+ type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
890
+ type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
891
+ type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
892
+ type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
772
893
  /**
773
- * Refund user information.
894
+ * Webhook handler for processing Waffo webhook notifications.
895
+ *
896
+ * @example
897
+ * ```typescript
898
+ * // Setup handler
899
+ * const handler = waffo.webhook()
900
+ * .onPayment((notification) => {
901
+ * console.log('Payment:', notification.result?.orderStatus);
902
+ * })
903
+ * .onRefund((notification) => {
904
+ * console.log('Refund:', notification.result?.refundStatus);
905
+ * });
906
+ *
907
+ * // Process webhook (e.g., in Express.js)
908
+ * app.post('/webhook', async (req, res) => {
909
+ * const body = req.body.toString();
910
+ * const signature = req.headers['x-signature'];
911
+ * const result = await handler.handleWebhook(body, signature);
912
+ *
913
+ * res.setHeader('X-SIGNATURE', result.responseSignature);
914
+ * res.status(200).send(result.responseBody);
915
+ * });
916
+ * ```
774
917
  */
775
- interface RefundUserInfo {
776
- userType?: string;
777
- userFirstName?: string;
778
- userLastName?: string;
779
- userEmail?: string;
780
- userPhone?: string;
781
- [key: string]: unknown;
918
+ declare class WebhookHandler {
919
+ private readonly waffoPublicKey;
920
+ private readonly privateKey;
921
+ private readonly logger?;
922
+ private paymentHandler?;
923
+ private refundHandler?;
924
+ private subscriptionStatusHandler?;
925
+ private subscriptionPaymentHandler?;
926
+ private subscriptionPeriodChangedHandler?;
927
+ constructor(config: WaffoConfig);
928
+ /**
929
+ * Registers a handler for payment notifications.
930
+ */
931
+ onPayment(handler: PaymentHandler): this;
932
+ /**
933
+ * Registers a handler for refund notifications.
934
+ */
935
+ onRefund(handler: RefundHandler): this;
936
+ /**
937
+ * Registers a handler for subscription status notifications.
938
+ */
939
+ onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
940
+ /**
941
+ * Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
942
+ * Only called when onSubscriptionStatus handler is not registered.
943
+ */
944
+ onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
945
+ /**
946
+ * Registers a handler for subscription period changed notifications.
947
+ */
948
+ onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
949
+ /**
950
+ * Processes a webhook notification.
951
+ *
952
+ * @param body - The raw webhook body
953
+ * @param signature - The X-SIGNATURE header value
954
+ * @returns Result with response body and signature
955
+ */
956
+ handleWebhook(body: string, signature: string): Promise<WebhookResult>;
957
+ /**
958
+ * Verifies a webhook signature.
959
+ *
960
+ * @param body - The raw webhook body
961
+ * @param signature - The X-SIGNATURE header value
962
+ * @returns true if signature is valid
963
+ */
964
+ verifySignature(body: string, signature: string): boolean;
965
+ /**
966
+ * Builds a success response with signature.
967
+ */
968
+ buildSuccessResponse(): {
969
+ body: string;
970
+ signature: string;
971
+ };
972
+ /**
973
+ * Builds a failed response with signature.
974
+ */
975
+ buildFailedResponse(message: string): {
976
+ body: string;
977
+ signature: string;
978
+ };
979
+ private createSuccessResult;
980
+ private createFailedResult;
782
981
  }
783
982
 
784
983
  /**
785
- * Order resource for managing payment orders.
984
+ * Generic API response wrapper.
985
+ *
986
+ * All API responses are wrapped in this class for consistent handling.
786
987
  *
787
988
  * @example
788
989
  * ```typescript
789
- * // Create an order
790
- * const response = await waffo.order().create({
791
- * paymentRequestId: 'unique-request-id',
792
- * merchantOrderId: 'order-123',
793
- * orderCurrency: 'USD',
794
- * orderAmount: '10.00',
795
- * orderDescription: 'Test order',
796
- * notifyUrl: 'https://example.com/webhook',
797
- * userInfo: {
798
- * userId: 'user-123',
799
- * userEmail: 'user@example.com',
800
- * },
801
- * paymentInfo: {
802
- * productName: 'Test Product',
803
- * },
804
- * });
990
+ * const response = await waffo.order().create(params);
805
991
  *
806
992
  * if (response.isSuccess()) {
807
- * console.log('Order created:', response.getData());
993
+ * const data = response.getData();
994
+ * console.log('Order ID:', data?.acquiringOrderId);
995
+ * } else {
996
+ * console.error(`Error [${response.code}]: ${response.getMessage()}`);
808
997
  * }
809
998
  * ```
810
999
  */
811
- declare class OrderResource extends BaseResource {
812
- private static readonly PATH_CREATE;
813
- private static readonly PATH_INQUIRY;
814
- private static readonly PATH_CANCEL;
815
- private static readonly PATH_REFUND;
816
- private static readonly PATH_CAPTURE;
1000
+ declare class ApiResponse<T> {
1001
+ /** Response code. "0" indicates success, other values indicate errors. */
1002
+ readonly code: string;
1003
+ /** Response data (present when code is "0") */
1004
+ readonly data?: T;
1005
+ /** Error message (present when code is not "0") */
1006
+ readonly message?: string;
1007
+ private constructor();
1008
+ /**
1009
+ * Creates a successful response.
1010
+ *
1011
+ * @param data - The response data
1012
+ */
1013
+ static success<T>(data?: T): ApiResponse<T>;
1014
+ /**
1015
+ * Creates an error response.
1016
+ *
1017
+ * @param code - The error code
1018
+ * @param message - The error message
1019
+ */
1020
+ static error<T>(code: string, message?: string): ApiResponse<T>;
1021
+ /**
1022
+ * Checks if the response indicates success.
1023
+ *
1024
+ * @returns true if the response code is "0"
1025
+ */
1026
+ isSuccess(): boolean;
1027
+ /**
1028
+ * Gets the response data.
1029
+ *
1030
+ * @returns The response data, or undefined if the response is an error
1031
+ */
1032
+ getData(): T | undefined;
1033
+ /**
1034
+ * Gets the error message.
1035
+ *
1036
+ * @returns The error message, or undefined if the response is successful
1037
+ */
1038
+ getMessage(): string | undefined;
1039
+ /**
1040
+ * Gets the response code.
1041
+ *
1042
+ * @returns The response code
1043
+ */
1044
+ getCode(): string;
1045
+ /**
1046
+ * Gets the response data or throws an error.
1047
+ *
1048
+ * @returns The response data
1049
+ * @throws Error if the response is not successful or data is undefined
1050
+ */
1051
+ getDataOrThrow(): T;
1052
+ }
1053
+
1054
+ /**
1055
+ * HTTP client for making requests to the Waffo API.
1056
+ *
1057
+ * Handles:
1058
+ * - Request signing with merchant's private key
1059
+ * - Response signature verification with Waffo's public key
1060
+ * - MerchantId auto-injection
1061
+ * - Error handling and timeout management
1062
+ */
1063
+ declare class WaffoHttpClient {
1064
+ private readonly baseUrl;
1065
+ private readonly apiKey;
1066
+ private readonly privateKey;
1067
+ private readonly waffoPublicKey;
1068
+ private readonly merchantId;
1069
+ private readonly connectTimeout;
1070
+ private readonly readTimeout;
1071
+ private readonly logger?;
1072
+ private readonly httpTransport;
1073
+ constructor(config: WaffoConfig);
817
1074
  /**
818
- * Creates a new payment order.
1075
+ * Sends a POST request to the Waffo API.
819
1076
  *
820
- * @param params - Order creation parameters
821
- * @param options - Optional request options
822
- * @returns API response with order data
823
- * @throws WaffoUnknownStatusError for network errors
1077
+ * @param path - API endpoint path (e.g., "/order/create")
1078
+ * @param request - Request body
1079
+ * @param options - Per-request options
1080
+ * @returns API response
1081
+ * @throws WaffoUnknownStatusError for network errors or unknown status
824
1082
  */
825
- create(params: CreateOrderParams, options?: RequestOptions): Promise<ApiResponse<CreateOrderData>>;
1083
+ post<T extends object, R>(path: string, request: T, options?: RequestOptions): Promise<ApiResponse<R>>;
826
1084
  /**
827
- * Queries an existing order.
828
- *
829
- * @param params - Order inquiry parameters
830
- * @param options - Optional request options
831
- * @returns API response with order data
832
- * @throws WaffoUnknownStatusError for network errors
1085
+ * Parses the API response body.
833
1086
  */
834
- inquiry(params: InquiryOrderParams, options?: RequestOptions): Promise<ApiResponse<InquiryOrderData>>;
1087
+ private parseResponse;
835
1088
  /**
836
- * Cancels an existing order.
837
- *
838
- * @param params - Order cancellation parameters
839
- * @param options - Optional request options
840
- * @returns API response with cancellation result
841
- * @throws WaffoUnknownStatusError for network errors
1089
+ * Auto-injects merchantId into the request if configured.
842
1090
  */
843
- cancel(params: CancelOrderParams, options?: RequestOptions): Promise<ApiResponse<CancelOrderData>>;
1091
+ private injectMerchantIdIfNeeded;
844
1092
  /**
845
- * Refunds an existing order.
846
- *
847
- * @param params - Order refund parameters
848
- * @param options - Optional request options
849
- * @returns API response with refund result
850
- * @throws WaffoUnknownStatusError for network errors
1093
+ * Checks if the error is a network-related error.
851
1094
  */
852
- refund(params: RefundOrderParams, options?: RequestOptions): Promise<ApiResponse<RefundOrderData>>;
1095
+ private isNetworkError;
1096
+ }
1097
+
1098
+ /**
1099
+ * Base class for API resources.
1100
+ */
1101
+ declare abstract class BaseResource {
1102
+ protected readonly httpClient: WaffoHttpClient;
1103
+ protected readonly basePath: string;
1104
+ constructor(httpClient: WaffoHttpClient, basePath: string);
853
1105
  /**
854
- * Captures an authorized order.
1106
+ * Gets the full path for an endpoint.
855
1107
  *
856
- * @param params - Order capture parameters
857
- * @param options - Optional request options
858
- * @returns API response with capture result
859
- * @throws WaffoUnknownStatusError for network errors
1108
+ * @param endpoint - The endpoint (e.g., "/create")
1109
+ * @returns Full path (e.g., "/order/create")
860
1110
  */
861
- capture(params: CaptureOrderParams, options?: RequestOptions): Promise<ApiResponse<CaptureOrderData>>;
1111
+ protected getPath(endpoint: string): string;
862
1112
  }
863
1113
 
864
1114
  /**
865
- * Subscription-related type definitions.
1115
+ * Order-related type definitions.
866
1116
  *
867
1117
  * Note: Full type definitions should be generated from openapi.json.
868
1118
  * These are placeholder interfaces for the SDK structure.
869
1119
  */
1120
+
870
1121
  /**
871
- * Create subscription request parameters.
1122
+ * Create order request parameters.
872
1123
  */
873
- interface CreateSubscriptionParams {
874
- /**
875
- * Subscription request ID sent from Merchant (max 32 characters).
876
- * Used for idempotent check.
877
- */
878
- subscriptionRequest: string;
879
- merchantSubscriptionId: string;
880
- currency: string;
881
- amount: string;
1124
+ interface CreateOrderParams {
1125
+ paymentRequestId: string;
1126
+ merchantOrderId: string;
1127
+ orderCurrency: string;
1128
+ orderAmount: string;
1129
+ orderDescription: string;
882
1130
  notifyUrl: string;
883
- productInfo: ProductInfo;
884
- userInfo: SubscriptionUserInfo;
885
- paymentInfo: SubscriptionPaymentInfo;
886
- merchantInfo?: SubscriptionMerchantInfo;
887
- goodsInfo?: {
888
- goodsId: string;
889
- goodsName: string;
890
- goodsCategory?: string;
891
- goodsUrl?: string;
892
- goodsQuantity?: number;
893
- [key: string]: unknown;
894
- };
1131
+ userInfo: UserInfo;
1132
+ paymentInfo: PaymentInfo;
1133
+ merchantInfo?: MerchantInfo;
1134
+ goodsInfo?: GoodsInfo;
1135
+ addressInfo?: AddressInfo;
1136
+ cardInfo?: CardInfo;
1137
+ riskData?: RiskData;
1138
+ userCurrency?: string;
895
1139
  successRedirectUrl?: string;
896
1140
  failedRedirectUrl?: string;
897
1141
  cancelRedirectUrl?: string;
898
- subscriptionManagementUrl?: string;
899
- requestedAt?: string;
900
- extendInfo?: string;
901
- /**
902
- * Order expiry time (ISO 8601 format, max 24 characters).
903
- */
1142
+ orderRequestedAt?: string;
904
1143
  orderExpiredAt?: string;
1144
+ extendInfo?: string;
1145
+ metadata?: string;
905
1146
  [key: string]: unknown;
906
1147
  }
907
1148
  /**
908
- * Create subscription response data.
909
- */
910
- interface CreateSubscriptionData {
911
- subscriptionRequest?: string;
912
- merchantSubscriptionId?: string;
913
- subscriptionId?: string;
914
- subscriptionStatus?: SubscriptionStatus;
915
- subscriptionAction?: string;
916
- [key: string]: unknown;
917
- }
918
- /**
919
- * Inquiry subscription request parameters.
920
- */
921
- interface InquirySubscriptionParams {
922
- subscriptionRequest?: string;
923
- subscriptionId?: string;
924
- merchantInfo?: SubscriptionMerchantInfo;
925
- [key: string]: unknown;
926
- }
927
- /**
928
- * Inquiry subscription response data.
929
- */
930
- interface InquirySubscriptionData {
931
- subscriptionRequest?: string;
932
- merchantSubscriptionId?: string;
933
- subscriptionId?: string;
934
- payMethodSubscriptionId?: string;
935
- subscriptionStatus?: SubscriptionStatus;
936
- subscriptionAction?: string;
937
- currency?: string;
938
- userCurrency?: string;
939
- amount?: string;
940
- productInfo?: ProductInfo;
941
- [key: string]: unknown;
942
- }
943
- /**
944
- * Cancel subscription request parameters.
945
- */
946
- interface CancelSubscriptionParams {
947
- subscriptionId?: string;
948
- merchantId?: string;
949
- requestedAt?: string;
950
- [key: string]: unknown;
951
- }
952
- /**
953
- * Cancel subscription response data.
954
- */
955
- interface CancelSubscriptionData {
956
- subscriptionRequest?: string;
957
- merchantSubscriptionId?: string;
958
- subscriptionId?: string;
959
- subscriptionStatus?: SubscriptionStatus;
960
- [key: string]: unknown;
961
- }
962
- /**
963
- * Manage subscription request parameters.
1149
+ * Create order response data.
964
1150
  */
965
- interface ManageSubscriptionParams {
966
- subscriptionId: string;
967
- merchantId: string;
968
- action: SubscriptionManageAction;
969
- newAmount?: string;
970
- newPeriodType?: PeriodType;
971
- newPeriodValue?: number;
972
- requestedAt: string;
1151
+ interface CreateOrderData {
1152
+ paymentRequestId?: string;
1153
+ merchantOrderId?: string;
1154
+ acquiringOrderId?: string;
1155
+ orderStatus?: OrderStatus;
1156
+ orderAction?: string;
973
1157
  [key: string]: unknown;
974
1158
  }
975
1159
  /**
976
- * Manage subscription response data.
1160
+ * Inquiry order request parameters.
977
1161
  */
978
- interface ManageSubscriptionData {
979
- subscriptionId?: string;
980
- subscriptionStatus?: SubscriptionStatus;
1162
+ interface InquiryOrderParams {
1163
+ paymentRequestId?: string;
1164
+ acquiringOrderId?: string;
1165
+ merchantInfo?: MerchantInfo;
981
1166
  [key: string]: unknown;
982
1167
  }
983
1168
  /**
984
- * Subscription status enum.
985
- * Based on openapi.json SubscriptionInquiryResponse.subscriptionStatus.
986
- */
987
- type SubscriptionStatus = 'AUTHORIZATION_REQUIRED' | 'IN_PROGRESS' | 'ACTIVE' | 'CLOSE' | 'MERCHANT_CANCELLED' | 'USER_CANCELLED' | 'CHANNEL_CANCELLED' | 'EXPIRED';
988
- /**
989
- * Subscription manage action enum.
990
- */
991
- type SubscriptionManageAction = 'PAUSE' | 'RESUME' | 'UPDATE_AMOUNT' | 'UPDATE_PERIOD';
992
- /**
993
- * Period type enum.
994
- * Values: DAILY, WEEKLY, MONTHLY
995
- */
996
- type PeriodType = 'DAILY' | 'WEEKLY' | 'MONTHLY';
997
- /**
998
- * Product information for subscription.
999
- * Based on openapi.json ProductInfo schema.
1169
+ * Inquiry order response data.
1000
1170
  */
1001
- interface ProductInfo {
1002
- /**
1003
- * Subscription product description (max 128 characters).
1004
- * Often appearing to user when asking user's confirmation.
1005
- */
1006
- description: string;
1007
- /**
1008
- * Subscription product period type: DAILY, WEEKLY, MONTHLY.
1009
- */
1010
- periodType: PeriodType;
1011
- /**
1012
- * Period interval (max 12 characters).
1013
- * - DAILY: 1-365
1014
- * - WEEKLY: 1-4
1015
- * - MONTHLY: 1-12
1016
- */
1017
- periodInterval: string;
1018
- /**
1019
- * Number of billing periods until subscription ends (max 24 characters).
1020
- * Empty means no defined end period.
1021
- */
1022
- numberOfPeriod?: string;
1023
- /**
1024
- * Trial period amount (max 24 characters).
1025
- */
1026
- trialPeriodAmount?: string;
1027
- /**
1028
- * Number of trial periods (max 12 characters).
1029
- */
1030
- numberOfTrialPeriod?: string;
1031
- /**
1032
- * Trial period type: DAILY, WEEKLY, MONTHLY.
1033
- * If omitted, uses periodType value by default.
1034
- */
1035
- trialPeriodType?: PeriodType;
1036
- /**
1037
- * Trial period interval (max 12 characters).
1038
- * If omitted, uses periodInterval value by default.
1039
- */
1040
- trialPeriodInterval?: string;
1041
- /**
1042
- * When the subscription starts (ISO 8601 format).
1043
- */
1044
- startDateTime?: string;
1171
+ interface InquiryOrderData {
1172
+ paymentRequestId?: string;
1173
+ merchantOrderId?: string;
1174
+ acquiringOrderId?: string;
1175
+ orderStatus?: OrderStatus;
1176
+ orderCurrency?: string;
1177
+ orderAmount?: string;
1178
+ finalDealAmount?: string;
1045
1179
  /**
1046
- * When the subscription ends (ISO 8601 format).
1180
+ * Refund expiry time (ISO 8601 format).
1047
1181
  */
1048
- endDateTime?: string;
1182
+ refundExpiryAt?: string;
1049
1183
  /**
1050
- * When the next payment is due (ISO 8601 format).
1184
+ * The associated subscription info.
1051
1185
  */
1052
- nextPaymentDateTime?: string;
1186
+ subscriptionInfo?: SubscriptionInfo;
1053
1187
  /**
1054
- * Current billing period number.
1188
+ * The address of the merchant page to redirect to when user cancels the payment.
1055
1189
  */
1056
- currentPeriod?: string;
1190
+ cancelRedirectUrl?: string;
1057
1191
  [key: string]: unknown;
1058
1192
  }
1059
1193
  /**
1060
- * User information for subscription.
1194
+ * Cancel order request parameters.
1061
1195
  */
1062
- interface SubscriptionUserInfo {
1063
- userId: string;
1064
- userEmail: string;
1065
- userPhone?: string;
1066
- userFirstName?: string;
1067
- userLastName?: string;
1068
- userCountryCode?: string;
1069
- userBrowserIp?: string;
1070
- userAgent?: string;
1196
+ interface CancelOrderParams {
1197
+ paymentRequestId?: string;
1198
+ acquiringOrderId?: string;
1199
+ merchantInfo?: MerchantInfo;
1200
+ orderRequestedAt?: string;
1071
1201
  [key: string]: unknown;
1072
1202
  }
1073
1203
  /**
1074
- * Payment information for subscription.
1204
+ * Cancel order response data.
1075
1205
  */
1076
- interface SubscriptionPaymentInfo {
1077
- productName: string;
1078
- payMethodType?: string;
1079
- payMethodName?: string;
1206
+ interface CancelOrderData {
1207
+ paymentRequestId?: string;
1208
+ merchantOrderId?: string;
1209
+ acquiringOrderId?: string;
1210
+ orderStatus?: OrderStatus;
1080
1211
  [key: string]: unknown;
1081
1212
  }
1082
1213
  /**
1083
- * Merchant information for subscription.
1214
+ * Refund order request parameters.
1084
1215
  */
1085
- interface SubscriptionMerchantInfo {
1216
+ interface RefundOrderParams {
1217
+ refundRequestId: string;
1218
+ paymentRequestId?: string;
1219
+ acquiringOrderId?: string;
1220
+ merchantRefundOrderId?: string;
1221
+ merchantInfo?: MerchantInfo;
1222
+ refundAmount: string;
1223
+ refundReason?: string;
1224
+ requestedAt?: string;
1225
+ notifyUrl?: string;
1226
+ userInfo?: RefundUserInfo;
1227
+ extendInfo?: string;
1228
+ [key: string]: unknown;
1229
+ }
1230
+ /**
1231
+ * Refund order response data.
1232
+ */
1233
+ interface RefundOrderData {
1234
+ refundRequestId?: string;
1235
+ merchantRefundOrderId?: string;
1236
+ acquiringOrderId?: string;
1237
+ acquiringRefundOrderId?: string;
1238
+ refundAmount?: string;
1239
+ refundStatus?: RefundStatus$1;
1240
+ remainingRefundAmount?: string;
1241
+ [key: string]: unknown;
1242
+ }
1243
+ /**
1244
+ * Capture order request parameters.
1245
+ */
1246
+ interface CaptureOrderParams {
1247
+ paymentRequestId?: string;
1248
+ acquiringOrderId?: string;
1086
1249
  merchantId: string;
1087
- subMerchantId?: string;
1250
+ captureAmount?: string;
1088
1251
  [key: string]: unknown;
1089
1252
  }
1090
1253
  /**
1091
- * Subscription change status values.
1254
+ * Capture order response data.
1092
1255
  */
1093
- type SubscriptionChangeStatus = 'IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'SUCCESS' | 'CLOSED';
1256
+ interface CaptureOrderData {
1257
+ paymentRequestId?: string;
1258
+ merchantOrderId?: string;
1259
+ acquiringOrderId?: string;
1260
+ orderStatus?: OrderStatus;
1261
+ [key: string]: unknown;
1262
+ }
1094
1263
  /**
1095
- * Product information for subscription change operations.
1096
- * Contains billing period settings for the new subscription plan.
1264
+ * Order status enum.
1097
1265
  */
1098
- interface SubscriptionChangeProductInfo {
1099
- /**
1100
- * Product description (max 128 characters).
1101
- */
1102
- description: string;
1103
- /**
1104
- * Billing period type: DAILY, WEEKLY, MONTHLY.
1105
- */
1106
- periodType: PeriodType;
1107
- /**
1108
- * Subscription amount for this product (max 12 characters).
1109
- */
1110
- amount: string;
1111
- /**
1112
- * Billing interval (max 12 characters).
1113
- */
1114
- periodInterval: string;
1115
- /**
1116
- * Total number of billing periods (max 24 characters, empty for unlimited).
1117
- */
1118
- numberOfPeriod?: string;
1119
- /**
1120
- * Trial period amount (max 24 characters).
1121
- */
1122
- trialPeriodAmount?: string;
1123
- /**
1124
- * Number of trial periods (max 12 characters).
1125
- */
1126
- numberOfTrialPeriod?: string;
1127
- /**
1128
- * Trial period type: DAILY, WEEKLY, MONTHLY.
1129
- */
1130
- trialPeriodType?: PeriodType;
1266
+ type OrderStatus = 'PAY_IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'AUTHED_WAITING_CAPTURE' | 'PAY_SUCCESS' | 'ORDER_CLOSE' | 'CAPTURE_IN_PROGRESS';
1267
+ /**
1268
+ * Refund status enum.
1269
+ */
1270
+ type RefundStatus$1 = 'REFUND_IN_PROGRESS' | 'ORDER_PARTIALLY_REFUNDED' | 'ORDER_FULLY_REFUNDED' | 'ORDER_REFUND_FAILED';
1271
+ /**
1272
+ * User information.
1273
+ */
1274
+ interface UserInfo {
1275
+ userId: string;
1276
+ userEmail: string;
1277
+ userPhone?: string;
1278
+ userFirstName?: string;
1279
+ userLastName?: string;
1280
+ userCreatedAt?: string;
1281
+ userTerminal?: string;
1282
+ userCountryCode?: string;
1283
+ userBrowserIp?: string;
1284
+ userAgent?: string;
1131
1285
  /**
1132
- * Trial period interval (max 12 characters).
1286
+ * User receipt URL (max 256 characters).
1133
1287
  */
1134
- trialPeriodInterval?: string;
1288
+ userReceiptUrl?: string;
1135
1289
  [key: string]: unknown;
1136
1290
  }
1137
1291
  /**
1138
- * Subscription change request parameters.
1292
+ * Payment information.
1139
1293
  */
1140
- interface SubscriptionChangeParams {
1141
- /**
1142
- * New unique request ID for this change (max 32 characters).
1143
- */
1144
- subscriptionRequest: string;
1145
- /**
1146
- * New merchant subscription plan ID (max 64 characters).
1147
- */
1148
- merchantSubscriptionId?: string;
1149
- /**
1150
- * Original subscription request ID to be changed (max 32 characters).
1151
- */
1152
- originSubscriptionRequest: string;
1153
- /**
1154
- * Remaining amount from the original subscription (max 24 characters).
1155
- */
1156
- remainingAmount: string;
1157
- /**
1158
- * Subscription currency code (ISO 4217).
1159
- */
1160
- currency: string;
1161
- /**
1162
- * User payment currency (when different from merchant currency).
1163
- */
1164
- userCurrency?: string;
1165
- /**
1166
- * Request time (ISO 8601 format).
1167
- */
1168
- requestedAt: string;
1169
- /**
1170
- * Redirect URL after successful subscription change.
1171
- */
1172
- successRedirectUrl?: string;
1173
- /**
1174
- * Redirect URL after failed subscription change.
1175
- */
1176
- failedRedirectUrl?: string;
1177
- /**
1178
- * Async notification URL for change notifications.
1179
- */
1180
- notifyUrl: string;
1181
- /**
1182
- * Redirect URL after user cancels.
1183
- */
1184
- cancelRedirectUrl?: string;
1185
- /**
1186
- * Merchant-side subscription management URL.
1187
- */
1188
- subscriptionManagementUrl?: string;
1189
- /**
1190
- * Reserved extend info (JSON format).
1191
- */
1192
- extendInfo?: string;
1193
- /**
1194
- * Order expiry time (ISO 8601 format).
1195
- */
1196
- orderExpiredAt?: string;
1197
- /**
1198
- * New subscription product information list.
1199
- */
1200
- productInfoList: SubscriptionChangeProductInfo[];
1201
- /**
1202
- * Merchant information.
1203
- */
1204
- merchantInfo?: SubscriptionMerchantInfo;
1205
- /**
1206
- * User information.
1207
- */
1208
- userInfo: SubscriptionUserInfo;
1209
- /**
1210
- * Goods information.
1211
- */
1212
- goodsInfo: {
1213
- goodsId: string;
1214
- goodsName: string;
1215
- goodsCategory?: string;
1216
- goodsUrl?: string;
1217
- appName?: string;
1218
- skuName?: string;
1219
- goodsUniquePrice?: string;
1220
- goodsQuantity?: number;
1221
- [key: string]: unknown;
1222
- };
1223
- /**
1224
- * Address information.
1225
- */
1226
- addressInfo?: {
1227
- address?: string;
1228
- city?: string;
1229
- region?: string;
1230
- postcode?: string;
1231
- addressCountryCode?: string;
1232
- [key: string]: unknown;
1233
- };
1234
- /**
1235
- * Payment method information.
1236
- */
1237
- paymentInfo: SubscriptionPaymentInfo;
1238
- /**
1239
- * Risk control auxiliary data.
1240
- */
1241
- riskData?: {
1242
- userType?: string;
1243
- userCategory?: string;
1244
- userLegalName?: string;
1245
- userDisplayName?: string;
1246
- userRegistrationIp?: string;
1247
- userLastSeenIp?: string;
1248
- userIsNew?: string;
1249
- userIsFirstPurchase?: string;
1250
- [key: string]: unknown;
1251
- };
1294
+ interface PaymentInfo {
1295
+ productName: string;
1296
+ payMethodType?: string;
1297
+ payMethodName?: string;
1298
+ payMethodProperties?: string;
1252
1299
  [key: string]: unknown;
1253
1300
  }
1254
1301
  /**
1255
- * Subscription change response data.
1302
+ * Merchant information.
1256
1303
  */
1257
- interface SubscriptionChangeData {
1258
- /**
1259
- * Original subscription request ID that was changed.
1260
- */
1261
- originSubscriptionRequest?: string;
1262
- /**
1263
- * New subscription request ID after the change.
1264
- */
1265
- subscriptionRequest?: string;
1266
- /**
1267
- * Merchant's new subscription plan ID.
1268
- */
1269
- merchantSubscriptionId?: string;
1270
- /**
1271
- * Current status of the subscription change.
1272
- */
1273
- subscriptionChangeStatus?: SubscriptionChangeStatus;
1274
- /**
1275
- * Action guide for user to complete authorization.
1276
- * When subscriptionChangeStatus = AUTHORIZATION_REQUIRED, contains webUrl.
1277
- */
1278
- subscriptionAction?: string;
1279
- /**
1280
- * New Waffo subscription ID.
1281
- */
1282
- subscriptionId?: string;
1304
+ interface MerchantInfo {
1305
+ merchantId: string;
1306
+ subMerchantId?: string;
1283
1307
  [key: string]: unknown;
1284
1308
  }
1285
1309
  /**
1286
- * Subscription change inquiry request parameters.
1310
+ * Goods information.
1287
1311
  */
1288
- interface SubscriptionChangeInquiryParams {
1289
- /**
1290
- * Original subscription request ID that was changed.
1291
- */
1292
- originSubscriptionRequest: string;
1293
- /**
1294
- * New subscription request ID after the change.
1295
- */
1296
- subscriptionRequest: string;
1312
+ interface GoodsInfo {
1313
+ goodsId?: string;
1314
+ goodsName?: string;
1315
+ goodsCategory?: string;
1316
+ goodsUrl?: string;
1317
+ appName?: string;
1318
+ skuName?: string;
1319
+ goodsUniquePrice?: string;
1320
+ goodsQuantity?: number;
1297
1321
  [key: string]: unknown;
1298
1322
  }
1299
1323
  /**
1300
- * Subscription change inquiry response data.
1324
+ * Address information.
1301
1325
  */
1302
- interface SubscriptionChangeInquiryData {
1303
- /**
1304
- * New subscription request ID after the change.
1305
- */
1306
- subscriptionRequest?: string;
1307
- /**
1308
- * Original subscription request ID that was changed.
1309
- */
1310
- originSubscriptionRequest?: string;
1311
- /**
1312
- * Merchant's new subscription plan ID.
1313
- */
1314
- merchantSubscriptionId?: string;
1315
- /**
1316
- * New Waffo subscription ID.
1317
- */
1318
- subscriptionId?: string;
1319
- /**
1320
- * Current status of the subscription change.
1321
- */
1322
- subscriptionChangeStatus?: SubscriptionChangeStatus;
1323
- /**
1324
- * Action guide for user authorization.
1325
- */
1326
- subscriptionAction?: string;
1327
- /**
1328
- * Remaining amount from the original subscription.
1329
- */
1330
- remainingAmount?: string;
1331
- /**
1332
- * Subscription currency (ISO 4217).
1333
- */
1334
- currency?: string;
1335
- /**
1336
- * User payment currency.
1337
- */
1338
- userCurrency?: string;
1339
- /**
1340
- * Request time.
1341
- */
1342
- requestedAt?: string;
1343
- /**
1344
- * Subscription management URL.
1345
- */
1346
- subscriptionManagementUrl?: string;
1347
- /**
1348
- * Extended info.
1349
- */
1350
- extendInfo?: string;
1351
- /**
1352
- * Order expiry time.
1353
- */
1354
- orderExpiredAt?: string;
1355
- /**
1356
- * Product information list.
1357
- */
1358
- productInfoList?: SubscriptionChangeProductInfo[];
1326
+ interface AddressInfo {
1327
+ address?: string;
1328
+ city?: string;
1329
+ region?: string;
1330
+ postcode?: string;
1331
+ addressCountryCode?: string;
1332
+ [key: string]: unknown;
1333
+ }
1334
+ /**
1335
+ * Card information.
1336
+ */
1337
+ interface CardInfo {
1338
+ cardNumber?: string;
1339
+ cardExpiryYear?: number;
1340
+ cardExpiryMonth?: number;
1341
+ cardCvv?: string;
1342
+ cardHolderName?: string;
1343
+ threeDsDecision?: string;
1344
+ [key: string]: unknown;
1345
+ }
1346
+ /**
1347
+ * Risk data.
1348
+ */
1349
+ interface RiskData {
1350
+ userType?: string;
1351
+ userCategory?: string;
1352
+ userLegalName?: string;
1353
+ userDisplayName?: string;
1354
+ userRegistrationIp?: string;
1355
+ userLastSeenIp?: string;
1356
+ userIsNew?: string;
1357
+ userIsFirstPurchase?: string;
1358
+ [key: string]: unknown;
1359
+ }
1360
+ /**
1361
+ * Refund user information.
1362
+ */
1363
+ interface RefundUserInfo {
1364
+ userType?: string;
1365
+ userFirstName?: string;
1366
+ userLastName?: string;
1367
+ userEmail?: string;
1368
+ userPhone?: string;
1369
+ [key: string]: unknown;
1370
+ }
1371
+
1372
+ /**
1373
+ * Order resource for managing payment orders.
1374
+ *
1375
+ * @example
1376
+ * ```typescript
1377
+ * // Create an order
1378
+ * const response = await waffo.order().create({
1379
+ * paymentRequestId: 'unique-request-id',
1380
+ * merchantOrderId: 'order-123',
1381
+ * orderCurrency: 'USD',
1382
+ * orderAmount: '10.00',
1383
+ * orderDescription: 'Test order',
1384
+ * notifyUrl: 'https://example.com/webhook',
1385
+ * userInfo: {
1386
+ * userId: 'user-123',
1387
+ * userEmail: 'user@example.com',
1388
+ * },
1389
+ * paymentInfo: {
1390
+ * productName: 'Test Product',
1391
+ * },
1392
+ * });
1393
+ *
1394
+ * if (response.isSuccess()) {
1395
+ * console.log('Order created:', response.getData());
1396
+ * }
1397
+ * ```
1398
+ */
1399
+ declare class OrderResource extends BaseResource {
1400
+ private static readonly PATH_CREATE;
1401
+ private static readonly PATH_INQUIRY;
1402
+ private static readonly PATH_CANCEL;
1403
+ private static readonly PATH_REFUND;
1404
+ private static readonly PATH_CAPTURE;
1359
1405
  /**
1360
- * Merchant information.
1406
+ * Creates a new payment order.
1407
+ *
1408
+ * @param params - Order creation parameters
1409
+ * @param options - Optional request options
1410
+ * @returns API response with order data
1411
+ * @throws WaffoUnknownStatusError for network errors
1361
1412
  */
1362
- merchantInfo?: SubscriptionMerchantInfo;
1413
+ create(params: CreateOrderParams, options?: RequestOptions): Promise<ApiResponse<CreateOrderData>>;
1363
1414
  /**
1364
- * User information.
1415
+ * Queries an existing order.
1416
+ *
1417
+ * @param params - Order inquiry parameters
1418
+ * @param options - Optional request options
1419
+ * @returns API response with order data
1420
+ * @throws WaffoUnknownStatusError for network errors
1365
1421
  */
1366
- userInfo?: SubscriptionUserInfo;
1422
+ inquiry(params: InquiryOrderParams, options?: RequestOptions): Promise<ApiResponse<InquiryOrderData>>;
1367
1423
  /**
1368
- * Goods information.
1424
+ * Cancels an existing order.
1425
+ *
1426
+ * @param params - Order cancellation parameters
1427
+ * @param options - Optional request options
1428
+ * @returns API response with cancellation result
1429
+ * @throws WaffoUnknownStatusError for network errors
1369
1430
  */
1370
- goodsInfo?: {
1371
- goodsId?: string;
1372
- goodsName?: string;
1373
- goodsCategory?: string;
1374
- goodsUrl?: string;
1375
- appName?: string;
1376
- skuName?: string;
1377
- goodsUniquePrice?: string;
1378
- goodsQuantity?: number;
1379
- [key: string]: unknown;
1380
- };
1431
+ cancel(params: CancelOrderParams, options?: RequestOptions): Promise<ApiResponse<CancelOrderData>>;
1381
1432
  /**
1382
- * Address information.
1433
+ * Refunds an existing order.
1434
+ *
1435
+ * @param params - Order refund parameters
1436
+ * @param options - Optional request options
1437
+ * @returns API response with refund result
1438
+ * @throws WaffoUnknownStatusError for network errors
1383
1439
  */
1384
- addressInfo?: {
1385
- address?: string;
1386
- city?: string;
1387
- region?: string;
1388
- postcode?: string;
1389
- addressCountryCode?: string;
1390
- [key: string]: unknown;
1391
- };
1440
+ refund(params: RefundOrderParams, options?: RequestOptions): Promise<ApiResponse<RefundOrderData>>;
1392
1441
  /**
1393
- * Payment information.
1442
+ * Captures an authorized order.
1443
+ *
1444
+ * @param params - Order capture parameters
1445
+ * @param options - Optional request options
1446
+ * @returns API response with capture result
1447
+ * @throws WaffoUnknownStatusError for network errors
1394
1448
  */
1395
- paymentInfo?: SubscriptionPaymentInfo;
1396
- [key: string]: unknown;
1449
+ capture(params: CaptureOrderParams, options?: RequestOptions): Promise<ApiResponse<CaptureOrderData>>;
1397
1450
  }
1398
1451
 
1399
1452
  /**
@@ -2062,4 +2115,4 @@ declare const RsaUtils: {
2062
2115
  generateKeyPair: typeof generateKeyPair;
2063
2116
  };
2064
2117
 
2065
- export { type AddressInfo, ApiResponse, type BaseNotification, type CancelOrderData, type CancelOrderParams, type CancelSubscriptionData, type CancelSubscriptionParams, type CaptureOrderData, type CaptureOrderParams, type CardInfo, type CreateOrderData, type CreateOrderParams, type CreateSubscriptionData, type CreateSubscriptionParams, Environment, EnvironmentBaseUrl, type GoodsInfo, type HttpRequest, type HttpResponse, type HttpTransport, type InquiryMerchantConfigData, type InquiryMerchantConfigParams, type InquiryOrderData, type InquiryOrderParams, type InquiryPayMethodConfigData, type InquiryPayMethodConfigParams, type InquiryRefundData, type InquiryRefundParams, type InquirySubscriptionData, type InquirySubscriptionParams, type ManageSubscriptionData, type ManageSubscriptionParams, MerchantConfigResource, type MerchantInfo, OrderResource, type OrderStatus, PayMethodConfigResource, type PayMethodInfo, type PaymentInfo, type PaymentNotification, type PaymentNotificationResult, type PeriodType, type ProductInfo, type RefundNotification, type RefundNotificationResult, type RefundOrderData, type RefundOrderParams, RefundResource, type RefundStatus$1 as RefundStatus, type RefundUserInfo, type RequestOptions, type RiskData, RsaUtils, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionNotificationResult, type SubscriptionPaymentInfo, type SubscriptionPeriodChangedNotification, SubscriptionResource, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUserInfo, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, WebhookEventType, WebhookHandler, type WebhookResult };
2118
+ export { type AddressInfo, ApiResponse, type BaseNotification, type CancelOrderData, type CancelOrderParams, type CancelSubscriptionData, type CancelSubscriptionParams, type CaptureOrderData, type CaptureOrderParams, type CardInfo, type CreateOrderData, type CreateOrderParams, type CreateSubscriptionData, type CreateSubscriptionParams, Environment, EnvironmentBaseUrl, type GoodsInfo, type HttpRequest, type HttpResponse, type HttpTransport, type InquiryMerchantConfigData, type InquiryMerchantConfigParams, type InquiryOrderData, type InquiryOrderParams, type InquiryPayMethodConfigData, type InquiryPayMethodConfigParams, type InquiryRefundData, type InquiryRefundParams, type InquirySubscriptionData, type InquirySubscriptionParams, type ManageSubscriptionData, type ManageSubscriptionParams, MerchantConfigResource, type MerchantInfo, OrderResource, type OrderStatus, PayMethodConfigResource, type PayMethodInfo, type PaymentInfo, type PaymentNotification, type PaymentNotificationResult, type PeriodType, type ProductInfo, type RefundNotification, type RefundNotificationResult, type RefundOrderData, type RefundOrderParams, RefundResource, type RefundStatus$1 as RefundStatus, type RefundUserInfo, type RequestOptions, type RiskData, RsaUtils, type SubscriptionInfo, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionNotificationResult, type SubscriptionPaymentInfo, type SubscriptionPeriodChangedNotification, SubscriptionResource, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUserInfo, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, WebhookEventType, WebhookHandler, type WebhookResult };