Skip to main content

tapsilat/types/
payment.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct Payment {
5    pub id: String,
6    pub amount: f64,
7    pub currency: String,
8    pub status: PaymentStatus,
9    pub description: Option<String>,
10    pub customer_id: Option<String>,
11    pub created_at: String,
12    pub updated_at: String,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub enum PaymentStatus {
17    #[serde(rename = "pending")]
18    Pending,
19    #[serde(rename = "processing")]
20    Processing,
21    #[serde(rename = "completed")]
22    Completed,
23    #[serde(rename = "failed")]
24    Failed,
25    #[serde(rename = "cancelled")]
26    Cancelled,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct CreatePaymentRequest {
31    pub amount: f64,
32    pub currency: String,
33    pub description: Option<String>,
34    pub customer_id: Option<String>,
35    pub callback_url: Option<String>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct PaymentResponse {
40    pub payment: Payment,
41    pub checkout_url: Option<String>,
42}