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
use std::fmt::{Display, Formatter, Result as FmtResult};
#[derive(Debug)]
pub enum CommandId {
TransactionReversal,
SalaryPayment,
BusinessPayment,
PromotionPayment,
AccountBalance,
CustomerPayBillOnline,
TransactionStatusQuery,
CheckIdentity,
BusinessPayBill,
BusinessBuyGoods,
DisburseFundsToBusiness,
BusinessToBusinessTransfer,
BusinessTransferFromMMFToUtility,
}
impl Display for CommandId {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{:?}", self)
}
}
#[derive(Debug)]
pub enum IdentifierTypes {
MSISDN = 1,
TillNumber = 2,
Shortcode = 4,
}
impl IdentifierTypes {
pub fn get_code(&self) -> &str {
match self {
IdentifierTypes::MSISDN => "1",
IdentifierTypes::TillNumber => "2",
IdentifierTypes::Shortcode => "4",
}
}
}
impl Display for IdentifierTypes {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{:?}", self.get_code())
}
}
#[derive(Debug)]
pub enum MpesaResponseCode {
Success = 0,
InsufficientFunds = 1,
LessThanMinimum = 2,
MoreThanMaximum = 3,
ExceededDailyLimit = 4,
ExceededMinimumBalance = 5,
UnresolvedPrimaryParty = 6,
UnresolvedReceiverParty = 7,
ExceededMaximumBalance = 8,
InvalidDebitAccount = 11,
InvalidCreditAccount = 12,
UnresolvedDebitAccount = 13,
UnresolvedCreditAccount = 14,
DuplicateDetected = 15,
InternalFailure = 17,
UnresolvedInitiator = 20,
TrafficBlocking = 26,
}
impl Display for MpesaResponseCode {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{:?}", self)
}
}