public class Refund {
@Autowired
VerifoneTransactionService verifoneTransactionService;
public void performRefund() {
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 Capture transaction
// if the status is not "SETTLEMENT_REQUESTED" the Refund will be executed https://verifone.cloud/api-catalog/verifone-ecommerce-api#operation/refundPayment
// if the status is "SETTLEMENT_REQUESTED" the Void capture will be executed https://verifone.cloud/api-catalog/verifone-ecommerce-api#operation/voidCapture
.additionalField("status", status)
.transactionTotal(transactionTotal); // required if the status is "SALE_SETTLED"
PaymentResponse paymentResponse = verifoneTransactionService.refund(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
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
}
}