|
|
|
@ -99,6 +99,8 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
|
|
|
|
bool ok = false; |
|
|
|
String failMsg = '支付失败,请重试'; |
|
|
|
isPaying.value = true; |
|
|
|
_startPayingTimeout(); |
|
|
|
if (method == _PayMethod.wechat) { |
|
|
|
ok = await payWechat(item, onResult: (success, msg) { |
|
|
|
if (!success) failMsg = msg ?? failMsg; |
|
|
|
@ -454,9 +456,13 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
// 先透传给外部回调 |
|
|
|
onResult?.call(success, msg); |
|
|
|
if (success) { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
await _confirmOrderAndShow(orderId, |
|
|
|
channel: '微信', initialMessage: msg); |
|
|
|
} else { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
_showPayResultDialog(false, msg ?? '支付失败'); |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -483,9 +489,13 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
onResult: (success, msg) async { |
|
|
|
onResult?.call(success, msg); |
|
|
|
if (success) { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
await _confirmOrderAndShow(orderId, |
|
|
|
channel: '支付宝', initialMessage: msg); |
|
|
|
} else { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
_showPayResultDialog(false, msg ?? '支付失败'); |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -506,9 +516,6 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
onResult?.call(false, '创建 Apple 订单失败'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
isPaying.value = true; |
|
|
|
_startPayingTimeout(); |
|
|
|
|
|
|
|
// 使用商品id作为内购的 productId(与后台保持一致) |
|
|
|
final productId = item.id; |
|
|
|
// 解析为 App Store 的真实商品ID(支持前缀/映射) |
|
|
|
@ -819,7 +826,10 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
final host = uri.host; |
|
|
|
final path = uri.path; |
|
|
|
if (scheme == 'deepvoiceclient' && host == 'paypal') { |
|
|
|
isPaying.value = false; |
|
|
|
if (path == '/return') { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
print('[PayPal] 检测到 /return,使用 orderId 回查: $orderId'); |
|
|
|
await _confirmOrderAndShow( |
|
|
|
orderId, |
|
|
|
@ -829,6 +839,8 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
intervalMs: 0, |
|
|
|
); |
|
|
|
} else if (path == '/cancel') { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
_showPayResultDialog(false, '已取消支付'); |
|
|
|
} |
|
|
|
// 一次性监听,处理后即取消 |
|
|
|
@ -836,6 +848,8 @@ abstract class GoodsBaseController extends GetxController { |
|
|
|
_deeplinkSub = null; |
|
|
|
} |
|
|
|
}, onError: (e) { |
|
|
|
isPaying.value = false; |
|
|
|
_cancelPayingTimeout(); |
|
|
|
// 忽略监听错误,保持现有轮询逻辑 |
|
|
|
}); |
|
|
|
return _payService.paypalPay( |
|
|
|
|