# Cancell or Refund a Payment

This guide explains how to process cancellations and refunds for previously authorized payments using the Getnet Web Checkout. 

This document applies to the following countries:
Argentina |
---|

## Cancellation
To set a cancellation, the Getnet Web Checkout API expects to receive the `payment_id` (extracted from the webhook notification) in the middle path parameter and the following property in the request body.

| Field | Type | Description | Example |
|---|---|---|---|
|`payment_id`| String | Payment ID to be cancelled or refunded | `44c1206c-fcfc-11ea-adc1-0242ac120002`

Request to: 
```json
POST {{host_getnet_api}}/digital-checkout/v1/payments/{payment_id}/cancellation
```

To check if the request was valid, you will receive a **201 HTTP response** which indicates a successful cancellation:

**Response**
Example of successful cancellation response:

```json
{
  "payment_id": "06f256c8-1bbf-42bf-93b4-ce2041bfb87e",
  "generated_by": "77d2306c-fcfc-11ea-adc1-0242ac120003",
  "status": "Cancelled",
  "transaction_datetime": "1997-07-16T19:20:30.45+01:00",
  "authorization_code": "840358"
}
```

## Refund

To set a refund, the Getnet Web Checkout API expects to receive the `payment_id` (extracted from the webhook notification) in the middle path parameter. 
And the in the `amount` property should have the value of the refund. If no value is provided, the transaction will be refunded for the full amount.

| Field | Type | Description | Example |
|---|---|---|---|
|`payment_id`| String | Payment ID to be cancelled or refunded | `44c1206c-fcfc-11ea-adc1-0242ac120002` |
|`amount` | Integer | Refund amount in integer format, where the last 2 digits represent the cents | `100` |

**Request**
The following code block shows an example of a refund request:

```json
curl 
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --data '{
  "amount": 100
}'
```

To check if the request was valid, you will receive a **201 HTTP response** which indicates a successful refund:

**Response**
Example of successful refund response:

```json
{
  "payment_id": "06f256c8-1bbf-42bf-93b4-ce2041bfb87e",
  "authorization_code": "840358",
  "status": "Refunded",
  "transaction_datetime": "1997-07-16T19:20:30.45+01:00",
  "generated_by": "77d2306c-fcfc-11ea-adc1-0242ac120003"
}
```

For more details, see:

[API reference - cancellation](https://docs.globalgetnet.com/en/products/online-payments/web-checkout/swagger#tag/payment/POST/payments/{payment_id}/cancellation)
[API reference - refund](https://docs.globalgetnet.com/en/products/online-payments/web-checkout/swagger#tag/payment/POST/payments/{payment_id}/refund)