# Cancel a pending transaction

Cancelling a pending transaction endpoint allows you to block the payment flow for consumers that currently visiting the payment page and also block the payment page for new consumers - only for specific transaction.

{% hint style="info" %}
This API will not refund approved transactions, see [refund-a-transaction](https://docs.sensepass.com/sensepay/transaction-api/payment-flows/refund-a-transaction "mention")
{% endhint %}

### API Interface

## Cancelling a pending transaction object (Payment Request)

<mark style="color:green;">`POST`</mark> `https://api.sensepass.com/api/transactions/cancel/{transactionNumber}`

#### Path Parameters

| Name                                                | Type   | Description                  |
| --------------------------------------------------- | ------ | ---------------------------- |
| transactionNumber<mark style="color:red;">\*</mark> | String | Transaction number to cancel |

**Authentication Request Body fields**

[See here our Authentication page](https://docs.sensepass.com/sensepay/transaction-api/authentication)

{% tabs %}
{% tab title="201: OK OK" %}

```javascript
{
  "status": 200,
  "status_message": "Transaction Was Canceled"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Input" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Error" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="501: Not Implemented This transaction cannot be cancelled due to cosumers activity" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Cancelling a pending transaction object using Device ID

<mark style="color:green;">`POST`</mark> `https://api.sensepass.com/api/transactions/cancelByDeviceId/{deviceId}`

#### This API will cancel the last pending transaction of a given device

#### Path Parameters

| Name                                       | Type   | Description                  |
| ------------------------------------------ | ------ | ---------------------------- |
| deviceId<mark style="color:red;">\*</mark> | String | Device ID of the transaction |

**Authentication Request Body fields**

[See here our Authentication page](https://docs.sensepass.com/sensepay/transaction-api/authentication)

{% tabs %}
{% tab title="201: OK OK" %}

```javascript
{
  "status": 200,
  "status_message": "Transaction Was Canceled"
}
```

{% endtab %}
{% endtabs %}

###

### Flow Chart

[See our payment flow chart here](https://docs.sensepass.com/sensepay/transaction-api/flow-charts/payment-flow)

### Transaction Status Flow

[See our transaction status flow here](https://docs.sensepass.com/sensepay/transaction-api/flow-charts/transaction-status-flow)
