1 | ## $Id: browser.py 14888 2017-11-01 17:03:53Z 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.remita.studentsbrowser import ( |
---|
20 | module_activated, |
---|
21 | RemitaRequestPaymentStatusPageStudent, |
---|
22 | RemitaVerifyPaymentStatusPageStudent, |
---|
23 | RemitaPageStudent) |
---|
24 | from kofacustom.nigeria.remita.applicantsbrowser import ( |
---|
25 | RemitaRequestPaymentStatusPageApplicant, |
---|
26 | RemitaVerifyPaymentStatusPageApplicant, |
---|
27 | RemitaPageApplicant) |
---|
28 | |
---|
29 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
30 | MERCHANTID = '2067163382' |
---|
31 | HOST = 'login.remita.net' |
---|
32 | HTTPS = True |
---|
33 | API_KEY = '309418' |
---|
34 | SERVICETYPEID = '4430731' |
---|
35 | |
---|
36 | class CustomRemitaRequestPaymentStatusPageStudent( |
---|
37 | RemitaRequestPaymentStatusPageStudent): |
---|
38 | """ Request webservice view for the Remita gateway. |
---|
39 | """ |
---|
40 | |
---|
41 | merchantId = MERCHANTID |
---|
42 | host = HOST |
---|
43 | https = HTTPS |
---|
44 | api_key = API_KEY |
---|
45 | |
---|
46 | class CustomRemitaVerifyPaymentStatusPageStudent( |
---|
47 | RemitaVerifyPaymentStatusPageStudent): |
---|
48 | """ Request webservice view for the Remita gateway. |
---|
49 | """ |
---|
50 | |
---|
51 | merchantId = MERCHANTID |
---|
52 | host = HOST |
---|
53 | https = HTTPS |
---|
54 | api_key = API_KEY |
---|
55 | |
---|
56 | class CustomRemitaPageStudent(RemitaPageStudent): |
---|
57 | """ View which sends a POST request to the Remita payment gateway. |
---|
58 | """ |
---|
59 | |
---|
60 | merchantId = MERCHANTID |
---|
61 | host = HOST |
---|
62 | https = HTTPS |
---|
63 | api_key = API_KEY |
---|
64 | |
---|
65 | init_url = '/remita/ecomm/split/init.reg' |
---|
66 | |
---|
67 | @property |
---|
68 | def serviceTypeId(self): |
---|
69 | student = self.context.student |
---|
70 | if self.context.p_category == 'schoolfee': |
---|
71 | if student.current_mode.startswith('dp_'): |
---|
72 | return '2067090482' |
---|
73 | if student.current_mode == 'pg_ft': |
---|
74 | return '2067090691' |
---|
75 | if student.current_mode.endswith('pg_pt'): |
---|
76 | return '2067091011' |
---|
77 | if student.current_mode == 'ug_sw': |
---|
78 | return '2066967204' |
---|
79 | if student.current_mode.endswith('ug_ft'): |
---|
80 | return '2067091395' |
---|
81 | if student.current_mode == 'ug_pt': |
---|
82 | return '2067091679' |
---|
83 | if student.faccode == 'JUPEB': |
---|
84 | return '1946888188' |
---|
85 | if self.context.p_category == 'bed_allocation': |
---|
86 | if student.is_postgrad: |
---|
87 | return '2067086599' |
---|
88 | return '2067089893' |
---|
89 | if self.context.p_category == 'hostel_maintenance': |
---|
90 | if student.is_postgrad: |
---|
91 | return '2067089226' |
---|
92 | return '2066966390' |
---|
93 | if self.context.p_category == 'clearance': |
---|
94 | if student.current_mode.startswith('dp_'): |
---|
95 | return '2067080314' |
---|
96 | if student.faccode == 'JUPEB': |
---|
97 | return '1947201668' |
---|
98 | if student.is_postgrad: |
---|
99 | return '2067086157' |
---|
100 | return '2067089446' |
---|
101 | if self.context.p_category == 'jupeb': |
---|
102 | return '1947198586' |
---|
103 | return '' |
---|
104 | |
---|
105 | @property |
---|
106 | def demo_lineitems(self): |
---|
107 | ba1 = self.context.amount_auth / 2 |
---|
108 | ba2 = self.context.amount_auth / 2 |
---|
109 | lineitems = ( |
---|
110 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
111 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
112 | "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"}, |
---|
113 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
114 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
115 | "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"} |
---|
116 | ) |
---|
117 | return lineitems |
---|
118 | |
---|
119 | def dynamic_provider_amt(self, student): |
---|
120 | if student.entry_session >= 2016: |
---|
121 | return 2500.0 |
---|
122 | return 1500.0 |
---|
123 | |
---|
124 | @property |
---|
125 | def lineitems(self): |
---|
126 | provider_amt = 0.0 |
---|
127 | if self.context.p_category == 'schoolfee' and \ |
---|
128 | not self.context.p_item == 'Balance': |
---|
129 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
130 | elif self.context.p_category == 'clearance': |
---|
131 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
132 | inst_amt = self.context.amount_auth - provider_amt |
---|
133 | if self.context.student.faccode == 'JUPEB' \ |
---|
134 | or self.context.student.current_mode == 'dp_ft': |
---|
135 | inst_acct = "0040217361038" |
---|
136 | else: |
---|
137 | inst_acct = "0040217361011" |
---|
138 | if provider_amt: |
---|
139 | lineitems = ( |
---|
140 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
141 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
142 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
143 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
144 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
145 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
146 | ) |
---|
147 | else: |
---|
148 | lineitems = ( |
---|
149 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
150 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
151 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
152 | ) |
---|
153 | return lineitems |
---|
154 | |
---|
155 | def update(self): |
---|
156 | if not module_activated(self.context.student.current_session): |
---|
157 | return |
---|
158 | self.orderId = self.context.p_id |
---|
159 | self.amount = str(self.context.amount_auth) |
---|
160 | error = self.init_update() |
---|
161 | if error: |
---|
162 | self.flash(error, type='danger') |
---|
163 | self.redirect(self.url(self.context, '@@index')) |
---|
164 | return |
---|
165 | return |
---|
166 | |
---|
167 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
168 | RemitaRequestPaymentStatusPageApplicant): |
---|
169 | """ Request webservice view for the Remita gateway. |
---|
170 | """ |
---|
171 | |
---|
172 | merchantId = MERCHANTID |
---|
173 | host = HOST |
---|
174 | https = HTTPS |
---|
175 | api_key = API_KEY |
---|
176 | |
---|
177 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
178 | RemitaVerifyPaymentStatusPageApplicant): |
---|
179 | """ Request webservice view for the Remita gateway. |
---|
180 | """ |
---|
181 | |
---|
182 | merchantId = MERCHANTID |
---|
183 | host = HOST |
---|
184 | https = HTTPS |
---|
185 | api_key = API_KEY |
---|
186 | |
---|
187 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
188 | """ View which sends a POST request to the Remita payment gateway. |
---|
189 | """ |
---|
190 | |
---|
191 | merchantId = MERCHANTID |
---|
192 | host = HOST |
---|
193 | https = HTTPS |
---|
194 | api_key = API_KEY |
---|
195 | |
---|
196 | init_url = '/remita/ecomm/split/init.reg' |
---|
197 | |
---|
198 | @property |
---|
199 | def serviceTypeId(self): |
---|
200 | applicant = self.context.__parent__ |
---|
201 | if applicant.__parent__.prefix.startswith('dp'): |
---|
202 | return '2066963437' |
---|
203 | if applicant.__parent__.prefix in ('spft', ): |
---|
204 | return '2067086388' |
---|
205 | if applicant.__parent__.prefix == 'pre': |
---|
206 | return '1946882248' |
---|
207 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
208 | 'ab','ak','akj','ase'): |
---|
209 | return '2066965951' |
---|
210 | return '' |
---|
211 | |
---|
212 | @property |
---|
213 | def demo_lineitems(self): |
---|
214 | lineitems = ( |
---|
215 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
216 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
217 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
218 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
219 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
220 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
221 | ) |
---|
222 | return lineitems |
---|
223 | |
---|
224 | @property |
---|
225 | def lineitems(self): |
---|
226 | provider_amt = 1000.0 |
---|
227 | if self.context.__parent__.applicant_id.startswith('dp'): |
---|
228 | inst_acct = "0040217361038" |
---|
229 | else: |
---|
230 | inst_acct = "0040217361011" |
---|
231 | #if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
232 | # provider_amt = 200.0 |
---|
233 | inst_amt = self.context.amount_auth - provider_amt |
---|
234 | lineitems = ( |
---|
235 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
236 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
237 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
238 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
239 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
240 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
241 | ) |
---|
242 | return lineitems |
---|
243 | |
---|
244 | def update(self): |
---|
245 | if not module_activated(self.context.__parent__.__parent__.year): |
---|
246 | return |
---|
247 | self.orderId = self.context.p_id |
---|
248 | self.amount = str(self.context.amount_auth) |
---|
249 | error = self.init_update() |
---|
250 | if error: |
---|
251 | self.flash(error, type='danger') |
---|
252 | self.redirect(self.url(self.context, '@@index')) |
---|
253 | return |
---|
254 | return |
---|