Skip to content
Snippets Groups Projects
Commit cf42c2e2 authored by Swapnesh Shah's avatar Swapnesh Shah
Browse files

[FIX] sale,payment: Encode Payment URL correctly


Before this commit, Payment URL was not encoded correctly which can compute Payment refernece Wrongly on website.

Eg,
  Enter Description which contains Special Characters
  Go to Payment Page using Computed URL.
  There will be wrong Payment Reference on Payment page.

With this commit, We encode Payment reference before generating Payment URL.

closes odoo/odoo#47387

X-original-commit: 6ebcc43d
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent b6af34d3
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
import hashlib
import hmac
from werkzeug import urls
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
from odoo.tools import ustr, consteq
......@@ -59,7 +61,7 @@ class PaymentLinkWizard(models.TransientModel):
def _generate_link(self):
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for payment_link in self:
payment_link.link = '%s/website_payment/pay?reference=%s&amount=%s&currency_id=%s&partner_id=%s&access_token=%s' % (base_url, payment_link.description, payment_link.amount, payment_link.currency_id.id, payment_link.partner_id.id, payment_link.access_token)
payment_link.link = '%s/website_payment/pay?reference=%s&amount=%s&currency_id=%s&partner_id=%s&access_token=%s' % (base_url, urls.url_quote(payment_link.description), payment_link.amount, payment_link.currency_id.id, payment_link.partner_id.id, payment_link.access_token)
@api.model
def check_token(self, access_token, partner_id, amount, currency_id):
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug import urls
from odoo import api, models
......@@ -26,4 +28,4 @@ class SalePaymentLink(models.TransientModel):
""" Override of the base method to add the order_id in the link. """
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for payment_link in self:
payment_link.link = '%s/website_payment/pay?reference=%s&amount=%s&currency_id=%s&partner_id=%s&order_id=%s&access_token=%s' % (base_url, payment_link.description, payment_link.amount, payment_link.currency_id.id, payment_link.partner_id.id, payment_link.res_id, payment_link.access_token)
payment_link.link = '%s/website_payment/pay?reference=%s&amount=%s&currency_id=%s&partner_id=%s&order_id=%s&access_token=%s' % (base_url, urls.url_quote(payment_link.description), payment_link.amount, payment_link.currency_id.id, payment_link.partner_id.id, payment_link.res_id, payment_link.access_token)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment