GatewayErrorResponse Class
Use to respond with an error indication following errors from the PaymentGateway adapter, such as request-forbidden responses, custom validation errors, or expired API tokens.
Use GatewayErrorResponse to create an object that stores information about error responses sent by the payment gateway adapter.
If GatewayResponse receives an exception rather than a valid request, it calls GatewayErrorResponse to create an error object with information about the exception.
The following are constructors for GatewayErrorResponse.
-
GatewayErrorResponse(errorCode, errorMessage)
Constructor to create a GatewayErrorResponse object that accepts
errorCodeanderrorMessage.
Constructor to create a GatewayErrorResponse object that accepts errorCode and errorMessage.
global GatewayErrorResponse(String errorCode, String errorMessage)
-
errorCode: Type: String Should match with the HTTP status code to be returned to the user. Here are a few examples.
- If the status code is for a bad request, the errorCode should be 400.
- If the status code is for a forbidden request, errorCode should be 403.
- If errorCode isn’t a valid HTTP status code, a 500 internal server error is returned.
errorCode must have a value, otherwise the platform throws an error.
-
errorMessage: Type: String The message response to users following an error.
errorMessage must have a value, otherwise the platform throws an error.