copy the bank authorisation number into a common variable name
Each API has a way of transmitting the authorisation number, we copy to a common name when handling response messages.
This commit is contained in:
parent
ebabb949e3
commit
a8f3dc7222
|
@ -15,6 +15,7 @@ HTML = 2
|
|||
|
||||
class PaymentCommon(object):
|
||||
PATH = '/tmp'
|
||||
BANK_ID = '__bank_id'
|
||||
|
||||
def __init__(self, options):
|
||||
LOGGER.debug('initializing with options %s' % options)
|
||||
|
|
|
@ -74,6 +74,7 @@ class Payment(PaymentCommon):
|
|||
def response(self, query_string):
|
||||
form = parse_qs(query_string)
|
||||
transaction_id = form.get('transaction_id',[''])[0]
|
||||
form[self.BANK_ID] = transaction_id
|
||||
|
||||
if 'signed' in form:
|
||||
content = 'signature ok'
|
||||
|
|
|
@ -30,6 +30,7 @@ __all__ = [ 'Payment' ]
|
|||
|
||||
BINPATH = 'binpath'
|
||||
PATHFILE = 'pathfile'
|
||||
AUTHORISATION_ID = 'authorisation_id'
|
||||
REQUEST_VALID_PARAMS = ['merchant_id', 'merchant_country', 'amount',
|
||||
'currency_code', 'pathfile', 'normal_return_url', 'cancel_return_url',
|
||||
'automatic_response_url', 'language', 'payment_means', 'header_flag',
|
||||
|
@ -40,7 +41,7 @@ REQUEST_VALID_PARAMS = ['merchant_id', 'merchant_country', 'amount',
|
|||
RESPONSE_PARAMS = [ 'code', 'error', 'merchant_id', 'merchant_country',
|
||||
'amount', 'transaction_id', 'payment_means', 'transmission_date',
|
||||
'payment_time', 'payment_date', 'response_code', 'payment_certificate',
|
||||
'authorisation_id', 'currency_code', 'card_number', 'cvv_flag',
|
||||
AUTHORISATION_ID, 'currency_code', 'card_number', 'cvv_flag',
|
||||
'cvv_response_code', 'bank_response_code', 'complementary_code',
|
||||
'complementary_info', 'return_context', 'caddie', 'receipt_complement',
|
||||
'merchant_language', 'language', 'customer_id', 'order_id', 'customer_email',
|
||||
|
@ -104,5 +105,7 @@ class Payment(PaymentCommon):
|
|||
params = {'message': form[DATA]}
|
||||
result = self.execute('response', params)
|
||||
d = dict(zip(RESPONSE_PARAMS, result))
|
||||
# The reference identifier for the payment is the authorisation_id
|
||||
d[self.BANK_ID] = result.get(AUTHORISATION_ID, '')
|
||||
LOGGER.debug('response contains fields %s' % d)
|
||||
return result.get(RESPONSE_CODE) == '00', form.get(ORDER_ID), d, None
|
||||
|
|
|
@ -21,6 +21,7 @@ ETAT = 'etat'
|
|||
ETAT_PAIEMENT_ACCEPTE = '1'
|
||||
SPCHECKOK = 'spcheckok'
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
REFSFP = 'refsfp'
|
||||
|
||||
def decrypt_ntkey(ntkey):
|
||||
key = binascii.unhexlify(ntkey.replace(' ',''))
|
||||
|
@ -132,6 +133,7 @@ next_url=%s' % (montant, email, next_url))
|
|||
LOGGER.debug('computed signature %s' % hmac)
|
||||
result = hmac==computed_hmac \
|
||||
and form.get(ETAT) == ETAT_PAIEMENT_ACCEPTE
|
||||
form[self.BANK_ID] = form.get(REFSFP, '')
|
||||
return result, reference, form, SPCHECKOK
|
||||
except ValueError:
|
||||
return False, reference, form, SPCHECKOK
|
||||
|
|
|
@ -16,6 +16,7 @@ PAYMENT_URL = "https://systempay.cyberpluspaiement.com/vads-payment/"
|
|||
LOGGER = logging.getLogger(__name__)
|
||||
SERVICE_URL = '???'
|
||||
VADS_TRANS_DATE = 'vads_trans_date'
|
||||
VADS_AUTH_NUMBER = 'vads_auth_number'
|
||||
|
||||
def isonow():
|
||||
return dt.datetime.now() \
|
||||
|
@ -266,6 +267,8 @@ parameters received: %s' % (name, kwargs))
|
|||
result = signature == fields['signature']
|
||||
LOGGER.debug('signature check result: %s' % result)
|
||||
transaction_id = '%s_%s' % (copy[VADS_TRANS_DATE], copy[VADS_TRANS_ID])
|
||||
# the VADS_AUTH_NUMBER is the number to match payment in bank logs
|
||||
copy[self.BANK_ID] = copy.get(copy[VADS_AUTH_NUMBER], '')
|
||||
return result, transaction_id, copy, None
|
||||
|
||||
def signature(self, fields):
|
||||
|
|
Loading…
Reference in New Issue