Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/__init__.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/__init__.py	(revision 14735)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/__init__.py	(revision 14735)
@@ -0,0 +1,1 @@
+# Make this a package.
Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/helpers.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/helpers.py	(revision 14735)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/helpers.py	(revision 14735)
@@ -0,0 +1,82 @@
+## $Id$
+##
+## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+"""General helper functions for the remita module in custom packages.
+"""
+from datetime import datetime
+import httplib
+import hashlib
+import json
+
+from zope.event import notify
+from kofacustom.nigeria.interfaces import MessageFactory as _
+
+def get_JSON_POST_response(
+        merchantId, serviceTypeId, api_key, orderId,
+        amount, responseurl, host, url, https, fullname, email, lineitems):
+    hashargs = 	merchantId + serviceTypeId + orderId + amount + responseurl + api_key
+    hashvalue = hashlib.sha512(hashargs).hexdigest()
+    headers={
+        'Content-Type':'application/json; charset=utf-8',
+    }
+    if https:
+        h = httplib.HTTPSConnection(host)
+    else:
+        h = httplib.HTTPConnection(host)
+    data = {
+            "merchantId":merchantId,
+            "serviceTypeId":serviceTypeId,
+            "totalAmount":amount,
+            "hash":hashvalue,
+            "payerName":fullname,
+            "payerEmail":email,
+            "orderId":orderId,
+            "responseurl":responseurl,
+            "lineItems":lineitems
+            }
+    h.request("POST", url, body=json.dumps(data), headers=headers)
+    resp = h.getresponse()
+    jsonout = resp.read()
+    parsed_json = json.loads(jsonout[6:-1])
+    return parsed_json
+
+
+def get_payment_status_via_rrr(merchantId, api_key, RRR, host, https):
+    hashargs = 	RRR + api_key + merchantId
+    hashvalue = hashlib.sha512(hashargs).hexdigest()
+    headers={
+        'Content-Type':'application/json; charset=utf-8',
+    }
+    url = '/remita/ecomm/%s/%s/%s/status.reg' % (merchantId, RRR, hashvalue)
+    if https:
+        h = httplib.HTTPSConnection(host)
+    else:
+        h = httplib.HTTPConnection(host)
+    h.request("GET", url, headers=headers)
+    resp = h.getresponse()
+    jsonout = resp.read()
+    parsed_json = json.loads(jsonout)
+    return parsed_json
+
+
+def write_payments_log(id, payment):
+    payment.logger.info(
+        '%s,%s,%s,%s,%s,%s,%s,%s,,,' % (
+        id, payment.p_id, payment.p_category,
+        payment.amount_auth, payment.r_code,
+        payment.provider_amt, payment.gateway_amt,
+        payment.thirdparty_amt))
Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py	(revision 14735)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py	(revision 14735)
@@ -0,0 +1,106 @@
+## $Id$
+##
+## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+import os
+import unittest
+from datetime import datetime, timedelta, date
+from zope.component import createObject, getUtility
+from zope.catalog.interfaces import ICatalog
+from hurry.workflow.interfaces import IWorkflowState
+from waeup.kofa.students.tests.test_browser import StudentsFullSetup
+from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
+from waeup.kofa.configuration import SessionConfiguration
+from waeup.kofa.students.payments import StudentOnlinePayment
+from kofacustom.nigeria.testing import FunctionalLayer
+
+from kofacustom.nigeria.remita.helpers import (
+    get_JSON_POST_response, get_payment_status_via_rrr)
+
+# Also run tests that send requests to external servers?
+#   If you enable this, please make sure the external services
+#   do exist really and are not bothered by being spammed by a test programme.
+EXTERNAL_TESTS = True
+
+def external_test(func):
+    if not EXTERNAL_TESTS:
+        myself = __file__
+        if myself.endswith('.pyc'):
+            myself = myself[:-2]
+        print "WARNING: external tests are skipped!"
+        print "WARNING: edit %s to enable them." % myself
+        return
+    return func
+
+class HelperTests(unittest.TestCase):
+
+    merchantId = '2547916'
+    serviceTypeId = '4430731'
+    api_key = '1946'
+    orderId = '3456346346'
+    amount = '1000'
+    responseurl = 'http://xxxx'
+    host = 'www.remitademo.net'
+    lineitems = (
+                  {"lineItemsId":"itemid1","beneficiaryName":"Oshadami Mike",
+                  "beneficiaryAccount":"6020067886","bankCode":"011",
+                  "beneficiaryAmount":"500","deductFeeFrom":"1"},
+                  {"lineItemsId":"itemid2","beneficiaryName":"Ogunseye Mujib",
+                  "beneficiaryAccount":"0360883515","bankCode":"050",
+                  "beneficiaryAmount":"500","deductFeeFrom":"0"}
+                )
+
+    @external_test
+    def test_get_JSON_POST_response(self):
+
+        url = '/remita/ecomm/split/init.reg'  # /remita/ecomm/v2/init.reg
+
+        resp = get_JSON_POST_response(
+                merchantId=self.merchantId, serviceTypeId=self.serviceTypeId,
+                api_key=self.api_key, orderId=self.orderId,
+                amount=self.amount, responseurl=self.responseurl,
+                host=self.host, url=url, https=False,
+                fullname='Anton Meier', email='am@xxx.de',
+                lineitems=self.lineitems)
+        assert resp == {
+            u'status': u'RRR Already Exist for the orderId',
+            u'orderID': u'3456346346',
+            u'RRR': u'280007640804 ',  # strange trailing whitespace which
+                                       # obviously does not belong to the RRR
+            u'statuscode': u'055'}
+
+    @external_test
+    def test_payment_status_via_rrr(self):
+
+        resp = get_payment_status_via_rrr(
+                merchantId=self.merchantId,
+                api_key=self.api_key,
+                RRR='280007640804',
+                host=self.host,
+                https=False,
+                )
+
+        assert resp == {
+            u'orderId': u'3456346346',
+            u'status': u'021',
+            u'amount': 1000.0,
+            u'transactiontime': u'2017-07-31 11:17:24 AM',
+            u'message': u'Transaction Pending',
+            u'lineitems': [{u'status': u'021', u'lineItemsId': u'itemid1'},
+                           {u'status': u'021', u'lineItemsId': u'itemid2'}
+                          ],
+            u'RRR': u'280007640804'}
+
