Sends information about an authorization reversal request to a gateway
adapter during a service call.
Namespace
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.
global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) { commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType(); commercepayments.GatewayResponse response; try { //add other requestType values here //.. else if (requestType == commercepayments.RequestType.AuthorizationReversal) { response = createAuthReversalResponse((commercepayments.AuthorizationReversalRequest)gatewayContext.getPaymentRequest());} 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.
global commercepayments.GatewayResponse createAuthReversalResponse(commercepayments.AuthorizationReversalRequest authReversalRequest) { commercepayments.AuthorizationReversalResponse authReversalResponse = new commercepayments.AuthorizationReversalResponse(); if(authReversalRequest.amount!=null ) { authReversalResponse.setAmount(authReversalRequest.amount); } else { throw new SalesforceValidationException('Required Field Missing : Amount'); } system.debug('Response - success'); authReversalResponse.setGatewayDate(system.now()); authReversalResponse.setGatewayResultCode('00'); authReversalResponse.setGatewayResultCodeDescription('Transaction Normal'); authReversalResponse.setGatewayReferenceNumber('SF'+getRandomNumber(6)); authReversalResponse.setSalesforceResultCodeInfo(SUCCESS_SALESFORCE_RESULT_CODE_INFO); return authReversalResponse; }
AuthorizationReversalRequest Constructors
The following are constructors for AuthorizationReversalRequest.
AuthorizationReversalRequest(amount, authorizationId)
AuthorizationReversalRequest Properties
The following are properties for AuthorizationReversalRequest.
paymentAuthorizationId
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