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}

Base URL

Sandbox Base URL

Strictly for sandbox testing. Never use the sandbox URL in your production environment.
https://merchantapisandbox.hesabe.com

Authorization

bearerAuth
headerAuthorizationBearer <JWT>

Pass access token obtained from login endpoint

Header Parameters

accessCode*string

Pass the merchant access code issued by Hesabe

Accept*string

application/json

Content-Type*string

application/json

Path Parameters

invoice_token*string

Pass the invoice token number

Request Body

application/json
  1. body
data*string

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

Details fetched successfully. Decrypt the server response to view the final result

application/json
  1. response
status?boolean
message?string
response?|null
Example Request
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})
Example Response
{  "status": true,  "message": "Invoice status update successfully",  "response": null}