1

I'm using curl for post some variables from controller, the result is a page with HTML data which is exactly I want, the issue is how to show this html page after run the curl function

the result like this

enter image description here

   public function OnlineBanking($amount,$response_url)
    {
  
  $prm_date         =  gmdate("Y-m-d H:i:s",time()+(8*60*60));
  $prm_amount       =  $amount;
  $prm_mrhref       =  "R".time(); //"Order-KAS-".time();
  $prm_mrhid        =  *****; // test MID
  $prm_mrhsKey      =  "*****;";// test secret key
  $prm_payment_mrh_hash = sha1($prm_mrhsKey . $prm_mrhid . $prm_mrhref . str_replace('.', '', $prm_amount));
  $prm_returnURL      = $response_url; // return URL once tranx process completes.
  $prm_POSTURL      = "https://www.example.com/gateway.php"; //Payment gateway connecting page
  
        $postData['ord_date'] = $prm_date;     
        $postData['ord_returnURL'] = $prm_returnURL;      
        $postData['ord_totalamt'] = $prm_amount;
        $postData['ord_mercref'] = $prm_mrhref;
        $postData['ord_mercID'] = $prm_mrhid;
        $postData['merchant_hashvalue'] = $prm_payment_mrh_hash;
        $res = self::curlRequest($prm_POSTURL,$postData);
        return $res;
   
    }


    public static function curlRequest($url, $data = null)
    {

        $curl = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_POSTFIELDS =>  http_build_query($data),
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST"
        ]);

        $response = curl_exec($curl);
        $err = curl_error($curl);
        curl_close($curl);
        return $response;
    }

1 Answers1

0

you need to set CURLOPT_RETURNTRANSFER => true you can read about it here

you would then simply need to echo your output

similar question managing curl output in php

meewog
  • 1,690
  • 1
  • 22
  • 26