async_mpesa/
types.rs

1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::error::MpesaError;
5
6#[allow(non_snake_case)]
7#[derive(Debug, Builder, Serialize, Clone)]
8#[builder(name = "AccountBalanceRequestArgs")]
9#[builder(pattern = "mutable")]
10#[builder(setter(into, strip_option))]
11#[builder(derive(Debug))]
12#[builder(build_fn(error = "MpesaError"))]
13pub struct AccountBalanceRequest {
14    pub CommandID: String,
15    pub PartyA: String,
16    pub IdentifierType: String,
17    pub Remarks: String,
18    pub Initiator: String,
19    pub SecurityCredential: String,
20    pub QueueTimeoutURL: String,
21    pub ResultURL: String
22}
23
24#[allow(non_snake_case)]
25#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
26pub struct AccountBalanceResponse {
27    pub OriginatorConversationID: String,
28    pub ConversationID: String,
29    pub ResponseCode: u16,
30    pub ResponseDescription: String
31}
32
33#[allow(non_snake_case)]
34#[derive(Debug, Builder, Serialize, Clone)]
35#[builder(name = "ExpressPushRequestArgs")]
36#[builder(pattern = "mutable")]
37#[builder(setter(into, strip_option))]
38#[builder(derive(Debug))]
39#[builder(build_fn(error = "MpesaError"))]
40pub struct ExpressPushRequest {
41    pub BusinessShortCode: String,
42    pub Password: String,
43    pub Timestamp: String,
44    pub TransactionType: String,
45    pub Amount: String,
46    pub PartyA: String,
47    pub PartyB: String,
48    pub PhoneNumber: String,
49    pub CallBackURL: String,
50    pub AccountReference: String,
51    pub TransactionDesc: String
52}
53
54#[allow(non_snake_case)]
55#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
56pub struct ExpressPushResponse {
57    MerchantRequestID: String,
58    CheckoutRequestID: String,
59    ResponseCode: String,
60    ResponseDescription: String,
61    CustomerMessage: String
62}
63
64#[allow(non_snake_case)]
65#[derive(Debug, Builder, Serialize, Clone)]
66#[builder(name = "B2CRequestArgs")]
67#[builder(pattern = "mutable")]
68#[builder(setter(into, strip_option))]
69#[builder(derive(Debug))]
70#[builder(build_fn(error = "MpesaError"))]
71pub struct B2CRequest {
72    pub InitiatorName: String,
73    pub SecurityCredential: String,
74    pub CommandID: String,
75    pub Amount: String,
76    pub PartyA: String,
77    pub PartyB: String,
78    pub Remarks: String,
79    pub QueueTimeOutURL: String,
80    pub ResultURL: String,
81    pub Occassion: String
82}
83
84#[allow(non_snake_case)]
85#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
86pub struct B2CResponse {
87    pub OriginatorConversationID: String,
88    pub ConversationID: String,
89    pub ResponseDescription: String
90}
91
92#[allow(non_snake_case)]
93#[derive(Debug, Builder, Serialize, Clone)]
94#[builder(name = "ExpressQueryRequestArgs")]
95#[builder(pattern = "mutable")]
96#[builder(setter(into, strip_option))]
97#[builder(derive(Debug))]
98#[builder(build_fn(error = "MpesaError"))]
99pub struct ExpressQueryRequest {
100    pub BusinessShortCode: String,
101    /// Base64 encoding
102    pub Password: String,
103    /// Timesatmp of the transaction whose status is being checked 
104    pub Timestamp: String,
105    pub CheckoutRequestID: String
106}
107
108#[allow(non_snake_case)]
109#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
110pub struct ExpressQueryResponse {
111    pub ResponseCode: i16,
112    pub ResponseDescription: String,
113    pub MerchantRequestID: String,
114    pub CheckoutRequestID: String,
115    pub ResultCode: i16,
116    pub ResultDesc: String
117}
118
119#[allow(non_snake_case)]
120#[derive(Debug, Builder, Serialize, Clone)]
121#[builder(name = "QRRequestArgs")]
122#[builder(pattern = "mutable")]
123#[builder(setter(into, strip_option))]
124#[builder(derive(Debug))]
125#[builder(build_fn(error = "MpesaError"))]
126pub struct QRRequest {
127    pub MerchantName: String,
128    pub RefNo: String,
129    pub Amount: String,
130    pub TrxCode: String,
131    pub CPI: String,
132    pub Size: String
133}
134
135#[allow(non_snake_case)]
136#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
137pub struct QRResponse {
138    pub ResponseCode: i16,
139    pub RequestID: String,
140    pub ResponseDescription: String,
141    pub QRCode: String
142}
143
144/// Reverses a C2B M-Pesa Transaction
145#[allow(non_snake_case)]
146#[derive(Debug, Builder, Serialize, Clone)]
147#[builder(name = "ReversalRequestArgs")]
148#[builder(pattern = "mutable")]
149#[builder(setter(into, strip_option))]
150#[builder(derive(Debug))]
151#[builder(build_fn(error = "MpesaError"))]
152pub struct ReversalRequest {
153    pub Initiator: String,
154    pub SecurityCredential: String,
155    pub CommandID: String,
156    /// Original transaction ID of the transaction being reversed
157    pub TransactionID: String,
158    pub Amount: String,
159    /// The organization that received the funds
160    pub ReceiverParty: String,
161    pub ReceiverIdentifierType: String,
162    pub ResultURL: String,
163    pub QueueTimeoutURL: String,
164    pub Remarks: String,
165    pub Occasion: String
166}
167
168#[allow(non_snake_case)]
169#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
170pub struct ReversalResponse {
171    pub OriginatorConversationID: String,
172    pub ConversationID: String,
173    pub ResponseCode: i16,
174    pub ResponseDescription: String
175}
176
177#[allow(non_snake_case)]
178#[derive(Debug, Builder, Serialize, Clone)]
179#[builder(name = "TaxRemitRequestArgs")]
180#[builder(pattern = "mutable")]
181#[builder(setter(into, strip_option))]
182#[builder(derive(Debug))]
183#[builder(build_fn(error = "MpesaError"))]
184pub struct TaxRemitRequest {
185    pub Initiator: String,
186    pub SecurityCredential: String,
187    pub CommandID: String,
188    pub SenderIdentifierType: String,
189    pub ReceiverIdentifierType: String,
190    pub Amount: String,
191    pub PartyA: String,
192    pub PartyB: String,
193    pub AccountReference: String,
194    pub Remarks: String,
195    pub QueueTimeoutURL: String,
196    pub ResultURL: String
197}
198
199#[allow(non_snake_case)]
200#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
201pub struct TaxRemitResponse {
202    pub OriginatorConversationID: String,
203    pub ConversationID: String,
204    pub ResponseCode: i16,
205    pub ResponseDescription: String
206}
207
208#[allow(non_snake_case)]
209#[derive(Debug, Builder, Serialize, Clone)]
210#[builder(name = "TransactionStatusRequestArgs")]
211#[builder(pattern = "mutable")]
212#[builder(setter(into, strip_option))]
213#[builder(derive(Debug))]
214#[builder(build_fn(error = "MpesaError"))]
215pub struct TransactionStatusRequest {
216    pub Initiator: String,
217    pub SecurityCredential: String,
218    pub CommandID: String,
219    pub TranscationID: String,
220    pub OriginatorConversationID: String,
221    pub PartyA: i64,
222    pub IdentifierType: u16,
223    pub ResultURL: String,
224    pub QueueTimeoutURL: String,
225    pub Remarks: String,
226    pub Occasion: String
227}
228
229#[allow(non_snake_case)]
230#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
231pub struct TransactionStatusResponse {
232    OriginatorConversationID: String,
233    ConversationID: String,
234    ResponseCode: u16,
235    ResponseDescription: String
236}
237
238#[allow(non_snake_case)]
239#[derive(Debug, Builder, Serialize, Clone)]
240#[builder(name = "BusinessBuyGoodsRequestArgs")]
241#[builder(pattern = "mutable")]
242#[builder(setter(into, strip_option))]
243#[builder(derive(Debug))]
244#[builder(build_fn(error = "MpesaError"))]
245pub struct BusinessBuyGoodsRequest {
246    pub Initiator: String,
247    pub SecurityCredential: String,
248    pub CommandID: String,
249    pub SenderIdentifierType: String,
250    pub ReceiverIdentifierType: String,
251    pub Amount: String,
252    pub PartyA: String,
253    pub PartyB: String,
254    pub AccountReference: String,
255    pub Requester: String,
256    pub Remarks: String,
257    pub QueueTimeoutURL: String,
258    pub ResultURL: String,
259}
260
261#[allow(non_snake_case)]
262#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
263pub struct BusinessBuyGoodsResponse {
264    OriginatorConversationID: String,
265    ConversationID: String,
266    ResponseCode: u16,
267    ResponseDescription: String
268}
269
270#[allow(non_snake_case)]
271#[derive(Debug, Builder, Serialize, Clone)]
272#[builder(name = "BusinessPayBillRequestArgs")]
273#[builder(pattern = "mutable")]
274#[builder(setter(into, strip_option))]
275#[builder(derive(Debug))]
276#[builder(build_fn(error = "MpesaError"))]
277pub struct BusinessPayBillRequest {
278    pub Initiator: String,
279    pub SecurityCredential: String,
280    pub CommandID: String,
281    pub SenderIdentifierType: String,
282    pub ReceiverIdentifierType: String,
283    pub Amount: String,
284    pub PartyA: String,
285    pub PartyB: String,
286    pub AccountReference: String,
287    pub Requester: String,
288    pub Remarks: String,
289    pub QueueTimeoutURL: String,
290    pub ResultURL: String,
291}
292
293#[allow(non_snake_case)]
294#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
295pub struct BusinessPayBillResponse {
296    OriginatorConversationID: String,
297    ConversationID: String,
298    ResponseCode: u16,
299    ResponseDescription: String
300}
301
302#[allow(non_snake_case)]
303#[derive(Debug, Builder, Serialize, Clone)]
304#[builder(name = "SingleInvoicingRequestArgs")]
305#[builder(pattern = "mutable")]
306#[builder(setter(into, strip_option))]
307#[builder(derive(Debug))]
308#[builder(build_fn(error = "MpesaError"))]
309pub struct SingleInvoicingRequest {
310    externalReference: String,
311    billedFullName: String,
312    billedPhoneNumber: String,
313    billedPeriod: String,
314    invoiceName: String,
315    dueDate: String,
316    accountReference: String,
317    amount: String,
318    invoiceItems: Vec<InvoiceItems>
319}
320
321#[allow(non_snake_case)]
322#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
323pub struct SingleInvoicingResponse {
324    Status_Message: String,
325    resmg: String,
326    rescode: i32,
327}
328
329#[allow(non_snake_case)]
330#[derive(Debug, Serialize, Clone)]
331pub struct InvoiceItems {
332    itemName: String,
333    amount: String,
334}
335
336
337#[allow(non_snake_case)]
338#[derive(Debug, Builder, Serialize, Clone)]
339#[builder(name = "BillOnboardingRequestArgs")]
340#[builder(pattern = "mutable")]
341#[builder(setter(into, strip_option))]
342#[builder(derive(Debug))]
343pub struct BillOnboardingRequest {
344    shortcode: String,
345    email: String,
346    officialContact: String,
347    sendReminders: String,
348    logo: String,
349    Callbackurl: String,
350}
351
352
353#[allow(non_snake_case)]
354#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
355pub struct BillOnboardingResponse {
356    app_key: String,
357    resmsg: String,
358    rescode: String,
359}
360
361
362#[allow(non_snake_case)]
363#[derive(Debug, Builder, Serialize, Clone)]
364#[builder(name = "ReconciliationRequestArgs")]
365#[builder(pattern = "mutable")]
366#[builder(setter(into, strip_option))]
367#[builder(derive(Debug))]
368pub struct ReconciliationRequest {
369    transactionId: String,
370    paidAmount: String,
371    msisdn: String,
372    dateCreated: String,
373    accountReference: String,
374    shortCode: String,
375}
376
377
378#[allow(non_snake_case)]
379#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
380pub struct ReconciliationResponse {
381    resmsg: String,
382    rescode: String,
383}
384
385
386#[allow(non_snake_case)]
387#[derive(Debug, Builder, Serialize, Clone)]
388#[builder(name = "CancelInvoiceRequestArgs")]
389#[builder(pattern = "mutable")]
390#[builder(setter(into, strip_option))]
391#[builder(derive(Debug))]
392pub struct CancelInvoiceRequest {
393    externalReference: String,
394}
395
396
397#[allow(non_snake_case)]
398#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
399pub struct CancelInvoiceResponse {
400    Status_Message: String,
401    resmsg: String,
402    rescode: String,
403    error: Vec<String>,
404}
405
406
407#[allow(non_snake_case)]
408#[derive(Debug, Builder, Serialize, Clone)]
409#[builder(name = "BillUpdateRequestArgs")]
410#[builder(pattern = "mutable")]
411#[builder(setter(into, strip_option))]
412#[builder(derive(Debug))]
413pub struct BillUpdateRequest {
414    shortcode: String,
415    email: String,
416    officialContact: String,
417    sendReminders: String,
418    logo: String,
419    Callbackurl: String,
420}
421
422
423#[allow(non_snake_case)]
424#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
425pub struct BillUpdateResponse {
426    resmsg: String,
427    rescode: String,
428}
429
430
431#[allow(non_snake_case)]
432#[derive(Debug, Builder, Serialize, Clone)]
433#[builder(name = "B2bExpressRequestArgs")]
434#[builder(pattern = "mutable")]
435#[builder(setter(into, strip_option))]
436#[builder(derive(Debug))]
437pub struct B2bExpressRequest {
438    primaryShortCode: String,
439    receiverShortCode: String,
440    amount: String,
441    paymentRef: String,
442    CallBackUrl: String,
443    partnerName: String,
444    RequestRefID: String,
445}
446
447
448#[allow(non_snake_case)]
449#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
450pub struct B2bExpressResponse {
451    code: String,
452    status: String,
453}
454
455
456#[allow(non_snake_case)]
457#[derive(Debug, Builder, Serialize, Clone)]
458#[builder(name = "B2cTopUpRequestArgs")]
459#[builder(pattern = "mutable")]
460#[builder(setter(into, strip_option))]
461#[builder(derive(Debug))]
462pub struct B2cTopUpRequest {
463    Initiator: String,
464    SecurityCredential: String,
465    CommandID: String,
466    SenderIdentifierType: String,
467    ReceiverIdentifierType: String,
468    Amount: String,
469    PartyA: String,
470    PartyB: String,
471    AccountReference: String,
472    Requester: String,
473    Remarks: String,
474    QueueTimeOutURL: String,
475    ResultURL: String,
476}
477
478
479#[allow(non_snake_case)]
480#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
481pub struct B2cTopUpResponse {
482    OriginatorConversationID: String,
483    ConversationID: String,
484    ResponseCode: String,
485    ResponseDescription: String,
486}
487
488
489#[allow(non_snake_case)]
490#[derive(Debug, Builder, Serialize, Clone)]
491#[builder(name = "RatibaRequestArgs")]
492#[builder(pattern = "mutable")]
493#[builder(setter(into, strip_option))]
494#[builder(derive(Debug))]
495pub struct RatibaRequest {
496    StandingOrderName: String,
497    StartDate: String,
498    EndDate: String,
499    BusinessShortCode: String,
500    TransactionType: String,
501    ReceiverPartyIdentifierType: String,
502    Amount: String,
503    PartyA: String,
504    CallBackURL: String,
505    AccountReference: String,
506    TransactionDesc: String,
507    Frequency: String,
508}
509
510
511#[allow(non_snake_case)]
512#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
513pub struct RatibaResponse {
514    ResponseHeader: ResponseHeaderRatiba,
515    ResponseBody: ResponseBodyRatiba,
516}
517
518#[allow(non_snake_case)]
519#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
520pub struct ResponseHeaderRatiba {
521    responseRefID: String,
522    responseCode: String,
523    responseDescription: String,
524    ResultDesc: String,
525}
526
527#[allow(non_snake_case)]
528#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
529pub struct ResponseBodyRatiba {
530    responseDescription: String,
531    responseCode: String,
532}