Changeset 7898 for main/waeup.custom/trunk/src/waeup/custom/interswitch
- Timestamp:
- 16 Mar 2012, 10:06:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
r7897 r7898 17 17 ## 18 18 from datetime import datetime 19 from urllib import urlencode 19 import httplib 20 import urllib 21 from xml.dom.minidom import parseString 20 22 import grok 21 23 from waeup.kofa.browser.layout import KofaPage, UtilityView … … 39 41 POST_ACTION = 'https://testwebpay.interswitchng.com/test_paydirect/webpay/pay.aspx' 40 42 43 HOST = 'testwebpay.interswitchng.com' 44 URL = '/test_paydirect/services/TransactionQueryWs.asmx' 45 httplib.HTTPConnection.debuglevel = 0 46 47 def SOAP_post(soap_action,xml): 48 """Handles making the SOAP request. 49 50 Further reading: 51 http://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryWs.asmx?op=getTransactionData 52 """ 53 h = httplib.HTTPConnection(HOST) 54 headers={ 55 'Host':HOST, 56 'Content-Type':'text/xml; charset=utf-8', 57 'Content-Length':len(xml), 58 'SOAPAction':'"%s"' % soap_action, 59 } 60 h.request('POST', URL, body=xml,headers=headers) 61 r = h.getresponse() 62 d = r.read() 63 if r.status!=200: 64 raise ValueError('Error connecting: %s, %s' % (r.status, r.reason)) 65 return d 66 67 def get_SOAP_response(product_id, transref): 68 xml="""\ 69 <?xml version="1.0" encoding="utf-8"?> 70 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 71 <soap:Body> 72 <getTransactionData xmlns="http://tempuri.org/"> 73 <product_id>%s</product_id> 74 <trans_ref>%s</trans_ref> 75 </getTransactionData> 76 </soap:Body> 77 </soap:Envelope>""" % (product_id, transref) 78 result_xml=SOAP_post("http://tempuri.org/getTransactionData",xml) 79 doc=parseString(result_xml) 80 response=doc.getElementsByTagName('getTransactionDataResult')[0].firstChild.data 81 return response 82 41 83 class InterswitchActionButton(RequestCallbackActionButton): 42 84 grok.order(2) … … 64 106 'prodID':PRODUCT_ID, 65 107 'redirectURL':site_redirect_url} 66 return QUERY_URL + '?%s' % url encode(args)108 return QUERY_URL + '?%s' % urllib.urlencode(args) 67 109 68 110 class InterswitchPage(KofaPage): … … 160 202 161 203 # Add webservice validation 162 204 validation_list = get_SOAP_response( 205 PRODUCT_ID, self.context.p_id).split(':') 206 # Validation does not make sense yet since the query string 207 # formats are conflicting. 208 print validation_list 163 209 164 210 write_log_message(self,'valid callback: %s' % self.context.p_id)
Note: See TracChangeset for help on using the changeset viewer.