Changeset 16488 for main/kofacustom.nigeria/trunk/src
- Timestamp:
- 20 May 2021, 19:47:27 (4 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
r16487 r16488 327 327 payment.r_code = p_status 328 328 try: 329 payment.r_desc = " %s - %s -%s" % (329 payment.r_desc = "Channel Name: %s - Terminal Id: %s - Location: %s" % ( 330 330 doc.getElementsByTagName('ChannelName')[0].firstChild.data, 331 331 doc.getElementsByTagName('TerminalId')[0].firstChild.data, 332 doc.getElementsByTagName('Location') )[0].firstChild.data332 doc.getElementsByTagName('Location')[0].firstChild.data) 333 333 except AttributeError: 334 334 pass 335 335 try: 336 336 amount = doc.getElementsByTagName('Amount')[0].firstChild.data 337 payment.r_amount_approved = int(amount)337 payment.r_amount_approved = float(amount) 338 338 except AttributeError: 339 339 pass 340 340 try: 341 341 payment.r_pay_reference = doc.getElementsByTagName( 342 'ReferenceNumber') .firstChild.data342 'ReferenceNumber')[0].firstChild.data 343 343 except AttributeError: 344 344 pass 345 345 if p_status not in ('Pending', 'Completed'): 346 msg = _('Unknown status: %s' % sr[0])347 log = 'invalid callback for payment %s: %s' % (payment.p_id, status)346 msg = _('Unknown status: %s' % p_status) 347 log = 'invalid callback for payment %s: %s' % (payment.p_id, p_status) 348 348 payment.p_state = 'failed' 349 349 notify(grok.ObjectModifiedEvent(payment)) -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/paydirectbrowser.py
r16487 r16488 122 122 return _('Invalid callback from Interswitch') 123 123 rc = doc.getElementsByTagName('ResponseCode')[0].firstChild.data 124 if rc != '100':124 if rc not in ('100', '108'): 125 125 return 'Error response code from Interswitch: %s' % rc 126 126 return … … 162 162 student.writeLogMessage(self, log) 163 163 self.flash(msg, type=flashtype) 164 self.redirect(self.url(self.context, '@@index')) 164 165 return 165 166 -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py
r16487 r16488 236 236 payment.p_session = self.student.current_session 237 237 payment.p_item = u'My Certificate' 238 payment.p_id = u'p1234'239 238 payment.p_id = 'p' + str(random.randint(10000000000, 90000000000)) 240 239 payment.amount_auth = 1000.0 … … 255 254 256 255 @external_test_2 257 def test_paydirect (self):256 def test_paydirect_pending(self): 258 257 # Manager can access InterswitchForm 259 258 self.browser.getLink("Pay via Interswitch PAYDirect").click() … … 302 301 print "Sample PDF refnumberslip.pdf written to %s" % path 303 302 303 @external_test_2 304 def test_paydirect_completed(self): 305 payment = createObject('waeup.StudentOnlinePayment') 306 payment.p_category = u'schoolfee' 307 payment.p_session = self.student.current_session 308 payment.p_item = u'My Certificate' 309 # p6214352306153 has been manuylly set completed by Interswitch 310 payment.p_id = u'p6214352306153' 311 payment.amount_auth = 700.0 # 300 will be added 312 self.student['payments'][payment.p_id] = payment 313 result_xml = get_SOAP_response_paydirect( 314 MERCHANT_ID, payment.p_id, PAYDIRECT_HOST, PAYDIRECT_URL, True) 315 doc=parseString(result_xml) 316 status=doc.getElementsByTagName('PaymentStatus')[0].firstChild.data 317 refnumber=doc.getElementsByTagName('ReferenceNumber')[0].firstChild.data 318 amount=float(doc.getElementsByTagName('Amount')[0].firstChild.data) 319 self.assertEqual(status, 'Completed') 320 self.assertEqual(amount, payment.amount_auth + 300) 321 self.assertEqual(refnumber, '60336214352306153') 322 # Now we login and check what will happen with the student after payment 323 self.browser.open(self.payments_path) 324 self.browser.getLink(payment.p_id).click() 325 self.browser.getLink("Pay via Interswitch PAYDirect").click() 326 # 300 has been added 327 self.assertEqual(payment.amount_auth, 1000) 328 # Reference number has been saved 329 self.browser.getControl("Requery").click() 330 self.assertEqual( 331 self.student['payments'][payment.p_id].r_pay_reference, '60336214352306153') 332 # Payment is made 333 self.assertEqual( 334 self.student['payments'][payment.p_id].p_state, 'paid') 335 # Rubbish has been stored too 336 self.assertTrue( 337 self.student['payments'][payment.p_id].r_desc.startswith('Channel Name: Bank Branc')) 338 logfile = os.path.join( 339 self.app['datacenter'].storage, 'logs', 'students.log') 340 logcontent = open(logfile).read() 341 self.assertTrue( 342 'zope.mgr - kofacustom.nigeria.interswitch.paydirectbrowser.PAYDirectPageStudent ' 343 '- K1000000 - valid callback for schoolfee payment %s: Completed' % payment.p_id in logcontent) 344 self.assertTrue( 345 'zope.mgr - K1000000 - First school fee payment made' in logcontent) 346 self.assertTrue( 347 'zope.mgr - kofacustom.nigeria.interswitch.paydirectbrowser.PAYDirectPageStudent ' 348 '- K1000000 - successful schoolfee payment: %s' % payment.p_id in logcontent) 349 350 351 352 # logdatei testen 353 304 354 class InterswitchTestsApplicants(ApplicantsFullSetup): 305 355 """Tests for the Interswitch payment gateway.
Note: See TracChangeset for help on using the changeset viewer.