Ignore:
Timestamp:
30 Nov 2012, 18:16:40 (12 years ago)
Author:
Henrik Bettermann
Message:

Catch connection errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py

    r9742 r9745  
    6666    }
    6767    h.request('POST', URL, body=xml,headers=headers)
    68     r = h.getresponse()
    69     d = r.read()
    70     if r.status!=200:
    71         raise ValueError('Error connecting: %s, %s' % (r.status, r.reason))
    72     return d
     68    response = h.getresponse()
     69    return response
    7370
    7471def get_SOAP_response(product_id, transref):
     
    8380  </soap:Body>
    8481</soap:Envelope>""" % (product_id, transref)
    85     result_xml=SOAP_post("http://tempuri.org/getTransactionData",xml)
     82    response=SOAP_post("http://tempuri.org/getTransactionData",xml)
     83    if response.status!=200:
     84        return 'Connection error (%s, %s)' % (response.status, response.reason)
     85    result_xml = response.read()
    8686    doc=parseString(result_xml)
    8787    response=doc.getElementsByTagName('getTransactionDataResult')[0].firstChild.data
     
    9090def query_interswitch(payment):
    9191    sr = get_SOAP_response(PRODUCT_ID, payment.p_id)
     92    if sr.startswith('Connection error'):
     93        msg = _('Connection error')
     94        log = sr
     95        return False, msg, log
    9296    wlist = sr.split(':')
    9397    if len(wlist) != 7:
Note: See TracChangeset for help on using the changeset viewer.