@RequiredArgsConstructor
public class Capture {
private final TabbyTransactionService tabbyTransactionService;
public void performCapture() {
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();
PaymentRequest paymentRequest = new PaymentRequest()
.transactionTotal(transactionTotal)
.transactionReferenceId(transactionReferenceId)
.tenantId(tenantId)
.applicationId(applicationId)
.additionalField("payment_id", paymentId); // The Tabby payment id gathered from the Authorize transaction.
PaymentResponse paymentResponse = tabbyTransactionService.capture(paymentRequest);
paymentResponse.isSuccessful();
paymentResponse.getFailureType(); // Failure type in case the transaction was not successful
paymentResponse.getRawResponse(); // Tabby raw response stored as a String
paymentResponse.getGatewayTransactionId(); // the gateway transaction id
paymentResponse.getResponseMap().get("payment_id"); // Tabby payment id
paymentResponse.getResponseMap().get("payment_status"); // Tabby payment status
}
}