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());
}
if (responseDTO.getAmount() == null || responseDTO.getPaymentTransactionType() == null) {
//Log an error, an exception will get thrown later as the payments won't add up.
LOG.error("The ResponseDTO returned from the Gateway does not contain either an Amount or Payment Transaction Type. " +
"Please check your implementation");
}
// Create a new transaction that references its parent UNCONFIRMED transaction.
PaymentTransaction transaction = orderPaymentService.createTransaction();
transaction.setAmount(responseDTO.getAmount());
transaction.setRawResponse(responseDTO.getRawResponse());
transaction.setSuccess(responseDTO.isSuccessful());
transaction.setType(responseDTO.getPaymentTransactionType());
transaction.setParentTransaction(tx);
transaction.setOrderPayment(payment);
transaction.setAdditionalFields(responseDTO.getResponseMap());
additionalTransactions.put(payment, transaction);
if (responseDTO.isSuccessful()) {
additionalConfirmedTransactions.put(payment, transaction.getType());
} else {
failedTransactions.add(responseDTO);
}