# Cancel payment request

After [Setup](./getting-started#3-initialize-and-set-up-the-sdk), and given that you have an in progress payment, you can try to cancel it.

If you're using the default Teya UI for "in progress" payments, the user can also use that UI to cancel the payment.

This cancellation is a best effort attempt - the card machine may choose to ignore it if the card was already presented.

If you need to trigger this cancellation attempt programmatically, and following the example on [Connecting to the SDK](./getting-started#2-connect-to-the-sdk-process), you can add a method on C# like this:

```csharp
public async Task<JsonElement> CancelPayment(string id)
{
    var parameters = new
    {
        transactionId = id, // id sent from the ePOS app on the "makePayment" request
    };
    return await SendRequestAsync("cancelPayment", parameters);
}
```

The SDK app will respond to this request with a JSON object in the "result" field of the json-rpc message like this:

```json
{
  "type": "cancelPayment->onResult",
  "result": "CANCELLING_PAYMENT"
}
```

The expected results are:

```json
PAYMENT_NOT_YET_CREATED
CANCELLING_PAYMENT
PAYMENT_ALREADY_FINISHED
NETWORK_ERROR
UNEXPECTED_SERVER_COMMUNICATION_ERROR
UNKNOWN_TRANSACTION_ID
```

`"CANCELLING_PAYMENT"` here is the success case, but it does not mean that the payment will be cancelled, just that the PosLink system got the request to try to cancel. 
