- Timestamp:
- 15 Jan 2015, 22:12:25 (10 years ago)
- Location:
- main/kofacustom.wdu/trunk/src/kofacustom/wdu/interswitch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.wdu/trunk/src/kofacustom/wdu/interswitch/browser.py
r11940 r12478 17 17 ## 18 18 import httplib 19 import hashlib 19 20 import grok 21 from waeup.kofa.interfaces import CLEARED 20 22 from kofacustom.nigeria.interswitch.browser import ( 21 23 InterswitchPaymentRequestWebservicePageApplicant, … … 27 29 from kofacustom.wdu.interfaces import MessageFactory as _ 28 30 29 PRODUCT_ID = ' 57'30 SITE_NAME = 'wdu -kofa.waeup.org'31 PROVIDER_ACCT = '0 0000000'32 PROVIDER_BANK_ID = ' 00'31 PRODUCT_ID = '6207' 32 SITE_NAME = 'wdu.waeup.org' 33 PROVIDER_ACCT = '0137712635' 34 PROVIDER_BANK_ID = '10' 33 35 PROVIDER_ITEM_NAME = 'BT Education' 34 INSTITUTION_NAME = ' Skeleton'36 INSTITUTION_NAME = 'WDU' 35 37 CURRENCY = '566' 36 GATEWAY_AMT = 150.0 37 #QUERY_URL = 'https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx' 38 #QUERY_URL = 'https://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryURL.aspx' 39 POST_ACTION = 'https://webpay.interswitchng.com/paydirect/webpay/pay.aspx' 40 #POST_ACTION = 'https://testwebpay.interswitchng.com/test_paydirect/webpay/pay.aspx' 38 GATEWAY_AMT = 300.0 41 39 42 HOST = 'webpay.interswitchng.com' 43 #HOST = 'testwebpay.interswitchng.com' 44 URL = '/paydirect/services/TransactionQueryWs.asmx' 45 #URL = '/test_paydirect/services/TransactionQueryWs.asmx' 46 httplib.HTTPConnection.debuglevel = 0 40 POST_ACTION = 'https://stageserv.interswitchng.com/test_paydirect/pay' 41 #POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' 42 43 #HOST = 'webpay.interswitchng.com' 44 HOST = 'stageserv.interswitchng.com' 45 HTTPS = True 46 47 #URL = '/paydirect/services/TransactionQueryWs.asmx' 48 URL = '/test_paydirect/services/TransactionQueryWS.asmx' 49 50 httplib.HTTPSConnection.debuglevel = 0 47 51 48 52 class CustomInterswitchPageStudent(InterswitchPageStudent): … … 55 59 currency = CURRENCY 56 60 product_id = PRODUCT_ID 61 mac = 'CEF793CBBE838AA0CBB29B74D571113B4EA6586D3BA77E7CFA0B95E278364EFC4526ED7BD255A366CDDE11F1F607F0F844B09D93B16F7CFE87563B2272007AB3' 57 62 58 63 def update(self): … … 69 74 xmldict['provider_bank_id'] = PROVIDER_BANK_ID 70 75 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME 71 # Institution data 72 xmldict['institution_acct'] = '00000000' 73 xmldict['institution_bank_id'] = '00' 74 xmldict['institution_amt'] = '0.0' 75 provider_amt = 0.0 76 self.pay_item_id = '0000' 76 xmldict['institution_acct_1'] = '4742014159' 77 xmldict['institution_bank_id_1'] = '47' 78 xmldict['institution_amt_1'] = '0.0' 79 xmldict['institution_acct_2'] = '0029688237' 80 xmldict['institution_bank_id_2'] = '11' 81 xmldict['institution_amt_2'] = '0.0' 82 provider_amt = 4000.0 83 self.pay_item_id = '101' 84 # other charges + tech fee 85 if self.context.student.state == CLEARED: 86 institution_amt_2 = 207500.0 + 1000.0 87 else : 88 institution_amt_2 = 150500.0 + 1000.0 77 89 xmldict['provider_amt'] = 100 * provider_amt 78 90 xmldict['institution_item_name'] = self.category 79 91 xmldict['institution_name'] = INSTITUTION_NAME 80 xmldict['institution_amt'] = 100 * ( 81 self.context.amount_auth - provider_amt - GATEWAY_AMT) 92 xmldict['institution_amt_1'] = 100 * ( 93 self.context.amount_auth - provider_amt - GATEWAY_AMT - institution_amt_2) 94 xmldict['institution_amt_2'] = 100 * institution_amt_2 95 82 96 # Interswitch amount is not part of the xml data 83 if provider_amt == 0: 84 xmltext = """<payment_item_detail> 97 xmltext = """<payment_item_detail> 85 98 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> 86 <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" /> 87 </item_details> 88 </payment_item_detail>""" % xmldict 89 else: 90 xmltext = """<payment_item_detail> 91 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> 92 <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" /> 93 <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" /> 99 <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id_1)s" acct_num="%(institution_acct_1)s" /> 100 <item_detail item_id="2" item_name="other charges and tech fee" item_amt="%(institution_amt_2)d" bank_id="%(institution_bank_id_2)s" acct_num="%(institution_acct_2)s" /> 101 <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> 94 102 </item_details> 95 103 </payment_item_detail>""" % xmldict … … 97 105 self.context.provider_amt = provider_amt 98 106 self.context.gateway_amt = GATEWAY_AMT 107 108 hashargs = ( 109 self.context.p_id + 110 PRODUCT_ID + 111 self.pay_item_id + 112 str(int(self.amount_auth)) + 113 self.site_redirect_url + 114 self.mac) 115 self.hashvalue = hashlib.sha512(hashargs).hexdigest() 99 116 return 100 117 101 class CustomInterswitchPageApplicant(InterswitchPageApplicant):102 """ View which sends a POST request to the Interswitch103 CollegePAY payment gateway.104 """105 grok.context(ICustomApplicantOnlinePayment)106 action = POST_ACTION107 site_name = SITE_NAME108 currency = CURRENCY109 pay_item_id = '0000'110 product_id = PRODUCT_ID111 112 def update(self):113 super(CustomInterswitchPageApplicant, self).update()114 xmldict = {}115 provider_amt = 400.0116 xmldict['institution_acct'] = '00000000000'117 xmldict['institution_bank_id'] = '00'118 xmldict['detail_ref'] = self.context.p_id119 xmldict['provider_amt'] = 100 * provider_amt120 xmldict['provider_acct'] = PROVIDER_ACCT121 xmldict['provider_bank_id'] = PROVIDER_BANK_ID122 xmldict['provider_item_name'] = PROVIDER_ITEM_NAME123 xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT)124 xmldict['institution_item_name'] = self.context.p_category125 xmldict['institution_name'] = INSTITUTION_NAME126 # Interswitch amount is not part of the xml data127 xmltext = """<payment_item_detail>128 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">129 <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" />130 <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" />131 </item_details>132 </payment_item_detail>""" % xmldict133 self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext134 self.context.provider_amt = provider_amt135 self.context.gateway_amt = GATEWAY_AMT136 return137 118 138 119 class CustomInterswitchPaymentRequestWebservicePageStudent( … … 144 125 gateway_host = HOST 145 126 gateway_url = URL 127 https = HTTPS 146 128 147 129 class CustomInterswitchPaymentRequestWebservicePageApplicant( … … 153 135 gateway_host = HOST 154 136 gateway_url = URL 137 https = HTTPS -
main/kofacustom.wdu/trunk/src/kofacustom/wdu/interswitch/tests.py
r11940 r12478 52 52 53 53 def test_interswitch_form(self): 54 self.app['configuration']['2004'].school_fee_fresh = 442800.0 55 self.app['configuration']['2004'].school_fee_returning = 385800.0 54 56 # Manager can access InterswitchForm 55 57 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 68 70 self.browser.contents) 69 71 self.assertMatches( 70 '...<span>4 0000.0</span>...',72 '...<span>442800.0</span>...', 71 73 self.browser.contents) 72 74 self.payment_url = self.browser.url 73 75 self.browser.getLink("CollegePAY", index=0).click() 74 # The total amount to be processed by Interswitch 75 # has been reduced by the Interswitch fee of 150 Nairas 76 self.assertMatches('...<input type="hidden" name="pay_item_id" value="0000" />...', 76 self.assertMatches('...<input type="hidden" name="pay_item_id" value="101" />...', 77 77 self.browser.contents) 78 78 self.assertMatches('...Total Amount Authorized:...', … … 80 80 self.assertEqual(self.student.current_mode, 'ug_ft') 81 81 self.assertMatches( 82 '...<input type="hidden" name="amount" value="4 000000" />...',83 self.browser.contents) 84 self.assertMatches( 85 '...item_name="School Fee " item_amt="4000000" bank_id="00" acct_num="00000000"...',82 '...<input type="hidden" name="amount" value="44280000" />...', 83 self.browser.contents) 84 self.assertMatches( 85 '...item_name="School Fees" item_amt="23000000" bank_id="47" acct_num="4742014159"...', 86 86 self.browser.contents) 87 87
Note: See TracChangeset for help on using the changeset viewer.