Skip to main content
The AvraAPI Laravel SDK registers one configured ApixClient singleton in your Laravel application. Use the AvraAPI Facade for concise application code or inject ApixClient where explicit dependencies are clearer. Both patterns use the same client and return the same response objects.
This package is for backend Laravel code only. Never put a Project Client Secret in a Blade view, browser JavaScript, mobile app, public repository, or client-facing response.

Facade

Use AvraAPI::currency(), AvraAPI::security(), and the other service accessors in a controller, job, command, or service class.

Dependency injection

Type-hint Avraapi\Apix\ApixClient when a class should declare its AvraAPI dependency explicitly.

Requirements

The current Laravel SDK release is 1.2.0. Composer installs its official PHP SDK ^1.5.2 dependency automatically.

Install the package

Run Composer from the root of your Laravel application:
Composer package discovery registers AvraApiServiceProvider and the AvraAPI alias. Do not add the provider or alias manually to config/app.php.

Configure project credentials

The package merges its configuration defaults automatically. Publish an application-owned config/avraapi.php file only when you want to inspect or customise those settings:
Keep your AvraAPI project credentials in the Laravel application’s .env file. APIX_PROJECT_KEY is the Project Client ID and APIX_API_SECRET is its matching Client Secret.
.env
development becomes dev and production becomes prod. The package defaults to production, so set APIX_ENV=development deliberately when working with a Development project. Keep the standard base URL for production. After changing .env values on a cached deployment, rebuild or clear that deployment’s Laravel configuration cache before it accepts new requests.

Use the Facade

Import the Facade in backend application code. Laravel resolves the shared configured client; do not construct a new client for every request.
Use the AvraAPI Facade in a controller
The Composer alias also makes AvraAPI available to Laravel. Importing Avraapi\Laravel\Facades\AvraAPI keeps the dependency explicit for IDEs and static analysis.

Use dependency injection

Inject Avraapi\Apix\ApixClient when a class should declare its dependency. It and the Facade resolve the same singleton.
Inject the configured client
Use one access pattern consistently inside a class. The Facade is convenient at application edges; dependency injection makes service dependencies explicit and easy to substitute in tests.

Read a JSON response

Most provider operations return ApiResponse. The operation result is in data; retain requestId in support records without retaining sensitive provider payloads.
Read an ApiResponse

Return generated media from a controller

Utilities can return BinaryResponse for PNG, SVG, or PDF output. Return its body with its content type. A utility configured for Base64 returns ApiResponse instead.
Return a generated QR image
Use isPdf(), isPng(), or isSvg() before selecting a media-specific workflow. The Laravel Utility guide documents the underlying output choices and response modes.

Use Privacy Mode for one provider request

All provider services inherit withPrivacyMode(). It sends X-Privacy-Mode: 1 for the next request only and then clears automatically.
Enable Privacy Mode for the next Security request
Privacy Mode keeps routing, billing, and usage tracking while applying the platform privacy guarantee to request and response payload storage. It does not make a request anonymous. The generic AvraAPI::call() method does not offer this fluent control.
lookupIp(..., privacyMode: true) and the Utilities privacyMode: true arguments remain supported and use the same header. Prefer withPrivacyMode() for a consistent one-request style.

Handle errors safely

The Laravel package preserves the PHP SDK’s typed exceptions. Catch a specific exception where your application has a recovery path, then use ApixException as the safe fallback.
Map an SDK failure to a Laravel response
Never return a Client Secret, raw provider diagnostic, or sensitive exception payload to a browser response. See the REST API guide for the standard AvraAPI response and error envelope.

Universal Payment Gateway

The Laravel SDK exposes the server-side UPG service through AvraAPI::payment() or an injected ApixClient. It uses the same typed options and result objects as the PHP SDK. Your application still owns pending orders, idempotency, callback routes, fulfilment, and final business decisions.

Universal Payment Gateway documentation

Follow the canonical checkout lifecycle, Payment Elements, completion, and gateway-specific guides. Do not invent Laravel-specific payment routes, events, jobs, or queues that the SDK does not provide.

Next steps

REST API Reference

Review provider request and response contracts.

Universal Payment Gateway

Build a server-authoritative payment integration.
Last modified on October 1, 2026