flutterwave_v3_models/charge/
ach.rs1use crate::{
2 common::payload::Payload,
3 fwcall::{FwCall, ToFwCall},
4};
5use std::borrow::Cow;
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8use validator::Validate;
9use crate::common::customer::CustomerData;
10
11#[derive(Debug, Serialize, Deserialize, Validate)]
12pub struct AchReq {
13 pub amount: i32,
14 pub currency: String,
15 pub email: String,
16 pub tx_ref: String,
17 pub fullname: String,
18 pub phone_number: String,
19 pub client_ip: String,
20 pub device_fingerprint: String,
21 pub meta: HashMap<String, String>,
22 pub redirect_url: String,
23 pub country: String,
24}
25
26impl<'a> ToFwCall<'a> for AchReq {
27 type ApiRequest = Self;
28
29 type ApiResponse = AchRes;
30
31 fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
32 FwCall::new(
33 Cow::Borrowed("/v3/charges?type=ach_payment"),
34 reqwest::Method::PUT,
35 Some(Payload::Plain(self)),
36 )
37 }
38}
39
40#[derive(Debug, Serialize, Deserialize)]
41pub struct AchRes {
42 pub status: String,
43 pub message: String,
44 pub data: AchResData,
45 pub meta: AchResMeta
46}
47
48#[derive(Debug, Serialize, Deserialize)]
49pub struct AchResMeta {
50 pub authorization: AchResAuthorization
51}
52
53#[derive(Debug, Serialize, Deserialize)]
54pub struct AchResAuthorization {
55 pub mode: String,
56 pub redirect: String,
57 pub validate_instructions: String
58}
59
60#[derive(Debug, Serialize, Deserialize)]
61pub struct AchResData {
62 pub id: i64,
63 pub tx_ref: String,
64 pub flw_ref: String,
65 pub device_fingerprint: String,
66 pub amount: i64,
67 pub charged_amount: i64,
68 pub app_fee: f64,
69 pub merchant_fee: i64,
70 pub processor_response: String,
71 pub auth_model: String,
72 pub auth_url: String,
73 pub currency: String,
74 pub ip: String,
75 pub narration: String,
76 pub status: String,
77 pub payment_type: String,
78 pub fraud_status: String,
79 pub charge_type: String,
80 pub created_at: String,
81 pub account_id: i64,
82 pub redirect_url: String,
83 pub customer: CustomerData,
84}