@waffo/waffo-node 2.5.1 → 2.6.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 +35 -2
- package/dist/index.d.mts +734 -607
- package/dist/index.d.ts +734 -607
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -187,6 +187,7 @@ interface CreateSubscriptionParams {
|
|
|
187
187
|
merchantSubscriptionId: string;
|
|
188
188
|
currency: string;
|
|
189
189
|
amount: string;
|
|
190
|
+
promotionInfo?: SubscriptionPromotionInfo;
|
|
190
191
|
userCurrency?: string;
|
|
191
192
|
notifyUrl: string;
|
|
192
193
|
productInfo: ProductInfo;
|
|
@@ -206,6 +207,10 @@ interface CreateSubscriptionParams {
|
|
|
206
207
|
cancelRedirectUrl?: string;
|
|
207
208
|
subscriptionManagementUrl?: string;
|
|
208
209
|
requestedAt?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Subscription start time (ISO 8601 format).
|
|
212
|
+
*/
|
|
213
|
+
startTime?: string;
|
|
209
214
|
extendInfo?: string;
|
|
210
215
|
/**
|
|
211
216
|
* Order expiry time (ISO 8601 format, max 24 characters).
|
|
@@ -214,12 +219,24 @@ interface CreateSubscriptionParams {
|
|
|
214
219
|
addressInfo?: SubscriptionAddressInfo;
|
|
215
220
|
riskData?: SubscriptionRiskData;
|
|
216
221
|
brandInfo?: SubscriptionBrandInfo;
|
|
222
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
217
223
|
subscriptionMode?: string;
|
|
224
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
218
225
|
acqMerchant?: Record<string, unknown>;
|
|
226
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
219
227
|
acqProduct?: Record<string, unknown>;
|
|
228
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
220
229
|
acqAgreements?: Record<string, unknown>[];
|
|
221
230
|
[key: string]: unknown;
|
|
222
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Promotion information for a subscription.
|
|
234
|
+
*/
|
|
235
|
+
interface SubscriptionPromotionInfo {
|
|
236
|
+
promotionCode?: string;
|
|
237
|
+
couponId?: string;
|
|
238
|
+
[key: string]: unknown;
|
|
239
|
+
}
|
|
223
240
|
/**
|
|
224
241
|
* Create subscription response data.
|
|
225
242
|
*/
|
|
@@ -263,6 +280,7 @@ interface InquirySubscriptionData {
|
|
|
263
280
|
payMethodSubscriptionId?: string;
|
|
264
281
|
subscriptionStatus?: SubscriptionStatus;
|
|
265
282
|
subscriptionAction?: string;
|
|
283
|
+
cancelReason?: string;
|
|
266
284
|
currency?: string;
|
|
267
285
|
userCurrency?: string;
|
|
268
286
|
amount?: string;
|
|
@@ -679,6 +697,10 @@ interface SubscriptionChangeParams {
|
|
|
679
697
|
* New merchant subscription plan ID (max 64 characters).
|
|
680
698
|
*/
|
|
681
699
|
merchantSubscriptionId?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Promotion information.
|
|
702
|
+
*/
|
|
703
|
+
promotionInfo?: SubscriptionPromotionInfo;
|
|
682
704
|
/**
|
|
683
705
|
* Original subscription request ID to be changed (max 32 characters).
|
|
684
706
|
*/
|
|
@@ -699,6 +721,10 @@ interface SubscriptionChangeParams {
|
|
|
699
721
|
* Request time (ISO 8601 format). Auto-injected if not provided.
|
|
700
722
|
*/
|
|
701
723
|
requestedAt?: string;
|
|
724
|
+
/**
|
|
725
|
+
* Subscription start time (ISO 8601 format).
|
|
726
|
+
*/
|
|
727
|
+
startTime?: string;
|
|
702
728
|
/**
|
|
703
729
|
* Redirect URL after successful subscription change.
|
|
704
730
|
*/
|
|
@@ -934,67 +960,106 @@ interface SubscriptionChangeInquiryData {
|
|
|
934
960
|
}
|
|
935
961
|
|
|
936
962
|
/**
|
|
937
|
-
*
|
|
963
|
+
* Order-related type definitions.
|
|
964
|
+
*
|
|
965
|
+
* Note: Full type definitions should be generated from openapi.json.
|
|
966
|
+
* These are placeholder interfaces for the SDK structure.
|
|
938
967
|
*/
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Create order request parameters.
|
|
971
|
+
*/
|
|
972
|
+
interface CreateOrderParams {
|
|
973
|
+
paymentRequestId: string;
|
|
974
|
+
merchantOrderId: string;
|
|
975
|
+
orderCurrency: string;
|
|
976
|
+
orderAmount: string;
|
|
977
|
+
orderDescription: string;
|
|
978
|
+
notifyUrl: string;
|
|
979
|
+
userInfo: UserInfo;
|
|
980
|
+
paymentInfo: PaymentInfo;
|
|
981
|
+
merchantInfo?: MerchantInfo;
|
|
982
|
+
goodsInfo?: GoodsInfo;
|
|
983
|
+
addressInfo?: AddressInfo;
|
|
984
|
+
cardInfo?: CardInfo;
|
|
985
|
+
riskData?: RiskData;
|
|
986
|
+
paymentTokenData?: PaymentTokenData;
|
|
987
|
+
brandInfo?: BrandInfo;
|
|
988
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
989
|
+
productDetail?: ProductDetail;
|
|
990
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
991
|
+
acqOrderExtSubscriptionInfo?: AcqOrderExtSubscriptionInfo;
|
|
992
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
993
|
+
channelId?: string;
|
|
994
|
+
/** @deprecated Legacy field retained for source compatibility; not in the current OpenAPI contract. */
|
|
995
|
+
innerCardData?: WaffoTokenCardData;
|
|
996
|
+
promotionInfo?: PromotionInfo;
|
|
997
|
+
x402Info?: X402Info;
|
|
998
|
+
userCurrency?: string;
|
|
999
|
+
successRedirectUrl?: string;
|
|
1000
|
+
failedRedirectUrl?: string;
|
|
1001
|
+
cancelRedirectUrl?: string;
|
|
1002
|
+
orderRequestedAt?: string;
|
|
1003
|
+
orderExpiredAt?: string;
|
|
1004
|
+
extendInfo?: string;
|
|
1005
|
+
[key: string]: unknown;
|
|
945
1006
|
}
|
|
946
1007
|
/**
|
|
947
|
-
*
|
|
1008
|
+
* Create order response data.
|
|
948
1009
|
*/
|
|
949
|
-
interface
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
error?: string;
|
|
1010
|
+
interface CreateOrderData {
|
|
1011
|
+
paymentRequestId?: string;
|
|
1012
|
+
merchantOrderId?: string;
|
|
1013
|
+
acquiringOrderId?: string;
|
|
1014
|
+
orderStatus?: OrderStatus;
|
|
1015
|
+
orderAction?: string;
|
|
1016
|
+
x402Info?: X402Info;
|
|
1017
|
+
[key: string]: unknown;
|
|
958
1018
|
}
|
|
959
1019
|
/**
|
|
960
|
-
*
|
|
1020
|
+
* Inquiry order request parameters.
|
|
1021
|
+
* Provide paymentRequestId or acquiringOrderId.
|
|
961
1022
|
*/
|
|
962
|
-
interface
|
|
963
|
-
|
|
1023
|
+
interface InquiryOrderParams {
|
|
1024
|
+
paymentRequestId?: string;
|
|
1025
|
+
acquiringOrderId?: string;
|
|
1026
|
+
[key: string]: unknown;
|
|
964
1027
|
}
|
|
965
1028
|
/**
|
|
966
|
-
*
|
|
1029
|
+
* Inquiry order response data.
|
|
967
1030
|
*/
|
|
968
|
-
interface
|
|
1031
|
+
interface InquiryOrderData {
|
|
969
1032
|
paymentRequestId?: string;
|
|
970
1033
|
merchantOrderId?: string;
|
|
971
1034
|
acquiringOrderId?: string;
|
|
972
|
-
orderStatus?:
|
|
1035
|
+
orderStatus?: OrderStatus;
|
|
973
1036
|
orderAction?: string;
|
|
974
1037
|
orderCurrency?: string;
|
|
975
1038
|
orderAmount?: string;
|
|
976
|
-
|
|
1039
|
+
originalAmount?: string;
|
|
977
1040
|
finalDealAmount?: string;
|
|
978
1041
|
orderDescription?: string;
|
|
979
|
-
merchantInfo?:
|
|
980
|
-
userInfo?:
|
|
981
|
-
goodsInfo?:
|
|
982
|
-
|
|
983
|
-
|
|
1042
|
+
merchantInfo?: MerchantInfo;
|
|
1043
|
+
userInfo?: UserInfo;
|
|
1044
|
+
goodsInfo?: GoodsInfo;
|
|
1045
|
+
paymentInfo?: PaymentInfo;
|
|
1046
|
+
addressInfo?: AddressInfo;
|
|
984
1047
|
orderRequestedAt?: string;
|
|
985
1048
|
orderExpiredAt?: string;
|
|
986
1049
|
orderUpdatedAt?: string;
|
|
987
1050
|
orderCompletedAt?: string;
|
|
988
|
-
|
|
1051
|
+
/**
|
|
1052
|
+
* Refund expiry time (ISO 8601 format).
|
|
1053
|
+
*/
|
|
1054
|
+
refundExpiryAt?: string;
|
|
1055
|
+
orderFailedReason?: string;
|
|
989
1056
|
extendInfo?: string;
|
|
1057
|
+
userCurrency?: string;
|
|
1058
|
+
x402Info?: X402Info;
|
|
990
1059
|
/**
|
|
991
1060
|
* The associated subscription info.
|
|
992
1061
|
*/
|
|
993
1062
|
subscriptionInfo?: SubscriptionInfo;
|
|
994
|
-
/**
|
|
995
|
-
* Refund expiry time (ISO 8601 format).
|
|
996
|
-
*/
|
|
997
|
-
refundExpiryAt?: string;
|
|
998
1063
|
/**
|
|
999
1064
|
* The address of the merchant page to redirect to when user cancels the payment.
|
|
1000
1065
|
*/
|
|
@@ -1002,708 +1067,700 @@ interface PaymentNotificationResult {
|
|
|
1002
1067
|
[key: string]: unknown;
|
|
1003
1068
|
}
|
|
1004
1069
|
/**
|
|
1005
|
-
*
|
|
1070
|
+
* Cancel order request parameters.
|
|
1006
1071
|
*/
|
|
1007
|
-
interface
|
|
1008
|
-
|
|
1009
|
-
merchantRefundOrderId?: string;
|
|
1072
|
+
interface CancelOrderParams {
|
|
1073
|
+
paymentRequestId?: string;
|
|
1010
1074
|
acquiringOrderId?: string;
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
refundAmount?: string;
|
|
1014
|
-
refundStatus?: string;
|
|
1015
|
-
remainingRefundAmount?: string;
|
|
1016
|
-
userCurrency?: string;
|
|
1017
|
-
finalDealAmount?: string;
|
|
1018
|
-
refundReason?: string;
|
|
1019
|
-
refundRequestedAt?: string;
|
|
1020
|
-
refundUpdatedAt?: string;
|
|
1021
|
-
refundCompletedAt?: string;
|
|
1022
|
-
refundFailedReason?: Record<string, unknown>;
|
|
1023
|
-
userInfo?: Record<string, unknown>;
|
|
1024
|
-
extendInfo?: string;
|
|
1025
|
-
/**
|
|
1026
|
-
* Refund source. Possible values: MERCHANT, RDR, ETHOCA.
|
|
1027
|
-
*/
|
|
1028
|
-
refundSource?: string;
|
|
1075
|
+
merchantId?: string;
|
|
1076
|
+
orderRequestedAt?: string;
|
|
1029
1077
|
[key: string]: unknown;
|
|
1030
1078
|
}
|
|
1031
1079
|
/**
|
|
1032
|
-
*
|
|
1033
|
-
* Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
|
|
1080
|
+
* Cancel order response data.
|
|
1034
1081
|
*/
|
|
1035
|
-
interface
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
* Payment method's subscription id.
|
|
1041
|
-
*/
|
|
1042
|
-
payMethodSubscriptionId?: string;
|
|
1043
|
-
subscriptionStatus?: string;
|
|
1044
|
-
subscriptionAction?: string;
|
|
1045
|
-
currency?: string;
|
|
1046
|
-
amount?: string;
|
|
1047
|
-
userCurrency?: string;
|
|
1048
|
-
productInfo?: Record<string, unknown>;
|
|
1049
|
-
merchantInfo?: Record<string, unknown>;
|
|
1050
|
-
userInfo?: Record<string, unknown>;
|
|
1051
|
-
goodsInfo?: Record<string, unknown>;
|
|
1052
|
-
addressInfo?: Record<string, unknown>;
|
|
1053
|
-
paymentInfo?: Record<string, unknown>;
|
|
1054
|
-
requestedAt?: string;
|
|
1055
|
-
updatedAt?: string;
|
|
1056
|
-
failedReason?: Record<string, unknown>;
|
|
1057
|
-
extendInfo?: string;
|
|
1058
|
-
subscriptionManagementUrl?: string;
|
|
1059
|
-
paymentDetails?: Record<string, unknown>[];
|
|
1082
|
+
interface CancelOrderData {
|
|
1083
|
+
paymentRequestId?: string;
|
|
1084
|
+
merchantOrderId?: string;
|
|
1085
|
+
acquiringOrderId?: string;
|
|
1086
|
+
orderStatus?: OrderStatus;
|
|
1060
1087
|
[key: string]: unknown;
|
|
1061
1088
|
}
|
|
1062
1089
|
/**
|
|
1063
|
-
*
|
|
1064
|
-
* Triggered when a subscription change (upgrade/downgrade) reaches final status (SUCCESS or CLOSED).
|
|
1090
|
+
* Refund order request parameters.
|
|
1065
1091
|
*/
|
|
1066
|
-
interface
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
subscriptionAction?: string;
|
|
1074
|
-
remainingAmount?: string;
|
|
1075
|
-
currency?: string;
|
|
1076
|
-
userCurrency?: string;
|
|
1092
|
+
interface RefundOrderParams {
|
|
1093
|
+
refundRequestId: string;
|
|
1094
|
+
acquiringOrderId: string;
|
|
1095
|
+
merchantId?: string;
|
|
1096
|
+
merchantRefundOrderId?: string;
|
|
1097
|
+
refundAmount: string;
|
|
1098
|
+
refundReason: string;
|
|
1077
1099
|
requestedAt?: string;
|
|
1078
|
-
|
|
1100
|
+
refundNotifyUrl?: string;
|
|
1101
|
+
userInfo?: RefundUserInfo;
|
|
1079
1102
|
extendInfo?: string;
|
|
1080
|
-
|
|
1081
|
-
productInfoList?: Record<string, unknown>[];
|
|
1082
|
-
merchantInfo?: Record<string, unknown>;
|
|
1083
|
-
userInfo?: Record<string, unknown>;
|
|
1084
|
-
goodsInfo?: Record<string, unknown>;
|
|
1085
|
-
addressInfo?: Record<string, unknown>;
|
|
1086
|
-
paymentInfo?: Record<string, unknown>;
|
|
1103
|
+
refundSource?: string;
|
|
1087
1104
|
[key: string]: unknown;
|
|
1088
1105
|
}
|
|
1089
1106
|
/**
|
|
1090
|
-
*
|
|
1107
|
+
* Refund order response data.
|
|
1091
1108
|
*/
|
|
1092
|
-
interface
|
|
1093
|
-
|
|
1094
|
-
|
|
1109
|
+
interface RefundOrderData {
|
|
1110
|
+
refundRequestId?: string;
|
|
1111
|
+
merchantRefundOrderId?: string;
|
|
1112
|
+
acquiringOrderId?: string;
|
|
1113
|
+
acquiringRefundOrderId?: string;
|
|
1114
|
+
refundAmount?: string;
|
|
1115
|
+
refundStatus?: RefundStatus$1;
|
|
1116
|
+
remainingRefundAmount?: string;
|
|
1117
|
+
refundSource?: string;
|
|
1095
1118
|
[key: string]: unknown;
|
|
1096
1119
|
}
|
|
1097
1120
|
/**
|
|
1098
|
-
*
|
|
1121
|
+
* Capture order request parameters.
|
|
1099
1122
|
*/
|
|
1100
|
-
interface
|
|
1101
|
-
|
|
1102
|
-
|
|
1123
|
+
interface CaptureOrderParams {
|
|
1124
|
+
paymentRequestId?: string;
|
|
1125
|
+
acquiringOrderId?: string;
|
|
1126
|
+
merchantId?: string;
|
|
1127
|
+
captureRequestedAt?: string;
|
|
1128
|
+
captureAmount: string;
|
|
1103
1129
|
[key: string]: unknown;
|
|
1104
1130
|
}
|
|
1105
1131
|
/**
|
|
1106
|
-
*
|
|
1132
|
+
* Capture order response data.
|
|
1107
1133
|
*/
|
|
1108
|
-
interface
|
|
1109
|
-
|
|
1110
|
-
|
|
1134
|
+
interface CaptureOrderData {
|
|
1135
|
+
paymentRequestId?: string;
|
|
1136
|
+
merchantOrderId?: string;
|
|
1137
|
+
acquiringOrderId?: string;
|
|
1138
|
+
orderStatus?: OrderStatus;
|
|
1139
|
+
compensateSuccess?: boolean;
|
|
1111
1140
|
[key: string]: unknown;
|
|
1112
1141
|
}
|
|
1113
1142
|
/**
|
|
1114
|
-
*
|
|
1143
|
+
* Order status enum.
|
|
1115
1144
|
*/
|
|
1116
|
-
|
|
1117
|
-
eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
|
|
1118
|
-
result?: SubscriptionNotificationResult;
|
|
1119
|
-
[key: string]: unknown;
|
|
1120
|
-
}
|
|
1145
|
+
type OrderStatus = 'PAY_IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'AUTHED_WAITING_CAPTURE' | 'PAY_SUCCESS' | 'ORDER_CLOSE' | 'CAPTURE_IN_PROGRESS';
|
|
1121
1146
|
/**
|
|
1122
|
-
*
|
|
1147
|
+
* Refund status enum.
|
|
1123
1148
|
*/
|
|
1124
|
-
|
|
1125
|
-
eventType: 'SUBSCRIPTION_CHANGE_NOTIFICATION';
|
|
1126
|
-
result?: SubscriptionChangeNotificationResult;
|
|
1127
|
-
[key: string]: unknown;
|
|
1128
|
-
}
|
|
1129
|
-
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
1130
|
-
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
1131
|
-
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
1132
|
-
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
1133
|
-
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
1134
|
-
type SubscriptionChangeHandler = (notification: SubscriptionChangeNotification) => void | Promise<void>;
|
|
1149
|
+
type RefundStatus$1 = 'REFUND_IN_PROGRESS' | 'ORDER_PARTIALLY_REFUNDED' | 'ORDER_FULLY_REFUNDED' | 'ORDER_REFUND_FAILED';
|
|
1135
1150
|
/**
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* @example
|
|
1139
|
-
* ```typescript
|
|
1140
|
-
* // Setup handler
|
|
1141
|
-
* const handler = waffo.webhook()
|
|
1142
|
-
* .onPayment((notification) => {
|
|
1143
|
-
* console.log('Payment:', notification.result?.orderStatus);
|
|
1144
|
-
* })
|
|
1145
|
-
* .onRefund((notification) => {
|
|
1146
|
-
* console.log('Refund:', notification.result?.refundStatus);
|
|
1147
|
-
* });
|
|
1148
|
-
*
|
|
1149
|
-
* // Process webhook (e.g., in Express.js)
|
|
1150
|
-
* app.post('/webhook', async (req, res) => {
|
|
1151
|
-
* const body = req.body.toString();
|
|
1152
|
-
* const signature = req.headers['x-signature'];
|
|
1153
|
-
* const result = await handler.handleWebhook(body, signature);
|
|
1154
|
-
*
|
|
1155
|
-
* res.setHeader('X-SIGNATURE', result.responseSignature);
|
|
1156
|
-
* res.status(200).send(result.responseBody);
|
|
1157
|
-
* });
|
|
1158
|
-
* ```
|
|
1151
|
+
* User information.
|
|
1159
1152
|
*/
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
* Registers a handler for payment notifications.
|
|
1173
|
-
*/
|
|
1174
|
-
onPayment(handler: PaymentHandler): this;
|
|
1175
|
-
/**
|
|
1176
|
-
* Registers a handler for refund notifications.
|
|
1177
|
-
*/
|
|
1178
|
-
onRefund(handler: RefundHandler): this;
|
|
1179
|
-
/**
|
|
1180
|
-
* Registers a handler for subscription status notifications.
|
|
1181
|
-
*/
|
|
1182
|
-
onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
|
|
1183
|
-
/**
|
|
1184
|
-
* Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
|
|
1185
|
-
* Only called when onSubscriptionStatus handler is not registered.
|
|
1186
|
-
*/
|
|
1187
|
-
onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
|
|
1188
|
-
/**
|
|
1189
|
-
* Registers a handler for subscription period changed notifications.
|
|
1190
|
-
*/
|
|
1191
|
-
onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
|
|
1192
|
-
/**
|
|
1193
|
-
* Registers a handler for subscription change notifications.
|
|
1194
|
-
*/
|
|
1195
|
-
onSubscriptionChange(handler: SubscriptionChangeHandler): this;
|
|
1196
|
-
/**
|
|
1197
|
-
* Processes a webhook notification.
|
|
1198
|
-
*
|
|
1199
|
-
* @param body - The raw webhook body
|
|
1200
|
-
* @param signature - The X-SIGNATURE header value
|
|
1201
|
-
* @returns Result with response body and signature
|
|
1202
|
-
*/
|
|
1203
|
-
handleWebhook(body: string, signature: string): Promise<WebhookResult>;
|
|
1204
|
-
/**
|
|
1205
|
-
* Verifies a webhook signature.
|
|
1206
|
-
*
|
|
1207
|
-
* @param body - The raw webhook body
|
|
1208
|
-
* @param signature - The X-SIGNATURE header value
|
|
1209
|
-
* @returns true if signature is valid
|
|
1210
|
-
*/
|
|
1211
|
-
verifySignature(body: string, signature: string): boolean;
|
|
1212
|
-
/**
|
|
1213
|
-
* Builds a success response with signature.
|
|
1214
|
-
*/
|
|
1215
|
-
buildSuccessResponse(): {
|
|
1216
|
-
body: string;
|
|
1217
|
-
signature: string;
|
|
1218
|
-
};
|
|
1153
|
+
interface UserInfo {
|
|
1154
|
+
userId: string;
|
|
1155
|
+
userEmail: string;
|
|
1156
|
+
userPhone?: string;
|
|
1157
|
+
userFirstName?: string;
|
|
1158
|
+
userLastName?: string;
|
|
1159
|
+
userCreatedAt?: string;
|
|
1160
|
+
userTerminal?: string;
|
|
1161
|
+
userCountryCode?: string;
|
|
1162
|
+
userBrowserIp?: string;
|
|
1163
|
+
userAgent?: string;
|
|
1219
1164
|
/**
|
|
1220
|
-
*
|
|
1165
|
+
* User receipt URL (max 256 characters).
|
|
1221
1166
|
*/
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
signature: string;
|
|
1225
|
-
};
|
|
1226
|
-
private createSuccessResult;
|
|
1227
|
-
private createFailedResult;
|
|
1167
|
+
userReceiptUrl?: string;
|
|
1168
|
+
[key: string]: unknown;
|
|
1228
1169
|
}
|
|
1229
|
-
|
|
1230
1170
|
/**
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
* All API responses are wrapped in this class for consistent handling.
|
|
1234
|
-
*
|
|
1235
|
-
* @example
|
|
1236
|
-
* ```typescript
|
|
1237
|
-
* const response = await waffo.order().create(params);
|
|
1238
|
-
*
|
|
1239
|
-
* if (response.isSuccess()) {
|
|
1240
|
-
* const data = response.getData();
|
|
1241
|
-
* console.log('Order ID:', data?.acquiringOrderId);
|
|
1242
|
-
* } else {
|
|
1243
|
-
* console.error(`Error [${response.code}]: ${response.getMessage()}`);
|
|
1244
|
-
* }
|
|
1245
|
-
* ```
|
|
1171
|
+
* Payment information.
|
|
1246
1172
|
*/
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
*
|
|
1264
|
-
* @param code - The error code
|
|
1265
|
-
* @param message - The error message
|
|
1266
|
-
*/
|
|
1267
|
-
static error<T>(code: string, message?: string): ApiResponse<T>;
|
|
1268
|
-
/**
|
|
1269
|
-
* Checks if the response indicates success.
|
|
1270
|
-
*
|
|
1271
|
-
* @returns true if the response code is "0"
|
|
1272
|
-
*/
|
|
1273
|
-
isSuccess(): boolean;
|
|
1274
|
-
/**
|
|
1275
|
-
* Gets the response data.
|
|
1276
|
-
*
|
|
1277
|
-
* @returns The response data, or undefined if the response is an error
|
|
1278
|
-
*/
|
|
1279
|
-
getData(): T | undefined;
|
|
1280
|
-
/**
|
|
1281
|
-
* Gets the error message.
|
|
1282
|
-
*
|
|
1283
|
-
* @returns The error message, or undefined if the response is successful
|
|
1284
|
-
*/
|
|
1285
|
-
getMessage(): string | undefined;
|
|
1286
|
-
/**
|
|
1287
|
-
* Gets the response code.
|
|
1288
|
-
*
|
|
1289
|
-
* @returns The response code
|
|
1290
|
-
*/
|
|
1291
|
-
getCode(): string;
|
|
1292
|
-
/**
|
|
1293
|
-
* Gets the response data or throws an error.
|
|
1294
|
-
*
|
|
1295
|
-
* @returns The response data
|
|
1296
|
-
* @throws Error if the response is not successful or data is undefined
|
|
1297
|
-
*/
|
|
1298
|
-
getDataOrThrow(): T;
|
|
1173
|
+
interface PaymentInfo {
|
|
1174
|
+
productName: string;
|
|
1175
|
+
payMethodType?: string;
|
|
1176
|
+
payMethodName?: string;
|
|
1177
|
+
payMethodProperties?: string;
|
|
1178
|
+
payMethodResponse?: string;
|
|
1179
|
+
userPaymentAccessToken?: string;
|
|
1180
|
+
payMethodUserAccountNo?: string;
|
|
1181
|
+
payMethodUserAccountType?: string;
|
|
1182
|
+
payOption?: string;
|
|
1183
|
+
cashierLanguage?: string;
|
|
1184
|
+
cashierAppearance?: string;
|
|
1185
|
+
payMethodCountry?: string;
|
|
1186
|
+
captureMode?: string;
|
|
1187
|
+
merchantInitiatedMode?: string;
|
|
1188
|
+
[key: string]: unknown;
|
|
1299
1189
|
}
|
|
1300
|
-
|
|
1301
1190
|
/**
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1304
|
-
* Handles:
|
|
1305
|
-
* - Request signing with merchant's private key
|
|
1306
|
-
* - Response signature verification with Waffo's public key
|
|
1307
|
-
* - MerchantId auto-injection
|
|
1308
|
-
* - Error handling and timeout management
|
|
1191
|
+
* Merchant information.
|
|
1309
1192
|
*/
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
private readonly waffoPublicKey;
|
|
1315
|
-
private readonly merchantId;
|
|
1316
|
-
private readonly connectTimeout;
|
|
1317
|
-
private readonly readTimeout;
|
|
1318
|
-
private readonly logger?;
|
|
1319
|
-
private readonly httpTransport;
|
|
1320
|
-
constructor(config: WaffoConfig);
|
|
1321
|
-
/**
|
|
1322
|
-
* Sends a POST request to the Waffo API.
|
|
1323
|
-
*
|
|
1324
|
-
* @param path - API endpoint path (e.g., "/order/create")
|
|
1325
|
-
* @param request - Request body
|
|
1326
|
-
* @param options - Per-request options
|
|
1327
|
-
* @returns API response
|
|
1328
|
-
* @throws WaffoUnknownStatusError for network errors or unknown status
|
|
1329
|
-
*/
|
|
1330
|
-
post<T extends object, R>(path: string, request: T, options?: RequestOptions): Promise<ApiResponse<R>>;
|
|
1331
|
-
/**
|
|
1332
|
-
* Parses the API response body.
|
|
1333
|
-
*/
|
|
1334
|
-
private parseResponse;
|
|
1335
|
-
/**
|
|
1336
|
-
* Auto-injects merchantId into the request if configured.
|
|
1337
|
-
*/
|
|
1338
|
-
private injectMerchantIdIfNeeded;
|
|
1339
|
-
/**
|
|
1340
|
-
* Checks if the error is a network-related error.
|
|
1341
|
-
*/
|
|
1342
|
-
private isNetworkError;
|
|
1193
|
+
interface MerchantInfo {
|
|
1194
|
+
merchantId: string;
|
|
1195
|
+
subMerchantId?: string;
|
|
1196
|
+
[key: string]: unknown;
|
|
1343
1197
|
}
|
|
1344
|
-
|
|
1345
1198
|
/**
|
|
1346
|
-
*
|
|
1199
|
+
* Goods information.
|
|
1347
1200
|
*/
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
protected getPath(endpoint: string): string;
|
|
1201
|
+
interface GoodsInfo {
|
|
1202
|
+
goodsId?: string;
|
|
1203
|
+
goodsName?: string;
|
|
1204
|
+
goodsCategory?: string;
|
|
1205
|
+
goodsUrl?: string;
|
|
1206
|
+
appName?: string;
|
|
1207
|
+
skuName?: string;
|
|
1208
|
+
goodsUniquePrice?: string;
|
|
1209
|
+
goodsQuantity?: number;
|
|
1210
|
+
[key: string]: unknown;
|
|
1359
1211
|
}
|
|
1360
|
-
|
|
1361
1212
|
/**
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1364
|
-
* Note: Full type definitions should be generated from openapi.json.
|
|
1365
|
-
* These are placeholder interfaces for the SDK structure.
|
|
1213
|
+
* Address information.
|
|
1366
1214
|
*/
|
|
1367
|
-
|
|
1215
|
+
interface AddressInfo {
|
|
1216
|
+
address?: string;
|
|
1217
|
+
city?: string;
|
|
1218
|
+
region?: string;
|
|
1219
|
+
postcode?: string;
|
|
1220
|
+
addressCountryCode?: string;
|
|
1221
|
+
[key: string]: unknown;
|
|
1222
|
+
}
|
|
1368
1223
|
/**
|
|
1369
|
-
*
|
|
1224
|
+
* Card information.
|
|
1370
1225
|
*/
|
|
1371
|
-
interface
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
userInfo: UserInfo;
|
|
1379
|
-
paymentInfo: PaymentInfo;
|
|
1380
|
-
merchantInfo?: MerchantInfo;
|
|
1381
|
-
goodsInfo?: GoodsInfo;
|
|
1382
|
-
addressInfo?: AddressInfo;
|
|
1383
|
-
cardInfo?: CardInfo;
|
|
1384
|
-
riskData?: RiskData;
|
|
1385
|
-
paymentTokenData?: PaymentTokenData;
|
|
1386
|
-
brandInfo?: BrandInfo;
|
|
1387
|
-
productDetail?: ProductDetail;
|
|
1388
|
-
acqOrderExtSubscriptionInfo?: AcqOrderExtSubscriptionInfo;
|
|
1389
|
-
channelId?: string;
|
|
1390
|
-
innerCardData?: WaffoTokenCardData;
|
|
1391
|
-
userCurrency?: string;
|
|
1392
|
-
successRedirectUrl?: string;
|
|
1393
|
-
failedRedirectUrl?: string;
|
|
1394
|
-
cancelRedirectUrl?: string;
|
|
1395
|
-
orderRequestedAt?: string;
|
|
1396
|
-
orderExpiredAt?: string;
|
|
1397
|
-
extendInfo?: string;
|
|
1226
|
+
interface CardInfo {
|
|
1227
|
+
cardNumber?: string;
|
|
1228
|
+
cardExpiryYear?: number;
|
|
1229
|
+
cardExpiryMonth?: number;
|
|
1230
|
+
cardCvv?: string;
|
|
1231
|
+
cardHolderName?: string;
|
|
1232
|
+
threeDsDecision?: string;
|
|
1398
1233
|
[key: string]: unknown;
|
|
1399
1234
|
}
|
|
1400
1235
|
/**
|
|
1401
|
-
*
|
|
1236
|
+
* Risk data.
|
|
1402
1237
|
*/
|
|
1403
|
-
interface
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1238
|
+
interface RiskData {
|
|
1239
|
+
userType?: string;
|
|
1240
|
+
userCategory?: string;
|
|
1241
|
+
userLegalName?: string;
|
|
1242
|
+
userDisplayName?: string;
|
|
1243
|
+
userRegistrationIp?: string;
|
|
1244
|
+
userLastSeenIp?: string;
|
|
1245
|
+
userIsNew?: string;
|
|
1246
|
+
userIsFirstPurchase?: string;
|
|
1409
1247
|
[key: string]: unknown;
|
|
1410
1248
|
}
|
|
1411
1249
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
* Provide paymentRequestId or acquiringOrderId.
|
|
1250
|
+
* Payment token data.
|
|
1414
1251
|
*/
|
|
1415
|
-
interface
|
|
1416
|
-
|
|
1417
|
-
acquiringOrderId?: string;
|
|
1252
|
+
interface PaymentTokenData {
|
|
1253
|
+
tokenId?: string;
|
|
1418
1254
|
[key: string]: unknown;
|
|
1419
1255
|
}
|
|
1420
1256
|
/**
|
|
1421
|
-
*
|
|
1257
|
+
* Brand display information for cashier.
|
|
1422
1258
|
*/
|
|
1423
|
-
interface
|
|
1259
|
+
interface BrandInfo {
|
|
1260
|
+
cashierLogoUrl?: string;
|
|
1261
|
+
cashierDisplayName?: string;
|
|
1262
|
+
cashierProductImageUrl?: string;
|
|
1263
|
+
[key: string]: unknown;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* @deprecated Legacy order extension retained for source compatibility.
|
|
1267
|
+
*/
|
|
1268
|
+
interface ProductDetail {
|
|
1269
|
+
subscriptionInfo?: SubscriptionInfo;
|
|
1270
|
+
[key: string]: unknown;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* @deprecated Legacy subscription extension retained for source compatibility.
|
|
1274
|
+
*/
|
|
1275
|
+
interface AcqOrderExtSubscriptionInfo {
|
|
1276
|
+
subscriptionId?: string;
|
|
1277
|
+
periodNo?: number;
|
|
1278
|
+
merchantRequest?: string;
|
|
1279
|
+
subscriptionEvent?: string;
|
|
1280
|
+
[key: string]: unknown;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* @deprecated Legacy tokenized card data retained for source compatibility.
|
|
1284
|
+
*/
|
|
1285
|
+
interface WaffoTokenCardData {
|
|
1286
|
+
cardBinDataList?: Record<string, unknown>[];
|
|
1287
|
+
maskedCardInfo?: string;
|
|
1288
|
+
cardBin?: string;
|
|
1289
|
+
cardExpiry?: string;
|
|
1290
|
+
[key: string]: unknown;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* x402 stablecoin payment information.
|
|
1294
|
+
*/
|
|
1295
|
+
interface X402Info {
|
|
1296
|
+
x402Request?: boolean;
|
|
1297
|
+
paymentSignatureHeader?: string;
|
|
1298
|
+
x402Response?: string;
|
|
1299
|
+
[key: string]: unknown;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Promotion information for an order.
|
|
1303
|
+
*/
|
|
1304
|
+
interface PromotionInfo {
|
|
1305
|
+
promotionCode?: string;
|
|
1306
|
+
couponId?: string;
|
|
1307
|
+
[key: string]: unknown;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Refund user information.
|
|
1311
|
+
*/
|
|
1312
|
+
interface RefundUserInfo {
|
|
1313
|
+
userType?: string;
|
|
1314
|
+
userFirstName?: string;
|
|
1315
|
+
userMiddleName?: string;
|
|
1316
|
+
userLastName?: string;
|
|
1317
|
+
nationality?: string;
|
|
1318
|
+
userEmail?: string;
|
|
1319
|
+
userPhone?: string;
|
|
1320
|
+
userBirthDay?: string;
|
|
1321
|
+
userIDType?: string;
|
|
1322
|
+
userIDNumber?: string;
|
|
1323
|
+
userIDIssueDate?: string;
|
|
1324
|
+
userIDExpiryDate?: string;
|
|
1325
|
+
userBankInfo?: RefundUserBankInfo;
|
|
1326
|
+
[key: string]: unknown;
|
|
1327
|
+
}
|
|
1328
|
+
interface RefundUserBankInfo {
|
|
1329
|
+
bankAccountNo?: string;
|
|
1330
|
+
bankCode?: string;
|
|
1331
|
+
bankName?: string;
|
|
1332
|
+
bankCity?: string;
|
|
1333
|
+
bankBranch?: string;
|
|
1334
|
+
[key: string]: unknown;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* Webhook event types sent by Waffo.
|
|
1339
|
+
*/
|
|
1340
|
+
declare enum WebhookEventType {
|
|
1341
|
+
PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
|
|
1342
|
+
REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
|
|
1343
|
+
SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
|
|
1344
|
+
SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION",
|
|
1345
|
+
SUBSCRIPTION_CHANGE_NOTIFICATION = "SUBSCRIPTION_CHANGE_NOTIFICATION"
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Result of webhook handling.
|
|
1349
|
+
*/
|
|
1350
|
+
interface WebhookResult {
|
|
1351
|
+
/** Whether the webhook was processed successfully */
|
|
1352
|
+
success: boolean;
|
|
1353
|
+
/** Response body to send back to Waffo */
|
|
1354
|
+
responseBody: string;
|
|
1355
|
+
/** Signature for the response body */
|
|
1356
|
+
responseSignature: string;
|
|
1357
|
+
/** Error message if processing failed */
|
|
1358
|
+
error?: string;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Base notification interface.
|
|
1362
|
+
*/
|
|
1363
|
+
interface BaseNotification {
|
|
1364
|
+
eventType: string;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Payment notification result payload (21 fields).
|
|
1368
|
+
*/
|
|
1369
|
+
interface PaymentNotificationResult {
|
|
1424
1370
|
paymentRequestId?: string;
|
|
1425
1371
|
merchantOrderId?: string;
|
|
1426
1372
|
acquiringOrderId?: string;
|
|
1427
|
-
orderStatus?:
|
|
1373
|
+
orderStatus?: string;
|
|
1428
1374
|
orderAction?: string;
|
|
1429
1375
|
orderCurrency?: string;
|
|
1430
1376
|
orderAmount?: string;
|
|
1377
|
+
userCurrency?: string;
|
|
1431
1378
|
finalDealAmount?: string;
|
|
1432
1379
|
orderDescription?: string;
|
|
1433
|
-
merchantInfo?:
|
|
1434
|
-
userInfo?:
|
|
1435
|
-
goodsInfo?:
|
|
1436
|
-
|
|
1437
|
-
|
|
1380
|
+
merchantInfo?: Record<string, unknown>;
|
|
1381
|
+
userInfo?: Record<string, unknown>;
|
|
1382
|
+
goodsInfo?: Record<string, unknown>;
|
|
1383
|
+
addressInfo?: Record<string, unknown>;
|
|
1384
|
+
paymentInfo?: Record<string, unknown>;
|
|
1438
1385
|
orderRequestedAt?: string;
|
|
1439
1386
|
orderExpiredAt?: string;
|
|
1440
1387
|
orderUpdatedAt?: string;
|
|
1441
1388
|
orderCompletedAt?: string;
|
|
1442
|
-
|
|
1443
|
-
* Refund expiry time (ISO 8601 format).
|
|
1444
|
-
*/
|
|
1445
|
-
refundExpiryAt?: string;
|
|
1446
|
-
orderFailedReason?: string;
|
|
1389
|
+
orderFailedReason?: Record<string, unknown>;
|
|
1447
1390
|
extendInfo?: string;
|
|
1448
|
-
userCurrency?: string;
|
|
1449
1391
|
/**
|
|
1450
1392
|
* The associated subscription info.
|
|
1451
1393
|
*/
|
|
1452
|
-
subscriptionInfo?: SubscriptionInfo;
|
|
1453
|
-
/**
|
|
1454
|
-
*
|
|
1455
|
-
*/
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
merchantId?: string;
|
|
1466
|
-
orderRequestedAt?: string;
|
|
1467
|
-
[key: string]: unknown;
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Cancel order response data.
|
|
1471
|
-
*/
|
|
1472
|
-
interface CancelOrderData {
|
|
1473
|
-
paymentRequestId?: string;
|
|
1474
|
-
merchantOrderId?: string;
|
|
1475
|
-
acquiringOrderId?: string;
|
|
1476
|
-
orderStatus?: OrderStatus;
|
|
1477
|
-
[key: string]: unknown;
|
|
1478
|
-
}
|
|
1479
|
-
/**
|
|
1480
|
-
* Refund order request parameters.
|
|
1481
|
-
*/
|
|
1482
|
-
interface RefundOrderParams {
|
|
1483
|
-
refundRequestId: string;
|
|
1484
|
-
acquiringOrderId: string;
|
|
1485
|
-
merchantId?: string;
|
|
1486
|
-
merchantRefundOrderId?: string;
|
|
1487
|
-
refundAmount: string;
|
|
1488
|
-
refundReason: string;
|
|
1489
|
-
requestedAt?: string;
|
|
1490
|
-
refundNotifyUrl?: string;
|
|
1491
|
-
userInfo?: RefundUserInfo;
|
|
1492
|
-
extendInfo?: string;
|
|
1493
|
-
refundSource?: string;
|
|
1394
|
+
subscriptionInfo?: SubscriptionInfo;
|
|
1395
|
+
/**
|
|
1396
|
+
* Refund expiry time (ISO 8601 format).
|
|
1397
|
+
*/
|
|
1398
|
+
refundExpiryAt?: string;
|
|
1399
|
+
/**
|
|
1400
|
+
* The address of the merchant page to redirect to when user cancels the payment.
|
|
1401
|
+
*/
|
|
1402
|
+
cancelRedirectUrl?: string;
|
|
1403
|
+
/**
|
|
1404
|
+
* x402 stablecoin payment information.
|
|
1405
|
+
*/
|
|
1406
|
+
x402Info?: X402Info;
|
|
1494
1407
|
[key: string]: unknown;
|
|
1495
1408
|
}
|
|
1496
1409
|
/**
|
|
1497
|
-
* Refund
|
|
1410
|
+
* Refund notification result payload (17 fields).
|
|
1498
1411
|
*/
|
|
1499
|
-
interface
|
|
1412
|
+
interface RefundNotificationResult {
|
|
1500
1413
|
refundRequestId?: string;
|
|
1501
1414
|
merchantRefundOrderId?: string;
|
|
1502
1415
|
acquiringOrderId?: string;
|
|
1503
1416
|
acquiringRefundOrderId?: string;
|
|
1417
|
+
origPaymentRequestId?: string;
|
|
1504
1418
|
refundAmount?: string;
|
|
1505
|
-
refundStatus?:
|
|
1419
|
+
refundStatus?: string;
|
|
1506
1420
|
remainingRefundAmount?: string;
|
|
1421
|
+
userCurrency?: string;
|
|
1422
|
+
finalDealAmount?: string;
|
|
1423
|
+
refundReason?: string;
|
|
1424
|
+
refundRequestedAt?: string;
|
|
1425
|
+
refundUpdatedAt?: string;
|
|
1426
|
+
refundCompletedAt?: string;
|
|
1427
|
+
refundFailedReason?: Record<string, unknown>;
|
|
1428
|
+
userInfo?: Record<string, unknown>;
|
|
1429
|
+
extendInfo?: string;
|
|
1430
|
+
/**
|
|
1431
|
+
* Refund source. Possible values: MERCHANT, RDR, ETHOCA.
|
|
1432
|
+
*/
|
|
1507
1433
|
refundSource?: string;
|
|
1508
1434
|
[key: string]: unknown;
|
|
1509
1435
|
}
|
|
1510
1436
|
/**
|
|
1511
|
-
*
|
|
1512
|
-
|
|
1513
|
-
interface CaptureOrderParams {
|
|
1514
|
-
paymentRequestId?: string;
|
|
1515
|
-
acquiringOrderId?: string;
|
|
1516
|
-
merchantId?: string;
|
|
1517
|
-
captureRequestedAt?: string;
|
|
1518
|
-
captureAmount: string;
|
|
1519
|
-
[key: string]: unknown;
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* Capture order response data.
|
|
1523
|
-
*/
|
|
1524
|
-
interface CaptureOrderData {
|
|
1525
|
-
paymentRequestId?: string;
|
|
1526
|
-
merchantOrderId?: string;
|
|
1527
|
-
acquiringOrderId?: string;
|
|
1528
|
-
orderStatus?: OrderStatus;
|
|
1529
|
-
[key: string]: unknown;
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Order status enum.
|
|
1533
|
-
*/
|
|
1534
|
-
type OrderStatus = 'PAY_IN_PROGRESS' | 'AUTHORIZATION_REQUIRED' | 'AUTHED_WAITING_CAPTURE' | 'PAY_SUCCESS' | 'ORDER_CLOSE' | 'CAPTURE_IN_PROGRESS';
|
|
1535
|
-
/**
|
|
1536
|
-
* Refund status enum.
|
|
1537
|
-
*/
|
|
1538
|
-
type RefundStatus$1 = 'REFUND_IN_PROGRESS' | 'ORDER_PARTIALLY_REFUNDED' | 'ORDER_FULLY_REFUNDED' | 'ORDER_REFUND_FAILED';
|
|
1539
|
-
/**
|
|
1540
|
-
* User information.
|
|
1437
|
+
* Subscription notification result payload (20 fields).
|
|
1438
|
+
* Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
|
|
1541
1439
|
*/
|
|
1542
|
-
interface
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
userFirstName?: string;
|
|
1547
|
-
userLastName?: string;
|
|
1548
|
-
userCreatedAt?: string;
|
|
1549
|
-
userTerminal?: string;
|
|
1550
|
-
userCountryCode?: string;
|
|
1551
|
-
userBrowserIp?: string;
|
|
1552
|
-
userAgent?: string;
|
|
1440
|
+
interface SubscriptionNotificationResult {
|
|
1441
|
+
subscriptionRequest?: string;
|
|
1442
|
+
merchantSubscriptionId?: string;
|
|
1443
|
+
subscriptionId?: string;
|
|
1553
1444
|
/**
|
|
1554
|
-
*
|
|
1445
|
+
* Payment method's subscription id.
|
|
1555
1446
|
*/
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
payMethodCountry?: string;
|
|
1575
|
-
captureMode?: string;
|
|
1576
|
-
merchantInitiatedMode?: string;
|
|
1577
|
-
[key: string]: unknown;
|
|
1578
|
-
}
|
|
1579
|
-
/**
|
|
1580
|
-
* Merchant information.
|
|
1581
|
-
*/
|
|
1582
|
-
interface MerchantInfo {
|
|
1583
|
-
merchantId: string;
|
|
1584
|
-
subMerchantId?: string;
|
|
1447
|
+
payMethodSubscriptionId?: string;
|
|
1448
|
+
subscriptionStatus?: string;
|
|
1449
|
+
subscriptionAction?: string;
|
|
1450
|
+
currency?: string;
|
|
1451
|
+
amount?: string;
|
|
1452
|
+
userCurrency?: string;
|
|
1453
|
+
productInfo?: Record<string, unknown>;
|
|
1454
|
+
merchantInfo?: Record<string, unknown>;
|
|
1455
|
+
userInfo?: Record<string, unknown>;
|
|
1456
|
+
goodsInfo?: Record<string, unknown>;
|
|
1457
|
+
addressInfo?: Record<string, unknown>;
|
|
1458
|
+
paymentInfo?: Record<string, unknown>;
|
|
1459
|
+
requestedAt?: string;
|
|
1460
|
+
updatedAt?: string;
|
|
1461
|
+
failedReason?: Record<string, unknown>;
|
|
1462
|
+
extendInfo?: string;
|
|
1463
|
+
subscriptionManagementUrl?: string;
|
|
1464
|
+
paymentDetails?: Record<string, unknown>[];
|
|
1585
1465
|
[key: string]: unknown;
|
|
1586
1466
|
}
|
|
1587
1467
|
/**
|
|
1588
|
-
*
|
|
1468
|
+
* Subscription change notification result payload.
|
|
1469
|
+
* Triggered when a subscription change (upgrade/downgrade) reaches final status (SUCCESS or CLOSED).
|
|
1589
1470
|
*/
|
|
1590
|
-
interface
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1471
|
+
interface SubscriptionChangeNotificationResult {
|
|
1472
|
+
subscriptionRequest?: string;
|
|
1473
|
+
originSubscriptionRequest?: string;
|
|
1474
|
+
merchantSubscriptionId?: string;
|
|
1475
|
+
subscriptionId?: string;
|
|
1476
|
+
/** Final status: SUCCESS or CLOSED */
|
|
1477
|
+
subscriptionChangeStatus?: string;
|
|
1478
|
+
subscriptionAction?: string;
|
|
1479
|
+
remainingAmount?: string;
|
|
1480
|
+
currency?: string;
|
|
1481
|
+
userCurrency?: string;
|
|
1482
|
+
requestedAt?: string;
|
|
1483
|
+
subscriptionManagementUrl?: string;
|
|
1484
|
+
extendInfo?: string;
|
|
1485
|
+
orderExpiredAt?: string;
|
|
1486
|
+
productInfoList?: Record<string, unknown>[];
|
|
1487
|
+
merchantInfo?: Record<string, unknown>;
|
|
1488
|
+
userInfo?: Record<string, unknown>;
|
|
1489
|
+
goodsInfo?: Record<string, unknown>;
|
|
1490
|
+
addressInfo?: Record<string, unknown>;
|
|
1491
|
+
paymentInfo?: Record<string, unknown>;
|
|
1599
1492
|
[key: string]: unknown;
|
|
1600
1493
|
}
|
|
1601
1494
|
/**
|
|
1602
|
-
*
|
|
1495
|
+
* Payment notification from Waffo.
|
|
1603
1496
|
*/
|
|
1604
|
-
interface
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
region?: string;
|
|
1608
|
-
postcode?: string;
|
|
1609
|
-
addressCountryCode?: string;
|
|
1497
|
+
interface PaymentNotification extends BaseNotification {
|
|
1498
|
+
eventType: 'PAYMENT_NOTIFICATION';
|
|
1499
|
+
result?: PaymentNotificationResult;
|
|
1610
1500
|
[key: string]: unknown;
|
|
1611
1501
|
}
|
|
1612
1502
|
/**
|
|
1613
|
-
*
|
|
1503
|
+
* Refund notification from Waffo.
|
|
1614
1504
|
*/
|
|
1615
|
-
interface
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
cardExpiryMonth?: number;
|
|
1619
|
-
cardCvv?: string;
|
|
1620
|
-
cardHolderName?: string;
|
|
1621
|
-
threeDsDecision?: string;
|
|
1505
|
+
interface RefundNotification extends BaseNotification {
|
|
1506
|
+
eventType: 'REFUND_NOTIFICATION';
|
|
1507
|
+
result?: RefundNotificationResult;
|
|
1622
1508
|
[key: string]: unknown;
|
|
1623
1509
|
}
|
|
1624
1510
|
/**
|
|
1625
|
-
*
|
|
1511
|
+
* Subscription status notification from Waffo.
|
|
1626
1512
|
*/
|
|
1627
|
-
interface
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
userLegalName?: string;
|
|
1631
|
-
userDisplayName?: string;
|
|
1632
|
-
userRegistrationIp?: string;
|
|
1633
|
-
userLastSeenIp?: string;
|
|
1634
|
-
userIsNew?: string;
|
|
1635
|
-
userIsFirstPurchase?: string;
|
|
1513
|
+
interface SubscriptionStatusNotification extends BaseNotification {
|
|
1514
|
+
eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
|
|
1515
|
+
result?: SubscriptionNotificationResult;
|
|
1636
1516
|
[key: string]: unknown;
|
|
1637
1517
|
}
|
|
1638
1518
|
/**
|
|
1639
|
-
*
|
|
1519
|
+
* Subscription period changed notification from Waffo.
|
|
1640
1520
|
*/
|
|
1641
|
-
interface
|
|
1642
|
-
|
|
1521
|
+
interface SubscriptionPeriodChangedNotification extends BaseNotification {
|
|
1522
|
+
eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
|
|
1523
|
+
result?: SubscriptionNotificationResult;
|
|
1643
1524
|
[key: string]: unknown;
|
|
1644
1525
|
}
|
|
1645
1526
|
/**
|
|
1646
|
-
*
|
|
1527
|
+
* Subscription change notification from Waffo.
|
|
1647
1528
|
*/
|
|
1648
|
-
interface
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
cashierProductImageUrl?: string;
|
|
1529
|
+
interface SubscriptionChangeNotification extends BaseNotification {
|
|
1530
|
+
eventType: 'SUBSCRIPTION_CHANGE_NOTIFICATION';
|
|
1531
|
+
result?: SubscriptionChangeNotificationResult;
|
|
1652
1532
|
[key: string]: unknown;
|
|
1653
1533
|
}
|
|
1534
|
+
type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
|
|
1535
|
+
type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
|
|
1536
|
+
type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
1537
|
+
type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
|
|
1538
|
+
type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
|
|
1539
|
+
type SubscriptionChangeHandler = (notification: SubscriptionChangeNotification) => void | Promise<void>;
|
|
1654
1540
|
/**
|
|
1655
|
-
*
|
|
1541
|
+
* Webhook handler for processing Waffo webhook notifications.
|
|
1542
|
+
*
|
|
1543
|
+
* @example
|
|
1544
|
+
* ```typescript
|
|
1545
|
+
* // Setup handler
|
|
1546
|
+
* const handler = waffo.webhook()
|
|
1547
|
+
* .onPayment((notification) => {
|
|
1548
|
+
* console.log('Payment:', notification.result?.orderStatus);
|
|
1549
|
+
* })
|
|
1550
|
+
* .onRefund((notification) => {
|
|
1551
|
+
* console.log('Refund:', notification.result?.refundStatus);
|
|
1552
|
+
* });
|
|
1553
|
+
*
|
|
1554
|
+
* // Process webhook (e.g., in Express.js)
|
|
1555
|
+
* app.post('/webhook', async (req, res) => {
|
|
1556
|
+
* const body = req.body.toString();
|
|
1557
|
+
* const signature = req.headers['x-signature'];
|
|
1558
|
+
* const result = await handler.handleWebhook(body, signature);
|
|
1559
|
+
*
|
|
1560
|
+
* res.setHeader('X-SIGNATURE', result.responseSignature);
|
|
1561
|
+
* res.status(200).send(result.responseBody);
|
|
1562
|
+
* });
|
|
1563
|
+
* ```
|
|
1656
1564
|
*/
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1565
|
+
declare class WebhookHandler {
|
|
1566
|
+
private readonly waffoPublicKey;
|
|
1567
|
+
private readonly privateKey;
|
|
1568
|
+
private readonly logger?;
|
|
1569
|
+
private paymentHandler?;
|
|
1570
|
+
private refundHandler?;
|
|
1571
|
+
private subscriptionStatusHandler?;
|
|
1572
|
+
private subscriptionPaymentHandler?;
|
|
1573
|
+
private subscriptionPeriodChangedHandler?;
|
|
1574
|
+
private subscriptionChangeHandler?;
|
|
1575
|
+
constructor(config: WaffoConfig);
|
|
1576
|
+
/**
|
|
1577
|
+
* Registers a handler for payment notifications.
|
|
1578
|
+
*/
|
|
1579
|
+
onPayment(handler: PaymentHandler): this;
|
|
1580
|
+
/**
|
|
1581
|
+
* Registers a handler for refund notifications.
|
|
1582
|
+
*/
|
|
1583
|
+
onRefund(handler: RefundHandler): this;
|
|
1584
|
+
/**
|
|
1585
|
+
* Registers a handler for subscription status notifications.
|
|
1586
|
+
*/
|
|
1587
|
+
onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
|
|
1588
|
+
/**
|
|
1589
|
+
* Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
|
|
1590
|
+
* Only called when onSubscriptionStatus handler is not registered.
|
|
1591
|
+
*/
|
|
1592
|
+
onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
|
|
1593
|
+
/**
|
|
1594
|
+
* Registers a handler for subscription period changed notifications.
|
|
1595
|
+
*/
|
|
1596
|
+
onSubscriptionPeriodChanged(handler: SubscriptionPeriodChangedHandler): this;
|
|
1597
|
+
/**
|
|
1598
|
+
* Registers a handler for subscription change notifications.
|
|
1599
|
+
*/
|
|
1600
|
+
onSubscriptionChange(handler: SubscriptionChangeHandler): this;
|
|
1601
|
+
/**
|
|
1602
|
+
* Processes a webhook notification.
|
|
1603
|
+
*
|
|
1604
|
+
* @param body - The raw webhook body
|
|
1605
|
+
* @param signature - The X-SIGNATURE header value
|
|
1606
|
+
* @returns Result with response body and signature
|
|
1607
|
+
*/
|
|
1608
|
+
handleWebhook(body: string, signature: string): Promise<WebhookResult>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Verifies a webhook signature.
|
|
1611
|
+
*
|
|
1612
|
+
* @param body - The raw webhook body
|
|
1613
|
+
* @param signature - The X-SIGNATURE header value
|
|
1614
|
+
* @returns true if signature is valid
|
|
1615
|
+
*/
|
|
1616
|
+
verifySignature(body: string, signature: string): boolean;
|
|
1617
|
+
/**
|
|
1618
|
+
* Builds a success response with signature.
|
|
1619
|
+
*/
|
|
1620
|
+
buildSuccessResponse(): {
|
|
1621
|
+
body: string;
|
|
1622
|
+
signature: string;
|
|
1623
|
+
};
|
|
1624
|
+
/**
|
|
1625
|
+
* Builds a failed response with signature.
|
|
1626
|
+
*/
|
|
1627
|
+
buildFailedResponse(_message: string): {
|
|
1628
|
+
body: string;
|
|
1629
|
+
signature: string;
|
|
1630
|
+
};
|
|
1631
|
+
private createSuccessResult;
|
|
1632
|
+
private createFailedResult;
|
|
1660
1633
|
}
|
|
1634
|
+
|
|
1661
1635
|
/**
|
|
1662
|
-
*
|
|
1636
|
+
* Generic API response wrapper.
|
|
1637
|
+
*
|
|
1638
|
+
* All API responses are wrapped in this class for consistent handling.
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* const response = await waffo.order().create(params);
|
|
1643
|
+
*
|
|
1644
|
+
* if (response.isSuccess()) {
|
|
1645
|
+
* const data = response.getData();
|
|
1646
|
+
* console.log('Order ID:', data?.acquiringOrderId);
|
|
1647
|
+
* } else {
|
|
1648
|
+
* console.error(`Error [${response.code}]: ${response.getMessage()}`);
|
|
1649
|
+
* }
|
|
1650
|
+
* ```
|
|
1663
1651
|
*/
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1652
|
+
declare class ApiResponse<T> {
|
|
1653
|
+
/** Response code. "0" indicates success, other values indicate errors. */
|
|
1654
|
+
readonly code: string;
|
|
1655
|
+
/** Response data (present when code is "0") */
|
|
1656
|
+
readonly data?: T;
|
|
1657
|
+
/** Error message (present when code is not "0") */
|
|
1658
|
+
readonly message?: string;
|
|
1659
|
+
private constructor();
|
|
1660
|
+
/**
|
|
1661
|
+
* Creates a successful response.
|
|
1662
|
+
*
|
|
1663
|
+
* @param data - The response data
|
|
1664
|
+
*/
|
|
1665
|
+
static success<T>(data?: T): ApiResponse<T>;
|
|
1666
|
+
/**
|
|
1667
|
+
* Creates an error response.
|
|
1668
|
+
*
|
|
1669
|
+
* @param code - The error code
|
|
1670
|
+
* @param message - The error message
|
|
1671
|
+
*/
|
|
1672
|
+
static error<T>(code: string, message?: string): ApiResponse<T>;
|
|
1673
|
+
/**
|
|
1674
|
+
* Checks if the response indicates success.
|
|
1675
|
+
*
|
|
1676
|
+
* @returns true if the response code is "0"
|
|
1677
|
+
*/
|
|
1678
|
+
isSuccess(): boolean;
|
|
1679
|
+
/**
|
|
1680
|
+
* Gets the response data.
|
|
1681
|
+
*
|
|
1682
|
+
* @returns The response data, or undefined if the response is an error
|
|
1683
|
+
*/
|
|
1684
|
+
getData(): T | undefined;
|
|
1685
|
+
/**
|
|
1686
|
+
* Gets the error message.
|
|
1687
|
+
*
|
|
1688
|
+
* @returns The error message, or undefined if the response is successful
|
|
1689
|
+
*/
|
|
1690
|
+
getMessage(): string | undefined;
|
|
1691
|
+
/**
|
|
1692
|
+
* Gets the response code.
|
|
1693
|
+
*
|
|
1694
|
+
* @returns The response code
|
|
1695
|
+
*/
|
|
1696
|
+
getCode(): string;
|
|
1697
|
+
/**
|
|
1698
|
+
* Gets the response data or throws an error.
|
|
1699
|
+
*
|
|
1700
|
+
* @returns The response data
|
|
1701
|
+
* @throws Error if the response is not successful or data is undefined
|
|
1702
|
+
*/
|
|
1703
|
+
getDataOrThrow(): T;
|
|
1670
1704
|
}
|
|
1705
|
+
|
|
1671
1706
|
/**
|
|
1672
|
-
*
|
|
1707
|
+
* HTTP client for making requests to the Waffo API.
|
|
1708
|
+
*
|
|
1709
|
+
* Handles:
|
|
1710
|
+
* - Request signing with merchant's private key
|
|
1711
|
+
* - Response signature verification with Waffo's public key
|
|
1712
|
+
* - MerchantId auto-injection
|
|
1713
|
+
* - Error handling and timeout management
|
|
1673
1714
|
*/
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1715
|
+
declare class WaffoHttpClient {
|
|
1716
|
+
private readonly baseUrl;
|
|
1717
|
+
private readonly apiKey;
|
|
1718
|
+
private readonly privateKey;
|
|
1719
|
+
private readonly waffoPublicKey;
|
|
1720
|
+
private readonly merchantId;
|
|
1721
|
+
private readonly connectTimeout;
|
|
1722
|
+
private readonly readTimeout;
|
|
1723
|
+
private readonly logger?;
|
|
1724
|
+
private readonly httpTransport;
|
|
1725
|
+
constructor(config: WaffoConfig);
|
|
1726
|
+
/**
|
|
1727
|
+
* Sends a POST request to the Waffo API.
|
|
1728
|
+
*
|
|
1729
|
+
* @param path - API endpoint path (e.g., "/order/create")
|
|
1730
|
+
* @param request - Request body
|
|
1731
|
+
* @param options - Per-request options
|
|
1732
|
+
* @returns API response
|
|
1733
|
+
* @throws WaffoUnknownStatusError for network errors or unknown status
|
|
1734
|
+
*/
|
|
1735
|
+
post<T extends object, R>(path: string, request: T, options?: RequestOptions): Promise<ApiResponse<R>>;
|
|
1736
|
+
/**
|
|
1737
|
+
* Parses the API response body.
|
|
1738
|
+
*/
|
|
1739
|
+
private parseResponse;
|
|
1740
|
+
/**
|
|
1741
|
+
* Auto-injects merchantId into the request if configured.
|
|
1742
|
+
*/
|
|
1743
|
+
private injectMerchantIdIfNeeded;
|
|
1744
|
+
/**
|
|
1745
|
+
* Checks if the error is a network-related error.
|
|
1746
|
+
*/
|
|
1747
|
+
private isNetworkError;
|
|
1680
1748
|
}
|
|
1749
|
+
|
|
1681
1750
|
/**
|
|
1682
|
-
*
|
|
1751
|
+
* Base class for API resources.
|
|
1683
1752
|
*/
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
userIDIssueDate?: string;
|
|
1696
|
-
userIDExpiryDate?: string;
|
|
1697
|
-
userBankInfo?: RefundUserBankInfo;
|
|
1698
|
-
[key: string]: unknown;
|
|
1699
|
-
}
|
|
1700
|
-
interface RefundUserBankInfo {
|
|
1701
|
-
bankAccountNo?: string;
|
|
1702
|
-
bankCode?: string;
|
|
1703
|
-
bankName?: string;
|
|
1704
|
-
bankCity?: string;
|
|
1705
|
-
bankBranch?: string;
|
|
1706
|
-
[key: string]: unknown;
|
|
1753
|
+
declare abstract class BaseResource {
|
|
1754
|
+
protected readonly httpClient: WaffoHttpClient;
|
|
1755
|
+
protected readonly basePath: string;
|
|
1756
|
+
constructor(httpClient: WaffoHttpClient, basePath: string);
|
|
1757
|
+
/**
|
|
1758
|
+
* Gets the full path for an endpoint.
|
|
1759
|
+
*
|
|
1760
|
+
* @param endpoint - The endpoint (e.g., "/create")
|
|
1761
|
+
* @returns Full path (e.g., "/order/create")
|
|
1762
|
+
*/
|
|
1763
|
+
protected getPath(endpoint: string): string;
|
|
1707
1764
|
}
|
|
1708
1765
|
|
|
1709
1766
|
/**
|
|
@@ -2145,6 +2202,69 @@ declare class PayMethodConfigResource extends BaseResource {
|
|
|
2145
2202
|
inquiry(params: InquiryPayMethodConfigParams, options?: RequestOptions): Promise<ApiResponse<InquiryPayMethodConfigData>>;
|
|
2146
2203
|
}
|
|
2147
2204
|
|
|
2205
|
+
/**
|
|
2206
|
+
* Wallet-related type definitions.
|
|
2207
|
+
*
|
|
2208
|
+
* Note: Full type definitions should be generated from openapi.json.
|
|
2209
|
+
* These are placeholder interfaces for the SDK structure.
|
|
2210
|
+
*/
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* Wallet inquiry request parameters (x402 stablecoin receiving-address inquiry).
|
|
2214
|
+
* Based on openapi.json WalletInquiryReq schema.
|
|
2215
|
+
*
|
|
2216
|
+
* Note: `merchantInfo` is auto-injected by the HTTP client before signing,
|
|
2217
|
+
* so it is optional in the public surface.
|
|
2218
|
+
*/
|
|
2219
|
+
interface WalletInquiryParams {
|
|
2220
|
+
paymentRequestId: string;
|
|
2221
|
+
merchantInfo?: MerchantInfo;
|
|
2222
|
+
orderCurrency: string;
|
|
2223
|
+
[key: string]: unknown;
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Wallet inquiry response data.
|
|
2227
|
+
* Based on openapi.json WalletInquiryResponse schema.
|
|
2228
|
+
*/
|
|
2229
|
+
interface WalletInquiryData {
|
|
2230
|
+
network?: string;
|
|
2231
|
+
asset?: string;
|
|
2232
|
+
payTo?: string;
|
|
2233
|
+
[key: string]: unknown;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
/**
|
|
2237
|
+
* Wallet resource for x402 stablecoin receiving-address inquiry.
|
|
2238
|
+
*
|
|
2239
|
+
* @example
|
|
2240
|
+
* ```typescript
|
|
2241
|
+
* // Inquire the stablecoin receiving address
|
|
2242
|
+
* const response = await waffo.wallet().inquiry({
|
|
2243
|
+
* paymentRequestId: 'unique-request-id',
|
|
2244
|
+
* orderCurrency: 'USDC',
|
|
2245
|
+
* });
|
|
2246
|
+
*
|
|
2247
|
+
* if (response.isSuccess()) {
|
|
2248
|
+
* const data = response.getData();
|
|
2249
|
+
* console.log('Network:', data?.network);
|
|
2250
|
+
* console.log('Asset:', data?.asset);
|
|
2251
|
+
* console.log('Pay to:', data?.payTo);
|
|
2252
|
+
* }
|
|
2253
|
+
* ```
|
|
2254
|
+
*/
|
|
2255
|
+
declare class WalletResource extends BaseResource {
|
|
2256
|
+
private static readonly PATH_INQUIRY;
|
|
2257
|
+
/**
|
|
2258
|
+
* Inquires the stablecoin receiving address for an x402 payment.
|
|
2259
|
+
*
|
|
2260
|
+
* @param params - Wallet inquiry parameters
|
|
2261
|
+
* @param options - Optional request options
|
|
2262
|
+
* @returns API response with wallet data
|
|
2263
|
+
* @throws WaffoUnknownStatusError for network errors
|
|
2264
|
+
*/
|
|
2265
|
+
inquiry(params: WalletInquiryParams, options?: RequestOptions): Promise<ApiResponse<WalletInquiryData>>;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2148
2268
|
/**
|
|
2149
2269
|
* Main entry point for the Waffo SDK.
|
|
2150
2270
|
*
|
|
@@ -2193,6 +2313,7 @@ declare class Waffo {
|
|
|
2193
2313
|
private _refund?;
|
|
2194
2314
|
private _merchantConfig?;
|
|
2195
2315
|
private _payMethodConfig?;
|
|
2316
|
+
private _wallet?;
|
|
2196
2317
|
/**
|
|
2197
2318
|
* Creates a new Waffo SDK instance.
|
|
2198
2319
|
*
|
|
@@ -2246,6 +2367,12 @@ declare class Waffo {
|
|
|
2246
2367
|
* @returns Pay method config resource
|
|
2247
2368
|
*/
|
|
2248
2369
|
payMethodConfig(): PayMethodConfigResource;
|
|
2370
|
+
/**
|
|
2371
|
+
* Returns the wallet resource for x402 stablecoin receiving-address inquiry.
|
|
2372
|
+
*
|
|
2373
|
+
* @returns Wallet resource
|
|
2374
|
+
*/
|
|
2375
|
+
wallet(): WalletResource;
|
|
2249
2376
|
/**
|
|
2250
2377
|
* Creates a webhook handler for processing Waffo webhook notifications.
|
|
2251
2378
|
*
|
|
@@ -2481,4 +2608,4 @@ declare const RsaUtils: {
|
|
|
2481
2608
|
generateKeyPair: typeof generateKeyPair;
|
|
2482
2609
|
};
|
|
2483
2610
|
|
|
2484
|
-
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 FixedMaintenanceRule, 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 PayMethodDetail, 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 SubscriptionChangeData, type SubscriptionChangeInquiryData, type SubscriptionChangeInquiryParams, type SubscriptionChangeParams, type SubscriptionChangeProductInfo, type SubscriptionChangeStatus, type SubscriptionInfo, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionNotificationResult, type SubscriptionPaymentDetail, type SubscriptionPaymentInfo, type SubscriptionPeriodChangedNotification, SubscriptionResource, type SubscriptionScheduledAmount, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUpdateProductInfo, type SubscriptionUserInfo, type UpdateSubscriptionData, type UpdateSubscriptionParams, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, WebhookEventType, WebhookHandler, type WebhookResult };
|
|
2611
|
+
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 FixedMaintenanceRule, 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 PayMethodDetail, type PayMethodInfo, type PaymentInfo, type PaymentNotification, type PaymentNotificationResult, type PeriodType, type ProductInfo, type PromotionInfo, type RefundNotification, type RefundNotificationResult, type RefundOrderData, type RefundOrderParams, RefundResource, type RefundStatus$1 as RefundStatus, type RefundUserInfo, type RequestOptions, type RiskData, RsaUtils, type SubscriptionChangeData, type SubscriptionChangeInquiryData, type SubscriptionChangeInquiryParams, type SubscriptionChangeParams, type SubscriptionChangeProductInfo, type SubscriptionChangeStatus, type SubscriptionInfo, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionNotificationResult, type SubscriptionPaymentDetail, type SubscriptionPaymentInfo, type SubscriptionPeriodChangedNotification, type SubscriptionPromotionInfo, SubscriptionResource, type SubscriptionScheduledAmount, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUpdateProductInfo, type SubscriptionUserInfo, type UpdateSubscriptionData, type UpdateSubscriptionParams, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, type WalletInquiryData, type WalletInquiryParams, WalletResource, WebhookEventType, WebhookHandler, type WebhookResult, type X402Info };
|