Skip to content

Commit 9713a0c

Browse files
fixed bug with mobile-money-uganda
1 parent 5bb3b61 commit 9713a0c

File tree

6 files changed

+57
-38
lines changed

6 files changed

+57
-38
lines changed

rave_python/rave_francophone.py

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,35 @@ def __init__(self, publicKey, secretKey, production, usingEnv):
1111

1212

1313
# 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-
if responseJson["data"]["data"].get("redirect_url", "N/A") == "N/A":
23-
redirectUrl = None
24-
else:
25-
redirectUrl = responseJson["data"]["data"]["redirect_url"]
26-
27-
# If all preliminary checks passed
28-
if not (responseJson["data"].get("chargeResponseCode", None) == "00"):
29-
# Otherwise we return that further action is required, along with the response
30-
suggestedAuth = responseJson["data"].get("suggested_auth", None)
31-
return {"error": False, "validationRequired": True, "txRef": txRef, "flwRef": flwRef, "suggestedAuth": suggestedAuth, "redirectUrl": redirectUrl}
32-
else:
33-
return {"error": False, "status": responseJson["status"], "validationRequired": False, "txRef": txRef, "flwRef": flwRef, "suggestedAuth": None, "redirectUrl": redirectUrl}
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}
3443

3544
# Charge mobile money function
3645
def charge(self, accountDetails, hasFailed=False):
@@ -42,7 +51,7 @@ def charge(self, accountDetails, hasFailed=False):
4251

4352
endpoint = self._baseUrl + self._endpointMap["account"]["charge"]
4453
# It is faster to add boilerplate than to check if each one is present
45-
accountDetails.update({"payment_type": "mobilemoneyfrancophone", "is_mobile_money_franco":"1", "currency":"XOF"})
54+
accountDetails.update({"payment_type": "mobilemoneyfrancophone", "is_mobile_money_franco":"1"})
4655

4756
# If transaction reference is not set
4857
if not ("txRef" in accountDetails):
@@ -51,5 +60,6 @@ def charge(self, accountDetails, hasFailed=False):
5160
if not ("orderRef" in accountDetails):
5261
accountDetails.update({"orderRef": generateTransactionReference()})
5362
# Checking for required account components
54-
requiredParameters = ["amount", "email", "phonenumber", "IP", "redirect_url"]
63+
# requiredParameters = ["amount", "email", "phonenumber", "IP", "redirect_url"]
64+
requiredParameters = ["amount"]
5565
return super(Francophone, self).charge(accountDetails, requiredParameters, endpoint)

rave_python/rave_payment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _handleChargeResponse(self, response, txRef, request=None, isMpesa=False):
6868
# If we cannot parse the json, it means there is a server error
6969
res = self._preliminaryResponseChecks(response, TransactionChargeError, txRef=txRef)
7070

71+
7172
responseJson = res["json"]
7273

7374
if isMpesa:

rave_python/rave_preauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def charge(self, cardDetails, chargeWithToken=False, hasFailed=False):
3232

3333

3434
# capture payment
35-
def capture(self, flwRef):
35+
def capture(self, flwRef ):
3636
""" This is called to complete the transaction.\n
3737
Parameters include:
3838
flwRef (string) -- This is the flutterwave reference you receive from action["flwRef"]

rave_python/rave_ugmobile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ def charge(self, accountDetails, hasFailed=False):
2727
if not ("orderRef" in accountDetails):
2828
accountDetails.update({"orderRef": generateTransactionReference()})
2929
# Checking for required account components
30-
requiredParameters = ["amount", "email", "phonenumber", "network", "IP", "redirect_url"]
30+
requiredParameters = ["amount", "email", "phonenumber", "network", "IP"]
3131
return super(UGMobile, self).charge(accountDetails, requiredParameters, endpoint)
3232

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="rave_python",
8-
version="1.0.1",
8+
version="1.2.2",
99
author="Flutterwave",
1010
author_email="developers@flutterwavego.com",
1111
description="Official Rave Python Wrapper By Flutterwave",

virtualCardTest.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
from rave_python import Rave, RaveExceptions, Misc
22

33

4-
rave = Rave("FLWPUBK_TEST-********************************-X", "FLWSECK_TEST-********************************-X", production = False, usingEnv = False)
5-
6-
# payload = {
7-
# "currency": "NGN",
8-
# "amount": "100",
9-
# "billing_name": "Blessed Yahaya",
10-
# "billing_address": "8, Providence Street",
11-
# "billing_city": "Lekki",
12-
# "billing_state": "Lagos",
13-
# "billing_postal_code": "100001",
14-
# "billing_country": "NG",
15-
# }
4+
rave = Rave("FLWPUBK-94ac45ac8778fc8c6942eeaec7fdeb5d-X", "FLWSECK-3c90d25b67063699bdd1688caa14b56c-X", production = True, usingEnv = False)
5+
6+
payload = {
7+
"PBFPubKey": "FLWPUBK-94ac45ac8778fc8c6942eeaec7fdeb5d-X",
8+
"currency": "UGX",
9+
"payment_type": "mobilemoneyuganda",
10+
"country": "NG",
11+
"amount": "50",
12+
"email": "user@example.com",
13+
"phonenumber": "054709929220",
14+
"network": "UGX",
15+
"firstname": "Cornelius",
16+
"lastname": "Ashley",
17+
"IP": "355426087298442",
18+
"txRef": "MC-02",
19+
"orderRef": "MC_03",
20+
"device_fingerprint": "69e6b7f0b72037aa8428b70fbe03986c"
21+
}
1622

1723
try:
18-
res = rave.VirtualCard.allCards()
24+
res = rave.UGMobile.charge(payload)
1925
print(res)
2026

2127
except RaveExceptions.IncompleteCardDetailsError as e:
2228
print(e)
2329

2430
except RaveExceptions.ServerError as e:
2531
print(e.err)
32+
33+

0 commit comments

Comments
 (0)