Skip to content

Payment Flows ​

Starting a payment always follows the same pattern: build the gateway's request object, call the gateway, then act on the typed result it returns. Each flow has its own result class with exactly the fields that flow needs.

ResultWhat you doReturned by
RedirectPaymentRedirect the customer to $payment->urlkbzPay()->pwa(), waveMoney()->initiate()
FormPaymentRedirect to $payment->autoSubmitUrlayaPay()->initiate(), cyberSource()->initiate()
QrPaymentShow the QR to the customerkbzPay()->qr(), yomaMmqr()->initiate(), yomaMmqr()->renewQr()
AppPaymentReturn the signed payload to your mobile appkbzPay()->app()

The customer finishing on the gateway's side is never proof of payment. Fulfill orders from the verified callback or a status check.

Redirect Payments ​

Here is the flow with the KBZ Pay PWA; Wave Money works the same way with its own payment page.

Redirect payment with the KBZ Pay PWACustomerYour appKBZ PayCheck outStart the paymentkbzPay()->pwa()Create the orderprecreate, trade_type PWAAPPprepay_idRedirect to the PWAredirect()->away($payment->url)Pay in the KBZ Pay appPayment notificationPOST to callbackUrlVerified callback is proofkbzPay()->handleCallback()
Redirect payment with the KBZ Pay PWA

The gateway hosts its own payment page. Send the customer there.

php
use Laranex\LaravelMyanmarPayments\Facades\MyanmarPayments;
use Laranex\PhpMyanmarPayments\KbzPay\KbzPayPaymentData;

$payment = MyanmarPayments::kbzPay()->pwa(new KbzPayPaymentData(
    orderId: 'ORDER_'.$order->id,
    amount: 10000,
    callbackUrl: route('payments.kbz.callback'),
));

return redirect()->away($payment->url);

$payment->gatewayReference holds the gateway's id for the attempt (KBZ prepay_id, Wave transaction_id).

Form Payments ​

Here is the flow with AYA Pay; CyberSource works the same way with its hosted checkout.

Form payment with AYA PayCustomerYour appAYA PayCheck outSign and encrypt the formayaPay()->initiate()Redirect to autoSubmitUrlencrypted, expires after ttl_minutesOpen the auto-submit routeGET myanmar-payments/formAuto-submitting form page410 Gone once the link expiresPost the signed formPOST /v1/payment/requestBack to your return URLnot proof of paymentBackend callbackpayload + checkSumVerified callback is proofayaPay()->handleCallback()
Form payment with AYA Pay

The gateway expects the customer's browser to POST a signed form. The package hosts a page that renders the form and submits it immediately, so a redirect is enough:

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

return redirect($payment->autoSubmitUrl);

autoSubmitUrl is an encrypted, expiring link to the package's myanmar-payments.form route. See Configuration.

To render the form yourself, for example with your own loading state, return toHtml() or use action, fields and enctype:

php
return response($payment->toHtml());
blade
<form id="payment-form" method="POST" action="{{ $payment->action }}"
      enctype="{{ $payment->enctype }}">
    @foreach ($payment->fields as $name => $value)
        <input type="hidden" name="{{ $name }}" value="{{ $value }}">
    @endforeach
</form>
<script>document.getElementById('payment-form').submit();</script>

Post the fields unchanged: they are signed. fields is an array keyed by name, in signing order; $payment->values() returns it and $payment->field($name) reads one.

QR Payments ​

Here is the flow with Yoma MMQR, whose QR expires after 120 seconds; a KBZ Pay QR follows the same steps without renewals.

QR payment with Yoma MMQRCustomerYour appYoma MMQRCheck outCheck out the orderyomaMmqr()->initiate()Generate the first QRqr/generateQR image and refLabelpayable for 120 secondsShow the QR$payment->qrImageDataUri()Expired? Renew the QRyomaMmqr()->renewQr($orderId)Scan with an MMQR walletPayment callbackorderNumber, status, hashValueVerified callback is proofyomaMmqr()->handleCallback()
QR payment with Yoma MMQR

Gateways return QR codes in two shapes:

PropertyGatewayUse it as
qrStringKBZ PayA payload: encode it into a QR image with any QR library
qrImageYoma MMQRA base64 image: display it as is, e.g. with qrImageDataUri()
php
$payment = MyanmarPayments::yomaMmqr()->initiate($data);
blade
<img src="{{ $payment->qrImageDataUri() }}" alt="Scan to pay">
<p>Valid until {{ $payment->expiresAt?->format('H:i:s') }}</p>

expiresAt is set when the gateway limits how long the QR is payable, and reference holds the id used for status checks (Yoma refLabel).

App Payments ​

Here is the flow with the KBZ Pay mobile SDK.

In-app payment with the KBZ Pay SDKCustomerYour appKBZ PayPay in your mobile appStart the paymentkbzPay()->app()Create the orderprecreate, trade_type APPprepay_idorderInfo, sign, signTyperesponse()->json(...)KBZPay.startPay()the customer pays in KBZ PayPayment screen closednot proof of paymentPayment notificationPOST to callbackUrlVerified callback is proofkbzPay()->handleCallback()
In-app payment with the KBZ Pay SDK

The KBZ Pay mobile SDK needs a signed order string. Return it to your app, which passes it to KBZPay.startPay():

php
$payment = MyanmarPayments::kbzPay()->app($data);

// orderId, orderInfo, sign, signType
return response()->json($payment->toArray());

The SDK's own result only means the payment screen closed; rely on the callback or kbzPay()->status().

See Results for every property.

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