| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { z } from 'zod';
- // 支付创建请求Schema
- export const PaymentCreateRequestSchema = z.object({
- orderId: z.number().int().positive(),
- totalAmount: z.number().int().positive(),
- description: z.string().min(1).max(128)
- });
- export type PaymentCreateRequest = z.infer<typeof PaymentCreateRequestSchema>;
- // 支付创建响应Schema
- export const PaymentCreateResponseSchema = z.object({
- paymentId: z.string(),
- timeStamp: z.string(),
- nonceStr: z.string(),
- package: z.string(),
- signType: z.string(),
- paySign: z.string(),
- totalAmount: z.number()
- });
- export type PaymentCreateResponse = z.infer<typeof PaymentCreateResponseSchema>;
- // 支付状态查询响应Schema
- export const PaymentStatusResponseSchema = z.object({
- paymentStatus: z.enum(['待支付', '支付中', '已支付', '支付失败', '已退款', '已关闭'])
- });
- export type PaymentStatusResponse = z.infer<typeof PaymentStatusResponseSchema>;
- // 支付回调请求Schema
- export const PaymentCallbackRequestSchema = z.object({
- id: z.string(),
- create_time: z.string(),
- event_type: z.string(),
- resource_type: z.string(),
- resource: z.object({
- algorithm: z.string(),
- ciphertext: z.string(),
- associated_data: z.string().optional(),
- nonce: z.string()
- }),
- summary: z.string()
- });
- export type PaymentCallbackRequest = z.infer<typeof PaymentCallbackRequestSchema>;
|