flutterwave_v3_models/transactions/
transaction_verify.rs1use serde::{Deserialize, Serialize};
2use validator::Validate;
3use crate::fwcall::{FwCall, ToFwCall};
4use std::borrow::Cow;
5
6#[derive(Debug, Serialize, Deserialize, Validate)]
7pub struct VerifyTransByIdReq {
8 pub trans_id: i32,
9}
10
11#[derive(Debug, Serialize, Deserialize, Validate)]
12pub struct VerifyTransByTxRefReq {
13 pub tx_ref: String,
14}
15
16
17#[derive(Serialize, Deserialize)]
18pub struct VerifyTransRes {
19 pub status: String,
20 pub message: String,
21 pub data: VerifyTransResData,
22}
23
24#[derive(Serialize, Deserialize)]
25pub struct VerifyTransResData {
26 pub id: i64,
27 pub tx_ref: String,
28 pub flw_ref: String,
29 pub device_fingerprint: String,
30 pub amount: i64,
31 pub currency: String,
32 pub charged_amount: i64,
33 pub app_fee: f64,
34 pub merchant_fee: i64,
35 pub processor_response: String,
36 pub auth_model: String,
37 pub ip: String,
38 pub narration: String,
39 pub status: String,
40 pub payment_type: String,
41 pub created_at: String,
42 pub account_id: i64,
43 pub card: Card,
44 pub meta: Option<String>,
45 pub amount_settled: f64,
46 pub customer: Customer,
47}
48
49#[derive(Serialize, Deserialize)]
50pub struct Card {
51 #[serde(rename = "first_6digits")]
52 pub first_6_digits: String,
53 #[serde(rename = "last_4digits")]
54 pub last_4_digits: String,
55 pub issuer: String,
56 pub country: String,
57 #[serde(rename = "type")]
58 pub card_type: String,
59 pub token: String,
60 pub expiry: String,
61}
62
63#[derive(Serialize, Deserialize)]
64pub struct Customer {
65 pub id: i64,
66 pub name: String,
67 pub phone_number: String,
68 pub email: String,
69 pub created_at: String,
70}
71
72impl<'a> ToFwCall<'a> for VerifyTransByIdReq {
73 type ApiRequest = Self;
74
75 type ApiResponse = VerifyTransRes;
76
77 fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
78 FwCall::new(
79 Cow::Owned(format!("/v3/transactions/{}/verify", self.trans_id)),
80 reqwest::Method::GET,
81 None,
82 )
83 }
84}
85
86impl<'a> ToFwCall<'a> for VerifyTransByTxRefReq {
87 type ApiRequest = Self;
88
89 type ApiResponse = VerifyTransRes;
90
91 fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
92 FwCall::new(
93 Cow::Owned(format!(
94 "/v3/transactions/verify_by_reference?tx_ref={}",
95 self.tx_ref
96 )),
97 reqwest::Method::GET,
98 None,
99 )
100 }
101}