@GracefulShutdown
public String authorizePayment(DbId<User> userId, String paymentProfileId, String cardCode, BigDecimal amountToAuthorize)
{
String customerProfileId = userAttributeService.getAttribute(userId, ATTR_PROFILE_ID);
if (customerProfileId == null)
throw new OperationDisallowedException(userId + " has no Authorize.Net customer profile");
List<PaymentMethod> paymentMethods = getPaymentMethods(userId, customerProfileId);
PaymentMethod paymentMethodToUse = null;
for (PaymentMethod paymentMethod : paymentMethods)
if (paymentMethod.getPaymentProfileId().equals(paymentProfileId)) {
paymentMethodToUse = paymentMethod;
break;
}
if (paymentMethodToUse == null)
throw new OperationDisallowedException(userId + " does not have paymentProfileId " + paymentProfileId);
Order order = Order.createOrder();
order.setTotalAmount(amountToAuthorize);
PaymentTransaction paymentTransaction = PaymentTransaction.createPaymentTransaction();