Skip to content

Commit

Permalink
refactor: better handling of get parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Nov 22, 2024
1 parent b98e5fb commit e50bb16
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,18 @@ def create_charge_on_braintree(self):
if custom_redirect_to:
redirect_to = custom_redirect_to

redirect_url = (
f"payment-success?doctype={self.data.reference_doctype}&docname={self.data.reference_docname}"
)
redirect_url = "payment-success"
else:
status = "Error"
redirect_url = (
f"payment-failed?doctype={self.data.reference_doctype}&docname={self.data.reference_docname}"
)
redirect_url = "payment-failed"

get_parameters = [("doctype", self.data.reference_doctype), ("docname", self.data.reference_docname)]
if redirect_to:
redirect_url += "&" + urlencode({"redirect_to": redirect_to})
get_parameters.append(("redirect_to", redirect_to))
if redirect_message:
redirect_url += "&" + urlencode({"redirect_message": redirect_message})
get_parameters.append(("redirect_message", redirect_message))

redirect_url += "?" + urlencode(get_parameters)
return {"redirect_to": redirect_url, "status": status}


Expand Down

0 comments on commit e50bb16

Please sign in to comment.