Commit Graph
1268 Commits
Author SHA1 Message Date
erio e25e7b3f2d fix(admin): fix refund dialog amount for REFUND_REQUESTED, improve button styles
- Don't treat refund_amount as "already refunded" in REFUND_REQUESTED status
  (it's the requested amount, not actually refunded)
- Pre-fill refund amount with user's requested amount
- Show "already refunded" only for PARTIALLY_REFUNDED/REFUNDED orders
- Change action buttons from stacked icon+text to compact inline style
2026-04-09 22:07:06 +08:00
erio 66cd16fce3 fix: remove unused canRefund, fix TS type assertions 2026-04-09 21:49:05 +08:00
erio cc858c3cc9 feat(admin): enhance refund workflow to match sub2apipay
Admin order list:
- Add REFUND_REQUESTED "approve refund" button with amount badge
- Add REFUND_FAILED "retry refund" button
- Add missing status filters (REFUND_REQUESTED, REFUND_FAILED)
- Order detail dialog: show refund request info + audit logs

Admin refund dialog:
- Show refund request info card (violet) when user requested
- Display user balance with insufficient balance warning
- Add "no deduction" info when deduct_balance unchecked
- Add force refund checkbox (shown when requireForce=true)
- Add warning display prop
- Pre-fill reason from user's refund request
- Default deduct_balance to true

chore: bump version to 0.1.108.141
2026-04-09 21:47:39 +08:00
erio ceee2d0584 fix: audit fixes - magic strings to constants, frontend any/catch, LB tests
Backend:
- Define OrderTypeBalance/Subscription, EntityStatusActive, DeductionType*,
  NotificationStatus* constants in payment/types.go
- Replace all magic strings in payment_order, payment_fulfillment, payment_refund
- Add local constants in easypay.go (tradeStatusSuccess, signTypeMD5)
- Add 27 unit tests for load balancer (filterByLimits, pickLeastAmount,
  getInstanceChannelLimits, startOfDay)

Frontend:
- Remove all `any` types in SettingsView.vue (18 catch blocks + 1 payload)
- Fix bare catch blocks in PaymentResultView, PaymentView
- Add `unknown` type annotation to all catch blocks

chore: bump version to 0.1.108.140
2026-04-09 21:29:49 +08:00
erio 8808910ee7 fix(frontend): unify currency to $ and add order number to admin orders
- Replace all ¥ / ¥ with $ across all payment views and components
- Add out_trade_no column to admin order list table
- Add order number field to admin order detail dialog

chore: bump version to 0.1.108.138
2026-04-09 21:14:57 +08:00
erio b25d7f3179 fix(frontend): restore RechargeSubscriptionIcon for purchase menu
chore: bump version to 0.1.108.135
2026-04-09 19:01:34 +08:00
erio 766f9fc590 fix: cast platform to string to fix TS2345 2026-04-09 18:48:42 +08:00
erio 05ce6d6bc0 feat(admin): add platform colors to plan edit group selector
chore: bump version to 0.1.108.134
2026-04-09 18:46:58 +08:00
erio acb86102f4 feat(admin): color plan names by group platform
chore: bump version to 0.1.108.133
2026-04-09 18:33:36 +08:00
erio 4bacf47e45 fix(admin): only show subscription-type groups in plan group selector 2026-04-09 18:19:31 +08:00
erio 3ce57cade8 fix(payment): use Stripe built-in QR dialog for WeChat Pay
Remove handleActions:false and custom QR rendering. Let Stripe's
native QR dialog handle WeChat Pay display in the popup window.
2026-04-09 18:04:04 +08:00
erio ae1709a616 fix(payment): use normal style for order number column 2026-04-09 17:49:09 +08:00
erio 3098651bdd fix(payment): show order number as separate column in order list 2026-04-09 17:43:42 +08:00
erio 49a36e55a9 feat(payment): show out_trade_no in order list 2026-04-09 17:34:23 +08:00
erio cb9dcaec2e fix(payment): show both order ID and order number in result pages
Display order ID (#24) and order number (sub2_xxx) as separate rows
in payment result and status panel success views.
2026-04-09 17:29:18 +08:00
erio 01864a7a1e fix(payment): ensure providers loaded before webhook, show out_trade_no
- Call EnsureProviders before webhook provider lookup to fix
  "provider not registered" error after restart or config changes
- Display out_trade_no instead of numeric ID in payment result pages
2026-04-09 17:23:23 +08:00
erio cfc20f6670 fix(admin): preserve provider list order after editing
Update provider in place instead of reloading the entire list,
which could change the display order.
2026-04-09 17:14:39 +08:00
erio 5ae2061d05 fix(admin): fix payment provider settings issues
- Remove "at least one payment type required" validation, allow
  saving providers with no payment types selected
- Auto-fill current domain for empty notify/return URL on save
  (trim whitespace, fall back to window.location.origin)
- Add type="button" to all buttons inside the settings form that
  are not submit buttons (edit, delete, refresh, create provider)
  to prevent accidental form submission triggering main settings save
2026-04-09 16:39:22 +08:00
erio 11ba3b6ecd fix(payment): restore Stripe popup flow, fix WeChat double QR dialog
Restore popup handling for Stripe Alipay/WeChat (reverts inline-only change).
Fix WeChat double QR issue by passing handleActions: false to
confirmWechatPayPayment, which prevents Stripe's built-in QR dialog
and lets our popup render the QR code directly.

Flow after fix:
- Stripe Alipay: popup → redirects to Alipay
- Stripe WeChat: popup → directly shows QR code (no Stripe dialog)
- Stripe Card: inline confirm → success page
2026-04-09 16:07:26 +08:00
erio 8b4e6bf317 refactor(payment): unify Stripe payment flow, remove StripePopupView dependency
All Stripe methods now use confirmPayment({redirect: 'if_required'}):
- Card: confirms inline, shows success page
- WeChat: Stripe shows QR modal overlay on same page, no popup
- Alipay: Stripe redirects to Alipay page, returns to result page

Removes POPUP_METHODS, StripePopupView postMessage handshake, and
onStripeRedirect handler. Eliminates double-popup issue for WeChat
(3 windows → 1) and simplifies Alipay (2 windows → 1 redirect).
2026-04-09 15:41:07 +08:00
erio 8a98f726b9 fix(payment): show success screen after Stripe card payment instead of auto-returning
Stripe card payment now shows a success page with order details and a
manual confirm button, matching the QR code payment success flow.
Previously it auto-returned to the recharge page after 1.5 seconds.
2026-04-09 15:21:23 +08:00
erio 03b97f14ad fix(payment): add return_url verification for popup payment mode
EasyPay popup mode relies on notify_url (webhook) to update order status,
but if the callback is missed, orders stay PENDING forever. This adds:

- POST /api/v1/payment/orders/verify endpoint that actively queries
  the upstream provider to check payment status
- Frontend PaymentResultView calls verify when receiving EasyPay
  return_url params (out_trade_no)
- Fix checkPaid to fall back to OutTradeNo when PaymentTradeNo is empty
  (popup mode doesn't have trade_no until the notify callback)
2026-04-09 14:56:24 +08:00
erio 6c9fd2ed00 fix: prevent settings save on provider edit, randomize order IDs
- Remove saveSettings() call from handleSaveProvider - editing a
  provider should not save the entire settings form
- Change order ID format from sub2_5 to sub2_20250409_5_aB3kX9mQ
  (prefix + date + dbID + 8-char alphanumeric random) to avoid
  collisions with external payment providers
- parseOrderID supports both legacy and new format
2026-04-09 11:58:49 +08:00
erio 53bcd4ce53 fix(admin): compact provider dialog layout, fix broken template 2026-04-09 11:44:32 +08:00
erio 7c2dbb07b5 fix(admin): skip null values when loading settings from backend
Backend returns null for unconfigured fields. Object.assign overwrites
form defaults (e.g. payment_enabled_types: []) with null, causing
"Cannot read properties of null" errors. Now only non-null values
are applied, preserving safe defaults for unconfigured environments.
2026-04-09 03:35:38 +08:00
erio 382b96b7b4 feat(payment): support alipay_direct/wxpay_direct in method selector
Add alipay_direct and wxpay_direct to METHOD_ORDER so they appear
in the correct position when enabled. The checkout API already returns
these types from direct provider instances; the method selector's
icon/style matching (includes('alipay')) already handles them.
2026-04-09 03:20:52 +08:00
erio 7f2877363d feat(payment): lightweight Stripe popup with postMessage credentials
Create StripePopupView.vue - a standalone minimal page (no AppLayout)
that receives clientSecret/publishableKey via postMessage from parent:
- Alipay: auto-calls confirmAlipayPayment(), shows "正在跳转..."
- WeChat: calls confirmWechatPayPayment(), shows QR code inline
- Much faster than loading full StripePaymentView (no API calls needed)
2026-04-09 03:13:35 +08:00
erio f50b48c482 fix(payment): restore easypay toggle, disable instances when provider disabled
- Add easypay back to enabled provider toggles (alongside alipay, wxpay, stripe)
- Disabling a provider toggle now also disables all matching provider instances
- Simplify enabledProviderKeyOptions - direct mapping instead of special cases
- Label: "启用的服务商" with hint about instance auto-disable
2026-04-09 03:00:49 +08:00
erio a8a98cc5a1 fix: order expiry cancels upstream, subscription layout, popup & label fixes
- ExpireTimedOutOrders now cancels upstream payment (Stripe PaymentIntent)
  before marking order as expired
- Active subscriptions moved below plan list with compact inline style
- StripePaymentView uses minimal layout (no AppLayout) in popup mode
- Fix misleading "服务商" label → "支持的支付方式" for payment type toggles
2026-04-09 02:29:18 +08:00
erio 21bcc04356 fix(payment): widen Stripe popup for Alipay checkout page (1250px) 2026-04-09 02:13:34 +08:00
erio fbdb68a0aa refactor(payment): direct Stripe confirm for alipay/wechat popup
Instead of opening a popup that renders the full Payment Element again
(forcing users to re-select payment method), pass the selected method
via query param. The popup now directly calls:
- confirmAlipayPayment() for Alipay (redirects to Alipay page)
- confirmWechatPayPayment() for WeChat (displays QR code)
Card and Google Pay remain inline on the main page.
2026-04-09 02:04:23 +08:00
erio 090f2e721f fix(payment): show result inline for all terminal states instead of auto-returning
Success, cancelled, and expired states now all display a result screen
in-place. User must click confirm to return, matching sub2apipay behavior.
2026-04-09 01:50:48 +08:00
erio 4f88ee637a fix(payment): inject paymentMode into provider config for correct redirect
The EasyPay provider reads paymentMode from e.config["paymentMode"] to decide
between redirect (submit.php) and API (mapi.php) paths. However, paymentMode
is stored as a separate DB column, not inside the encrypted config JSON.
SelectInstance() returned it in the InstanceSelection struct but never injected
it into the Config map, so the provider always fell through to the API/QR path.

Also includes:
- Subscription success flow: show "订阅成功" and refresh on return
- Active subscription card: platform colors, rate/quota display
- Subscription plan card: compact layout to save height
- Provider list: drag-and-drop reorder via sort_order
2026-04-09 01:13:16 +08:00
erio 9a0bdaba8e refactor(frontend): extract centralized platform color config
Create utils/platformColors.ts as single source of truth for all
platform color classes (badge, border, accent, text, icon, button,
discount). Refactor SubscriptionPlanCard to use it.
2026-04-09 00:15:25 +08:00
erio 1afb222311 fix(payment): align subscription card colors with platform convention
Change Anthropic color from amber to orange to match GroupsView,
ChannelsView and other admin components.
2026-04-09 00:10:43 +08:00
erio 5f4378b4ae feat(payment): show group details and quota info on subscription plan cards
Extend checkout API to return group name, rate multiplier, daily/weekly/monthly
limits and supported model scopes. Redesign SubscriptionPlanCard to display
platform badge, group quota info, and model scope tags.
2026-04-09 00:00:25 +08:00
erio e86c7005b5 fix(payment): subscription plans grid layout from top-left 2026-04-08 22:16:29 +08:00
erio 3f5e277855 refactor(payment): inline subscription flow and simplify payment modes
- EasyPay: remove redirect mode, keep only qrcode and popup
- Stripe: remove mode config entirely, always use inline Payment Element
- Subscription: replace dialog with inline confirm UI (plan summary +
  method selector + fee breakdown), same flow as top-up
- Move PaymentStatusPanel/StripePaymentInline to shared section for
  both recharge and subscription payments
- Hide tabs and help card during payment/subscription confirm phases
2026-04-08 22:07:42 +08:00
erio 8e02b123c8 fix(payment): Stripe redirect methods (Alipay) open in new window
When user selects a redirect-based payment method (e.g. Alipay) in the
inline Stripe Element and clicks pay, the payment page opens in a new
window instead of navigating the current page away. The main page
switches to waiting/polling mode. Inline methods (card, WeChat) still
complete directly on the page.
2026-04-08 21:41:24 +08:00
erio d911245679 fix(payment): add cancel order to Stripe inline + widen popup window 2026-04-08 21:30:07 +08:00
erio 384a1b3070 feat(payment): embed Stripe Payment Element inline instead of popup
Stripe payment now shows the Payment Element directly on the purchase
page. User selects payment method (Alipay/WeChat/Card) inline, then
confirms. Redirect-based methods (Alipay) navigate to the payment
page; non-redirect methods (Card/WeChat) complete inline.
2026-04-08 21:26:17 +08:00
erio dc731465d5 fix(ui): widen payment popup window from 520px to 680px 2026-04-08 21:20:11 +08:00
erio aab31329af fix(payment): use global amount range for quick buttons, not per-method
Quick amount buttons and custom input always use the global min/max
range (union of all methods). Payment method availability is
determined by whether the selected amount fits each method's limits.
2026-04-08 21:10:24 +08:00
erio c846eaa444 fix(ui): widen cancel rate limit select dropdowns to prevent text truncation 2026-04-08 21:07:48 +08:00
erio fafde2a493 feat(payment): configurable payment mode (qrcode/redirect/popup)
- EasyPay supports 3 modes: qrcode (API/QR), redirect (new tab), popup (small window)
- Stripe supports 2 modes: popup (small window, default), redirect (new tab)
- Backend passes payment_mode through to create-order response
- Frontend opens pay URL based on configured mode
2026-04-08 18:05:24 +08:00
erio 6dcf14f46a refactor(payment): replace dialog overlay with inline payment status
Payment waiting/QR/success states now render inline on the page
instead of as a modal overlay dialog. The page content switches
between selection mode and payment status mode.
2026-04-08 17:33:01 +08:00
erio be82609939 fix(payment): audit fixes for alipay/wxpay/stripe payment providers
Backend:
- Extract YuanToFen/FenToYuan to payment/amount.go using shopspring/decimal
- Require alipay publicKey in config validation
- Fix wxpay webhook response to return JSON per V3 spec
- Remove wxpay certSerial fallback to publicKeyId
- Define magic strings as named constants in wxpay/alipay providers
- Add slog warning for wxpay H5→Native payment downgrade
- Make EncryptionKey validation return error on invalid (non-empty) key
- Make decryptConfig propagate errors instead of returning nil
- Add idempotency check in doBalance to prevent stuck FAILED retries

Frontend:
- Fix dashboard currency symbol from $ to ¥
- Fix AdminPaymentPlansView any type to proper SubscriptionPlan type
- Make quick amount buttons follow selected payment method limits
- Center help image with larger height and text below
2026-04-08 17:11:32 +08:00
erio 93a43950fe feat(payment): open Stripe and redirect payments in popup window
Instead of navigating the main page away during payment, open Stripe
and EasyPay redirect payments in a popup window while showing a
waiting dialog on the purchase page. Extract POPUP_WINDOW_FEATURES
constant to providerConfig.ts.
2026-04-08 16:33:01 +08:00
erio 0ed9816487 feat(payment): click-to-preview help image with fullscreen overlay 2026-04-08 14:06:19 +08:00
erio 4049b2f695 feat(payment): inline QR code dialog for scan-to-pay mode
QR code payments now display in an inline dialog on the payment page
with countdown and status polling. Success is shown directly without
page navigation. Redirect mode (pay_url only) still navigates to the
polling page as before.
2026-04-08 13:29:02 +08:00