cubits / cubits-php
Cubits PHP Client Library
Requires (Dev)
- phpunit/phpunit: ^6
This package is not auto-updated.
Last update: 2024-12-22 06:54:58 UTC
README
An easy way to buy, send, and accept bitcoin through the Cubits API.
This library supports API key authentication method
Installation
composer require cubits/cubits-php
Usage
Start by enabling an API Key on your account.
Next, configure the Cubits library via Cubits::configure
method and create an instance of the client using the Cubits::withApiKey
method:
Cubits::configure("https://pay.cubits.com/api/v1/",true); $cubits = Cubits::withApiKey($_ENV['Cubits_API_KEY'], $_ENV['Cubits_API_SECRET'])
Examples
Create an Invoice
$response = $cubits->createInvoice("EUR", "42.95", "Your Order #1234", array( "description" => "1 widget at EUR 42.95", "reference" => "my custom tracking code for this order" ));
Get an Invoice
$response = $cubits->getInvoice("ef73a6ed61a8c97427eaae2073b9127b");
Send Money
$response = $cubits->sendMoney("3Pj4mJfK62n9mjMRcHYs96nd15UQLHHhPS","0.25120521");
List Accounts
$response = $cubits->listAccounts();
Request Quote
$response = $cubits->requestQuote("buy","EUR","10","BTC");
Buy
$response = $cubits->buy("EUR","10");
Sell
$response = $cubits->sell("0.150","EUR");
createChannel
$response = $cubits->createChannel("EUR");
getChannel
$cubits->getChannel("7ff31a5843887cbaffb9adb3fcb2aebd");
updateChannel
$response = $cubits->updateChannel("7ff31a5843887cbaffb9adb3fcb2aebd", "EUR", "Alpaca underwear");
Security notes
If someone gains access to your API Key they will have complete control of your Cubits account. This includes the abillity to send all of your bitcoins elsewhere.
For this reason, API access is disabled on all Cubits accounts by default. If you decide to enable API key access you should take precautions to store your API key securely in your application. How to do this is application specific, but it's something you should research if you have never done this before.