paymentlib/nswcpp/jsonb/
notification_details.rs

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
use crate::nswcpp::jsonb::gateway_response::GatewayResponse;
use crate::nswcpp::jsonb::payment_components::PaymentComponents;

use serde::{Deserialize, Serialize};

use crate::nswcpp::enums::status::Status;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct NotificationDetails {
    pub payment_reference: String,
    pub status: Status,
    pub payment_completion_reference: String,
    pub requested_amount: f64,
    pub amount: f64,
    pub total_surcharge: f64,
    pub payment_components: Vec<PaymentComponents>,
    pub agency_transaction_id: String,
    pub calling_system: String,
    pub customer_reference: String,
    pub gateway_response: Vec<GatewayResponse>,
}

impl NotificationDetails {
    pub fn normalize(&self) -> NotificationDetails {
        NotificationDetails {
            payment_reference: self.payment_reference.clone(),
            status: self.status.clone(),
            payment_completion_reference: self.payment_completion_reference.clone(),
            requested_amount: self.requested_amount,
            amount: self.amount,
            total_surcharge: self.total_surcharge,
            payment_components: self.payment_components.clone(),
            agency_transaction_id: self.agency_transaction_id.clone(),
            calling_system: self.calling_system.clone(),
            customer_reference: self.customer_reference.clone(),
            gateway_response: self.gateway_response.clone(),
        }
    }
}