Changeset 15773


Ignore:
Timestamp:
7 Nov 2019, 17:45:43 (5 years ago)
Author:
Henrik Bettermann
Message:

Adjust to Nigeria package.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/etranzact/browser.py

    r15733 r15773  
    2222from kofacustom.nigeria.etranzact.studentsbrowser import (
    2323    EtranzactPageStudent, EtranzactReceiveResponseStudent,
    24     EtranzactRequestPaymentStatusPageStudent)
     24    EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated)
    2525from kofacustom.nigeria.etranzact.payoutletbrowser import (
    26     EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant)
     26    EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant,
     27    EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant,
     28    payoutlet_module_activated)
     29from kofacustom.nigeria.etranzact.payoutletwebservice  import NigeriaPaymentDataWebservice
    2730
    2831# Temporarily we can use the test portal like in kofacustom.nigeria
     
    3538#SECRET_KEY =
    3639#TERMINAL_ID =
     40GATEWAY_AMT = 500.0
    3741LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png'
    3842
     
    4448    terminal_id = TERMINAL_ID
    4549    logo_url = LOGO_URL
     50    gateway_amt = GATEWAY_AMT
     51
     52    def update(self):
     53        # Already now it becomes an Etranzact payment. We set the net amount
     54        # and add the gateway amount.
     55        if not webconnect_module_activated(
     56            self.context.__parent__.__parent__.year, self.context):
     57            return _("Etranzact payments deactivated.")
     58        if not self.context.r_company:
     59            self.context.net_amt = self.context.amount_auth
     60            self.context.amount_auth += self.gateway_amt
     61            self.context.gateway_amt = self.gateway_amt
     62            self.context.r_company = u'etranzact'
     63        self.amount = "%.1f" % self.context.amount_auth
     64        error = self.init_update()
     65        if error:
     66            self.flash(error, type='danger')
     67            self.redirect(self.url(self.context, '@@index'))
     68            return
     69        return
    4670
    4771class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant):
     
    6690    terminal_id = TERMINAL_ID
    6791    logo_url = LOGO_URL
     92    gateway_amt = GATEWAY_AMT
     93
     94    def update(self):
     95        # Already now it becomes an Etranzact payment. We set the net amount
     96        # and add the gateway amount.
     97        if not webconnect_module_activated(
     98            self.context.student.current_session, self.context):
     99            return _("Etranzact payments deactivated.")
     100        if not self.context.r_company:
     101            self.context.net_amt = self.context.amount_auth
     102            self.context.amount_auth += self.gateway_amt
     103            self.context.gateway_amt = self.gateway_amt
     104            self.context.r_company = u'etranzact'
     105        self.amount = "%.1f" % self.context.amount_auth
     106        error = self.init_update()
     107        if error:
     108            self.flash(error, type='danger')
     109            self.redirect(self.url(self.context, '@@index'))
     110            return
     111        return
    68112
    69113class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent):
     
    81125    logo_url = LOGO_URL
    82126
     127# Payoutlet customizations
     128
     129class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent):
     130    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
     131    """
     132    gateway_amt = GATEWAY_AMT
     133
     134    def update(self):
     135        if not payoutlet_module_activated(
     136            self.context.student.current_session, self.context):
     137            return
     138        super(EtranzactEnterPinPageStudent, self).update()
     139        # Already now it becomes an Etranzact payment. We set the net amount
     140        # and add the gateway amount.
     141        provider_amt = 0.0
     142        if self.context.p_category == 'registration':
     143            provider_amt = 5000.0
     144        if not self.context.r_company:
     145            self.context.net_amt = self.context.amount_auth
     146            self.context.amount_auth += self.gateway_amt
     147            self.context.amount_auth += provider_amt
     148            self.context.gateway_amt = self.gateway_amt
     149            self.context.provider_amt = provider_amt
     150            self.context.r_company = u'etranzact'
     151        return
     152
     153class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
     154    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
     155    """
     156    gateway_amt = GATEWAY_AMT
     157
     158    def update(self):
     159        if not payoutlet_module_activated(
     160            self.context.__parent__.__parent__.year, self.context):
     161            return
     162        super(EtranzactEnterPinPageStudent, self).update()
     163        # Already now it becomes an Etranzact payment. We set the net amount
     164        # and add the gateway amount.
     165        provider_amt = 0.0
     166        if not self.context.r_company:
     167            self.context.net_amt = self.context.amount_auth
     168            self.context.amount_auth += self.gateway_amt
     169            self.context.amount_auth += provider_amt
     170            self.context.gateway_amt = self.gateway_amt
     171            self.context.provider_amt = provider_amt
     172            self.context.r_company = u'etranzact'
     173        return
     174
    83175class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
    84176    """ Query history of Etranzact payments
     
    94186    host = HOST
    95187    https = HTTPS
     188
     189class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
     190    """A simple webservice to publish payment and payer details on request from
     191    accepted IP addresses without authentication.
     192    """
     193    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
     194    ACCEPTED_IP = None
     195
     196    CATEGORY_MAPPING = {
     197        'SCHOOLFEE': ('schoolfee',),
     198         }
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/interfaces.py

    r15737 r15773  
    8383
    8484    # Additional fees in custom package add here
     85
     86    registration_fee = schema.Float(
     87        title = _(u'Registration Fee'),
     88        default = 0.0,
     89        required = False,
     90        )
    8591
    8692    late_registration_fee = schema.Float(
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/interswitch/browser.py

    r15728 r15773  
    6161    product_id = PRODUCT_ID
    6262    mac = MAC 
     63    gateway_amt = GATEWAY_AMT
    6364
    6465    def update(self):
     
    6869            self.redirect(self.url(self.context, '@@index'))
    6970            return
     71        # Already now it becomes an Interswitch payment. We set the net amount
     72        # and add the gateway amount.
     73        if not self.context.r_company:
     74            self.context.net_amt = self.context.amount_auth
     75            self.context.amount_auth += self.gateway_amt
     76            self.context.gateway_amt = self.gateway_amt
     77            self.context.r_company = u'interswitch'
    7078        student = self.student
    7179        xmldict = self.xmldict
     
    7583        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
    7684        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
    77         provider_amt = 0.0
    7885        xmldict['institution_acct'] = ''
    7986        xmldict['institution_bank_id'] = ''
    80         provider_amt = 5000.0
     87        provider_amt = 0.0
    8188        self.pay_item_id = ''
    8289        # Institution data
     
    103110        xmldict['institution_item_name'] = self.context.category
    104111        xmldict['institution_name'] = INSTITUTION_NAME
    105         xmldict['institution_amt'] = 100 * (
    106             self.context.amount_auth - provider_amt - GATEWAY_AMT)
    107         # Interswitch amount is not part of the xml data
     112        xmldict['institution_amt'] = 100 * self.context.net_amt
     113        if not self.context.provider_amt:
     114            self.context.provider_amt = provider_amt
     115            self.context.amount_auth += provider_amt
    108116        if provider_amt == 0:
    109117            xmltext = """<payment_item_detail>
     
    120128</payment_item_detail>""" % xmldict
    121129        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
    122         self.context.provider_amt = provider_amt
    123         self.context.gateway_amt = GATEWAY_AMT
    124 
     130        self.amount_auth = int(100 * self.context.amount_auth)
    125131        hashargs = (
    126132            self.context.p_id +
     
    144150    product_id = PRODUCT_ID
    145151    mac = MAC
     152    gateway_amt = GATEWAY_AMT
    146153
    147154    def update(self):
     
    151158            self.redirect(self.url(self.context, '@@index'))
    152159            return
     160        # Already now it becomes an Interswitch payment. We set the net amount
     161        # and add the gateway amount.
     162        if not self.context.r_company:
     163            self.context.net_amt = self.context.amount_auth
     164            self.context.amount_auth += self.gateway_amt
     165            self.context.gateway_amt = self.gateway_amt
     166            self.context.r_company = u'interswitch'
     167        self.amount_auth = int(100 * self.context.amount_auth)
    153168        xmldict = {}
    154         provider_amt = 400.0
     169        provider_amt = 0.0
    155170        xmldict['institution_acct'] = '0040484781'
    156171        xmldict['institution_bank_id'] = '31'
     
    160175        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
    161176        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
    162         xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT)
    163177        xmldict['institution_item_name'] = self.context.category
    164178        xmldict['institution_name'] = INSTITUTION_NAME
    165         # Interswitch amount is not part of the xml data
     179        xmldict['institution_amt'] = 100 * self.context.net_amt
     180        if not self.context.provider_amt:
     181            self.context.provider_amt = provider_amt
     182            self.context.amount_auth += provider_amt
    166183        xmltext = """<payment_item_detail>
    167184<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
     
    171188</payment_item_detail>""" % xmldict
    172189        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
    173         self.context.provider_amt = provider_amt
    174         self.context.gateway_amt = GATEWAY_AMT
    175 
     190        self.amount_auth = int(100 * self.context.amount_auth)
    176191        hashargs = (
    177192            self.context.p_id +
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/interswitch/tests.py

    r15728 r15773  
    7575                           self.browser.contents)
    7676        self.assertEqual(self.student.current_mode, 'ug_ft')
    77         self.assertTrue(
    78             '<input type="hidden" name="amount" value="4000000" />' in
    79             self.browser.contents)
    80         self.assertTrue(
    81             'item_name="Tuition Plus (total amount)" item_amt="3475000" bank_id="117" acct_num="1011005811"' in
     77        # 250 gateway charge have been added
     78        payment = self.student['payments'][self.value]
     79        self.assertEqual(payment.amount_auth, 40250)
     80        self.assertEqual(payment.net_amt, 40000)
     81        self.assertTrue(
     82            '<input type="hidden" name="amount" value="4025000" />' in
     83            self.browser.contents)
     84        self.assertTrue(
     85            'item_name="Tuition Plus (total amount)" item_amt="4000000" bank_id="117" acct_num="1011005811"' in
    8286            self.browser.contents)
    8387
     
    8690        acc_payment = createObject('waeup.StudentOnlinePayment')
    8791        acc_payment.p_state = 'unpaid'
    88         acc_payment.p_category = 'clearance'
     92        acc_payment.p_category = 'registration'
    8993        acc_payment.p_id = 'xyz'
    9094        acc_payment.pay_item_id = '123'
    91         acc_payment.amount_auth = 876.0
     95        acc_payment.amount_auth = 1000.0
    9296        self.student['payments']['xyz'] = acc_payment
    9397        self.browser.open(self.payments_path + '/xyz')
    9498        self.browser.getLink("Pay via Interswitch", index=0).click()
    95         self.assertMatches('...<input type="hidden" name="pay_item_id" value="102" />...',
     99        self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />' in
    96100                           self.browser.contents)
    97101        self.assertMatches('...Total Amount Authorized:...',
    98102                           self.browser.contents)
    99103        self.assertEqual(self.student.current_mode, 'ug_ft')
    100         self.assertMatches(
    101             '...<input type="hidden" name="amount" value="87600" />...',
    102             self.browser.contents)
     104        # 5000 provider charge and 250 gateway charge have been added
     105        self.assertTrue(
     106            '<input type="hidden" name="amount" value="625000" />' in
     107            self.browser.contents)
     108        self.assertEqual(acc_payment.amount_auth, 6250)
     109        self.assertEqual(acc_payment.net_amt, 1000)
    103110        delta = timedelta(days=8)
    104111        acc_payment.creation_date -= delta
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/utils.py

    r15744 r15773  
    2121    ADMITTED, CLEARANCE, CLEARED, RETURNING, PAID, REGISTERED, VALIDATED)
    2222from kofacustom.nigeria.students.utils import NigeriaStudentsUtils
    23 from kofacustom.iuokada.interswitch.browser import GATEWAY_AMT
    2423from kofacustom.iuokada.interfaces import MessageFactory as _
    2524
     
    123122                    amount = getattr(certificate, 'school_fee_2', 0.0)
    124123                if amount and category == 'schoolfee40':
    125                     amount = 0.4*amount + 0.6*GATEWAY_AMT
     124                    amount = 0.4*amount
    126125                elif amount and category == 'secondinstal':
    127                     amount = 0.6*amount + 0.4*GATEWAY_AMT
     126                    amount = 0.6*amount
    128127        elif category == 'clearance':
    129128            try:
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/utils/utils.py

    r15738 r15773  
    2929        'schoolfee': 'Tuition Plus (total amount)',
    3030        'schoolfee40': 'Tuition Plus (40% - 1st instalment)',
    31         'secondinstal': 'Tuition Plus (60% - 2nd instalment))',
     31        'secondinstal': 'Tuition Plus (60% - 2nd instalment)',
    3232        'clearance': 'Acceptance Fee',
    3333        'registration': 'Registration Fee',
Note: See TracChangeset for help on using the changeset viewer.