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