paystack/models/charge.rs
1//! Charge
2//! ===========
3//! This file contains all the structs and definitions needed to
4//! create charges using the Paystack API.
5
6use crate::{Channel, Currency};
7use derive_builder::Builder;
8use serde::Serialize;
9
10/// This struct is used to create a charge body for creating a Charge Authorization using the Paystack API.
11/// The struct is constructed using the `ChargeBodyBuilder`
12#[derive(Serialize, Debug, Builder)]
13pub struct ChargeBody {
14 /// Customer's email address
15 email: String,
16 /// Amount should be in the smallest unit of the currency e.g. kobo if in NGN and cents if in USD
17 amount: String,
18 /// Valid authorization code to charge
19 authorization_code: String,
20 /// Unique transaction reference. Only `-`, `.`, `=` and alphanumeric characters allowed.
21 #[builder(default = "None")]
22 reference: Option<String>,
23 /// Currency in which amount should be charged.
24 #[builder(default = "None")]
25 currency: Option<Currency>,
26 /// Stringified JSON object.
27 /// Add a custom_fields attribute which has an array of objects if you would like the fields to be added to your transaction
28 /// when displayed on the dashboard.
29 /// Sample: {"custom_fields":[{"display_name":"Cart ID","variable_name": "cart_id","value": "8393"}]}
30 #[builder(default = "None")]
31 metadata: Option<String>,
32 /// Send us 'card' or 'bank' or 'card','bank' as an array to specify what options to show the user paying
33 #[builder(default = "None")]
34 channel: Option<Vec<Channel>>,
35 /// The code for the subaccount that owns the payment. e.g. `ACCT_8f4s1eq7ml6rlzj`
36 #[builder(default = "None")]
37 subaccount: Option<String>,
38 /// A flat fee to charge the subaccount for this transaction in the subunit of the supported currency.
39 /// This overrides the split percentage set when the subaccount was created.
40 /// Ideally, you will need to use this if you are splitting in flat rates (since subaccount creation only allows for percentage split).
41 #[builder(default = "None")]
42 transaction_charge: Option<u32>,
43 /// Who bears Paystack charges? account or subaccount (defaults to account).
44 #[builder(default = "None")]
45 bearer: Option<String>,
46 /// If you are making a scheduled charge call, it is a good idea to queue them so the processing system does not
47 /// get overloaded causing transaction processing errors.
48 /// Send queue:true to take advantage of our queued charging.
49 #[builder(default = "None")]
50 queue: Option<bool>,
51}