> ## Documentation Index
> Fetch the complete documentation index at: https://doc-test-my.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a UPI Payment Link

> Cancel a UPI Payment Link using this endpoint.

Use this endpoint to cancel a UPI Payment Link.

<RequestExample>
  ```bash Curl theme={null}
  curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
  -X POST https://api.razorpay.com/v1/payment_links/plink_ExjpAUN3gVHrPJ/cancel \
  -H 'Content-type: application/json' \
  ```

  ```php PHP theme={null}
  $api = new Api($key_id, $secret);

  $api->paymentLink->fetch($paymentLinkId)->cancel();
  ```

  ```javascript Node.js theme={null}
  var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })

  instance.paymentLink.cancel(paymentLinkId)
  ```

  ```python Python theme={null}
  import razorpay
  client = razorpay.Client(auth=("YOUR_ID", "YOUR_SECRET"))

  client.payment_link.cancel(paymentLinkId)
  ```

  ```go Go theme={null}
  import ( razorpay "github.com/razorpay/razorpay-go" )
  client := razorpay.NewClient("YOUR_KEY_ID", "YOUR_SECRET")

  body, err := client.PaymentLink.Cancel("<paymentLinkId>", nil, nil)
  ```

  ```ruby Ruby theme={null}
  require "razorpay"
  Razorpay.setup('key_id', 'key_secret')

  paymentLinkId = "plink_ExjpAUN3gVHrPJ"

  Razorpay::PaymentLink.cancel(paymentLinkId)
  ```

  ```java Java theme={null}
  import org.json.JSONObject;
  import com.razorpay.Payment;
  import com.razorpay.RazorpayClient;
  import com.razorpay.RazorpayException;

  RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");
  String PaymentLinkId = "plink_FMbhpT6nqDjDei";

  PaymentLink paymentlink = razorpay.paymentLink.cancel(paymentLinkId);
  ```

  ```csharp .NET theme={null}
  RazorpayClient client = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  string paymentLinkId = "plink_Z6t7VFTb9xHeOs";

  PaymentLink paymentlink = client.PaymentLink.Fetch(paymentLinkId).Cancel();
  ```

  ```bash CLI theme={null}
  razorpay payment-links cancel plink_ABC123
  ```

  ```bash Curl theme={null}
  curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
  -X POST https://api.razorpay.com/v1/payment_links/plink_ExjpAUN3gVHrPJ/cancel \
  -H 'Content-type: application/json' \
  ```

  ```php PHP theme={null}
  $api = new Api($key_id, $secret);

  $api->paymentLink->fetch($paymentLinkId)->cancel();
  ```

  ```java Java theme={null}
  import org.json.JSONObject;
  import com.razorpay.Payment;
  import com.razorpay.RazorpayClient;
  import com.razorpay.RazorpayException;

  RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");
  String PaymentLinkId = "plink_FMbhpT6nqDjDei";

  PaymentLink paymentlink = razorpay.paymentLink.cancel(paymentLinkId);
  ```

  ```csharp .NET theme={null}
  RazorpayClient client = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  string paymentLinkId = "plink_Z6t7VFTb9xHeOs";

  PaymentLink paymentlink = client.PaymentLink.Fetch(paymentLinkId).Cancel();
  ```

  ```bash CLI theme={null}
  razorpay payment-links cancel plink_ABC123
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "accept_partial": false,
    "amount": 100,
    "amount_paid": 0,
    "cancelled_at": 1602524667,
    "created_at": 1602524646,
    "currency": "MYR",
    "customer": {
      "contact": "<phone>",
      "email": "<email>"
    },
    "description": "Payment for Acme Inc",
    "expire_by": 0,
    "expired_at": 0,
    "first_min_partial_amount": 0,
    "id": "plink_Fo4oI0cXjpQIz3",
    "notes": null,
    "notify": {
      "email": true,
      "sms": true
    },
    "order_id": "order_Fo4oOGcvR4srav",
    "payments": [],
    "reference_id": "",
    "reminder_enable": false,
    "reminders": [],
    "short_url": "https://rzp.io/i/foDnrXbBD",
    "status": "cancelled",
    "updated_at": 1602524667,
    "upi_link": true,
    "user_id": "FmjfFPCOUOAcSH"
  }
  ```

  ```json Failure theme={null}
  {
    "error": {
      "code": "BAD_REQUEST_ERROR",
      "description": "The api key provided is invalid",
      "source": "NA",
      "step": "NA",
      "reason": "NA",
      "metadata": {}
    }
  }
  ```

  ```json Success theme={null}
  {
    "amount": 100,
    "amount_paid": 0,
    "cancelled_at": 1602524667,
    "created_at": 1602524646,
    "currency": "MYR",
    "customer": {
      "contact": "<phone>",
      "email": "<email>"
    },
    "description": "Payment for Acme Inc",
    "expire_by": 0,
    "expired_at": 0,
    "id": "plink_Fo4oI0cXjpQIz3",
    "notes": null,
    "notify": {
      "email": true,
      "sms": true
    },
    "order_id": "order_Fo4oOGcvR4srav",
    "payments": [],
    "reference_id": "",
    "reminder_enable": false,
    "reminders": [],
    "short_url": "https://rzp.io/i/foDnrXbBD",
    "status": "cancelled",
    "updated_at": 1602524667,
    "upi_link": true,
    "user_id": "FmjfFPCOUOAcSH"
  }
  ```

  ```json Failure theme={null}
  {
    "error": {
      "code": "BAD_REQUEST_ERROR",
      "description": "The api key provided is invalid",
      "source": "NA",
      "step": "NA",
      "reason": "NA",
      "metadata": {}
    }
  }
  ```
