Changeset 15773 for main/kofacustom.iuokada/trunk/src
- Timestamp:
- 7 Nov 2019, 17:45:43 (5 years ago)
- 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 22 22 from kofacustom.nigeria.etranzact.studentsbrowser import ( 23 23 EtranzactPageStudent, EtranzactReceiveResponseStudent, 24 EtranzactRequestPaymentStatusPageStudent )24 EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated) 25 25 from kofacustom.nigeria.etranzact.payoutletbrowser import ( 26 EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant) 26 EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, 27 EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, 28 payoutlet_module_activated) 29 from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice 27 30 28 31 # Temporarily we can use the test portal like in kofacustom.nigeria … … 35 38 #SECRET_KEY = 36 39 #TERMINAL_ID = 40 GATEWAY_AMT = 500.0 37 41 LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' 38 42 … … 44 48 terminal_id = TERMINAL_ID 45 49 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 46 70 47 71 class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): … … 66 90 terminal_id = TERMINAL_ID 67 91 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 68 112 69 113 class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): … … 81 125 logo_url = LOGO_URL 82 126 127 # Payoutlet customizations 128 129 class 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 153 class 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 83 175 class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): 84 176 """ Query history of Etranzact payments … … 94 186 host = HOST 95 187 https = HTTPS 188 189 class 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 83 83 84 84 # 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 ) 85 91 86 92 late_registration_fee = schema.Float( -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/interswitch/browser.py
r15728 r15773 61 61 product_id = PRODUCT_ID 62 62 mac = MAC 63 gateway_amt = GATEWAY_AMT 63 64 64 65 def update(self): … … 68 69 self.redirect(self.url(self.context, '@@index')) 69 70 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' 70 78 student = self.student 71 79 xmldict = self.xmldict … … 75 83 xmldict['provider_bank_id'] = PROVIDER_BANK_ID 76 84 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME 77 provider_amt = 0.078 85 xmldict['institution_acct'] = '' 79 86 xmldict['institution_bank_id'] = '' 80 provider_amt = 5000.087 provider_amt = 0.0 81 88 self.pay_item_id = '' 82 89 # Institution data … … 103 110 xmldict['institution_item_name'] = self.context.category 104 111 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 108 116 if provider_amt == 0: 109 117 xmltext = """<payment_item_detail> … … 120 128 </payment_item_detail>""" % xmldict 121 129 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) 125 131 hashargs = ( 126 132 self.context.p_id + … … 144 150 product_id = PRODUCT_ID 145 151 mac = MAC 152 gateway_amt = GATEWAY_AMT 146 153 147 154 def update(self): … … 151 158 self.redirect(self.url(self.context, '@@index')) 152 159 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) 153 168 xmldict = {} 154 provider_amt = 400.0169 provider_amt = 0.0 155 170 xmldict['institution_acct'] = '0040484781' 156 171 xmldict['institution_bank_id'] = '31' … … 160 175 xmldict['provider_bank_id'] = PROVIDER_BANK_ID 161 176 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME 162 xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT)163 177 xmldict['institution_item_name'] = self.context.category 164 178 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 166 183 xmltext = """<payment_item_detail> 167 184 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> … … 171 188 </payment_item_detail>""" % xmldict 172 189 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) 176 191 hashargs = ( 177 192 self.context.p_id + -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/interswitch/tests.py
r15728 r15773 75 75 self.browser.contents) 76 76 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 82 86 self.browser.contents) 83 87 … … 86 90 acc_payment = createObject('waeup.StudentOnlinePayment') 87 91 acc_payment.p_state = 'unpaid' 88 acc_payment.p_category = ' clearance'92 acc_payment.p_category = 'registration' 89 93 acc_payment.p_id = 'xyz' 90 94 acc_payment.pay_item_id = '123' 91 acc_payment.amount_auth = 876.095 acc_payment.amount_auth = 1000.0 92 96 self.student['payments']['xyz'] = acc_payment 93 97 self.browser.open(self.payments_path + '/xyz') 94 98 self.browser.getLink("Pay via Interswitch", index=0).click() 95 self.assert Matches('...<input type="hidden" name="pay_item_id" value="102" />...',99 self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />' in 96 100 self.browser.contents) 97 101 self.assertMatches('...Total Amount Authorized:...', 98 102 self.browser.contents) 99 103 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) 103 110 delta = timedelta(days=8) 104 111 acc_payment.creation_date -= delta -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/utils.py
r15744 r15773 21 21 ADMITTED, CLEARANCE, CLEARED, RETURNING, PAID, REGISTERED, VALIDATED) 22 22 from kofacustom.nigeria.students.utils import NigeriaStudentsUtils 23 from kofacustom.iuokada.interswitch.browser import GATEWAY_AMT24 23 from kofacustom.iuokada.interfaces import MessageFactory as _ 25 24 … … 123 122 amount = getattr(certificate, 'school_fee_2', 0.0) 124 123 if amount and category == 'schoolfee40': 125 amount = 0.4*amount + 0.6*GATEWAY_AMT124 amount = 0.4*amount 126 125 elif amount and category == 'secondinstal': 127 amount = 0.6*amount + 0.4*GATEWAY_AMT126 amount = 0.6*amount 128 127 elif category == 'clearance': 129 128 try: -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/utils/utils.py
r15738 r15773 29 29 'schoolfee': 'Tuition Plus (total amount)', 30 30 'schoolfee40': 'Tuition Plus (40% - 1st instalment)', 31 'secondinstal': 'Tuition Plus (60% - 2nd instalment) )',31 'secondinstal': 'Tuition Plus (60% - 2nd instalment)', 32 32 'clearance': 'Acceptance Fee', 33 33 'registration': 'Registration Fee',
Note: See TracChangeset for help on using the changeset viewer.