# Price

> How a price is rendered by the API: formatted and raw, gross and net, with its tax.

- Source: `api/models/Price.php` <https://github.com/wagnerwagner/merx/blob/2.0.0-alpha.11/api/models/Price.php>

## Fields

Available in the Price model, can be fetched with the `select` parameter.

| Name | Return type |
| --- | --- |
| currency | `null\|string` |
| price | `string` |
| priceRaw | `float` |
| priceNet | `string` |
| priceNetRaw | `null\|float` |
| priceIncludingTax | `null\|bool` |
| tax | `null\|Wagnerwagner\Merx\Tax` |

## Views

Available in the Price model, can be fetched with the `view` parameter.

| Name | Fields |
| --- | --- |
| compact | `price` |
| formatted | `price, priceNet, tax` |
| raw | `currency, priceRaw, priceNetRaw, tax` |
| default | `price, priceRaw, priceNet, priceNetRaw, priceIncludingTax, tax` |

## Type

`Wagnerwagner\Merx\Price`

## Examples

The Price model of an example cart, in each of its views.

```json title="View: default"
{
    "price": "€89.90",
    "priceIncludingTax": true,
    "priceNet": "€75.55",
    "priceNetRaw": 75.5499999999999971578290569595992565155029296875,
    "priceRaw": 89.900000000000005684341886080801486968994140625,
    "tax": {
        "price": "€14.35",
        "priceRaw": 14.3499999999999996447286321199499070644378662109375,
        "rate": "19%",
        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
    }
}
```

```json title="View: compact"
{
    "price": "€89.90"
}
```

```json title="View: formatted"
{
    "price": "€89.90",
    "priceNet": "€75.55",
    "tax": {
        "price": "€14.35",
        "priceRaw": 14.3499999999999996447286321199499070644378662109375,
        "rate": "19%",
        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
    }
}
```

```json title="View: raw"
{
    "currency": "EUR",
    "priceNetRaw": 75.5499999999999971578290569595992565155029296875,
    "priceRaw": 89.900000000000005684341886080801486968994140625,
    "tax": {
        "price": "€14.35",
        "priceRaw": 14.3499999999999996447286321199499070644378662109375,
        "rate": "19%",
        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
    }
}
```
