> For the complete documentation index, see [llms.txt](https://developers.mtpelerin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.mtpelerin.com/integration-guides/events.md).

# Events

## Transaction success event

When a user has reached the end of a buy/swap/sell process, you can listen for the following postMessage event:

```
{ type: 'paymentSubmitted', data: { paymentType, paymentId } }

paymentType: bankTransfer|card|crypto
```

This can be used to trigger a navigation to the desired post-transaction screen or page.

Documentation: <https://developer.mozilla.org/en-US/docs/Web/API/Window/message_event>

## Order creation event

This event is emitted when a new order is created in our system. It includes all the relevant information needed to display or process the order on your side.

```
{ "type": "orderCreated", "data": Order }
```

Depending on the order type (“buy”, “sell”, or “swap”), the `Order` payload may include different fields. Below are examples for each case.

### Buy order example

```
{
  "id": "123456789",
  "expirationDate": "2025-06-30T12:38:32.887Z",
  "cryptoAddress": "bc1ql…..",
  "currencyIn": "CHF",
  "currencyOut": "BTC",
  "marketRate": "85854.9",
  "network": "bitcoin_mainnet",
  "paymentMode": "bank",
  "type": "buy",
  "valueIn": "100",
  "valueOut": "0.001165"
}
```

### Sell order (Lightning) example

```
{
  "id": "123456789",
  "expirationDate": "2025-06-30T12:38:32.887Z",
  "offRampAddress": "mtpelerin@ln.mtpelerin.com",
  "lnInvoice": "lnbc4…",
  "cryptoAddress": "",
  "currencyIn": "sat",
  "currencyOut": "CHF",
  "marketRate": "0.00085931",
  "network": "lightning_mainnet",
  "paymentMode": "bank",
  "type": "sell",
  "valueIn": "44444",
  "valueOut": "38.19"
}
```

### Swap order example

```
{
  "id": "123456789",
  "expirationDate": "2025-06-30T12:38:32.887Z",
  "offRampAddress": "3LgdKdB9x42m4ujae78NcwUXjYW3z45KrX",
  "cryptoAddress": "",
  "cryptoAddressIn": "bc1qlu…..",
  "cryptoAddressOut": "0xee21c7…….",
  "currencyIn": "BTC",
  "currencyOut": "USDT",
  "marketRate": "107891.95",
  "network": "mainnet",
  "paymentMode": "bank",
  "type": "swap",
  "valueIn": "0.001",
  "valueOut": "106.892119",
  "networkIn": "bitcoin_mainnet",
  "networkOut": "mainnet"
}
```
