Skip to content

Results ​

Starting a payment returns one of four classes exported from @laranex/myanmar-payments. Each has a read-only flow property, and PaymentResult is their union, so a switch on payment.flow tells them apart. Fields a gateway did not provide are undefined.

RedirectPayment ​

Returned by kbz.pwa() and wave.initiate().

FieldTypeDescription
flow'redirect'PaymentFlow.Redirect
orderIdstringYour order ID, as sent to the gateway
urlstringThe gateway page to redirect the customer to
gatewayReferencestring | undefinedThe gateway's ID for this attempt (KBZ prepay_id, Wave transaction_id)
rawRecord<string, unknown>The gateway's response, for logging

FormPayment ​

Returned by aya.initiate() and cs.initiate().

Field / MethodTypeDescription
flow'form'PaymentFlow.Form
orderIdstringYour order ID
actionstringThe gateway URL the form posts to
fieldsreadonly FormField[]The signed hidden fields ({ name, value }) in order. Post them unchanged
enctypestringThe encoding the gateway expects; application/x-www-form-urlencoded unless the gateway needs another (AYA: multipart/form-data)
toHtml()stringA complete, escaped page that submits the form on load
field(name)string | undefinedOne field's value
values()Record<string, string>The fields as an object

FormField is { readonly name: string; readonly value: string }.

QrPayment ​

Returned by kbz.qr(), yoma.initiate() and yoma.renewQr().

Field / MethodTypeDescription
flow'qr'PaymentFlow.Qr
orderIdstringYour order ID
qrStringstring | undefinedA QR payload to encode yourself (KBZ Pay)
qrImagestring | undefinedA base64 image to display as is (Yoma MMQR)
expiresAtDate | undefinedWhen the QR stops being payable; undefined when the gateway sets no limit
referencestring | undefinedThe gateway's ID for this QR, used for status checks (Yoma refLabel, KBZ prepay_id)
rawRecord<string, unknown>The gateway's response, for logging
qrImageDataUri(mimeType?)string | undefinedqrImage as a data URI; mimeType defaults to image/png. undefined when there is no image

AppPayment ​

Returned by kbz.app(). JSON.stringify(payment) writes orderId, orderInfo, sign and signType, the names the KBZ Pay SDK uses.

Field / MethodTypeDescription
flow'app'PaymentFlow.App
orderIdstringYour order ID
orderInfostringThe signed order string the SDK expects
signstringThe signature of orderInfo
signTypestringThe signature algorithm, SHA256
rawRecord<string, unknown>The gateway's response; left out of toJSON()
toJSON(){ orderId, orderInfo, sign, signType }{"orderId", "orderInfo", "sign", "signType"}, the values your app needs

PaymentFlow ​

A string union, so payment.flow === 'redirect' works too.

ConstantValueClass
PaymentFlow.RedirectredirectRedirectPayment
PaymentFlow.FormformFormPayment
PaymentFlow.QrqrQrPayment
PaymentFlow.AppappAppPayment

PaymentFlow is also a type: 'redirect' | 'form' | 'qr' | 'app'.

raw values are plain JavaScript values, with JSON numbers kept as their exact text in a string (1000.50 stays "1000.50"), never a rounded number. JSON.stringify(payment.raw) logs them.

Every result class takes its fields as an object, so you can build one in your own tests, e.g. new RedirectPayment({ orderId: 'ORDER_1', url: 'https://…' }).

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