@waffo/waffo-node 2.1.0 → 2.2.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 +88 -33
- package/dist/index.d.ts +88 -33
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,7 +229,7 @@ app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res)
|
|
|
229
229
|
|
|
230
230
|
const webhookHandler = waffo.webhook()
|
|
231
231
|
.onPayment((notification) => {
|
|
232
|
-
console.log('Payment received:', notification.acquiringOrderId);
|
|
232
|
+
console.log('Payment received:', notification.result?.acquiringOrderId);
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
const result = await webhookHandler.handleWebhook(body, signature);
|
|
@@ -283,7 +283,7 @@ export class PaymentController {
|
|
|
283
283
|
) {
|
|
284
284
|
const webhookHandler = this.waffo.webhook()
|
|
285
285
|
.onPayment((notification) => {
|
|
286
|
-
console.log('Payment received:', notification.acquiringOrderId);
|
|
286
|
+
console.log('Payment received:', notification.result?.acquiringOrderId);
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
const result = await webhookHandler.handleWebhook(body, signature);
|
|
@@ -318,7 +318,7 @@ fastify.post('/webhook', async (request, reply) => {
|
|
|
318
318
|
|
|
319
319
|
const webhookHandler = waffo.webhook()
|
|
320
320
|
.onPayment((notification) => {
|
|
321
|
-
console.log('Payment received:', notification.acquiringOrderId);
|
|
321
|
+
console.log('Payment received:', notification.result?.acquiringOrderId);
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
const result = await webhookHandler.handleWebhook(body, signature);
|
|
@@ -688,28 +688,28 @@ const waffo = new Waffo({ /* config */ });
|
|
|
688
688
|
const webhookHandler = waffo.webhook()
|
|
689
689
|
.onPayment((notification) => {
|
|
690
690
|
console.log('Payment notification received:');
|
|
691
|
-
console.log(' Acquiring Order ID:', notification.acquiringOrderId);
|
|
692
|
-
console.log(' Order Status:', notification.orderStatus);
|
|
693
|
-
console.log(' Payment Amount:', notification.orderAmount);
|
|
694
|
-
console.log(' Payment Currency:', notification.orderCurrency);
|
|
691
|
+
console.log(' Acquiring Order ID:', notification.result?.acquiringOrderId);
|
|
692
|
+
console.log(' Order Status:', notification.result?.orderStatus);
|
|
693
|
+
console.log(' Payment Amount:', notification.result?.orderAmount);
|
|
694
|
+
console.log(' Payment Currency:', notification.result?.orderCurrency);
|
|
695
695
|
|
|
696
696
|
// Tip: First verify amount and currency match your records
|
|
697
697
|
// Then handle based on orderStatus
|
|
698
698
|
|
|
699
|
-
if (notification.orderStatus === 'PAY_SUCCESS') {
|
|
699
|
+
if (notification.result?.orderStatus === 'PAY_SUCCESS') {
|
|
700
700
|
// Payment successful - update order status, deliver goods, etc.
|
|
701
701
|
}
|
|
702
702
|
})
|
|
703
703
|
.onRefund((notification) => {
|
|
704
|
-
console.log('Refund notification:', notification.acquiringRefundOrderId);
|
|
704
|
+
console.log('Refund notification:', notification.result?.acquiringRefundOrderId);
|
|
705
705
|
// Handle refund notification
|
|
706
706
|
})
|
|
707
707
|
.onSubscriptionStatus((notification) => {
|
|
708
708
|
console.log('Subscription status notification:');
|
|
709
|
-
console.log(' Subscription ID:', notification.subscriptionId);
|
|
710
|
-
console.log(' Subscription Status:', notification.subscriptionStatus);
|
|
709
|
+
console.log(' Subscription ID:', notification.result?.subscriptionId);
|
|
710
|
+
console.log(' Subscription Status:', notification.result?.subscriptionStatus);
|
|
711
711
|
|
|
712
|
-
switch (notification.subscriptionStatus) {
|
|
712
|
+
switch (notification.result?.subscriptionStatus) {
|
|
713
713
|
case 'ACTIVE':
|
|
714
714
|
// Subscription activated - grant membership privileges
|
|
715
715
|
break;
|
|
@@ -731,28 +731,28 @@ const webhookHandler = waffo.webhook()
|
|
|
731
731
|
}
|
|
732
732
|
})
|
|
733
733
|
.onSubscriptionPeriodChanged((notification) => {
|
|
734
|
-
console.log('Subscription period changed:', notification.subscriptionId);
|
|
734
|
+
console.log('Subscription period changed:', notification.result?.subscriptionId);
|
|
735
735
|
// Key fields to track:
|
|
736
|
-
// - notification.period: Current period number
|
|
737
|
-
// - notification.nextChargeAt: Next billing time
|
|
738
|
-
// - notification.subscriptionStatus: Subscription status
|
|
739
|
-
// - notification.orderStatus: Current billing order status (SUCCESS/FAILED)
|
|
740
|
-
// - notification.orderAmount: Billing amount
|
|
741
|
-
// - notification.orderCurrency: Billing currency
|
|
736
|
+
// - notification.result?.period: Current period number
|
|
737
|
+
// - notification.result?.nextChargeAt: Next billing time
|
|
738
|
+
// - notification.result?.subscriptionStatus: Subscription status
|
|
739
|
+
// - notification.result?.orderStatus: Current billing order status (SUCCESS/FAILED)
|
|
740
|
+
// - notification.result?.orderAmount: Billing amount
|
|
741
|
+
// - notification.result?.orderCurrency: Billing currency
|
|
742
742
|
})
|
|
743
743
|
.onSubscriptionChange((notification) => {
|
|
744
744
|
console.log('Subscription change notification:');
|
|
745
|
-
console.log(' Change Request ID:', notification.subscriptionRequest);
|
|
746
|
-
console.log(' Change Status:', notification.subscriptionChangeStatus);
|
|
747
|
-
console.log(' Origin Subscription:', notification.originSubscriptionId);
|
|
748
|
-
console.log(' New Subscription:', notification.subscriptionId);
|
|
745
|
+
console.log(' Change Request ID:', notification.result?.subscriptionRequest);
|
|
746
|
+
console.log(' Change Status:', notification.result?.subscriptionChangeStatus);
|
|
747
|
+
console.log(' Origin Subscription:', notification.result?.originSubscriptionId);
|
|
748
|
+
console.log(' New Subscription:', notification.result?.subscriptionId);
|
|
749
749
|
|
|
750
|
-
if (notification.subscriptionChangeStatus === 'SUCCESS') {
|
|
750
|
+
if (notification.result?.subscriptionChangeStatus === 'SUCCESS') {
|
|
751
751
|
// Subscription change successful
|
|
752
752
|
// - Original subscription is now MERCHANT_CANCELLED
|
|
753
753
|
// - New subscription is now ACTIVE
|
|
754
754
|
// Update user's subscription level accordingly
|
|
755
|
-
} else if (notification.subscriptionChangeStatus === 'CLOSED') {
|
|
755
|
+
} else if (notification.result?.subscriptionChangeStatus === 'CLOSED') {
|
|
756
756
|
// Subscription change failed/closed
|
|
757
757
|
// Original subscription remains unchanged
|
|
758
758
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -176,7 +176,6 @@ declare enum WebhookEventType {
|
|
|
176
176
|
PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
|
|
177
177
|
REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
|
|
178
178
|
SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
|
|
179
|
-
SUBSCRIPTION_PAYMENT_NOTIFICATION = "SUBSCRIPTION_PAYMENT_NOTIFICATION",
|
|
180
179
|
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
|
|
181
180
|
}
|
|
182
181
|
/**
|
|
@@ -199,47 +198,104 @@ interface BaseNotification {
|
|
|
199
198
|
eventType: string;
|
|
200
199
|
}
|
|
201
200
|
/**
|
|
202
|
-
* Payment notification
|
|
201
|
+
* Payment notification result payload (21 fields).
|
|
203
202
|
*/
|
|
204
|
-
interface
|
|
205
|
-
eventType: 'PAYMENT_NOTIFICATION';
|
|
206
|
-
acquiringOrderId?: string;
|
|
207
|
-
merchantOrderId?: string;
|
|
203
|
+
interface PaymentNotificationResult {
|
|
208
204
|
paymentRequestId?: string;
|
|
205
|
+
merchantOrderId?: string;
|
|
206
|
+
acquiringOrderId?: string;
|
|
209
207
|
orderStatus?: string;
|
|
210
|
-
|
|
208
|
+
orderAction?: string;
|
|
211
209
|
orderCurrency?: string;
|
|
210
|
+
orderAmount?: string;
|
|
211
|
+
userCurrency?: string;
|
|
212
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;
|
|
213
225
|
[key: string]: unknown;
|
|
214
226
|
}
|
|
215
227
|
/**
|
|
216
|
-
* Refund notification
|
|
228
|
+
* Refund notification result payload (17 fields).
|
|
217
229
|
*/
|
|
218
|
-
interface
|
|
219
|
-
eventType: 'REFUND_NOTIFICATION';
|
|
220
|
-
acquiringRefundOrderId?: string;
|
|
230
|
+
interface RefundNotificationResult {
|
|
221
231
|
refundRequestId?: string;
|
|
222
|
-
|
|
232
|
+
merchantRefundOrderId?: string;
|
|
233
|
+
acquiringOrderId?: string;
|
|
234
|
+
acquiringRefundOrderId?: string;
|
|
235
|
+
origPaymentRequestId?: string;
|
|
223
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;
|
|
224
248
|
[key: string]: unknown;
|
|
225
249
|
}
|
|
226
250
|
/**
|
|
227
|
-
* Subscription
|
|
251
|
+
* Subscription notification result payload (20 fields).
|
|
252
|
+
* Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
|
|
228
253
|
*/
|
|
229
|
-
interface
|
|
230
|
-
|
|
254
|
+
interface SubscriptionNotificationResult {
|
|
255
|
+
subscriptionRequest?: string;
|
|
256
|
+
merchantSubscriptionId?: string;
|
|
231
257
|
subscriptionId?: string;
|
|
232
258
|
subscriptionStatus?: string;
|
|
259
|
+
subscriptionAction?: string;
|
|
260
|
+
currency?: string;
|
|
261
|
+
amount?: string;
|
|
262
|
+
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>[];
|
|
233
275
|
[key: string]: unknown;
|
|
234
276
|
}
|
|
235
277
|
/**
|
|
236
|
-
*
|
|
278
|
+
* Payment notification from Waffo.
|
|
237
279
|
*/
|
|
238
|
-
interface
|
|
239
|
-
eventType: '
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
280
|
+
interface PaymentNotification extends BaseNotification {
|
|
281
|
+
eventType: 'PAYMENT_NOTIFICATION';
|
|
282
|
+
result?: PaymentNotificationResult;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Refund notification from Waffo.
|
|
287
|
+
*/
|
|
288
|
+
interface RefundNotification extends BaseNotification {
|
|
289
|
+
eventType: 'REFUND_NOTIFICATION';
|
|
290
|
+
result?: RefundNotificationResult;
|
|
291
|
+
[key: string]: unknown;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Subscription status notification from Waffo.
|
|
295
|
+
*/
|
|
296
|
+
interface SubscriptionStatusNotification extends BaseNotification {
|
|
297
|
+
eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
|
|
298
|
+
result?: SubscriptionNotificationResult;
|
|
243
299
|
[key: string]: unknown;
|
|
244
300
|
}
|
|
245
301
|
/**
|
|
@@ -247,13 +303,13 @@ interface SubscriptionPaymentNotification extends BaseNotification {
|
|
|
247
303
|
*/
|
|
248
304
|
interface SubscriptionPeriodChangedNotification extends BaseNotification {
|
|
249
305
|
eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
|
|
250
|
-
|
|
306
|
+
result?: SubscriptionNotificationResult;
|
|
251
307
|
[key: string]: unknown;
|
|
252
308
|
}
|
|
253
309
|
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
254
310
|
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
255
311
|
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
256
|
-
type SubscriptionPaymentHandler = (notification:
|
|
312
|
+
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
257
313
|
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
258
314
|
/**
|
|
259
315
|
* Webhook handler for processing Waffo webhook notifications.
|
|
@@ -263,10 +319,10 @@ type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChanged
|
|
|
263
319
|
* // Setup handler
|
|
264
320
|
* const handler = waffo.webhook()
|
|
265
321
|
* .onPayment((notification) => {
|
|
266
|
-
* console.log('Payment:', notification.orderStatus);
|
|
322
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
267
323
|
* })
|
|
268
324
|
* .onRefund((notification) => {
|
|
269
|
-
* console.log('Refund:', notification.refundStatus);
|
|
325
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
270
326
|
* });
|
|
271
327
|
*
|
|
272
328
|
* // Process webhook (e.g., in Express.js)
|
|
@@ -303,7 +359,8 @@ declare class WebhookHandler {
|
|
|
303
359
|
*/
|
|
304
360
|
onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
|
|
305
361
|
/**
|
|
306
|
-
* Registers a handler for
|
|
362
|
+
* Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
|
|
363
|
+
* Only called when onSubscriptionStatus handler is not registered.
|
|
307
364
|
*/
|
|
308
365
|
onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
|
|
309
366
|
/**
|
|
@@ -887,10 +944,8 @@ interface InquirySubscriptionData {
|
|
|
887
944
|
* Cancel subscription request parameters.
|
|
888
945
|
*/
|
|
889
946
|
interface CancelSubscriptionParams {
|
|
890
|
-
subscriptionRequest?: string;
|
|
891
947
|
subscriptionId?: string;
|
|
892
|
-
|
|
893
|
-
cancelReason?: string;
|
|
948
|
+
merchantId?: string;
|
|
894
949
|
requestedAt?: string;
|
|
895
950
|
[key: string]: unknown;
|
|
896
951
|
}
|
|
@@ -1782,13 +1837,13 @@ declare class Waffo {
|
|
|
1782
1837
|
* // Setup webhook handler
|
|
1783
1838
|
* const handler = waffo.webhook()
|
|
1784
1839
|
* .onPayment((notification) => {
|
|
1785
|
-
* console.log('Payment:', notification.orderStatus);
|
|
1840
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
1786
1841
|
* })
|
|
1787
1842
|
* .onRefund((notification) => {
|
|
1788
|
-
* console.log('Refund:', notification.refundStatus);
|
|
1843
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
1789
1844
|
* })
|
|
1790
1845
|
* .onSubscriptionStatus((notification) => {
|
|
1791
|
-
* console.log('Subscription:', notification.subscriptionStatus);
|
|
1846
|
+
* console.log('Subscription:', notification.result?.subscriptionStatus);
|
|
1792
1847
|
* });
|
|
1793
1848
|
*
|
|
1794
1849
|
* // In Express.js route handler
|
|
@@ -2007,4 +2062,4 @@ declare const RsaUtils: {
|
|
|
2007
2062
|
generateKeyPair: typeof generateKeyPair;
|
|
2008
2063
|
};
|
|
2009
2064
|
|
|
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
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -176,7 +176,6 @@ declare enum WebhookEventType {
|
|
|
176
176
|
PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
|
|
177
177
|
REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
|
|
178
178
|
SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
|
|
179
|
-
SUBSCRIPTION_PAYMENT_NOTIFICATION = "SUBSCRIPTION_PAYMENT_NOTIFICATION",
|
|
180
179
|
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
|
|
181
180
|
}
|
|
182
181
|
/**
|
|
@@ -199,47 +198,104 @@ interface BaseNotification {
|
|
|
199
198
|
eventType: string;
|
|
200
199
|
}
|
|
201
200
|
/**
|
|
202
|
-
* Payment notification
|
|
201
|
+
* Payment notification result payload (21 fields).
|
|
203
202
|
*/
|
|
204
|
-
interface
|
|
205
|
-
eventType: 'PAYMENT_NOTIFICATION';
|
|
206
|
-
acquiringOrderId?: string;
|
|
207
|
-
merchantOrderId?: string;
|
|
203
|
+
interface PaymentNotificationResult {
|
|
208
204
|
paymentRequestId?: string;
|
|
205
|
+
merchantOrderId?: string;
|
|
206
|
+
acquiringOrderId?: string;
|
|
209
207
|
orderStatus?: string;
|
|
210
|
-
|
|
208
|
+
orderAction?: string;
|
|
211
209
|
orderCurrency?: string;
|
|
210
|
+
orderAmount?: string;
|
|
211
|
+
userCurrency?: string;
|
|
212
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;
|
|
213
225
|
[key: string]: unknown;
|
|
214
226
|
}
|
|
215
227
|
/**
|
|
216
|
-
* Refund notification
|
|
228
|
+
* Refund notification result payload (17 fields).
|
|
217
229
|
*/
|
|
218
|
-
interface
|
|
219
|
-
eventType: 'REFUND_NOTIFICATION';
|
|
220
|
-
acquiringRefundOrderId?: string;
|
|
230
|
+
interface RefundNotificationResult {
|
|
221
231
|
refundRequestId?: string;
|
|
222
|
-
|
|
232
|
+
merchantRefundOrderId?: string;
|
|
233
|
+
acquiringOrderId?: string;
|
|
234
|
+
acquiringRefundOrderId?: string;
|
|
235
|
+
origPaymentRequestId?: string;
|
|
223
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;
|
|
224
248
|
[key: string]: unknown;
|
|
225
249
|
}
|
|
226
250
|
/**
|
|
227
|
-
* Subscription
|
|
251
|
+
* Subscription notification result payload (20 fields).
|
|
252
|
+
* Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
|
|
228
253
|
*/
|
|
229
|
-
interface
|
|
230
|
-
|
|
254
|
+
interface SubscriptionNotificationResult {
|
|
255
|
+
subscriptionRequest?: string;
|
|
256
|
+
merchantSubscriptionId?: string;
|
|
231
257
|
subscriptionId?: string;
|
|
232
258
|
subscriptionStatus?: string;
|
|
259
|
+
subscriptionAction?: string;
|
|
260
|
+
currency?: string;
|
|
261
|
+
amount?: string;
|
|
262
|
+
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>[];
|
|
233
275
|
[key: string]: unknown;
|
|
234
276
|
}
|
|
235
277
|
/**
|
|
236
|
-
*
|
|
278
|
+
* Payment notification from Waffo.
|
|
237
279
|
*/
|
|
238
|
-
interface
|
|
239
|
-
eventType: '
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
280
|
+
interface PaymentNotification extends BaseNotification {
|
|
281
|
+
eventType: 'PAYMENT_NOTIFICATION';
|
|
282
|
+
result?: PaymentNotificationResult;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Refund notification from Waffo.
|
|
287
|
+
*/
|
|
288
|
+
interface RefundNotification extends BaseNotification {
|
|
289
|
+
eventType: 'REFUND_NOTIFICATION';
|
|
290
|
+
result?: RefundNotificationResult;
|
|
291
|
+
[key: string]: unknown;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Subscription status notification from Waffo.
|
|
295
|
+
*/
|
|
296
|
+
interface SubscriptionStatusNotification extends BaseNotification {
|
|
297
|
+
eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
|
|
298
|
+
result?: SubscriptionNotificationResult;
|
|
243
299
|
[key: string]: unknown;
|
|
244
300
|
}
|
|
245
301
|
/**
|
|
@@ -247,13 +303,13 @@ interface SubscriptionPaymentNotification extends BaseNotification {
|
|
|
247
303
|
*/
|
|
248
304
|
interface SubscriptionPeriodChangedNotification extends BaseNotification {
|
|
249
305
|
eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
|
|
250
|
-
|
|
306
|
+
result?: SubscriptionNotificationResult;
|
|
251
307
|
[key: string]: unknown;
|
|
252
308
|
}
|
|
253
309
|
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
254
310
|
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
255
311
|
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
256
|
-
type SubscriptionPaymentHandler = (notification:
|
|
312
|
+
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
257
313
|
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
258
314
|
/**
|
|
259
315
|
* Webhook handler for processing Waffo webhook notifications.
|
|
@@ -263,10 +319,10 @@ type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChanged
|
|
|
263
319
|
* // Setup handler
|
|
264
320
|
* const handler = waffo.webhook()
|
|
265
321
|
* .onPayment((notification) => {
|
|
266
|
-
* console.log('Payment:', notification.orderStatus);
|
|
322
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
267
323
|
* })
|
|
268
324
|
* .onRefund((notification) => {
|
|
269
|
-
* console.log('Refund:', notification.refundStatus);
|
|
325
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
270
326
|
* });
|
|
271
327
|
*
|
|
272
328
|
* // Process webhook (e.g., in Express.js)
|
|
@@ -303,7 +359,8 @@ declare class WebhookHandler {
|
|
|
303
359
|
*/
|
|
304
360
|
onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
|
|
305
361
|
/**
|
|
306
|
-
* Registers a handler for
|
|
362
|
+
* Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
|
|
363
|
+
* Only called when onSubscriptionStatus handler is not registered.
|
|
307
364
|
*/
|
|
308
365
|
onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
|
|
309
366
|
/**
|
|
@@ -887,10 +944,8 @@ interface InquirySubscriptionData {
|
|
|
887
944
|
* Cancel subscription request parameters.
|
|
888
945
|
*/
|
|
889
946
|
interface CancelSubscriptionParams {
|
|
890
|
-
subscriptionRequest?: string;
|
|
891
947
|
subscriptionId?: string;
|
|
892
|
-
|
|
893
|
-
cancelReason?: string;
|
|
948
|
+
merchantId?: string;
|
|
894
949
|
requestedAt?: string;
|
|
895
950
|
[key: string]: unknown;
|
|
896
951
|
}
|
|
@@ -1782,13 +1837,13 @@ declare class Waffo {
|
|
|
1782
1837
|
* // Setup webhook handler
|
|
1783
1838
|
* const handler = waffo.webhook()
|
|
1784
1839
|
* .onPayment((notification) => {
|
|
1785
|
-
* console.log('Payment:', notification.orderStatus);
|
|
1840
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
1786
1841
|
* })
|
|
1787
1842
|
* .onRefund((notification) => {
|
|
1788
|
-
* console.log('Refund:', notification.refundStatus);
|
|
1843
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
1789
1844
|
* })
|
|
1790
1845
|
* .onSubscriptionStatus((notification) => {
|
|
1791
|
-
* console.log('Subscription:', notification.subscriptionStatus);
|
|
1846
|
+
* console.log('Subscription:', notification.result?.subscriptionStatus);
|
|
1792
1847
|
* });
|
|
1793
1848
|
*
|
|
1794
1849
|
* // In Express.js route handler
|
|
@@ -2007,4 +2062,4 @@ declare const RsaUtils: {
|
|
|
2007
2062
|
generateKeyPair: typeof generateKeyPair;
|
|
2008
2063
|
};
|
|
2009
2064
|
|
|
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -463,7 +463,7 @@ var HEADER_SDK_VERSION = "x-sdk-version";
|
|
|
463
463
|
var HEADER_CONTENT_TYPE = "content-type";
|
|
464
464
|
var CONTENT_TYPE_JSON = "application/json";
|
|
465
465
|
var API_VERSION = "1.0.0";
|
|
466
|
-
var SDK_VERSION = "waffo-node/2.
|
|
466
|
+
var SDK_VERSION = "waffo-node/2.2.0";
|
|
467
467
|
var WaffoHttpClient = class {
|
|
468
468
|
baseUrl;
|
|
469
469
|
apiKey;
|
|
@@ -616,7 +616,6 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
|
616
616
|
WebhookEventType2["PAYMENT_NOTIFICATION"] = "PAYMENT_NOTIFICATION";
|
|
617
617
|
WebhookEventType2["REFUND_NOTIFICATION"] = "REFUND_NOTIFICATION";
|
|
618
618
|
WebhookEventType2["SUBSCRIPTION_STATUS_NOTIFICATION"] = "SUBSCRIPTION_STATUS_NOTIFICATION";
|
|
619
|
-
WebhookEventType2["SUBSCRIPTION_PAYMENT_NOTIFICATION"] = "SUBSCRIPTION_PAYMENT_NOTIFICATION";
|
|
620
619
|
WebhookEventType2["SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"] = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION";
|
|
621
620
|
return WebhookEventType2;
|
|
622
621
|
})(WebhookEventType || {});
|
|
@@ -656,7 +655,8 @@ var WebhookHandler = class {
|
|
|
656
655
|
return this;
|
|
657
656
|
}
|
|
658
657
|
/**
|
|
659
|
-
* Registers a handler for
|
|
658
|
+
* Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
|
|
659
|
+
* Only called when onSubscriptionStatus handler is not registered.
|
|
660
660
|
*/
|
|
661
661
|
onSubscriptionPayment(handler) {
|
|
662
662
|
this.subscriptionPaymentHandler = handler;
|
|
@@ -703,10 +703,7 @@ var WebhookHandler = class {
|
|
|
703
703
|
case "SUBSCRIPTION_STATUS_NOTIFICATION" /* SUBSCRIPTION_STATUS_NOTIFICATION */:
|
|
704
704
|
if (this.subscriptionStatusHandler) {
|
|
705
705
|
await this.subscriptionStatusHandler(parsed);
|
|
706
|
-
}
|
|
707
|
-
break;
|
|
708
|
-
case "SUBSCRIPTION_PAYMENT_NOTIFICATION" /* SUBSCRIPTION_PAYMENT_NOTIFICATION */:
|
|
709
|
-
if (this.subscriptionPaymentHandler) {
|
|
706
|
+
} else if (this.subscriptionPaymentHandler) {
|
|
710
707
|
await this.subscriptionPaymentHandler(parsed);
|
|
711
708
|
}
|
|
712
709
|
break;
|
|
@@ -1193,13 +1190,13 @@ var Waffo = class _Waffo {
|
|
|
1193
1190
|
* // Setup webhook handler
|
|
1194
1191
|
* const handler = waffo.webhook()
|
|
1195
1192
|
* .onPayment((notification) => {
|
|
1196
|
-
* console.log('Payment:', notification.orderStatus);
|
|
1193
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
1197
1194
|
* })
|
|
1198
1195
|
* .onRefund((notification) => {
|
|
1199
|
-
* console.log('Refund:', notification.refundStatus);
|
|
1196
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
1200
1197
|
* })
|
|
1201
1198
|
* .onSubscriptionStatus((notification) => {
|
|
1202
|
-
* console.log('Subscription:', notification.subscriptionStatus);
|
|
1199
|
+
* console.log('Subscription:', notification.result?.subscriptionStatus);
|
|
1203
1200
|
* });
|
|
1204
1201
|
*
|
|
1205
1202
|
* // In Express.js route handler
|