Newer Version Available
GatewayNotificationResponse Class
Namespace
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
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();
2if (saveResult.isSuccess()) {
3 system.debug('Notification accepted by platform');
4} else {
5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage()));
6}
7gnr.setStatusCode(200);
8gnr.setResponseBody(Blob.valueOf('[accepted]'));
9return gnr;GatewayNotificationResponse Methods
The following are methods for GatewayNotificationResponse.
setResponseBody(responseBody)
Signature
global void setResponseBody(Blob responseBody)
Parameters
- responseBody
- Type: Blob
- Common response
values
include accepted for successfully
receiving the response. For
example:
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse(); 2if (saveResult.isSuccess()) { 3 system.debug('Notification accepted by platform'); 4} else { 5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage())); 6} 7gnr.setStatusCode(200); 8gnr.setResponseBody(Blob.valueOf('[accepted]')); 9return gnr;
Return Value
Type: void
setStatusCode(statusCode)
Signature
global void setStatusCode(Integer statusCode)
Parameters
- statusCode
- Type: Integer
- 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:
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse(); 2if (saveResult.isSuccess()) { 3 system.debug('Notification accepted by platform'); 4} else { 5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage())); 6} 7gnr.setStatusCode(200); 8gnr.setResponseBody(Blob.valueOf('[accepted]')); 9return gnr;
Return Value
Type: void