---
title: Price
published: 2026-09-15
lastmod: 2026-11-02
url: https://larasell.dev/docs/reference/price
---

## Table of contents
- [Creating a price](#creating-a-price)
- [Access & serialization](#access--serialization)
- [Arithmetic operations](#arithmetic-operations)
- [Formatting prices](#formatting-prices)
- [Currencies](#currencies)

# Price

A `Price`{href="https://raw.githubusercontent.com/Larasell-dev/larasell/refs/heads/main/src/Price.php"} represents a currency-independent amount in minor units (e.g. cents). Internally, the amount is stored as a string and uses BCMath, so prices never suffer from floating point rounding errors.

## Creating a price

To create a `Price`{href="https://raw.githubusercontent.com/Larasell-dev/larasell/refs/heads/main/src/Price.php"}, you pass an integer in minor units (e.g. cents) to the `of` method:

```php
use Larasell\Larasell\Price;

Price::of(1_000); // Amount in cents
Price::of('1000'); // Strings are also allowed
```

Use `fromArray` if you need to create a `Price`{href="https://raw.githubusercontent.com/Larasell-dev/larasell/refs/heads/main/src/Price.php"} from a payload/array:

```php
use Larasell\Larasell\Price;

Price::fromArray(['amount' => 1299]);
```

Passing anything other than an integer value throws an `InvalidArgumentException`. This includes decimal or formatted strings:

```php
use Larasell\Larasell\Price;

Price::of('12.99'); // throws InvalidArgumentException
Price::of('1_000'); // throws InvalidArgumentException
```

Larasell normalizes price amounts. Leading zeros are stripped, and a negative zero becomes a positive zero:

```php
use Larasell\Larasell\Price;

Price::of('04999')->amount(); // returns '4999'
Price::of('-0')->amount(); // returns '0'
```

## Access & serialization

The `amount` method returns the value as a string:

```php
use Larasell\Larasell\Price;

$price = Price::of(4999);
$price->amount(); // returns '4999'
```

To serialize prices, you can use the `toArray` and `jsonSerialize` methods:

```php
use Larasell\Larasell\Price;

// Both return ['amount' => '4999']
$price->toArray();
$price->jsonSerialize();
```

## Arithmetic operations

You can do a bunch of mathematical calculations with prices, like adding two prices:

```php
use Larasell\Larasell\Price;

$first = Price::of(800);
$second = Price::of(1000);

$result = $first->add($second);
$result->amount(); // returns '1800'
```

Or subtracting them:

```php
use Larasell\Larasell\Price;

$first = Price::of(600);
$second = Price::of(300);

$result = $first->subtract($second);
$result->amount(); // returns '300'
```

Subtracting prices can result in negative amounts:

```php
use Larasell\Larasell\Price;

$first = Price::of(400);
$second = Price::of(800);

$result = $first->subtract($second);
$result->amount(); // returns '-400'
```

You can also multiply prices:

```php
use Larasell\Larasell\Price;

$price = Price::of(200);

$result = $price->multiply(5);
$result->amount(); // returns '1000'
```

There's also the `greaterThan` method to compare prices:

```php
use Larasell\Larasell\Price;

$first = Price::of(100);
$second = Price::of(200);

$first->greaterThan($second); // returns false
$second->greaterThan($first); // returns true
```

Here's the full set of comparison methods: `greaterThan`, `greaterThanOrEqual`, `lessThan`, `lessThanOrEqual` and `equals`:

```php
use Larasell\Larasell\Price;

$first = Price::of(100);
$second = Price::of(200);

$first->lessThan($second); // returns true
$first->lessThanOrEqual(Price::of(100)); // returns true
$second->greaterThanOrEqual($first); // returns true
$first->equals(Price::of(100)); // returns true
```

If you need the raw comparison result, `compareTo` returns `-1` when the price is less than the given price, `0` when they are equal and `1` when it is greater:

```php
use Larasell\Larasell\Price;

Price::of(100)->compareTo(Price::of(200)); // returns -1
Price::of(200)->compareTo(Price::of(100)); // returns 1
Price::of(100)->compareTo(Price::of(100)); // returns 0
```

Note: comparisons only consider the amount, not the currency. A price of 100 EUR cents is "equal" to a price of 100 USD cents. Since prices are currency-independent, you are responsible for only comparing prices in the same currency.

`isPositive`, `isNegative` and `isZero` allow you to check whether a price is positive, negative or zero:

```php
use Larasell\Larasell\Price;

Price::of(-500)->isPositive(); // returns false
Price::of(100)->isPositive(); // returns true
Price::of(-500)->isNegative(); // returns true
Price::of(0)->isZero(); // returns true
```

## Formatting prices

To display a price, pass it to the `format` method together with a currency. The currency can be a string or a `Currency`{href="https://raw.githubusercontent.com/Larasell-dev/larasell/refs/heads/main/src/Enums/Currency.php"} enum case. Minor units are respected per currency, so `JPY` has no decimals, `BHD` uses three and `EUR` uses two:

```php
use Larasell\Larasell\Enums\Currency;
use Larasell\Larasell\Price;

$price = Price::of(1299);

Price::format($price, 'EUR'); // '€12.99' (locale dependent)
Price::format($price, Currency::EUR); // '€12.99'
Price::format($price, Currency::JPY); // '¥1,299'
```

Pass a locale as the third argument to format the price for a specific locale.
Either as a simple string or a [`Locale`](/docs/reference/locale) enum case.
If you leave the parameter out, Larasell formats the price determined by `App::currentLocale()`:

```php
use Larasell\Larasell\Enums\Currency;
use Larasell\Larasell\Enums\Locale;
use Larasell\Larasell\Price;

Price::format($price, Currency::EUR, 'de-DE'); // '12,99 €'
Price::format($price, Currency::EUR, Locale::ENGLISH_UNITED_STATES); // '€12.99'
```

## Currencies

The `Currency`{href="https://raw.githubusercontent.com/Larasell-dev/larasell/refs/heads/main/src/Enums/Currency.php"} enum represents currencies. Every case knows its minor unit digits, which the formatter uses to convert minor units to the displayed amount. Most currencies use two decimals, but some use three (like `BHD`, `KWD`, `OMR`) and some have no minor unit at all (like `JPY`, `ISK`, `VND`):

```php
use Larasell\Larasell\Enums\Currency;

Currency::USD->minorUnitDigits(); // 2
Currency::BHD->minorUnitDigits(); // 3
Currency::JPY->minorUnitDigits(); // 0
Currency::from('EUR'); // Currency::EUR
```

Larasell supports all currencies that Stripe supports (139 in total):

- `AED` — United Arab Emirates Dirham
- `AFN` — Afghan Afghani
- `ALL` — Albanian Lek
- `AMD` — Armenian Dram
- `ANG` — Netherlands Antillean Guilder
- `AOA` — Angolan Kwanza
- `ARS` — Argentine Peso
- `AUD` — Australian Dollar
- `AWG` — Aruban Florin
- `AZN` — Azerbaijani Manat
- `BAM` — Bosnia and Herzegovina Convertible Mark
- `BBD` — Barbadian Dollar
- `BDT` — Bangladeshi Taka
- `BHD` — Bahraini Dinar
- `BIF` — Burundian Franc
- `BMD` — Bermudian Dollar
- `BND` — Brunei Dollar
- `BOB` — Bolivian Boliviano
- `BRL` — Brazilian Real
- `BSD` — Bahamian Dollar
- `BWP` — Botswana Pula
- `BYN` — Belarusian Ruble
- `BZD` — Belize Dollar
- `CAD` — Canadian Dollar
- `CDF` — Congolese Franc
- `CHF` — Swiss Franc
- `CLP` — Chilean Peso
- `CNY` — Chinese Renminbi Yuan
- `COP` — Colombian Peso
- `CRC` — Costa Rican Colón
- `CVE` — Cape Verdean Escudo
- `CZK` — Czech Koruna
- `DJF` — Djiboutian Franc
- `DKK` — Danish Krone
- `DOP` — Dominican Peso
- `DZD` — Algerian Dinar
- `EGP` — Egyptian Pound
- `ETB` — Ethiopian Birr
- `EUR` — Euro
- `FJD` — Fijian Dollar
- `FKP` — Falkland Islands Pound
- `GBP` — British Pound
- `GEL` — Georgian Lari
- `GIP` — Gibraltar Pound
- `GMD` — Gambian Dalasi
- `GNF` — Guinean Franc
- `GTQ` — Guatemalan Quetzal
- `GYD` — Guyanese Dollar
- `HKD` — Hong Kong Dollar
- `HNL` — Honduran Lempira
- `HTG` — Haitian Gourde
- `HUF` — Hungarian Forint
- `IDR` — Indonesian Rupiah
- `ILS` — Israeli New Shekel
- `INR` — Indian Rupee
- `ISK` — Icelandic Króna
- `JMD` — Jamaican Dollar
- `JOD` — Jordanian Dinar
- `JPY` — Japanese Yen
- `KES` — Kenyan Shilling
- `KGS` — Kyrgyzstani Som
- `KHR` — Cambodian Riel
- `KMF` — Comorian Franc
- `KRW` — South Korean Won
- `KWD` — Kuwaiti Dinar
- `KYD` — Cayman Islands Dollar
- `KZT` — Kazakhstani Tenge
- `LAK` — Lao Kip
- `LBP` — Lebanese Pound
- `LKR` — Sri Lankan Rupee
- `LRD` — Liberian Dollar
- `LSL` — Lesotho Loti
- `MAD` — Moroccan Dirham
- `MDL` — Moldovan Leu
- `MGA` — Malagasy Ariary
- `MKD` — Macedonian Denar
- `MMK` — Myanmar Kyat
- `MNT` — Mongolian Tögrög
- `MOP` — Macanese Pataca
- `MUR` — Mauritian Rupee
- `MVR` — Maldivian Rufiyaa
- `MWK` — Malawian Kwacha
- `MXN` — Mexican Peso
- `MYR` — Malaysian Ringgit
- `MZN` — Mozambican Metical
- `NAD` — Namibian Dollar
- `NGN` — Nigerian Naira
- `NIO` — Nicaraguan Córdoba
- `NOK` — Norwegian Krone
- `NPR` — Nepalese Rupee
- `NZD` — New Zealand Dollar
- `OMR` — Omani Rial
- `PAB` — Panamanian Balboa
- `PEN` — Peruvian Sol
- `PGK` — Papua New Guinean Kina
- `PHP` — Philippine Peso
- `PKR` — Pakistani Rupee
- `PLN` — Polish Złoty
- `PYG` — Paraguayan Guaraní
- `QAR` — Qatari Riyal
- `RON` — Romanian Leu
- `RSD` — Serbian Dinar
- `RUB` — Russian Ruble
- `RWF` — Rwandan Franc
- `SAR` — Saudi Riyal
- `SBD` — Solomon Islands Dollar
- `SCR` — Seychellois Rupee
- `SEK` — Swedish Krona
- `SGD` — Singapore Dollar
- `SHP` — Saint Helena Pound
- `SLE` — Sierra Leonean Leone
- `SOS` — Somali Shilling
- `SRD` — Surinamese Dollar
- `STD` — São Tomé and Príncipe Dobra
- `SZL` — Swazi Lilangeni
- `THB` — Thai Baht
- `TJS` — Tajikistani Somoni
- `TND` — Tunisian Dinar
- `TOP` — Tongan Paʻanga
- `TRY` — Turkish Lira
- `TTD` — Trinidad and Tobago Dollar
- `TWD` — New Taiwan Dollar
- `TZS` — Tanzanian Shilling
- `UAH` — Ukrainian Hryvnia
- `UGX` — Ugandan Shilling
- `USD` — US Dollar
- `UYU` — Uruguayan Peso
- `UZS` — Uzbekistani Sum
- `VND` — Vietnamese Đồng
- `VUV` — Vanuatu Vatu
- `WST` — Samoan Tala
- `XAF` — Central African CFA Franc
- `XCD` — East Caribbean Dollar
- `XCG` — Caribbean Guilder
- `XOF` — West African CFA Franc
- `XPF` — CFP Franc
- `YER` — Yemeni Rial
- `ZAR` — South African Rand
- `ZMW` — Zambian Kwacha

Note: Stripe still uses the outdated `STD` code for the São Tomé and Príncipe dobra ([ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) renamed it to `STN` in 2018), so Larasell matches Stripe's code for compatibility.
