[16717] | 1 | ## $Id: browser.py 16717 2021-11-24 06:44:33Z henrik $ |
---|
[15615] | 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, |
---|
[15847] | 24 | EtranzactRequestPaymentStatusPageStudent, |
---|
| 25 | webconnect_module_activated) |
---|
[15756] | 26 | from kofacustom.nigeria.etranzact.payoutletbrowser import ( |
---|
| 27 | EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, |
---|
[15847] | 28 | EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, |
---|
| 29 | payoutlet_module_activated) |
---|
[15756] | 30 | from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice |
---|
[15615] | 31 | |
---|
| 32 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
| 33 | |
---|
| 34 | from kofacustom.nigeria.etranzact.tests import ( |
---|
[15756] | 35 | HOST, HTTPS, SECRET_KEY, TERMINAL_ID, GATEWAY_AMT) |
---|
[15615] | 36 | |
---|
| 37 | #HOST = |
---|
| 38 | #HTTPS = |
---|
| 39 | #SECRET_KEY = |
---|
| 40 | #TERMINAL_ID = |
---|
[15756] | 41 | #GATEWAY_AMT = |
---|
[15615] | 42 | LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' |
---|
| 43 | |
---|
| 44 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
| 45 | |
---|
| 46 | host = HOST |
---|
| 47 | https = HTTPS |
---|
| 48 | secret_key = SECRET_KEY |
---|
| 49 | terminal_id = TERMINAL_ID |
---|
| 50 | logo_url = LOGO_URL |
---|
[15756] | 51 | gateway_amt = GATEWAY_AMT |
---|
[15615] | 52 | |
---|
[15756] | 53 | def update(self): |
---|
[16592] | 54 | if not webconnect_module_activated( |
---|
| 55 | self.context.__parent__.__parent__.year, self.context): |
---|
| 56 | self.flash(_('Forbidden'), type='danger') |
---|
| 57 | self.redirect(self.url(self.context, '@@index')) |
---|
| 58 | return |
---|
[15756] | 59 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 60 | # and add the gateway amount. |
---|
| 61 | if not self.context.r_company: |
---|
| 62 | self.context.net_amt = self.context.amount_auth |
---|
| 63 | self.context.amount_auth += self.gateway_amt |
---|
| 64 | self.context.gateway_amt = self.gateway_amt |
---|
| 65 | self.context.r_company = u'etranzact' |
---|
| 66 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 67 | error = self.init_update() |
---|
| 68 | if error: |
---|
| 69 | self.flash(error, type='danger') |
---|
| 70 | self.redirect(self.url(self.context, '@@index')) |
---|
| 71 | return |
---|
| 72 | |
---|
[15615] | 73 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
| 74 | |
---|
| 75 | secret_key = SECRET_KEY |
---|
| 76 | terminal_id = TERMINAL_ID |
---|
| 77 | |
---|
| 78 | class CustomEtranzactRequestPaymentStatusPageApplicant( |
---|
| 79 | EtranzactRequestPaymentStatusPageApplicant): |
---|
| 80 | |
---|
| 81 | host = HOST |
---|
| 82 | https = HTTPS |
---|
| 83 | secret_key = SECRET_KEY |
---|
| 84 | terminal_id = TERMINAL_ID |
---|
| 85 | logo_url = LOGO_URL |
---|
| 86 | |
---|
| 87 | class CustomEtranzactPageStudent(EtranzactPageStudent): |
---|
| 88 | |
---|
| 89 | host = HOST |
---|
| 90 | https = HTTPS |
---|
| 91 | secret_key = SECRET_KEY |
---|
| 92 | terminal_id = TERMINAL_ID |
---|
| 93 | logo_url = LOGO_URL |
---|
[15756] | 94 | gateway_amt = GATEWAY_AMT |
---|
[15615] | 95 | |
---|
[15756] | 96 | def update(self): |
---|
[16592] | 97 | if not webconnect_module_activated( |
---|
| 98 | self.context.student.current_session, self.context): |
---|
| 99 | self.flash(_('Forbidden'), type='danger') |
---|
| 100 | self.redirect(self.url(self.context, '@@index')) |
---|
| 101 | return |
---|
[15756] | 102 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 103 | # and add the gateway amount. |
---|
| 104 | if not self.context.r_company: |
---|
| 105 | self.context.net_amt = self.context.amount_auth |
---|
| 106 | self.context.amount_auth += self.gateway_amt |
---|
| 107 | self.context.gateway_amt = self.gateway_amt |
---|
| 108 | self.context.r_company = u'etranzact' |
---|
| 109 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 110 | error = self.init_update() |
---|
| 111 | if error: |
---|
| 112 | self.flash(error, type='danger') |
---|
| 113 | self.redirect(self.url(self.context, '@@index')) |
---|
| 114 | return |
---|
| 115 | return |
---|
| 116 | |
---|
[15615] | 117 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
| 118 | |
---|
| 119 | secret_key = SECRET_KEY |
---|
| 120 | terminal_id = TERMINAL_ID |
---|
| 121 | |
---|
| 122 | class CustomEtranzactRequestPaymentStatusPageStudent( |
---|
| 123 | EtranzactRequestPaymentStatusPageStudent): |
---|
| 124 | |
---|
| 125 | host = HOST |
---|
| 126 | https = HTTPS |
---|
| 127 | secret_key = SECRET_KEY |
---|
| 128 | terminal_id = TERMINAL_ID |
---|
| 129 | logo_url = LOGO_URL |
---|
| 130 | |
---|
[15756] | 131 | # Payoutlet customizations |
---|
[15615] | 132 | |
---|
[15756] | 133 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
| 134 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
| 135 | """ |
---|
| 136 | gateway_amt = GATEWAY_AMT |
---|
[15615] | 137 | |
---|
[15756] | 138 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
| 139 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
| 140 | """ |
---|
| 141 | gateway_amt = GATEWAY_AMT |
---|
| 142 | |
---|
| 143 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
| 144 | """ Query history of Etranzact payments |
---|
| 145 | """ |
---|
| 146 | terminal_id = TERMINAL_ID |
---|
| 147 | host = HOST |
---|
| 148 | https = HTTPS |
---|
| 149 | |
---|
| 150 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
| 151 | """ Query history of Etranzact payments |
---|
| 152 | """ |
---|
| 153 | terminal_id = TERMINAL_ID |
---|
| 154 | host = HOST |
---|
| 155 | https = HTTPS |
---|
| 156 | |
---|
| 157 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
| 158 | """A simple webservice to publish payment and payer details on request from |
---|
| 159 | accepted IP addresses without authentication. |
---|
| 160 | """ |
---|
| 161 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
| 162 | ACCEPTED_IP = None |
---|
| 163 | |
---|
| 164 | CATEGORY_MAPPING = { |
---|
| 165 | 'SCHOOLFEE': ('schoolfee',), |
---|
| 166 | } |
---|
| 167 | |
---|