---
schema_version: "1"
id: 329ffbd9d0c5b0b40c6e6dcd0eec174dcec6b0b78fb2d924292db5ea6250e20d
title: GatewayResponse Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_commercepayments_GatewayResponse.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_commercepayments_GatewayResponse.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 44f78b354c6817422af2e3c63bbbdda46761f9da7cf48ca69d95a595b6c4eded
description: 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.
---
# GatewayResponse Interface

Generic payment gateway response interface. This class extends the [CaptureResponse](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_CaptureResponse.htm#apex_class_commerce_payments_CaptureResponse "The payment gateway adapter sends this response for the capture request type. This class extends AbstractResponse and inherits its methods."), [AbstractTransactionResponse](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AbstractTransactionResponse.htm#apex_class_commercepayments_AbstractTransactionResponse "Abstract class for storing normalized information sent from payment gateways about a payment transaction. Holds the common response fields sent from payment gateways for authorization, sale, capture, and refund transactions."), and [AbstractResponse](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AbstractResponse.htm#apex_class_commerce_payments_AbstractResponse "Contains the normalized response fields from payment gateways that are common to all the other gateway responses.") classes and inherits all their properties. It has no unique methods or parameters.

## Namespace

[CommercePayments](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commercepayments.htm "Use the CommercePayments namespace to provide a safe and customizable platform for managing customer payments and refunds.")

- **[GatewayResponse Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_commercepayments_GatewayResponse.htm#apex_interface_commerce_payments_GatewayResponse_Example)**

## 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](https://github.com/forcedotcom/Core-Payments-Reference-Gateway-Integration-Adapters/blob/master/PayeezyGatewayAdapter/classes/AbstractTransactionService.apex) in the [CommercePayments Gateway Reference Implementation](https://github.com/forcedotcom/Core-Payments-Reference-Gateway-Integration-Adapters).