PHP code example of paybeehive / beehivehub-php-sdk
1. Go to this page and download the library: Download paybeehive/beehivehub-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paybeehive / beehivehub-php-sdk example snippets
eehiveHub\SDK\BeehiveHubClient;
$beehive = new BeehiveHubClient('your_secret_key');
$transaction = $beehive->transactions->create([
'amount' => 10000, // R$ 100,00 em centavos
'paymentMethod' => 'pix',
'customer' => [
'name' => 'João Silva',
'email' => '[email protected] ',
'document' => ['type' => 'cpf', 'number' => '00000000191'],
'phone' => '11999999999',
],
'items' => [
['title' => 'Produto Teste', 'unitPrice' => 10000, 'quantity' => 1, 'tangible' => true],
],
'postbackUrl' => 'https://example.com/webhook',
]);
echo "Transação criada: " . $transaction['id'];
$beehive = new BeehiveHubClient('your_secret_key_here');
$beehive = new BeehiveHubClient('your_secret_key', ['environment' => 'sandbox']);
$beehive = new BeehiveHubClient($_ENV['BEEHIVE_SECRET_KEY']);
$transaction = $beehive->transactions->create([
'amount' => 10000,
'paymentMethod' => 'pix',
'customer' => [
'name' => 'João Silva',
'email' => '[email protected] ',
'document' => ['type' => 'cpf', 'number' => '00000000191'],
'phone' => '11999999999',
],
'items' => [
['title' => 'Produto Teste', 'unitPrice' => 10000, 'quantity' => 1, 'tangible' => true],
],
'postbackUrl' => 'https://example.com/webhook',
'metadata' => ['orderId' => '1234567890'],
]);
$transactions = $beehive->transactions->list([
'limit' => 100,
'offset' => 0,
'createdFrom' => '2026-01-01T00:00:00',
]);
$transaction = $beehive->transactions->get(123456);
// Estorno total
$refund = $beehive->transactions->refund(123456);
// Estorno parcial
$partialRefund = $beehive->transactions->refund(123456, 5000);
$updated = $beehive->transactions->updateDelivery(123456, [
'status' => 'in_transit',
'trackingCode' => 'BR123456789',
]);
$customer = $beehive->customers->create([
'name' => 'Maria Santos',
'email' => '[email protected] ',
'document' => ['type' => 'cpf', 'number' => '98765432100'],
'phone' => '11988888888',
'address' => [
'street' => 'Rua Teste',
'streetNumber' => '456',
'complement' => 'Apto 101',
'neighborhood' => 'Jardins',
'zipCode' => '01234567',
'city' => 'São Paulo',
'state' => 'SP',
'country' => 'br',
],
]);
$customers = $beehive->customers->list(['email' => '[email protected] ']);
$customer = $beehive->customers->get(123456);
$transfer = $beehive->transfers->create([
'amount' => 50000,
'recipientId' => 916,
]);
// Com conta bancária opcional
$transferWithAccount = $beehive->transfers->create([
'amount' => 50000,
'recipientId' => 916,
'bankAccount' => [
'bankCode' => '001',
'agencyNumber' => '1234',
'accountNumber' => '12345',
'accountDigit' => '6',
'type' => 'conta_corrente',
'legalName' => 'Destinatário Teste',
'documentNumber' => '12345678900',
'documentType' => 'cpf',
],
]);
$transfer = $beehive->transfers->get(123456);
$balance = $beehive->balance->get();
echo "Disponível: R$ " . ($balance['amount'] / 100);
echo "Recipient ID: " . $balance['recipientId'];
$recipient = $beehive->recipients->create([
'legalName' => 'Recebedor Teste Ltda',
'document' => ['type' => 'cnpj', 'number' => '58593776000142'],
'transferSettings' => [
'transferEnabled' => true,
'automaticAnticipationEnabled' => false,
'anticipatableVolumePercentage' => 100,
],
'bankAccount' => [
'bankCode' => '001',
'agencyNumber' => '1234',
'accountNumber' => '12345',
'accountDigit' => '6',
'type' => 'conta_corrente',
'legalName' => 'Recebedor Teste Ltda',
'documentNumber' => '58593776000142',
'documentType' => 'cnpj',
],
]);
$recipients = $beehive->recipients->list();
$recipient = $beehive->recipients->get(916);
$updated = $beehive->recipients->update(916, ['legalName' => 'Novo Nome Ltda']);
$bankAccount = $beehive->bankAccounts->create(916, [
'bankCode' => '341',
'agencyNumber' => '9876',
'accountNumber' => '54321',
'accountDigit' => '0',
'type' => 'conta_poupanca',
'legalName' => 'Empresa Teste Ltda',
'documentNumber' => '60572883000136',
'documentType' => 'cnpj',
]);
$accounts = $beehive->bankAccounts->list(916);
$company = $beehive->company->get();
$updated = $beehive->company->update([
'invoiceDescriptor' => 'Beehive Hub',
'details' => [
'averageRevenue' => 10000,
'averageTicket' => 100.50,
'physicalProducts' => true,
'productsDescription' => 'Produtos físicos',
'siteUrl' => 'https://www.meusite.com.br',
'phone' => '11999999999',
'email' => '[email protected] ',
],
]);
$paymentLink = $beehive->paymentLinks->create([
'title' => 'Meu Link de Pagamento',
'amount' => 1000,
'settings' => [
'defaultPaymentMethod' => 'credit_card',
'requestAddress' => true,
'requestPhone' => true,
'traceable' => true,
'boleto' => ['enabled' => true, 'expiresInDays' => 3],
'pix' => ['enabled' => true, 'expiresInDays' => 1],
'card' => ['enabled' => true, 'freeInstallments' => 1, 'maxInstallments' => 12],
],
]);
// $paymentLink['url'] já vem montada
$paymentLinks = $beehive->paymentLinks->list();
$paymentLink = $beehive->paymentLinks->get(247);
$updated = $beehive->paymentLinks->update(247, [
'title' => 'Título Atualizado',
'amount' => 2000,
]);
$beehive->paymentLinks->delete(247);
use BeehiveHub\SDK\BeehiveHubClient;
use BeehiveHub\SDK\Exceptions\BeehiveHubAuthenticationError;
use BeehiveHub\SDK\Exceptions\BeehiveHubValidationError;
use BeehiveHub\SDK\Exceptions\BeehiveHubAPIError;
use BeehiveHub\SDK\Exceptions\BeehiveHubNetworkError;
$beehive = new BeehiveHubClient($_ENV['BEEHIVE_SECRET_KEY']);
try {
$transaction = $beehive->transactions->create([...]);
echo "Transação criada: " . $transaction['id'];
} catch (BeehiveHubAuthenticationError $e) {
echo "Chave de API inválida: " . $e->getMessage();
} catch (BeehiveHubValidationError $e) {
echo "Erro de validação: " . $e->getMessage();
print_r($e->details);
} catch (BeehiveHubAPIError $e) {
echo "Erro da API [{$e->statusCode}]: " . $e->getMessage();
} catch (BeehiveHubNetworkError $e) {
echo "Erro de rede: " . $e->getMessage();
}
// R$ 100,00 = 10000 centavos
'amount' => 10000
// R$ 1,50 = 150 centavos
'amount' => 150
// Converter reais para centavos
$reais = 100.0;
$centavos = (int) round($reais * 100); // 10000
// .env
BEEHIVE_SECRET_KEY=your_secret_key_here
// app.php
use BeehiveHub\SDK\BeehiveHubClient;
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$beehive = new BeehiveHubClient($_ENV['BEEHIVE_SECRET_KEY']);
bash
composer