1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use strum_macros::EnumString;
use uuid::Uuid;
/// Represents a payment in the Lago billing system.
///
/// A payment records a monetary transaction associated with an invoice
/// or payment request.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Payment {
/// Unique identifier for the payment in Lago.
pub lago_id: Uuid,
/// Unique identifier of the customer in Lago.
pub lago_customer_id: Uuid,
/// The customer external unique identifier.
pub external_customer_id: String,
/// List of invoice IDs associated with the payment.
pub invoice_ids: Vec<Uuid>,
/// The unique identifier of the paid resource in Lago.
pub lago_payable_id: Uuid,
/// The type of the paid resource (Invoice or PaymentRequest).
pub payable_type: PayableType,
/// The amount of the payment in cents.
pub amount_cents: i64,
/// The currency of the payment amount.
pub amount_currency: String,
/// The status of the payment within the payment provider.
pub status: String,
/// The normalized payment status by Lago.
pub payment_status: PaymentStatus,
/// The type of payment (manual or provider).
#[serde(rename = "type")]
pub payment_type: PaymentType,
/// Reference for the payment.
pub reference: Option<String>,
/// Code of the payment provider.
pub payment_provider_code: Option<String>,
/// The type of payment provider.
pub payment_provider_type: Option<PaymentProviderType>,
/// DEPRECATED: use provider_payment_id.
pub external_payment_id: Option<String>,
/// Unique identifier of the payment within the payment provider.
pub provider_payment_id: Option<String>,
/// Unique identifier of the customer within the payment provider.
pub provider_customer_id: Option<String>,
/// The next action to be taken by the customer to complete the payment.
pub next_action: Option<Value>,
/// When the payment was created.
pub created_at: DateTime<Utc>,
}
/// The type of the paid resource.
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
pub enum PayableType {
/// An invoice payment.
Invoice,
/// A payment request.
PaymentRequest,
}
/// The normalized payment status by Lago.
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum PaymentStatus {
/// Payment succeeded.
Succeeded,
/// Payment failed.
Failed,
/// Payment is pending.
Pending,
/// Payment is being processed.
Processing,
}
/// The type of payment.
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum PaymentType {
/// Manual payment.
Manual,
/// Payment through a provider.
Provider,
}
/// The type of payment provider.
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum PaymentProviderType {
/// Adyen payment provider.
#[serde(alias = "PaymentProviders::AdyenProvider")]
Adyen,
/// Cashfree payment provider.
#[serde(alias = "PaymentProviders::CashfreeProvider")]
Cashfree,
/// GoCardless payment provider.
#[serde(alias = "PaymentProviders::GocardlessProvider")]
Gocardless,
/// Stripe payment provider.
#[serde(alias = "PaymentProviders::StripeProvider")]
Stripe,
/// Flutterwave payment provider.
#[serde(alias = "PaymentProviders::FlutterwaveProvider")]
Flutterwave,
/// MoneyHash payment provider.
#[serde(alias = "PaymentProviders::MoneyhashProvider")]
Moneyhash,
}