---
url: https://laranex.vercel.app/laravel-myanmar-payments/drivers/yoma-mmqr.md
description: >-
  Integrate Yoma Bank MMQR with Laravel Myanmar Payments. Ready-made QR images,
  QR renewal, status checks and verified callbacks.
---

# Yoma MMQR

Yoma MMQR is Yoma Bank's MMQR gateway: it issues ready-made QR images that customers scan with any MMQR wallet.

| Call | What it does | Returns |
|---|---|---|
| `yomaMmqr()->initiate($data)` | Check out the order and generate its first QR | [`QrPayment`](#initiate-response) |
| `yomaMmqr()->renewQr($orderId)` | Generate a new QR for a checked-out order | [`QrPayment`](#renewqr-response) |
| `yomaMmqr()->status($reference)` | Check a QR's payment status | [`PaymentStatusResult`](#status-response) |
| `yomaMmqr()->handleCallback($request)` | Verify the callback | [`PaymentCallback`](#handlecallback-response) |

## How it works

Yoma checks each order out once, then issues QR codes that each stay payable for 120 seconds.

## Initiating a Payment

```php
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;
use Laranex\PhpMyanmarPayments\YomaMmqr\YomaMmqrPaymentData;

$data = new YomaMmqrPaymentData(
    orderId: 'ORDER_'.$order->id,
    amount: 10000,
    description: 'Order #'.$order->id,
);

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

$order->update(['qr_reference' => $payment->reference]);

return view('payments.qr', ['payment' => $payment]);
```

```blade
<img src="{{ $payment->qrImageDataUri() }}" alt="Scan with any MMQR wallet">
```

### YomaMmqrPaymentData

| Parameter | Type | Required | Rules |
|---|---|---|---|
| `orderId` | `string` | Yes | Unique order number, at most 20 characters |
| `amount` | `Amount\|int` | Yes | Whole kyat, greater than 0, e.g. `10000` or `Amount::kyat(10000)`. Yoma documents no decimals or currency |
| `description` | `string` | Yes | At most 50 characters |

Length limits count characters, not bytes.

### QR Image

`qrImage` is an already rendered base64 QR image: display it as is, no QR library needed.

## Handling Callbacks

```php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;
use Laranex\PhpMyanmarPayments\Exceptions\SignatureVerificationException;

Route::post('/payments/yoma/callback', function (Request $request) {
    try {
        $callback = MyanmarPayments::yomaMmqr()->handleCallback($request);
    } catch (SignatureVerificationException) {
        abort(400);
    }

    if ($callback->isSuccessful()) {
        // $callback->orderId is your orderNumber
    }

    return MyanmarPayments::acknowledge($callback);
})->name('payments.yoma.callback');
```

The callback URL is registered with Yoma, not sent per order. Every callback must carry the required `YOMA_MMQR_WEBHOOK_SECRET` in the `X-Webhook-Secret` header, compared in constant time; a missing or wrong header fails verification. The hash is checked with HMAC-SHA256 keyed with your order number plus `YOMA_MMQR_WEBHOOK_HASHKEY`. Yoma's specification only says the payload is hashed with that key; HMAC-SHA256 is inferred from its description and its 64-hex-digit sample.

::: warning Callbacks carry no amount
Yoma signs only `orderNumber` and `status`, and the callback has no amount (`$callback->amount` is `null`). Before fulfilling, confirm the payment with `MyanmarPayments::yomaMmqr()->status($reference)`, using the `reference` of the QR you created for the order's stored amount, rather than trusting the callback alone.
:::

## QR Lifetime and Renewal

A QR is payable for 120 seconds (`YomaMmqr::QR_LIFETIME_SECONDS`); `$payment->expiresAt` tells you when. Yoma accepts each order number **once**, so never call `initiate()` again for the same order. Renew the QR instead:

```php
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;

$payment = MyanmarPayments::yomaMmqr()->renewQr('ORDER_'.$order->id);

$order->update(['qr_reference' => $payment->reference]);
```

Each renewal retires the previous `reference`; only the newest one answers status checks.

## Status Checks

```php
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;

$result = MyanmarPayments::yomaMmqr()->status($order->qr_reference);

if ($result->isSuccessful()) {
    // the QR was paid
}
```

`status()` takes the QR's `reference`, not your `orderId`. An expired QR returns `PaymentStatus::Expired` instead of throwing.

## Responses

What Yoma MMQR puts in each property. See [Results](/laravel-myanmar-payments/references/results) and [PaymentCallback & Status](/laravel-myanmar-payments/references/payment-callback) for the full classes.

### `initiate()` → `QrPayment` {#initiate-response}

| Property / Method | Yoma MMQR value |
|---|---|
| `orderId` | Your `orderId` (Yoma `orderNumber`) |
| `qrString` | Always `null` |
| `qrImage` | Yoma `qrString`, a base64 QR image. Always set |
| `expiresAt` | Now + 120 seconds (`YomaMmqr::QR_LIFETIME_SECONDS`). Always set |
| `reference` | Yoma `refLabel`, e.g. `100000083331`. Pass it to `status()`. Always set |
| `raw` | The `qr/generate` response: `refLabel`, `qrString`, `errorCode` (`null`), `errorDescription` |
| `qrImageDataUri()` | `data:image/png;base64,…`. Yoma doesn't name the image format; PNG is the usual one |

`initiate()` checks the order out (`payment/checkout`), then generates its first QR; the result comes from the generate call.

### `renewQr()` → `QrPayment` {#renewqr-response}

The same values as [`initiate()`](#initiate-response) for the `orderId` you passed, with a new `qrImage`, `reference` and `expiresAt`. The previous `reference` stops answering status checks.

### `status()` → `PaymentStatusResult` {#status-response}

| Property | Yoma MMQR value |
|---|---|
| `orderId` | Always `null`: Yoma only returns the reference |
| `status` | `paymentStatus` mapped, see [Statuses](#statuses). `Expired` for a `QR EXPIRED` error |
| `gatewayStatus` | Yoma `paymentStatus`, trimmed, e.g. `SUCCESS`. `QR EXPIRED` for an expired QR |
| `gatewayReference` | Yoma `refLabel`, falling back to the reference you passed. Always set |
| `amount` | Always `null`: Yoma's status response has no amount |
| `raw` | The `payment/check-status` response: `refLabel`, `paymentStatus`, `errorCode`, `errorDescription` |

### `handleCallback()` → `PaymentCallback` {#handlecallback-response}

| Property / Method | Yoma MMQR value |
|---|---|
| `orderId` | Yoma `orderNumber` (your `orderId`) |
| `status` | `status` mapped case-insensitively, see [Statuses](#statuses) |
| `gatewayStatus` | Yoma `status`, trimmed, as sent, e.g. `success` |
| `gatewayReference` | Always `null`: Yoma's callback has no reference |
| `amount` | Always `null`: Yoma signs only `orderNumber` and `status` and sends no amount. Confirm with [`status()`](#status-checks) before fulfilling |
| `raw` | The verified body: `orderNumber`, `status`, `hashValue` |
| `acknowledgement` | HTTP `200`, empty body, `Content-Type: text/plain` |

## Statuses

| Yoma value | `PaymentStatus` |
|---|---|
| `success` (callback), `SUCCESS` (status) | `Successful` |
| `PENDING` | `Pending` |
| `fail` (callback), `FAILED` (status) | `Failed` |
| `QR EXPIRED` error | `Expired` |
| anything else | `Unknown` |

## Access Tokens

Yoma authenticates with an OAuth token that lasts hours. The package caches it in your cache store (see [Configuration](/laravel-myanmar-payments/configuration#cache)) and fetches a new one, retrying once, when Yoma answers `401`. `MyanmarPayments::yomaMmqr()->forgetToken()` drops the cached token, e.g. after rotating the client secret.

The token is cached under `myanmar-payments.yoma-mmqr.token.<sha256(baseUrl|clientId)>`, the same key every Laranex SDK uses, so services in different languages can share one cache (the cache store's own prefix still applies), for Yoma's `expires_in` minus 60 seconds (at least 60 seconds).

## Errors

| Call | Throws | When |
|---|---|---|
| `new YomaMmqrPaymentData(...)` | `InvalidPaymentDataException` | A value breaks the rules above. Nothing is sent |
| `initiate()` | `ApiException` | The token request fails, Yoma answers with an HTTP error or an `errorCode` (e.g. `PAYMENT ALREADY EXISTS`), `checkOutStatus` isn't `true`, or there is no `qrString` or `refLabel` |
| `renewQr()` | `ApiException` | As `initiate()`, without the checkout |
| `status()` | `ApiException` | The token request fails, or Yoma answers with an HTTP error or any `errorCode` other than `QR EXPIRED` |
| `handleCallback()` | `SignatureVerificationException` | `X-Webhook-Secret` is missing or wrong, `orderNumber` is missing, `orderNumber` or `status` holds an object or array, or `hashValue` doesn't match |

Yoma reports business errors with HTTP 200 and an `errorCode`; `ApiException` carries it in `gatewayCode` (an empty `errorCode` counts as none) and Yoma's `errorDescription` (or `error_description`) in `gatewayMessage`.

### Error Codes

Yoma's specification lists these `errorCode` values. Its error table gives HTTP 200 for the business codes, `401` for `UNAUTHORIZED` and `400` for `VALIDATION ERROR`; `PAYMENT ALREADY EXISTS` and `QR EXPIRED` appear only in the endpoint descriptions.

| `errorCode` | Yoma's description | What it means for your app |
|---|---|---|
| `PAYMENT ALREADY EXISTS` | Listed for checkout, without a description | The order number was already checked out. Never call `initiate()` twice for one order: call `renewQr()` |
| `PAYMENT ALREADY DONE` | Payment already processed for this order | The order may already be paid: confirm against your records before charging again or fulfilling |
| `PAYMENT ALREADY PROCESSED` | Duplicate processing detected | As above: confirm against your records |
| `MERCHANT NOT FOUND` | Merchant is invalid or inactive | Check the merchant ID and that your Yoma account is active |
| `PAYMENT NOT FOUND` | Order or refLabel not found | Yoma doesn't know the order number or reference: check you passed the stored `refLabel` |
| `QR EXPIRED` | Qr has been expired. | `status()` reports the QR as expired instead of an error; renew the QR to keep collecting the payment |
| `UNAUTHORIZED` | Missing or invalid token | The token is refetched once; if it persists, check the client ID and secret |
| `VALIDATION ERROR` | One or more fields are invalid | A request field broke Yoma's rules; Yoma's `errorDescription` says which |
