payment_kit/
models.rs

1use serde::{Deserialize, Serialize};
2use crate::status::PaymentStatus;
3
4/// Represents the supported types of payment instruments.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub enum PaymentInstrument {
7    CreditCard { provider: String },
8    VirtualAccount { provider: String },
9    BankTransfer { provider: String },
10    EWallet { provider: String },
11    Custom { provider: String },
12}
13
14/// Payload sent to initiate a payment transaction.
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct PaymentRequest {
17    pub order_id: String,
18    pub amount: u64,
19    pub currency: String,
20    pub payment_instrument: PaymentInstrument,
21    pub customer_id: Option<String>,
22    pub description: Option<String>,
23    pub metadata: Option<serde_json::Value>,
24}
25
26/// Response returned after successfully creating a payment.
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct PaymentResponse {
29    pub transaction_id: String,
30    pub amount: u64,
31    pub payment_instrument: PaymentInstrument,
32    pub status: PaymentStatus,
33    pub redirect_url: Option<String>,
34}
35
36/// Request payload to initiate a refund.
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct RefundRequest {
39    pub transaction_id: String,
40    pub amount: u64,
41    pub reason: Option<String>,
42}
43
44/// Response returned after processing a refund.
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct RefundResponse {
47    pub refund_id: String,
48    pub status: PaymentStatus,
49    pub transaction_id: String,
50    pub refunded: bool,
51}