---
url: https://laranex.vercel.app/laravel-myanmar-payments/amounts.md
description: >-
  Amounts are exact Amount values or plain integers, never floats. Each gateway
  validates them against its documented rules for decimals and minimums.
---

# Amounts

Every payment data class takes `Amount|int` for its amount. A plain `int` is a whole amount; use the `Laranex\PhpMyanmarPayments\Amount` value object when you need decimals. Floats are never accepted, so an amount is never rounded on its way into a signature.

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

Amount::kyat(10000);       // whole amount
Amount::parse('10000.50'); // decimal amount

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

## Creating Amounts

| Constructor | Accepts |
|---|---|
| `Amount::kyat(int $amount)` | A whole amount, 0 or more. Works for whole units of any currency |
| `Amount::parse(string $amount)` | Plain digits with an optional decimal part: `10000`, `10000.50`, `0.5`. Leading zeros of the whole part are dropped (`007.50` becomes `7.50`); the fraction is kept exactly |
| `Amount::from(Amount\|int $amount)` | An `Amount` as is, or an `int` through `kyat()`. The payment data classes use it |

`parse()` rejects signs, exponents, spaces and thousands separators (`-1`, `1e5`, ` 10`, `1,000`, `10.`, `.5`), and both constructors reject negatives, by throwing `InvalidPaymentDataException` with an `amount` error.

An `Amount` exposes `toString()` (as given without leading zeros, also via `(string) $amount` and `json_encode()`, which writes a string), `decimalPlaces()`, `wholePart()`, `isZero()`, `isPositive()` and `equals($other)`, which compares with another `Amount` or a decimal string, ignoring leading zeros and trailing fractional zeros; text that is not a plain decimal is never equal. The payment data classes always store an `Amount`, so `$data->amount` is an `Amount` even when you passed an `int`.

## Gateway Rules

Each gateway checks the amount against its official documentation when the payment data is created, before any request is sent:

| Gateway | Decimals | Other rules |
|---|---|---|
| KBZ Pay | Up to 2 places | Greater than 0, MMK only |
| Wave Pay | No | Greater than 0, MMK only. The total defaults to the sum of the items |
| Wave Pay Mini App | No | Greater than 0. The total defaults to the sum of the items |
| AYA Payment Gateway | No | Greater than 0, MMK only |
| Yoma MMQR | No | Greater than 0 |
| CyberSource | Any | 0 or more, at most 15 characters, currencies enabled on your Secure Acceptance profile |

A violation throws `InvalidPaymentDataException`, e.g. `Wave Pay does not accept decimal amounts; the amount field must be a whole number.` AYA Payment Gateway, whose documentation shows no decimal amounts, reports `AYA Payment Gateway documents no decimal amounts; the amount field must be a whole number.`

Amounts reported back by gateways (`PaymentCallback::$amount`, `PaymentStatusResult::$amount`) stay plain strings: they are the raw values the gateway sent. Compare them with your order before fulfilling.
