Skip to content

Commit

Permalink
[IMP] payment_redsys: Updating the module to the version 18
Browse files Browse the repository at this point in the history
  • Loading branch information
jordi-josc committed Feb 25, 2025
1 parent 076c0ff commit 2768d8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion payment_redsys/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Pasarela de pago Redsys",
"category": "Payment Acquirer",
"summary": "Payment Acquirer: Redsys Implementation",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"depends": ["payment", "website_sale"],
Expand Down
18 changes: 12 additions & 6 deletions payment_redsys/models/payment_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ def _redsys_get_api_url(self):
code = fields.Selection(
selection_add=[("redsys", "Redsys")], ondelete={"redsys": "set default"}
)
redsys_merchant_name = fields.Char("Merchant Name", required_if_provider="redsys")
redsys_merchant_code = fields.Char("Merchant code", required_if_provider="redsys")
redsys_merchant_name = fields.Char(
"Merchant Name", required_if_provider="redsys")
redsys_merchant_code = fields.Char(
"Merchant code", required_if_provider="redsys")
redsys_merchant_description = fields.Char(
"Product Description", required_if_provider="redsys"
)
redsys_secret_key = fields.Char("Secret Key", required_if_provider="redsys")
redsys_secret_key = fields.Char(
"Secret Key", required_if_provider="redsys")
redsys_terminal = fields.Char(
"Terminal", default="1", required_if_provider="redsys"
)
Expand Down Expand Up @@ -117,7 +120,8 @@ def _get_website_url(self):
else domain
)
else:
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
base_url = self.env["ir.config_parameter"].sudo(
).get_param("web.base.url")
return base_url or ""

def _prepare_merchant_parameters(self, tx_values):
Expand Down Expand Up @@ -170,7 +174,8 @@ def sign_parameters(self, secret_key, params64):
if "Ds_Merchant_Order" in params_dic:
order = str(params_dic["Ds_Merchant_Order"])
else:
order = str(urllib.parse.unquote(params_dic.get("Ds_Order", "Not found")))
order = str(urllib.parse.unquote(
params_dic.get("Ds_Order", "Not found")))
cipher = DES3.new(
key=base64.b64decode(secret_key), mode=DES3.MODE_CBC, IV=b"\0\0\0\0\0\0\0\0"
)
Expand All @@ -179,7 +184,8 @@ def sign_parameters(self, secret_key, params64):
key = cipher.encrypt(str.encode(order + zeros.decode()))
if isinstance(params64, str):
params64 = params64.encode()
dig = hmac.new(key=key, msg=params64, digestmod=hashlib.sha256).digest()
dig = hmac.new(key=key, msg=params64,
digestmod=hashlib.sha256).digest()
return base64.b64encode(dig).decode()

def redsys_get_form_action_url(self):
Expand Down

0 comments on commit 2768d8f

Please sign in to comment.