This package conects localbitcoins.com API. With this package you can:
- Query Balance for your wallet
- Get Bitcoin buyers for a specific regoin
- Initiate a sell trade
- Release bitcoin to a specific trade
- Get chat message from the buyer
- PHP 7.1+
- Composer
To install this package run the commands bellow.
composer require ndlovu28/lbtc
Register the application in config/app.php by appending the line bellow in prividers section
Ndlovu28\Lbtc\LbtcServiceProvider::class,
Optionally you can add the bellow aliases section to call Lbtc in a short form.
'Lbtc' => Ndlovu28\Lbtc\Lbtc::class,
Load the database with the command bellow
php artisan migrate
In your controller or class add the line bellow if you added aliases
use Lbtc;
Or this if you did not add aliases
use Ndlovu28\Lbtc\Lbtc;
Initialize the class with your localbitcoins key and secret
$lbtc = new Lbtc();
$lbtc->config($key, $secret);
$balance = $lbtc->checkBalance();
Get advert with a matching amount to sell bitcoin for, the type of transaction, and location information. This will return the advert id if the found or false if not found
$ad_id = $lbtc->getBuyers('20000', 'm-pesa-tanzania-vodacom', 'Tanzania', 'TZ');
Start a trade with the given ad_id from get advert query. See here for trx_data array for the required fields for diiiferent payment methods.
$contact_id = $lbtc->initTrade($ad_id, $amount, $message, $trx_data);
The above will return contact_id which can be used to send messages to the buyer and check status of the trade.
//Send mesaage to the buyer
$result = $lbtc->sendMessage($contact_id, $message);
//Get messages array from the buyer
$messages = $lbtc->getMessages($contact_id);
//Check the status of the trade, return true if complete of false if its still pending payment
$status = $lbtc-<checkTrade($contact_id);
//Release bitcoins once the payment has been marked as PAID: Retunrns boolean for status
$lbtc->releseTrade($contact_id)