// Cannot confirm anything here if there is no provider
if (paymentConfigurationServiceProvider == null) {
String msg = "There are unconfirmed payment transactions on this payment but no payment gateway" +
" configuration or transaction confirmation service configured";
LOG.error(msg);
throw new CheckoutException(msg, context.getSeedData());
}
PaymentGatewayConfigurationService cfg = paymentConfigurationServiceProvider.getGatewayConfigurationService(tx.getOrderPayment().getGatewayType());
PaymentResponseDTO responseDTO = null;
if (PaymentType.CREDIT_CARD.equals(payment.getType())) {
// Handles the PCI-Compliant Scenario where you have an UNCONFIRMED CREDIT_CARD payment on the order.
// This can happen if you send the Credit Card directly to Broadleaf or you use a Digital Wallet solution like MasterPass.
// The Actual Credit Card PAN is stored in blSecurePU and will need to be sent to the Payment Gateway for processing.
PaymentRequestDTO s2sRequest = orderToPaymentRequestService.translatePaymentTransaction(payment.getAmount(), tx);
populateCreditCardOnRequest(s2sRequest, payment);
populateBillingAddressOnRequest(s2sRequest, payment);
populateCustomerOnRequest(s2sRequest, payment);
if (cfg.getConfiguration().isPerformAuthorizeAndCapture()) {
responseDTO = cfg.getTransactionService().authorizeAndCapture(s2sRequest);
} else {
responseDTO = cfg.getTransactionService().authorize(s2sRequest);
}
} else {
// This handles the THIRD_PARTY_ACCOUNT scenario (like PayPal Express Checkout) where
// the transaction just needs to be confirmed with the Gateway
responseDTO = cfg.getTransactionConfirmationService()
.confirmTransaction(orderToPaymentRequestService.translatePaymentTransaction(payment.getAmount(), tx));
}
if (responseDTO == null) {
String msg = "Unable to Confirm/Authorize the UNCONFIRMED Transaction with id: " + tx.getId() + ". " +
"The ResponseDTO returned from the Gateway was null. Please check your implementation";
LOG.error(msg);
throw new CheckoutException(msg, context.getSeedData());
}
if (LOG.isTraceEnabled()) {
LOG.trace("Transaction Confirmation Raw Response: " + responseDTO.getRawResponse());
}