Changeset 9775
- Timestamp:
- 6 Dec 2012, 08:42:16 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py
r9749 r9775 19 19 import grok 20 20 from zope.component import getUtility 21 from kofacustom.nigeria.interswitch.helpers import query_interswitch 21 from kofacustom.nigeria.interswitch.helpers import ( 22 query_interswitch, write_payments_log) 22 23 from waeup.kofa.browser.layout import KofaPage, UtilityView 23 24 from waeup.kofa.interfaces import IKofaUtils … … 36 37 INSTITUTION_NAME = 'Uniben' 37 38 CURRENCY = '566' 39 GATEWAY_AMT = 150.0 38 40 #QUERY_URL = 'https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx' 39 41 #QUERY_URL = 'https://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryURL.aspx' … … 156 158 xmldict['institution_amt'] = '0.0' 157 159 if self.context.p_category == 'schoolfee': 158 provider_amt = 1500 160 provider_amt = 1500.0 159 161 if student.current_mode.endswith('_ft'): 160 162 self.pay_item_id = '5700' … … 181 183 elif self.context.p_category == 'clearance': 182 184 self.pay_item_id = '5702' 183 provider_amt = 1500 185 provider_amt = 1500.0 184 186 if student.current_mode == 'pg_ft': 185 187 xmldict['institution_acct'] = '5330832799' … … 196 198 elif self.context.p_category == 'gown': 197 199 self.pay_item_id = '5704' 198 provider_amt = 0 200 provider_amt = 0.0 199 201 xmldict['institution_bank_id'] = '7' 200 202 xmldict['institution_acct'] = '1016232382' 201 203 elif self.context.p_category.startswith('hostel_maintenance'): 202 204 self.pay_item_id = '5705' 203 provider_amt = 0 205 provider_amt = 0.0 204 206 xmldict['institution_bank_id'] = '129' 205 207 xmldict['institution_acct'] = '0014414547' … … 209 211 xmldict['institution_name'] = INSTITUTION_NAME 210 212 xmldict['institution_amt'] = 100 * ( 211 self.context.amount_auth - provider_amt - 150)213 self.context.amount_auth - provider_amt - GATEWAY_AMT) 212 214 # Interswitch amount is not part of the xml data 213 215 if provider_amt == 0: … … 225 227 </payment_item_detail>""" % xmldict 226 228 self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext 229 self.context.provider_amt = provider_amt 230 self.context.gateway_amt = GATEWAY_AMT 227 231 return 228 232 … … 262 266 self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z") 263 267 self.site_redirect_url = self.url(self.context, 'request_webservice') 264 provider_amt = 400 268 provider_amt = 400.0 265 269 if self.applicant.applicant_id.startswith('pg'): 266 270 xmldict['institution_acct'] = '0031716030' … … 277 281 xmldict['provider_bank_id'] = PROVIDER_BANK_ID 278 282 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME 279 xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - 150)283 xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT) 280 284 xmldict['institution_item_name'] = self.context.p_category 281 285 xmldict['institution_name'] = INSTITUTION_NAME … … 288 292 </payment_item_detail>""" % xmldict 289 293 self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext 294 self.context.provider_amt = provider_amt 295 self.context.gateway_amt = GATEWAY_AMT 290 296 return 291 297 … … 368 374 self.flash(msg) 369 375 return 376 write_payments_log(student.student_id, self.context) 370 377 success, msg, log = self.context.doAfterStudentPayment() 371 378 if log is not None: … … 396 403 self.flash(msg) 397 404 return 405 write_payments_log(applicant.applicant_id, self.context) 398 406 success, msg, log = self.context.doAfterApplicantPayment() 399 407 if log is not None: -
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py
r9731 r9775 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 import os 18 19 from zope.component import createObject, getUtility 19 20 from zope.catalog.interfaces import ICatalog … … 58 59 self.browser.contents) 59 60 ctrl = self.browser.getControl(name='val_id') 60 value = ctrl.options[0]61 self.browser.getLink( value).click()61 self.value = ctrl.options[0] 62 self.browser.getLink(self.value).click() 62 63 self.assertMatches('...Amount Authorized...', 63 64 self.browser.contents) … … 122 123 ctrl = self.browser.getControl(name='val_id') 123 124 value = ctrl.options[1] 125 self.assertEqual(self.student['payments'][value].provider_amt, 0.0) 126 self.assertEqual(self.student['payments'][value].gateway_amt, 0.0) 124 127 self.browser.getLink(value).click() 125 128 self.browser.getLink("CollegePAY", index=0).click() 129 # Split amounts have been set. 130 self.assertEqual(self.student['payments'][value].provider_amt, 1500.0) 131 self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) 126 132 self.assertMatches('...<input type="hidden" name="pay_item_id" value="5701" />...', 127 133 self.browser.contents) … … 148 154 # Manager can access InterswitchForm 149 155 self.browser.getLink("CollegePAY", index=0).click() 156 self.assertEqual(self.student['payments'][value].provider_amt, 1500.0) 157 self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) 150 158 self.assertMatches('...<input type="hidden" name="pay_item_id" value="5702" />...', 151 159 self.browser.contents) … … 176 184 # Manager can access InterswitchForm 177 185 self.browser.getLink("CollegePAY", index=0).click() 186 self.assertEqual(self.student['payments'][value].provider_amt, 0.0) 187 self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) 178 188 self.assertMatches('...<input type="hidden" name="pay_item_id" value="5704" />...', 179 189 self.browser.contents) … … 201 211 # Manager can access InterswitchForm 202 212 self.browser.getLink("CollegePAY", index=0).click() 213 self.assertEqual(self.student['payments'][value].provider_amt, 0.0) 214 self.assertEqual(self.student['payments'][value].gateway_amt, 150.0) 203 215 self.assertMatches('...<input type="hidden" name="pay_item_id" value="5705" />...', 204 216 self.browser.contents) … … 237 249 @external_test 238 250 def test_webservice(self): 239 251 # First we have open InterswitchPageStudent to set provider_amt 252 # and gateway_amt 253 self.browser.open(self.payment_url + '/goto_interswitch') 254 # Now we can call the webservice 240 255 self.browser.open(self.payment_url + '/request_webservice') 241 256 self.assertMatches('...Unsuccessful callback...', … … 250 265 self.assertEqual(len(results), 1) 251 266 self.assertEqual(results[0].p_state, 'failed') 267 268 # Let's replace the p_id with a valid p_id of the Uniben 269 # live system. This is definitely not an appropriate 270 # solution for testing, but we have no choice since 271 # Interswitch doesn't provide any interface 272 # for testing. 273 payment = self.student['payments'][self.value] 274 payment.p_id = 'p3547789850240' 275 self.browser.open(self.payment_url + '/request_webservice') 276 self.assertMatches('...Callback amount does not match...', 277 self.browser.contents) 278 # The payment is now in state failed ... 279 self.assertMatches('...<span>Failed</span>...', 280 self.browser.contents) 281 # Let's replace the amount autorized with the amount of the 282 # live system payment 283 payment.amount_auth = payment.r_amount_approved 284 self.browser.open(self.payment_url + '/request_webservice') 285 self.assertMatches('...Successful payment...', 286 self.browser.contents) 287 # The payment is now in state paid ... 288 self.assertMatches('...<span>Paid</span>...', 289 self.browser.contents) 290 # ... and the catalog has been updated 291 cat = getUtility(ICatalog, name='payments_catalog') 292 results = list( 293 cat.searchResults(p_state=('paid', 'paid'))) 294 self.assertEqual(len(results), 1) 295 self.assertEqual(results[0].p_state, 'paid') 296 # Approval is logged in students.log ... 297 logfile = os.path.join( 298 self.app['datacenter'].storage, 'logs', 'students.log') 299 logcontent = open(logfile).read() 300 self.assertTrue( 301 'zope.mgr - ' 302 'waeup.uniben.interswitch.browser.InterswitchPaymentRequestWebservicePageStudent - ' 303 'B1000000 - successful schoolfee payment: p3547789850240\n' 304 in logcontent) 305 # ... and in payments.log 306 logfile = os.path.join( 307 self.app['datacenter'].storage, 'logs', 'payments.log') 308 logcontent = open(logfile).read() 309 self.assertTrue( 310 '"zope.mgr",B1000000,p3547789850240,schoolfee,' 311 '12000.0,00,1500.0,150.0,0.0,,,\n' 312 in logcontent) 313 252 314 253 315 class InterswitchTestsApplicants(ApplicantsFullSetup): -
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r9688 r9775 70 70 """ 71 71 grok.context(ICustomStudentOnlinePayment) 72 form_fields = grok.AutoFields(ICustomStudentOnlinePayment) 72 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( 73 'provider_amt', 'gateway_amt', 'thirdparty_amt') 73 74 form_fields[ 74 75 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') … … 106 107 """ 107 108 grok.context(ICustomStudentOnlinePayment) 108 form_fields = grok.AutoFields(ICustomStudentOnlinePayment) 109 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( 110 'provider_amt', 'gateway_amt', 'thirdparty_amt') 109 111 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 110 112 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
Note: See TracChangeset for help on using the changeset viewer.