fix(client): dispose 不再静默取消支付订单,redirect launchUrl 加失败兜底
- PaymentFlowController 新增 stopPolling():只停轮询 Timer,不发远程 cancel、 不改 state;PaymentScreen.dispose() 改调它,不再复用 cancel()——离开支付页 (切左导航 tab)不再等同于放弃订单,cancel() 只留给「取消订单」按钮的显式路径。 - redirect 分支 launchUrl 前加 canLaunchUrl 判定 + try-catch,失败时用 showPangolinToast 给可见提示(新增 l10n openAlipayFailed,zh/en 均补)。 - purchase_page.dart::_choose 下单后严格判 phase == awaitingPayment 才跳转 支付页,建单失败(failed)不再误跳。 - 回归测试:payment_pages_test.dart 补两条用例区分 dispose(不触发 cancel、 state 不归 idle)与「取消订单」按钮(远程 cancel + state 归 idle); payment_flow_test.dart 补 stopPolling() 单元测试。
This commit is contained in:
@@ -138,6 +138,11 @@ class PaymentFlowController extends StateNotifier<PaymentFlowState> {
|
||||
if (mounted) state = const PaymentFlowState();
|
||||
}
|
||||
|
||||
/// 只停轮询 Timer,**不**远程 cancel、**不**改 state——供支付页 dispose()
|
||||
/// 用(离开页面 ≠ 放弃订单)。与 [cancel] 区分:后者是「取消订单」按钮的显式
|
||||
/// 放弃路径(远程 cancel + 状态归 idle)。
|
||||
void stopPolling() => _stopPolling();
|
||||
|
||||
/// 单拍轮询(Timer 驱动;测试直接调用,不依赖真实时钟)。
|
||||
Future<void> pollOnce() async {
|
||||
final order = state.order;
|
||||
|
||||
Reference in New Issue
Block a user