Skip to content

Add Alipay top-up integration - #4952

Closed
ZacBi wants to merge 1 commit into
QuantumNous:mainfrom
ZacBi:feature/alipay-epay-style
Closed

Add Alipay top-up integration#4952
ZacBi wants to merge 1 commit into
QuantumNous:mainfrom
ZacBi:feature/alipay-epay-style

Conversation

@ZacBi

@ZacBi ZacBi commented May 18, 2026

Copy link
Copy Markdown

Summary

  • add direct Alipay page-pay top-up integration with async notify handling
  • add admin settings for Alipay credentials and callback configuration
  • keep wallet UI consistent with existing EPay-style payment methods
  • ignore local Codex/work output directories in .gitignore

Summary by CodeRabbit

  • New Features
    • Added Alipay as a payment method for user top-ups
    • Administrators can now configure Alipay integration with credentials and webhook URLs in system settings
    • Enhanced payment processing to support flexible HTTP methods (GET/POST) for improved payment gateway compatibility

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 929eee4f-26ed-45d5-9006-6c8c7cf91806

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd0d3b and 4212400.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (18)
  • .gitignore
  • controller/option.go
  • controller/payment_webhook_availability.go
  • controller/topup.go
  • controller/topup_alipay.go
  • go.mod
  • model/option.go
  • model/topup.go
  • router/api-router.go
  • setting/payment_alipay.go
  • web/default/src/features/system-settings/billing/index.tsx
  • web/default/src/features/system-settings/billing/section-registry.tsx
  • web/default/src/features/system-settings/integrations/payment-settings-section.tsx
  • web/default/src/features/system-settings/types.ts
  • web/default/src/features/wallet/api.ts
  • web/default/src/features/wallet/hooks/use-payment.ts
  • web/default/src/features/wallet/lib/payment.ts
  • web/default/src/features/wallet/types.ts

Walkthrough

This PR integrates Alipay as a payment method for user top-ups. It adds Alipay constants and configuration variables, implements webhook availability checks and option management, wires Alipay request routing and callback processing with signature verification and quota crediting, extends frontend payment form submission to support HTTP method selection (GET/POST), and provides an admin settings UI for Alipay credential configuration.

Changes

Alipay Top-Up Integration

Layer / File(s) Summary
Constants, configuration variables, and dependencies
model/topup.go, setting/payment_alipay.go, go.mod
Payment method/provider constants (PaymentMethodAlipay, PaymentProviderAlipay) and Alipay configuration variables (app ID, private/public keys, sandbox mode, notify/return URLs) are added; go.mod imports Alipay client dependencies from github.com/smartwalle/.
Alipay configuration validation and option management
controller/payment_webhook_availability.go, controller/option.go, model/option.go
Validation helpers check Alipay credential completeness and pay-method enrollment; AlipayPublicKey is treated as a visible (non-sensitive) key option; runtime option map initialization and update handlers wire Alipay settings for persistence and retrieval.
Alipay payment request and webhook processing
controller/topup.go, controller/topup_alipay.go, router/api-router.go
Top-up request filtering and routing direct Alipay payments to a dedicated handler; client initialization and callback URL resolution use configured/default values; requestAlipayPagePay builds page-pay requests, persists pending records, and returns payment URLs; AlipayNotify webhook validates signatures, verifies trade status, matches callback amounts to stored records (2-decimal precision), updates completion status, calculates and credits user quota, and logs results; POST /api/user/alipay/notify endpoint is registered.
Frontend payment form HTTP method selection
web/default/src/features/wallet/types.ts, web/default/src/features/wallet/api.ts, web/default/src/features/wallet/lib/payment.ts, web/default/src/features/wallet/hooks/use-payment.ts
PaymentResponse type includes optional method field; requestPayment API extracts method from response; submitPaymentForm accepts method parameter and applies it to form submission (defaulting to POST); payment hook passes method from response.
Admin settings UI for Alipay configuration
web/default/src/features/system-settings/types.ts, web/default/src/features/system-settings/billing/index.tsx, web/default/src/features/system-settings/billing/section-registry.tsx, web/default/src/features/system-settings/integrations/payment-settings-section.tsx
BillingSettings type extended with Alipay credential and callback fields; billing defaults and section registry populate Alipay values; payment settings form includes Alipay schema with URL validation; dedicated saveAlipaySettings handler and unified onSubmit both support selective persistence of changed Alipay fields (private key only when provided); "Alipay Gateway" UI section renders credential textareas, sandbox toggle, callback URL inputs, and save button.
Project artifacts
.gitignore
Adds ignore patterns for .codex/, output/, and skills/ directories.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • QuantumNous/new-api#1976: Both PRs modify the top-up flow around controller/topup.go's RequestEpay/top-up record handling by extending payment-method/provider support (main adds Alipay redirects/constants; retrieved adds PaymentMethod plumbing and admin completion/history based on those methods).
  • QuantumNous/new-api#1957: Both PRs modify the top-up flow in controller/topup.go—notably RequestEpay—so the Alipay redirect/behavior in the main PR overlaps with the quota_display_type/token-amount handling introduced in #1957.
  • QuantumNous/new-api#4089: Both PRs update controller/topup.go to conditionally include specific online/top-up payment methods and adjust GetTopUpInfo's enablement/available-methods response fields (Alipay vs Waffo Pancake).

Suggested reviewers

  • Calcium-Ion
  • seefs001
  • creamlike1024

Poem

🐰 A rabbit hops through payment flows,
With Alipay now the system knows,
From webhook ACKs to quota gains,
Each admin switch and form sustains,
The payment path that brings delight!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feature/alipay-epay-style

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ZacBi ZacBi closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant