@seaverse/payment-sdk 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2277,7 +2277,7 @@ class RetentionModal {
2277
2277
  */
2278
2278
  createModal() {
2279
2279
  const { language, productName, purchaseAmount, bonusAmount, discountPrice } = this.options;
2280
- const isZh = language === 'zh-CN';
2280
+ const isZh = language === 'zh';
2281
2281
  const t = isZh ? {
2282
2282
  title: '你有一笔订单待支付',
2283
2283
  timePrefix: '请在',
@@ -2909,10 +2909,20 @@ class SeaartPaymentSDK {
2909
2909
  }
2910
2910
  // 3. 等待所有资源加载完成
2911
2911
  await Promise.all(loadTasks);
2912
+ let language = 'en';
2913
+ if (config.language == 'zh') {
2914
+ language = 'zhCN';
2915
+ }
2916
+ else if (config.language == 'zh-TW') {
2917
+ language = 'zhTW';
2918
+ }
2919
+ else {
2920
+ language = config.language || 'en';
2921
+ }
2912
2922
  // 4. 初始化 SDK
2913
2923
  await window.SeaartPaymentComponent.init({
2914
2924
  client_id: config.clientId,
2915
- language: config.language || 'zhCN',
2925
+ language: language,
2916
2926
  });
2917
2927
  // 5. 保存配置并标记已初始化
2918
2928
  this.config = config;
@@ -3344,6 +3354,30 @@ const SDK_CONFIG = {
3344
3354
  DEFAULT_BUSINESS_TYPE: 1,
3345
3355
  };
3346
3356
 
3357
+ /**
3358
+ * 共享类型定义
3359
+ * Shared types for CreditPackageModal and GenericPackageModal
3360
+ */
3361
+ /**
3362
+ * 语言代码 → 国家/地区代码映射
3363
+ * 用于根据用户语言自动匹配支付渠道的国家参数
3364
+ */
3365
+ const LOCALE_TO_COUNTRY_CODE = {
3366
+ 'en': 'US', // English → 美国
3367
+ 'zh': 'CN', // 简体中文 → 中国大陆
3368
+ 'zh-TW': 'TW', // 繁體中文 → 台灣
3369
+ 'ja': 'JP', // 日本語 → 日本
3370
+ 'ko': 'KR', // 한국어 → 韩国
3371
+ 'es': 'ES', // Español → 西班牙
3372
+ 'fr': 'FR', // Français → 法国
3373
+ 'de': 'DE', // Deutsch → 德国
3374
+ 'pt': 'PT', // Português → 葡萄牙
3375
+ 'ru': 'RU', // Русский → 俄罗斯
3376
+ 'ar': 'SA', // العربية → 沙特阿拉伯
3377
+ 'hi': 'IN', // हिन्दी → 印度
3378
+ 'id': 'ID', // Bahasa Indonesia → 印度尼西亚
3379
+ };
3380
+
3347
3381
  /**
3348
3382
  * UI 反馈工具类
3349
3383
  * 提供统一的用户界面反馈(错误提示、加载状态等)
@@ -3729,7 +3763,7 @@ class PurchaseSuccessModal {
3729
3763
  */
3730
3764
  createModal() {
3731
3765
  const { data, language } = this.options;
3732
- const isZh = language === 'zh-CN';
3766
+ const isZh = language === 'zh';
3733
3767
  // 创建遮罩层
3734
3768
  this.overlay = document.createElement('div');
3735
3769
  this.overlay.id = 'purchase-success-modal-overlay';
@@ -4238,20 +4272,19 @@ class BasePackageModal {
4238
4272
  clientId: config.clientId || envConfig.clientId,
4239
4273
  orderApiUrl: config.orderApiUrl || envConfig.orderApiUrl,
4240
4274
  cssUrl: config.cssUrl || envConfig.cssUrl,
4241
- language: config.countryCode || 'US',
4242
4275
  };
4243
4276
  console.log(`[${this.constructor.name}] Using environment:`, config.environment);
4244
4277
  // 3. Initialize SeaartPaymentSDK
4245
4278
  await SeaartPaymentSDK.getInstance().init({
4246
4279
  scriptUrl: finalConfig.scriptUrl,
4247
4280
  clientId: finalConfig.clientId,
4248
- language: finalConfig.language,
4281
+ language: this.language,
4249
4282
  scriptTimeout: config.scriptTimeout,
4250
4283
  cssUrl: finalConfig.cssUrl,
4251
4284
  });
4252
4285
  // 4. Get payment methods list
4253
4286
  const paymentMethods = await SeaartPaymentSDK.getInstance().getPaymentMethods({
4254
- country_code: finalConfig.language,
4287
+ country_code: LOCALE_TO_COUNTRY_CODE[this.language] || 'US',
4255
4288
  business_type: config.businessType ?? 1, // Default to 1 (one-time purchase)
4256
4289
  });
4257
4290
  // 5. Find matching payment method
@@ -4454,7 +4487,7 @@ class BasePackageModal {
4454
4487
  try {
4455
4488
  // Disable button, show initializing state
4456
4489
  button.disabled = true;
4457
- const isZh = this.language === 'zh-CN';
4490
+ const isZh = this.language === 'zh';
4458
4491
  button.innerHTML = this.getLoadingButtonHTML(isZh ? '初始化中...' : 'Initializing...');
4459
4492
  // Wait for SDK initialization (with retry)
4460
4493
  const initialized = await this.waitForSDKInitialization(30000, 1);
@@ -4483,7 +4516,7 @@ class BasePackageModal {
4483
4516
  * Cleanup resources
4484
4517
  */
4485
4518
  cleanup() {
4486
- console.log(`[${this.constructor.name}] Cleaning up...`);
4519
+ // console.log(`[${this.constructor.name}] Cleaning up...`);
4487
4520
  // Remove resize listener
4488
4521
  if (this.resizeHandler) {
4489
4522
  window.removeEventListener('resize', this.resizeHandler);
@@ -4624,7 +4657,7 @@ class CreditPackCard {
4624
4657
  */
4625
4658
  createCard() {
4626
4659
  const container = document.createElement('div');
4627
- const isZh = this.options.language === 'zh-CN';
4660
+ const isZh = this.options.language === 'zh';
4628
4661
  const hasBonus = this.options.bonusCredits > 0;
4629
4662
  const isHighlighted = this.options.recommended || false;
4630
4663
  const showBadge = this.options.isFirstPurchase || false;
@@ -5110,7 +5143,7 @@ class PaymentVerificationModal {
5110
5143
  * 创建弹窗元素
5111
5144
  */
5112
5145
  createModal() {
5113
- const isZh = this.options.language === 'zh-CN';
5146
+ const isZh = this.options.language === 'zh';
5114
5147
  // 创建遮罩层
5115
5148
  this.overlay = document.createElement('div');
5116
5149
  this.overlay.id = 'payment-verification-modal-overlay';
@@ -5462,7 +5495,7 @@ class PaymentVerificationModal {
5462
5495
  // 更新按钮文本为 Processing...
5463
5496
  const completeBtn = document.getElementById('verification-complete-btn');
5464
5497
  if (completeBtn) {
5465
- const isZh = this.options.language === 'zh-CN';
5498
+ const isZh = this.options.language === 'zh';
5466
5499
  completeBtn.textContent = isZh ? '处理中...' : 'Processing...';
5467
5500
  completeBtn.style.pointerEvents = 'none';
5468
5501
  completeBtn.style.opacity = '0.85';
@@ -5480,7 +5513,7 @@ class PaymentVerificationModal {
5480
5513
  // 恢复按钮文本
5481
5514
  const completeBtn = document.getElementById('verification-complete-btn');
5482
5515
  if (completeBtn) {
5483
- const isZh = this.options.language === 'zh-CN';
5516
+ const isZh = this.options.language === 'zh';
5484
5517
  completeBtn.textContent = isZh ? '我已完成支付' : 'I\'ve Completed Payment';
5485
5518
  completeBtn.style.pointerEvents = '';
5486
5519
  completeBtn.style.opacity = '';
@@ -5604,7 +5637,7 @@ class PaymentFailedModal {
5604
5637
  */
5605
5638
  createModal() {
5606
5639
  const { language } = this.options;
5607
- const isZh = language === 'zh-CN';
5640
+ const isZh = language === 'zh';
5608
5641
  // 创建遮罩层(与验证弹框一致)
5609
5642
  this.overlay = document.createElement('div');
5610
5643
  this.overlay.id = 'payment-failed-modal-overlay';
@@ -5947,7 +5980,7 @@ class PaymentFailedModal {
5947
5980
  * 切换详情展开/折叠
5948
5981
  */
5949
5982
  toggleDetails() {
5950
- const isZh = this.options.language === 'zh-CN';
5983
+ const isZh = this.options.language === 'zh';
5951
5984
  const detailsToggleText = isZh ? '查看详情' : 'View Details';
5952
5985
  const detailsHideText = isZh ? '隐藏详情' : 'Hide Details';
5953
5986
  this.detailsExpanded = !this.detailsExpanded;
@@ -6048,7 +6081,7 @@ async function createOrderAndInitPayment(config) {
6048
6081
  // 2. 初始化 SDK 并加载支付方式
6049
6082
  const paymentMethods = await loadPaymentMethods({
6050
6083
  clientId: config.clientId,
6051
- countryCode: config.countryCode,
6084
+ language_code: config.language_code,
6052
6085
  businessType: config.purchaseType,
6053
6086
  });
6054
6087
  // 使用 transaction_id 作为 sys_order_id(这是 SDK 要求的)
@@ -6081,11 +6114,21 @@ async function loadPaymentMethods(params) {
6081
6114
  if (typeof window === 'undefined' || !window.SeaartPaymentComponent) {
6082
6115
  throw new Error('SeaartPaymentComponent SDK not loaded');
6083
6116
  }
6117
+ let language = 'en';
6118
+ if (params.language_code == 'zh') {
6119
+ language = 'zhCN';
6120
+ }
6121
+ else if (params.language_code == 'zh-TW') {
6122
+ language = 'zhTW';
6123
+ }
6124
+ else {
6125
+ language = params.language_code || 'en';
6126
+ }
6084
6127
  // 初始化 SDK(如果尚未初始化)
6085
6128
  try {
6086
6129
  await window.SeaartPaymentComponent.init({
6087
6130
  client_id: params.clientId,
6088
- language: params.countryCode,
6131
+ language: language,
6089
6132
  });
6090
6133
  }
6091
6134
  catch (error) {
@@ -6094,7 +6137,7 @@ async function loadPaymentMethods(params) {
6094
6137
  }
6095
6138
  // 获取支付方式列表
6096
6139
  const response = await window.SeaartPaymentComponent.getPaymentMethodList({
6097
- country_code: params.countryCode,
6140
+ country_code: LOCALE_TO_COUNTRY_CODE[params.language_code] || 'US',
6098
6141
  business_type: params.businessType,
6099
6142
  });
6100
6143
  if (!response.data?.payment_method_list) {
@@ -7187,7 +7230,7 @@ class PaymentUIRenderer {
7187
7230
  <!-- ═══ Left ═══ -->
7188
7231
  <div style="padding: 32px 32px;">
7189
7232
  ${this.sectionTitle('Payment Method')}
7190
- <div style="display: flex; flex-direction: column; gap: 8px;">
7233
+ <div style="display: flex; flex-direction: column; gap: 14px;">
7191
7234
  ${methodItem(0)}
7192
7235
  ${methodItem(1)}
7193
7236
  ${methodItem(2)}
@@ -7250,7 +7293,7 @@ class PaymentUIRenderer {
7250
7293
  <div style="padding: 32px 32px; overflow-y: auto;">
7251
7294
  ${this.sectionTitle('Payment Method')}
7252
7295
 
7253
- <div id="payment-methods-list" style="display: flex; flex-direction: column; gap: 8px;">
7296
+ <div id="payment-methods-list" style="display: flex; flex-direction: column; gap: 14px;">
7254
7297
  ${config.loadingMethods ? this.getLoadingHTML() : this.getPaymentMethodsHTML(config)}
7255
7298
  </div>
7256
7299
  </div>
@@ -7657,22 +7700,14 @@ class PaymentUIRenderer {
7657
7700
  * 多语言文本配置
7658
7701
  */
7659
7702
  const LANGUAGE_TEXTS = {
7660
- en: {
7703
+ 'en': {
7661
7704
  creatingOrder: 'Creating order...',
7662
7705
  openingPayment: 'Opening payment window...',
7663
7706
  processingPayment: 'Processing payment...',
7664
7707
  paymentSuccess: 'Payment completed successfully!',
7665
7708
  sdkNotInitialized: 'Payment SDK not initialized. Please contact support.',
7666
7709
  orderCreationFailed: 'Failed to create order',
7667
- },
7668
- 'zh-CN': {
7669
- creatingOrder: '正在创建订单...',
7670
- openingPayment: '正在打开支付窗口...',
7671
- processingPayment: '正在处理支付...',
7672
- paymentSuccess: '支付成功!',
7673
- sdkNotInitialized: '支付 SDK 未初始化,请联系客服。',
7674
- orderCreationFailed: '创建订单失败',
7675
- },
7710
+ }
7676
7711
  };
7677
7712
  class PaymentCheckoutModal {
7678
7713
  constructor(options) {
@@ -7722,8 +7757,8 @@ class PaymentCheckoutModal {
7722
7757
  * 获取当前语言的文本
7723
7758
  */
7724
7759
  getText(key) {
7725
- const language = this.options.language || 'en';
7726
- return LANGUAGE_TEXTS[language][key];
7760
+ // const language = this.options.language;
7761
+ return LANGUAGE_TEXTS['en'][key];
7727
7762
  }
7728
7763
  /**
7729
7764
  * 打开弹框
@@ -7820,7 +7855,7 @@ class PaymentCheckoutModal {
7820
7855
  */
7821
7856
  checkSDKInitialized() {
7822
7857
  if (typeof window === 'undefined' || !window.SeaartPaymentComponent) {
7823
- const errorMessage = this.options.language === 'zh-CN'
7858
+ const errorMessage = this.options.language === 'zh'
7824
7859
  ? '支付 SDK 未初始化,请确保 SeaartPaymentComponent 已加载'
7825
7860
  : 'Payment SDK not initialized. Please ensure SeaartPaymentComponent is loaded.';
7826
7861
  console.error('[PaymentCheckoutModal]', errorMessage);
@@ -7843,7 +7878,7 @@ class PaymentCheckoutModal {
7843
7878
  this.cleanup();
7844
7879
  }, () => {
7845
7880
  // 超时回调
7846
- const timeoutMessage = this.options.language === 'zh-CN'
7881
+ const timeoutMessage = this.options.language === 'zh'
7847
7882
  ? '支付验证超时,请稍后重试'
7848
7883
  : 'Payment verification timeout. Please try again.';
7849
7884
  this.verificationModal?.close();
@@ -7889,7 +7924,7 @@ class PaymentCheckoutModal {
7889
7924
  this.stopOrderPolling();
7890
7925
  this.verificationModal?.close();
7891
7926
  this.verificationModal = null;
7892
- const errorMessage = this.options.language === 'zh-CN'
7927
+ const errorMessage = this.options.language === 'zh'
7893
7928
  ? `支付失败:${orderData.status === 'failed' ? '支付失败' : orderData.status === 'expired' ? '订单已过期' : '订单已退款'}`
7894
7929
  : `Payment ${orderData.status}. Please try again.`;
7895
7930
  // 显示支付失败弹窗
@@ -7915,7 +7950,7 @@ class PaymentCheckoutModal {
7915
7950
  continue;
7916
7951
  }
7917
7952
  // 超过最大次数,显示错误
7918
- const errorMessage = this.options.language === 'zh-CN'
7953
+ const errorMessage = this.options.language === 'zh'
7919
7954
  ? '查询订单状态失败,请稍后重试'
7920
7955
  : 'Failed to check order status. Please try again.';
7921
7956
  this.showPaymentFailedModal(errorMessage, error instanceof Error ? error.message : String(error));
@@ -7928,7 +7963,7 @@ class PaymentCheckoutModal {
7928
7963
  }
7929
7964
  // 轮询超时(10 次后仍为 pending)
7930
7965
  console.warn('[PaymentCheckoutModal] Polling timeout after', maxAttempts, 'attempts');
7931
- const timeoutMessage = this.options.language === 'zh-CN'
7966
+ const timeoutMessage = this.options.language === 'zh'
7932
7967
  ? '支付验证超时,请检查支付状态或联系客服'
7933
7968
  : 'Payment verification timeout. Please check your payment status or contact support.';
7934
7969
  this.showPaymentFailedModal(timeoutMessage);
@@ -8037,7 +8072,10 @@ class PaymentCheckoutModal {
8037
8072
  });
8038
8073
  }
8039
8074
  /**
8040
- * 自动选中默认支付方式(优先选中第一个 Dropin 支付方式)
8075
+ * 自动选中默认支付方式
8076
+ * 策略:
8077
+ * - 如果有 Dropin(payment_type === 2),自动选中并渲染表单
8078
+ * - 如果只有 Link(payment_type === 1),不自动选中,让用户手动选择
8041
8079
  */
8042
8080
  async autoSelectDefaultPaymentMethod() {
8043
8081
  const paymentMethods = this.stateManager.get('paymentMethods');
@@ -8045,12 +8083,27 @@ class PaymentCheckoutModal {
8045
8083
  // 如果已经有选中的,不重复选择
8046
8084
  if (selectedPaymentMethod)
8047
8085
  return;
8048
- // 优先找 Dropin(payment_type === 2),其次选第一个
8086
+ // 查找第一个 Dropin 支付方式
8049
8087
  const dropinIndex = paymentMethods.findIndex((m) => m.payment_type === 2);
8050
- const defaultIndex = dropinIndex !== -1 ? dropinIndex : 0;
8051
- if (paymentMethods[defaultIndex]) {
8052
- console.log(`[PaymentCheckoutModal] Auto-selecting payment method at index ${defaultIndex} (type: ${paymentMethods[defaultIndex].payment_type})`);
8053
- await this.handleSelectPaymentMethod(defaultIndex);
8088
+ // 仅当存在 Dropin 时才自动选中
8089
+ if (dropinIndex !== -1) {
8090
+ const method = paymentMethods[dropinIndex];
8091
+ console.log(`[PaymentCheckoutModal] Auto-selecting Dropin payment method at index ${dropinIndex}`);
8092
+ // 设置选中状态(高亮显示)
8093
+ this.stateManager.setState({
8094
+ selectedPaymentMethod: method,
8095
+ showAddCardForm: false,
8096
+ });
8097
+ this.options.onPaymentMethodSelect?.(method);
8098
+ // 重新渲染以显示选中状态
8099
+ this.renderPaymentMethods();
8100
+ // 自动执行 Dropin 策略(渲染支付表单)
8101
+ console.log('[PaymentCheckoutModal] Auto-executing Dropin payment strategy');
8102
+ await this.executePaymentStrategy(method, dropinIndex);
8103
+ }
8104
+ else {
8105
+ // ✅ 没有 Dropin,全是 Link 支付,不自动选中
8106
+ console.log('[PaymentCheckoutModal] No Dropin payment available, waiting for user selection');
8054
8107
  }
8055
8108
  }
8056
8109
  /**
@@ -8388,14 +8441,30 @@ class CreditPackageModal extends BasePackageModal {
8388
8441
  // Then call parent open() which will render with the fetched packages
8389
8442
  return super.open();
8390
8443
  }
8444
+ /**
8445
+ * 覆盖 BasePackageModal 的 initializeSDK 方法
8446
+ * CreditPackageModal 使用 PaymentCheckoutModal,不需要 BasePackageModal 的 SDK 初始化
8447
+ * PaymentCheckoutModal 会自行处理 SDK 初始化
8448
+ */
8449
+ async initializeSDK() {
8450
+ console.log('[CreditPackageModal] Skipping BasePackageModal SDK initialization (handled by PaymentCheckoutModal)');
8451
+ // 标记为已初始化,避免父类重复调用
8452
+ this.sdkInitialized = true;
8453
+ }
8454
+ /**
8455
+ * 覆盖 BasePackageModal 的 waitForSDKInitialization 方法
8456
+ * CreditPackageModal 使用 PaymentCheckoutModal,不需要等待 BasePackageModal 的 SDK 初始化
8457
+ */
8458
+ async waitForSDKInitialization(_timeout, _maxRetries) {
8459
+ console.log('[CreditPackageModal] Skipping SDK initialization wait (handled by PaymentCheckoutModal)');
8460
+ return true; // 直接返回成功,让 PaymentCheckoutModal 处理
8461
+ }
8391
8462
  /**
8392
8463
  * Create and configure the PaymentModal instance
8393
8464
  */
8394
8465
  createModal() {
8395
8466
  return new PaymentModal({
8396
- title: this.language === 'zh-CN'
8397
- ? (this.options.title_cn || '选择您的创作力量')
8398
- : (this.options.title || ''),
8467
+ title: this.options.title || '',
8399
8468
  showCloseButton: true,
8400
8469
  closeOnOverlayClick: false, // Disable click overlay to close
8401
8470
  closeOnEsc: false, // Disable ESC key to close
@@ -8430,22 +8499,7 @@ class CreditPackageModal extends BasePackageModal {
8430
8499
  }
8431
8500
  console.log('[CreditPackageModal] Fetching available packages from API...');
8432
8501
  const apiPackages = await fetchAvailablePackages(apiHost, token);
8433
- console.log('%c ====apiPackages==>>>>>>>>', 'color:orange;', apiPackages);
8434
- // Convert API format to CreditPackage format
8435
8502
  this.dynamicPackages = apiPackages;
8436
- // .map(pkg => {
8437
- // const converted = convertToCreditPack(pkg);
8438
- // return {
8439
- // id: converted.id,
8440
- // name: converted.name,
8441
- // price: String(converted.price),
8442
- // credits: String(converted.totalCredits),
8443
- // base_credits: String(converted.baseCredits),
8444
- // bonus_credits: converted.bonusCredits > 0 ? String(converted.bonusCredits) : undefined,
8445
- // is_popular: converted.recommended || false,
8446
- // day_limit: this.parsePurchaseLimit(converted.purchaseLimit),
8447
- // } as CreditPackage;
8448
- // });
8449
8503
  console.log(`[CreditPackageModal] Successfully fetched ${this.dynamicPackages.length} packages`);
8450
8504
  }
8451
8505
  catch (error) {
@@ -8564,14 +8618,14 @@ class CreditPackageModal extends BasePackageModal {
8564
8618
  apiHost: sdkConfig.orderApiUrl || envConfig.orderApiUrl,
8565
8619
  accountToken: sdkConfig.accountToken || '',
8566
8620
  clientId: sdkConfig.clientId || envConfig.clientId,
8567
- countryCode: sdkConfig.countryCode,
8621
+ language_code: this.language,
8568
8622
  };
8569
8623
  }
8570
8624
  /**
8571
8625
  * Get package display name for payment modal title
8572
8626
  */
8573
8627
  getPackageDisplayName(pkg) {
8574
- const isZh = this.language === 'zh-CN';
8628
+ const isZh = this.language === 'zh';
8575
8629
  return isZh ? `${pkg.total_credits} 积分套餐` : `${pkg.total_credits} Credits Package`;
8576
8630
  }
8577
8631
  /**
@@ -8643,7 +8697,7 @@ class CreditPackageModal extends BasePackageModal {
8643
8697
  if (!container) {
8644
8698
  throw new Error('Modal content container not found');
8645
8699
  }
8646
- const isZh = this.language === 'zh-CN';
8700
+ const isZh = this.language === 'zh';
8647
8701
  const styles = this.getResponsiveStyles();
8648
8702
  container.innerHTML = `
8649
8703
  <div style="
@@ -8721,7 +8775,7 @@ class CreditPackageModal extends BasePackageModal {
8721
8775
  * Render package card using CreditPackCard component
8722
8776
  */
8723
8777
  renderPackageCard(pkg, index) {
8724
- const isZh = this.language === 'zh-CN';
8778
+ const isZh = this.language === 'zh';
8725
8779
  const isPopular = pkg.is_first_purchase_pkg;
8726
8780
  // 使用新的 CreditPackCard 组件生成卡片 HTML
8727
8781
  const cardInstance = new CreditPackCard({
@@ -8733,7 +8787,7 @@ class CreditPackageModal extends BasePackageModal {
8733
8787
  totalCredits: parseInt(pkg.total_credits),
8734
8788
  recommended: isPopular,
8735
8789
  isFirstPurchase: isPopular,
8736
- language: isZh ? 'zh-CN' : 'en',
8790
+ language: isZh ? 'zh' : 'en',
8737
8791
  onBuy: async (packId) => {
8738
8792
  // 这个回调会在 attachEventListeners 中被重新绑定
8739
8793
  console.log('[CreditPackageModal] Package selected:', packId);
@@ -8761,6 +8815,24 @@ class GenericPackageModal extends BasePackageModal {
8761
8815
  super(options);
8762
8816
  }
8763
8817
  // === Abstract Method Implementations ===
8818
+ /**
8819
+ * 覆盖 BasePackageModal 的 initializeSDK 方法
8820
+ * GenericPackageModal 使用 PaymentCheckoutModal,不需要 BasePackageModal 的 SDK 初始化
8821
+ * PaymentCheckoutModal 会自行处理 SDK 初始化
8822
+ */
8823
+ async initializeSDK() {
8824
+ console.log('[GenericPackageModal] Skipping BasePackageModal SDK initialization (handled by PaymentCheckoutModal)');
8825
+ // 标记为已初始化,避免父类重复调用
8826
+ this.sdkInitialized = true;
8827
+ }
8828
+ /**
8829
+ * 覆盖 BasePackageModal 的 waitForSDKInitialization 方法
8830
+ * GenericPackageModal 使用 PaymentCheckoutModal,不需要等待 BasePackageModal 的 SDK 初始化
8831
+ */
8832
+ async waitForSDKInitialization(_timeout, _maxRetries) {
8833
+ console.log('[GenericPackageModal] Skipping SDK initialization wait (handled by PaymentCheckoutModal)');
8834
+ return true; // 直接返回成功,让 PaymentCheckoutModal 处理
8835
+ }
8764
8836
  /**
8765
8837
  * Create and configure the PaymentModal instance
8766
8838
  */
@@ -8840,6 +8912,7 @@ class GenericPackageModal extends BasePackageModal {
8840
8912
  if (container) {
8841
8913
  container.addEventListener('close-modal', () => {
8842
8914
  this.close();
8915
+ this.options.onClose?.();
8843
8916
  });
8844
8917
  }
8845
8918
  }
@@ -8943,7 +9016,7 @@ class GenericPackageModal extends BasePackageModal {
8943
9016
  apiHost: sdkConfig.orderApiUrl || envConfig.orderApiUrl,
8944
9017
  accountToken: sdkConfig.accountToken || '',
8945
9018
  clientId: sdkConfig.clientId || envConfig.clientId,
8946
- countryCode: sdkConfig.countryCode,
9019
+ language_code: this.language,
8947
9020
  };
8948
9021
  }
8949
9022
  /**
@@ -9197,7 +9270,7 @@ class GenericPackageModal extends BasePackageModal {
9197
9270
  /**
9198
9271
  * SDK version
9199
9272
  */
9200
- const VERSION$2 = '0.9.0';
9273
+ const VERSION$2 = '0.9.2';
9201
9274
 
9202
9275
  var __defProp = Object.defineProperty;
9203
9276
  var __defProps = Object.defineProperties;