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/interswitch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.