---
title: "Cancel a debit the gateway has not collected yet"
description: "Asks the gateway to stop a pending debit: GoCardless before it submits the payment to the banks, Mollie while the payment is cancelable, Cashfree for a subscription payment, Stripe for a bank debit…"
canonical_url: "https://twominutebilling.com/help/developers/api-reference/invoices/cancel-a-debit-the-gateway-has-not-collected-yet"
---
# Cancel a debit the gateway has not collected yet

> Asks the gateway to stop a pending debit: GoCardless before it submits the payment to the banks, Mollie while the payment is cancelable, Cashfree for a subscription payment, Stripe for a bank debit…

<api-operation method="POST" path="/v1/businesses/{biz}/payments/{pay}/cancel_pending_debit">
<template v-slot:docs="">

Asks the gateway to stop a pending debit: GoCardless before it submits the payment to the banks, Mollie while the payment is cancelable, Cashfree for a subscription payment, Stripe for a bank debit that is processing, Authorize.net for an eCheck that has not settled. When the gateway cancels it, the payment becomes `failed` with `failure_code: debit_cancelled`, no money moves, and the invoice stops automatic collection (`dunning_status: stopped`). When the gateway had already settled the debit, that outcome is booked and returned. A refusal books nothing. The transaction's `pending_debit_cancel` says whether the action is offered.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Business id (biz_…)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pay
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Payment id (pay_…)
    </td>
  </tr>
</tbody>
</table>

## Headers

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        Idempotency-Key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Safely retry writes — repeats return the original response. If a write FAILED after it had already taken effect, that failure is what repeats: the key is spent, and a new attempt needs a new key.
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The cancel pending debit's id.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The cancel pending debit's status.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        outcome
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        cancelled
      </code>
      
      : the gateway stopped it. <code>
        settled
      </code>
      
       / <code>
        failed
      </code>
      
      : the gateway had already decided, and that is now booked. One of <code>
        cancelled
      </code>
      
      , <code>
        settled
      </code>
      
      , <code>
        failed
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The amount in minor units (integer), e.g. 2900 = $29.00.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The cancel pending debit's currency (ISO-4217 code).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        method_type
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The payment method type of the payment. Null when not known.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failure_code
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The failure code.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      What the gateway did with the debit.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        404
      </code>
    </td>
    
    <td>
      No such payment
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      The payment is not in progress, or the gateway did not cancel it (<code>
        code: debit_not_cancelable
      </code>
      
      )
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl -X POST "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/payments/pay_XXXXXXXXXXXX01/cancel_pending_debit" \
  -H "Authorization: Bearer $TMBILLING_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

</template>

<template v-slot:response="">
<code-group>

```json [200 OK]
{
  "object": "payment",
  "id": "pay_XXXXXXXXXXXX01",
  "status": "failed",
  "outcome": "cancelled",
  "amount_minor": 2900,
  "currency": "EUR",
  "method_type": "sepa_debit",
  "failure_code": "debit_cancelled"
}
```

```json [404 Not Found]
{
  "error": {
    "type": "invalid_request_error",
    "message": "No such payment"
  }
}
```

```json [409 Conflict]
{
  "error": {
    "type": "conflict_error",
    "message": "The payment is not in progress, or the gateway did not cancel it (code: debit_not_cancelable)"
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
