新增支付流程,新增支付页面等待倒计时,自动检查订单状态等

This commit is contained in:
2025-10-22 17:47:07 +08:00
parent 15d2e1047b
commit 2e7e85fb27
8 changed files with 432 additions and 67 deletions
+6 -3
View File
@@ -38,10 +38,10 @@ abstract class Api {
static const String kr_getPaymentMethods = "/v1/app/payment/methods";
/// 进行下单
static const String kr_purchase = "/v1/app/order/purchase";
static const String kr_purchase = "/v1/public/order/purchase";
/// 获取支付地址,跳转到付款地址
static const String kr_checkout = "/v1/app/order/checkout";
/// 获取支付地址,跳转到付款地址(参考 Tauri 项目)
static const String kr_checkout = "/v1/public/portal/order/checkout";
/// 获取可购买套餐
static const String kr_getPackageList = "/v1/public/subscribe/list";
@@ -61,6 +61,9 @@ abstract class Api {
/// 通过该接口判断订单状态
static const String kr_orderDetail = "/v1/app/order/detail";
/// 查询订单状态(公开接口,参考 Tauri 项目)
static const String kr_queryOrderStatus = "/v1/public/order/detail";
/// 获取消息列表
static const String kr_getMessageList = "/v1/public/announcement/list";
@@ -120,6 +120,27 @@ class KRSubscribeApi {
return right(baseResponse.model);
}
/// 查询订单状态(公开接口,用于支付轮询)
Future<Either<HttpError, KROrderStatus>> kr_queryOrderStatus(
String orderNo) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['order_no'] = orderNo;
BaseResponse<KROrderStatus> baseResponse =
await HttpUtil.getInstance().request<KROrderStatus>(
Api.kr_queryOrderStatus,
data,
method: HttpMethod.GET,
isShowLoading: false,
);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model);
}
/// 获取支付方式
Future<Either<HttpError, List<KRPaymentMethod>>>
kr_getPaymentMethods() async {
@@ -231,14 +252,14 @@ class KRSubscribeApi {
return right(baseResponse.model.orderNo);
}
/// 获取支付地址,跳转到付款地址
Future<Either<HttpError, String>> kr_checkout(String orderId) async {
/// 获取支付地址,跳转到付款地址(新版本:支持多种支付类型)
Future<Either<HttpError, KRCheckoutResponse>> kr_checkout(String orderId) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['orderNo'] = orderId;
data['returnUrl'] = AppConfig.getInstance().baseUrl;
BaseResponse<KRPurchaseOrderUrl> baseResponse =
await HttpUtil.getInstance().request<KRPurchaseOrderUrl>(
BaseResponse<KRCheckoutResponse> baseResponse =
await HttpUtil.getInstance().request<KRCheckoutResponse>(
Api.kr_checkout,
data,
method: HttpMethod.POST,
@@ -249,7 +270,7 @@ class KRSubscribeApi {
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model.url);
return right(baseResponse.model);
}
/// 重置订阅周期