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

# Laravel SDK advanced services

> Use the Laravel SDK server-side Universal Payment Gateway integration and follow the canonical AvraAPI payment guides.

The Laravel SDK currently supports one Advanced Service: the **Universal Payment
Gateway (UPG)**. It provides the typed `payment()` accessor for backend payment
work while the canonical UPG documentation defines the complete integration,
gateway capabilities, frontend presentation, and completion rules.

The Laravel integration resolves the same configured `ApixClient` and typed
payment objects as the PHP SDK. It does not add Laravel-specific payment
events, queues, jobs, controllers, or webhook routes.

<Warning>
  Payment actions are backend-only. Never send a Project Client Secret,
  `completionContext`, callback artifact, gateway credential, or an unverified
  provider return payload to a browser.
</Warning>

<CardGroup cols={2}>
  <Card title="Quick Setup" icon="bolt" href="/universal-payment-gateway/quick-setup" className="border-2 border-slate-800/60 hover:border-[#0450ff] transition-all duration-700 ease-out">
    Connect a payment flow with the smallest complete backend integration.
  </Card>

  <Card title="Advanced Setup" icon="sliders" href="/universal-payment-gateway/advanced-setup/payment-initiation" className="border-2 border-slate-800/60 hover:border-[#0450ff] transition-all duration-700 ease-out">
    Control initiation, returns, webhooks, and authoritative completion.
  </Card>

  <Card title="Payment Elements" icon="table-columns" href="/universal-payment-gateway/payment-elements/overview" className="border-2 border-slate-800/60 hover:border-[#0450ff] transition-all duration-700 ease-out">
    Add AvraAPI's optional checkout UI while retaining your backend authority.
  </Card>

  <Card title="Gateway capabilities" icon="building-columns" href="/universal-payment-gateway/gateway-wise-functions" className="border-2 border-slate-800/60 hover:border-[#0450ff] transition-all duration-700 ease-out">
    Find verified gateway-specific functions, payment choices, and limits.
  </Card>
</CardGroup>

## Access the Laravel payment service

```php title="Access the Advanced Service" theme={null}
<?php

use Avraapi\Laravel\Facades\AvraAPI;

// AvraAPI SDK call. Keep this in backend application code.
$payments = AvraAPI::payment();
```

The accessor returns a typed `PaymentService`. Its common lifecycle methods
return dedicated payment value objects rather than a generic provider result.

| Laravel SDK method | Result type | Use it for |
| - | - | - |
| `availability()` | `PaymentAvailability` | Discover public payment methods safe to pass to Payment Elements. |
| `createOrder(CreateOrderOptions $options)` | `PaymentSession` | Prepare one payment session from your backend-owned pending order. |
| `completePayment(PaymentCompletionOptions $options)` | `PaymentCompletionResult` | Verify and complete a callback or return from your backend. |
| `verifyCallback(VerifyCallbackOptions $options)` | `VerificationResult` | Verify a supported callback payload in the server-side flow. |
| `verifySensitiveCallback(SensitiveCallbackOptions $options)` | `SensitiveVerificationResult` | Handle a sensitive callback artifact on the backend only. |

The service also exposes typed gateway facilities through `payhere()`,
`marxpay()`, `payplus()`, `koko()`, `onepay()`, and `webxpay()`. Use the
[gateway-wise guides](/universal-payment-gateway/gateway-wise-functions) for
the provider-specific contract instead of treating every gateway alike.

## Keep authority in your backend

<Steps>
  <Step title="Create a pending order">
    Store your order, amount, currency, customer data, and fulfilment intent in
    your application before creating a payment session.
  </Step>

  <Step title="Prepare the session through payment()">
    Use `createOrder()` with a typed `CreateOrderOptions` object. Keep the
    returned `completionContext` with your pending order; it is not browser
    data.
  </Step>

  <Step title="Present the checkout">
    Follow the selected gateway's redirect, overlay, or embedded presentation
    guide. A browser event or return page is not authoritative payment proof.
  </Step>

  <Step title="Complete and fulfil">
    Send the callback or return payload to your backend and use
    `completePayment()`. Fulfil only after the returned completion result is
    verified and its payment status meets your application policy.
  </Step>
</Steps>

<Info>
  `PaymentSession::completionContext` is deliberately server-only. A
  `PaymentCompletionResult` is the normalised completion result, but your
  application remains responsible for idempotency, order state, and the final
  fulfilment decision.
</Info>

<Note>
  Use the Facade in a controller, command, job, or service class, or inject
  `Avraapi\Apix\ApixClient` when the dependency should be explicit. Both
  patterns resolve the same configured payment service.
</Note>

## Choose the right UPG guide

<CardGroup cols={3}>
  <Card title="UPG Overview" icon="compass" href="/universal-payment-gateway/overview">
    Learn the lifecycle, project requirements, and supported integration paths.
  </Card>

  <Card title="Webhooks & completion" icon="shield-check" href="/universal-payment-gateway/advanced-setup/webhooks-and-completion">
    Implement authoritative callback verification and reconciliation.
  </Card>

  <Card title="Gateway-wise functions" icon="building-columns" href="/universal-payment-gateway/gateway-wise-functions">
    Use provider-specific capabilities only where they are verified and released.
  </Card>
</CardGroup>

## SDK availability

UPG is available through the PHP, Laravel, and Node.js SDKs. In Laravel, use
the Facade accessor `AvraAPI::payment()` (or inject the underlying
`ApixClient`) to use the same typed payment service and option objects. In
Node.js, use the released server-only `client.payment()` lifecycle. Use the
canonical UPG guides rather than attempting to recreate this server-side
contract through a raw HTTP call.

## Next steps

<CardGroup cols={2}>
  <Card title="Start Quick Setup" icon="rocket" href="/universal-payment-gateway/quick-setup">
    Build the smallest complete payment flow first.
  </Card>

  <Card title="Review UPG errors" icon="triangle-exclamation" href="/universal-payment-gateway/errors">
    Understand safe handling for unavailable methods, callbacks, and completion outcomes.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.