summaryrefslogtreecommitdiff
path: root/addons/payment_sips/models
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-05-09 14:10:51 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-05-15 08:33:06 +0200
commit429bcd9464928c21b0bdc3e99280cd50bf0c36b8 (patch)
tree35d97e4eb5f3cff8bbf16275875bf694bb6e278f /addons/payment_sips/models
parent45b4a4a4dd09fa6d8a2e18e52adf542f015124d7 (diff)
[FIX] payment_sips: special characters
The field `transactionReference` of Sips must contain only alphanumerical characters. Previous commit 31dc6b888eeb2d787f5675 solved the special case of several attempts to pay, but a much simpler case may appear in v11. Paying an invoice is likely to fail since the reference contains by default `/`. In the previous commit, we could simply modify the common `payment` module code. In this specific case, however, we only change the reference if the acquirer is Sips. opw-1841483
Diffstat (limited to 'addons/payment_sips/models')
-rw-r--r--addons/payment_sips/models/payment.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py
index 46464b7d60c..60e4d9f3153 100644
--- a/addons/payment_sips/models/payment.py
+++ b/addons/payment_sips/models/payment.py
@@ -4,6 +4,7 @@
import json
import logging
+import re
from hashlib import sha256
from werkzeug import urls
@@ -111,6 +112,16 @@ class AcquirerSips(models.Model):
return self.environment == 'prod' and self.sips_prod_url or self.sips_test_url
+class PaymentTransactionSips(models.Model):
+ _inherit = 'payment.transaction'
+
+ @api.model
+ def _get_next_reference(self, reference, acquirer=None):
+ if acquirer and acquirer.provider == 'sips':
+ reference = re.sub(r'[^0-9a-zA-Z]+', 'x' , reference)
+ return super(PaymentTransactionSips, self)._get_next_reference(reference, acquirer=acquirer)
+
+
class TxSips(models.Model):
_inherit = 'payment.transaction'