Broadleaf Microservices
  • v1.0.0-latest-prod

Verifone Authorize and Capture Transaction

Prerequisites

Before making a transaction, you need:

Executing an Authorize and Capture Transaction

Use the following code snippet to perform an Authorize and Capture transaction:

public class AuthorizeAndCapture {

 @Autowired
 VerifoneTransactionService verifoneTransactionService;

 public void performAuthorizeAndCapture() {

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

		 PaymentRequest paymentRequest = new PaymentRequest()
		        .transactionReferenceId(merchantReference) // Source: PaymentTransactionServices
		        .transactionTotal(transactionTotal)
                .additionalField("payment_provider_contract", "PPC") // Source: Payment#paymentMethodProperties or VerifonePaymentModificationService#modifyPaymentMethodProperties(...)
		        .additionalField("encrypted_card", encryptedCard) // Source: Payment#paymentMethodProperties
		        .additionalField("public_key_alias", publicKeyAlias); // Source: Payment#paymentMethodProperties

	 	PaymentResponse paymentResponse = verifoneTransactionService.authorizeAndCapture(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 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("authorization_code");

        // A client (user friendly) identifier for the transaction generated at the outset of a business event.
        // The format will be dependent on the calling system.
        // A reference supplied by the system retaining the original source information and used to assist in locating
        // that transaction or a copy of the transaction. This value is critical in matching values that are sent
        // to other Payment processors or Acquirers. This value would correspond to the ISO8583 specification as RRN
        // in attribute DE 37, which limits the value to being an alphanumeric value 12 characters.
	  	paymentResponse.getResponseMap().get("rrn");
        paymentResponse.getResponseMap().get("arn");
	  	paymentResponse.getResponseMap().get("avs_result");
	  	paymentResponse.getResponseMap().get("cvv_result");
	  	paymentResponse.getResponseMap().get("cavv_result");
	   	paymentResponse.getRawResponse(); // Verifone Raw response stored as a JSON object
	}
}

To use the VF Reuse Token replace the encrypted_card and public_key_alias with reuse_token.