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