(20250102) Safaricom M-Pesa work.
This commit is contained in:
@@ -339,6 +339,8 @@ class SafaricomMPesaExpress:
|
||||
"TransactionDesc": description[:13] if len(description) > 13 else description
|
||||
}
|
||||
|
||||
print("HEADERS:", input_headers)
|
||||
|
||||
# Make the API call:
|
||||
api_response = await self.__post(
|
||||
url = r"https://api.safaricom.co.ke/mpesa/stkpush/v1/processrequest",
|
||||
@@ -392,11 +394,14 @@ if __name__ == "__main__":
|
||||
# Make the request:
|
||||
response = await my_m_pesa.request_payment(
|
||||
amount = 1.00,
|
||||
party_a = "254748877373",
|
||||
party_a = "254700123007",
|
||||
type = "CustomerPayBillOnline",
|
||||
reference = "TestTransactionTXN12345678",
|
||||
description = "Some description about the payment reason...",
|
||||
callback_url = r"https://api.thecaoffice.com/converse/test/callback",
|
||||
# callback_url = r"https://api.thecaoffice.com/converse/test/callback",
|
||||
callback_url = r"https://v2.api.bicree.com/user/callback/test",
|
||||
payer_no = "254700123007",
|
||||
|
||||
)
|
||||
|
||||
# Show the response:
|
||||
|
||||
@@ -212,8 +212,8 @@ class MPesaExpressAuthorization(BaseModel):
|
||||
self.expiresAt = self.lastRefresh + datetime.timedelta(seconds = int(0.95 * float(api_json.get("expires_in"))))
|
||||
token_refreshed = True
|
||||
|
||||
# Done here:
|
||||
return token_refreshed
|
||||
# Done here:
|
||||
return token_refreshed
|
||||
|
||||
async def get_access_token(
|
||||
self,
|
||||
|
||||
@@ -53,6 +53,9 @@ from icecream import IceCreamDebugger
|
||||
# To work with datatypes:
|
||||
from typing import List, Literal
|
||||
|
||||
# To work with date and time:
|
||||
import time
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
@@ -199,8 +202,10 @@ class ProducerKafka:
|
||||
:return: None
|
||||
"""
|
||||
|
||||
start_time = time.time()
|
||||
self.__producer.flush()
|
||||
self.__printer("Producer flushed.")
|
||||
message = f"Producer flushed in {time.time() - start_time:.5f} second(s)."
|
||||
self.__printer(message)
|
||||
|
||||
def close(self):
|
||||
|
||||
@@ -211,7 +216,7 @@ class ProducerKafka:
|
||||
|
||||
if self.__connected:
|
||||
try:
|
||||
self.__producer.flush()
|
||||
self.flush()
|
||||
self.__printer("Producer closed!")
|
||||
self.__connected = False
|
||||
except Exception as exception: self.__printer(exception)
|
||||
|
||||
Reference in New Issue
Block a user