# $merx->initializeOrder()

> Creates virtual OrderPage and validates it. Runs the payment gateway’s `initializePayment` function. Saves virtual OrderPage in the customer’s session.

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

```php
$merx->initializeOrder(array $data): string
```

## Parameters

| Name | Type | Default |
| --- | --- | --- |
| `$data` | `array` | `–` |

## Return type

`string`

The return URL, or the `redirect` that the gateway’s `initializePayment` set on the virtual order page.

## Exceptions

| Type | Description |
| --- | --- |
| `Exception` | error.merx.cart.stock or error.merx.cart.soldOut when the cart holds more of a product than its stock |

## Parent class

`Wagnerwagner\Merx\Merx`
