Broadleaf Microservices
  • v1.0.0-latest-prod

MyFatoorah Reverse Authorization Transaction

Prerequisites

Set up your environment as described in the Environment Setup Guide

Executing a Reverse Authorization Transaction

Note
This transaction type is only relevant if your MyFatoorah account is configured to execute Authorizations and Captures as separate transactions.

Use the following code snippet to perform a Reverse Authorization transaction:

public class ReverseAuthorization {

 @Autowired
 MyFatoorahTransactionService myFatoorahTransactionService;

 public void performReverseAuthorization() {

		 PaymentRequest paymentRequest = new PaymentRequest()
		        .additionalField("invoiceId", invoiceId); // The MyFatoorah invoice id gathered from the Authorize transaction.

	 	PaymentResponse paymentResponse = myFatoorahTransactionService.reverseAuthorize(paymentRequest);

		paymentResponse.isSuccessful();
		paymentResponse.getGatewayResponseCode(); // MyFatoorah reason_code
      		paymentResponse.getGatewayTransactionId(); // MyFatoorah transaction ID
	   	paymentResponse.getRawResponse(); // MyFatoorah Raw response stored as a JSON object.
	   	paymentResponse.getGatewayTransactionType();
	   	paymentResponse.getResponseMap().get("invoiceId"); // MyFatoorah invoiceId.
	   	paymentResponse.getResponseMap().get("paymentId"); // MyFatoorah paymentId.
	   	paymentResponse.getResponseMap().get("paymentGateway"); // MyFatoorah paymentGateway.
	   	paymentResponse.getResponseMap().get("transactionId");  // MyFatoorah transactionId.
	}
}