Changeset 17231
- Timestamp:
- 18 Dec 2022, 09:24:18 (2 years ago)
- Location:
- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch
- Files:
-
- 3 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: -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py
r17221 r17231 419 419 # https://webpay.interswitchng.com/collections/api/v1/gettransaction.json?merchantcode=MX76823&transactionreference=p6709347986663&amount=100 420 420 421 mac = "uS6U18pC6GFKCpJoZH6J6jlOmR81FSrHkjBRpMaaydNQtywuG0hdB02J56MCqLV8rmzeAkhiaQR2nNcX3EPJePl5ppidImeKSzdunhddQh61UGpZPiS2CxMdAem8ueA1" 422 421 423 @external_test_3 422 424 def test_confirm_transaction(self): … … 427 429 payment = StudentOnlinePayment() 428 430 payment.p_id ='p4465649308559' 431 payment.amount_auth = 100000.0 429 432 success, msg, log = confirm_transaction( 430 payment, merchant_code, host, url, https )433 payment, merchant_code, host, url, https, self.mac) 431 434 self.assertFalse(success) 432 435 self.assertTrue('Unsuccessful callback:' in msg) … … 436 439 payment.amount_auth = 1.0 437 440 success, msg, log = confirm_transaction( 438 payment, merchant_code, host, url, https )441 payment, merchant_code, host, url, https, self.mac) 439 442 self.assertTrue('Amount Inconsistency' in log) 440 443 payment.amount_auth = 100.0 441 444 success, msg, log = confirm_transaction( 442 payment, merchant_code, host, url, https )445 payment, merchant_code, host, url, https, self.mac) 443 446 self.assertEqual('Successful callback received', msg) 444 447 self.assertTrue(success) -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/webcheckoutbrowser.py
r17227 r17231 267 267 https = True 268 268 split_accounts = None 269 mac = None 269 270 270 271 … … 282 283 self.gateway_host, 283 284 self.gateway_url, 284 self.https) 285 self.https, 286 self.mac) 285 287 applicant.writeLogMessage(self, log) 286 288 if not success: … … 309 311 gateway_url = None 310 312 https = True 313 mac = None 311 314 312 315 def update(self): … … 323 326 self.gateway_host, 324 327 self.gateway_url, 325 self.https) 328 self.https, 329 self.mac) 326 330 student.writeLogMessage(self, log) 327 331 if not success:
Note: See TracChangeset for help on using the changeset viewer.