I have problems to use curl in order to do some stripe payments.I installed the php curl extension with using the absolute path in ext folder but sept_opt is still undefined but curl_init() seems ok.
Install extension php, install curl.exe, system variables
print_r(curl_getinfo($ch)); :
Array ( [url] => [content_type] => [http_code] => 0 [header_size] => 0
[request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0
[redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0
[connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0
[size_download] => 0 [speed_download] => 0 [speed_upload] => 0
[download_content_length] => -1 [upload_content_length] => -1
[starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] =>
[primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 [http_version] => 0 [protocol] => 0 [ssl_verifyresult] => 0 [scheme] => [appconnect_time_us] => 0
[connect_time_us] => 0 [namelookup_time_us] => 0 [pretransfer_time_us] => 0 [redirect_time_us] => 0 [starttransfer_time_us] => 0 [total_time_us] => 0 )
if (!function_exists('curl_setopt_array')) {
function curl_setopt_array(&$ch, $curl_options)
{
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) {
return false;
}
}
return true;
}
}
$ch = curl_init();
print_r(curl_getinfo($ch));
$url="http://api.stripe.com/v1/".$endpoint;
curl_septopt($ch, CURL_OPT_URL, $url);
curl_septopt($ch, CURL_OPT_RETURNTRANSFER, true);
curl_septopt($ch, CURL_OPT_USERPWD, $this->api_key ) ;
curl_septopt($ch, CURL_HTTP_AUTH , CURL_AUTH_BASIC);
curl_septopt($ch, CURL_OPTIONS_POSTFIELDS , 'http_build_query('.$data.')');
Fatal error: Uncaught Error: Call to undefined function curl_septopt()
in C:xampphtdocsvenifruitlibsstripe.php:29 Stack trace: #0
C:xampphtdocsvenifruitmodulesespace-achat-primeurstripe-creer-paiement.php(17):
Stripe->api(‘customers’, Array) #1
C:xampphtdocsvenifruitindex.php(187):
include(‘C:xampphtdocs…’) #2 {main} thrown in
C:xampphtdocsvenifruitlibsstripe.php on line 29
2
Answers
We need to use ssl connections the easier is that way take this class on github and install to the root of server : Stripe class on github
And use this easy code :
The method is called
curl_setopt();
and notcurl_septopt();
.Also, there is no need to encode the Postfields. When passed as Array, it will encode it. Read the manual for details.