Skip to content

Commit bd88f1c

Browse files
authored
Merge pull request #43 from RafaelJohn9/fix/service
fix: added the missing fields in the facade services
2 parents 4088739 + e76c821 commit bd88f1c

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

mpesakit/services/express.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def __init__(self, http_client: HttpClient, token_manager: TokenManager) -> None
2828
def push(
2929
self,
3030
business_short_code: int,
31-
passkey: str,
3231
transaction_type: str,
3332
amount: float,
3433
party_a: str,
@@ -37,13 +36,15 @@ def push(
3736
callback_url: str,
3837
account_reference: str,
3938
transaction_desc: str,
39+
passkey: str | None = None,
40+
timestamp: str | None = None,
41+
password: str | None = None,
4042
**kwargs,
4143
) -> StkPushSimulateResponse:
4244
"""Initiate an M-Pesa STK Push transaction.
4345
4446
Args:
4547
business_short_code: M-Pesa business shortcode.
46-
passkey: M-Pesa passkey.
4748
transaction_type: Transaction type (e.g., 'CustomerPayBillOnline').
4849
amount: Transaction amount.
4950
party_a: MSISDN sending the funds.
@@ -52,14 +53,16 @@ def push(
5253
callback_url: URL for receiving the callback.
5354
account_reference: Reference for the transaction.
5455
transaction_desc: Description of the transaction.
56+
passkey: M-Pesa passkey.
57+
timestamp: Timestamp for the transaction.
58+
password: Password for the transaction.
5559
**kwargs: Additional fields for StkPushSimulateRequest.
5660
5761
Returns:
5862
StkPushSimulateResponse: Response from M-Pesa API.
5963
"""
6064
request = StkPushSimulateRequest(
6165
BusinessShortCode=business_short_code,
62-
Passkey=passkey,
6366
TransactionType=transaction_type,
6467
Amount=amount,
6568
PartyA=party_a,
@@ -68,6 +71,9 @@ def push(
6871
CallBackURL=callback_url,
6972
AccountReference=account_reference,
7073
TransactionDesc=transaction_desc,
74+
Passkey=passkey,
75+
Timestamp=timestamp,
76+
Password=password,
7177
**{
7278
k: v
7379
for k, v in kwargs.items()

mpesakit/services/tax.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def remittance(
3131
remarks: str,
3232
account_reference: str,
3333
result_url: str,
34+
queue_timeout_url: str,
3435
**kwargs,
3536
) -> TaxRemittanceResponse:
3637
"""Initiate a tax remittance transaction.
@@ -43,6 +44,7 @@ def remittance(
4344
remarks: Additional remarks.
4445
account_reference: Account reference for the transaction.
4546
result_url: URL for result notification.
47+
queue_timeout_url: URL for timeout notification.
4648
**kwargs: Additional fields for TaxRemittanceRequest.
4749
4850
Returns:
@@ -56,6 +58,7 @@ def remittance(
5658
Remarks=remarks,
5759
AccountReference=account_reference,
5860
ResultURL=result_url,
61+
QueueTimeOutURL=queue_timeout_url,
5962
**{
6063
k: v
6164
for k, v in kwargs.items()

tests/unit/services/test_tax_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_remittance_calls_tax_remittance(tax_service, mock_http_client):
4949
remarks="OK",
5050
account_reference="353353",
5151
result_url="https://mydomain.com/b2b/remittax/result/",
52-
QueueTimeOutURL="https://mydomain.com/b2b/remittax/queue/",
52+
queue_timeout_url="https://mydomain.com/b2b/remittax/queue/",
5353
)
5454
assert isinstance(resp, TaxRemittanceResponse)
5555
assert resp.is_successful() is True
@@ -74,7 +74,7 @@ def test_remittance_filters_kwargs(tax_service, mock_http_client):
7474
remarks="OK",
7575
account_reference="353353",
7676
result_url="https://mydomain.com/b2b/remittax/result/",
77-
QueueTimeOutURL="https://mydomain.com/b2b/remittax/queue/",
77+
queue_timeout_url="https://mydomain.com/b2b/remittax/queue/",
7878
unexpected_field="should be ignored",
7979
)
8080
assert isinstance(resp, TaxRemittanceResponse)

0 commit comments

Comments
 (0)