## Main Content

### cURL Example

```bash
curl --request POST \
  --url https://api.pay.walletconnect.com/v1/gateway/payment/{id}/cancel \
  --header 'Api-Key: <api-key>'
```

### Python Example

```python
import requests

url = "https://api.pay.walletconnect.com/v1/gateway/payment/{id}/cancel"

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

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

print(response.text)
```

### JavaScript (fetch) Example

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

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

### PHP Example

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.pay.walletconnect.com/v1/gateway/payment/{id}/cancel",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "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 Example

```go
package main

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

func main() {

url := "https://api.pay.walletconnect.com/v1/gateway/payment/{id}/cancel"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("Api-Key", "<api-key>")

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

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

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

### Response Structure

#### Success Response (200)
```json
{
  "cancelledAt": "2025-01-14T10:30:00Z",
  "cancelledReason": "cancelled_by_user",
  "paymentId": "pay_c4a2ecc101KQFN7X7RZACHTYV7JX5C4QET",
  "status": "cancelled"
}
```

#### Error Responses

```json
{
  "message": "<string>"
}
```

### Authorizations

- **Api-Key** : Required header parameter.

### Headers

- **Api-Key**: string | null
- **App-Id**: string | null
- **Client-Id**: string | null
- **WCP-Version**: string | null
- **Sdk-Name**: string | null
- **Sdk-Version**: string | null
- **Sdk-Platform**: string | null

### Path Parameters

- **id**: string (required) - Payment ID

### Additional Response Codes

- **400**: Bad request
- **401**: Unauthorized
- **404**: Not found
- **500**: Server error

### Payment Status Enum
- **requires_action**
- **processing**
- **succeeded**
- **failed**
- **expired**
- **cancelled**
