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