# Gateways::validatePaymentAmount()

> Makes sure a payment actually covers the order it is about to complete

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

```php
Gateways::validatePaymentAmount(int $amount, null|string $currency, Wagnerwagner\Merx\OrderPage $virtualOrderPage): void
```

## Parameters

| Name | Type | Default |
| --- | --- | --- |
| `$amount` | `int` | `–` |
| `$currency` | `null\|string` | `–` |
| `$virtualOrderPage` | `Wagnerwagner\Merx\OrderPage` | `–` |

## Return type

`void`

## Exceptions

| Type | Description |
| --- | --- |
| `Exception` | merx.amountMismatch when amount or currency do not match the cart |

## Description

A Stripe PaymentIntent is created when the client secret is fetched and
keeps the cart total of that moment. The cart stays editable until the
checkout, so both can drift apart: the order would list goods the payment
does not pay for. Correcting the amount is the frontend’s job — it has to
fetch a new client secret when the cart changes — so this only refuses.

## Parent class

`Wagnerwagner\Merx\Gateways`
