Changeset 15916 for main


Ignore:
Timestamp:
10 Jan 2020, 12:14:21 (5 years ago)
Author:
Henrik Bettermann
Message:

Catch socket error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/helpers.py

    r15730 r15916  
    7878    try:
    7979        h.request("GET", url, headers=headers)
     80        resp = h.getresponse()
    8081    except:
    8182        return {'error': 'Socket Error: Connection to Remita gateway refused.'}
    82     resp = h.getresponse()
    8383    if resp.status!=200:
    8484        return {'error': 'Connection error (%s, %s)' % (resp.status, resp.reason)}
     
    113113    payment.r_desc = jr['message']
    114114    payment.r_amount_approved = jr['amount']
    115     payment.r_pay_reference = jr['RRR']
     115    try:
     116        payment.r_pay_reference = jr['RRR']
     117    except KeyError:
     118        msg = _('Error: ${a}', mapping = {'a': payment.r_desc})
     119        log = 'unsuccessful response for %s payment %s: %s' % (
     120            payment.p_category, payment.p_id, payment.r_desc)
     121        payment.p_state = 'failed'
     122        notify(grok.ObjectModifiedEvent(payment))
     123        return False, msg, log
    116124    #payment.r_company = u'remita'
    117125    if payment.r_code not in ('00', '01'):
Note: See TracChangeset for help on using the changeset viewer.