Summary
When a Stripe payment is completed, the redirect URL generated by payments can incorrectly include redirect_to=None.
This leads to malformed success URLs such as:
payment-success?doctype=Payment Request&docname=ACC-PRQ-2026-00002&redirect_to=None
https://example.com/payment-success?redirect_to=None
In our case this caused the success page to break because the request parameters were no longer interpreted correctly downstream.
We also observed this traceback:
frappe.exceptions.DoesNotExistError: Payment Request ACC-PRQ-2026-00002?redirect_to=None not found
Affected area
File:
payments/payment_gateways/doctype/stripe_settings/stripe_settings.py
Method:
finalize_request()
Environment
erpnext 16.9.1 version-16 (99a81db)
frappe 16.11.0 version-16 (694a53f)
payments 0.0.1 develop (3cebd94)
print_designer 1.6.7 develop (9d62227)
swiss_accounting_software 0.0.6 main (5388f1c)
Observed in our environment with:
- Frappe / ERPNext +
payments
- Stripe test mode
- Payment Request based checkout flow
Steps to reproduce
- Configure Stripe in ERPNext / Frappe using the standard
payments Stripe integration.
- Create a
Payment Request.
- Complete a Stripe payment successfully.
- Let the flow return to the configured success page.
Variant A
Leave redirect_to unset / effectively None.
Variant B
Set a custom redirect_url, for example:
https://example.com/payment-success
Actual behavior
finalize_request() builds a redirect URL that still appends redirect_to=None.
Example:
https://example.com/payment-success?redirect_to=None
or
payment-success?doctype=Payment Request&docname=ACC-PRQ-2026-00002&redirect_to=None
This pollutes the return URL with a meaningless query parameter and can break downstream parsing / success page behavior.
In our case it resulted in a malformed lookup where the document name was effectively treated as:
ACC-PRQ-2026-00002?redirect_to=None
instead of just:
Expected behavior
If redirect_to is empty / None, it should not be appended at all.
Expected success URL:
payment-success?doctype=Payment Request&docname=ACC-PRQ-2026-00002
or, when a custom redirect URL is configured:
https://example.com/payment-success
with no redirect_to=None appended.
Root cause
Current logic in finalize_request():
if redirect_to and "?" in redirect_url:
redirect_url += "&" + urlencode({"redirect_to": redirect_to})
else:
redirect_url += "?" + urlencode({"redirect_to": redirect_to})
This is wrong because the else branch still appends redirect_to, even when redirect_to is None.
Proposed fix
Only append redirect_to if it actually has a value.
Suggested change:
if redirect_to:
if "?" in redirect_url:
redirect_url += "&" + urlencode({"redirect_to": redirect_to})
else:
redirect_url += "?" + urlencode({"redirect_to": redirect_to})
Why this matters
This is not cosmetic.
A successful Stripe payment can return the user to a broken URL and trigger downstream lookup failures on the ERPNext side. It also makes custom success URLs unreliable.
Additional note
We confirmed locally that changing the redirect composition logic to only append redirect_to when truthy removes the broken ?redirect_to=None behavior.
Summary
When a Stripe payment is completed, the redirect URL generated by
paymentscan incorrectly includeredirect_to=None.This leads to malformed success URLs such as:
payment-success?doctype=Payment Request&docname=ACC-PRQ-2026-00002&redirect_to=Nonehttps://example.com/payment-success?redirect_to=NoneIn our case this caused the success page to break because the request parameters were no longer interpreted correctly downstream.
We also observed this traceback:
Affected area
File:
payments/payment_gateways/doctype/stripe_settings/stripe_settings.pyMethod:
finalize_request()Environment
erpnext 16.9.1 version-16 (99a81db)
frappe 16.11.0 version-16 (694a53f)
payments 0.0.1 develop (3cebd94)
print_designer 1.6.7 develop (9d62227)
swiss_accounting_software 0.0.6 main (5388f1c)
Observed in our environment with:
paymentsSteps to reproduce
paymentsStripe integration.Payment Request.Variant A
Leave
redirect_tounset / effectivelyNone.Variant B
Set a custom
redirect_url, for example:Actual behavior
finalize_request()builds a redirect URL that still appendsredirect_to=None.Example:
or
This pollutes the return URL with a meaningless query parameter and can break downstream parsing / success page behavior.
In our case it resulted in a malformed lookup where the document name was effectively treated as:
instead of just:
Expected behavior
If
redirect_tois empty /None, it should not be appended at all.Expected success URL:
or, when a custom redirect URL is configured:
with no
redirect_to=Noneappended.Root cause
Current logic in
finalize_request():This is wrong because the
elsebranch still appendsredirect_to, even whenredirect_toisNone.Proposed fix
Only append
redirect_toif it actually has a value.Suggested change:
Why this matters
This is not cosmetic.
A successful Stripe payment can return the user to a broken URL and trigger downstream lookup failures on the ERPNext side. It also makes custom success URLs unreliable.
Additional note
We confirmed locally that changing the redirect composition logic to only append
redirect_towhen truthy removes the broken?redirect_to=Nonebehavior.