[IMP] payment_sips: testing values

Prior to this revision, setting the provider to the 'test' mode caused
hardcoded values for merchantId, secret and keyVersion to be used
without any possibility to override them.

While somewhat useful, it was quite limiting since it used the 'simu'
environment of Atos Wordline, preventing you from testing any other
platform and from using the 'test' environment for Atos.

This revision removes these hardcoded values, which gives more
flexibility as far as testing goes at the cost of a bit more setup
(since you might need to change some values manually, notably the
keyVersion).

Task-2259942
This commit is contained in:
Damien Bouvy
2020-08-17 12:39:30 +00:00
parent 9392f9cfc8
commit fc9ea2c519
+3 -14
View File
@@ -62,12 +62,7 @@ class AcquirerSips(models.Model):
if self.provider != 'sips':
raise ValidationError(_('Incorrect payment acquirer provider'))
data = values['Data']
# Test key provided by Worldine
key = u'002001000000001_KEY1'
if self.state == 'enabled':
key = getattr(self, 'sips_secret')
key = self.sips_secret
shasign = sha256((data + key).encode('utf-8'))
return shasign.hexdigest()
@@ -80,14 +75,8 @@ class AcquirerSips(models.Model):
if not currency_code:
raise ValidationError(_('Currency not supported by Wordline'))
amount = round(values['amount'] * 100)
if self.state == 'enabled':
# For production environment, key version 2 is required
merchant_id = getattr(self, 'sips_merchant_id')
key_version = self.env['ir.config_parameter'].sudo().get_param('sips.key_version', '2')
else:
# Test key provided by Atos Wordline works only with version 1
merchant_id = '002001000000001'
key_version = '1'
merchant_id = self.sips_merchant_id
key_version = self.sips_key_version
sips_tx_values = dict(values)
sips_tx_values.update({