Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(payments): separate redirect constructor from authorization #37502

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,28 +368,29 @@ def on_payment_authorized(self, status=None):
if not status:
return

shopping_cart_settings = frappe.get_doc("E Commerce Settings")

if status in ["Authorized", "Completed"]:
redirect_to = None
self.set_as_paid()
self.on_payment_authorized_redirect()

# if shopping cart enabled and in session
if (
shopping_cart_settings.enabled
and hasattr(frappe.local, "session")
and frappe.local.session.user != "Guest"
) and self.payment_channel != "Phone":

success_url = shopping_cart_settings.payment_success_url
if success_url:
redirect_to = ({"Orders": "/orders", "Invoices": "/invoices", "My Account": "/me"}).get(
success_url, "/me"
)
else:
redirect_to = get_url("/orders/{0}".format(self.reference_name))
def on_payment_authorized_redirect(self):
shopping_cart_settings = frappe.get_doc("E Commerce Settings")
redirect_to = None
# if shopping cart enabled and in session
if (
shopping_cart_settings.enabled
and hasattr(frappe.local, "session")
and frappe.local.session.user != "Guest"
) and self.payment_channel != "Phone":

success_url = shopping_cart_settings.payment_success_url
if success_url:
redirect_to = ({"Orders": "/orders", "Invoices": "/invoices", "My Account": "/me"}).get(
success_url, "/me"
)
else:
redirect_to = get_url("/orders/{0}".format(self.reference_name))

return redirect_to
return redirect_to

def create_subscription(self, payment_provider, gateway_controller, data):
if payment_provider == "stripe":
Expand Down
Loading