Cancel Payment Request

Overview

You can cancel an active payment request to prevent any further payments from being accepted. Once cancelled, the payment request will no longer be accessible to customers and cannot be reactivated.

Endpoint

POST /api/payment-requests/{public_id}/cancel

Parameters

Parameter
Type
Location
Description
Example

public_id

string

path

The payment request's public UUID

550e8400-e29b-41d4-a716-446655440000

Cancellation Rules

  • Only active payment requests can be cancelled

  • Completed, expired, or already cancelled payment requests cannot be cancelled

  • Cancelled payment requests are immediately removed from public access

  • Any partial payments already received remain with the merchant

Example Request

curl -X POST \
  -H "X-API-Key: unter_YOUR_API_KEY_HERE" \
  https://api.unter.tech/api/payment-requests/550e8400-e29b-41d4-a716-446655440000/cancel

Success Response (200 OK)

{
  "message": "Payment request cancelled successfully"
}

Error Responses

Payment Request Not Found or Not Cancellable (404)

This error occurs when:

  • The payment request doesn't exist

  • The payment request doesn't belong to your merchant account

  • The payment request is not in active status (already completed, expired, or cancelled)

{
  "message": "No query results for model [App\\Models\\PaymentRequest]"
}

Effects on Customer Experience

  • Payment URL becomes unavailable: Customers visiting the payment URL will see a "not found" error

  • No refunds issued: Cancelling doesn't automatically refund existing payments

Best Practices

  1. Check status before cancelling

    • Verify the payment request is still active

    • Handle cases where it's already completed or expired

  2. Consider partial payments

    • Check if any payments have been received

    • Decide how to handle partial payments (refund, keep, etc.)

  3. Use webhooks for automation

    • Set up webhook handlers for payment status changes

    • Don't rely solely on manual cancellation

Last updated