fix(payments): separate redirect constructor from authorization #37502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Condiser a payment gateway that implements Instant Payment Notification (IPN), i.e. a request to
a custom webhook to notifiy the payment status.
Such IPN requests regularely are incoming prior to the user returning from the embedded form.
Now, those IPN endpoints in erpnext need to invoke
on_payment_authorized
on the referenc document all the whilethey cannot make sense of any redirects.
What is more, as the user returns from the embedded form, they still need the redirect information, but without
invoking those parts of
on_payment_authorized
which would recreate state (such as: create payment entry and invoice).Therefore, under the current implementation, implementing IPN means creating 2 payment entries, 2 invoces, etc, in those
cases wher not only the IPN returns but also the user (i.e. the user doesn't early abandon, but after having paid).
Proposed solution
on_payment_authorized
in a backwards compatible mannerThis is meant to be used in payment flow finalizers as so: