Ignore:
Timestamp:
18 Dec 2022, 09:24:18 (21 months ago)
Author:
Henrik Bettermann
Message:

Use Mac validation.

File:
1 edited

Legend:

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

    r17221 r17231  
    382382# Web checkout helper functions
    383383
    384 def get_JSON_webcheckout_response(merchant_code, transref, host, url, https, amount):
     384def get_JSON_webcheckout_response(merchant_code, transref, host, url,
     385                                  https, amount, mac=None):
     386    amount = int(100 * amount)
     387    hashargs = transref + merchant_code + str(amount) + mac
     388    hashvalue = hashlib.sha512(hashargs).hexdigest()
    385389    headers={
    386390        'Content-Type':'text/xml; charset=utf-8',
     391        'Hash':hashvalue,
    387392    }
    388393    if https:
     
    390395    else:
    391396        h = httplib.HTTPConnection(host)
    392     amount = int(100 * amount)
    393397    args = {'merchantcode': merchant_code,
    394398            'transactionreference': transref,
     
    401405    response = h.getresponse()
    402406    if response.status!=200:
    403         return {'error': 'Connection error (%s, %s)' % (response.status, response.reason)}
     407        return {'error': 'Connection error (%s, %s)' % (
     408            response.status, response.reason)}
    404409    jsonout = response.read()
    405410    parsed_json = json.loads(jsonout)
    406411    return parsed_json
    407412
    408 def confirm_transaction(payment, merchant_code, host, url, https=True):
     413def confirm_transaction(payment, merchant_code, host, url, https, mac):
    409414    jr = get_JSON_webcheckout_response(merchant_code, payment.p_id, host, url,
    410                            https, payment.amount_auth)
     415                           https, payment.amount_auth, mac)
    411416    error = jr.get('error')
    412417    if error:
Note: See TracChangeset for help on using the changeset viewer.