Changeset 15755
- Timestamp:
- 5 Nov 2019, 23:19:58 (5 years ago)
- Location:
- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/payment.py
r15730 r15755 41 41 return 42 42 43 @property44 def net_amt(self):45 return self.amount_auth - self.provider_amt - self.gateway_amt46 47 43 NigeriaApplicantOnlinePayment = attrs_to_fields( 48 NigeriaApplicantOnlinePayment, omit=['display_item', 'net_amt'])44 NigeriaApplicantOnlinePayment, omit=['display_item',]) 49 45 50 46 # Applicant online payments must be importable. So we might need a factory. -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/applicantsbrowser.py
r15702 r15755 33 33 34 34 from kofacustom.nigeria.etranzact.tests import ( 35 TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL )35 TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL, GATEWAY_AMT) 36 36 37 37 grok.templatedir('browser_templates') … … 93 93 terminal_id = TERMINAL_ID 94 94 logo_url = LOGO_URL 95 gateway_amt = GATEWAY_AMT 95 96 96 97 @property … … 101 102 102 103 def init_update(self): 104 if not module_activated(self.context.__parent__.__parent__.year): 105 return _("Etranzact payments deactivated.") 103 106 if self.context.p_state == 'paid': 104 107 return _("Payment ticket can't be re-sent to Etranzact.") … … 116 119 # which authenticates the response. 117 120 self.responseurl = self.url(self.context, 'receive_etranzact') 118 # Already now it becomes a Etranzact payment 119 self.context.r_company = u'etranzact' 120 hashargs = self.amount + self.terminal_id+self.transaction_id \ 121 self.transaction_id = self.context.p_id 122 hashargs = self.amount + self.terminal_id + self.transaction_id \ 121 123 + self.responseurl + self.secret_key 122 124 self.hashvalue = hashlib.md5(hashargs).hexdigest() … … 125 127 126 128 def update(self): 127 if not module_activated(self.context.__parent__.__parent__.year): 128 return 129 self.transaction_id = self.context.p_id 129 # Already now it becomes an Etranzact payment. We set the net amount 130 # and add the gateway amount. 131 if not self.context.r_company: 132 self.context.net_amt = self.context.amount_auth 133 self.context.amount_auth += self.gateway_amt 134 self.context.gateway_amt = self.gateway_amt 135 self.context.r_company = u'etranzact' 130 136 self.amount = "%.1f" % self.context.amount_auth 131 137 error = self.init_update() -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/helpers.py
r15734 r15755 181 181 payment.r_card_num = "%s %s" % (form.get('CARD_TYPE', None), 182 182 form.get('CARD_NO', None)) 183 payment.r_company = u'etranzact'184 183 if payment.r_code != '0': 185 184 msg = _('Unsuccessful response: ${a}', mapping = {'a': payment.r_desc}) -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/payoutletbrowser.py
r15730 r15755 39 39 from kofacustom.nigeria.students.interfaces import INigeriaStudentOnlinePayment 40 40 from kofacustom.nigeria.applicants.interfaces import INigeriaApplicantOnlinePayment 41 from kofacustom.nigeria.etranzact.tests import HOST, TERMINAL_ID, HTTPS 41 from kofacustom.nigeria.etranzact.tests import HOST, TERMINAL_ID, HTTPS, GATEWAY_AMT 42 42 from kofacustom.nigeria.etranzact.helpers import query_payoutlet 43 43 … … 84 84 85 85 class EtranzactEnterPinPageStudent(KofaPage): 86 """ 86 """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` 87 87 """ 88 88 grok.context(INigeriaStudentOnlinePayment) … … 95 95 action = 'query_payoutlet_history' 96 96 placeholder = _('Confirmation Number (PIN)') 97 gateway_amt = GATEWAY_AMT 97 98 98 99 def update(self): 99 100 if not module_activated(self.context.student.current_session): 100 101 return 102 if self.context.r_company and self.context.r_company != 'etranzact': 103 return _("Payment ticket has been used for another payment gateway.") 101 104 super(EtranzactEnterPinPageStudent, self).update() 105 # Already now it becomes an Etranzact payment. We set the net amount 106 # and add the gateway amount. 107 if not self.context.r_company: 108 self.context.net_amt = self.context.amount_auth 109 self.context.amount_auth += self.gateway_amt 110 self.context.gateway_amt = self.gateway_amt 111 self.context.r_company = u'etranzact' 102 112 return 103 113 104 114 class EtranzactEnterPinPageApplicant(EtranzactEnterPinPageStudent): 105 """ 115 """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` 106 116 """ 107 117 grok.require('waeup.payApplicant') … … 155 165 if not module_activated(self.context.__parent__.__parent__.year): 156 166 return 157 ob_class = self.__implemented__.__name__158 167 if self.context.p_state == 'paid': 159 168 self.flash(_('This ticket has already been paid.')) -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/studentsbrowser.py
r15702 r15755 33 33 34 34 from kofacustom.nigeria.etranzact.tests import ( 35 TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL )35 TERMINAL_ID, HOST, HTTPS, SECRET_KEY, LOGO_URL, GATEWAY_AMT) 36 36 37 37 grok.templatedir('browser_templates') … … 93 93 terminal_id = TERMINAL_ID 94 94 logo_url = LOGO_URL 95 gateway_amt = GATEWAY_AMT 95 96 96 97 @property … … 101 102 102 103 def init_update(self): 104 if not module_activated(self.context.student.current_session): 105 return _("Etranzact payments deactivated.") 103 106 if self.context.p_state == 'paid': 104 107 return _("Payment ticket can't be re-sent to Etranzact.") … … 116 119 # which authenticates the response. 117 120 self.responseurl = self.url(self.context, 'receive_etranzact') 118 # Already now it becomes a Etranzact payment 119 self.context.r_company = u'etranzact' 120 hashargs = self.amount + self.terminal_id+self.transaction_id \ 121 self.transaction_id = self.context.p_id 122 hashargs = self.amount + self.terminal_id + self.transaction_id \ 121 123 + self.responseurl + self.secret_key 122 124 self.hashvalue = hashlib.md5(hashargs).hexdigest() … … 125 127 126 128 def update(self): 127 if not module_activated(self.context.student.current_session): 128 return 129 self.transaction_id = self.context.p_id 129 # Already now it becomes an Etranzact payment. We set the net amount 130 # and add the gateway amount. 131 if not self.context.r_company: 132 self.context.net_amt = self.context.amount_auth 133 self.context.amount_auth += self.gateway_amt 134 self.context.gateway_amt = self.gateway_amt 135 self.context.r_company = u'etranzact' 130 136 self.amount = "%.1f" % self.context.amount_auth 131 137 error = self.init_update() -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/etranzact/tests.py
r15734 r15755 41 41 # do exist really and are not bothered by being spammed by a test programme. 42 42 43 EXTERNAL_TESTS = True43 EXTERNAL_TESTS = False 44 44 45 45 TERMINAL_ID = '5003021194' … … 48 48 SECRET_KEY = 'DEMO_KEY' 49 49 LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' 50 GATEWAY_AMT = 500.0 50 51 51 52 # Valid transaction id in Etranzact system -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/browser.py
r15727 r15755 34 34 from kofacustom.nigeria.interfaces import MessageFactory as _ 35 35 36 GATEWAY_AMT = 300.0 37 36 38 # Buttons 37 39 … … 306 308 xml_data = None 307 309 hashvalue = None 310 gateway_amt = GATEWAY_AMT 308 311 309 312 def init_update(self): … … 317 320 if time_delta.days > 7: 318 321 return _("This payment ticket is too old. Please create a new ticket.") 322 if self.context.r_company and self.context.r_company != 'interswitch': 323 return _("Payment ticket has been used for another payment gateway.") 319 324 student = self.context.student 320 325 certificate = getattr(student['studycourse'],'certificate',None) … … 326 331 self.context.p_item, self.context.p_session): 327 332 return _("This type of payment has already been made.") 328 self.amount_auth = int(100 * self.context.amount_auth)329 333 xmldict = {} 330 334 if certificate is not None: … … 341 345 self.student = student 342 346 self.xmldict = xmldict 343 self.context.r_company = u'interswitch'344 347 return 345 348 … … 351 354 self.flash(error, type='danger') 352 355 self.redirect(self.url(self.context, '@@index')) 356 # Already now it becomes an Interswitch payment. We set the net amount 357 # and add the gateway amount. 358 if not self.context.r_company: 359 self.context.net_amt = self.context.amount_auth 360 self.context.amount_auth += self.gateway_amt 361 self.context.gateway_amt = self.gateway_amt 362 self.context.r_company = u'interswitch' 363 self.amount_auth = int(100 * self.context.amount_auth) 353 364 return 354 365 … … 363 374 label = _('Submit data to CollegePAY (Interswitch Payment Gateway)') 364 375 submit_button = _('Submit') 365 hashvalue = None366 376 367 377 action = None … … 371 381 product_id = None 372 382 xml_data = None 383 hashvalue = None 384 gateway_amt = GATEWAY_AMT 373 385 374 386 def init_update(self): … … 379 391 return _("Payment ticket can't be send to CollegePAY. " 380 392 "Application period has expired.") 393 if self.context.r_company and self.context.r_company != 'interswitch': 394 return _("Payment ticket has been used for another payment gateway.") 381 395 tz = getUtility(IKofaUtils).tzinfo 382 396 time_delta = datetime.utcnow() - self.context.creation_date … … 384 398 return _("This payment ticket is too old. Please create a new ticket.") 385 399 self.applicant = self.context.__parent__ 386 self.amount_auth = int(100 * self.context.amount_auth)387 400 self.category = self.context.category 388 401 tz = getUtility(IKofaUtils).tzinfo … … 390 403 self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z") 391 404 self.site_redirect_url = self.url(self.context, 'request_webservice') 392 self.context.r_company = u'interswitch'393 405 return 394 406 … … 400 412 self.flash(error, type='danger') 401 413 self.redirect(self.url(self.context, '@@index')) 402 return 414 # Already now it becomes an Interswitch payment. We set the net amount 415 # and add the gateway amount. 416 if not self.context.r_company: 417 self.context.net_amt = self.context.amount_auth 418 self.context.amount_auth += self.gateway_amt 419 self.context.gateway_amt = self.gateway_amt 420 self.context.r_company = u'interswitch' 421 self.amount_auth = int(100 * self.context.amount_auth) 422 return -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py
r15702 r15755 103 103 # Split amounts have been set. 104 104 self.assertEqual(self.student['payments'][value].provider_amt, 0.0) 105 self.assertEqual(self.student['payments'][value].gateway_amt, 0.0)105 self.assertEqual(self.student['payments'][value].gateway_amt, 300.0) 106 106 self.assertMatches('...<input type="hidden" name="pay_item_id" />...', 107 107 self.browser.contents) 108 self.assert Matches(109 ' ...<input type="hidden" name="amount" value="2000000" />...',108 self.assertTrue( 109 '<input type="hidden" name="amount" value="2030000" />' in 110 110 self.browser.contents) 111 111 … … 118 118 self.browser.contents) 119 119 self.assertEqual(self.student.current_mode, 'ug_ft') 120 self.assert Matches(121 ' ...<input type="hidden" name="amount" value="4000000" />...',120 self.assertTrue( 121 '<input type="hidden" name="amount" value="4030000" />' in 122 122 self.browser.contents) 123 123 delta = timedelta(days=8) -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/payments/interfaces.py
r15731 r15755 111 111 default = 0.0, 112 112 required = False, 113 readonly = True,113 readonly = False, 114 114 ) 115 115 -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/applicantsbrowser.py
r15529 r15755 34 34 35 35 from kofacustom.nigeria.remita.tests import ( 36 MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID )36 MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID, GATEWAY_AMT) 37 37 38 38 grok.templatedir('browser_templates') … … 235 235 if self.context.p_state == 'paid': 236 236 return _("Payment ticket can't be re-sent to Remita.") 237 if self.context.r_company and self.context.r_company != 'remita': 238 return _("Payment ticket has been used for another payment gateway.") 237 239 now = datetime.utcnow() 238 240 if self.context.creation_date.tzinfo is not None: … … 260 262 if resp.get('statuscode') not in ('021', '025', '055'): 261 263 return 'RRR generation message from Remita: ' + resp.get('status') 262 # Already now it becomes a Remita payment263 self.context.r_company = u'remita'264 264 self.rrr = self.context.r_pay_reference = resp['RRR'].rstrip() 265 265 hashargs = self.merchantId + self.rrr + self.api_key … … 269 269 'RRR retrieved: %s, ServiceTypeId: %s' 270 270 % (self.rrr, self.serviceTypeId)) 271 272 271 return 273 272 … … 281 280 self.redirect(self.url(self.context, '@@index')) 282 281 return 283 return 282 # Already now it becomes a Remita payment. We set the net amount 283 # and add the gateway amount. 284 if not self.context.r_company: 285 self.context.net_amt = self.context.amount_auth 286 self.context.amount_auth += self.gateway_amt 287 self.context.gateway_amt = self.gateway_amt 288 self.context.r_company = u'remita' 289 self.amount_auth = int(100 * self.context.amount_auth) 290 return -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/studentsbrowser.py
r14805 r15755 34 34 35 35 from kofacustom.nigeria.remita.tests import ( 36 MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID )36 MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID, GATEWAY_AMT) 37 37 38 38 grok.templatedir('browser_templates') … … 221 221 api_key = API_KEY 222 222 serviceTypeId = SERVICETYPEID 223 gateway_amt = GATEWAY_AMT 223 224 224 225 #orderId = '3456346346' … … 243 244 if self.context.p_state == 'paid': 244 245 return _("Payment ticket can't be re-sent to Remita.") 246 if self.context.r_company and self.context.r_company != 'remita': 247 return _("Payment ticket has been used for another payment gateway.") 245 248 now = datetime.utcnow() 246 249 if self.context.creation_date.tzinfo is not None: … … 276 279 if resp.get('statuscode') not in ('021', '025', '055'): 277 280 return 'RRR generation message from Remita: ' + resp.get('status') 278 # Already now it becomes a Remita payment279 self.context.r_company = u'remita'280 281 self.rrr = self.context.r_pay_reference = resp['RRR'].rstrip() 281 282 hashargs = self.merchantId + self.rrr + self.api_key … … 296 297 self.redirect(self.url(self.context, '@@index')) 297 298 return 298 return 299 # Already now it becomes a Remita payment. We set the net amount 300 # and add the gateway amount. 301 if not self.context.r_company: 302 self.context.net_amt = self.context.amount_auth 303 self.context.amount_auth += self.gateway_amt 304 self.context.gateway_amt = self.gateway_amt 305 self.context.r_company = u'remita' 306 self.amount_auth = int(100 * self.context.amount_auth) 307 return -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/tests.py
r15468 r15755 44 44 API_KEY = '1946' 45 45 SERVICETYPEID = '4430731' 46 GATEWAY_AMT = 0.0 46 47 47 48 def external_test(func): … … 86 87 lineitems=self.lineitems) 87 88 return resp 89 90 def test_dummytest(self): 91 return 88 92 89 93 @external_test -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/payments.py
r15730 r15755 64 64 return None 65 65 66 @property67 def net_amt(self):68 return self.amount_auth - self.provider_amt - self.gateway_amt69 70 66 NigeriaStudentOnlinePayment = attrs_to_fields(NigeriaStudentOnlinePayment, 71 omit=['display_item', 'net_amt'])67 omit=['display_item',]) 72 68 73 69 class NigeriaStudentOnlinePaymentFactory(StudentOnlinePaymentFactory):
Note: See TracChangeset for help on using the changeset viewer.