Skip to content

AYA Pay ​

The AYA Payment Gateway is one hosted checkout for AYA Pay, other wallets (KBZ Pay, WavePay, UAB Pay, CB Pay…) and cards (VISA, Mastercard, JCB).

CallWhat it doesReturns
$ayaPay->services()List the channels enabled for your accountlist<AyaPayService>
$ayaPay->initiate($data)Signed form posted to AYAFormPayment
$ayaPay->status($orderId)Enquire an orderPaymentStatusResult
$ayaPay->handleCallback($request)Verify the backend callbackPaymentCallback
$ayaPay->verifyRedirect($request)Verify the customer's returnPaymentCallback

How it works ​

AYA posts the result to your callback URL and also signs the query string it adds when sending the customer back.

AYA Pay: channels, signed form, callback, returnCustomerYour appAYA PayList enabled channels$ayaPay->services()Channels and methodse.g. aya_pay: QR, NOTIPick a channel and methodaya_pay + AyaPayMethod::QrSigned form, auto-submits$ayaPay->initiate($data)Post the form and payPOST /v1/payment/requestBackend callbackpayload + checkSumVerified callback is proof$ayaPay->handleCallback($request)Back on your return pagepayload + checkSum in the queryShow the right message$ayaPay->verifyRedirect($request)
AYA Pay: channels, signed form, callback, return

Channels and Methods ​

channel is a lowercase key such as aya_pay, kbz_pay or visa; method is how the customer pays through it. Which ones you have depends on your merchant account, so list them:

php
use Laranex\PhpMyanmarPayments\AyaPay\AyaPay;
use Laranex\PhpMyanmarPayments\AyaPay\AyaPayConfig;
use Laranex\PhpMyanmarPayments\AyaPay\AyaPayMethod;

$ayaPay = new AyaPay(new AyaPayConfig(
    appKey: '...',
    appSecret: '...',
    baseUrl: AyaPayConfig::PRODUCTION_URL,
));

foreach ($ayaPay->services() as $service) {
    // $service->name: "AYA Pay"
    // $service->key: "aya_pay", pass it as channel
    // $service->imageUrl: the channel's logo
    // $service->methods: [AyaPayMethod::Qr, AyaPayMethod::Noti]
    if ($service->supports(AyaPayMethod::Qr)) {
        // offer the QR method
    }
}

Methods AYA lists that this package doesn't know yet are kept in $service->unknownMethods; data and each service's methods are read only when they are JSON lists, and method entries that aren't text, numbers or booleans are skipped.

AyaPayMethodValueCustomer
AyaPayMethod::WebWEBPays on a hosted web page (cards)
AyaPayMethod::QrQRScans a QR with the wallet app
AyaPayMethod::NotiNOTIApproves a push notification in the wallet app

Initiating a Payment ​

php
use Laranex\PhpMyanmarPayments\AyaPay\AyaPayMethod;
use Laranex\PhpMyanmarPayments\AyaPay\AyaPayPaymentData;

$data = new AyaPayPaymentData(
    orderId: 'ORDER_'.$order->id,
    amount: 10000,
    channel: 'aya_pay',
    method: AyaPayMethod::Qr,
    returnUrl: 'https://shop.test/payments/aya/return',
    description: 'Order #'.$order->id,
);

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

// The page posts the signed form to AYA on load.
echo $payment->toHtml();

AyaPayPaymentData ​

ParameterTypeRequiredRules
orderIdstringYesUnique, 6 to 40 characters (merchOrderId), no :
amountAmount|intYesWhole kyat, greater than 0, e.g. 10000 or Amount::kyat(10000). AYA documents no decimals and only accepts MMK (104)
channelstringYesA key from services()
methodAyaPayMethodYesAyaPayMethod::Web, ::Qr or ::Noti
returnUrl?stringNoAbsolute http or https URL. null uses the URL registered with AYA
description?stringNoShown to the customer, no :
userRefslist<string>NoUp to 5 of your own values, echoed back in the callback, none containing :

AYA joins the signed values with :, so orderId, description and userRefs can't contain one (The orderId field must not contain ":".); a : in any user ref is reported once, under userRefs.

Handling Callbacks ​

AYA posts to the callback URL registered with them.

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

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

if ($callback->isSuccessful()) {
    // $callback->orderId is your merchOrderId
    // $callback->gatewayReference is AYA's tranId
}

$callback->acknowledgement->send();

AYA signs only the fields present in its payload: fields AYA leaves out are skipped when verifying, and the rest are verified in the order the specification lists.

Because AYA joins the signed values with :, a matching checkSum alone could let a value be re-split into other fields. A payload is therefore only accepted when, besides the checksum:

  • no signed value contains :, except dateTime, which must be empty or have the form YYYY-MM-DD HH:MM:SS;
  • merchOrderId is present, and so is tranId when statusCode is 00 (a failed, rejected or pending payload may leave it out);
  • amount is a decimal, e.g. 10000 or 10000.00;
  • the currency code is 104 (MMK);
  • statusCode is two digits.

Anything else throws SignatureVerificationException: AYA Pay callback checksum verification failed. when payload or checkSum is missing or not a string, the payload can't be decoded, holds a nested value or the checksum doesn't match, and AYA Pay callback payload is malformed. when a correctly signed payload breaks these rules (redirect or enquiry response instead of callback for the return page and status()).

The Return Page ​

AYA signs the query string it adds when sending the customer back, so the return page can show the right message:

