# IPaymentProcessor\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/paymentProcessor/IPaymentProcessor_v1.sol)

### Functions

#### processPayments

Processes all payments from an {IERC20PaymentClientBase\_v1} instance. Please note: this function does not support callbacks on transfer of tokens.

*It's up to the the implementation to keep up with what has been paid out or not.*

*Currently callback functions on token transfers are not supported and thus not checked. This could lead to a failed transaction which could influence the batched processing of payments.*

```solidity
function processPayments(IERC20PaymentClientBase_v1 client) external;
```

**Parameters**

| Name     | Type                         | Description                                                            |
| -------- | ---------------------------- | ---------------------------------------------------------------------- |
| `client` | `IERC20PaymentClientBase_v1` | The {IERC20PaymentClientBase\_v1} instance to process its to payments. |

#### cancelRunningPayments

Cancels all unfinished payments from an {IERC20PaymentClientBase\_v1} instance.

*It's up to the the implementation to keep up with what has been paid out or not.*

```solidity
function cancelRunningPayments(IERC20PaymentClientBase_v1 client) external;
```

**Parameters**

| Name     | Type                         | Description                                                            |
| -------- | ---------------------------- | ---------------------------------------------------------------------- |
| `client` | `IERC20PaymentClientBase_v1` | The {IERC20PaymentClientBase\_v1} instance to process its to payments. |

#### unclaimable

Getter for the amount of tokens that could not be claimed.

```solidity
function unclaimable(address client, address token, address paymentReceiver)
    external
    view
    returns (uint amount);
```

**Parameters**

| Name              | Type      | Description                    |
| ----------------- | --------- | ------------------------------ |
| `client`          | `address` | address of the payment client. |
| `token`           | `address` | address of the payment token.  |
| `paymentReceiver` | `address` | PaymentReceiver's address.     |

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `amount` | `uint256` | Amount of tokens that could not be claimed. |

#### claimPreviouslyUnclaimable

claim every unclaimable amount that the paymentClient owes to the \_msgSender and send it to a specified receiver.

*This function should be callable if the \_msgSender has unclaimedAmounts.*

```solidity
function claimPreviouslyUnclaimable(
    address client,
    address token,
    address receiver
) external;
```

**Parameters**

| Name       | Type      | Description                                                                                  |
| ---------- | --------- | -------------------------------------------------------------------------------------------- |
| `client`   | `address` | The IERC20PaymentClientBase\_v1 instance address that processes all claims from \_msgSender. |
| `token`    | `address` | address of the payment token.                                                                |
| `receiver` | `address` | The address that will receive the previously unclaimable amount.                             |

#### validPaymentOrder

Function that checks if the given PaymentOrder was valid.

```solidity
function validPaymentOrder(IERC20PaymentClientBase_v1.PaymentOrder memory order)
    external
    returns (bool);
```

**Parameters**

| Name    | Type                                      | Description                                                     |
| ------- | ----------------------------------------- | --------------------------------------------------------------- |
| `order` | `IERC20PaymentClientBase_v1.PaymentOrder` | The IERC20PaymentClientBase\_v1 Order that needs to be checked. |

**Returns**

| Name     | Type   | Description                               |
| -------- | ------ | ----------------------------------------- |
| `<none>` | `bool` | valid Bool if the Payment Order is valid. |

### Events

#### PaymentOrderProcessed

Emitted when a payment gets processed for execution.

```solidity
event PaymentOrderProcessed(
    address indexed paymentClient,
    address indexed recipient,
    address indexed paymentToken,
    uint amount,
    uint originChainId,
    uint targetChainId,
    bytes32 flags,
    bytes32[] data
);
```

**Parameters**

| Name            | Type        | Description                                                    |
| --------------- | ----------- | -------------------------------------------------------------- |
| `paymentClient` | `address`   | The payment client that originated the order.                  |
| `recipient`     | `address`   | The address that will receive the payment.                     |
| `paymentToken`  | `address`   | The address of the token that will be used for the payment.    |
| `amount`        | `uint256`   | The amount of tokens the payment consists of.                  |
| `originChainId` | `uint256`   | The id of the origin chain.                                    |
| `targetChainId` | `uint256`   | The id of the target chain.                                    |
| `flags`         | `bytes32`   | Flags that indicate additional data used by the payment order. |
| `data`          | `bytes32[]` | Array of additional data regarding the payment order.          |

#### TokensReleased

Emitted when an amount of ERC20 tokens gets sent out of the contract.

```solidity
event TokensReleased(
    address indexed recipient, address indexed token, uint amount
);
```

**Parameters**

| Name        | Type      | Description                                                  |
| ----------- | --------- | ------------------------------------------------------------ |
| `recipient` | `address` | The address that will receive the payment.                   |
| `token`     | `address` | The token address in which the payment should have happened. |
| `amount`    | `uint256` | The amount of tokens the payment consists of.                |

#### UnclaimableAmountAdded

Emitted when a payment was unclaimable due to a token error.

```solidity
event UnclaimableAmountAdded(
    address indexed paymentClient,
    address indexed token,
    address indexed recipient,
    uint amount
);
```

**Parameters**

| Name            | Type      | Description                                        |
| --------------- | --------- | -------------------------------------------------- |
| `paymentClient` | `address` | The payment client that originated the order.      |
| `token`         | `address` |                                                    |
| `recipient`     | `address` | The address that should have received the payment. |
| `amount`        | `uint256` | The amount of tokens that were unclaimable.        |

### Errors

#### Module\_\_PaymentProcessor\_\_OnlyCallableByModule

invalid caller.

```solidity
error Module__PaymentProcessor__OnlyCallableByModule();
```

#### Module\_\_PaymentProcessor\_\_CannotCallOnOtherClientsOrders

a client can only execute on its own orders.

```solidity
error Module__PaymentProcessor__CannotCallOnOtherClientsOrders();
```

#### Module\_\_PaymentProcessor\_\_NothingToClaim

the paymentReceiver is not owed any money by the paymentClient.

```solidity
error Module__PaymentProcessor__NothingToClaim(
    address paymentClient, address paymentReceiver
);
```
