[FIX] payment_paypal: change access_token parameter name

PayPal refuses to take access_token name parameter and throws an error
to user that they need to log again. Since the Access Token is neeeded to
cancel transaction, it is renamed to return_access_tkn.

opw-3810686

closes odoo/odoo#158249

X-original-commit: e1ed847912b60bf09e13087963fad87afbed875c
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: anko-odoo <anko@odoo.com>
This commit is contained in:
Anita (anko)
2024-03-20 17:11:47 +00:00
parent e353da27d4
commit a629230fec
3 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -65,11 +65,12 @@ class PaypalController(http.Controller):
@http.route(
_cancel_url, type='http', auth='public', methods=['GET'], csrf=False, save_session=False
)
def paypal_return_from_canceled_checkout(self, tx_ref, access_token):
def paypal_return_from_canceled_checkout(self, tx_ref, return_access_tkn):
""" Process the transaction after the customer has canceled the payment.
:param str tx_ref: The reference of the transaction having been canceled.
:param str access_token: The access token to verify the authenticity of the request.
:param str return_access_tkn: The access token to verify the authenticity of the request.
PayPal forbids any parameter with the name "token" inside.
"""
_logger.info(
"Handling redirection from Paypal for cancellation of transaction with reference %s",
@@ -79,7 +80,7 @@ class PaypalController(http.Controller):
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data(
'paypal', {'item_number': tx_ref}
)
if not payment_utils.check_access_token(access_token, tx_ref):
if not payment_utils.check_access_token(return_access_tkn, tx_ref):
raise Forbidden()
tx_sudo._handle_notification_data('paypal', {})
@@ -38,7 +38,7 @@ class PaymentTransaction(models.Model):
cancel_url = urls.url_join(base_url, PaypalController._cancel_url)
cancel_url_params = {
'tx_ref': self.reference,
'access_token': payment_utils.generate_access_token(self.reference),
'return_access_tkn': payment_utils.generate_access_token(self.reference),
}
partner_first_name, partner_last_name = payment_utils.split_partner_name(self.partner_name)
return {
+1 -1
View File
@@ -21,7 +21,7 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon):
cancel_url = self._build_url(PaypalController._cancel_url)
cancel_url_params = {
'tx_ref': self.reference,
'access_token': self._generate_test_access_token(self.reference),
'return_access_tkn': self._generate_test_access_token(self.reference),
}
return {
'address1': 'Huge Street 2/543',