Cancel invoice

Cancels an existing invoice for a merchant. Once canceled, the invoice cannot be paid or processed further. The request should include the invoice token number

PUT
/api/v1/invoice/{invoice_token}
AuthorizationBearer <token>

Pass access token obtained from login endpoint

In: header

Path Parameters

invoice_tokenstring

Pass the invoice token number

Header Parameters

accessCodestring

Pass the merchant access code issued by Hesabe

Acceptstring

application/json

Content-Typestring

application/json

datastring

Convert payload JSON object to encrypted string and send it to the server

Step 1: Create JSON Object

{
  "merchantCode": "842217", // Sandbox merchant code
  "statusId": "3" // "3" for cancelling the invoice
}

Step 2: Convert JSON Object into Encrypted string and post to Hesabe

{
  "data": "0e7898bd7464d0c402fe8a949d9cbf9b5f8c59ee58f681aecdd90bd6b0b506de11a11b69c0a658c7a9948425daa7261a"
}

Step 3: Receive encrypted response from Hesabe

{
  "response": "60a8f6241932227b840a9f5e36987f4d894e5813e1ec714a9f1093832ea77937b298e2fd12ae31865c8949b356931c0fd6c88f5b188f1e01857538b4431055a88813ef3ef595ff271d7ac37f0338f9a4689fd9bec344551d7b4c0c9a382f99d9"
}

Step 4: Decrypt the api response and view the JSON output

{
  "status": true,
  "message": "Invoice status update successfully",
  "response": null
}

Response Body

application/json

application/json

application/json

application/json

const body = JSON.stringify({  "data": "0e7898bd7464d0c402fe8a949d9cbf9b5f8c59ee58f681aecdd90bd6b0b506de11a11b69c0a658c7a9948425daa7261a"})fetch("https://merchantapisandbox.hesabe.com/api/v1/invoice/8417596678339677489", {  method: "PUT",  headers: {    "Content-Type": "application/json",    "accessCode": "c333729b-d060-4b74-a49d-7686a8353481",    "Accept": "application/json"  },  body})
{
  "status": true,
  "message": "Invoice status update successfully",
  "response": null
}
{
  "status": false,
  "message": "Invoice status update failed",
  "response": null
}
{
  "message": "Request not found, Please verify the request data"
}
{
  "message": "Internal Server Error, An unexpected error occurred on the server while processing the request. This may be due to a temporary issue or a server-side malfunction. Please try again later or contact support if the issue persists"
}