lai3221/aspire-laravel-sdk

Laravel 11 SDK for the Aspire API, covering sandbox and production environments.

Maintainers

Package info

github.com/lai3221/aspire-laravel-sdk

pkg:composer/lai3221/aspire-laravel-sdk

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-05 07:52 UTC

This package is auto-updated.

Last update: 2026-06-05 09:16:18 UTC


README

A Laravel 11 friendly SDK for Aspire's REST APIs. It supports sandbox and production environments, API-key and bearer-token authentication, typed resources, webhook verification, and an editable endpoint map for partner-specific Swagger/OpenAPI paths.

Important: Aspire may provide partner-specific API routes in Swagger during onboarding. This package keeps all endpoint paths in config/aspire.php, so you can adjust paths without changing application code.

Installation

composer require aspireapp/aspire-laravel-sdk
php artisan vendor:publish --tag=aspire-config

Environment

ASPIRE_ENVIRONMENT=sandbox
ASPIRE_SANDBOX_BASE_URL=https://sandbox-api.aspireapp.com
ASPIRE_PRODUCTION_BASE_URL=https://api.aspireapp.com
ASPIRE_API_VERSION=v1
ASPIRE_CLIENT_ID=your-client-id
ASPIRE_CLIENT_SECRET=your-client-secret
ASPIRE_API_KEY=your-api-key
ASPIRE_ACCESS_TOKEN=your-oauth-access-token
ASPIRE_PROXY_URL=socks5h://username:password@127.0.0.1:1080
ASPIRE_WEBHOOK_SECRET=your-webhook-secret

Switch to production by setting:

ASPIRE_ENVIRONMENT=production

If Aspire gives you a region-specific or account-specific host, set:

ASPIRE_BASE_URL=https://your-onboarded-host.example

Quick start

use Aspire\Sdk\Facades\Aspire;

$accounts = Aspire::accounts()->list();
$balances = Aspire::accounts()->balances('account_id');

$payout = Aspire::payouts()->create([
    'source_account_id' => 'account_id',
    'recipient_id' => 'recipient_id',
    'amount' => 10000,
    'currency' => 'SGD',
    'reference' => 'INV-1001',
]);

OAuth

$url = Aspire::oauth()->authorizationUrl(
    redirectUri: route('aspire.callback'),
    scopes: ['accounts.read', 'transactions.read', 'payouts.write']
);

$token = Aspire::oauth()->token($request->get('code'), route('aspire.callback'));
$refreshed = Aspire::oauth()->refresh($token['refresh_token']);

Resources

Accounts

Aspire::accounts()->list(['currency' => 'SGD']);
Aspire::accounts()->retrieve('account_id');
Aspire::accounts()->balances('account_id');
Aspire::accounts()->details('account_id');

Transactions and bank feeds

Aspire::transactions()->list(['from' => '2026-01-01', 'to' => '2026-01-31']);
Aspire::transactions()->retrieve('transaction_id');
Aspire::bankFeeds()->accounts();
Aspire::bankFeeds()->transactions(['account_id' => 'account_id']);
Aspire::bankFeeds()->sync(['account_id' => 'account_id']);

Recipients and payouts

Aspire::recipients()->create([...]);
Aspire::recipients()->validate([...]);
Aspire::payouts()->quote([...]);
Aspire::payouts()->create([...]);
Aspire::payouts()->bulkCreate(['items' => [[...], [...]]]);
Aspire::payouts()->cancel('payout_id');
Aspire::payouts()->paymentLink([...]);

FX

Aspire::fx()->quote([
    'source_currency' => 'SGD',
    'target_currency' => 'USD',
    'source_amount' => 10000,
]);

Aspire::fx()->convert(['quote_id' => 'quote_id']);

Cards and users

Aspire::users()->create([...]);
Aspire::cards()->create([...]);
Aspire::cards()->freeze('card_id');
Aspire::cards()->unfreeze('card_id');
Aspire::cards()->updateLimits('card_id', [...]);
Aspire::cards()->transactions('card_id');

