@seaverse/payment-sdk 0.7.0 → 0.8.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/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * - monthly: Monthly credits (expires 30 days after last grant)
10
10
  * - permanent: Permanent credits (never expires)
11
11
  */
12
- type CreditPoolType = 'daily' | 'event' | 'monthly' | 'permanent';
12
+ type CreditPoolType$1 = 'daily' | 'event' | 'monthly' | 'permanent';
13
13
  /**
14
14
  * Single credit pool detail
15
15
  */
@@ -17,7 +17,7 @@ interface CreditPoolDetail {
17
17
  /**
18
18
  * Pool type
19
19
  */
20
- type: CreditPoolType;
20
+ type: CreditPoolType$1;
21
21
  /**
22
22
  * Balance in this pool (decimal string for precision)
23
23
  */
@@ -32,7 +32,7 @@ interface CreditPoolDetail {
32
32
  /**
33
33
  * Credit detail response data
34
34
  */
35
- interface CreditDetailResponse {
35
+ interface CreditDetailResponse$1 {
36
36
  /**
37
37
  * Total balance across all pools
38
38
  */
@@ -48,7 +48,7 @@ interface CreditDetailResponse {
48
48
  interface CreditDetailSuccessResponse {
49
49
  code: 0;
50
50
  message: string;
51
- data: CreditDetailResponse;
51
+ data: CreditDetailResponse$1;
52
52
  }
53
53
  /**
54
54
  * Credit account model
@@ -249,7 +249,7 @@ declare class PaymentClient {
249
249
  * });
250
250
  * ```
251
251
  */
252
- getCreditDetail(): Promise<CreditDetailResponse>;
252
+ getCreditDetail(): Promise<CreditDetailResponse$1>;
253
253
  /**
254
254
  * Get authenticated user's credit account information
255
255
  *
@@ -445,6 +445,8 @@ interface CheckoutOptions extends BaseCheckoutOptions {
445
445
  interface SubscribeOptions extends CheckoutOptions {
446
446
  /** 计费周期(可选,"month" 或 "year",默认 "month") */
447
447
  billing_period?: BillingPeriod;
448
+ /** 购买类型:1-一次性,2-订阅(必填) */
449
+ purchaseType: PurchaseType;
448
450
  }
449
451
  /**
450
452
  * 显示支付弹窗选项
@@ -1030,6 +1032,1377 @@ declare const BIZ_CODE: {
1030
1032
  readonly INVALID_ORDER_STATUS: 4006;
1031
1033
  };
1032
1034
 
1035
+ /**
1036
+ * SeaartPayment Types
1037
+ * SeaartPaymentComponent SDK 相关类型定义
1038
+ */
1039
+ declare global {
1040
+ interface Window {
1041
+ SeaartPaymentComponent: SeaartPaymentComponentSDK;
1042
+ }
1043
+ }
1044
+ /**
1045
+ * SeaartPaymentComponent SDK 接口
1046
+ */
1047
+ interface SeaartPaymentComponentSDK {
1048
+ /**
1049
+ * 初始化 SDK
1050
+ */
1051
+ init(config: {
1052
+ client_id: string;
1053
+ language?: string;
1054
+ }): Promise<void>;
1055
+ /**
1056
+ * 获取支付方式列表
1057
+ */
1058
+ getPaymentMethodList(params: {
1059
+ country_code: string;
1060
+ business_type: number;
1061
+ }): Promise<PaymentMethodListResponse>;
1062
+ /**
1063
+ * 创建支付实例
1064
+ */
1065
+ createPayment(params: {
1066
+ sys_order_id: string;
1067
+ account_token?: string;
1068
+ }): SeaartPaymentInstance;
1069
+ }
1070
+ /**
1071
+ * 支付实例接口
1072
+ */
1073
+ interface SeaartPaymentInstance {
1074
+ /**
1075
+ * 获取订单信息
1076
+ */
1077
+ getOrderInfo(): Promise<OrderInfoResponse>;
1078
+ /**
1079
+ * 创建 Link 支付
1080
+ */
1081
+ createLink(paymentMethod: PaymentMethod, options: {
1082
+ callback_url: string;
1083
+ }): SeaartLinkPayment;
1084
+ /**
1085
+ * 创建 Dropin 支付
1086
+ */
1087
+ createDropin(paymentMethod: PaymentMethod, callbacks: DropinCallbacks): SeaartDropinPayment;
1088
+ /**
1089
+ * 创建 BindCard 支付
1090
+ */
1091
+ createBindCard(paymentMethod: PaymentMethod, callbacks: BindCardCallbacks): SeaartBindCardPayment;
1092
+ }
1093
+ /**
1094
+ * Link 支付接口
1095
+ */
1096
+ interface SeaartLinkPayment {
1097
+ /**
1098
+ * 创建订单并获取支付链接
1099
+ */
1100
+ createOrder(): Promise<{
1101
+ data: {
1102
+ payment_url: string;
1103
+ transaction_id: string;
1104
+ };
1105
+ }>;
1106
+ }
1107
+ /**
1108
+ * Dropin 支付接口
1109
+ */
1110
+ interface SeaartDropinPayment {
1111
+ /**
1112
+ * 渲染支付组件到指定容器
1113
+ */
1114
+ render(selector: string): Promise<void>;
1115
+ /**
1116
+ * 销毁支付组件
1117
+ */
1118
+ destroy(): void;
1119
+ }
1120
+ /**
1121
+ * BindCard 支付接口
1122
+ */
1123
+ interface SeaartBindCardPayment {
1124
+ /**
1125
+ * 获取用户已绑定的卡列表
1126
+ */
1127
+ getCardList(): Promise<BindCardListResponse>;
1128
+ /**
1129
+ * 使用已绑定的卡创建订单
1130
+ */
1131
+ createOrder(instrumentId: string): Promise<void>;
1132
+ }
1133
+ /**
1134
+ * Dropin 回调集合
1135
+ */
1136
+ interface DropinCallbacks {
1137
+ onSubmit?: (payload: any) => void;
1138
+ onError?: (payload: any, error: any) => void;
1139
+ onCreateOrder?: (payload: any) => void;
1140
+ onCompleted?: (payload: any) => void;
1141
+ onFailed?: (payload: any) => void;
1142
+ onLoading?: (loading: boolean) => void;
1143
+ }
1144
+ /**
1145
+ * BindCard 回调集合
1146
+ */
1147
+ interface BindCardCallbacks {
1148
+ onCompleted?: (payload: any) => void;
1149
+ onFailed?: (payload: any) => void;
1150
+ }
1151
+ /**
1152
+ * 支付方式列表响应
1153
+ */
1154
+ interface PaymentMethodListResponse {
1155
+ err: number;
1156
+ message?: string;
1157
+ data?: {
1158
+ payment_method_list: PaymentMethod[];
1159
+ };
1160
+ }
1161
+ /**
1162
+ * 订单信息响应
1163
+ */
1164
+ interface OrderInfoResponse {
1165
+ err: number;
1166
+ message?: string;
1167
+ data?: {
1168
+ order_info: OrderInfo;
1169
+ };
1170
+ }
1171
+ /**
1172
+ * 已绑卡列表响应
1173
+ */
1174
+ interface BindCardListResponse {
1175
+ err: number;
1176
+ message?: string;
1177
+ data?: {
1178
+ user_bind_info_list: BindCard[];
1179
+ };
1180
+ }
1181
+ /**
1182
+ * SDK 配置
1183
+ */
1184
+ interface SeaartPaymentSDKConfig {
1185
+ /** 脚本 URL */
1186
+ scriptUrl: string;
1187
+ /** 客户端 ID */
1188
+ clientId: string;
1189
+ /** 语言 */
1190
+ language?: string;
1191
+ /** 脚本加载超时(毫秒) */
1192
+ scriptTimeout?: number;
1193
+ /** CSS 样式表 URL(可选) */
1194
+ cssUrl?: string;
1195
+ }
1196
+ /**
1197
+ * 支付方式
1198
+ */
1199
+ interface PaymentMethod {
1200
+ /** 渠道方支付id */
1201
+ channel_pay_id: string;
1202
+ /** 支付渠道名称 */
1203
+ payment_channel_name: string;
1204
+ /** 支付渠道 1-adyen 2-paypal 3-v5pay 5-wallet */
1205
+ payment_channel_type: number;
1206
+ /** 支付方式图标 */
1207
+ payment_method_icon: string;
1208
+ /** 支付方式id */
1209
+ payment_method_id: string;
1210
+ /** 支付方式名称 */
1211
+ payment_method_name: string;
1212
+ /** 支付类型 1:link 2:dropin */
1213
+ payment_type: 1 | 2;
1214
+ /** 支付方式类型 */
1215
+ payment_method_type: string;
1216
+ }
1217
+ /**
1218
+ * 支付方式查询参数
1219
+ */
1220
+ interface PaymentMethodsParams {
1221
+ /** 国家/地区代码 */
1222
+ country_code: string;
1223
+ /** 业务类型:1-一次性购买,2-订阅 */
1224
+ business_type: 1 | 2;
1225
+ }
1226
+ /**
1227
+ * 订单信息
1228
+ */
1229
+ interface OrderInfo {
1230
+ /** 平台订单号 */
1231
+ sys_order_id?: string;
1232
+ /** 订单状态 1=>待支付,2=>已支付 */
1233
+ order_status?: number;
1234
+ /** 订单剩余时间(秒) */
1235
+ expire_time: number;
1236
+ /** 语言码 */
1237
+ language_code?: string;
1238
+ /** 国家码 */
1239
+ country_code?: string;
1240
+ /** 接入方订单id */
1241
+ cp_order_id?: string;
1242
+ /** 币种 */
1243
+ currency?: string;
1244
+ /** 三方平台订单id */
1245
+ flow_id?: string;
1246
+ /** 包名 */
1247
+ package_name?: string;
1248
+ /** 支付类型,1-一次性购买,2-订阅 */
1249
+ pay_type?: number;
1250
+ /** 应付价格 */
1251
+ price?: number;
1252
+ /** 商品id */
1253
+ product_id?: string;
1254
+ /** 商品名称 */
1255
+ product_name?: string;
1256
+ /** 购买数量 */
1257
+ quantity?: string;
1258
+ /** 应付价格 */
1259
+ mark_price?: number;
1260
+ }
1261
+ /**
1262
+ * Link 支付参数
1263
+ */
1264
+ interface LinkPaymentOptions {
1265
+ /** 回调 URL */
1266
+ callback_url: string;
1267
+ }
1268
+ /**
1269
+ * Dropin 支付参数
1270
+ */
1271
+ interface DropinPaymentOptions {
1272
+ /** 容器 ID(CSS 选择器) */
1273
+ containerId: string;
1274
+ /** 用户提交支付表单时触发 */
1275
+ onSubmit?: (payload: any) => void;
1276
+ /** 创建支付组件过程中发生错误时触发 */
1277
+ onError?: (payload: any, error: any) => void;
1278
+ /** 创建支付订单时触发 */
1279
+ onCreateOrder?: (payload: any) => void;
1280
+ /** 支付成功完成时触发 */
1281
+ onCompleted?: (payload: any) => void;
1282
+ /** 支付失败时触发 */
1283
+ onFailed?: (payload: any) => void;
1284
+ /** 加载状态变化时触发 */
1285
+ onLoading?: (loading: boolean) => void;
1286
+ }
1287
+ /**
1288
+ * BindCard 支付参数
1289
+ */
1290
+ interface BindCardPaymentOptions {
1291
+ /** 支付完成回调 */
1292
+ onCompleted?: (payload: any) => void;
1293
+ /** 支付失败回调 */
1294
+ onFailed?: (payload: any) => void;
1295
+ }
1296
+ /**
1297
+ * 已绑定的卡信息
1298
+ */
1299
+ interface BindCard {
1300
+ /** 卡号(掩码) */
1301
+ card_no?: string;
1302
+ /** 支付渠道 1-adyen 2-paypal 3-v5pay 4-payermax */
1303
+ channel_type?: number;
1304
+ /** 用户支付方式记录唯一id */
1305
+ instrument_id?: string;
1306
+ /** 最后使用时间 */
1307
+ last_use_at?: number;
1308
+ /** 支付方式类型 */
1309
+ payment_method_type?: string;
1310
+ /** 支付方式卡品牌 */
1311
+ stored_payment_method_type?: string;
1312
+ /** 用户ID */
1313
+ user_id?: string;
1314
+ /** 用户类型 1-identify_id 2-cp_account_id */
1315
+ user_type?: number;
1316
+ }
1317
+ /**
1318
+ * Generic package interface that supports all package types
1319
+ */
1320
+ interface GenericPackage {
1321
+ /** Unique package ID */
1322
+ id: string;
1323
+ /** Display name */
1324
+ name: string;
1325
+ /** Price in USD (string for decimal precision) */
1326
+ price: string;
1327
+ /** Currency code */
1328
+ currency: string;
1329
+ /** Total credits */
1330
+ credits: string;
1331
+ /** Base credits (optional, for packages with bonus) */
1332
+ base_credits?: string;
1333
+ /** Bonus credits (optional) */
1334
+ bonus_credits?: string;
1335
+ /** Bonus percentage (e.g., 20 for +20%) */
1336
+ bonus_percentage?: number;
1337
+ /** Daily purchase limit (0 = unlimited) */
1338
+ day_limit?: number;
1339
+ /** Lifetime purchase limit (0 = unlimited) */
1340
+ lifetime_limit?: number;
1341
+ /** Package type for categorization */
1342
+ package_type?: 'iceBreaker' | 'emergency' | 'firstCharge' | 'custom';
1343
+ }
1344
+
1345
+ /**
1346
+ * LinkPaymentComponent
1347
+ * Link 支付组件(跳转支付)- payment_type = 1
1348
+ */
1349
+
1350
+ declare class LinkPaymentComponent {
1351
+ private paymentInstance;
1352
+ private orderId;
1353
+ private accountToken?;
1354
+ private paymentMethod;
1355
+ private callbackUrl;
1356
+ private linkPayment;
1357
+ constructor(params: {
1358
+ paymentInstance: SeaartPaymentInstance;
1359
+ orderId: string;
1360
+ accountToken?: string;
1361
+ paymentMethod: PaymentMethod;
1362
+ callbackUrl: string;
1363
+ });
1364
+ /**
1365
+ * 创建订单并获取支付链接
1366
+ */
1367
+ createOrder(): Promise<{
1368
+ data: {
1369
+ payment_url: string;
1370
+ transaction_id: string;
1371
+ };
1372
+ }>;
1373
+ /**
1374
+ * 跳转到支付页面(当前窗口)
1375
+ */
1376
+ redirectToPayment(): Promise<void>;
1377
+ /**
1378
+ * 新窗口打开支付页面
1379
+ */
1380
+ openPayment(windowFeatures?: string): Promise<Window | null>;
1381
+ }
1382
+
1383
+ /**
1384
+ * DropinPaymentComponent
1385
+ * Dropin 支付组件(嵌入式支付)- payment_type = 2
1386
+ */
1387
+
1388
+ declare class DropinPaymentComponent {
1389
+ private paymentInstance;
1390
+ private orderId;
1391
+ private accountToken?;
1392
+ private paymentMethod;
1393
+ private containerId;
1394
+ private callbacks;
1395
+ private dropinPayment;
1396
+ private rendered;
1397
+ constructor(params: {
1398
+ paymentInstance: SeaartPaymentInstance;
1399
+ orderId: string;
1400
+ accountToken?: string;
1401
+ paymentMethod: PaymentMethod;
1402
+ } & DropinPaymentOptions);
1403
+ /**
1404
+ * 渲染支付组件到容器
1405
+ */
1406
+ render(): Promise<void>;
1407
+ /**
1408
+ * 销毁组件
1409
+ */
1410
+ destroy(): void;
1411
+ }
1412
+
1413
+ /**
1414
+ * BindCardPaymentComponent
1415
+ * BindCard 支付组件(已绑定卡片支付)
1416
+ */
1417
+
1418
+ declare class BindCardPaymentComponent {
1419
+ private paymentInstance;
1420
+ private orderId;
1421
+ private paymentMethod;
1422
+ private callbacks;
1423
+ private bindCardPayment;
1424
+ constructor(params: {
1425
+ paymentInstance: SeaartPaymentInstance;
1426
+ orderId: string;
1427
+ accountToken?: string;
1428
+ paymentMethod: PaymentMethod;
1429
+ } & BindCardPaymentOptions);
1430
+ /**
1431
+ * 获取用户已绑定的卡列表
1432
+ */
1433
+ getCardList(): Promise<BindCard[]>;
1434
+ /**
1435
+ * 使用已绑定的卡创建订单
1436
+ */
1437
+ createOrder(instrumentId: string): Promise<void>;
1438
+ }
1439
+
1440
+ /**
1441
+ * OrderPayment
1442
+ * 订单支付实例 - 为每个订单创建独立的支付实例
1443
+ */
1444
+
1445
+ declare class OrderPayment {
1446
+ private paymentInstance;
1447
+ private orderId;
1448
+ private accountToken?;
1449
+ constructor(params: {
1450
+ paymentInstance: SeaartPaymentInstance;
1451
+ orderId: string;
1452
+ accountToken?: string;
1453
+ });
1454
+ /**
1455
+ * 获取订单信息
1456
+ */
1457
+ getOrderInfo(): Promise<OrderInfo>;
1458
+ /**
1459
+ * 创建 Link 支付组件(按需加载)
1460
+ * 适用于 payment_type = 1
1461
+ */
1462
+ createLinkPayment(paymentMethod: PaymentMethod, options: LinkPaymentOptions): LinkPaymentComponent;
1463
+ /**
1464
+ * 创建 Dropin 支付组件(按需加载)
1465
+ * 适用于 payment_type = 2
1466
+ */
1467
+ createDropinPayment(paymentMethod: PaymentMethod, options: DropinPaymentOptions): DropinPaymentComponent;
1468
+ /**
1469
+ * 创建 BindCard 支付组件(按需加载)
1470
+ * 适用于 payment_type = 2 且支持绑卡的支付方式
1471
+ */
1472
+ createBindCardPayment(paymentMethod: PaymentMethod, options: BindCardPaymentOptions): BindCardPaymentComponent;
1473
+ }
1474
+
1475
+ /**
1476
+ * PaymentModal - 原生 JavaScript 支付弹框组件
1477
+ * 提供类似 next-meta 的 BaseModal 体验,但使用纯 JavaScript 实现
1478
+ * 支持 Dropin 支付模式的嵌入式展示
1479
+ */
1480
+ interface PaymentModalOptions {
1481
+ /** 弹框标题 */
1482
+ title?: string;
1483
+ /** 是否显示关闭按钮 */
1484
+ showCloseButton?: boolean;
1485
+ /** 点击遮罩层是否关闭 */
1486
+ closeOnOverlayClick?: boolean;
1487
+ /** ESC 键是否关闭 */
1488
+ closeOnEsc?: boolean;
1489
+ /** 关闭回调 */
1490
+ onClose?: () => void;
1491
+ /** 自定义类名 */
1492
+ className?: string;
1493
+ /** 弹框宽度(默认: 480px) */
1494
+ maxWidth?: string;
1495
+ }
1496
+ declare class PaymentModal {
1497
+ private overlay;
1498
+ private modal;
1499
+ private contentContainer;
1500
+ private isOpen;
1501
+ private isExiting;
1502
+ private options;
1503
+ private escHandler;
1504
+ private savedScrollY;
1505
+ private savedScrollbarWidth;
1506
+ constructor(options?: PaymentModalOptions);
1507
+ /**
1508
+ * 打开弹框
1509
+ */
1510
+ open(): void;
1511
+ /**
1512
+ * 关闭弹框
1513
+ */
1514
+ close(): void;
1515
+ /**
1516
+ * 设置弹框内容
1517
+ */
1518
+ setContent(content: HTMLElement | string): void;
1519
+ /**
1520
+ * 获取内容容器
1521
+ */
1522
+ getContentContainer(): HTMLElement | null;
1523
+ /**
1524
+ * 销毁弹框
1525
+ */
1526
+ private destroy;
1527
+ /**
1528
+ * 创建弹框元素
1529
+ */
1530
+ private createModal;
1531
+ /**
1532
+ * 注入动画样式
1533
+ */
1534
+ private injectStyles;
1535
+ /**
1536
+ * 锁定 body 滚动
1537
+ */
1538
+ private lockBodyScroll;
1539
+ /**
1540
+ * 解锁 body 滚动
1541
+ */
1542
+ private unlockBodyScroll;
1543
+ /**
1544
+ * 检查弹框是否打开
1545
+ */
1546
+ isModalOpen(): boolean;
1547
+ }
1548
+
1549
+ /**
1550
+ * DropinPaymentModal - Dropin 支付弹框
1551
+ * 封装 DropinPaymentComponent 并在弹框中展示
1552
+ */
1553
+
1554
+ interface DropinPaymentModalOptions extends Omit<DropinPaymentOptions, 'containerId'> {
1555
+ /** 弹框标题 */
1556
+ modalTitle?: string;
1557
+ /** 弹框选项 */
1558
+ modalOptions?: Omit<PaymentModalOptions, 'title'>;
1559
+ }
1560
+ declare class DropinPaymentModal {
1561
+ private paymentInstance;
1562
+ private orderId;
1563
+ private accountToken;
1564
+ private paymentMethod;
1565
+ private options;
1566
+ private modal;
1567
+ private dropinPayment;
1568
+ private containerElement;
1569
+ constructor(paymentInstance: SeaartPaymentInstance, orderId: string, accountToken: string | undefined, paymentMethod: PaymentMethod, options: DropinPaymentModalOptions);
1570
+ /**
1571
+ * 打开弹框并渲染支付组件
1572
+ */
1573
+ open(): Promise<void>;
1574
+ /**
1575
+ * 关闭弹框
1576
+ */
1577
+ close(): void;
1578
+ /**
1579
+ * 清理资源
1580
+ */
1581
+ private cleanup;
1582
+ /**
1583
+ * 显示加载状态
1584
+ */
1585
+ private showLoading;
1586
+ /**
1587
+ * 隐藏加载状态
1588
+ */
1589
+ private hideLoading;
1590
+ /**
1591
+ * 检查弹框是否打开
1592
+ */
1593
+ isOpen(): boolean;
1594
+ }
1595
+
1596
+ /**
1597
+ * SeaartPaymentSDK
1598
+ * 基于 SeaartPaymentComponent 的支付 SDK 封装
1599
+ *
1600
+ * 核心职责:
1601
+ * 1. 动态加载 SeaartPaymentComponent 脚本
1602
+ * 2. 全局初始化(仅一次)
1603
+ * 3. 获取支付方式列表
1604
+ * 4. 创建订单支付实例
1605
+ */
1606
+
1607
+ declare class SeaartPaymentSDK {
1608
+ private static instance;
1609
+ private initialized;
1610
+ private config;
1611
+ /**
1612
+ * 私有构造函数(单例模式)
1613
+ */
1614
+ private constructor();
1615
+ /**
1616
+ * 获取 SDK 单例
1617
+ */
1618
+ static getInstance(): SeaartPaymentSDK;
1619
+ /**
1620
+ * 全局初始化(应用启动时调用一次)
1621
+ */
1622
+ init(config: SeaartPaymentSDKConfig): Promise<void>;
1623
+ /**
1624
+ * 获取支付方式列表
1625
+ */
1626
+ getPaymentMethods(params: PaymentMethodsParams): Promise<PaymentMethod[]>;
1627
+ /**
1628
+ * 创建订单支付实例
1629
+ */
1630
+ createOrderPayment(params: {
1631
+ orderId: string;
1632
+ accountToken?: string;
1633
+ }): OrderPayment;
1634
+ /**
1635
+ * 创建 Dropin 支付弹框(快捷方法)
1636
+ * 在弹框中直接展示 Dropin 支付组件
1637
+ */
1638
+ createDropinPaymentModal(params: {
1639
+ orderId: string;
1640
+ accountToken?: string;
1641
+ paymentMethod: PaymentMethod;
1642
+ } & DropinPaymentModalOptions): DropinPaymentModal;
1643
+ /**
1644
+ * 处理支付回调(在回调页面调用)
1645
+ * @param params 回调参数
1646
+ * @param apiHost Payment API 地址
1647
+ * @param authToken 认证 Token
1648
+ */
1649
+ handleCallback(params: {
1650
+ type: 'subscription' | 'creditpack' | 'change_subscription';
1651
+ }, apiHost: string, authToken?: string): Promise<{
1652
+ success: boolean;
1653
+ status: string;
1654
+ data?: any;
1655
+ }>;
1656
+ /**
1657
+ * 确保 SDK 已初始化
1658
+ */
1659
+ private ensureInitialized;
1660
+ /**
1661
+ * 获取当前配置(用于组件访问)
1662
+ */
1663
+ getConfig(): SeaartPaymentSDKConfig | null;
1664
+ /**
1665
+ * 销毁 SDK(测试用)
1666
+ */
1667
+ destroy(): void;
1668
+ }
1669
+
1670
+ /**
1671
+ * 共享类型定义
1672
+ * Shared types for CreditPackageModal and GenericPackageModal
1673
+ */
1674
+ /** 环境类型 */
1675
+ type Environment = 'development' | 'production';
1676
+ /** 环境配置接口 */
1677
+ interface EnvironmentConfig {
1678
+ /** SDK 脚本 URL */
1679
+ scriptUrl: string;
1680
+ /** 客户端 ID */
1681
+ clientId: string;
1682
+ /** 订单 API 地址 */
1683
+ orderApiUrl: string;
1684
+ /** 钱包 API 地址 */
1685
+ walletApiUrl: string;
1686
+ /** CSS 文件 URL */
1687
+ cssUrl: string;
1688
+ }
1689
+ /**
1690
+ * SDK 配置选项 - 简化版(支持环境变量)
1691
+ * 用户只需提供 environment、countryCode、accountToken 三个核心参数
1692
+ * SDK 会自动根据 environment 选择对应的配置
1693
+ */
1694
+ interface PaymentSDKConfig {
1695
+ /** 环境变量(development/production) - SDK 自动选择对应配置 */
1696
+ environment: Environment;
1697
+ /** 国家/地区代码 */
1698
+ countryCode: string;
1699
+ /** 账户 Token(用于用户认证) */
1700
+ accountToken?: string;
1701
+ /** 业务类型:1-一次性,2-订阅(可选,默认为 1) */
1702
+ businessType?: 1 | 2;
1703
+ /** 脚本加载超时(毫秒,默认 10000ms) */
1704
+ scriptTimeout?: number;
1705
+ /** 支付方式类型过滤(可选,默认 'dropin') */
1706
+ paymentMethodType?: string;
1707
+ /** 自定义脚本 URL(覆盖环境配置) */
1708
+ scriptUrl?: string;
1709
+ /** 自定义客户端 ID(覆盖环境配置) */
1710
+ clientId?: string;
1711
+ /** 自定义订单 API 地址(覆盖环境配置) */
1712
+ orderApiUrl?: string;
1713
+ /** 自定义 CSS URL(覆盖环境配置) */
1714
+ cssUrl?: string;
1715
+ }
1716
+
1717
+ /**
1718
+ * CreditPackageModal - 积分套餐选择弹框
1719
+ * 展示不同的积分套餐供用户选择
1720
+ */
1721
+
1722
+ interface CreditPackageModalOptions {
1723
+ /** SDK 配置(必填 - 用于自动初始化支付 SDK) */
1724
+ sdkConfig: PaymentSDKConfig;
1725
+ /** 语言(默认 'en') */
1726
+ language?: 'en' | 'zh-CN';
1727
+ /** 弹框标题 */
1728
+ title?: string;
1729
+ /** 弹框标题(中文) */
1730
+ title_cn?: string;
1731
+ /** 副标题 */
1732
+ subtitle?: string;
1733
+ /** 副标题(中文) */
1734
+ subtitle_cn?: string;
1735
+ /**
1736
+ * 支付成功回调 - 弹框内部完成支付后通知使用方
1737
+ * @param orderId 订单ID
1738
+ * @param transactionId 交易ID
1739
+ */
1740
+ onPaymentSuccess?: (orderId: string, transactionId: string) => void;
1741
+ /**
1742
+ * 支付失败回调
1743
+ * @param error 错误信息
1744
+ */
1745
+ onPaymentFailed?: (error: Error) => void;
1746
+ /** 弹框关闭回调 */
1747
+ onClose?: () => void;
1748
+ paymentMethod?: PaymentMethod;
1749
+ accountToken?: string;
1750
+ }
1751
+ declare class CreditPackageModal {
1752
+ private modal;
1753
+ private options;
1754
+ private language;
1755
+ private resizeHandler;
1756
+ private isInitializingSDK;
1757
+ private sdkInitialized;
1758
+ private readonly SPACING;
1759
+ private readonly COLORS;
1760
+ constructor(options: CreditPackageModalOptions);
1761
+ /**
1762
+ * 打开弹框
1763
+ */
1764
+ open(): Promise<void>;
1765
+ /**
1766
+ * 等待 SDK 初始化完成(支持超时和重试)
1767
+ * @param timeout 超时时间(毫秒),默认 30 秒
1768
+ * @param maxRetries 最大重试次数,默认 1 次
1769
+ * @returns 是否初始化成功
1770
+ */
1771
+ private waitForSDKInitialization;
1772
+ /**
1773
+ * 初始化支付SDK(后台静默执行)
1774
+ */
1775
+ private initializeSDK;
1776
+ /**
1777
+ * 关闭弹框
1778
+ */
1779
+ close(): void;
1780
+ /**
1781
+ * 获取响应式样式配置
1782
+ */
1783
+ private getResponsiveStyles;
1784
+ /**
1785
+ * 渲染弹框内容
1786
+ */
1787
+ private renderContent;
1788
+ /**
1789
+ * 渲染套餐卡片
1790
+ */
1791
+ private renderPackageCard;
1792
+ /**
1793
+ * 格式化数字(添加逗号)
1794
+ */
1795
+ private formatNumber;
1796
+ /**
1797
+ * 获取加载按钮的 HTML(带旋转动画)
1798
+ * @param text 加载文本
1799
+ * @param isPopular 是否为 Popular 套餐(用于调整颜色)
1800
+ */
1801
+ private getLoadingButtonHTML;
1802
+ /**
1803
+ * 添加事件监听
1804
+ */
1805
+ private attachEventListeners;
1806
+ /**
1807
+ * 处理支付流程
1808
+ */
1809
+ private handlePaymentFlow;
1810
+ /**
1811
+ * 打开支付弹框
1812
+ */
1813
+ private openPaymentModal;
1814
+ /**
1815
+ * 清理资源
1816
+ */
1817
+ private cleanup;
1818
+ /**
1819
+ * 检查弹框是否打开
1820
+ */
1821
+ isOpen(): boolean;
1822
+ }
1823
+
1824
+ /**
1825
+ * GenericPackageModal - 通用套餐选择弹框
1826
+ * 支持多种套餐类型(破冰包、告急包、首充包等)
1827
+ * 套餐数据从外部配置传入,无硬编码
1828
+ */
1829
+
1830
+ interface GenericPackageModalOptions {
1831
+ /** 套餐数据(必填 - 从外部配置传入) */
1832
+ packages: GenericPackage[];
1833
+ /** SDK 配置(必填 - 用于自动初始化支付 SDK) */
1834
+ sdkConfig: PaymentSDKConfig;
1835
+ /** 语言(默认 'en') */
1836
+ language?: 'en' | 'zh-CN';
1837
+ /**
1838
+ * 支付成功回调 - 弹框内部完成支付后通知使用方
1839
+ * @param orderId 订单ID
1840
+ * @param transactionId 交易ID
1841
+ * @param pkg 购买的套餐
1842
+ */
1843
+ onPaymentSuccess?: (orderId: string, transactionId: string, pkg: GenericPackage) => void;
1844
+ /**
1845
+ * 支付失败回调
1846
+ * @param error 错误信息
1847
+ * @param pkg 购买失败的套餐
1848
+ */
1849
+ onPaymentFailed?: (error: Error, pkg: GenericPackage) => void;
1850
+ /** 弹框关闭回调 */
1851
+ onClose?: () => void;
1852
+ }
1853
+ declare class GenericPackageModal {
1854
+ private modal;
1855
+ private options;
1856
+ private language;
1857
+ private resizeHandler;
1858
+ private isInitializingSDK;
1859
+ private sdkInitialized;
1860
+ private paymentMethod?;
1861
+ private accountToken?;
1862
+ constructor(options: GenericPackageModalOptions);
1863
+ /**
1864
+ * 打开弹框
1865
+ */
1866
+ open(): Promise<void>;
1867
+ /**
1868
+ * 等待 SDK 初始化完成(支持超时和重试)
1869
+ * @param timeout 超时时间(毫秒),默认 30 秒
1870
+ * @param maxRetries 最大重试次数,默认 1 次
1871
+ * @returns 是否初始化成功
1872
+ */
1873
+ private waitForSDKInitialization;
1874
+ /**
1875
+ * 初始化支付SDK(后台静默执行)
1876
+ */
1877
+ private initializeSDK;
1878
+ /**
1879
+ * 关闭弹框
1880
+ */
1881
+ close(): void;
1882
+ /**
1883
+ * 渲染弹框内容
1884
+ */
1885
+ private renderContent;
1886
+ /**
1887
+ * 渲染套餐卡片
1888
+ */
1889
+ private renderPackageCard;
1890
+ /**
1891
+ * 格式化数字(添加逗号)
1892
+ */
1893
+ private formatNumber;
1894
+ /**
1895
+ * 获取加载按钮的 HTML(带旋转动画)
1896
+ */
1897
+ private getLoadingButtonHTML;
1898
+ /**
1899
+ * 添加事件监听
1900
+ */
1901
+ private attachEventListeners;
1902
+ /**
1903
+ * 处理支付流程
1904
+ */
1905
+ private handlePaymentFlow;
1906
+ /**
1907
+ * 打开支付弹框
1908
+ */
1909
+ private openPaymentModal;
1910
+ /**
1911
+ * 清理资源
1912
+ */
1913
+ private cleanup;
1914
+ /**
1915
+ * 检查弹框是否打开
1916
+ */
1917
+ isOpen(): boolean;
1918
+ }
1919
+
1920
+ /**
1921
+ * 积分套餐数据
1922
+ */
1923
+ interface CreditPackage {
1924
+ id: string;
1925
+ name: string;
1926
+ price: string;
1927
+ currency: string;
1928
+ base_credits: string;
1929
+ bonus_credits: string;
1930
+ credits: string;
1931
+ day_limit: number;
1932
+ is_popular?: boolean;
1933
+ }
1934
+ declare const CREDIT_PACKAGES: CreditPackage[];
1935
+ /**
1936
+ * 创作力量类型和对应的积分消耗
1937
+ */
1938
+ interface CreativePowerType {
1939
+ icon: string;
1940
+ name: string;
1941
+ name_cn: string;
1942
+ credits_range: string;
1943
+ description: string;
1944
+ description_cn: string;
1945
+ }
1946
+ declare const CREATIVE_POWER_TYPES: CreativePowerType[];
1947
+
1948
+ /**
1949
+ * 共享配置文件
1950
+ * Shared configuration for CreditPackageModal and GenericPackageModal
1951
+ */
1952
+
1953
+ /**
1954
+ * 环境配置映射表
1955
+ * SDK 根据 environment 参数自动选择对应的配置
1956
+ */
1957
+ declare const ENVIRONMENT_CONFIGS: Record<Environment, EnvironmentConfig>;
1958
+ /**
1959
+ * 响应式断点配置
1960
+ * Responsive breakpoints for grid layout
1961
+ */
1962
+ declare const RESPONSIVE_BREAKPOINTS: {
1963
+ readonly mobile: 768;
1964
+ readonly tablet: 1200;
1965
+ readonly laptop: 1400;
1966
+ readonly desktop: number;
1967
+ };
1968
+ /**
1969
+ * 网格列数配置
1970
+ * Grid columns for different screen sizes
1971
+ */
1972
+ declare const GRID_COLUMNS: {
1973
+ readonly mobile: 1;
1974
+ readonly tablet: 2;
1975
+ readonly laptop: 2;
1976
+ readonly desktop: 4;
1977
+ };
1978
+ /**
1979
+ * SDK 初始化配置
1980
+ */
1981
+ declare const SDK_CONFIG: {
1982
+ /** 默认脚本加载超时 (毫秒) */
1983
+ readonly DEFAULT_SCRIPT_TIMEOUT: 10000;
1984
+ /** 默认 SDK 初始化超时 (毫秒) */
1985
+ readonly DEFAULT_INIT_TIMEOUT: 30000;
1986
+ /** 默认最大重试次数 */
1987
+ readonly DEFAULT_MAX_RETRIES: 1;
1988
+ /** 默认业务类型 (1=一次性购买, 2=订阅) */
1989
+ readonly DEFAULT_BUSINESS_TYPE: 1;
1990
+ };
1991
+
1992
+ /**
1993
+ * UI 反馈工具类
1994
+ * 提供统一的用户界面反馈(错误提示、加载状态等)
1995
+ */
1996
+ /**
1997
+ * 显示错误消息
1998
+ * 替代浏览器原生 alert(),提供更好的用户体验
1999
+ *
2000
+ * @param message 错误消息
2001
+ * @param duration 显示时长(毫秒),默认 3000ms
2002
+ */
2003
+ declare function showErrorMessage(message: string, duration?: number): void;
2004
+ /**
2005
+ * 显示成功消息
2006
+ *
2007
+ * @param message 成功消息
2008
+ * @param duration 显示时长(毫秒),默认 3000ms
2009
+ */
2010
+ declare function showSuccessMessage(message: string, duration?: number): void;
2011
+ /**
2012
+ * 显示加载指示器
2013
+ *
2014
+ * @param message 加载消息,默认 'Initializing...'
2015
+ * @returns 加载指示器的 HTML 元素(用于后续移除)
2016
+ */
2017
+ declare function showLoadingIndicator(message?: string): HTMLElement;
2018
+ /**
2019
+ * 移除加载指示器
2020
+ *
2021
+ * @param loader 加载指示器元素(可选)
2022
+ */
2023
+ declare function hideLoadingIndicator(loader?: HTMLElement | null): void;
2024
+ /**
2025
+ * 显示信息提示
2026
+ *
2027
+ * @param message 信息内容
2028
+ * @param duration 显示时长(毫秒),默认 3000ms
2029
+ */
2030
+ declare function showInfoMessage(message: string, duration?: number): void;
2031
+
2032
+ /**
2033
+ * PurchaseSuccessModal - 购买成功弹窗
2034
+ * 纯 JavaScript 实现,不依赖 React
2035
+ *
2036
+ * 参考设计: credit-pack-success-modal
2037
+ * - 邮件确认卡片风格
2038
+ * - 精美的动画效果(淡入淡出、缩放)
2039
+ * - 包含成功图标、套餐详情、积分数、支付金额
2040
+ */
2041
+ interface PurchaseSuccessData {
2042
+ /** 套餐名称 */
2043
+ packName: string;
2044
+ /** 积分数 */
2045
+ credits: number;
2046
+ /** 金额(例如: "0.49") */
2047
+ amount: string;
2048
+ /** 货币符号(例如: "$"),默认 "$" */
2049
+ currency?: string;
2050
+ /** 订单ID(可选) */
2051
+ orderId?: string;
2052
+ /** 交易ID(可选) */
2053
+ transactionId?: string;
2054
+ }
2055
+ interface PurchaseSuccessModalOptions {
2056
+ /** 购买成功数据 */
2057
+ data: PurchaseSuccessData;
2058
+ /** 语言,默认 'en' */
2059
+ language?: 'en' | 'zh-CN';
2060
+ /** 关闭回调 */
2061
+ onClose?: () => void;
2062
+ }
2063
+ /**
2064
+ * 购买成功弹窗类
2065
+ */
2066
+ declare class PurchaseSuccessModal {
2067
+ private overlay;
2068
+ private modal;
2069
+ private options;
2070
+ private isExiting;
2071
+ private scrollY;
2072
+ private boundHandleEscKey;
2073
+ constructor(options: PurchaseSuccessModalOptions);
2074
+ /**
2075
+ * 打开弹窗
2076
+ */
2077
+ open(): void;
2078
+ /**
2079
+ * 关闭弹窗
2080
+ */
2081
+ close(): void;
2082
+ /**
2083
+ * 创建弹窗元素
2084
+ */
2085
+ private createModal;
2086
+ /**
2087
+ * 生成弹窗 HTML
2088
+ */
2089
+ private getModalHTML;
2090
+ /**
2091
+ * 添加 CSS 动画
2092
+ */
2093
+ private addStyles;
2094
+ /**
2095
+ * 添加事件监听
2096
+ */
2097
+ private attachEventListeners;
2098
+ /**
2099
+ * 处理 ESC 键
2100
+ */
2101
+ private handleEscKey;
2102
+ /**
2103
+ * 清理资源
2104
+ */
2105
+ private cleanup;
2106
+ /**
2107
+ * HTML 转义工具函数
2108
+ * 防止 XSS 攻击
2109
+ */
2110
+ private escapeHtml;
2111
+ /**
2112
+ * 检查弹窗是否打开
2113
+ */
2114
+ isOpen(): boolean;
2115
+ }
2116
+
2117
+ /**
2118
+ * Payment Storage
2119
+ * 支付数据存储 - 统一管理 localStorage 操作
2120
+ */
2121
+ /**
2122
+ * 交易存储数据结构
2123
+ */
2124
+ interface TransactionStorageData {
2125
+ /** 交易 ID */
2126
+ transactionId: string;
2127
+ /** 订单 ID */
2128
+ orderId: string;
2129
+ /** 创建时间(毫秒时间戳) */
2130
+ createdAt: number;
2131
+ /** 过期时间(毫秒时间戳) */
2132
+ expiresAt: number;
2133
+ }
2134
+ declare class PaymentStorage {
2135
+ private static readonly KEY;
2136
+ /**
2137
+ * 保存交易数据
2138
+ */
2139
+ static saveTransaction(data: {
2140
+ transactionId: string;
2141
+ orderId: string;
2142
+ expiresIn: number;
2143
+ }): void;
2144
+ /**
2145
+ * 获取交易数据
2146
+ */
2147
+ static getTransaction(): TransactionStorageData | null;
2148
+ /**
2149
+ * 清除交易数据
2150
+ */
2151
+ static clearTransaction(): void;
2152
+ }
2153
+
2154
+ /**
2155
+ * Error Handler
2156
+ * 错误处理器 - 标准化错误和友好提示
2157
+ */
2158
+ /**
2159
+ * 支付错误类
2160
+ */
2161
+ declare class PaymentError extends Error {
2162
+ code: number;
2163
+ bizCode: number | undefined;
2164
+ constructor(code: number, bizCode: number | undefined, message: string);
2165
+ }
2166
+ declare class ErrorHandler {
2167
+ /**
2168
+ * 标准化错误
2169
+ */
2170
+ static normalize(error: any): PaymentError;
2171
+ /**
2172
+ * 根据错误码获取友好提示
2173
+ */
2174
+ static getFriendlyMessage(error: PaymentError): string;
2175
+ }
2176
+
2177
+ /**
2178
+ * Script Loader
2179
+ * 动态加载 SeaartPaymentComponent SDK 脚本
2180
+ */
2181
+ interface ScriptLoaderOptions {
2182
+ scriptUrl: string;
2183
+ timeout?: number;
2184
+ }
2185
+ declare class ScriptLoader {
2186
+ private static loadedScripts;
2187
+ /**
2188
+ * 动态加载 SeaartPaymentComponent SDK
2189
+ */
2190
+ static loadSeaartPaymentComponent(options: ScriptLoaderOptions): Promise<void>;
2191
+ /**
2192
+ * 等待 window.SeaartPaymentComponent 可用
2193
+ */
2194
+ private static waitForSeaartPaymentComponent;
2195
+ /**
2196
+ * 清除已加载的脚本记录(测试用)
2197
+ */
2198
+ static clearLoadedScripts(): void;
2199
+ }
2200
+ /**
2201
+ * Stylesheet Loader
2202
+ * 动态加载 CSS 样式表
2203
+ */
2204
+ declare class StylesheetLoader {
2205
+ /**
2206
+ * 已加载的样式表 URL 缓存
2207
+ */
2208
+ private static loadedStylesheets;
2209
+ /**
2210
+ * 加载支付组件样式表
2211
+ * @param url CSS 文件 URL
2212
+ * @returns Promise<void>
2213
+ */
2214
+ static loadPaymentStylesheet(url: string): Promise<void>;
2215
+ /**
2216
+ * 清除缓存(用于测试)
2217
+ */
2218
+ static clearCache(): void;
2219
+ }
2220
+
2221
+ /**
2222
+ * Subscription API
2223
+ * 订阅管理 - 查询、变更、重启订阅
2224
+ */
2225
+ /**
2226
+ * 当前订阅状态
2227
+ */
2228
+ interface CurrentSubscription {
2229
+ subscription_id: string;
2230
+ product_id: string;
2231
+ tier: string;
2232
+ billing_period: 'month' | 'year';
2233
+ status: string;
2234
+ cancel_at_period_end: boolean;
2235
+ current_period_end: number;
2236
+ }
2237
+ /**
2238
+ * 活跃订阅详情
2239
+ */
2240
+ interface ActiveSubscription {
2241
+ subscription_id: string;
2242
+ tier: number;
2243
+ billing_period: 'month' | 'year';
2244
+ price: string;
2245
+ currency: string;
2246
+ current_period_start: number;
2247
+ next_billing_date: number;
2248
+ status: string;
2249
+ cancel_at_period_end: boolean;
2250
+ can_cancel: boolean;
2251
+ }
2252
+ /**
2253
+ * 统一响应格式
2254
+ */
2255
+ interface UnifiedResponse<T = any> {
2256
+ code: number;
2257
+ msg: string;
2258
+ data: T | null;
2259
+ }
2260
+ /**
2261
+ * 创建订单响应
2262
+ */
2263
+ interface CreateOrderResponse {
2264
+ /** 订单 ID */
2265
+ order_id: string;
2266
+ /** 交易 ID */
2267
+ transaction_id: string;
2268
+ /** 价格 */
2269
+ price: string;
2270
+ /** 货币代码 */
2271
+ currency: string;
2272
+ /** 重定向 URL */
2273
+ redirect_url: string;
2274
+ /** SDK 配置 */
2275
+ sdk_config: SdkConfig;
2276
+ }
2277
+ /**
2278
+ * SDK 配置
2279
+ */
2280
+ interface SdkConfig {
2281
+ /** 应用 ID */
2282
+ app_id: string;
2283
+ /** API 域名 */
2284
+ api_host: string;
2285
+ /** 环境 */
2286
+ environment: string;
2287
+ }
2288
+ /**
2289
+ * 获取当前订阅状态(用于升降级判断)
2290
+ */
2291
+ declare function getCurrentSubscription(apiHost: string, authToken?: string, signal?: AbortSignal): Promise<CurrentSubscription | null>;
2292
+ /**
2293
+ * 创建订单
2294
+ * @param apiHost 接口域名
2295
+ * @param authToken 认证令牌
2296
+ * @param params 创建订单参数
2297
+ * @param product_id 产品ID
2298
+ * @param purchase_type 购买类型(1=一次性, 2=订阅)
2299
+ * @returns 创建订单响应
2300
+ */
2301
+ declare function createOrder(apiHost: string, authToken: string, params: {
2302
+ product_id: string;
2303
+ purchase_type: number | string;
2304
+ }): Promise<CreateOrderResponse | null | undefined>;
2305
+ /**
2306
+ * 获取活跃订阅详情
2307
+ */
2308
+ declare function getActiveSubscription(apiHost: string, authToken?: string): Promise<ActiveSubscription | null>;
2309
+ /**
2310
+ * 升降级订阅
2311
+ */
2312
+ declare function changeSubscription(apiHost: string, authToken: string | undefined, params: {
2313
+ productId: string;
2314
+ billingPeriod: 'month' | 'year';
2315
+ redirectUrl: string;
2316
+ }): Promise<{
2317
+ transaction_id: string;
2318
+ price: string;
2319
+ order_id: string;
2320
+ currency: string;
2321
+ }>;
2322
+ /**
2323
+ * 重新启动订阅
2324
+ * 用于已取消但仍在有效期内的订阅,重新恢复自动续费
2325
+ */
2326
+ declare function restartSubscription(apiHost: string, authToken: string | undefined, params: {
2327
+ subscriptionId: string;
2328
+ }): Promise<{
2329
+ success: boolean;
2330
+ message: string;
2331
+ next_billing_date: number;
2332
+ }>;
2333
+ /**
2334
+ * 积分池类型
2335
+ */
2336
+ type CreditPoolType = 'daily' | 'event' | 'monthly' | 'permanent';
2337
+ /**
2338
+ * 积分池详情
2339
+ */
2340
+ interface CreditPool {
2341
+ /** 积分池类型 */
2342
+ type: CreditPoolType;
2343
+ /** 该池余额(字符串格式,保留精度) */
2344
+ balance: string;
2345
+ /** 过期时间戳(毫秒,0 表示永不过期) */
2346
+ expires_at: number;
2347
+ }
2348
+ /**
2349
+ * 积分详情响应
2350
+ */
2351
+ interface CreditDetailResponse {
2352
+ /** 总余额(字符串格式,保留精度) */
2353
+ total_balance: string;
2354
+ /** 用户等级 */
2355
+ tier?: string;
2356
+ /** 积分池数组(仅包含余额 > 0 的池) */
2357
+ pools: CreditPool[];
2358
+ }
2359
+ /**
2360
+ * 获取积分详情
2361
+ * @param apiHost 接口域名(如 https://wallet.sg.seaverse.dev)
2362
+ * @param authToken 认证令牌
2363
+ * @returns 积分详情
2364
+ */
2365
+ declare function getCreditDetail(apiHost: string, authToken?: string): Promise<CreditDetailResponse | null>;
2366
+
2367
+ /**
2368
+ * Order API
2369
+ * 订单管理 - 查询和轮询订单状态
2370
+ */
2371
+ /**
2372
+ * 订单状态
2373
+ */
2374
+ type OrderStatus = 'pending' | 'paid' | 'failed' | 'expired' | 'refunded';
2375
+ /**
2376
+ * 订单状态响应
2377
+ */
2378
+ interface OrderStatusResponse {
2379
+ status: OrderStatus;
2380
+ }
2381
+ /**
2382
+ * 查询订单状态
2383
+ * @param transactionId SDK checkout 返回的 transaction_id
2384
+ * @param apiHost Payment API 地址
2385
+ * @param authToken 认证 Token
2386
+ * @returns 订单状态
2387
+ */
2388
+ declare function checkOrderStatus(transactionId: string, apiHost: string, authToken?: string): Promise<OrderStatus>;
2389
+ /**
2390
+ * 轮询订单状态直到支付完成或超时
2391
+ * @param transactionId SDK checkout 返回的 transaction_id
2392
+ * @param apiHost Payment API 地址
2393
+ * @param authToken 认证 Token
2394
+ * @param options 轮询配置
2395
+ * @returns 最终订单状态
2396
+ */
2397
+ declare function pollOrderStatus(transactionId: string, apiHost: string, authToken: string | undefined, options?: {
2398
+ /** 轮询间隔(毫秒),默认 2000ms */
2399
+ interval?: number;
2400
+ /** 最大轮询次数,默认 30 次(总计 60 秒) */
2401
+ maxAttempts?: number;
2402
+ /** 每次轮询后的回调 */
2403
+ onPoll?: (status: OrderStatus, attempt: number) => void;
2404
+ }): Promise<OrderStatus>;
2405
+
1033
2406
  /**
1034
2407
  * @seaverse/payment-sdk
1035
2408
  *
@@ -1077,7 +2450,7 @@ declare const BIZ_CODE: {
1077
2450
  /**
1078
2451
  * SDK version
1079
2452
  */
1080
- declare const VERSION = "0.7.0";
2453
+ declare const VERSION = "0.8.0";
1081
2454
 
1082
- export { API_ENDPOINTS, BIZ_CODE, COMPONENT_LOAD_TIMEOUT, CheckoutAPI, DEFAULT_CHECKOUT_CONFIG, ENV_CONFIG, HTTP_STATUS, PAYMENT_ELEMENT_NAME, PaymentAPIError, PaymentCheckoutClient, PaymentClient, SeaArtPayLoader, VERSION, centsToDollars, createCheckoutPaymentError, delay, dollarsToCents, formatPrice, generateOrderReference, getCurrentUrl, getGlobalLoader, getSDKLocale, isBrowser, isCheckoutPaymentError, resetGlobalLoader, safeJsonParse, withTimeout };
1083
- export type { ApiErrorResponse, ApiResponse, ApiSuccessResponse, BaseCheckoutOptions, BillingPeriod, CheckoutAPIConfig, CheckoutAPIResponse, CheckoutClientConfig, CheckoutClientStatus, CheckoutOptions, CheckoutPaymentError, CheckoutPaymentErrorCode, CheckoutResult, ComponentLoadStatus, CreditAccount, CreditAccountStatus, CreditDetailResponse, CreditDetailSuccessResponse, CreditPoolDetail, CreditPoolType, CreditTransaction, ListTransactionsRequest, LoaderConfig, PaymentClientOptions, PaymentEnvironment, PaymentReadyEventDetail, PaymentResult, PaymentSuccessEventDetail, PaymentUnsuccessEventDetail, PaymentUnsuccessResult, PurchaseType, SDKCheckoutRequest, SDKCheckoutResponse, SDKConfig, SDKLoadStatus, SeaArtPaymentElement, ShowPaymentOptions, SubscribeOptions, SubscriptionParams, SubscriptionPeriod, TransactionListResponse, TransactionStatus, TransactionType };
2455
+ export { API_ENDPOINTS, BIZ_CODE, BindCardPaymentComponent, COMPONENT_LOAD_TIMEOUT, CREATIVE_POWER_TYPES, CREDIT_PACKAGES, CheckoutAPI, CreditPackageModal, DEFAULT_CHECKOUT_CONFIG, DropinPaymentComponent, DropinPaymentModal, ENVIRONMENT_CONFIGS, ENV_CONFIG, ErrorHandler, GRID_COLUMNS, GenericPackageModal, HTTP_STATUS, LinkPaymentComponent, OrderPayment, PAYMENT_ELEMENT_NAME, PaymentAPIError, PaymentCheckoutClient, PaymentClient, PaymentError, PaymentModal, PaymentStorage, PurchaseSuccessModal, RESPONSIVE_BREAKPOINTS, SDK_CONFIG, ScriptLoader, SeaArtPayLoader, SeaartPaymentSDK, StylesheetLoader, VERSION, centsToDollars, changeSubscription, checkOrderStatus, createCheckoutPaymentError, createOrder, delay, dollarsToCents, formatPrice, generateOrderReference, getActiveSubscription, getCreditDetail, getCurrentSubscription, getCurrentUrl, getGlobalLoader, getSDKLocale, hideLoadingIndicator, isBrowser, isCheckoutPaymentError, pollOrderStatus, resetGlobalLoader, restartSubscription, safeJsonParse, showErrorMessage, showInfoMessage, showLoadingIndicator, showSuccessMessage, withTimeout };
2456
+ export type { ActiveSubscription, ApiErrorResponse, ApiResponse, ApiSuccessResponse, BaseCheckoutOptions, BillingPeriod, BindCard, BindCardCallbacks, BindCardPaymentOptions, CheckoutAPIConfig, CheckoutAPIResponse, CheckoutClientConfig, CheckoutClientStatus, CheckoutOptions, CheckoutPaymentError, CheckoutPaymentErrorCode, CheckoutResult, ComponentLoadStatus, CreateOrderResponse, CreativePowerType, CreditAccount, CreditAccountStatus, CreditDetailResponse$1 as CreditDetailResponse, CreditDetailSuccessResponse, CreditPackage, CreditPackageModalOptions, CreditPoolDetail, CreditPoolType$1 as CreditPoolType, CreditTransaction, CurrentSubscription, DropinCallbacks, DropinPaymentModalOptions, DropinPaymentOptions, Environment, EnvironmentConfig, GenericPackage, GenericPackageModalOptions, LinkPaymentOptions, ListTransactionsRequest, LoaderConfig, OrderInfo, OrderStatus, OrderStatusResponse, PaymentClientOptions, PaymentEnvironment, PaymentMethod, PaymentMethodsParams, PaymentModalOptions, PaymentReadyEventDetail, PaymentResult, PaymentSDKConfig, PaymentSuccessEventDetail, PaymentUnsuccessEventDetail, PaymentUnsuccessResult, PurchaseSuccessData, PurchaseSuccessModalOptions, PurchaseType, SDKCheckoutRequest, SDKCheckoutResponse, SDKConfig, SDKLoadStatus, ScriptLoaderOptions, SeaArtPaymentElement, SeaartBindCardPayment, SeaartDropinPayment, SeaartLinkPayment, SeaartPaymentComponentSDK, SeaartPaymentInstance, SeaartPaymentSDKConfig, ShowPaymentOptions, SubscribeOptions, SubscriptionParams, SubscriptionPeriod, TransactionListResponse, TransactionStatus, TransactionStorageData, TransactionType, UnifiedResponse };