@Test public void testHandleFullMixedSinglePaymentOkOnlineAuthPaymentFailedCapture() throws Exception { configureTestPG(true, false, TestPaymentGatewayImpl.PROCESSING); String label = assertPgFeatures("testPaymentGateway", false, true, true, false); CustomerOrder customerOrder = createTestOrder(TestOrderType.FULL, label, true); assertSinglePaymentEntry(customerOrder.getOrdernum(), "1445.66", PaymentGateway.AUTH, Payment.PAYMENT_STATUS_PROCESSING, false); assertEquals("1445.66", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); deactivateTestPgParameter(TestPaymentGatewayImpl.PROCESSING); activateTestPgParameterSetOn(TestPaymentGatewayImpl.CAPTURE_FAIL); assertTrue(handler.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"); assertInventory(WAREHOUSE_ID, "CC_TEST6", "500.00", "3.00"); assertInventory(WAREHOUSE_ID, "CC_TEST5-NOINV", "0.00", "4.00"); assertInventory(WAREHOUSE_ID, "CC_TEST9", "0.00", "0.00"); assertTrue(customerOrder.getDelivery().size() == 2); assertDeliveryStates(customerOrder.getDelivery(), new HashMap<String, String>() {{ put(CustomerOrderDelivery.MIX_DELIVERY_GROUP, CustomerOrderDelivery.DELIVERY_STATUS_DATE_WAIT); put(CustomerOrderDelivery.ELECTRONIC_DELIVERY_GROUP, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); }}); assertMultiPaymentEntry(customerOrder.getOrdernum(), Arrays.asList("1445.66", "1445.66", "1445.66"), Arrays.asList(PaymentGateway.AUTH, PaymentGateway.AUTH, PaymentGateway.CAPTURE), Arrays.asList(Payment.PAYMENT_STATUS_PROCESSING, Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_FAILED), Arrays.asList(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE)); assertEquals("1445.66", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_IN_PROGRESS, 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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_PAYMENT_OK, orderEvent.getCustomerOrder())); handled = true; } else if (Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { handled = true; } else { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_CANCEL_WITH_REFUND, orderEvent.getCustomerOrder())); handled = true; } } return handled; } }
PaymentProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl implements OrderEventHandler, ApplicationContextAware { @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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_PAYMENT_OK, orderEvent.getCustomerOrder())); handled = true; } else if (Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { handled = true; } else { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_CANCEL_WITH_REFUND, orderEvent.getCustomerOrder())); handled = true; } } return handled; } } }
PaymentProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl implements OrderEventHandler, ApplicationContextAware { @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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_PAYMENT_OK, orderEvent.getCustomerOrder())); handled = true; } else if (Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { handled = true; } else { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_CANCEL_WITH_REFUND, orderEvent.getCustomerOrder())); handled = true; } } return handled; } } PaymentProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); }
PaymentProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl implements OrderEventHandler, ApplicationContextAware { @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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_PAYMENT_OK, orderEvent.getCustomerOrder())); handled = true; } else if (Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { handled = true; } else { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_CANCEL_WITH_REFUND, orderEvent.getCustomerOrder())); handled = true; } } return handled; } } PaymentProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override void setApplicationContext(final ApplicationContext applicationContext); @Override boolean handle(final OrderEvent orderEvent); }
PaymentProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl implements OrderEventHandler, ApplicationContextAware { @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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_PAYMENT_OK, orderEvent.getCustomerOrder())); handled = true; } else if (Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { handled = true; } else { handleInternal(orderEvent); getOrderStateManager().fireTransition(new OrderEventImpl(orderEvent, OrderStateManager.EVT_CANCEL_WITH_REFUND, orderEvent.getCustomerOrder())); handled = true; } } return handled; } } PaymentProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override void setApplicationContext(final ApplicationContext applicationContext); @Override boolean handle(final OrderEvent orderEvent);  }