Updates verify step to function with ussd.
This commit is contained in:
parent
d163b50ca7
commit
0520a84b9e
@ -9,6 +9,7 @@ import sys
|
|||||||
import urllib
|
import urllib
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import uuid
|
import uuid
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import celery
|
import celery
|
||||||
@ -185,9 +186,9 @@ def send_ussd_request(address, data_dir):
|
|||||||
}
|
}
|
||||||
|
|
||||||
req = urllib.request.Request(config.get('_USSD_PROVIDER'))
|
req = urllib.request.Request(config.get('_USSD_PROVIDER'))
|
||||||
data_str = json.dumps(data)
|
urlencoded_data = urllib.parse.urlencode(data)
|
||||||
data_bytes = data_str.encode('utf-8')
|
data_bytes = urlencoded_data.encode('utf-8')
|
||||||
req.add_header('Content-Type', 'application/json')
|
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
req.data = data_bytes
|
req.data = data_bytes
|
||||||
response = urllib.request.urlopen(req)
|
response = urllib.request.urlopen(req)
|
||||||
return response.read().decode('utf-8')
|
return response.read().decode('utf-8')
|
||||||
@ -388,10 +389,9 @@ class Verifier:
|
|||||||
|
|
||||||
def verify_ussd_pins(self, address, balance):
|
def verify_ussd_pins(self, address, balance):
|
||||||
response_data = send_ussd_request(address, self.data_dir)
|
response_data = send_ussd_request(address, self.data_dir)
|
||||||
if response_data[:11] != 'CON Balance':
|
if response_data[:11] != 'CON Balance' and response_data[:9] != 'CON Salio':
|
||||||
raise VerifierError(response_data, 'pins')
|
raise VerifierError(response_data, 'pins')
|
||||||
|
|
||||||
|
|
||||||
def verify(self, address, balance, debug_stem=None):
|
def verify(self, address, balance, debug_stem=None):
|
||||||
|
|
||||||
for k in active_tests:
|
for k in active_tests:
|
||||||
|
Loading…
Reference in New Issue
Block a user