From 4affebd7285c8b2ababad641ef0faf0e97048ecb Mon Sep 17 00:00:00 2001 From: "ramprakash.v" Date: Wed, 24 Jan 2024 19:31:28 +0530 Subject: [PATCH] Returning entire order status response in handleJuspayResponse --- expresscheckout-php-sdk/Program.php | 5 +--- expresscheckout-php-sdk/composer.json | 2 +- .../handleJuspayResponse.php | 28 ++----------------- .../initiateJuspayPayment.php | 4 +-- expresscheckout-php-sdk/setup.php | 26 ----------------- 5 files changed, 5 insertions(+), 60 deletions(-) diff --git a/expresscheckout-php-sdk/Program.php b/expresscheckout-php-sdk/Program.php index 62dbad20b..53d404064 100644 --- a/expresscheckout-php-sdk/Program.php +++ b/expresscheckout-php-sdk/Program.php @@ -27,10 +27,7 @@ public function orderStatus() { $requestOption = new RequestOptions(); $requestOption->withCustomerId("testing-customer-one"); $order = Order::status($params, $requestOption); - echo "id: ". $order->orderId . PHP_EOL; - echo "amount: ". $order->amount . PHP_EOL; - echo "status: " . $order->status . PHP_EOL; - echo "order env" . getenv("ORDER_ID") . PHP_EOL; + echo "order: ". json_encode($order->__get("*")) . PHP_EOL; } catch ( JuspayException $e ) { echo "error code" . $e->getHttpResponseCode() . PHP_EOL; echo "error message: " . $e->getErrorMessage() . PHP_EOL; diff --git a/expresscheckout-php-sdk/composer.json b/expresscheckout-php-sdk/composer.json index 78d4e2c52..1cb90b302 100644 --- a/expresscheckout-php-sdk/composer.json +++ b/expresscheckout-php-sdk/composer.json @@ -13,7 +13,7 @@ "process-timeout":0 }, "scripts": { - "run_server": "composer install && php -S 0.0.0.0:5000 router.php", + "run_server": "composer install --no-dev && php -S 0.0.0.0:5000 router.php", "run_app": "composer install && php Program.php" }, "authors": [ diff --git a/expresscheckout-php-sdk/handleJuspayResponse.php b/expresscheckout-php-sdk/handleJuspayResponse.php index c85f678f3..a37a58f62 100644 --- a/expresscheckout-php-sdk/handleJuspayResponse.php +++ b/expresscheckout-php-sdk/handleJuspayResponse.php @@ -27,35 +27,12 @@ function getOrder($orderId, $config) { } } -function orderStatusMessage ($order) { - $response = array("order_id" => $order->orderId); - switch ($order->status) { - case "CHARGED": - $response += ["message" => "order payment done successfully"]; - break; - case "PENDING": - case "PENDING_VBV": - $response += ["message" => "order payment pending"]; - break; - case "AUTHENTICATION_FAILED": - $response += ["message" => "authentication failed"]; - break; - case "AUTHORIZATION_FAILED": - $response += ["message"=> "order payment authorization failed"]; - break; - default: - $response += ["message"=> "order status " . $order->status]; - } - $response += ["order_status"=> $order->status]; - return $response; -} - // POST ROUTE if (isset($_POST["order_id"])) { try { $orderId = $_POST["order_id"]; $order = getOrder($orderId, $config); - $response = orderStatusMessage($order); + $response = $order->__get("*"); } catch (JuspayException $e ) { @@ -66,7 +43,7 @@ function orderStatusMessage ($order) { } else if (isset($_GET["order_id"])) { // GET ROUTE $orderId = $_GET["order_id"]; $order = getOrder($orderId, $config); - $response = orderStatusMessage($order); + $response = $order->__get("*"); } else { http_response_code(400); $response = array('message' => 'order id not found'); @@ -74,4 +51,3 @@ function orderStatusMessage ($order) { header('Content-Type: application/json'); echo json_encode($response); ?> - diff --git a/expresscheckout-php-sdk/initiateJuspayPayment.php b/expresscheckout-php-sdk/initiateJuspayPayment.php index f174cf8ee..6c6e4bbcb 100644 --- a/expresscheckout-php-sdk/initiateJuspayPayment.php +++ b/expresscheckout-php-sdk/initiateJuspayPayment.php @@ -8,9 +8,6 @@ $config = ServerEnv::$config; -$inputJSON = file_get_contents('php://input'); -$input = json_decode($inputJSON, true); -header('Content-Type: application/json'); $orderId = uniqid(); $amount = mt_rand(1,100); try { @@ -37,5 +34,6 @@ $response = array("message" => $e->getErrorMessage()); error_log($e->getErrorMessage()); } +header('Content-Type: application/json'); echo json_encode($response); ?> \ No newline at end of file diff --git a/expresscheckout-php-sdk/setup.php b/expresscheckout-php-sdk/setup.php index 2da2c719e..00dd6ce9b 100644 --- a/expresscheckout-php-sdk/setup.php +++ b/expresscheckout-php-sdk/setup.php @@ -10,31 +10,5 @@ } } else { shell_exec("composer_installer.sh"); - if (!extension_loaded("gmp")) { - $output=null; - $exitCode=null; - exec('sh ext_installer.sh gmp', $output, $exitCode); - if ($exitCode === 0) { - print_r($output); - echo PHP_EOL. "gmp extension added successfully" . PHP_EOL; - } else { - print_r($output); - echo PHP_EOL . "failed enabling gmp extension manually install from: https://www.php.net/manual/en/gmp.installation.php" . PHP_EOL; - if (!extension_loaded("bcmath")) { - $output=null; - $exitCode=null; - exec('sh package_install.sh bcmath', $output, $exitCode); - if ($exitCode === 0) { - print_r($output); - echo PHP_EOL. "bcmath extension added successfully" . PHP_EOL; - } else { - print_r($output); - echo PHP_EOL . "failed enabling bcmath extension manually install from: https://www.php.net/manual/en/bc.installation.php" . PHP_EOL; - } - } - } - } else { - echo "gmp extension enabled" . PHP_EOL; - } } ?> \ No newline at end of file