Files
device-voice-h5/openspec/changes/add-alipay-payment-link-flow/specs/alipay-payment-link/spec.md
sexygoat 427b211295
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m0s
fix: pay
2026-05-22 15:16:22 +08:00

59 lines
4.1 KiB
Markdown

## ADDED Requirements
### Requirement: Package payment SHALL support Alipay payment links
The system SHALL allow users to choose Alipay during package purchase and SHALL handle backend Alipay responses through `payment_link` while preserving the existing WeChat and wallet payment branches.
#### Scenario: User pays a package order with Alipay
- **WHEN** the user selects `alipay` in the package payment popup and the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL open or present the returned Alipay payment link for the user
- **AND** the system SHALL NOT require WeChat `pay_config` fields for this branch
#### Scenario: User pays a package order with wallet balance
- **WHEN** the user selects `wallet` and the backend completes the package payment without a third-party redirect
- **THEN** the system SHALL preserve the existing wallet payment success flow
- **AND** the system SHALL refresh relevant wallet-related page state after success
#### Scenario: Strong recharge branch returns an Alipay payment link
- **WHEN** package order creation enters the strong recharge branch and the backend returns `order_type: "recharge"` with `payment_link`
- **THEN** the system SHALL use the Alipay payment-link flow for that recharge branch
- **AND** the system SHALL preserve the existing strong recharge messaging and follow-up refresh behavior
### Requirement: Pending order payment SHALL support Alipay payment links
The system SHALL allow users to continue payment for pending package orders from the order list through an Alipay payment link flow.
#### Scenario: User continues a pending order with Alipay
- **WHEN** the user starts payment for a pending order from the order list and the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL open or present the returned payment link
- **AND** the system SHALL refresh the order list from backend status after the user completes or retries the flow
### Requirement: Wallet recharge flows SHALL support Alipay payment links
The system SHALL support Alipay both when creating a new wallet recharge order and when retrying payment for a pending recharge order.
#### Scenario: User creates a new wallet recharge with Alipay
- **WHEN** the user confirms a wallet recharge with `payment_method: "alipay"` and the backend returns `payment_link`
- **THEN** the system SHALL open or present the returned payment link
- **AND** the system SHALL preserve the existing recharge validation rules and amount checks
#### Scenario: User retries a pending recharge order with Alipay
- **WHEN** the user continues payment for a pending recharge order and the backend returns `payment_link`
- **THEN** the system SHALL open or present the returned Alipay payment link
- **AND** the system SHALL refresh wallet detail and recharge list state from backend data after the user completes or retries the flow
### Requirement: Payment method branching SHALL distinguish WeChat and Alipay contracts
The system SHALL treat WeChat and Alipay payment preparation responses as different contracts and SHALL determine final payment success from backend order or recharge status instead of the redirect result alone.
#### Scenario: WeChat payment returns pay_config
- **WHEN** the backend returns `payment_method: "wechat"` with `pay_config`
- **THEN** the system SHALL continue to use the existing WeChat H5 payment invocation flow
- **AND** the system SHALL preserve the current `app_type` behavior for WeChat requests
#### Scenario: Alipay payment returns payment_link
- **WHEN** the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL use the returned link fields instead of expecting `pay_config`
- **AND** the system SHALL NOT depend on `app_type` for the Alipay branch
#### Scenario: User returns after Alipay jump
- **WHEN** the user comes back to the application after opening the Alipay payment link
- **THEN** the system SHALL refresh the relevant order or recharge data from backend APIs
- **AND** the system SHALL determine whether the payment succeeded from refreshed backend status