Skip to main content

Process Response

The response returned from the Payment Gateway would be in a field called data. This would be encrypted using the same set of AES - IV & Secret Keys and hence would need to be decrypted using HesabeCrypt library’s decrypt function. The value after decryption would be like on the right.

Sample Response

{
"status": true,
"code": 1,
"message": "Transaction Success",
"response": {
"data": {
"resultCode": "CAPTURED",
"amount": 10,
"paymentToken": "1569830677725743478",
"paymentId": "100201927384634224",
"paidOn": "2019-09-30 11:05:16",
"orderReferenceNumber": null,
"variable1": null,
"variable2": null,
"variable3": null,
"variable4": null,
"variable5": null,
"method": 1,
"administrativeCharge": "5"
}
}
}

Response Parameters

FieldTypeDescription
statusBooleanPayment status (true for success; false for failure)
resultCodeStringSuccess transactions have values "CAPTURED", "ACCEPT", or "SUCCESS"
amountNumericAmount must be greater than zero
paymentTokenNumeric14-digit Payment Token returned from Hesabe
paymentIdAlphanumericPayment Id returned from Hesabe
paidOnAlphanumericDate and Time of Payment
orderReferenceNumberAlphanumericCustom user parameter passed in the request
variable1AlphanumericCustom user parameter included in the response
variable2AlphanumericCustom user parameter included in the response
variable3AlphanumericCustom user parameter included in the response
variable4AlphanumericCustom user parameter included in the response
variable5AlphanumericCustom user parameter included in the response
methodNumeric1 or 2 (1 for KNET; 2 for MPGS)
administrativeChargeNumericAdministrative Charge

Common REST API Status Codes

This table includes widely used HTTP status codes that are relevant to REST API operations. These codes represent standard responses from the server regarding the outcome of HTTP requests, such as authentication results, validation errors, or server issues.

Status CodeDescription
200OK – The request has succeeded. Used for successful GET or POST responses.
201Created – The request has succeeded, and a new resource has been created. Common in POST requests that create data.
204No Content – The server successfully processed the request, but there is no content to send in response.
400Bad Request – The server could not understand the request due to an invalid syntax. Often used when required fields are missing.
401Unauthorized – Authentication is required and has failed or has not yet been provided.
403Forbidden – The server understands the request but refuses to authorize it.
404Not Found – The requested resource could not be found on the server.
405Method Not Allowed – The request method is known by the server but has been disabled for the requested resource.
408Request Timeout – The server timed out waiting for the request.
409Conflict – The request conflicts with the current state of the resource.
415Unsupported Media Type – The media format of the requested data is not supported by the server.
429Too Many Requests – The user has sent too many requests in a given amount of time (rate limiting).
500Internal Server Error – A generic error message, given when an unexpected condition is encountered.
502Bad Gateway – The server was acting as a gateway or proxy and received an invalid response from the upstream server.
503Service Unavailable – The server is not ready to handle the request, often due to maintenance or overload.

Custom Application Error Codes

Description:

This table lists application-specific error codes used to identify and describe issues related to merchant transactions, authentication, authorization, and payment processing. Each code corresponds to a unique system error or validation failure, allowing clients and developers to handle errors in a structured way.

Error CodeDescription
422The input data provided is either invalid or incomplete.
501The specified merchant is not recognized or registered.
503The merchant does not have access to the requested service.
504Incorrect login credentials provided by the merchant.
505The payment token is invalid or has expired.
506The request contains data that is not formatted or structured correctly.
507A generic error occurred during the transaction process.
508The transaction amount exceeds the allowed limit.
509The number of transactions for the day exceeds the permitted limit.
510The total transaction amount for the day has been exceeded.
511The number of transactions for the month exceeds the permitted limit.
512A threshold has been reached, but the transaction can still proceed.
513The session has expired due to inactivity.
514The amount captured is less than what was originally authorized.
515The captured amount exceeds the authorized amount.
516The captured amount is more than the available authorized balance.
517The authorization has expired and is no longer valid.
518Authorization must be enabled before proceeding with this transaction.
519The currency used in the transaction is not supported or invalid.
520The transaction was cancelled by the user or system.
521This transaction has already been captured and cannot be captured again.
522Terminal ID is missing from the request or is invalid.
523The account details provided are incorrect or incomplete.
524The KNET card used is not valid or unsupported.
525The commission structure provided is invalid or does not match the expected format.