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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// A bank-name entry in the bundled Razorpay snapshot.
pub struct Bank(pub(crate) u32);
impl Bank {
fn row(self) -> crate::snapshot::BankNameView {
crate::snapshot::bank_name(self.0).expect("valid bank handle")
}
/// Returns the bank code.
pub fn code(self) -> crate::BankCode {
self.row().code()
}
/// Returns Razorpay's reported bank name.
pub fn name(self) -> &'static str {
self.row().name()
}
/// Returns separate bank-level metadata when Razorpay reports it.
pub fn profile(self) -> Option<BankProfile> {
self.code().profile()
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// Bank-level metadata reported by Razorpay.
pub struct BankProfile(pub(crate) u32);
impl BankProfile {
fn row(self) -> crate::snapshot::BankView {
crate::snapshot::bank_profile(self.0).expect("valid profile handle")
}
/// Returns the profile's bank code.
pub fn code(self) -> crate::BankCode {
self.row().code()
}
/// Returns the corresponding bank-name entry.
pub fn bank(self) -> Bank {
self.code().bank().expect("generated bank name")
}
/// Returns Razorpay's bank classification.
pub fn kind(self) -> BankKind {
self.row().kind()
}
/// Returns Razorpay's reference IFSC, if reported and well formed.
pub fn reference_ifsc(self) -> Option<crate::Ifsc> {
self.row().reference_ifsc()
}
/// Returns the reported MICR value without numeric interpretation.
pub fn micr(self) -> Option<&'static str> {
self.row().text(0)
}
/// Returns the reported issuer identification number as text.
pub fn iin(self) -> Option<&'static str> {
self.row().text(1)
}
/// Returns Razorpay's tri-state report for a bank-level service.
pub fn reported_status(self, service: BankService) -> ReportedStatus {
self.row().status(service)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// A bank classification reported by Razorpay.
pub enum BankKind {
/// A district central cooperative bank.
DistrictCentralCooperative,
/// A foreign bank.
Foreign,
/// A local area bank.
LocalArea,
/// A bank in Razorpay's other urban cooperative category.
OtherUrbanCooperative,
/// A payments bank.
Payments,
/// A public-sector bank.
PublicSector,
/// A private-sector bank.
Private,
/// A regional rural bank.
RegionalRural,
/// A scheduled urban cooperative bank.
ScheduledUrbanCooperative,
/// A state cooperative bank.
StateCooperative,
/// A small finance bank.
SmallFinance,
}
impl BankKind {
/// Returns Razorpay's source code for this classification.
pub const fn source_code(self) -> &'static str {
match self {
Self::DistrictCentralCooperative => "DCCB",
Self::Foreign => "Foreign",
Self::LocalArea => "LAB",
Self::OtherUrbanCooperative => "O-UCB",
Self::Payments => "PB",
Self::PublicSector => "PSB",
Self::Private => "Private",
Self::RegionalRural => "RRB",
Self::ScheduledUrbanCooperative => "S-UCB",
Self::StateCooperative => "SCB",
Self::SmallFinance => "SFB",
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// A bank-level service represented in Razorpay metadata.
pub enum BankService {
/// Automated Clearing House credit.
AchCredit,
/// Automated Clearing House debit.
AchDebit,
/// Aadhaar Payment Bridge System.
Apbs,
/// National Automated Clearing House debit.
NachDebit,
/// Unified Payments Interface.
Upi,
/// Immediate Payment Service.
Imps,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// Razorpay's reported state for a bank-level service.
pub enum ReportedStatus {
/// Razorpay reports the service as available.
Available,
/// Razorpay reports the service as unavailable.
Unavailable,
/// Razorpay does not report this service for the bank.
NotReported,
}