php
// GET /payments/aya/return
use Laranex\PhpMyanmarPayments\Exceptions\SignatureVerificationException;
use Laranex\PhpMyanmarPayments\Http\CallbackRequest;

try {
    $result = $ayaPay->verifyRedirect(CallbackRequest::fromGlobals());
} catch (SignatureVerificationException) {
    http_response_code(400);
    echo 'invalid return';
    exit;
}

echo $result->isSuccessful()
    ? 'Thank you, your payment was received.'
    : 'Payment '.$result->status->value.'.';

payload may be standard base64 with or without its = padding; partial padding, the URL-safe alphabet, line breaks and payloads that aren't UTF-8 JSON are rejected. A + that reached you as a space (an unencoded query string) is read back as +; the checksum is still verified. Still fulfill orders from the backend callback.

Status Checks ​

php
$result = $ayaPay->status('ORDER_'.$order->id);

if ($result->isSuccessful()) {
    // $result->gatewayReference is AYA's tranId
}

status() takes your orderId.

Responses ​

What AYA Pay 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.

services() → list<AyaPayService> ​

Property / MethodAYA Pay value
nameAYA name, e.g. AYA Pay. Falls back to key
keyAYA key, e.g. aya_pay, kbz_pay, visa. Pass it as channel. Always set
imageUrlAYA image_url, the channel's logo. null when AYA sends none
methodslist<AyaPayMethod> this package knows, e.g. [AyaPayMethod::Qr, AyaPayMethod::Noti]
unknownMethodslist<string> of methods AYA listed that this package doesn't know yet. Usually []
supports($method)Whether methods contains $method

Entries AYA sends without a key are skipped.

initiate() → FormPayment ​

Property / MethodAYA Pay value
flow()PaymentFlow::Form
orderIdYour $data->orderId
action{baseUrl}/v1/payment/request, e.g. https://pgw.ayainnovation.com/v1/payment/request
fieldsThe signed fields below, in signing order. Post them unchanged
enctypemultipart/form-data
autoSubmitUrlnull in plain PHP until you call withAutoSubmitUrl()
withAutoSubmitUrl($url)Returns a copy with autoSubmitUrl set
toHtml(?string $nonce = null)A full HTML page that posts fields to action on load; $nonce is added to its inline script
field($name)One field's value, or null
values()fields as an array
Form fieldValue
merchOrderId$data->orderId
amount$data->amount, e.g. 10000
appKey$config->appKey
timestampUnix time in seconds
userRef1 … userRef5$data->userRefs, "" when unused
description$data->description, "" when unset
currencyCode104 (MMK)
channel$data->channel, e.g. aya_pay
method$data->method, e.g. QR
overrideFrontendRedirectUrl$data->returnUrl, "" when unset
checkSumHMAC-SHA256 of the values above joined with :

initiate() makes no HTTP call. FormPayment has no raw: nothing is sent to AYA until the customer's browser posts the form.

status() → PaymentStatusResult ​

PropertyAYA Pay value
orderIdAYA merchOrderId. Always set: an enquiry payload without it fails verification
statusstatusCode mapped, see Statuses
gatewayStatusAYA statusCode, always two digits, e.g. 00
gatewayReferenceAYA tranId. Always set when statusCode is 00; null when a payload with another status leaves it out
amountAYA amount, e.g. 10000
rawThe verified, decoded enquiry payload: merchOrderId, tranId, amount, currenyCode, statusCode, paymentCardNumber, paymentMobileNumber, cardTypeName, cardExpiryDate, nameOnCard, approvalCode, tranRef, userRef1–5, description, dateTime

raw only has the keys AYA sent. The currency code arrives as currenyCode: AYA's payload spells it that way.

handleCallback() → PaymentCallback ​

Property / MethodAYA Pay value
orderIdAYA merchOrderId (your orderId)
statusstatusCode mapped, see Statuses
gatewayStatusAYA statusCode, always two digits, e.g. 00
gatewayReferenceAYA tranId. Always set when statusCode is 00; null when a payload with another status leaves it out
amountAYA amount, e.g. 10000
rawThe verified, decoded payload, with the same keys as status()
acknowledgementHTTP 200, empty body, Content-Type: text/plain

verifyRedirect() → PaymentCallback ​

The same values as handleCallback(), read from the signed payload and checkSum AYA adds to your return URL (query string first, then the body). There is nothing to acknowledge: render your own page.

Statuses ​

AYA statusCodePaymentStatus
00Successful
01Pending
02 (fail), 03 (reject)Failed
04Expired
anything elseUnknown

Errors ​

CallThrowsWhen
new AyaPayPaymentData(...)InvalidPaymentDataExceptionA value breaks the rules above, e.g. a : in orderId. Nothing is signed
services()ApiExceptionAYA answers with an HTTP error or a status other than 00
status()ApiExceptionAYA answers with an HTTP error or a status other than 00, e.g. 20 Transaction not found
status()SignatureVerificationExceptionThe enquiry payload's checkSum doesn't match, or the payload is malformed (see Handling Callbacks)
handleCallback(), verifyRedirect()SignatureVerificationExceptionpayload or checkSum is missing, payload isn't base64 JSON, a signed field holds an object or array, checkSum doesn't match, or the payload is malformed (see Handling Callbacks)

ApiException carries AYA's status (e.g. 20 Transaction not found, 09 Duplicate order ID) in gatewayCode and its message in gatewayMessage. When AYA can't be reached, the calls throw ApiException with httpStatus 0 and the original error as getPrevious().