GatewayResponse Interface
Generic payment gateway response interface. This class extends the
CaptureResponse, AbstractTransactionResponse, and AbstractResponse classes and inherits all their
properties. It has no unique methods or parameters.
Namespace
GatewayResponse Example Implementation
This is an example implementation of the commercepayments.GatewayResponse interface.
/**
* Abstract function to build gateway response for a Transaction
* The input is the response from gateway
* It creates and returns GatewayResponse from the HttpResponse
*/
public abstract commercepayments.GatewayResponse buildResponse(HttpResponse response);
/**
* Function to process transaction requests
* Steps involved are:
* 1. Build HttpRequest with the input Request from gateway context
* 2. Send request and get the response from gateway
* 3. Parse the response from gateway and return GatewayResponse
*/
public commercepayments.GatewayResponse execute(){
HttpRequest req;
try{
//Building a new request
req = buildRequest();
} catch(PayeezeValidationException e) {
return getValidationExceptionError(e);
}
commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp();
HttpResponse res = null;
try{
//Sending the request
res = http.send(req);
} catch(CalloutException ce) {
return getCalloutExceptionError(ce);
}
try{
//Parsing the response from gateway
return buildResponse(res);
} catch(Exception e) {
return getParseExceptionError(e);
}
}
For additional context, review the complete Sample Gateway Adapter in the CommercePayments Gateway Reference Implementation.