[FIX] payment_buckaroo: parameters case
Quoting Buckaroo Payment Engine 3.0 Implementation Manual: Note: parameter names are not case sensitive (both in the request and in the response). Parameter values are case sensitive. Using data.get(BRQ_PAYMENT') is unreliable and may break in the future. Update test to use different case. opw 665439
This commit is contained in:
parent
e74840f1e9
commit
6efc371291
|
@ -11,6 +11,16 @@ from openerp.tools.float_utils import float_compare
|
|||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def normalize_keys_upper(data):
|
||||
"""Set all keys of a dictionnary to uppercase
|
||||
|
||||
Buckaroo parameters names are case insensitive
|
||||
convert everything to upper case to be able to easily detected the presence
|
||||
of a parameter by checking the uppercase key only
|
||||
"""
|
||||
return dict((key.upper(), val) for key, val in data.items())
|
||||
|
||||
|
||||
class AcquirerBuckaroo(osv.Model):
|
||||
_inherit = 'payment.acquirer'
|
||||
|
||||
|
@ -123,6 +133,7 @@ class TxBuckaroo(osv.Model):
|
|||
def _buckaroo_form_get_tx_from_data(self, cr, uid, data, context=None):
|
||||
""" Given a data dict coming from buckaroo, verify it and find the related
|
||||
transaction record. """
|
||||
data = normalize_keys_upper(data)
|
||||
reference, pay_id, shasign = data.get('BRQ_INVOICENUMBER'), data.get('BRQ_PAYMENT'), data.get('BRQ_SIGNATURE')
|
||||
if not reference or not pay_id or not shasign:
|
||||
error_msg = 'Buckaroo: received data with missing reference (%s) or pay_id (%s) or shashign (%s)' % (reference, pay_id, shasign)
|
||||
|
@ -151,7 +162,7 @@ class TxBuckaroo(osv.Model):
|
|||
|
||||
def _buckaroo_form_get_invalid_parameters(self, cr, uid, tx, data, context=None):
|
||||
invalid_parameters = []
|
||||
|
||||
data = normalize_keys_upper(data)
|
||||
if tx.acquirer_reference and data.get('BRQ_TRANSACTIONS') != tx.acquirer_reference:
|
||||
invalid_parameters.append(('Transaction Id', data.get('BRQ_TRANSACTIONS'), tx.acquirer_reference))
|
||||
# check what is buyed
|
||||
|
@ -163,6 +174,7 @@ class TxBuckaroo(osv.Model):
|
|||
return invalid_parameters
|
||||
|
||||
def _buckaroo_form_validate(self, cr, uid, tx, data, context=None):
|
||||
data = normalize_keys_upper(data)
|
||||
status_code = int(data.get('BRQ_STATUSCODE','0'))
|
||||
if status_code in self._buckaroo_valid_tx_status:
|
||||
tx.write({
|
||||
|
|
|
@ -122,7 +122,7 @@ class BuckarooForm(BuckarooCommon):
|
|||
'BRQ_CURRENCY': u'EUR',
|
||||
'BRQ_CUSTOMER_NAME': u'Jan de Tester',
|
||||
'BRQ_INVOICENUMBER': u'SO004',
|
||||
'BRQ_PAYMENT': u'573311D081B04069BD6336001611DBD4',
|
||||
'brq_payment': u'573311D081B04069BD6336001611DBD4',
|
||||
'BRQ_PAYMENT_METHOD': u'paypal',
|
||||
'BRQ_SERVICE_PAYPAL_PAYERCOUNTRY': u'NL',
|
||||
'BRQ_SERVICE_PAYPAL_PAYEREMAIL': u'fhe@openerp.com',
|
||||
|
@ -130,7 +130,7 @@ class BuckarooForm(BuckarooCommon):
|
|||
'BRQ_SERVICE_PAYPAL_PAYERLASTNAME': u'Tester',
|
||||
'BRQ_SERVICE_PAYPAL_PAYERMIDDLENAME': u'de',
|
||||
'BRQ_SERVICE_PAYPAL_PAYERSTATUS': u'verified',
|
||||
'BRQ_SIGNATURE': u'175d82dd53a02bad393fee32cb1eafa3b6fbbd91',
|
||||
'Brq_signature': u'175d82dd53a02bad393fee32cb1eafa3b6fbbd91',
|
||||
'BRQ_STATUSCODE': u'190',
|
||||
'BRQ_STATUSCODE_DETAIL': u'S001',
|
||||
'BRQ_STATUSMESSAGE': u'Transaction successfully processed',
|
||||
|
|
Loading…
Reference in New Issue