Changeset 10165 for main/waeup.futminna/trunk/src/waeup
- Timestamp:
- 10 May 2013, 06:30:06 (12 years ago)
- Location:
- main/waeup.futminna/trunk/src/waeup/futminna/interswitch
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.futminna/trunk/src/waeup/futminna/interswitch/browser.py
r9934 r10165 18 18 import httplib 19 19 import grok 20 from zope.component import getUtility 20 from zope.interface import Interface 21 from zope.component import getUtility, queryAdapter 21 22 from kofacustom.nigeria.interswitch.browser import ( 22 InterswitchPaymentRequestWebservicePageStudent 23 InterswitchPaymentRequestWebservicePageStudent, 24 InterswitchPaymentRequestWebservicePageApplicant 23 25 ) 24 26 from waeup.kofa.browser.layout import KofaPage … … 26 28 from waeup.kofa.utils.helpers import to_timezone 27 29 from waeup.futminna.students.interfaces import ICustomStudentOnlinePayment 30 from waeup.futminna.applicants.interfaces import ICustomApplicantOnlinePayment 28 31 from waeup.futminna.interfaces import MessageFactory as _ 29 32 … … 46 49 #URL = '/test_paydirect/services/TransactionQueryWs.asmx' 47 50 httplib.HTTPConnection.debuglevel = 0 51 52 def interswitch_img_url(view): 53 static = view.static 54 if static is None or static.get( 55 'interswitch_verve_mastercard.gif', None) is None: 56 static = queryAdapter( 57 view.request, Interface, name='waeup.futminna.interswitch') 58 return static['interswitch_verve_mastercard.gif']() 48 59 49 60 class InterswitchPageStudent(KofaPage): … … 206 217 return 207 218 219 class InterswitchPageApplicant(KofaPage): 220 """ View which sends a POST request to the Interswitch 221 CollegePAY payment gateway. 222 """ 223 grok.context(ICustomApplicantOnlinePayment) 224 grok.require('waeup.payApplicant') 225 grok.template('applicant_goto_interswitch') 226 grok.name('goto_interswitch') 227 label = _('Submit data to CollegePAY (Interswitch Payment Gateway)') 228 submit_button = _('Submit') 229 action = POST_ACTION 230 site_name = SITE_NAME 231 currency = CURRENCY 232 pay_item_id = '103' 233 product_id = PRODUCT_ID 234 #mac = '' 235 236 def interswitch_img_url(self): 237 return interswitch_img_url(self) 238 239 def update(self): 240 if self.context.p_state != 'unpaid': 241 self.flash(_("Payment ticket can't be re-send to CollegePAY.")) 242 self.redirect(self.url(self.context, '@@index')) 243 return 244 if self.context.__parent__.__parent__.expired \ 245 and self.context.__parent__.__parent__.strict_deadline: 246 self.flash(_("Payment ticket can't be send to CollegePAY. " 247 "Application period has expired.")) 248 self.redirect(self.url(self.context, '@@index')) 249 return 250 self.applicant = self.context.__parent__ 251 self.amount_auth = 100 * self.context.amount_auth 252 xmldict = {} 253 self.category = getUtility( 254 IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category] 255 tz = getUtility(IKofaUtils).tzinfo 256 self.local_date_time = to_timezone( 257 self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z") 258 self.site_redirect_url = self.url(self.context, 'request_webservice') 259 provider_amt = 500.0 260 if self.applicant.applicant_id.startswith('pg'): 261 xmldict['institution_acct'] = '2005910931' 262 xmldict['institution_bank_id'] = '8' 263 else: 264 xmldict['institution_acct'] = '00000000000' 265 xmldict['institution_bank_id'] = '00' 266 xmldict['detail_ref'] = self.context.p_id 267 xmldict['provider_amt'] = 100 * provider_amt 268 xmldict['provider_acct'] = PROVIDER_ACCT 269 xmldict['provider_bank_id'] = PROVIDER_BANK_ID 270 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME 271 xmldict['institution_amt'] = 100 * ( 272 self.context.amount_auth - provider_amt - GATEWAY_AMT) 273 xmldict['institution_item_name'] = self.context.p_category 274 xmldict['institution_name'] = INSTITUTION_NAME 275 276 #hashargs = ( 277 # self.context.p_id + 278 # PRODUCT_ID + 279 # self.pay_item_id + 280 # str(int(self.amount_auth)) + 281 # self.site_redirect_url + 282 # self.mac) 283 #self.hashvalue = hashlib.sha512(hashargs).hexdigest() 284 285 # Interswitch amount is not part of the xml data 286 xmltext = """<payment_item_detail> 287 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> 288 <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> 289 <item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> 290 </item_details> 291 </payment_item_detail>""" % xmldict 292 self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext 293 self.context.provider_amt = provider_amt 294 self.context.gateway_amt = GATEWAY_AMT 295 return 296 208 297 class InterswitchPaymentRequestWebservicePageStudent( 209 298 InterswitchPaymentRequestWebservicePageStudent): … … 214 303 gateway_host = HOST 215 304 gateway_url = URL 305 306 class InterswitchPaymentRequestWebservicePageApplicant( 307 InterswitchPaymentRequestWebservicePageApplicant): 308 """ Request webservice view for the CollegePAY gateway 309 """ 310 grok.context(ICustomApplicantOnlinePayment) 311 product_id = PRODUCT_ID 312 gateway_host = HOST 313 gateway_url = URL -
main/waeup.futminna/trunk/src/waeup/futminna/interswitch/tests.py
r9791 r10165 17 17 ## 18 18 import os 19 from zope.component import getUtility 19 from zope.component import getUtility, createObject 20 20 from zope.catalog.interfaces import ICatalog 21 21 from hurry.workflow.interfaces import IWorkflowState 22 from waeup.kofa.university.faculty import Faculty 23 from waeup.kofa.university.department import Department 22 24 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 23 25 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup … … 233 235 '20000.0,00,1500.0,300.0,0.0,,,\n' 234 236 in logcontent) 237 238 class InterswitchTestsApplicants(ApplicantsFullSetup): 239 """Tests for the Interswitch payment gateway. 240 """ 241 242 layer = FunctionalLayer 243 244 def setUp(self): 245 super(InterswitchTestsApplicants, self).setUp() 246 # Create at least one FUTMinna faculty 247 self.app['faculties']['CPGS'] = Faculty(code='ABC') 248 self.app['faculties']['CPGS']['dep1'] = Department(code='dep1') 249 self.certificate2 = createObject('waeup.Certificate') 250 self.certificate2.code = u'CERT2' 251 self.certificate2.application_category = 'pg_ft' 252 self.certificate2.study_mode = 'pg_ft' 253 self.certificate2.start_level = 999 254 self.certificate2.end_level = 999 255 self.app['faculties']['CPGS']['dep1'].certificates.addCertificate( 256 self.certificate2) 257 self.applicantscontainer.application_category = 'pg_ft' 258 self.applicant.applicant_id = u'pg_anything' 259 260 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 261 self.browser.open(self.manage_path) 262 #IWorkflowState(self.student).setState('started') 263 super(InterswitchTestsApplicants, self).fill_correct_values() 264 self.browser.getControl(name="form.course1").value = ['CERT2'] 265 self.applicantscontainer.application_fee = 3333.0 266 self.browser.getControl(name="form.nationality").value = ['NG'] 267 self.browser.getControl(name="transition").value = ['start'] 268 self.browser.getControl("Save").click() 269 self.browser.getControl("Add online").click() 270 self.assertMatches('...ticket created...', 271 self.browser.contents) 272 #ctrl = self.browser.getControl(name='val_id') 273 #value = ctrl.options[0] 274 #self.browser.getLink(value).click() 275 self.assertMatches('...Amount Authorized...', 276 self.browser.contents) 277 self.assertMatches( 278 '...<span>3333.0</span>...', 279 self.browser.contents) 280 self.payment_url = self.browser.url 281 282 283 def test_interswitch_form(self): 284 285 # Manager can access InterswitchForm 286 self.browser.getLink("CollegePAY", index=0).click() 287 self.assertMatches('...Total Amount Authorized:...', 288 self.browser.contents) 289 self.assertTrue( 290 '<input type="hidden" name="amount" value="333300.0" />' 291 in self.browser.contents) 292 self.assertTrue( 293 '<item_detail item_id="1" item_name="application" ' 294 'item_amt="253300" bank_id="8" acct_num="2005910931" />' 295 in self.browser.contents) 296 self.assertTrue( 297 '<item_detail item_id="2" item_name="BT Education" ' 298 'item_amt="50000" bank_id="31" acct_num="0026781725" />' 299 in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.