omise-php icon indicating copy to clipboard operation
omise-php copied to clipboard

Some PHP hosting with curl can't use omise-lib

Open modernduck opened this issue 8 years ago • 2 comments

Hi I just get started and follow this guide

https://www.omise.co/omise-js-api

and somehow got error at

 $charge = OmiseCharge::create(array(
  'amount'   => 10025,
  'currency' => 'thb',
  'card'     => $_POST["omiseToken"]
));

and I some how fix it with manual curl like


<?php 
        // create curl resource 
        $ch = curl_init(); 

        // set url 
        curl_setopt($ch, CURLOPT_URL, "https://api.omise.co/charges" ); 
        curl_setopt($ch, CURLOPT_POST, 1 ); 
        curl_setopt($ch, CURLOPT_USERPWD, "{{$PRIVATE_KEY}}:");//-u

        $postdata = array(
                'description' => 'Test curl',
                'amount' => "570000",
                'currency' => 'thb',
                'return_uri' => "{{$REDIRECT_URL}}",
                'card'  => $_POST['omiseToken'] 
            )
        ;

        curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 
        
        // close curl resource to free up system resources 
        curl_close($ch);      
        $result = json_decode($output);
        if($result->status == "successful"){
            $newURL = "{{$REDIRECT_URL}}";
            header('Location: '.$newURL);
        }
            
         else
            print_r($result);
        
?>

modernduck avatar Jun 21 '17 10:06 modernduck

Hi @modernduck. Thanks for reporting us. Can you provide a version of cURL library that that host is using and an error message or any screenshots that show the error you've got?

Note, you can use the code below to check the cURL lib version.

echo '<pre>';
print_r(curl_version());  

guzzilar avatar Jun 21 '17 11:06 guzzilar

sorry for late reply was busy fixing stuff

Array ( [version_number] => 466176 [age] => 3 [features] => 34493 [ssl_version_number] => 0 [version] => 7.29.0 [host] => x86_64-redhat-linux-gnu [ssl_version] => NSS/3.19.1 Basic ECC [libz_version] => 1.2.7 [protocols] => Array ( [0] => dict [1] => file [2] => ftp [3] => ftps [4] => gopher [5] => http [6] => https [7] => imap [8] => imaps [9] => ldap [10] => ldaps [11] => pop3 [12] => pop3s [13] => rtsp [14] => scp [15] => sftp [16] => smtp [17] => smtps [18] => telnet [19] => tftp )

)

modernduck avatar Jun 29 '17 04:06 modernduck

Since there hasn’t been any activity on this issue for a while, we’re going to close it. If you’re still experiencing this issue, please feel free to reopen it with more details and we’ll take another look.

aashishgurung avatar Mar 10 '23 08:03 aashishgurung