[15601] | 1 | ## $Id: browser.py 17545 2023-08-17 03:53:32Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | |
---|
| 19 | from kofacustom.nigeria.etranzact.applicantsbrowser import ( |
---|
| 20 | EtranzactPageApplicant, EtranzactReceiveResponseApplicant, |
---|
| 21 | EtranzactRequestPaymentStatusPageApplicant) |
---|
| 22 | from kofacustom.nigeria.etranzact.studentsbrowser import ( |
---|
| 23 | EtranzactPageStudent, EtranzactReceiveResponseStudent, |
---|
[15773] | 24 | EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated) |
---|
[15733] | 25 | from kofacustom.nigeria.etranzact.payoutletbrowser import ( |
---|
[15773] | 26 | EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, |
---|
| 27 | EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, |
---|
| 28 | payoutlet_module_activated) |
---|
| 29 | from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice |
---|
[15601] | 30 | |
---|
| 31 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
| 32 | |
---|
| 33 | from kofacustom.nigeria.etranzact.tests import ( |
---|
[16104] | 34 | HOST, HTTPS) |
---|
[15601] | 35 | |
---|
[16637] | 36 | HOST = 'www.etranzactng.net' |
---|
[15824] | 37 | HTTPS = True |
---|
[16141] | 38 | GATEWAY_AMT = 0.0 # is beeing added by Etranzact |
---|
[15601] | 39 | LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' |
---|
| 40 | |
---|
[16084] | 41 | WEBCONNECT_STUD_PARAMS = { |
---|
| 42 | 'schoolfee': ('7007139588','QIgl9a35R30A1RGK'), |
---|
| 43 | 'schoolfee40': ('7007139589','3coU0eolOEbEUeO3'), |
---|
| 44 | 'secondinstal': ('7007139590','zGpEjy6CdPxCHqen'), |
---|
| 45 | 'transcript_local': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
[16142] | 46 | 'transcript': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
[16084] | 47 | 'transcript_overseas': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
| 48 | 'registration': ('7007139599','KGHjZ2hRbaDJGBX8'), |
---|
| 49 | 'book': ('7007139600','rrKE2Ua7eu8TF0Is'), |
---|
| 50 | 'parentsconsult': ('7007139598','HsqjOlAB5xfQNDyo'), |
---|
| 51 | 'sundry': ('7007139591','0XkOFShPnWn8tY5O'), |
---|
[17545] | 52 | 'health_insurance':('7007140478', 'Be24m7O7iODZXcYF'), |
---|
[16084] | 53 | } |
---|
| 54 | |
---|
| 55 | def determine_appl_params(payment): |
---|
| 56 | terminal_id = '' |
---|
| 57 | secret_key = '' |
---|
| 58 | if payment.__parent__.__parent__.prefix.startswith('pg'): |
---|
| 59 | terminal_id = '7007139606' |
---|
| 60 | secret_key = 'E64s3IN9cXRJeltY' |
---|
| 61 | else: |
---|
| 62 | terminal_id = '7007139604' |
---|
| 63 | secret_key = 'vlEEJxvJBjC468g1' |
---|
| 64 | return terminal_id, secret_key |
---|
| 65 | |
---|
| 66 | def determine_stud_params(payment): |
---|
| 67 | terminal_id = '' |
---|
| 68 | secret_key = '' |
---|
| 69 | for key in WEBCONNECT_STUD_PARAMS.keys(): |
---|
| 70 | if payment.p_category == key: |
---|
| 71 | terminal_id = WEBCONNECT_STUD_PARAMS[key][0] |
---|
| 72 | secret_key = WEBCONNECT_STUD_PARAMS[key][1] |
---|
| 73 | if not terminal_id: |
---|
| 74 | terminal_id = WEBCONNECT_STUD_PARAMS['sundry'][0] |
---|
| 75 | secret_key = WEBCONNECT_STUD_PARAMS['sundry'][1] |
---|
| 76 | return terminal_id, secret_key |
---|
| 77 | |
---|
[15601] | 78 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
| 79 | |
---|
| 80 | host = HOST |
---|
| 81 | https = HTTPS |
---|
| 82 | logo_url = LOGO_URL |
---|
[15773] | 83 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 84 | |
---|
[16084] | 85 | @property |
---|
| 86 | def terminal_id(self): |
---|
| 87 | return determine_appl_params(self.context)[0] |
---|
| 88 | |
---|
| 89 | @property |
---|
| 90 | def secret_key(self): |
---|
| 91 | return determine_appl_params(self.context)[1] |
---|
| 92 | |
---|
[15773] | 93 | def update(self): |
---|
[15999] | 94 | if not webconnect_module_activated( |
---|
| 95 | self.context.__parent__.__parent__.year, self.context): |
---|
[16350] | 96 | self.flash('Forbidden', type='danger') |
---|
[15999] | 97 | self.redirect(self.url(self.context, '@@index')) |
---|
| 98 | return |
---|
[15773] | 99 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 100 | # and add the gateway amount. |
---|
| 101 | if not self.context.r_company: |
---|
| 102 | self.context.net_amt = self.context.amount_auth |
---|
| 103 | self.context.amount_auth += self.gateway_amt |
---|
| 104 | self.context.gateway_amt = self.gateway_amt |
---|
| 105 | self.context.r_company = u'etranzact' |
---|
| 106 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 107 | error = self.init_update() |
---|
| 108 | if error: |
---|
| 109 | self.flash(error, type='danger') |
---|
| 110 | self.redirect(self.url(self.context, '@@index')) |
---|
| 111 | return |
---|
| 112 | return |
---|
| 113 | |
---|
[15601] | 114 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
| 115 | |
---|
[16084] | 116 | @property |
---|
| 117 | def terminal_id(self): |
---|
| 118 | return determine_appl_params(self.context)[0] |
---|
[15601] | 119 | |
---|
[16084] | 120 | @property |
---|
| 121 | def secret_key(self): |
---|
| 122 | return determine_appl_params(self.context)[1] |
---|
| 123 | |
---|
[15601] | 124 | class CustomEtranzactRequestPaymentStatusPageApplicant( |
---|
| 125 | EtranzactRequestPaymentStatusPageApplicant): |
---|
| 126 | |
---|
| 127 | host = HOST |
---|
| 128 | https = HTTPS |
---|
| 129 | logo_url = LOGO_URL |
---|
| 130 | |
---|
[16084] | 131 | @property |
---|
| 132 | def terminal_id(self): |
---|
| 133 | return determine_appl_params(self.context)[0] |
---|
| 134 | |
---|
| 135 | @property |
---|
| 136 | def secret_key(self): |
---|
| 137 | return determine_appl_params(self.context)[1] |
---|
| 138 | |
---|
[15601] | 139 | class CustomEtranzactPageStudent(EtranzactPageStudent): |
---|
| 140 | |
---|
| 141 | host = HOST |
---|
| 142 | https = HTTPS |
---|
| 143 | logo_url = LOGO_URL |
---|
[15773] | 144 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 145 | |
---|
[16084] | 146 | @property |
---|
| 147 | def terminal_id(self): |
---|
| 148 | return determine_stud_params(self.context)[0] |
---|
| 149 | |
---|
| 150 | @property |
---|
| 151 | def secret_key(self): |
---|
| 152 | return determine_stud_params(self.context)[1] |
---|
| 153 | |
---|
[15773] | 154 | def update(self): |
---|
[15999] | 155 | if not webconnect_module_activated( |
---|
| 156 | self.context.student.current_session, self.context): |
---|
| 157 | self.flash(_('Forbidden'), type='danger') |
---|
| 158 | self.redirect(self.url(self.context, '@@index')) |
---|
| 159 | return |
---|
[15773] | 160 | # Already now it becomes an Etranzact 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'etranzact' |
---|
| 167 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 168 | error = self.init_update() |
---|
| 169 | if error: |
---|
| 170 | self.flash(error, type='danger') |
---|
| 171 | self.redirect(self.url(self.context, '@@index')) |
---|
| 172 | return |
---|
| 173 | return |
---|
| 174 | |
---|
[15601] | 175 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
| 176 | |
---|
[16084] | 177 | @property |
---|
| 178 | def terminal_id(self): |
---|
| 179 | return determine_stud_params(self.context)[0] |
---|
[15601] | 180 | |
---|
[16084] | 181 | @property |
---|
| 182 | def secret_key(self): |
---|
| 183 | return determine_stud_params(self.context)[1] |
---|
| 184 | |
---|
[15601] | 185 | class CustomEtranzactRequestPaymentStatusPageStudent( |
---|
| 186 | EtranzactRequestPaymentStatusPageStudent): |
---|
| 187 | |
---|
| 188 | host = HOST |
---|
| 189 | https = HTTPS |
---|
| 190 | logo_url = LOGO_URL |
---|
| 191 | |
---|
[16084] | 192 | @property |
---|
| 193 | def terminal_id(self): |
---|
| 194 | return determine_stud_params(self.context)[0] |
---|
| 195 | |
---|
| 196 | @property |
---|
| 197 | def secret_key(self): |
---|
| 198 | return determine_stud_params(self.context)[1] |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | |
---|
[15773] | 204 | # Payoutlet customizations |
---|
| 205 | |
---|
| 206 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
| 207 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
| 208 | """ |
---|
| 209 | gateway_amt = GATEWAY_AMT |
---|
| 210 | |
---|
| 211 | def update(self): |
---|
| 212 | if not payoutlet_module_activated( |
---|
| 213 | self.context.student.current_session, self.context): |
---|
[15999] | 214 | self.flash(_('Forbidden'), type='danger') |
---|
| 215 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 216 | return |
---|
| 217 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 218 | # and add the gateway amount. |
---|
| 219 | if not self.context.r_company: |
---|
| 220 | self.context.net_amt = self.context.amount_auth |
---|
| 221 | self.context.amount_auth += self.gateway_amt |
---|
| 222 | self.context.gateway_amt = self.gateway_amt |
---|
| 223 | self.context.r_company = u'etranzact' |
---|
| 224 | return |
---|
| 225 | |
---|
| 226 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
| 227 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
| 228 | """ |
---|
| 229 | gateway_amt = GATEWAY_AMT |
---|
| 230 | |
---|
| 231 | def update(self): |
---|
| 232 | if not payoutlet_module_activated( |
---|
| 233 | self.context.__parent__.__parent__.year, self.context): |
---|
[15999] | 234 | self.flash(_('Forbidden'), type='danger') |
---|
| 235 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 236 | return |
---|
| 237 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 238 | # and add the gateway amount. |
---|
| 239 | if not self.context.r_company: |
---|
| 240 | self.context.net_amt = self.context.amount_auth |
---|
| 241 | self.context.amount_auth += self.gateway_amt |
---|
| 242 | self.context.gateway_amt = self.gateway_amt |
---|
| 243 | self.context.r_company = u'etranzact' |
---|
| 244 | return |
---|
| 245 | |
---|
[15733] | 246 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
| 247 | """ Query history of Etranzact payments |
---|
| 248 | """ |
---|
[16084] | 249 | terminal_id = '7007134590' |
---|
[15733] | 250 | host = HOST |
---|
| 251 | https = HTTPS |
---|
[15601] | 252 | |
---|
[15733] | 253 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
| 254 | """ Query history of Etranzact payments |
---|
| 255 | """ |
---|
[15898] | 256 | terminal_id = '7009158847' |
---|
[15733] | 257 | host = HOST |
---|
[15773] | 258 | https = HTTPS |
---|
| 259 | |
---|
| 260 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
| 261 | """A simple webservice to publish payment and payer details on request from |
---|
| 262 | accepted IP addresses without authentication. |
---|
| 263 | """ |
---|
| 264 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
| 265 | ACCEPTED_IP = None |
---|
| 266 | |
---|
| 267 | CATEGORY_MAPPING = { |
---|
[15781] | 268 | 'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',), |
---|
| 269 | 'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',), |
---|
| 270 | 'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',), |
---|
[16111] | 271 | |
---|
| 272 | 'IUO_SUNDRY_FEES': ('combi',), |
---|
| 273 | |
---|
| 274 | 'IUO_MATRICULATION_FEE': ('matric',), |
---|
| 275 | 'IUO_LATE_REGISTRATION_FEE': ('late_registration',), |
---|
[16311] | 276 | 'IUO_WAEC/NECO_VERIFICATION_FEE': ('waecneco',), |
---|
[16111] | 277 | 'IUO_JAMB_VERIFICATION': ('jambver',), |
---|
| 278 | 'IUO_CONVOCATION_FEE': ('conv',), |
---|
| 279 | 'IUO_ALUMNI_FEE': ('alumni',), |
---|
| 280 | 'IUO_SCIENCE_BENCE_FEE': ('science',), |
---|
| 281 | 'IUO_LETTER_OF_IDENTIFICATION_FEE': ('lo_ident',), |
---|
| 282 | 'IUO_CHANGE_OF_COURSE_FEE': ('change_course',), |
---|
| 283 | 'IUO_IUITS_FEE': ('iuits',), |
---|
| 284 | 'IUO_FINES_FEE': ('fine',), |
---|
| 285 | 'IUO_PHARMACY_LAB_SUPPORT_FEE': ('pharmlab',), |
---|
| 286 | 'IUO_MAKEUP_FEE': ('resit1', 'resit2', 'resit3', 'resit4', |
---|
| 287 | 'resit5', 'resit6', 'resit7', 'resit8', |
---|
| 288 | 'resit9',), |
---|
| 289 | 'IUO_CLINICAL_FEE_MEDICAL_STUDENTS': ('clinical',), |
---|
| 290 | 'IUO_TRANSCRIPT_FEE_INTERNATIONAL': ('transcript_overseas',), |
---|
[16142] | 291 | 'IUO_TRANCRIPT_FEE_LOCAL': ('transcript_local', 'transcript'), |
---|
[16261] | 292 | 'IUO_ACCEPTANCE_FEE': ('clearance',), |
---|
| 293 | 'IUO_CLEARANCE_FEE': ('grad_clearance',), |
---|
[16111] | 294 | 'IUO_ID_CARD_FEE': ('id_card',), |
---|
[15781] | 295 | 'IUO_REGISTRATION_FEE': ('registration',), |
---|
[16111] | 296 | 'IUO_DEVELOPMENT_FEE': ('develop',), |
---|
| 297 | 'IUO_MUNICIPAL_FEE': ('municipal_fresh','municipal_returning'), |
---|
| 298 | 'IUO_BOOK_DEPOSIT': ('book',), |
---|
[15781] | 299 | 'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',), |
---|
[16340] | 300 | |
---|
| 301 | 'IUO_APPLICATION_FORM_UNDERGRADUATE': ('application',), |
---|
| 302 | 'IUO_APPLICATION_FORM_POSTGRADUATE': ('application',), |
---|
[16397] | 303 | |
---|
[16577] | 304 | 'IUO_MAKE_UP_REGISTRATION_FEE': ('makeup_admin',), |
---|
[17519] | 305 | 'IUO_STUDENT_HEALTH_INSURANCE': ('health_insurance',), |
---|
[16577] | 306 | |
---|
[16685] | 307 | 'IUO_COMBI_PAYMENT': ('combi',), |
---|
| 308 | |
---|
[16397] | 309 | 'JUPEB_FORM_FEE': ('jupeb_form',), |
---|
| 310 | 'JUPEB_ACCEPTANCE_FEE': ('jupeb_acc',), |
---|
| 311 | 'JUPEB_SCIENCE_COURSE': ('jupeb_sci',), |
---|
| 312 | 'JUPEB_ARTS_COURSE': ('jupeb_arts',), |
---|
| 313 | 'JUPEB_HOSTEL_FEE': ('jupeb_hostel',), |
---|
| 314 | 'JUPEB_REGISTRATION_FEE': ('jupeb_reg',), |
---|
[15773] | 315 | } |
---|