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
//! Response
//! ==========
//! This file contains the structs needed to represent the different response
//! of the Paystack API.
//!
//!

use serde::{Deserialize, Serialize};

/// This struct represents the response of the Paystack transaction initalization.
#[derive(Deserialize, Debug, Clone)]
pub struct TransactionResponse {
    pub status: bool,
    pub message: String,
    pub data: TransactionResponseData,
}

/// This struct represents the data of the transaction response
#[derive(Deserialize, Debug, Clone)]
pub struct TransactionResponseData {
    pub authorization_url: String,
    pub access_code: String,
    pub reference: String,
}

/// This struct represents the transaction status response
#[derive(Deserialize, Debug, Clone)]
pub struct TransactionStatus {
    pub status: bool,
    pub message: String,
    pub data: TransactionStatusData,
}

/// This struct represents a list of transaction status
#[derive(Deserialize, Debug, Clone)]
pub struct TransactionStatusList {
    pub status: bool,
    pub message: String,
    pub data: Vec<TransactionStatusData>,
}

/// This struct represents the data of the transaction status response
#[derive(Deserialize, Debug, Clone)]
pub struct TransactionStatusData {
    pub id: Option<u32>,
    pub status: Option<String>,
    pub reference: Option<String>,
    pub amount: Option<u32>,
    pub message: Option<String>,
    pub gateway_response: Option<String>,
    pub paid_at: Option<String>,
    pub created_at: Option<String>,
    pub channel: Option<String>,
    pub currency: Option<String>,
    pub ip_address: Option<String>,
    pub metadata: Option<String>,
    pub fees: Option<i32>,
    pub customer: Option<Customer>,
    pub authorization: Option<Authorization>,
}

/// This struct represents the authorization data of the transaction status response
#[derive(Debug, Deserialize, Clone)]
pub struct Authorization {
    pub authorization_code: Option<String>,
    pub bin: Option<String>,
    pub last4: Option<String>,
    pub exp_month: Option<String>,
    pub exp_year: Option<String>,
    pub channel: Option<String>,
    pub card_type: Option<String>,
    pub bank: Option<String>,
    pub country_code: Option<String>,
    pub brand: Option<String>,
    pub reusable: Option<bool>,
    pub signature: Option<String>,
    pub account_name: Option<String>,
}

/// This struct represents the Paystack customer data
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Customer {
    pub id: Option<u32>,
    pub first_name: Option<String>,
    pub last_name: Option<String>,
    pub email: Option<String>,
    pub customer_code: String,
    pub phone: Option<String>,
    pub metadata: Option<String>,
    pub risk_action: Option<String>,
    pub international_format_phone: Option<String>,
}