lingo: backend options must be dict (#41439)

This commit is contained in:
Benjamin Dauvergne 2020-04-08 09:59:48 +02:00
parent a40dc2e73f
commit ead8de9bcc
1 changed files with 6 additions and 3 deletions

View File

@ -103,14 +103,17 @@ class PaymentBackend(models.Model):
return self.label
def get_payment(self):
if isinstance(self.service_options, six.string_types):
options = self.service_options or {}
if isinstance(options, six.string_types):
# backward compatibility when used againt postgresql < 9.4 and
# service_options is received as a string.
try:
self.service_options = json.loads(self.service_options)
options = json.loads(options)
except ValueError:
pass
return eopayment.Payment(self.service, self.service_options)
if not isinstance(options, dict):
options = {}
return eopayment.Payment(self.service, options)
@python_2_unicode_compatible