Broadleaf Microservices
  • v1.0.0-latest-prod

Braintree Reverse Authorization Transaction

Prerequisites

Set up your environment as described in the Environment Setup Guide

Executing a Reverse Authorization Transaction

Note
Braintree only supports reverse authorizations for the full authorized amount. Also, if a partial capture is executed, then the remaining authorized amount is automatically voided/reversed.

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

public class ReverseAuthorization {

 @Autowired
 BraintreeTransactionService braintreeTransactionService;

 public void performReverseAuthorization() {
        PaymentRequest paymentRequest = new PaymentRequest()
		        .additionalField("TRANSACTION_ID", transactionId); // The Braintree transaction id gathered from the Authorize transaction.

	 	PaymentResponse paymentResponse = braintreeTransactionService.reverseAuthorize(paymentRequest);

		paymentResponse.isSuccessful();
		paymentResponse.getGatewayResponseCode(); // The Braintree response code
		paymentResponse.getFailureType(); // Failure type in case the transaction was not successful.
	   	paymentResponse.getRawResponse(); // Braintree raw response stored as a JSON object.
		paymentResponse.getGatewayTransactionId(); // gatewayTransaction Id from Braintree.
		paymentResponse.getGatewayTransactionType(); // Braintree gateway transaction type.
		paymentResponse.getResponseMap().get("TRANSACTION_ID"); // Braintree transaction Id.
	   	paymentResponse.getResponseMap().get("TRANSACTION_STATUS"); // Braintree transaction status.
	}
}