</ResponseExample>

## Path Parameters

<ParamField path="id" type="string" required>
  Unique identifier of the Payment Link.
</ParamField>

## Response Parameters

<ResponseField name="accept_partial" type="boolean">
  Indicates whether customers can make [partial payments](/docs/payments/payment-links/partial-payments) using the Payment Link. Possible values:

  * `true`: Customer can make partial payments.
  * `false` (default): Customer cannot make partial payments.
</ResponseField>

<ResponseField name="amount" type="integer">
  Amount to be paid using the Payment Link. Must be in the smallest unit of the currency. For example, if you want to receive a payment of , you must enter the value `30000`. In the case of three decimal currencies, such as KWD, BHD and OMR, to refund a payment of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, to refund a payment of 295, pass the value as 295.

  <Warning>
    **Watch Out!**

    As per payment guidelines, you should pass the last decimal number as 0 for three decimal currency payments. For example, if you want to refund a customer 99.991 KD for a transaction, you should pass the value for the amount parameter as `99990` and not `99991`.
  </Warning>
</ResponseField>

<ResponseField name="amount_paid" type="integer">
  Amount paid by the customer.
</ResponseField>

<ResponseField name="callback_url" type="string">
  If specified, adds a redirect URL to the Payment Link. Once the customer completes the payment, they are redirected to the specified URL.
</ResponseField>

<ResponseField name="callback_method" type="string">
  If `callback_url` parameter is passed, `callback_method` must be passed with the value `get`.
</ResponseField>

<ResponseField name="cancelled_at" type="integer">
  Timestamp, in Unix, at which the Payment Link was cancelled by you.
</ResponseField>

<ResponseField name="created_at" type="integer">
  Timestamp, in Unix, indicating when the Payment Link was created.
</ResponseField>

