[FIX] payment, website_sale: SIPS adaptation
SIPS payment has two limitations: - A payment reference can only be used once, even if the payment was not proceeded - A payment reference can only contain alphanumerical characters These limitations do not fit the payment process which: - Reuses existing transactions - Introduces a `-` character when creating a new transaction for the same order. First issue is solved by an ugly hack since there is no link module between `website_sale` and `payment_sips` in order to override the behavior of `sale_get_transaction`. Second issue is solved by modifying the character to `x`. In this case, we could consider overriding the method `get_next_reference` in `payment_sips`. However, this method is called before the creation of the transaction, and we should do a crappy workaround using the context to get the `acquier_id`. opw-728209
This commit is contained in:
@@ -527,7 +527,7 @@ class PaymentTransaction(models.Model):
|
||||
ref_suffix = 1
|
||||
init_ref = reference
|
||||
while self.env['payment.transaction'].sudo().search_count([('reference', '=', reference)]):
|
||||
reference = init_ref + '-' + str(ref_suffix)
|
||||
reference = init_ref + 'x' + str(ref_suffix)
|
||||
ref_suffix += 1
|
||||
return reference
|
||||
|
||||
|
||||
@@ -463,7 +463,15 @@ class Website(models.Model):
|
||||
tx_id = request.session.get('sale_transaction_id')
|
||||
if tx_id:
|
||||
transaction = self.env['payment.transaction'].sudo().browse(tx_id)
|
||||
if transaction.state != 'cancel':
|
||||
# Ugly hack for SIPS: SIPS does not allow to reuse a payment reference, even if the
|
||||
# payment was not not proceeded. For example:
|
||||
# - Select SIPS for payment
|
||||
# - Be redirected to SIPS website
|
||||
# - Go back to eCommerce without paying
|
||||
# - Be redirected to SIPS website again => error
|
||||
# Since there is no link module between 'website_sale' and 'payment_sips', we prevent
|
||||
# here to reuse any previous transaction for SIPS.
|
||||
if transaction.state != 'cancel' and transaction.acquirer_id.provider != 'sips':
|
||||
return transaction
|
||||
else:
|
||||
request.session['sale_transaction_id'] = False
|
||||
|
||||
Reference in New Issue
Block a user