- 🇪🇸Spain rubofvil
In the file
vendor/twig/twig/src/Template.phpThe function `ob_start` is avoding the redirect of the Redsys. The Twig is called to load the node (if the the webform is embeded into a node) after `exit` is called.
This patch fix the issue, but isn't a good solution. It's to understand the issue
diff --git a/vendor/twig/twig/src/Template.php b/vendor/twig/twig/src/Template.php index 76d55cbcb..daf98c079 100644 --- a/vendor/twig/twig/src/Template.php +++ b/vendor/twig/twig/src/Template.php @@ -384,7 +384,12 @@ abstract class Template if ($this->env->isDebug()) { ob_start(); } else { - ob_start(function () { return ''; }); + if (!empty($_POST["hidden_processor"]) && $_POST["hidden_processor"] == "1") { + // Avoid executing ob_start allow the processor to continue + } else { + ob_start(function () { return ''; }); + } + } try { $this->display($context);
A porpouse is make a development that in some cases the Twig not render a node or panel,....
- 🇪🇸Spain francescbassas Barcelona
Thanks @rubofvil.
This helps us to understand that the reason of get redsys redirection working in local environment is due to having twig debug enabled on services.yml.
twig.config: debug: true
I don't know if this makes sense to you.
- 🇪🇸Spain francescbassas Barcelona
@rubofvil I think the solution may be to rewrite current redirect to Redsys https://lab.civicrm.org/extensions/redsys/-/blob/2.4.3/CRM/Core/Payment/... like something as Paypal does https://lab.civicrm.org/dev/core/-/blob/5.57.2/CRM/Core/Payment/PayPalIm....
This makes sense to you?
- 🇪🇸Spain rubofvil
Thx Francesc, but in this case Paypal is redirecting and sending the params with _GET and can use `CRM_Utils_System::redirect`
But we need to use a post in a form (with method _POST) like in doc "Formulario de envío de petición" (https://pagosonline.redsys.es/conexion-redireccion.html)
Pd. I tried to manage sending vars via _POST with Curl and a redirect with headers but i din't find a solution with this
- 🇪🇸Spain xavi-xaloc
@rubofvil I've tried the proposed patch but it doesn't work for us. We just found the opposite, that redirection works only when ob_start function is executed without callback function, as it is applied when debugging is enabled.
Anyway, when sending the form, the proposed condition is not matched:+ if (!empty($_POST["hidden_processor"]) && $_POST["hidden_processor"] == "1") { + // Avoid executing ob_start allow the processor to continue + }
So ob_start function with callback function is executed:
else { + ob_start(function () { return ''; }); + }