---
schema_version: "1"
id: db04bd7f56bda4a1e3ebac6e3e48d6221c96c0699ac239586d700face8a1adb4
title: GatewayNotificationResponse Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_commercepayments_GatewayNotificationResponse.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_GatewayNotificationResponse.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4bdf368e888e92fae68827817af8ae9383bedd092a580f06d2c60a7fcf993227
description: When the payment gateway sends a notification to the payments platform, the platform responds with a GatewayNotificationResponse indicating whether the platform succeeded or failed at receiving the notification.Sets the body of the response to the gateway. Some gateways expect the payments platform to acknowledge the notification with a response regardless of whether the notification was accepted.Sets the HTTP status code sent to the gateway as part of the payments platform’s response notification.
---
# GatewayNotificationResponse Class

When the payment gateway sends a notification to the payments platform, the platform responds with a GatewayNotificationResponse indicating whether the platform succeeded or failed at receiving the notification.

## 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.")

## Usage

You must specify the CommercePayments namespace when creating an instance of this class. The constructor of this class takes no arguments. For example:

CommercePayments.GatewayNotificationResponse gnr = new CommercePayments.GatewayNotificationResponse();

When an asynchronous payment gateway sends a notification, the gateway requires the platform to acknowledge that it has either succeeded or failed in receiving the notification. Payment gateway adapters use this class to construct the acknowledgment response, which gateways expect for a notification. GatewayNotificationResponse is the return type of the processNotification method.

## Example

commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();
if (saveResult.isSuccess()) {
    system.debug('Notification accepted by platform');
} else {
    system.debug('Errors in the result '\+ Blob.valueOf(saveResult.getErrorMessage()));
}
gnr.setStatusCode(200);
gnr.setResponseBody(Blob.valueOf('\[accepted\]'));
return gnr;

- **[GatewayNotificationResponse Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_GatewayNotificationResponse.htm#apex_commercepayments_GatewayNotificationResponse_methods)**

## GatewayNotificationResponse Methods

The following are methods for GatewayNotificationResponse.

- **[setResponseBody(responseBody)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_GatewayNotificationResponse.htm#apex_commercepayments_GatewayNotificationResponse_setResponseBody)**  
    Sets the body of the response to the gateway. Some gateways expect the payments platform to acknowledge the notification with a response regardless of whether the notification was accepted.
- **[setStatusCode(statusCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_GatewayNotificationResponse.htm#apex_commercepayments_GatewayNotificationResponse_setStatusCode)**  
    Sets the HTTP status code sent to the gateway as part of the payments platform’s response notification.

### setResponseBody(responseBody)

Sets the body of the response to the gateway. Some gateways expect the payments platform to acknowledge the notification with a response regardless of whether the notification was accepted.

#### Signature

global void setResponseBody(Blob responseBody)

#### Parameters

- **responseBody**:
    
    Type: [Blob](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_blob.htm#apex_methods_system_blob "Contains methods for the Blob primitive data type.") Common response values include accepted
    
    for successfully receiving the response. For example:
    
    commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();
    if (saveResult.isSuccess()) {
        system.debug('Notification accepted by platform');
    } else {
        system.debug('Errors in the result '\+ Blob.valueOf(saveResult.getErrorMessage()));
    }
    gnr.setStatusCode(200);
    gnr.setResponseBody(Blob.valueOf('\[accepted\]'));
    return gnr;

#### Return Value

Type: void

### setStatusCode(statusCode)

Sets the HTTP status code sent to the gateway as part of the payments platform’s response notification.

#### Signature

global void setStatusCode(Integer statusCode)

#### Parameters

- **statusCode**:
    
    Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")
    
    The status code will vary based on the type of payments platform response. Users should configure their GatewayNotificationResponse class to account for all values that their payments platform can possibly return. For example:
    
    commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();
    if (saveResult.isSuccess()) {
        system.debug('Notification accepted by platform');
    } else {
        system.debug('Errors in the result '\+ Blob.valueOf(saveResult.getErrorMessage()));
    }
    gnr.setStatusCode(200);
    gnr.setResponseBody(Blob.valueOf('\[accepted\]'));
    return gnr;

#### Return Value

Type: void