Broadleaf Microservices
  • v1.0.0-latest-prod

Verifone Capture Transaction

Prerequisites

Set up your environment as described in the Environment Setup Guide

Executing a Capture Transaction

Use the following code snippet to perform a Capture transaction:

public class Capture {

 @Autowired
 VerifoneTransactionService verifoneTransactionService;

 public void performCapture() {

		 CurrencyUnit currency = Monetary.getCurrency(currencyCode);
		 MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();

		 PaymentRequest paymentRequest = new PaymentRequest()
		        .additionalField("id", transactionId) // The Verifone id of the original Authorize transaction
		        .transactionTotal(transactionTotal);

	 	PaymentResponse paymentResponse = verifoneTransactionService.capture(paymentRequest);

		paymentResponse.isSuccessful();
		paymentResponse.getGatewayResponseCode(); // Verifone reason_code
        paymentResponse.getGatewayTransactionId(); // Verifone transaction ID
        paymentResponse.getMessage(); // Verifone response message
		paymentResponse.getFailureType(); // Failure type in case the transaction was not successful.
	  	paymentResponse.getResponseMap().get("id"); // Verifone transaction ID, reference used for all subsequent refund transactions
	  	paymentResponse.getResponseMap().get("status"); // Verifone transaction status
	  	paymentResponse.getResponseMap().get("processor_reference"); // Reference identifying the transaction, as provided by the processor.

        // When the payment is authorized successfully, this field holds the authorization code for the payment.
        // When the payment is not authorized, this field is not returned.
	  	paymentResponse.getResponseMap().get("rrn");
        paymentResponse.getResponseMap().get("arn");
	   	paymentResponse.getRawResponse(); // Verifone Raw response stored as a JSON object
	}
}