## Get payments for a merchant

### cURL

```bash
curl --request GET \
  --url https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments \
  --header 'X-Api-Key: <api-key>'
```

### Python

```python
import requests

url = "https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments"

headers = {"X-Api-Key": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {method: 'GET', headers: {'X-Api-Key': '<api-key>'}};

fetch('https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "X-Api-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments"

req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("X-Api-Key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Java (Unirest)

```java
HttpResponse<String> response = Unirest.get("https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments")
  .header("X-Api-Key", "<api-key>")
  .asString();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.pay.walletconnect.com/v1/merchants/{merchant_id}/payments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-Api-Key"] = '<api-key>'

response = http.request(request)
puts response.read_body
```

### Response Structure

#### 200

```json
{
  "data": [
    {
      "payment_id": "<string>",
      "merchant_id": "<string>",
      "reference_id": "<string>",
      "is_terminal": true,
      "wallet_name": "<string>",
      "token_symbol": "<string>",
      "token_decimals": 0,
      "token_logo": "<string>",
      "chain_logo": "<string>",
      "wallet_logo": "<string>",
      "chain_id": "<string>",
      "buyer_caip10": "<string>",
      "token_caip19": "<string>",
      "tx_hash": "<string>",
      "nonce": 1073741823,
      "token_amount": "<string>",
      "fiat_amount": -1,
      "fiat_currency": "<string>",
      "created_at": "<string>",
      "last_updated_at": "<string>",
      "settled_at": "<string>",
      "settlement_status": "<string>",
      "settlement_tx_hash": "<string>"
    }
  ],
  "stats": {
    "total_customers": 1073741823,
    "total_revenue": {
      "amount": 123,
      "currency": "<string>"
    },
    "total_transactions": 1073741823
  },
  "next_cursor": "<string>"
}
```

### Authorizations

- **X-Api-Key** (string, header, required) - Deprecated. Legacy service API key for path-based routes. `Api-Key` header is also accepted for backward compatibility.

### Path Parameters
- **merchant_id** (string, required)

### Query Parameters
- **start_ts** (string<date-time>, optional)
- **end_ts** (string<date-time>, optional)
- **asset** (string, optional)
- **network** (string, optional)
- **sort_by** (enum<string>, optional) - Options: `date`, `amount`
- **sort_dir** (enum<string>, optional) - Options: `asc`, `desc`
- **cursor** (string, optional)
- **limit** (integer, required) - Range: `1 <= x <= 200`
- **status** (enum<string>[], optional) - Options: `requires_action`, `processing`, `succeeded`, `failed`, `expired`

### Response
- **data** (object[], required)
- **stats** (object, required)
- **next_cursor** (string | null, optional)
