Cubit/Bitcoin With curl function
Using Curl same function you have to go the same functionality but here in addition u need to generate nonce and signature.
To start with bitcoin or cubit you need to generate cubits_key and cubits_secret from your merchant account. To use the cubits api you need three things or All requests to the API MUST include the following headers for authentication:
Cubits-Key: ...
Cubits-Nonce: ...
Cubits-Signature: ...
here is the code of bitcoin and cubit integration with using curl function
you will get all your response in result like in which includes invoice id and invoice url. so now you have to redirect the user to that invoice url . when u redirect the user to that url it redirect to cubit/bitcoin payment and that will look like this
To start with bitcoin or cubit you need to generate cubits_key and cubits_secret from your merchant account. To use the cubits api you need three things or All requests to the API MUST include the following headers for authentication:
Cubits-Key: ...
Cubits-Nonce: ...
Cubits-Signature: ...
here is the code of bitcoin and cubit integration with using curl function
<?php
$url = 'https://api.cubits.com/';
ini_set('display_errors', 1);
$name = "test";
$path = "/api/v1/invoices";
$url = $url.$path;
$fields = array(
"currency"=>"EUR",
"price"=> "266.45",
"name"=> "shankit sharma",
"description"=> "Twelve ounces of high quality, organic Guatemalan coffee",
"reference"=> "d0cef2"
);
$fields = json_encode($fields);
$_API_KEY = "api key here";
$_API_SECRET = "api secret here";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_POST, 1);
$post_data = hash('sha256', utf8_encode( $fields ), false );
$microseconds = sprintf('%0.0f',round(microtime(true) * 1000000));
$message = utf8_encode($path) . $microseconds . $post_data ;
$hmac_key = $_API_SECRET;
$signature =hash_hmac("sha512", $message , $hmac_key);
$headers = array('User-Agent: Cubits/PHP v0.0.1');
$headers[] = "X-Cubits-Key: {$_API_KEY}";
$headers[] = "X-Cubits-Signature: $signature";
$headers[] = "X-Cubits-Nonce: $microseconds";
$headers[] = "Accept: application/vnd.api+json";
$headers[] = "Content-Type: application/vnd.api+json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//execute post
$result = curl_exec($ch);
echo $result;
//close connection
curl_close($ch);
?>
$url = 'https://api.cubits.com/';
ini_set('display_errors', 1);
$name = "test";
$path = "/api/v1/invoices";
$url = $url.$path;
$fields = array(
"currency"=>"EUR",
"price"=> "266.45",
"name"=> "shankit sharma",
"description"=> "Twelve ounces of high quality, organic Guatemalan coffee",
"reference"=> "d0cef2"
);
$fields = json_encode($fields);
$_API_KEY = "api key here";
$_API_SECRET = "api secret here";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_POST, 1);
$post_data = hash('sha256', utf8_encode( $fields ), false );
$microseconds = sprintf('%0.0f',round(microtime(true) * 1000000));
$message = utf8_encode($path) . $microseconds . $post_data ;
$hmac_key = $_API_SECRET;
$signature =hash_hmac("sha512", $message , $hmac_key);
$headers = array('User-Agent: Cubits/PHP v0.0.1');
$headers[] = "X-Cubits-Key: {$_API_KEY}";
$headers[] = "X-Cubits-Signature: $signature";
$headers[] = "X-Cubits-Nonce: $microseconds";
$headers[] = "Accept: application/vnd.api+json";
$headers[] = "Content-Type: application/vnd.api+json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//execute post
$result = curl_exec($ch);
echo $result;
//close connection
curl_close($ch);
?>
you will get all your response in result like in which includes invoice id and invoice url. so now you have to redirect the user to that invoice url . when u redirect the user to that url it redirect to cubit/bitcoin payment and that will look like this
![]() |
Comments
Post a Comment