支付协议

This commit is contained in:
chen wei bo
2025-08-26 16:41:44 +08:00
parent 1c010f3f7c
commit b1537ea43a
3 changed files with 24 additions and 49 deletions
+7 -19
View File
@@ -5,7 +5,6 @@
import { ApiClient } from "../network/client/ApiClient";
import type { Endpoint } from "../network/client/endpoints";
import type { ApiResponse } from "../network/client/types";
import { OrderStatus, CreateOrderReq, CreateOrderData, QueryOrderData } from "./types";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
export class PaymentApi {
@@ -14,9 +13,9 @@ export class PaymentApi {
private constructor(private api = ApiClient.I) {}
// 下单
createOrder(req: CreateOrderReq): Promise<ApiResponse<CreateOrderData>> {
let epData: Endpoint<CreateOrderReq, { orderId: string; payUrl: string; expireAt?: number; }> = {
path: "pay/create",
createOrder(req: proto.cs.ICSCreateOrderReq): Promise<ApiResponse<proto.cs.ICSCreateOrderRes>> {
let epData: Endpoint<proto.cs.ICSCreateOrderReq, proto.cs.ICSCreateOrderRes> = {
path: "api/logic/createOrder",
method: "POST",
codec: "json",
needsAuth: true,
@@ -25,24 +24,13 @@ export class PaymentApi {
}
// 查询订单
queryOrder(orderId: string): Promise<ApiResponse<QueryOrderData>> {
let epData: Endpoint<{ orderId: string }, { orderId: string; status: OrderStatus; paidAt?: number; failureReason?: string; }> = {
path: "pay/query",
queryOrder(req: proto.cs.ICSQueryOrderReq): Promise<ApiResponse<proto.cs.ICSQueryOrderRes>> {
let epData: Endpoint<proto.cs.ICSQueryOrderReq, proto.cs.ICSQueryOrderRes> = {
path: "api/logic/queryOrder",
method: "POST",
codec: "json",
needsAuth: true,
};
return this.api.call(epData, { orderId });
}
// 取消订单
cancelOrder(orderId: string): Promise<ApiResponse<{ ok: boolean }>> {
let epData: Endpoint<{ orderId: string }, { ok: boolean; }> = {
path: "pay/cancel",
method: "POST",
codec: "json",
needsAuth: true,
};
return this.api.call(epData, { orderId });
return this.api.call(epData, req);
}
}