123123q - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 123123q.php

  1. <?php
  2. public function check_ipn_response()
  3.         {
  4.             global $woocommerce;
  5.  
  6.             $requestType = !empty($_GET['payop']) ? $_GET['payop'] : '';
  7.  
  8.             if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  9.                 $postedData = json_decode(file_get_contents('php://input'), true);
  10.                 if (!is_array($postedData)) {
  11.                     $postedData = [];
  12.                 }
  13.             } else {
  14.                 $postedData = $_GET;
  15.             }
  16. ;
  17.             switch ($requestType) {
  18.                 case 'result':
  19.                     @ob_clean();
  20.  
  21.                     $postedData = stripslashes_deep($postedData);
  22.                     if ($postedData['status'] === 'wait') {
  23.                         wp_die('Status wait', 'Status wait', 200);
  24.                     }
  25.                     $orderId = $postedData['orderId'];
  26.                     $order = new WC_Order($orderId);
  27.  
  28.                     $valid = $this->check_ipn_request_is_valid($postedData);
  29.                     if ($valid === true) {
  30.                         if ($postedData['status'] === 'success') {
  31.                             $order->update_status('processing', __('Payment successfully paid', 'payop-woocommerce'));
  32.                             wp_die('Status success', 'Status success', 200);
  33.                         } elseif ($postedData['status'] === 'error') {
  34.                             $order->update_status('failed', __('Payment not paid', 'payop-woocommerce'));
  35.                             wp_die('Status fail', 'Status fail', 200);
  36.                         }
  37.                         do_action('valid-payop-standard-ipn-reques', $postedData);
  38.                     } else {
  39.                         wp_die($valid, $valid, 400);
  40.                     }
  41.                     break;
File Description
  • 123123q
  • PHP Code
  • 20 Nov-2019
  • 1.73 Kb
You can Share it: