Skip to content

Commit 34b3fdb

Browse files
added verify method to MoMo superclasses and enabled meta in verify response
1 parent e39c4b7 commit 34b3fdb

13 files changed

+68
-77
lines changed

rave_python/rave_bills.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def create(self, details):
5757
tracking_payload = {
5858
"publicKey": self._getPublicKey(),
5959
"language": "Python v2",
60-
"version": "1.2.10",
60+
"version": "1.2.12",
6161
"title": "Create-Bills-error",
6262
"message": responseTime
6363
}
@@ -68,7 +68,7 @@ def create(self, details):
6868
tracking_payload = {
6969
"publicKey": self._getPublicKey(),
7070
"language": "Python v2",
71-
"version": "1.2.10",
71+
"version": "1.2.12",
7272
"title": "Create-Bills",
7373
"message": responseTime
7474
}

rave_python/rave_francophone.py

+8-33
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,6 @@ class Francophone(Payment):
99
def __init__(self, publicKey, secretKey, production, usingEnv):
1010
super(Francophone, self).__init__(publicKey, secretKey, production, usingEnv)
1111

12-
13-
# returns true if further action is required, false if it isn't
14-
# def _handleChargeResponse(self, response, txRef, request=None):
15-
# """ This handles charge responses """
16-
# res = self._preliminaryResponseChecks(response, MobileChargeError, txRef=txRef)
17-
18-
# responseJson = res["json"]
19-
# flwRef = res["flwRef"]
20-
21-
# # Checking if there is redirect url
22-
23-
# if responseJson["data"]["data"].get("redirect_url", "N/A") == "N/A":
24-
# redirectUrl = None
25-
# else:
26-
# redirectUrl = responseJson["data"]["data"]["redirect_url"]
27-
28-
# # If all preliminary checks passed
29-
# if not (responseJson["data"].get("chargeResponseCode", None) == "00"):
30-
# # Otherwise we return that further action is required, along with the response
31-
# # suggestedAuth = responseJson["data"].get("suggested_auth", None)
32-
# return {
33-
# "error": False,
34-
# "status": responseJson["status"],
35-
# "message": responseJson["message"],
36-
# "code": responseJson["data"]["code"],
37-
# "transaction status": responseJson["data"]["status"],
38-
# "ts": responseJson["data"]["ts"],
39-
# "link": responseJson["data"]["link"]
40-
# }
41-
# else:
42-
# return {"error": False, "status": responseJson["status"], "validationRequired": False, "txRef": txRef, "flwRef": flwRef, "suggestedAuth": None, "redirectUrl": redirectUrl}
4312

4413
# Charge mobile money function
4514
def charge(self, accountDetails, hasFailed=False):
@@ -49,7 +18,7 @@ def charge(self, accountDetails, hasFailed=False):
4918
hasFailed (boolean) -- This is a flag to determine if the attempt had previously failed due to a timeout\n
5019
"""
5120

52-
feature_name = "Initiate-Francophone-mobile-money-charge"
21+
feature_name = "Francophone-MoMo-charge"
5322
endpoint = self._baseUrl + self._endpointMap["account"]["charge"]
5423

5524
# It is faster to add boilerplate than to check if each one is present
@@ -69,6 +38,12 @@ def charge(self, accountDetails, hasFailed=False):
6938
return super(Francophone, self).charge(feature_name, accountDetails, requiredParameters, endpoint)
7039

7140
def refund(self, flwRef, amount):
72-
feature_name = "Francophone-charge-refund"
41+
feature_name = "Francophone-MoMo-refund"
7342
endpoint = self._baseUrl + self._endpointMap["refund"]
7443
return super(Francophone, self).refund(feature_name, flwRef, amount)
44+
45+
def verify(self, txRef):
46+
feature_name = "Francophone-MoMo-verify"
47+
endpoint = self._baseUrl + self._endpointMap["verify"]
48+
return super(Francophone, self).verify(feature_name, txRef)
49+

rave_python/rave_ghmobile.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def charge(self, accountDetails, hasFailed=False):
1818
"""
1919

