Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py	(revision 16487)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py	(revision 16488)
@@ -327,23 +327,23 @@
     payment.r_code = p_status
     try:
-        payment.r_desc = "%s - %s - %s" % (
+        payment.r_desc = "Channel Name: %s - Terminal Id: %s - Location: %s" % (
             doc.getElementsByTagName('ChannelName')[0].firstChild.data,
             doc.getElementsByTagName('TerminalId')[0].firstChild.data,
-            doc.getElementsByTagName('Location'))[0].firstChild.data
+            doc.getElementsByTagName('Location')[0].firstChild.data)
     except AttributeError:
         pass
     try:
         amount = doc.getElementsByTagName('Amount')[0].firstChild.data
-        payment.r_amount_approved = int(amount)
+        payment.r_amount_approved = float(amount)
     except AttributeError:
         pass
     try:
         payment.r_pay_reference = doc.getElementsByTagName(
-            'ReferenceNumber').firstChild.data
+            'ReferenceNumber')[0].firstChild.data
     except AttributeError:
         pass
     if p_status not in ('Pending', 'Completed'):
-        msg = _('Unknown status: %s' % sr[0])
-        log = 'invalid callback for payment %s: %s' % (payment.p_id, status)
+        msg = _('Unknown status: %s' % p_status)
+        log = 'invalid callback for payment %s: %s' % (payment.p_id, p_status)
         payment.p_state = 'failed'
         notify(grok.ObjectModifiedEvent(payment))
Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/paydirectbrowser.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/paydirectbrowser.py	(revision 16487)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/paydirectbrowser.py	(revision 16488)
@@ -122,5 +122,5 @@
                 return _('Invalid callback from Interswitch')
             rc = doc.getElementsByTagName('ResponseCode')[0].firstChild.data
-            if rc != '100':
+            if rc not in ('100', '108'):
                 return 'Error response code from Interswitch: %s' % rc
         return
@@ -162,4 +162,5 @@
             student.writeLogMessage(self, log)
         self.flash(msg, type=flashtype)
+        self.redirect(self.url(self.context, '@@index'))
         return
 
Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py	(revision 16487)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py	(revision 16488)
@@ -236,5 +236,4 @@
         payment.p_session = self.student.current_session
         payment.p_item = u'My Certificate'
-        payment.p_id = u'p1234'
         payment.p_id = 'p' + str(random.randint(10000000000, 90000000000))
         payment.amount_auth = 1000.0
@@ -255,5 +254,5 @@
 
     @external_test_2
-    def test_paydirect(self):
+    def test_paydirect_pending(self):
         # Manager can access InterswitchForm
         self.browser.getLink("Pay via Interswitch PAYDirect").click()
@@ -302,4 +301,55 @@
         print "Sample PDF refnumberslip.pdf written to %s" % path
 
+    @external_test_2
+    def test_paydirect_completed(self):
+        payment = createObject('waeup.StudentOnlinePayment')
+        payment.p_category = u'schoolfee'
+        payment.p_session = self.student.current_session
+        payment.p_item = u'My Certificate'
+        # p6214352306153 has been manuylly set completed by Interswitch
+        payment.p_id = u'p6214352306153'
+        payment.amount_auth = 700.0 # 300 will be added
+        self.student['payments'][payment.p_id] = payment
+        result_xml = get_SOAP_response_paydirect(
+            MERCHANT_ID, payment.p_id, PAYDIRECT_HOST, PAYDIRECT_URL, True)
+        doc=parseString(result_xml)
+        status=doc.getElementsByTagName('PaymentStatus')[0].firstChild.data
+        refnumber=doc.getElementsByTagName('ReferenceNumber')[0].firstChild.data
+        amount=float(doc.getElementsByTagName('Amount')[0].firstChild.data)
+        self.assertEqual(status, 'Completed')
+        self.assertEqual(amount, payment.amount_auth + 300)
+        self.assertEqual(refnumber, '60336214352306153')
+        # Now we login and check what will happen with the student after payment
+        self.browser.open(self.payments_path)
+        self.browser.getLink(payment.p_id).click()
+        self.browser.getLink("Pay via Interswitch PAYDirect").click()
+        # 300 has been added
+        self.assertEqual(payment.amount_auth, 1000)
+        # Reference number has been saved 
+        self.browser.getControl("Requery").click()
+        self.assertEqual(
+            self.student['payments'][payment.p_id].r_pay_reference, '60336214352306153')
+        # Payment is made
+        self.assertEqual(
+            self.student['payments'][payment.p_id].p_state, 'paid')
+        # Rubbish has been stored too
+        self.assertTrue(
+            self.student['payments'][payment.p_id].r_desc.startswith('Channel Name: Bank Branc'))
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'zope.mgr - kofacustom.nigeria.interswitch.paydirectbrowser.PAYDirectPageStudent '
+            '- K1000000 - valid callback for schoolfee payment %s: Completed' % payment.p_id in logcontent)
+        self.assertTrue(
+            'zope.mgr - K1000000 - First school fee payment made' in logcontent)
+        self.assertTrue(
+            'zope.mgr - kofacustom.nigeria.interswitch.paydirectbrowser.PAYDirectPageStudent '
+            '- K1000000 - successful schoolfee payment: %s' % payment.p_id in logcontent)
+
+
+
+# logdatei testen
+
 class InterswitchTestsApplicants(ApplicantsFullSetup):
     """Tests for the Interswitch payment gateway.
