@@ -62,6 +62,9 @@ public function getTransactionReference()
62
62
63
63
/**
64
64
* Automatically perform any required redirect
65
+ *
66
+ * This method is meant to be a helper for simple scenarios. If you want to customize the
67
+ * redirection page, just call the getRedirectUrl() and getRedirectData() methods directly.
65
68
*/
66
69
public function redirect ()
67
70
{
@@ -70,44 +73,39 @@ public function redirect()
70
73
}
71
74
72
75
if ('GET ' === $ this ->getRedirectMethod ()) {
73
- return HttpRedirectResponse::create ($ this ->getRedirectUrl ())->send ();
76
+ HttpRedirectResponse::create ($ this ->getRedirectUrl ())->send ();
77
+ exit ;
74
78
} elseif ('POST ' === $ this ->getRedirectMethod ()) {
75
- $ hiddenFields = implode (
76
- "\n" ,
77
- array_map (
78
- function ($ name , $ value ) {
79
- return sprintf (
80
- '<input type="hidden" name="%1$s" value="%2$s" /> ' ,
81
- htmlspecialchars ($ name , ENT_QUOTES , 'UTF-8 ' ),
82
- htmlspecialchars ($ value , ENT_QUOTES , 'UTF-8 ' )
83
- );
84
- },
85
- $ this ->getRedirectData ()
86
- )
87
- );
88
-
89
- $ output = <<<EOF
90
- <!DOCTYPE html>
79
+ $ hiddenFields = '' ;
80
+ foreach ($ this ->getRedirectData () as $ key => $ value ) {
81
+ $ hiddenFields .= sprintf (
82
+ '<input type="hidden" name="%1$s" value="%2$s" /> ' ,
83
+ htmlspecialchars ($ key , ENT_QUOTES , 'UTF-8 ' ),
84
+ htmlspecialchars ($ value , ENT_QUOTES , 'UTF-8 ' )
85
+ )."\n" ;
86
+ }
87
+
88
+ $ output = '<!DOCTYPE html>
91
89
<html>
92
90
<head>
93
91
<title>Redirecting...</title>
94
92
</head>
95
93
<body onload="document.forms[0].submit();">
96
94
<form action="%1$s" method="post">
97
- <p>Redirecting to payment gateway ...</p>
95
+ <p>Redirecting to payment page ...</p>
98
96
<p>
99
97
%2$s
100
98
<input type="submit" value="Continue" />
101
99
</p>
102
100
</form>
103
101
</body>
104
102
</html> ' ;
105
- EOF ;
106
103
$ output = sprintf ($ output , htmlspecialchars ($ this ->redirectUrl , ENT_QUOTES , 'UTF-8 ' ), $ hiddenFields );
107
104
108
- return HttpResponse::create ($ output )->send ();
105
+ HttpResponse::create ($ output )->send ();
106
+ exit ;
109
107
}
110
108
111
- throw new RuntimeException (" Unexpected redirect method ' { $ response ->getRedirectMethod ()} ' " );
109
+ throw new RuntimeException (' Invalid redirect method " ' . $ response ->getRedirectMethod (). ' ". ' );
112
110
}
113
111
}
0 commit comments