blackboxcode/pando-account-bundle
Installation Add the bundle via Composer:
composer require blackboxcode/pando-account-bundle
Register the bundle in config/bundles.php (Symfony):
BlackBoxCode\PandoAccountBundle\PandoAccountBundle::class => ['all' => true],
Configuration Publish the default config:
php artisan vendor:publish --provider="BlackBoxCode\PandoAccountBundle\PandoAccountBundle" --tag="config"
Update config/pando_account.php with your Pando API credentials and environment settings.
First Use Case: Fetching an Account
Inject the PandoAccountService into a controller or service:
use BlackBoxCode\PandoAccountBundle\Service\PandoAccountService;
class AccountController extends Controller
{
public function __construct(private PandoAccountService $accountService) {}
public function show(string $accountId)
{
$account = $this->accountService->getAccount($accountId);
return response()->json($account);
}
}
Account Management
createAccount() or updateAccount() with an array of Pando-compatible attributes.
$accountData = [
'name' => 'Test Account',
'email' => 'test@example.com',
'metadata' => ['custom_field' => 'value']
];
$this->accountService->createAccount($accountData);
getAccount() or listAccounts().
$accounts = $this->accountService->listAccounts(['status' => 'active']);
Webhook Integration
webhook section in config/pando_account.php:
'webhook' => [
'url' => 'https://your-app.com/pando-webhook',
'events' => ['account.created', 'account.updated'],
],
public function handleWebhook(Request $request, PandoWebhookHandler $handler)
{
$handler->process($request);
}
Event-Driven Extensions
use BlackBoxCode\PandoAccountBundle\Event\AccountEvent;
public function __construct(private EventDispatcherInterface $dispatcher) {}
public function createAccount(array $data)
{
$account = $this->accountService->createAccount($data);
$this->dispatcher->dispatch(new AccountEvent($account, 'created'));
}
PandoAccountFacade for cleaner syntax in Blade or controllers:
use BlackBoxCode\PandoAccountBundle\Facades\PandoAccount;
$account = PandoAccount::getAccount($id);
PandoAccountService in unit tests:
$this->mock(PandoAccountService::class)
->shouldReceive('getAccount')
->once()
->andReturn(['id' => 123, 'name' => 'Test']);
API Rate Limits
$account = Cache::remember("pando_account_{$accountId}", now()->addHours(1), function () use ($accountId) {
return $this->accountService->getAccount($accountId);
});
PandoAccountService's getRateLimitStatus() method.Webhook Idempotency
PandoWebhookHandler:
$handler = new PandoWebhookHandler($request, config('pando_account.webhook.secret'));
if (!$handler->isValid()) {
abort(403, 'Invalid webhook signature');
}
idempotency_keys in the config to handle duplicate webhook deliveries.Data Mismatches
snake_case while your app uses camelCase. Normalize responses:
$account = $this->accountService->getAccount($id);
$normalized = (object) array_map('str_replace', ['_', ''], (array) $account);
debug: true in config/pando_account.php to log raw API responses:
'debug' => env('PANDO_DEBUG', false),
PandoDebugController
The bundle includes a debug endpoint at /_pando/debug to inspect API calls and responses.Custom Account Mappers Override the default mapper to transform Pando data:
// config/pando_account.php
'mappers' => [
'account' => App\Services\CustomAccountMapper::class,
];
Implement BlackBoxCode\PandoAccountBundle\Mapper\AccountMapperInterface.
Add Custom Fields
Extend the Account entity by adding a custom_fields array to your config:
'custom_fields' => [
'tax_id' => 'string',
'preferred_language' => 'string',
],
These will be included in create/update operations.
Batch Operations
Use the batchProcess() method for bulk operations (e.g., updating 100+ accounts):
$this->accountService->batchProcess(
'update',
['id' => [1, 2, 3]],
['status' => 'active']
);
Note: Pando’s API may impose batch size limits.
How can I help you explore Laravel packages today?