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
yoma.Initiate(ctx, data)Check out the order and generate its first QR*QrPayment
yoma.RenewQR(ctx, orderID)Generate a new QR for a checked-out order*QrPayment
yoma.Status(ctx, reference)Check a QR's payment status*PaymentStatusResult
yoma.HandleCallback(request)Verify the callback*PaymentCallback

yoma is the *yomammqr.Gateway that paymentsfacades.MyanmarPayments().YomaMmqr() returns. 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 orderyoma.Initiate(ctx, data)Generate the QRqr/generate: QR + refLabelShow the QR for 120 spayment.QRImageDataURI(mimeType)Expired? Renew the QRyoma.RenewQR(ctx, orderID)Scan with an MMQR walletPayment callbackorderNumber, status, hashValueVerified callback is proofHandleCallbackFromContext(name, ctx)No callback? Check statusyoma.Status(ctx, reference)
Yoma MMQR: token, checkout, QR, renewal, result

Initiating a Payment ​

go
import (
	"fmt"
	"html/template"

	"github.com/goravel/framework/contracts/http"
	myanmarpayments "github.com/laranex/go-myanmar-payments/v4"
	"github.com/laranex/go-myanmar-payments/v4/yomammqr"
	paymentsfacades "github.com/laranex/goravel-myanmar-payments/v4/facades"
)

func (r *CheckoutController) Yoma(ctx http.Context) http.Response {
	order := findOrder(ctx) // your own order lookup

	yoma, err := paymentsfacades.MyanmarPayments().YomaMmqr()
	if err != nil {
		return ctx.Response().String(http.StatusInternalServerError, "%s", err)
	}
	data := yomammqr.PaymentData{
		OrderID:     fmt.Sprintf("ORDER_%d", order.ID),
		Amount:      myanmarpayments.Kyat(10000),
		Description: fmt.Sprintf("Order #%d", order.ID),
	}

	payment, err := yoma.Initiate(ctx, data)
	if err != nil {
		return ctx.Response().String(http.StatusBadGateway, "%s", err)
	}

	order.QRReference = payment.Reference
	saveOrder(order) // your own persistence

	return ctx.Response().View().Make("payments/qr.tmpl", map[string]any{
		"qr": template.URL(payment.QRImageDataURI("")),
	})
}
html
<img src="{{ .qr }}" alt="Scan with any MMQR wallet">

yomammqr.PaymentData ​

FieldTypeRequiredRules
OrderIDstringYesUnique order number, at most 20 characters
Amountmyanmarpayments.AmountYesWhole kyat, greater than 0, e.g. Kyat(10000). Yoma documents no decimals or currency
DescriptionstringYesAt 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. Wrap the data URI in template.URL, or html/template replaces it with #ZgotmplZ.

Handling Callbacks ​

go
import (
	"github.com/goravel/framework/contracts/http"
	payments "github.com/laranex/goravel-myanmar-payments/v4"
	paymentsfacades "github.com/laranex/goravel-myanmar-payments/v4/facades"

	"yourapp/app/facades"
)

facades.Route().Post("/payments/yoma/callback", func(
	ctx http.Context,
) http.Response {
	callback, err := paymentsfacades.MyanmarPayments().
		HandleCallbackFromContext(payments.GatewayYomaMmqr, ctx)
	if err != nil { // *myanmarpayments.SignatureVerificationError, ...
		return ctx.Response().String(http.StatusBadRequest, "invalid")
	}

	if callback.IsSuccessful() {
		// callback.OrderID is your orderNumber
	}

	return payments.Acknowledge(ctx, 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.

Callbacks carry no amount

Yoma signs only orderNumber and status, and the callback has no amount (callback.Amount is empty). Before fulfilling, confirm the payment with yoma.Status(ctx, 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.QRLifetime); payment.ExpiresAt tells you when. Yoma accepts each order number once, so never call Initiate() again for the same order. Renew the QR instead:

go
import (
	"fmt"

	paymentsfacades "github.com/laranex/goravel-myanmar-payments/v4/facades"
)

yoma, err := paymentsfacades.MyanmarPayments().YomaMmqr()
payment, err := yoma.RenewQR(ctx, fmt.Sprintf("ORDER_%d", order.ID))

order.QRReference = payment.Reference

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

Status Checks ​

go
import paymentsfacades "github.com/laranex/goravel-myanmar-payments/v4/facades"

yoma, err := paymentsfacades.MyanmarPayments().YomaMmqr()
result, err := yoma.Status(ctx, order.QRReference)

if err == nil && result.IsSuccessful() {
	// the QR was paid
}

Status() takes the QR's Reference, not your OrderID. An expired QR returns StatusExpired instead of an error.

Responses ​

What Yoma MMQR puts in each field. See Results and PaymentCallback & Status for the full types.

Initiate() → *QrPayment ​

Field / MethodYoma MMQR value
OrderIDYour OrderID (Yoma orderNumber)
QRStringAlways empty
QRImageYoma qrString, a base64 QR image. Always set
ExpiresAtNow + 120 seconds (yomammqr.QRLifetime). 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 ​

FieldYoma MMQR value
OrderIDAlways empty: Yoma only returns the reference
StatuspaymentStatus mapped, see Statuses. StatusExpired 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 empty: 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 empty: Yoma's callback has no reference
AmountAlways empty: Yoma signs only orderNumber and status and sends no amount. Confirm with Status() before fulfilling
RawThe verified body: orderNumber, status, hashValue
AcknowledgementHTTP 200, empty body, Content-Type: text/plain

Statuses ​

Yoma valuePaymentStatus
success (callback), SUCCESS (status)StatusSuccessful
PENDINGStatusPending
fail (callback), FAILED (status)StatusFailed
QR EXPIRED errorStatusExpired
anything elseStatusUnknown

Access Tokens ​

Yoma authenticates with an OAuth token that lasts hours. The package caches it in your cache store (see Configuration), shares one token request between concurrent calls, and fetches a new one, retrying once, when Yoma answers 401. The shared token request is bounded by the configured timeout (MYANMAR_PAYMENTS_HTTP_TIMEOUT), not one call's ctx: canceling one call never fails the others; that call stops waiting and returns an *APIError. yoma.ForgetToken() drops the cached token, e.g. after rotating the client secret; a token request already in flight is not cached when it completes.

The token is cached 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 ​

CallReturnsWhen
Initiate()*InvalidPaymentDataErrorA value breaks the rules above. 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, 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; *APIError 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.

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