@RequiredArgsConstructor
public class Authorize {
private final CheckoutComTransactionService checkoutComTransactionService;
public void performAuthorization() {
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();
PaymentRequest paymentRequest = new PaymentRequest()
.transactionReferenceId(transactionReferenceId)// This is the unique transaction reference ID
.transactionTotal(transactionTotal)
.additionalField(CheckoutConstants.TOKEN, cardToken)
.tenantId("TENANT"); // Declare the tenant id to help identify where transaction results should be recorded
PaymentResponse paymentResponse = checkoutComTransactionService.authorize(paymentRequest);
paymentResponse.isSuccessful();
paymentResponse.getGatewayResponseCode(); //Checkout.com Response Code
paymentResponse.getFailureType(); // Failure type in case the transaction was not successful.
paymentResponse.getRawResponse(); // Checkout.com raw response stored as a JSON object.
paymentResponse.getResponseMap().get(CheckoutConstants.PAYMENT_ID); // Checkout.com Payment ID used for subsequent transactions.
paymentResponse.getPaymentMethodProperties().get(CheckoutConstants.SOURCE_ID); // Source ID to be used in place of card token.
}
}