use of org.broadleafcommerce.core.checkout.service.workflow.CheckoutResponse in project BroadleafCommerce by BroadleafCommerce.
the class CheckoutTest method testCheckout.
@Test(groups = { "checkout" }, dependsOnGroups = { "createCartForCustomer", "testShippingInsert" }, dataProvider = "USCurrency", dataProviderClass = BroadleafCurrencyProvider.class)
@Transactional
public void testCheckout(BroadleafCurrency usCurrency) throws Exception {
HashMap currencyConsiderationContext = new HashMap();
currencyConsiderationContext.put("aa", "bb");
CurrencyConversionContext.setCurrencyConversionContext(currencyConsiderationContext);
CurrencyConversionContext.setCurrencyConversionService(new CurrencyConversionService() {
@Override
public Money convertCurrency(Money source, Currency destinationCurrency, int destinationScale) {
return source;
}
});
String userName = "customer1";
Customer customer = customerService.readCustomerByUsername(userName);
Order order = orderService.createNewCartForCustomer(customer);
usCurrency = currencyService.save(usCurrency);
order.setCurrency(usCurrency);
Address address = buildAddress();
FulfillmentGroup group = buildFulfillmentGroup(order, address);
addSampleItemToOrder(order, group);
order.setTotalShipping(new Money(0D));
addPaymentToOrder(order, address);
// execute pricing for this order
orderService.save(order, true);
CheckoutResponse response = checkoutService.performCheckout(order);
assert (order.getTotal().greaterThan(order.getSubTotal()));
}
use of org.broadleafcommerce.core.checkout.service.workflow.CheckoutResponse in project BroadleafCommerce by BroadleafCommerce.
the class DefaultPaymentGatewayCheckoutService method initiateCheckout.
@Override
public String initiateCheckout(Long orderId) throws Exception {
Order order = orderService.findOrderById(orderId, true);
if (order == null || order instanceof NullOrderImpl) {
throw new IllegalArgumentException("Could not order with id " + orderId);
}
CheckoutResponse response;
try {
response = checkoutService.performCheckout(order);
} catch (CheckoutException e) {
throw new Exception(e);
}
if (response.getOrder().getOrderNumber() == null) {
LOG.error("Order Number for Order ID: " + order.getId() + " is null.");
}
return response.getOrder().getOrderNumber();
}
Aggregations