Newer Version Available

This content describes an older version of this product. View Latest

AuthorizationReversalRequest Class

Sends information about an authorization reversal request to a gateway adapter during a service call.

Namespace

CommercePayments

Example

Add your reversal classes to your payment gateway adapter. We recommend adding AuthorizationReversal as a possible requestType value when calling processRequest on the gateway’s response.

1global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {
2        commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();
3        commercepayments.GatewayResponse response;
4        
5        try {
6        //add other requestType values here
7        //..
8        else if (requestType == commercepayments.RequestType.AuthorizationReversal) {
9                response = createAuthReversalResponse((commercepayments.AuthorizationReversalRequest)gatewayContext.getPaymentRequest());}
10        
11        return response;

Then, add a class that sets the amount of the authorization reversal request, as well as gateway information and the Salesforce result code.

1global commercepayments.GatewayResponse createAuthReversalResponse(commercepayments.AuthorizationReversalRequest authReversalRequest) {
2        commercepayments.AuthorizationReversalResponse authReversalResponse = new commercepayments.AuthorizationReversalResponse();
3        if(authReversalRequest.amount!=null )
4        {
5            authReversalResponse.setAmount(authReversalRequest.amount);
6        }
7        else
8        {
9             throw new SalesforceValidationException('Required Field Missing : Amount');             
10        }
11   
12        system.debug('Response - success');
13        authReversalResponse.setGatewayDate(system.now());
14        authReversalResponse.setGatewayResultCode('00');
15        authReversalResponse.setGatewayResultCodeDescription('Transaction Normal');
16        authReversalResponse.setGatewayReferenceNumber('SF'+getRandomNumber(6));
17        authReversalResponse.setSalesforceResultCodeInfo(SUCCESS_SALESFORCE_RESULT_CODE_INFO);
18        return authReversalResponse;
19    }

AuthorizationReversalRequest Constructors

The following are constructors for AuthorizationReversalRequest.

AuthorizationReversalRequest(amount, authorizationId)

Constructor for building the amount in an authorization reversal request. This constructor is intended for test usage and throws an exception if used outside of the Apex test context.

Signature

global AuthorizationReversalRequest(Double amount, String authorizationId)

Parameters

amount
Type: Double
The amount of the authorization reversal request.
authorizationId
Type: String
The authorization request to be reversed.

AuthorizationReversalRequest Properties

The following are properties for AuthorizationReversalRequest.

accountId

References the customer account for the transaction where the authorization reversal was performed.

Signature

global String accountId {get; set;}

Property Value

Type: String

amount

The total amount of the authorization reversal request. Can be positive or negative.

Signature

global Double amount {get; set;}

Property Value

Type: Double

paymentAuthorizationId

References the payment authorization to be reversed.

Signature

global String paymentAuthorizationId {get; set;}

Property Value

Type: String

AuthorizationReversalRequest Methods

The following are methods for AuthorizationReversalRequest.

equals(obj)

Maintains the integrity of lists of type AuthorizationReversalRequest by determining the equality of external objects in a list. This method is dynamic and based on the equals method in Java.

Signature

global Boolean equals(Object obj)

Parameters

obj
Type: Object
External object whose key is to be validated.

Return Value

Type: Boolean

hashCode()

Maintains the integrity of lists of type AuthorizationReversalRequest by determining the uniqueness of the external object in a list.

Signature

global Integer hashCode()

Return Value

Type: Integer

toString()

Converts a date to a string.

Signature

global String toString()

Return Value

Type: String