@waffo/waffo-node 2.3.1 → 2.3.2
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 +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -1
- 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
|
*
|
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
|
*
|
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.2";
|
|
467
467
|
var WaffoHttpClient = class {
|
|
468
468
|
baseUrl;
|
|
469
469
|
apiKey;
|
|
@@ -624,6 +624,7 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
|
624
624
|
WebhookEventType2["REFUND_NOTIFICATION"] = "REFUND_NOTIFICATION";
|
|
625
625
|
WebhookEventType2["SUBSCRIPTION_STATUS_NOTIFICATION"] = "SUBSCRIPTION_STATUS_NOTIFICATION";
|
|
626
626
|
WebhookEventType2["SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"] = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION";
|
|
627
|
+
WebhookEventType2["SUBSCRIPTION_CHANGE_NOTIFICATION"] = "SUBSCRIPTION_CHANGE_NOTIFICATION";
|
|
627
628
|
return WebhookEventType2;
|
|
628
629
|
})(WebhookEventType || {});
|
|
629
630
|
var WebhookHandler = class {
|
|
@@ -635,6 +636,7 @@ var WebhookHandler = class {
|
|
|
635
636
|
subscriptionStatusHandler;
|
|
636
637
|
subscriptionPaymentHandler;
|
|
637
638
|
subscriptionPeriodChangedHandler;
|
|
639
|
+
subscriptionChangeHandler;
|
|
638
640
|
constructor(config) {
|
|
639
641
|
this.waffoPublicKey = config.waffoPublicKey;
|
|
640
642
|
this.privateKey = config.privateKey;
|
|
@@ -676,6 +678,13 @@ var WebhookHandler = class {
|
|
|
676
678
|
this.subscriptionPeriodChangedHandler = handler;
|
|
677
679
|
return this;
|
|
678
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Registers a handler for subscription change notifications.
|
|
683
|
+
*/
|
|
684
|
+
onSubscriptionChange(handler) {
|
|
685
|
+
this.subscriptionChangeHandler = handler;
|
|
686
|
+
return this;
|
|
687
|
+
}
|
|
679
688
|
/**
|
|
680
689
|
* Processes a webhook notification.
|
|
681
690
|
*
|
|
@@ -719,6 +728,11 @@ var WebhookHandler = class {
|
|
|
719
728
|
await this.subscriptionPeriodChangedHandler(parsed);
|
|
720
729
|
}
|
|
721
730
|
break;
|
|
731
|
+
case "SUBSCRIPTION_CHANGE_NOTIFICATION" /* SUBSCRIPTION_CHANGE_NOTIFICATION */:
|
|
732
|
+
if (this.subscriptionChangeHandler) {
|
|
733
|
+
await this.subscriptionChangeHandler(parsed);
|
|
734
|
+
}
|
|
735
|
+
break;
|
|
722
736
|
default:
|
|
723
737
|
this.logger?.warn(`Unknown webhook event type: ${eventType}`);
|
|
724
738
|
return this.createFailedResult(`Unknown event type: ${eventType}`);
|