---
url: https://laranex.vercel.app/laravel-myanmar-payments/payment-flows.md
description: >-
  Each gateway method returns one typed result class per flow — RedirectPayment,
  FormPayment, QrPayment, AppPayment or MiniAppPayment — so you always know what
  to do next.
---

# Payment Flows

Starting a payment always follows the same pattern: build the gateway's request object, call the gateway, then act on the typed result it returns. Each flow has its own result class with exactly the fields that flow needs.

| Result | What you do | Returned by |
|---|---|---|
| `RedirectPayment` | Redirect the customer to `$payment->url` | `kbzPay()->pwa()`, `wavePay()->initiate()` |
| `FormPayment` | Redirect to `$payment->autoSubmitUrl` | `ayaPay()->initiate()`, `cyberSource()->hostedCheckout()` |
| `QrPayment` | Show the QR to the customer | `kbzPay()->qr()`, `yomaMmqr()->initiate()`, `yomaMmqr()->renewQr()` |
| `AppPayment` | Return the signed payload to your mobile app | `kbzPay()->app()` |
| `MiniAppPayment` | Return the signed payload to your mini app page | `wavePayMiniApp()->payment()` |

The customer finishing on the gateway's side is never proof of payment. Fulfill orders from the verified [callback](/laravel-myanmar-payments/callbacks) or a status check.

## Redirect Payments

Here is the flow with the KBZ Pay PWA; Wave Pay works the same way with its own payment page.

The gateway hosts its own payment page. Send the customer there.

```php
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;
use Laranex\PhpMyanmarPayments\KbzPay\KbzPayPaymentData;

$payment = MyanmarPayments::kbzPay()->pwa(new KbzPayPaymentData(
    orderId: 'ORDER_'.$order->id,
    amount: 10000,
    callbackUrl: route('payments.kbz.callback'),
));

return redirect()->away($payment->url);
```

`$payment->gatewayReference` holds the gateway's id for the attempt (KBZ `prepay_id`, Wave `transaction_id`).

## Form Payments

Here is the flow with AYA Pay; CyberSource works the same way with its hosted checkout.

The gateway expects the customer's browser to POST a signed form. The package hosts a page that renders the form and submits it immediately, so a redirect is enough:

```php
$payment = MyanmarPayments::ayaPay()->initiate($data);

return redirect($payment->autoSubmitUrl);
```

`autoSubmitUrl` is an encrypted, expiring link to the package's `myanmar-payments.form` route. See [Configuration](/laravel-myanmar-payments/configuration#auto-submit-form-route).

To render the form yourself, for example with your own loading state, return `toHtml()` or use `action`, `fields` and `enctype`:

```php
return response($payment->toHtml());
```

Under a Content-Security-Policy that allows scripts by nonce, pass it so the inline script runs: `$payment->toHtml(Vite::cspNonce())` renders `<script nonce="…">`. The package's form route does the same when your app sets the nonce with [`Vite::useCspNonce()`](/laravel-myanmar-payments/configuration#auto-submit-form-route).

```blade
<form id="payment-form" method="POST" action="{{ $payment->action }}"
      enctype="{{ $payment->enctype }}">
    @foreach ($payment->fields as $name => $value)
        <input type="hidden" name="{{ $name }}" value="{{ $value }}">
    @endforeach
</form>
<script>document.getElementById('payment-form').submit();</script>
```

Post the fields unchanged: they are signed.

## QR Payments

Here is the flow with Yoma MMQR, whose QR expires after 120 seconds; a KBZ Pay QR follows the same steps without renewals.

Gateways return QR codes in two shapes:

| Property | Gateway | Use it as |
|---|---|---|
| `qrString` | KBZ Pay | A payload: encode it into a QR image with any QR library |
| `qrImage` | Yoma MMQR | A base64 image: display it as is, e.g. with `qrImageDataUri()` |

```php
$payment = MyanmarPayments::yomaMmqr()->initiate($data);
```

```blade
<img src="{{ $payment->qrImageDataUri() }}" alt="Scan to pay">
<p>Valid until {{ $payment->expiresAt?->format('H:i:s') }}</p>
```

`expiresAt` is set when the gateway limits how long the QR is payable, and `reference` holds the id used for status checks (Yoma `refLabel`).

## App Payments

Here is the flow with the KBZ Pay mobile SDK.

The KBZ Pay mobile SDK needs a signed order string. Return it to your app, which passes it to `KBZPay.startPay()`:

```php
$payment = MyanmarPayments::kbzPay()->app($data);

// orderId, orderInfo, sign, signType
return response()->json($payment->toArray());
```

The SDK's own result only means the payment screen closed; rely on the callback or `kbzPay()->status()`.

## Mini App Payments

Wave Pay Mini App runs your web page inside the WavePay app. `payment()` signs the object the page passes to Wave's JavaScript SDK; no request is sent. `MiniAppPayment::toArray()` is exactly that object:

```php
$payment = MyanmarPayments::wavePayMiniApp()->payment($data);

// amount, miniAppID, merchantRefID, orderID, callBackUrl, hashValue, items
return response()->json($payment->toArray());
```

The page calls `WaveJsSDK.paymentModule.makePayment(payload)` with it after logging in with your app's access token; the SDK's result is not proof of payment. See [Wave Pay Mini App](/laravel-myanmar-payments/drivers/wave-pay-mini-app) for the whole flow.

See [Results](/laravel-myanmar-payments/references/results) for every property.
