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
await yoma.initiate(data)Check out the order and generate its first QRQrPayment
await yoma.renewQr(orderId)Generate a new QR for a checked-out orderQrPayment
await yoma.status(reference)Check a QR's payment statusPaymentStatusResult
yoma.handleCallback(request)Verify the callbackPaymentCallback

Responses shows what Yoma MMQR puts in each result.

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 orderawait yoma.initiate(data)Generate the QRqr/generate: QR + refLabelShow the QR for 120 spayment.qrImageDataUri()Expired? Renew the QRawait yoma.renewQr(orderId)Scan with an MMQR walletPayment callbackorderNumber, status, hashValueVerified callback is proofyoma.handleCallback(request)No callback? Check statusawait yoma.status(reference)
Yoma MMQR: token, checkout, QR, renewal, result

Initiating a Payment ​

ts
import {
  YomaMmqr,
  type YomaMmqrPaymentData,
} from '@laranex/myanmar-payments/yoma-mmqr';

// Create it once at startup: the in-memory token cache lives on the instance.
const yoma = new YomaMmqr({
  merchantId: '...',
  clientId: '...',
  clientSecret: '...',
  webhookHashKey: '...',
  apiVersion: 'v1rc',
  timeoutSeconds: 30,
});

const data: YomaMmqrPaymentData = {
  orderId: `ORDER_${order.id}`,
  amount: 10000,
  description: `Order #${order.id}`,
};

const payment = await yoma.initiate(data);

// Store payment.reference with the order for status checks.

const src = payment.qrImageDataUri();
res.end(`<img src="${src}" alt="Scan with any MMQR wallet">`);

YomaMmqrPaymentData ​

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

QR Image ​

qrImage is an already rendered base64 PNG of the payment slip: display it as is, no QR library needed.

Handling Callbacks ​

ts
import { CallbackRequest } from '@laranex/myanmar-payments';

// POST /payments/yoma/callback
try {
  const request = await CallbackRequest.fromNodeRequest(req);
  const callback = yoma.handleCallback(request);

  if (callback.isSuccessful()) {
    // callback.orderId is your orderNumber
  }

  callback.acknowledgement.send(res);
} catch {
  res.writeHead(400).end('invalid callback');
}

The callback URL is registered with Yoma, not sent per order. When webhookSecret is configured, callbacks must carry it in the X-Webhook-Secret header. The hash is checked with HMAC-SHA256 keyed with your order number plus webhookHashKey.

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:

ts
const payment = await yoma.renewQr(`ORDER_${order.id}`);

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

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

Status Checks ​

ts
// reference is the payment.reference you stored
const result = await yoma.status(reference);

if (result.isSuccessful()) {
  // the QR was paid
}

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

Responses ​

What Yoma MMQR puts in each field. See Results and PaymentCallback & Status for the full classes. A field the gateway didn't send is undefined. raw holds plain JavaScript values, with JSON numbers kept as their exact text in a string (1000.50 stays "1000.50").

initiate() → QrPayment ​

Field / MethodYoma MMQR value
flow'qr'
orderIdYour data.orderId (Yoma orderNumber)
qrStringAlways undefined
qrImageYoma qrString, a base64 PNG of the payment slip. 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,…

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 ​

FieldYoma MMQR value
orderIdAlways undefined: 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 undefined: Yoma's status response has no amount
rawThe payment/check-status response: refLabel, paymentStatus, errorCode, errorDescription

handleCallback() → PaymentCallback ​

FieldYoma MMQR value
orderIdYoma orderNumber (your orderId)
statusstatus mapped case-insensitively, see Statuses
gatewayStatusYoma status, trimmed, as sent, e.g. success
gatewayReferenceAlways undefined: Yoma's callback has no reference
amountAlways undefined: Yoma's callback has no 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 ​

Yoma authenticates with an OAuth token that lasts hours. The gateway keeps it in the token cache, shares one token request between concurrent calls, and fetches a new token, retrying once, when Yoma answers 401. The shared token request is bounded by the HTTP client timeout rather than one call's signal, so aborting one call never fails the others. await yoma.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, for Yoma's expires_in minus 60 seconds (at least 60 seconds). expires_in is read from its leading digits, so 28800.0 is 28800 seconds; a missing or non-positive value means 3600.

Errors ​

CallThrowsWhen
initiate()InvalidPaymentDataErrorYomaMmqr.validate(data) fails. Nothing is sent
initiate()ApiErrorThe 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()ApiErrorAs initiate(), without the checkout
status()ApiErrorThe token request fails, or Yoma answers with an HTTP error or any errorCode other than QR EXPIRED
handleCallback()SignatureVerificationErrorX-Webhook-Secret is missing or wrong (when webhookSecret is set), orderNumber is missing, status holds an object or array, or hashValue doesn't match

The async calls reject with these errors. Yoma reports business errors with HTTP 200 and an errorCode; ApiError carries it in gatewayCode and Yoma's errorDescription in gatewayMessage. When Yoma can't be reached, the request times out or the signal aborts, the calls throw ApiError with the original error as cause.

Released under the MIT License, except where a package says otherwise.