Some PHP hosting with curl can't use omise-lib
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);
?>
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());
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 )
)
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.