flutterwave_v3_models/validate_charge/
mod.rs

1use crate::common::card_data_res::ResCardData;
2use serde::{Deserialize, Serialize};
3use validator::Validate;
4use crate::{
5    common::payload::Payload,
6    fwcall::{FwCall, ToFwCall},
7};
8use std::borrow::Cow;
9
10
11#[derive(Debug, Serialize, Deserialize, Validate)]
12pub struct ValidateChargeReq {
13    #[validate(length(min = 6, max = 6))]
14    pub otp: String,
15    pub flw_ref: String,
16    #[serde(rename = "type")]
17    pub charge_type: String,
18}
19
20
21#[derive(Debug, Serialize, Deserialize)]
22pub struct ValidateChargeRes {
23    pub status: String,
24    pub message: String,
25    pub data: ValidateChargeResData,
26}
27
28#[derive(Debug, Serialize, Deserialize)]
29pub struct ValidateChargeResData {
30    id: i32,
31    tx_ref: String,
32    flw_ref: String,
33    device_fingerprint: String,
34    amount: i32,
35    charge_amount: i32,
36    app_fee: i32,
37    merchant_fee: i32,
38    processor_response: String,
39    auth_model: String,
40    currency: String,
41    ip: String,
42    narration: String,
43    status: String,
44    auth_url: String,
45    payment_type: String,
46    fraud_status: String,
47    charge_type: String,
48    created_at: String,
49    account_id: i32,
50    customer: ResponseCustomerData,
51    card: ResCardData,
52}
53
54#[derive(Debug, Serialize, Deserialize)]
55pub struct ResponseCustomerData {
56    id: i32,
57    phone_number: String,
58    name: String,
59    email: String,
60    created_at: String,
61}
62
63impl<'a> ToFwCall<'a> for ValidateChargeReq {
64    type ApiRequest = Self;
65
66    type ApiResponse = ValidateChargeRes;
67
68    fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
69        FwCall::new(
70            Cow::Borrowed("/v3/validate-charge"),
71            reqwest::Method::POST,
72            Some(Payload::Plain(self)),
73        )
74    }
75}