2020
endpoint = self._baseUrl + self._endpointMap["account"]["charge"]
21-
feature_name = "Initiate-Ghana-mobile-money-charge"
21+
feature_name = "Ghana-MoMo-charge"
2222

2323
# It is faster to add boilerplate than to check if each one is present
2424
accountDetails.update({"payment_type": "mobilemoneygh", "country":"GH", "is_mobile_money_gh":"1", "currency":"GHS"})
@@ -36,7 +36,12 @@ def charge(self, accountDetails, hasFailed=False):
3636
return super(GhMobile, self).charge(feature_name, accountDetails, requiredParameters, endpoint)
3737

3838
def refund(self, flwRef, amount):
39-
feature_name = "Ghana-mobile-money-charge-refund"
39+
feature_name = "Ghana-MoMo-refund"
4040
endpoint = self._baseUrl + self._endpointMap["refund"]
4141
return super(GhMobile, self).refund(feature_name, flwRef, amount)
4242

43+
def verify(self, txRef):
44+
feature_name = "Ghana-MoMo-verify"
45+
endpoint = self._baseUrl + self._endpointMap["verify"]
46+
return super(GhMobile, self).verify(feature_name, txRef)
47+

rave_python/rave_mpesa.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def charge(self, accountDetails, hasFailed=False):
1818
"""
1919
## feature logic
2020
# Setting the endpoint
21-
feature_name = "Initiate-Mpesa-charge"
21+
feature_name = "Mpesa-charge"
2222
endpoint = self._baseUrl + self._endpointMap["account"]["charge"]
2323

2424
# Adding boilerplate mpesa requirements
@@ -38,11 +38,11 @@ def charge(self, accountDetails, hasFailed=False):
3838
return res
3939

4040
def verify(self, txRef):
41-
feature_name = "Verify-Mpesa_charge"
41+
feature_name = "Verify-Mpesa"
4242
endpoint = self._baseUrl + self._endpointMap["account"]["verify"]
4343
return super(Mpesa, self).verify(feature_name, txRef, endpoint)
4444

4545
def refund(self, flwRef, amount):
46-
feature_name = "Mpesa-charge-refund"
46+
feature_name = "Mpesa-refund"
4747
endpoint = self._baseUrl + self._endpointMap["account"]["refund"]
4848
return super(Mpesa, self).refund(feature_name, flwRef, amount)

rave_python/rave_payment.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"acctmessage": "",
1616
"currency": "",
1717
"chargedamount": 00,
18-
"chargemessage": ""
18+
"chargemessage": "",
19+
"meta": ""
1920
}
2021

2122
# All payment subclasses are encrypted classes
@@ -78,7 +79,7 @@ def _handleChargeResponse(self, response, txRef, request=None, isMpesa=False):
7879
"validationRequired": True,
7980
"txRef": txRef,
8081
"flwRef": responseJson["data"]["flwRef"],
81-
"narration": responseJson["data"]["narration"]
82+
"narration": responseJson["data"]["narration"],
8283
}
8384
else:
8485
# if all preliminary tests pass
@@ -129,7 +130,7 @@ def _handleVerifyResponse(self, response, txRef):
129130
responseJson = res["json"]
130131
# retrieve necessary properties from response
131132
verify_response["status"] = responseJson['status']
132-
verify_response['flwRef'], verify_response["txRef"], verify_response["vbvcode"], verify_response["vbvmessage"], verify_response["acctmessage"], verify_response["currency"], verify_response["chargecode"], verify_response["amount"], verify_response["chargedamount"], verify_response["chargemessage"] = Payment.retrieve(responseJson['data'], "flwref", "txref", "vbvcode", "vbvmessage", "acctmessage", "currency", "chargecode", "amount", "chargedamount", "chargemessage")
133+
verify_response['flwRef'], verify_response["txRef"], verify_response["vbvcode"], verify_response["vbvmessage"], verify_response["acctmessage"], verify_response["currency"], verify_response["chargecode"], verify_response["amount"], verify_response["chargedamount"], verify_response["chargemessage"], verify_response["meta"] = Payment.retrieve(responseJson['data'], "flwref", "txref", "vbvcode", "vbvmessage", "acctmessage", "currency", "chargecode", "amount", "chargedamount", "chargemessage", "meta")
133134

134135
# Check if the chargecode is 00
135136
if verify_response['chargecode'] == "00":
@@ -218,12 +219,12 @@ def charge(self, feature_name, paymentDetails, requiredParameters, endpoint, sho
218219
if response.ok:
219220
tracking_endpoint = self._trackingMap
220221
responseTime = response.elapsed.total_seconds()
221-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name, "message": responseTime}
222+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name, "message": responseTime}
222223
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
223224
else:
224225
tracking_endpoint = self._trackingMap
225226
responseTime = response.elapsed.total_seconds()
226-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name + "-error", "message": responseTime}
227+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name + "-error", "message": responseTime}
227228
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
228229

229230
if shouldReturnRequest:
@@ -265,12 +266,12 @@ def validate(self, feature_name, flwRef, otp, endpoint=None):
265266
if response.ok:
266267
tracking_endpoint = self._trackingMap
267268
responseTime = response.elapsed.total_seconds()
268-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name, "message": responseTime}
269+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name, "message": responseTime}
269270
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
270271
else:
271272
tracking_endpoint = self._trackingMap
272273
responseTime = response.elapsed.total_seconds()
273-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name + "-error", "message": responseTime}
274+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name + "-error", "message": responseTime}
274275
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
275276

276277
return self._handleValidateResponse(response, flwRef)
@@ -300,12 +301,12 @@ def verify(self, feature_name, txRef, endpoint=None):
300301
if response.ok:
301302
tracking_endpoint = self._trackingMap
302303
responseTime = response.elapsed.total_seconds()
303-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name, "message": responseTime}
304+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name, "message": responseTime}
304305
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
305306
else:
306307
tracking_endpoint = self._trackingMap
307308
responseTime = response.elapsed.total_seconds()
308-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name + "-error", "message": responseTime}
309+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name + "-error", "message": responseTime}
309310
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
310311

311312
return self._handleVerifyResponse(response, txRef)
@@ -332,12 +333,12 @@ def refund(self, feature_name, flwRef, amount, ):
332333
if response.ok:
333334
tracking_endpoint = self._trackingMap
334335
responseTime = response.elapsed.total_seconds()
335-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name, "message": responseTime}
336+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name, "message": responseTime}
336337
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
337338
else:
338339
tracking_endpoint = self._trackingMap
339340
responseTime = response.elapsed.total_seconds()
340-
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.10", "title": feature_name + "-error", "message": responseTime}
341+
tracking_payload = {"publicKey": self._getPublicKey(),"language": "Python v2", "version": "1.2.12", "title": feature_name + "-error", "message": responseTime}
341342
tracking_response = requests.post(tracking_endpoint, data=json.dumps(tracking_payload))
342343

343344
try:

rave_python/rave_rwmobile.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def charge(self, accountDetails, hasFailed=False):
1818
"""
1919

2020
#feature logic
21-
feature_name = "Initiate-Rwanda-mobile-money-charge"
21+
feature_name = "Rwanda-MoMo-charge"
2222
endpoint = self._baseUrl + self._endpointMap["account"]["charge"]
2323

2424
# It is faster to add boilerplate than to check if each one is present
@@ -37,7 +37,12 @@ def charge(self, accountDetails, hasFailed=False):
3737
return super(RWMobile, self).charge(feature_name, accountDetails, requiredParameters, endpoint)
3838

3939
def refund(self, flwRef, amount):
40-
feature_name = "Rwanda-mobile-money-charge-refund"
40+
feature_name = "Rwanda-MoMo-refund"
4141
endpoint = self._baseUrl + self._endpointMap["refund"]
4242
return super(RWMobile, self).refund(feature_name, flwRef, amount)
4343

44+
def verify(self, txRef):
45+
feature_name = "Rwanda-MoMo-verify"
46+
endpoint = self._baseUrl + self._endpointMap["verify"]
47+
return super(RWMobile, self).verify(feature_name, txRef)
48+

0 commit comments

Comments
 (0)