@Test public void testHandleStandardInventoryShippedAuth() throws Exception { String label = assertPgFeatures("testPaymentGateway", false, true, true, true); CustomerOrder customerOrder = createTestOrder(TestOrderType.STANDARD, label, false); assertTrue(pendingHandler.handle( new OrderEventImpl("", customerOrder, null, Collections.EMPTY_MAP))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "9.00", "2.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "1.00", "1.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_ALLOCATION_WAIT); CustomerOrderDelivery delivery = null; for (final CustomerOrderDelivery orderDelivery : customerOrder.getDelivery()) { if (CustomerOrderDelivery.DELIVERY_STATUS_ALLOCATION_WAIT.equals(orderDelivery.getDeliveryStatus())) { assertNull(delivery); delivery = orderDelivery; } } assertTrue(allocationHandler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertTrue(packingHandler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertTrue(packedHandler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertTrue(releaseHandler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertTrue(shippedHandler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPPED); assertEquals(CustomerOrder.ORDER_STATUS_COMPLETED, customerOrder.getOrderStatus()); assertTrue(handler.handle( new OrderEventImpl("", customerOrder, null, Collections.EMPTY_MAP))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_INVENTORY_RETURNED); assertMultiPaymentEntry(customerOrder.getOrdernum(), Arrays.asList("689.74", "689.74", "689.74"), Arrays.asList(PaymentGateway.AUTH, PaymentGateway.CAPTURE, PaymentGateway.REFUND), Arrays.asList(Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_OK), Arrays.asList(Boolean.FALSE, Boolean.TRUE, Boolean.FALSE)); assertEquals("689.74", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_RETURNED, customerOrder.getOrderStatus()); }
@Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentProcessor paymentProcessor = paymentProcessorFactory.create(order.getPgLabel(), pgShop.getCode()); if (!paymentProcessor.isPaymentGatewayEnabled()) { throw new PGDisabledException("PG " + order.getPgLabel() + " is disabled in " + order.getShop().getCode(), order.getPgLabel()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { creditQuantity(orderEvent); final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } else { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { return false; } creditQuantity(orderEvent); } handleInternal(orderEvent); return true; } }
CancelOrderWithRefundOrderEventHandlerImpl extends CancelOrderEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentProcessor paymentProcessor = paymentProcessorFactory.create(order.getPgLabel(), pgShop.getCode()); if (!paymentProcessor.isPaymentGatewayEnabled()) { throw new PGDisabledException("PG " + order.getPgLabel() + " is disabled in " + order.getShop().getCode(), order.getPgLabel()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { creditQuantity(orderEvent); final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } else { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { return false; } creditQuantity(orderEvent); } handleInternal(orderEvent); return true; } } }
CancelOrderWithRefundOrderEventHandlerImpl extends CancelOrderEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentProcessor paymentProcessor = paymentProcessorFactory.create(order.getPgLabel(), pgShop.getCode()); if (!paymentProcessor.isPaymentGatewayEnabled()) { throw new PGDisabledException("PG " + order.getPgLabel() + " is disabled in " + order.getShop().getCode(), order.getPgLabel()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { creditQuantity(orderEvent); final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } else { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { return false; } creditQuantity(orderEvent); } handleInternal(orderEvent); return true; } } CancelOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                      final WarehouseService warehouseService,
                                                      final InventoryResolver inventoryResolver,
                                                      final ProductService productService); }
CancelOrderWithRefundOrderEventHandlerImpl extends CancelOrderEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentProcessor paymentProcessor = paymentProcessorFactory.create(order.getPgLabel(), pgShop.getCode()); if (!paymentProcessor.isPaymentGatewayEnabled()) { throw new PGDisabledException("PG " + order.getPgLabel() + " is disabled in " + order.getShop().getCode(), order.getPgLabel()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { creditQuantity(orderEvent); final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } else { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { return false; } creditQuantity(orderEvent); } handleInternal(orderEvent); return true; } } CancelOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                      final WarehouseService warehouseService,
                                                      final InventoryResolver inventoryResolver,
                                                      final ProductService productService); @Override boolean handle(final OrderEvent orderEvent); }
CancelOrderWithRefundOrderEventHandlerImpl extends CancelOrderEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentProcessor paymentProcessor = paymentProcessorFactory.create(order.getPgLabel(), pgShop.getCode()); if (!paymentProcessor.isPaymentGatewayEnabled()) { throw new PGDisabledException("PG " + order.getPgLabel() + " is disabled in " + order.getShop().getCode(), order.getPgLabel()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { creditQuantity(orderEvent); final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } else { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { return false; } creditQuantity(orderEvent); } handleInternal(orderEvent); return true; } } CancelOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                      final WarehouseService warehouseService,
                                                      final InventoryResolver inventoryResolver,
                                                      final ProductService productService); @Override boolean handle(final OrderEvent orderEvent);  }