- Timestamp:
- 18 Dec 2022, 09:24:18 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py
r17221 r17231 382 382 # Web checkout helper functions 383 383 384 def get_JSON_webcheckout_response(merchant_code, transref, host, url, https, amount): 384 def get_JSON_webcheckout_response(merchant_code, transref, host, url, 385 https, amount, mac=None): 386 amount = int(100 * amount) 387 hashargs = transref + merchant_code + str(amount) + mac 388 hashvalue = hashlib.sha512(hashargs).hexdigest() 385 389 headers={ 386 390 'Content-Type':'text/xml; charset=utf-8', 391 'Hash':hashvalue, 387 392 } 388 393 if https: … … 390 395 else: 391 396 h = httplib.HTTPConnection(host) 392 amount = int(100 * amount)393 397 args = {'merchantcode': merchant_code, 394 398 'transactionreference': transref, … … 401 405 response = h.getresponse() 402 406 if response.status!=200: 403 return {'error': 'Connection error (%s, %s)' % (response.status, response.reason)} 407 return {'error': 'Connection error (%s, %s)' % ( 408 response.status, response.reason)} 404 409 jsonout = response.read() 405 410 parsed_json = json.loads(jsonout) 406 411 return parsed_json 407 412 408 def confirm_transaction(payment, merchant_code, host, url, https =True):413 def confirm_transaction(payment, merchant_code, host, url, https, mac): 409 414 jr = get_JSON_webcheckout_response(merchant_code, payment.p_id, host, url, 410 https, payment.amount_auth )415 https, payment.amount_auth, mac) 411 416 error = jr.get('error') 412 417 if error:
Note: See TracChangeset for help on using the changeset viewer.