1111
1212from mpesa_sdk .mpesa_ratiba import (
1313 MpesaRatiba ,
14+ FrequencyEnum ,
15+ TransactionTypeEnum ,
16+ ReceiverPartyIdentifierTypeEnum ,
1417 StandingOrderRequest ,
1518 StandingOrderResponse ,
1619 StandingOrderCallback ,
@@ -45,14 +48,14 @@ def valid_standing_order_request():
4548 StartDate = "20240905" ,
4649 EndDate = "20250905" ,
4750 BusinessShortCode = "174379" ,
48- TransactionType = "Standing Order Customer Pay Bill" ,
49- ReceiverPartyIdentifierType = "4" ,
51+ TransactionType = TransactionTypeEnum . STANDING_ORDER_CUSTOMER_PAY_BILL ,
52+ ReceiverPartyIdentifierType = ReceiverPartyIdentifierTypeEnum . MERCHANT_TILL ,
5053 Amount = "4500" ,
5154 PartyA = "254708374149" ,
5255 CallBackURL = "https://mydomain.com/pat" ,
5356 AccountReference = "Test" ,
5457 TransactionDesc = "Electric Bike" ,
55- Frequency = "2" ,
58+ Frequency = FrequencyEnum . DAILY ,
5659 )
5760
5861
@@ -172,14 +175,14 @@ def test_standing_order_request_invalid_date_format():
172175 StartDate = "202423305" , # Invalid date
173176 EndDate = "20250905" ,
174177 BusinessShortCode = "174379" ,
175- TransactionType = "Standing Order Customer Pay Bill" ,
176- ReceiverPartyIdentifierType = "4" ,
178+ TransactionType = TransactionTypeEnum . STANDING_ORDER_CUSTOMER_PAY_BILL ,
179+ ReceiverPartyIdentifierType = ReceiverPartyIdentifierTypeEnum . MERCHANT_TILL ,
177180 Amount = "4500" ,
178181 PartyA = "254708374149" ,
179182 CallBackURL = "https://mydomain.com/pat" ,
180183 AccountReference = "Test" ,
181184 TransactionDesc = "Electric Bike" ,
182- Frequency = "2" ,
185+ Frequency = FrequencyEnum . DAILY ,
183186 )
184187 assert "Date must be in 'yyyymmdd' format" in str (excinfo .value )
185188
@@ -192,14 +195,14 @@ def test_standing_order_request_invalid_date_value():
192195 StartDate = "20241305" , # Invalid month
193196 EndDate = "20250905" ,
194197 BusinessShortCode = "174379" ,
195- TransactionType = "Standing Order Customer Pay Bill" ,
196- ReceiverPartyIdentifierType = "4" ,
198+ TransactionType = TransactionTypeEnum . STANDING_ORDER_CUSTOMER_PAY_BILL ,
199+ ReceiverPartyIdentifierType = ReceiverPartyIdentifierTypeEnum . MERCHANT_TILL ,
197200 Amount = "4500" ,
198201 PartyA = "254708374149" ,
199202 CallBackURL = "https://mydomain.com/pat" ,
200203 AccountReference = "Test" ,
201204 TransactionDesc = "Electric Bike" ,
202- Frequency = "2" ,
205+ Frequency = FrequencyEnum . WEEKLY ,
203206 )
204207 assert "Date must be in 'yyyymmdd' format" in str (excinfo .value )
205208
@@ -211,14 +214,14 @@ def test_standing_order_request_other_date_value():
211214 StartDate = "2024-12-05" , # With separators
212215 EndDate = "20250905" ,
213216 BusinessShortCode = "174379" ,
214- TransactionType = "Standing Order Customer Pay Bill" ,
215- ReceiverPartyIdentifierType = "4" ,
217+ TransactionType = TransactionTypeEnum . STANDING_ORDER_CUSTOMER_PAY_BILL ,
218+ ReceiverPartyIdentifierType = ReceiverPartyIdentifierTypeEnum . MERCHANT_TILL ,
216219 Amount = "4500" ,
217220 PartyA = "254708374149" ,
218221 CallBackURL = "https://mydomain.com/pat" ,
219222 AccountReference = "Test" ,
220223 TransactionDesc = "Electric Bike" ,
221- Frequency = "2" ,
224+ Frequency = FrequencyEnum . MONTHLY ,
222225 )
223226 assert request .StartDate == "20241205" # Should normalize to yyyymmdd format
224227
@@ -231,13 +234,13 @@ def test_invalid_phone_number():
231234 StartDate = "20240905" ,
232235 EndDate = "20250905" ,
233236 BusinessShortCode = "174379" ,
234- TransactionType = "Standing Order Customer Pay Bill" ,
235- ReceiverPartyIdentifierType = "4" ,
237+ TransactionType = TransactionTypeEnum . STANDING_ORDER_CUSTOMER_PAY_BILL ,
238+ ReceiverPartyIdentifierType = ReceiverPartyIdentifierTypeEnum . MERCHANT_TILL ,
236239 Amount = "4500" ,
237240 PartyA = "123456789" , # Invalid phone number
238241 CallBackURL = "https://mydomain.com/pat" ,
239242 AccountReference = "Test" ,
240243 TransactionDesc = "Electric Bike" ,
241- Frequency = "2" ,
244+ Frequency = FrequencyEnum . MONTHLY ,
242245 )
243246 assert "Invalid PartyA phone number" in str (excinfo .value )
0 commit comments