> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orqex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel

> Service provider, facade and configuration.

The SDK ships a Laravel integration. The service provider is auto-discovered, so installing
the package is enough.

## Configure

```bash theme={null}
ORCHESTRATE_SECRET_KEY=sk_live_...
```

Publish the config file if you need to change the defaults:

```bash theme={null}
php artisan vendor:publish --tag=orchestrate-config
```

```php theme={null}
// config/orchestrate.php
return [
    'secret_key'      => env('ORCHESTRATE_SECRET_KEY'),
    'base_uri'        => env('ORCHESTRATE_BASE_URI', 'https://api.orqex.com/v1'),
    'timeout'         => (float) env('ORCHESTRATE_TIMEOUT', 30),
    'connect_timeout' => (float) env('ORCHESTRATE_CONNECT_TIMEOUT', 10),
    'max_retries'     => (int) env('ORCHESTRATE_MAX_RETRIES', 2),
];
```

## Use it

The client is bound as a singleton, so inject it:

```php theme={null}
use Orqex\Orchestrate\OrchestrateClient;

final class CheckoutController
{
    public function __construct(private readonly OrchestrateClient $orqex) {}

    public function store(Request $request)
    {
        $checkout = $this->orqex->checkouts()->create([...]);

        return redirect()->away($checkout->url);
    }
}
```

Or use the facade:

```php theme={null}
use Orqex\Orchestrate\Laravel\Facades\Orchestrate;

$intent = Orchestrate::paymentIntents()->retrieve($id);
```

## Switching environments

Point `ORCHESTRATE_SECRET_KEY` at a `sk_sandbox_` key in your local and staging
environments, and a `sk_live_` key in production. Nothing else changes — see
[Authentication](/authentication).

## Receiving webhooks

Register a route that is exempt from CSRF, verify the signature against the **raw** body,
then hand the work to a queued job so the endpoint answers fast. See
[Webhooks](/webhooks) for the signature check and the event list.

```php theme={null}
Route::post('/webhooks/orqex', function (Request $request) {
    // verify the signature against $request->getContent(), then:
    ProcessOrqexEvent::dispatch($request->json()->all());

    return response()->noContent();
})->withoutMiddleware(VerifyCsrfToken::class);
```
