Skip to content

Commit

Permalink
feat: Decode URL-encoded data in payment gateway files
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Oct 2, 2024
1 parent 8b57e6d commit a7e6f80
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion payments/templates/pages/braintree_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License: MIT. See LICENSE

import json
import urllib.parse

import frappe
from frappe import _
Expand Down Expand Up @@ -33,7 +34,7 @@ def get_context(context):
# all these keys exist in form_dict
if not (set(expected_keys) - set(list(frappe.form_dict))):
for key in expected_keys:
context[key] = frappe.form_dict[key]
context[key] = urllib.parse.unquote(frappe.form_dict[key])

context.client_token = get_client_token(context.reference_docname)

Expand Down
3 changes: 2 additions & 1 deletion payments/templates/pages/gocardless_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License: GNU General Public License v3. See license.txt

import json
import urllib.parse

import frappe
from frappe import _
Expand Down Expand Up @@ -33,7 +34,7 @@ def get_context(context):
# all these keys exist in form_dict
if not (set(expected_keys) - set(frappe.form_dict.keys())):
for key in expected_keys:
context[key] = frappe.form_dict[key]
context[key] = urllib.parse.unquote(frappe.form_dict[key])

context["amount"] = flt(context["amount"])

Expand Down
4 changes: 3 additions & 1 deletion payments/templates/pages/paytm_checkout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import json
import urllib.parse

import frappe
from frappe import _
Expand All @@ -16,7 +17,8 @@ def get_context(context):
paytm_config = get_paytm_config()

try:
doc = frappe.get_doc("Integration Request", frappe.form_dict["order_id"])
order_id = urllib.parse.unquote(frappe.form_dict.get("order_id", ""))
doc = frappe.get_doc("Integration Request", order_id)

context.payment_details = get_paytm_params(json.loads(doc.data), doc.name, paytm_config)

Expand Down
3 changes: 2 additions & 1 deletion payments/templates/pages/razorpay_checkout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import json
import urllib.parse

import frappe
from frappe import _
Expand Down Expand Up @@ -30,7 +31,7 @@ def get_context(context):
payment_details = json.loads(doc.data)

for key in expected_keys:
context[key] = payment_details[key]
context[key] = urllib.parse.unquote(payment_details.get(key, ""))

context["token"] = frappe.form_dict["token"]
context["amount"] = flt(context["amount"])
Expand Down
4 changes: 3 additions & 1 deletion payments/templates/pages/stripe_checkout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import json
import urllib.parse

import frappe
from frappe import _
Expand Down Expand Up @@ -31,7 +32,8 @@ def get_context(context):
# all these keys exist in form_dict
if not (set(expected_keys) - set(list(frappe.form_dict))):
for key in expected_keys:
context[key] = frappe.form_dict[key]
context[key] = urllib.parse.unquote(frappe.form_dict[key])

gateway_controller = get_gateway_controller(
context.reference_doctype, context.reference_docname, context.payment_gateway
)
Expand Down

0 comments on commit a7e6f80

Please sign in to comment.