# $merx->createOrder()

> Stores order page to file system

- Source: `src/Merx.php#L121` <https://github.com/wagnerwagner/merx/blob/2.0.0-alpha.11/src/Merx.php#L121>

```php
$merx->createOrder(array $data = []): Wagnerwagner\Merx\OrderPage
```

## Parameters

| Name | Type | Default |
| --- | --- | --- |
| `$data` | `array` | `[]` |

## Return type

`Wagnerwagner\Merx\OrderPage`

## Exceptions

| Type | Description |
| --- | --- |
| `Exception` | error.merx.cart.stock or error.merx.cart.soldOut when the stock ran out before the payment was completed |

## Description

Checks the stock again, calls `completePayment` of the payment gateway,
lowers the stock of the ordered products while
`wagnerwagner.merx.reduceStock` is true, and deletes the cart.

## Parent class

`Wagnerwagner\Merx\Merx`