<ResponseField name="currency" type="string">
  Defaults to INR. We accept payments in [international currencies.](/docs/payments/international-payments#supported-currencies)

  <Info>
    **Handy Tips**

    Razorpay has added support for zero decimal currencies, such as JPY, and three decimal currencies, such as KWD, BHD, and OMR, allowing businesses to accept international payments in these currencies. Know more about [Currency Conversion](/docs/payments/international-payments/currency-conversion) (May 2024).
  </Info>
</ResponseField>

<ResponseField name="customer" type="json object">
  Customer details.
</ResponseField>

<ResponseField name="name" type="string">
  The customer's name.
</ResponseField>

<ResponseField name="email" type="string">
  The customer's email address.
</ResponseField>

<ResponseField name="contact" type="string">
  The customer's phone number.
</ResponseField>

<ResponseField name="description" type="string">
  A brief description of the Payment Link.
</ResponseField>

<ResponseField name="expire_by" type="integer">
  Timestamp, in Unix, when the Payment Link will expire. By default, a Payment Link will be valid for six months from the date of creation. Please note that the expire by date cannot exceed more than six months from the date of creation.
</ResponseField>

<ResponseField name="expired_at" type="integer">
  Timestamp, in Unix, at which the Payment Link expired.
</ResponseField>

<ResponseField name="first_min_partial_amount" type="integer">
  Minimum amount that must be paid by the customer as the first partial payment. For example, if an amount of  is to be received from the customer in two installments of #1 - , #2 - , then you can set this value as `500000`.
</ResponseField>

<ResponseField name="id" type="string">
  Unique identifier of the Payment Link. For example, `plink_ERgihyaAAC0VNW`.
</ResponseField>

<ResponseField name="upi_link" type="boolean">
  Indicates whether the Payment Link is a UPI Payment Link.

  * `true`: A UPI Payment Link has been created.
  * `false`: It is a Standard Payment Link.
</ResponseField>

<ResponseField name="notes" type="object">
  Set of key-value pairs that you can use to store additional information. You (Businesses) can enter a maximum of 15 key-value pairs, with each value having a maximum limit of 256 characters.
</ResponseField>

<ResponseField name="notify" type="array">
  Defines who handles Payment Link notification.
</ResponseField>

<ResponseField name="sms" type="boolean">
  Defines who handles the SMS notification.

  * `true`: Razorpay handles the notification.
  * `false`: Businesses handle the notification.
</ResponseField>

<ResponseField name="email" type="boolean">
  Defines who handles the email notification.

  * `true`: Razorpay handles the notification.
  * `false`: Businesses handle the notification.
</ResponseField>

<ResponseField name="payments" type="array">
  Payment details such as amount, payment id, Payment Link id and more are stored in this array. It is populated only after a payment is successfully captured by the customer. Only captured payments will be shown here. Until then, the value is `null`.
</ResponseField>

<ResponseField name="amount" type="integer">
  The amount paid by the customer using the Payment Link.
</ResponseField>

<ResponseField name="created_at" type="integer">
  Timestamp, in Unix, indicating when the payment was made.
</ResponseField>

<ResponseField name="method" type="string">
  The payment method used to make the payment. Possible values:

  * `netbanking`
  * `card`
  * `wallet`
  * `upi`
  * `emi`
  * `bank_transfer`
</ResponseField>

<ResponseField name="payment_id" type="string">
  Unique identifier of the payment made against the Payment Link.
</ResponseField>

<ResponseField name="plink_id" type="string">
  Unique identifier of the Payment Link. For example, `plink_ERgihyaAAC0VNW`.
</ResponseField>

<ResponseField name="status" type="string">
  The payment state. Possible value is `captured`.
</ResponseField>

<ResponseField name="updated_at" type="integer">
  Timestamp, in Unix, indicating when the payment was updated.
</ResponseField>

<ResponseField name="reference_id" type="string">
  Reference number tagged to a Payment Link. Must be a unique number for each Payment Link. The maximum character limit supported is 40.
</ResponseField>

<ResponseField name="short_url" type="string">
  The unique short URL generated for the Payment Link.
</ResponseField>

<ResponseField name="status" type="string">
  Displays the current state of the Payment Link. Possible values:

  * `created`
  * `partially_paid`
  * `expired`
  * `cancelled`
  * `paid`
</ResponseField>

<ResponseField name="updated_at" type="integer">
  Timestamp, in Unix, indicating when the Payment Link was updated.
</ResponseField>

<ResponseField name="reminder_enable" type="boolean">
  Used to send [reminders](/docs/payments/payment-links/reminders) for the Payment Link. Possible values:

  * `true`: To send reminders.
  * `false`: To disable reminders.
</ResponseField>

<ResponseField name="user_id" type="string">
  A unique identifier for the user role through which the Payment Link was created. For example, `HD1JAKCCPGDfRx`.
</ResponseField>

## Errors

<AccordionGroup>
  <Accordion title="cannot cancel or expire an already paid/partially paid link">
    **Code:** `400`

    When you try to cancel/expire a Payment Link which is already paid or partially paid.

    **Solution:** Ensure that the Payment Link is in the `created` state to cancel the Payment Link.
  </Accordion>

  <Accordion title="cannot cancel or expire an expired link">
    **Code:** `400`

    When you try to cancel/expire a payment link which has expired or cancelled.

    **Solution:** Ensure the Payment Link you want to cancel is in the `created` state.
  </Accordion>

  <Accordion title="The id provided does not exist">
    **Code:** `400`

    The Payment Link does not belong to the requestor business, or it doesn't exist.

    **Solution:** Ensure that the Payment Link is valid and belongs to the requestor business.
  </Accordion>

  <Accordion title="The api {key/secret} provided is invalid">
    **Code:** `4xx`

    There is a mismatch between the API credentials passed in the API call and the API credentials generated on the Dashboard.

    **Solution:** Ensure that the API Keys are active and entered correctly. Also, make sure there are no white-spaces before or after the keys.
  </Accordion>

  <Accordion title="an update is already in progress.">
    **Code:** `400`

    Another update or cancel operation is currently in progress for the same Payment Link. Razorpay holds a short-lived lock against the link id to prevent concurrent state changes.

    **Solution:** Wait a few seconds and retry. If the issue persists, fetch the link to confirm its current state before retrying.
  </Accordion>
</AccordionGroup>