Account opening

Aspire::accountOpening()->createApplication([...]);
Aspire::accountOpening()->updateApplication('application_id', [...]);
Aspire::accountOpening()->uploadDocument('application_id', [...]);
Aspire::accountOpening()->submitApplication('application_id');

Webhooks

$payload = $request->getContent();
$signature = $request->header(config('aspire.webhook.signature_header'));
$timestamp = $request->header(config('aspire.webhook.timestamp_header'));

abort_unless(Aspire::webhooks()->verify($payload, $signature, $timestamp), 403);

$event = json_decode($payload, true);

Generic requests

Use this when Aspire adds an endpoint before this SDK adds a typed method:

$response = Aspire::request('POST', '/custom/path', payload: ['key' => 'value']);

Endpoint coverage

The endpoint map in config/aspire.php covers:

  • OAuth authorization, token refresh, token revocation
  • Accounts, balances, account details
  • Transactions and transaction attachments
  • Bank Feed accounts, transactions, sync
  • Recipients creation, validation, CRUD
  • Payouts, bulk payouts, payout quote, cancellation, payment links
  • FX quotes and conversions
  • Card issuance, card update, freeze, unfreeze, cancellation, limits, card transactions
  • Users/employees access lifecycle
  • Account-opening applications and document uploads
  • Webhook endpoint management and local signature verification

Publishing to GitHub and Packagist

  1. Create a public GitHub repository, for example aspire-laravel-sdk.
  2. Commit this package.
  3. Add a semantic version tag:
git tag v0.1.0
git push origin main --tags
  1. Submit the repository URL on Packagist.
  2. Enable Packagist GitHub hook or GitHub Actions auto-update.

Suggested first release: v0.1.0, then promote to v1.0.0 after confirming Aspire's partner Swagger paths and response schemas in sandbox.

Testing

composer install
composer test

Code style

composer format

License

MIT

Multi-account runtime credentials and per-account proxy

API reference: https://docs.api.aspireapp.com/api

For applications that manage several Aspire registered accounts in one Laravel project, do not rely on a single .env credential set. Store each account's client_id, client_secret, token and proxy settings in your database, then build a runtime client from the account selected by the frontend.

use App\Models\AspireAccount;
use Aspire\Sdk\Facades\Aspire;

$account = AspireAccount::query()
    ->whereKey($request->integer('aspire_account_id'))
    ->where('company_id', $request->user()->company_id)
    ->where('is_active', true)
    ->firstOrFail();

$balance = Aspire::forAccount($account)
    ->accounts()
    ->balances($request->string('account_id')->toString());

The SDK reads these model or array attributes when using Aspire::forAccount() or Aspire::forCredentials():

  • environment: sandbox or production
  • base_url: optional Aspire account-specific or region-specific base URL
  • client_id: Aspire Client ID for the selected registered account
  • client_secret: Aspire Client Secret for the selected registered account
  • api_key: optional API key, when your Aspire integration uses API-key authentication
  • access_token: optional OAuth access token
  • proxy_url or proxy: preferred per-account full proxy URL, for example socks5h://username:password@127.0.0.1:1080
  • proxy_scheme, proxy_host, proxy_port, proxy_username, proxy_password: backward-compatible split proxy settings
$client = Aspire::forCredentials([
    'environment' => 'production',
    'client_id' => $account->client_id,
    'client_secret' => $account->client_secret,
    'access_token' => $account->access_token,
    'proxy_url' => 'socks5h://proxy-user:proxy-pass@127.0.0.1:1080',
]);

$payout = $client->payouts()->create($payload);

See MULTI_ACCOUNT_USAGE.md for migration, Eloquent model, SOCKS5 proxy string support, token refresh and controller examples.

Transfer helper example:

$transfer = Aspire::forAccount($account)->transfers()->create($payload);