PHPackages                             darknautica/volta-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. darknautica/volta-php

ActiveLibrary[Payment Processing](/categories/payments)

darknautica/volta-php
=====================

The official Laravel SDK for Volta — AI billing, handled.

v1.0.0(2mo ago)018MITPHPPHP ^8.2

Since Apr 9Pushed 2mo agoCompare

[ Source](https://github.com/DarkNautica/volta-php)[ Packagist](https://packagist.org/packages/darknautica/volta-php)[ Docs](https://github.com/DarkNautica/volta-php)[ RSS](/packages/darknautica-volta-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

volta-php
=========

[](#volta-php)

> The official Laravel SDK for [Volta](https://volta.test) — AI billing, handled.

[![Latest Version on Packagist](https://camo.githubusercontent.com/8f03e64d778ae210e99725b5fe7e5ba9917b1a6f129ec9f9af987ddc11e5edf3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461726b6e6175746963612f766f6c74612d7068702e737667)](https://packagist.org/packages/darknautica/volta-php)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, or 12

Installation
------------

[](#installation)

```
composer require darknautica/volta-php
```

Publish the config:

```
php artisan vendor:publish --tag=volta-config
```

Add to your `.env`:

```
VOLTA_APP_KEY=your-app-key-here
VOLTA_BASE_URL=https://volta.test
```

Quick Start
-----------

[](#quick-start)

Three lines to add billing to any AI endpoint:

```
use DarkNautica\Volta\Facades\Volta;

// Check before calling AI
if (!Volta::hasAccess($user->id)) {
    return response()->json(['error' => 'Insufficient credits'], 402);
}

// Make your AI call here...

// Deduct after success
Volta::charge($user->id, 1);
```

Middleware
----------

[](#middleware)

Protect entire routes automatically:

```
// Requires 1 credit (default)
Route::post('/generate', [AIController::class, 'generate'])
    ->middleware('volta.gate');

// Requires 3 credits, specific model
Route::post('/analyze', [AIController::class, 'analyze'])
    ->middleware('volta.gate:3,gpt-4');
```

The middleware resolves the user automatically:

1. `$request->volta_user_id` if set explicitly
2. `$request->user()->id` if authenticated
3. Falls back to request IP for anonymous users

Blade Directives
----------------

[](#blade-directives)

```
{{-- Show balance --}}
@voltaBalance($user->id) credits remaining

{{-- Conditional content --}}
@voltaHasAccess($user->id, 1)
    Generate
@endvoltaHasAccess

@voltaNoAccess($user->id, 1)
    Buy more credits
@endvoltaNoAccess

{{-- Embed billing portal --}}

```

Available Methods
-----------------

[](#available-methods)

MethodDescription`Volta::charge($userId, $credits, $model?)`Deduct credits. Throws on failure.`Volta::hasAccess($userId, $credits?)`Check access. Always returns bool.`Volta::balance($userId)`Get credit balance.`Volta::topUp($userId, $credits)`Add credits to a user.`Volta::usage($userId)`Get usage history array.`Volta::portalUrl($userId, $options?)`Get signed billing portal URL.Testing Connection
------------------

[](#testing-connection)

```
php artisan volta:test
```

This will verify your API key, test connectivity, and display account info.

Error Handling
--------------

[](#error-handling)

```
use DarkNautica\Volta\Exceptions\InsufficientCreditsException;
use DarkNautica\Volta\Exceptions\RateLimitExceededException;

try {
    Volta::charge($user->id, 1);
} catch (InsufficientCreditsException $e) {
    return response()->json(['error' => 'Not enough credits'], 402);
} catch (RateLimitExceededException $e) {
    return response()->json(['error' => 'Slow down', 'retry_after' => $e->retryAfter], 429);
}
```

Fail Silently Mode
------------------

[](#fail-silently-mode)

Set `VOLTA_FAIL_SILENTLY=true` in `.env` to prevent Volta errors from crashing your app. When enabled:

- `hasAccess()` returns `false`
- `balance()` returns `0`
- `charge()` returns `false`

This is useful for apps that should degrade gracefully if Volta is unreachable.

Configuration
-------------

[](#configuration)

Env VariableDefaultDescription`VOLTA_APP_KEY`*(required)*Your Volta API key`VOLTA_BASE_URL``https://volta.test`Volta API base URL`VOLTA_TIMEOUT``10`HTTP timeout in seconds`VOLTA_FAIL_SILENTLY``false`Suppress exceptions, return safe defaults`VOLTA_CACHE_TTL``30`Balance cache duration in seconds (0 to disable)License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance88

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/538442c06e81234b160948e3e4a3ef2db287d3ca8ceaf06a62762faa60b43c8a?d=identicon)[DarkNautica](/maintainers/DarkNautica)

---

Top Contributors

[![DarkNautica](https://avatars.githubusercontent.com/u/181977445?v=4)](https://github.com/DarkNautica "DarkNautica (1 commits)")

---

Tags

laravelsdkstripebillingaicredits

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/darknautica-volta-php/health.svg)

```
[![Health](https://phpackages.com/badges/darknautica-volta-php/health.svg)](https://phpackages.com/packages/darknautica-volta-php)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
