Skip to content

Yoma MMQR ​

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

CallWhat it doesReturns
$yomaMmqr->initiate($data)Check out the order and generate its first QRQrPayment
$yomaMmqr->renewQr($orderId)Generate a new QR for a checked-out orderQrPayment
$yomaMmqr->status($reference)Check a QR's payment statusPaymentStatusResult
$yomaMmqr->handleCallback($request)Verify the callbackPaymentCallback

How it works ​

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

Yoma MMQR: token, checkout, QR, renewal, resultCustomerYour appYoma MMQRGet a token unless cachedPOST /token, then cachedCheck out the order$yomaMmqr->initiate($data)Generate the QRqr/generate: QR + refLabelShow the QR for 120 s$payment->qrImageDataUri()Expired? Renew the QR$yomaMmqr->renewQr($orderId)Scan with an MMQR walletPayment callbackorderNumber, status, hashValueVerified callback is proof$yomaMmqr->handleCallback($request)No callback? Check status$yomaMmqr->status($reference)
Yoma MMQR: token, checkout, QR, renewal, result

Initiating a Payment ​

php
use Laranex\PhpMyanmarPayments\YomaMmqr\YomaMmqr;
use Laranex\PhpMyanmarPayments\YomaMmqr\YomaMmqrConfig;
use Laranex\PhpMyanmarPayments\YomaMmqr\YomaMmqrPaymentData;

$yomaMmqr = new YomaMmqr(
    new YomaMmqrConfig(
        merchantId: '...',
        clientId: '...',
        clientSecret: '...',
        webhookHashKey: '...',
        apiVersion: 'v1rc',
        webhookSecret: '...',
        baseUrl: YomaMmqrConfig::PRODUCTION_URL,
    ),
    cache: $cache, // a shared PSR-16 cache for the access token
);

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

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

// Store $payment->reference with the order for status checks.

$src = htmlspecialchars((string) $payment->qrImageDataUri());
echo '<img src="'.$src.'" alt="Scan with any MMQR wallet">';

YomaMmqrPaymentData ​

ParameterTypeRequiredRules
orderIdstringYesUnique order number, at most 20 characters
amountAmount|intYesWhole kyat, greater than 0, e.g. 10000 or Amount::kyat(10000). Yoma documents no decimals or currency
descriptionstringYesAt most 50 characters

Length limits count characters, not bytes.

Handling Callbacks ​

php
// POST /payments/yoma/callback
use Laranex\PhpMyanmarPayments\Exceptions\SignatureVerificationException;
use Laranex\PhpMyanmarPayments\Http\CallbackRequest;

try {
    $callback = $yomaMmqr->handleCallback(CallbackRequest::fromGlobals());
} catch (SignatureVerificationException) {
    http_response_code(400);
    echo 'invalid callback';
    exit;
}

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

$callback->acknowledgement->send();

The callback URL is registered with Yoma, not sent per order. Every callback must carry the configured webhookSecret in the X-Webhook-Secret header; a missing or wrong header fails verification. The hash is checked with HMAC-SHA256 keyed with your order number plus webhookHashKey. 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.

Callbacks carry no amount

Yoma signs only orderNumber and status, and the callback has no amount ($callback->amount is null). Match orderNumber to your stored order, whose QR was generated for the stored amount, and trust that amount; optionally confirm with $yomaMmqr->status($reference).

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
$payment = $yomaMmqr->renewQr('ORDER_'.$order->id);

// Store the new $payment->reference: the previous one stops working.

Status Checks ​

php
// $reference is the $payment->reference you stored
$result = $yomaMmqr->status($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 and PaymentCallback & Status for the full classes. A property the gateway didn't send is null. JSON numbers keep their exact text as strings.

initiate() → QrPayment ​

Property / MethodYoma MMQR value
flow()PaymentFlow::Qr
orderIdYour $data->orderId (Yoma orderNumber)
qrStringAlways null
qrImageYoma qrString, a base64 QR image. Always set
expiresAtNow + 120 seconds (YomaMmqr::QR_LIFETIME_SECONDS). Always set
referenceYoma refLabel, e.g. 100000083331. Pass it to status(). Always set
rawThe 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 ​

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

status() → PaymentStatusResult ​

PropertyYoma MMQR value
orderIdAlways null: Yoma only returns the reference
statuspaymentStatus mapped case-insensitively, see Statuses. Expired for a QR EXPIRED error
gatewayStatusYoma paymentStatus, trimmed, e.g. SUCCESS. QR EXPIRED for an expired QR
gatewayReferenceYoma refLabel, falling back to the reference you passed. Always set
amountAlways null: Yoma's status response has no amount
rawThe payment/check-status response: refLabel, paymentStatus, errorCode, errorDescription

handleCallback() → PaymentCallback ​

Property / MethodYoma MMQR value
orderIdYoma orderNumber (your orderId)
statusstatus mapped case-insensitively, see Statuses
gatewayStatusYoma status, trimmed, as sent, e.g. success
gatewayReferenceAlways null: Yoma's callback has no reference
amountAlways null: Yoma signs only orderNumber and status and sends no amount. Trust your stored amount
rawThe verified body: orderNumber, status, hashValue
acknowledgementHTTP 200, empty body, Content-Type: text/plain

Statuses ​

Yoma valuePaymentStatus
success (callback), SUCCESS (status)Successful
PENDINGPending
fail (callback), FAILED (status)Failed
QR EXPIRED errorExpired
anything elseUnknown

Access Tokens ​

Tokens are kept in the token cache and refetched once when Yoma answers 401; $yomaMmqr->forgetToken() drops the cached token.

The token is cached for Yoma's expires_in minus 60 seconds (at least 60 seconds). expires_in is read from its leading digits after any whitespace, so 28800.0 and 28800 are 28800 seconds; a missing or non-positive value means 3600.

Errors ​

CallThrowsWhen
new YomaMmqrPaymentData(...)InvalidPaymentDataExceptionA value breaks the rules above. Nothing is sent
initiate()ApiExceptionThe token request fails, Yoma answers with an HTTP error or an errorCode (e.g. PAYMENT ALREADY EXISTS), checkOutStatus isn't true, or qrString or refLabel is missing or empty
renewQr()ApiExceptionAs initiate(), without the checkout
status()ApiExceptionThe token request fails, or Yoma answers with an HTTP error or any errorCode other than QR EXPIRED
handleCallback()SignatureVerificationExceptionX-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. When Yoma can't be reached, the calls throw ApiException with httpStatus 0 and the original error as getPrevious().

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.

errorCodeYoma's descriptionWhat it means for your app
PAYMENT ALREADY EXISTSListed for checkout, without a descriptionThe order number was already checked out. Never call initiate() twice for one order: call renewQr()
PAYMENT ALREADY DONEPayment already processed for this orderThe order may already be paid: confirm against your records before charging again or fulfilling
PAYMENT ALREADY PROCESSEDDuplicate processing detectedAs above: confirm against your records
MERCHANT NOT FOUNDMerchant is invalid or inactiveCheck the merchant ID and that your Yoma account is active
PAYMENT NOT FOUNDOrder or refLabel not foundYoma doesn't know the order number or reference: check you passed the stored refLabel
QR EXPIREDQr has been expired.status() reports the QR as expired instead of an error; renew the QR to keep collecting the payment
UNAUTHORIZEDMissing or invalid tokenThe token is refetched once; if it persists, check the client ID and secret
VALIDATION ERROROne or more fields are invalidA request field broke Yoma's rules; Yoma's errorDescription says which