[FIX] payment_sips: special characters
The field `transactionReference` of Sips must contain only
alphanumerical characters. Previous commit 31dc6b888e 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
This commit is contained in:
committed by
Nicolas Martinelli
parent
45b4a4a4dd
commit
429bcd9464
@@ -159,7 +159,7 @@ class PaymentTransaction(models.Model):
|
||||
'currency_id': invoice.currency_id.id,
|
||||
'partner_id': invoice.partner_id.id,
|
||||
'partner_country_id': invoice.partner_id.country_id.id,
|
||||
'reference': self.get_next_reference(invoice.number),
|
||||
'reference': self._get_next_reference(invoice.number, acquirer=acquirer),
|
||||
'account_invoice_id': invoice.id,
|
||||
}
|
||||
if add_tx_values:
|
||||
|
||||
@@ -685,6 +685,10 @@ class PaymentTransaction(models.Model):
|
||||
|
||||
@api.model
|
||||
def get_next_reference(self, reference):
|
||||
return self._get_next_reference(reference)
|
||||
|
||||
@api.model
|
||||
def _get_next_reference(self, reference, acquirer=None):
|
||||
ref_suffix = 1
|
||||
init_ref = reference
|
||||
while self.env['payment.transaction'].sudo().search_count([('reference', '=', reference)]):
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class PaymentTransaction(models.Model):
|
||||
'currency_id': order.pricelist_id.currency_id.id,
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_country_id': order.partner_id.country_id.id,
|
||||
'reference': self.get_next_reference(order.name),
|
||||
'reference': self._get_next_reference(order.name, acquirer=acquirer),
|
||||
'sale_order_id': order.id,
|
||||
}
|
||||
if add_tx_values:
|
||||
|
||||
Reference in New Issue
Block a user