Skip to content

Commit 5bb3b61

Browse files
added files for MOMO transactions
1 parent a4bd871 commit 5bb3b61

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

rave_python/rave_payment.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,33 @@ def _handleChargeResponse(self, response, txRef, request=None, isMpesa=False):
6969
res = self._preliminaryResponseChecks(response, TransactionChargeError, txRef=txRef)
7070

7171
responseJson = res["json"]
72-
flwRef = responseJson["data"]["flwRef"]
7372

7473
if isMpesa:
75-
return {"error": False, "status": responseJson["status"], "validationRequired": True, "txRef": txRef, "flwRef": flwRef, "narration": responseJson["data"]["narration"]}
74+
return {
75+
"error": False,
76+
"status": responseJson["status"],
77+
"validationRequired": True,
78+
"txRef": txRef,
79+
"flwRef": responseJson["data"]["flwRef"],
80+
"narration": responseJson["data"]["narration"]
81+
}
7682
else:
7783
# if all preliminary tests pass
7884
if not (responseJson["data"].get("chargeResponseCode", None) == "00"):
79-
if responseJson["data"].get("currency", 'None') == 'UGX':
80-
return {"error": False, "status": responseJson["status"], "validationRequired": True, "txRef": txRef, "flwRef": flwRef, "chargeResponseMessage": responseJson["data"]["chargeResponseMessage"]}
81-
82-
return {"error": False, "status": responseJson["status"],"validationRequired": True, "txRef": txRef, "flwRef": flwRef, "chargeResponseMessage": responseJson["data"]["chargeResponseMessage"]}
85+
if responseJson.get("message", 'None') == 'Momo initiated':
86+
return {
87+
"error": False,
88+
"status": responseJson["status"],
89+
"message": responseJson["message"],
90+
"code": responseJson["data"]["code"],
91+
"transaction status": responseJson["data"]["status"],
92+
"ts": responseJson["data"]["ts"],
93+
"link": responseJson["data"]["link"]
94+
}
95+
96+
return {"error": False, "status": responseJson["status"],"validationRequired": True, "txRef": txRef, "flwRef": responseJson["data"]["flwRef"], "chargeResponseMessage": responseJson["data"]["chargeResponseMessage"]}
8397
else:
84-
return {"error": True, "validationRequired": False, "txRef": txRef, "flwRef": flwRef}
98+
return {"error": True, "validationRequired": False, "txRef": txRef, "flwRef": responseJson["data"]["flwRef"]}
8599

86100
def _handleCaptureResponse(self, response, request=None):
87101
""" This handles transaction charge responses """

0 commit comments

Comments
 (0)