[FIX] payment: Save payment token only if user is connected
- Fix an issue where the transaction were always set a 'form_save' thus always creating payment tokens. - Fix an issue where when the customer paying while not being logged in was crashing. The issue is due to the fact that we are creating payment transactions linked to no partners, doing so it crashing the code when creating the payment token with no partner set.
This commit is contained in:
@@ -89,7 +89,7 @@ class WebsitePayment(http.Controller):
|
||||
'amount': float(amount),
|
||||
'currency_id': currency_id,
|
||||
'partner_id': partner_id,
|
||||
'type': 'form_save' if acquirer.save_token else 'form',
|
||||
'type': 'form_save' if acquirer.save_token != 'none' and partner_id else 'form',
|
||||
}
|
||||
|
||||
tx = request.env['payment.transaction'].sudo().create(values)
|
||||
@@ -119,7 +119,7 @@ class WebsitePayment(http.Controller):
|
||||
'currency_id': int(currency_id),
|
||||
'partner_id': partner_id,
|
||||
'payment_token_id': pm_id,
|
||||
'type': 'form_save' if token.acquirer_id.save_token else 'form',
|
||||
'type': 'form_save' if token.acquirer_id.save_token != 'none' and partner_id else 'form',
|
||||
}
|
||||
|
||||
tx = request.env['payment.transaction'].sudo().create(values)
|
||||
|
||||
Reference in New Issue
Block a user