@waffo/waffo-node 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +64 -7
- package/dist/index.d.ts +64 -7
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -735,7 +735,8 @@ declare enum WebhookEventType {
|
|
|
735
735
|
PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
|
|
736
736
|
REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
|
|
737
737
|
SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
|
|
738
|
-
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
|
|
738
|
+
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION",
|
|
739
|
+
SUBSCRIPTION_CHANGE_NOTIFICATION = "SUBSCRIPTION_CHANGE_NOTIFICATION"
|
|
739
740
|
}
|
|
740
741
|
/**
|
|
741
742
|
* Result of webhook handling.
|
|
@@ -853,6 +854,33 @@ interface SubscriptionNotificationResult {
|
|
|
853
854
|
paymentDetails?: Record<string, unknown>[];
|
|
854
855
|
[key: string]: unknown;
|
|
855
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Subscription change notification result payload.
|
|
859
|
+
* Triggered when a subscription change (upgrade/downgrade) reaches final status (SUCCESS or CLOSED).
|
|
860
|
+
*/
|
|
861
|
+
interface SubscriptionChangeNotificationResult {
|
|
862
|
+
subscriptionRequest?: string;
|
|
863
|
+
originSubscriptionRequest?: string;
|
|
864
|
+
merchantSubscriptionId?: string;
|
|
865
|
+
subscriptionId?: string;
|
|
866
|
+
/** Final status: SUCCESS or CLOSED */
|
|
867
|
+
subscriptionChangeStatus?: string;
|
|
868
|
+
subscriptionAction?: string;
|
|
869
|
+
remainingAmount?: string;
|
|
870
|
+
currency?: string;
|
|
871
|
+
userCurrency?: string;
|
|
872
|
+
requestedAt?: string;
|
|
873
|
+
subscriptionManagementUrl?: string;
|
|
874
|
+
extendInfo?: string;
|
|
875
|
+
orderExpiredAt?: string;
|
|
876
|
+
productInfoList?: Record<string, unknown>[];
|
|
877
|
+
merchantInfo?: Record<string, unknown>;
|
|
878
|
+
userInfo?: Record<string, unknown>;
|
|
879
|
+
goodsInfo?: Record<string, unknown>;
|
|
880
|
+
addressInfo?: Record<string, unknown>;
|
|
881
|
+
paymentInfo?: Record<string, unknown>;
|
|
882
|
+
[key: string]: unknown;
|
|
883
|
+
}
|
|
856
884
|
/**
|
|
857
885
|
* Payment notification from Waffo.
|
|
858
886
|
*/
|
|
@@ -885,11 +913,20 @@ interface SubscriptionPeriodChangedNotification extends BaseNotification {
|
|
|
885
913
|
result?: SubscriptionNotificationResult;
|
|
886
914
|
[key: string]: unknown;
|
|
887
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Subscription change notification from Waffo.
|
|
918
|
+
*/
|
|
919
|
+
interface SubscriptionChangeNotification extends BaseNotification {
|
|
920
|
+
eventType: 'SUBSCRIPTION_CHANGE_NOTIFICATION';
|
|
921
|
+
result?: SubscriptionChangeNotificationResult;
|
|
922
|
+
[key: string]: unknown;
|
|
923
|
+
}
|
|
888
924
|
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
889
925
|
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
890
926
|
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
891
927
|
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
892
928
|
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
929
|
+
type SubscriptionChangeHandler = (notification: SubscriptionChangeNotification) => void | Promise<void>;
|
|
893
930
|
/**
|
|
894
931
|
* Webhook handler for processing Waffo webhook notifications.
|
|
895
932
|
*
|
|
@@ -924,6 +961,7 @@ declare class WebhookHandler {
|
|
|
924
961
|
private subscriptionStatusHandler?;
|
|
925
962
|
private subscriptionPaymentHandler?;
|
|
926
963
|
private subscriptionPeriodChangedHandler?;
|
|
964
|
+
private subscriptionChangeHandler?;
|
|
927
965
|
constructor(config: WaffoConfig);
|
|
928
966
|
/**
|
|
929
967
|
* Registers a handler for payment notifications.
|
|
@@ -946,6 +984,10 @@ declare class WebhookHandler {
|
|
|
946
984
|
* Registers a handler for subscription period changed notifications.
|
|
947
985
|
*/
|
|
948
986
|
onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
|
|
987
|
+
/**
|
|
988
|
+
* Registers a handler for subscription change notifications.
|
|
989
|
+
*/
|
|
990
|
+
onSubscriptionChange(handler: SubscriptionChangeHandler): this;
|
|
949
991
|
/**
|
|
950
992
|
* Processes a webhook notification.
|
|
951
993
|
*
|
|
@@ -1215,14 +1257,13 @@ interface CancelOrderData {
|
|
|
1215
1257
|
*/
|
|
1216
1258
|
interface RefundOrderParams {
|
|
1217
1259
|
refundRequestId: string;
|
|
1218
|
-
|
|
1219
|
-
|
|
1260
|
+
acquiringOrderId: string;
|
|
1261
|
+
merchantId?: string;
|
|
1220
1262
|
merchantRefundOrderId?: string;
|
|
1221
|
-
merchantInfo?: MerchantInfo;
|
|
1222
1263
|
refundAmount: string;
|
|
1223
|
-
refundReason
|
|
1224
|
-
requestedAt
|
|
1225
|
-
|
|
1264
|
+
refundReason: string;
|
|
1265
|
+
requestedAt: string;
|
|
1266
|
+
refundNotifyUrl?: string;
|
|
1226
1267
|
userInfo?: RefundUserInfo;
|
|
1227
1268
|
extendInfo?: string;
|
|
1228
1269
|
[key: string]: unknown;
|
|
@@ -1363,9 +1404,25 @@ interface RiskData {
|
|
|
1363
1404
|
interface RefundUserInfo {
|
|
1364
1405
|
userType?: string;
|
|
1365
1406
|
userFirstName?: string;
|
|
1407
|
+
userMiddleName?: string;
|
|
1366
1408
|
userLastName?: string;
|
|
1409
|
+
nationality?: string;
|
|
1367
1410
|
userEmail?: string;
|
|
1368
1411
|
userPhone?: string;
|
|
1412
|
+
userBirthDay?: string;
|
|
1413
|
+
userIDType?: string;
|
|
1414
|
+
userIDNumber?: string;
|
|
1415
|
+
userIDIssueDate?: string;
|
|
1416
|
+
userIDExpiryDate?: string;
|
|
1417
|
+
userBankInfo?: RefundUserBankInfo;
|
|
1418
|
+
[key: string]: unknown;
|
|
1419
|
+
}
|
|
1420
|
+
interface RefundUserBankInfo {
|
|
1421
|
+
bankAccountNo?: string;
|
|
1422
|
+
bankCode?: string;
|
|
1423
|
+
bankName?: string;
|
|
1424
|
+
bankCity?: string;
|
|
1425
|
+
bankBranch?: string;
|
|
1369
1426
|
[key: string]: unknown;
|
|
1370
1427
|
}
|
|
1371
1428
|
|
package/dist/index.d.ts
CHANGED
|
@@ -735,7 +735,8 @@ declare enum WebhookEventType {
|
|
|
735
735
|
PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
|
|
736
736
|
REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
|
|
737
737
|
SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
|
|
738
|
-
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
|
|
738
|
+
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION",
|
|
739
|
+
SUBSCRIPTION_CHANGE_NOTIFICATION = "SUBSCRIPTION_CHANGE_NOTIFICATION"
|
|
739
740
|
}
|
|
740
741
|
/**
|
|
741
742
|
* Result of webhook handling.
|
|
@@ -853,6 +854,33 @@ interface SubscriptionNotificationResult {
|
|
|
853
854
|
paymentDetails?: Record<string, unknown>[];
|
|
854
855
|
[key: string]: unknown;
|
|
855
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Subscription change notification result payload.
|
|
859
|
+
* Triggered when a subscription change (upgrade/downgrade) reaches final status (SUCCESS or CLOSED).
|
|
860
|
+
*/
|
|
861
|
+
interface SubscriptionChangeNotificationResult {
|
|
862
|
+
subscriptionRequest?: string;
|
|
863
|
+
originSubscriptionRequest?: string;
|
|
864
|
+
merchantSubscriptionId?: string;
|
|
865
|
+
subscriptionId?: string;
|
|
866
|
+
/** Final status: SUCCESS or CLOSED */
|
|
867
|
+
subscriptionChangeStatus?: string;
|
|
868
|
+
subscriptionAction?: string;
|
|
869
|
+
remainingAmount?: string;
|
|
870
|
+
currency?: string;
|
|
871
|
+
userCurrency?: string;
|
|
872
|
+
requestedAt?: string;
|
|
873
|
+
subscriptionManagementUrl?: string;
|
|
874
|
+
extendInfo?: string;
|
|
875
|
+
orderExpiredAt?: string;
|
|
876
|
+
productInfoList?: Record<string, unknown>[];
|
|
877
|
+
merchantInfo?: Record<string, unknown>;
|
|
878
|
+
userInfo?: Record<string, unknown>;
|
|
879
|
+
goodsInfo?: Record<string, unknown>;
|
|
880
|
+
addressInfo?: Record<string, unknown>;
|
|
881
|
+
paymentInfo?: Record<string, unknown>;
|
|
882
|
+
[key: string]: unknown;
|
|
883
|
+
}
|
|
856
884
|
/**
|
|
857
885
|
* Payment notification from Waffo.
|
|
858
886
|
*/
|
|
@@ -885,11 +913,20 @@ interface SubscriptionPeriodChangedNotification extends BaseNotification {
|
|
|
885
913
|
result?: SubscriptionNotificationResult;
|
|
886
914
|
[key: string]: unknown;
|
|
887
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Subscription change notification from Waffo.
|
|
918
|
+
*/
|
|
919
|
+
interface SubscriptionChangeNotification extends BaseNotification {
|
|
920
|
+
eventType: 'SUBSCRIPTION_CHANGE_NOTIFICATION';
|
|
921
|
+
result?: SubscriptionChangeNotificationResult;
|
|
922
|
+
[key: string]: unknown;
|
|
923
|
+
}
|
|
888
924
|
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
889
925
|
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
890
926
|
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
891
927
|
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
892
928
|
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
929
|
+
type SubscriptionChangeHandler = (notification: SubscriptionChangeNotification) => void | Promise<void>;
|
|
893
930
|
/**
|
|
894
931
|
* Webhook handler for processing Waffo webhook notifications.
|
|
895
932
|
*
|
|
@@ -924,6 +961,7 @@ declare class WebhookHandler {
|
|
|
924
961
|
private subscriptionStatusHandler?;
|
|
925
962
|
private subscriptionPaymentHandler?;
|
|
926
963
|
private subscriptionPeriodChangedHandler?;
|
|
964
|
+
private subscriptionChangeHandler?;
|
|
927
965
|
constructor(config: WaffoConfig);
|
|
928
966
|
/**
|
|
929
967
|
* Registers a handler for payment notifications.
|
|
@@ -946,6 +984,10 @@ declare class WebhookHandler {
|
|
|
946
984
|
* Registers a handler for subscription period changed notifications.
|
|
947
985
|
*/
|
|
948
986
|
onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
|
|
987
|
+
/**
|
|
988
|
+
* Registers a handler for subscription change notifications.
|
|
989
|
+
*/
|
|
990
|
+
onSubscriptionChange(handler: SubscriptionChangeHandler): this;
|
|
949
991
|
/**
|
|
950
992
|
* Processes a webhook notification.
|
|
951
993
|
*
|
|
@@ -1215,14 +1257,13 @@ interface CancelOrderData {
|
|
|
1215
1257
|
*/
|
|
1216
1258
|
interface RefundOrderParams {
|
|
1217
1259
|
refundRequestId: string;
|
|
1218
|
-
|
|
1219
|
-
|
|
1260
|
+
acquiringOrderId: string;
|
|
1261
|
+
merchantId?: string;
|
|
1220
1262
|
merchantRefundOrderId?: string;
|
|
1221
|
-
merchantInfo?: MerchantInfo;
|
|
1222
1263
|
refundAmount: string;
|
|
1223
|
-
refundReason
|
|
1224
|
-
requestedAt
|
|
1225
|
-
|
|
1264
|
+
refundReason: string;
|
|
1265
|
+
requestedAt: string;
|
|
1266
|
+
refundNotifyUrl?: string;
|
|
1226
1267
|
userInfo?: RefundUserInfo;
|
|
1227
1268
|
extendInfo?: string;
|
|
1228
1269
|
[key: string]: unknown;
|
|
@@ -1363,9 +1404,25 @@ interface RiskData {
|
|
|
1363
1404
|
interface RefundUserInfo {
|
|
1364
1405
|
userType?: string;
|
|
1365
1406
|
userFirstName?: string;
|
|
1407
|
+
userMiddleName?: string;
|
|
1366
1408
|
userLastName?: string;
|
|
1409
|
+
nationality?: string;
|
|
1367
1410
|
userEmail?: string;
|
|
1368
1411
|
userPhone?: string;
|
|
1412
|
+
userBirthDay?: string;
|
|
1413
|
+
userIDType?: string;
|
|
1414
|
+
userIDNumber?: string;
|
|
1415
|
+
userIDIssueDate?: string;
|
|
1416
|
+
userIDExpiryDate?: string;
|
|
1417
|
+
userBankInfo?: RefundUserBankInfo;
|
|
1418
|
+
[key: string]: unknown;
|
|
1419
|
+
}
|
|
1420
|
+
interface RefundUserBankInfo {
|
|
1421
|
+
bankAccountNo?: string;
|
|
1422
|
+
bankCode?: string;
|
|
1423
|
+
bankName?: string;
|
|
1424
|
+
bankCity?: string;
|
|
1425
|
+
bankBranch?: string;
|
|
1369
1426
|
[key: string]: unknown;
|
|
1370
1427
|
}
|
|
1371
1428
|
|
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.3.
|
|
466
|
+
var SDK_VERSION = "waffo-node/2.3.3";
|
|
467
467
|
var WaffoHttpClient = class {
|
|
468
468
|
baseUrl;
|
|
469
469
|
apiKey;
|
|
@@ -600,13 +600,12 @@ var WaffoHttpClient = class {
|
|
|
600
600
|
if (!info.merchantId) {
|
|
601
601
|
info.merchantId = this.merchantId;
|
|
602
602
|
}
|
|
603
|
-
} else if ("merchantId" in req) {
|
|
604
|
-
if (!req.merchantId) {
|
|
605
|
-
req.merchantId = this.merchantId;
|
|
606
|
-
}
|
|
607
603
|
} else {
|
|
608
604
|
req.merchantInfo = { merchantId: this.merchantId };
|
|
609
605
|
}
|
|
606
|
+
if (!req.merchantId) {
|
|
607
|
+
req.merchantId = this.merchantId;
|
|
608
|
+
}
|
|
610
609
|
}
|
|
611
610
|
/**
|
|
612
611
|
* Checks if the error is a network-related error.
|
|
@@ -624,6 +623,7 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
|
624
623
|
WebhookEventType2["REFUND_NOTIFICATION"] = "REFUND_NOTIFICATION";
|
|
625
624
|
WebhookEventType2["SUBSCRIPTION_STATUS_NOTIFICATION"] = "SUBSCRIPTION_STATUS_NOTIFICATION";
|
|
626
625
|
WebhookEventType2["SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"] = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION";
|
|
626
|
+
WebhookEventType2["SUBSCRIPTION_CHANGE_NOTIFICATION"] = "SUBSCRIPTION_CHANGE_NOTIFICATION";
|
|
627
627
|
return WebhookEventType2;
|
|
628
628
|
})(WebhookEventType || {});
|
|
629
629
|
var WebhookHandler = class {
|
|
@@ -635,6 +635,7 @@ var WebhookHandler = class {
|
|
|
635
635
|
subscriptionStatusHandler;
|
|
636
636
|
subscriptionPaymentHandler;
|
|
637
637
|
subscriptionPeriodChangedHandler;
|
|
638
|
+
subscriptionChangeHandler;
|
|
638
639
|
constructor(config) {
|
|
639
640
|
this.waffoPublicKey = config.waffoPublicKey;
|
|
640
641
|
this.privateKey = config.privateKey;
|
|
@@ -676,6 +677,13 @@ var WebhookHandler = class {
|
|
|
676
677
|
this.subscriptionPeriodChangedHandler = handler;
|
|
677
678
|
return this;
|
|
678
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Registers a handler for subscription change notifications.
|
|
682
|
+
*/
|
|
683
|
+
onSubscriptionChange(handler) {
|
|
684
|
+
this.subscriptionChangeHandler = handler;
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
679
687
|
/**
|
|
680
688
|
* Processes a webhook notification.
|
|
681
689
|
*
|
|
@@ -719,6 +727,11 @@ var WebhookHandler = class {
|
|
|
719
727
|
await this.subscriptionPeriodChangedHandler(parsed);
|
|
720
728
|
}
|
|
721
729
|
break;
|
|
730
|
+
case "SUBSCRIPTION_CHANGE_NOTIFICATION" /* SUBSCRIPTION_CHANGE_NOTIFICATION */:
|
|
731
|
+
if (this.subscriptionChangeHandler) {
|
|
732
|
+
await this.subscriptionChangeHandler(parsed);
|
|
733
|
+
}
|
|
734
|
+
break;
|
|
722
735
|
default:
|
|
723
736
|
this.logger?.warn(`Unknown webhook event type: ${eventType}`);
|
|
724
737
|
return this.createFailedResult(`Unknown event type: ${eventType}`);
|