Hi,
my custom file name is : sadad.php (included common files).the payment gateway post the following parameters to our website. this is my code for sadad.php:
we can’t control post parameters that send by payment gateways to our website.
e.g. bank send us result of a payment transaction using post method.
how to control post parameters that send to the script from external sites?
thanks
mansour
You may use Route_Action server event, see: https://discourse.hkvstore.com/t/using-route-action-server-event-v2021/3393/1 your payment gateway posts data to your site by HTTP POST, the route arguments are unimportant, you just get the data by $_POST or by POST Parameters and then do what you want with the data.You may just put your code in your route action and change echo to:
Hi,
I used the following code for testing purpose.
$app->post('/sadad', function ($request, $response, array $args) {
if (isset($_POST["ResCode"])){
$resultCode = $_POST["ResCode"];
$InvoiceNumber = $_POST["OrderId"];
$Token = $_POST["token"];
SWITCH ($resultCode){
case "0":
$body = $response->getBody();
$body->write('success');
return $response; // Return the response
break;
default:
$body = $response->getBody();
$body->write('error');
return $response; // Return the response
}
}
});
I received the following error when I opened the site home page and also http://site/sadad{“statusCode”:0,“error”:{“class”:“text-danger”,“type”:“\u062e\u0637\u0627”,“description”:“\u0647\u0646\u06af\u0627\u0645 \u067e\u0631\u062f\u0627\u0632\u0634 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627 \u062e\u0637\u0627\u06cc\u06cc \u062f\u0627\u062e\u0644\u06cc \u0631\u062e \u062f\u0627\u062f\u0647 \u0627\u0633\u062a.”}}What’s the problem?
Thanks
$app->post(‘/sadad’, function ($request, $response, array $args) {
…
I received the following error when I opened the site home page and also > http://site/sadad
If you use $app->post() you cannot use it by HTTP GET, you must use HTTP POST, see How to create routes.
Hi,
This is the error after activating Debug mode:{“statusCode”:0,“error”:{“class”:“text-danger”,“type”:“\u062e\u0637\u0627”,“description”:“C:\xampp\htdocs\newpedra\vendor\nikic\fast-route\src\DataGenerator\RegexBasedAbstract.php(86): Cannot register two routes matching "/newpedra/sadad" for method "POST"”}}Thanks
Hi,
I corrected the route name. Now, I receive the 400 error message after coming back from bank gateway.
It’s because of Token, isn’t it? (CHECK_TOKEN I mean)Thanks
Routes created in Route_Action does not require token at all (because your own code does not check it). Make sure you have updated your payment gateway to post to your correct(renamed) route (no “.php”).
If you post to your route action /test, you don’t need the test.php and the token at all. To update data just get the posted data in your route action, then build and execute an UPDATE statement by ExecuteUpdate().
Hi,
The Route_Action server event prints the result as the plain text and header / footer of the site does NOT show.
I want to print the route result as a normal generated file (with header & footer)
any idea?Thanks
the problem is I have no control on bank payment gateway post parameters. >
You may use Page_Load server event. (Make sure you use the latest version, v2021.0.8 as of today.)You may also put your code in the content of the Custom File.
Hi,
So, placing the following code in Page_Load sever event for sadad.php will ignore the default “CHECK_TOKEN” setting?if (CurrentPage()->TableName == “sadad.php”) {
Config(“CHECK_TOKEN”, false);
}Isn’t it?Thanks