Files
18xchat/assets/Scripts/chat18x/payment/PaymentApi.ts
T
2025-08-26 16:41:44 +08:00

37 lines
1.2 KiB
TypeScript

/**
* 和服务器交互的API接口
*
*/
import { ApiClient } from "../network/client/ApiClient";
import type { Endpoint } from "../network/client/endpoints";
import type { ApiResponse } from "../network/client/types";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
export class PaymentApi {
private static _I: PaymentApi | null = null;
static get I() { return this._I ?? (this._I = new PaymentApi()); }
private constructor(private api = ApiClient.I) {}
// 下单
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,
};
return this.api.call(epData, req);
}
// 查询订单
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, req);
}
}