[15601] | 1 | ## $Id: browser.py 16084 2020-05-04 13:33:15Z 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 ( |
---|
[16084] | 34 | HOST, HTTPS) |
---|
[15601] | 35 | |
---|
[15824] | 36 | HOST = 'www.etranzact.net' |
---|
| 37 | HTTPS = True |
---|
[15773] | 38 | GATEWAY_AMT = 500.0 |
---|
[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'), |
---|
| 46 | 'transcript_overseas': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
| 47 | 'registration': ('7007139599','KGHjZ2hRbaDJGBX8'), |
---|
| 48 | 'book': ('7007139600','rrKE2Ua7eu8TF0Is'), |
---|
| 49 | 'parentsconsult': ('7007139598','HsqjOlAB5xfQNDyo'), |
---|
| 50 | 'sundry': ('7007139591','0XkOFShPnWn8tY5O'), |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | def determine_appl_params(payment): |
---|
| 54 | terminal_id = '' |
---|
| 55 | secret_key = '' |
---|
| 56 | if payment.__parent__.__parent__.prefix.startswith('pg'): |
---|
| 57 | terminal_id = '7007139606' |
---|
| 58 | secret_key = 'E64s3IN9cXRJeltY' |
---|
| 59 | else: |
---|
| 60 | terminal_id = '7007139604' |
---|
| 61 | secret_key = 'vlEEJxvJBjC468g1' |
---|
| 62 | return terminal_id, secret_key |
---|
| 63 | |
---|
| 64 | def determine_stud_params(payment): |
---|
| 65 | terminal_id = '' |
---|
| 66 | secret_key = '' |
---|
| 67 | for key in WEBCONNECT_STUD_PARAMS.keys(): |
---|
| 68 | if payment.p_category == key: |
---|
| 69 | terminal_id = WEBCONNECT_STUD_PARAMS[key][0] |
---|
| 70 | secret_key = WEBCONNECT_STUD_PARAMS[key][1] |
---|
| 71 | if not terminal_id: |
---|
| 72 | terminal_id = WEBCONNECT_STUD_PARAMS['sundry'][0] |
---|
| 73 | secret_key = WEBCONNECT_STUD_PARAMS['sundry'][1] |
---|
| 74 | return terminal_id, secret_key |
---|
| 75 | |
---|
[15601] | 76 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
| 77 | |
---|
| 78 | host = HOST |
---|
| 79 | https = HTTPS |
---|
| 80 | logo_url = LOGO_URL |
---|
[15773] | 81 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 82 | |
---|
[16084] | 83 | @property |
---|
| 84 | def terminal_id(self): |
---|
| 85 | return determine_appl_params(self.context)[0] |
---|
| 86 | |
---|
| 87 | @property |
---|
| 88 | def secret_key(self): |
---|
| 89 | return determine_appl_params(self.context)[1] |
---|
| 90 | |
---|
[15773] | 91 | def update(self): |
---|
[15999] | 92 | if not webconnect_module_activated( |
---|
| 93 | self.context.__parent__.__parent__.year, self.context): |
---|
| 94 | self.flash(_('Forbidden'), type='danger') |
---|
| 95 | self.redirect(self.url(self.context, '@@index')) |
---|
| 96 | return |
---|
[15773] | 97 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 98 | # and add the gateway amount. |
---|
| 99 | if not self.context.r_company: |
---|
| 100 | self.context.net_amt = self.context.amount_auth |
---|
| 101 | self.context.amount_auth += self.gateway_amt |
---|
| 102 | self.context.gateway_amt = self.gateway_amt |
---|
| 103 | self.context.r_company = u'etranzact' |
---|
| 104 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 105 | error = self.init_update() |
---|
| 106 | if error: |
---|
| 107 | self.flash(error, type='danger') |
---|
| 108 | self.redirect(self.url(self.context, '@@index')) |
---|
| 109 | return |
---|
| 110 | return |
---|
| 111 | |
---|
[15601] | 112 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
| 113 | |
---|
[16084] | 114 | @property |
---|
| 115 | def terminal_id(self): |
---|
| 116 | return determine_appl_params(self.context)[0] |
---|
[15601] | 117 | |
---|
[16084] | 118 | @property |
---|
| 119 | def secret_key(self): |
---|
| 120 | return determine_appl_params(self.context)[1] |
---|
| 121 | |
---|
[15601] | 122 | class CustomEtranzactRequestPaymentStatusPageApplicant( |
---|
| 123 | EtranzactRequestPaymentStatusPageApplicant): |
---|
| 124 | |
---|
| 125 | host = HOST |
---|
| 126 | https = HTTPS |
---|
| 127 | logo_url = LOGO_URL |
---|
| 128 | |
---|
[16084] | 129 | @property |
---|
| 130 | def terminal_id(self): |
---|
| 131 | return determine_appl_params(self.context)[0] |
---|
| 132 | |
---|
| 133 | @property |
---|
| 134 | def secret_key(self): |
---|
| 135 | return determine_appl_params(self.context)[1] |
---|
| 136 | |
---|
[15601] | 137 | class CustomEtranzactPageStudent(EtranzactPageStudent): |
---|
| 138 | |
---|
| 139 | host = HOST |
---|
| 140 | https = HTTPS |
---|
| 141 | logo_url = LOGO_URL |
---|
[15773] | 142 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 143 | |
---|
[16084] | 144 | @property |
---|
| 145 | def terminal_id(self): |
---|
| 146 | return determine_stud_params(self.context)[0] |
---|
| 147 | |
---|
| 148 | @property |
---|
| 149 | def secret_key(self): |
---|
| 150 | return determine_stud_params(self.context)[1] |
---|
| 151 | |
---|
[15773] | 152 | def update(self): |
---|
[15999] | 153 | if not webconnect_module_activated( |
---|
| 154 | self.context.student.current_session, self.context): |
---|
| 155 | self.flash(_('Forbidden'), type='danger') |
---|
| 156 | self.redirect(self.url(self.context, '@@index')) |
---|
| 157 | return |
---|
[15773] | 158 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 159 | # and add the gateway amount. |
---|
| 160 | if not self.context.r_company: |
---|
| 161 | self.context.net_amt = self.context.amount_auth |
---|
| 162 | self.context.amount_auth += self.gateway_amt |
---|
| 163 | self.context.gateway_amt = self.gateway_amt |
---|
| 164 | self.context.r_company = u'etranzact' |
---|
| 165 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 166 | error = self.init_update() |
---|
| 167 | if error: |
---|
| 168 | self.flash(error, type='danger') |
---|
| 169 | self.redirect(self.url(self.context, '@@index')) |
---|
| 170 | return |
---|
| 171 | return |
---|
| 172 | |
---|
[15601] | 173 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
| 174 | |
---|
[16084] | 175 | @property |
---|
| 176 | def terminal_id(self): |
---|
| 177 | return determine_stud_params(self.context)[0] |
---|
[15601] | 178 | |
---|
[16084] | 179 | @property |
---|
| 180 | def secret_key(self): |
---|
| 181 | return determine_stud_params(self.context)[1] |
---|
| 182 | |
---|
[15601] | 183 | class CustomEtranzactRequestPaymentStatusPageStudent( |
---|
| 184 | EtranzactRequestPaymentStatusPageStudent): |
---|
| 185 | |
---|
| 186 | host = HOST |
---|
| 187 | https = HTTPS |
---|
| 188 | logo_url = LOGO_URL |
---|
| 189 | |
---|
[16084] | 190 | @property |
---|
| 191 | def terminal_id(self): |
---|
| 192 | return determine_stud_params(self.context)[0] |
---|
| 193 | |
---|
| 194 | @property |
---|
| 195 | def secret_key(self): |
---|
| 196 | return determine_stud_params(self.context)[1] |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
[15773] | 202 | # Payoutlet customizations |
---|
| 203 | |
---|
| 204 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
| 205 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
| 206 | """ |
---|
| 207 | gateway_amt = GATEWAY_AMT |
---|
| 208 | |
---|
| 209 | def update(self): |
---|
| 210 | if not payoutlet_module_activated( |
---|
| 211 | self.context.student.current_session, self.context): |
---|
[15999] | 212 | self.flash(_('Forbidden'), type='danger') |
---|
| 213 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 214 | return |
---|
| 215 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 216 | # and add the gateway amount. |
---|
| 217 | provider_amt = 0.0 |
---|
| 218 | if self.context.p_category == 'registration': |
---|
| 219 | provider_amt = 5000.0 |
---|
| 220 | if not self.context.r_company: |
---|
| 221 | self.context.net_amt = self.context.amount_auth |
---|
| 222 | self.context.amount_auth += self.gateway_amt |
---|
| 223 | self.context.amount_auth += provider_amt |
---|
| 224 | self.context.gateway_amt = self.gateway_amt |
---|
| 225 | self.context.provider_amt = provider_amt |
---|
| 226 | self.context.r_company = u'etranzact' |
---|
| 227 | return |
---|
| 228 | |
---|
| 229 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
| 230 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
| 231 | """ |
---|
| 232 | gateway_amt = GATEWAY_AMT |
---|
| 233 | |
---|
| 234 | def update(self): |
---|
| 235 | if not payoutlet_module_activated( |
---|
| 236 | self.context.__parent__.__parent__.year, self.context): |
---|
[15999] | 237 | self.flash(_('Forbidden'), type='danger') |
---|
| 238 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 239 | return |
---|
| 240 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 241 | # and add the gateway amount. |
---|
| 242 | provider_amt = 0.0 |
---|
| 243 | if not self.context.r_company: |
---|
| 244 | self.context.net_amt = self.context.amount_auth |
---|
| 245 | self.context.amount_auth += self.gateway_amt |
---|
| 246 | self.context.amount_auth += provider_amt |
---|
| 247 | self.context.gateway_amt = self.gateway_amt |
---|
| 248 | self.context.provider_amt = provider_amt |
---|
| 249 | self.context.r_company = u'etranzact' |
---|
| 250 | return |
---|
| 251 | |
---|
[15733] | 252 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
| 253 | """ Query history of Etranzact payments |
---|
| 254 | """ |
---|
[16084] | 255 | terminal_id = '7007134590' |
---|
[15733] | 256 | host = HOST |
---|
| 257 | https = HTTPS |
---|
[15601] | 258 | |
---|
[15733] | 259 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
| 260 | """ Query history of Etranzact payments |
---|
| 261 | """ |
---|
[15898] | 262 | terminal_id = '7009158847' |
---|
[15733] | 263 | host = HOST |
---|
[15773] | 264 | https = HTTPS |
---|
| 265 | |
---|
| 266 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
| 267 | """A simple webservice to publish payment and payer details on request from |
---|
| 268 | accepted IP addresses without authentication. |
---|
| 269 | """ |
---|
| 270 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
| 271 | ACCEPTED_IP = None |
---|
| 272 | |
---|
| 273 | CATEGORY_MAPPING = { |
---|
[15781] | 274 | 'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',), |
---|
| 275 | 'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',), |
---|
| 276 | 'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',), |
---|
| 277 | 'IUO_TRANSCRIPT_FEE': ('transcript',), |
---|
| 278 | 'IUO_REGISTRATION_FEE': ('registration',), |
---|
| 279 | 'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',), |
---|
| 280 | 'IUO_BOOK_DEPOSIT_FEE': ('book',), |
---|
| 281 | 'IUO_SUNDRY_FEES': ('late_registration', |
---|
| 282 | 'science','clinical','develop','municipal', |
---|
| 283 | 'alumni','conv','matric','waecneco','jambver','pharmlab','lo_ident', |
---|
[15937] | 284 | 'change_course','resit1','resit2','resit3','resit4','resit5', |
---|
| 285 | 'resit6','resit7','resit8','resit9','iuits','fine','combi'), |
---|
[15773] | 286 | } |
---|