@Test public void testHandleElectronicPaymentOkOnlineAuth() throws Exception { configureTestPG(true, true, TestPaymentGatewayImpl.PROCESSING); String label = assertPgFeatures("testPaymentGateway", false, true, true, true); CustomerOrder customerOrder = createTestOrder(TestOrderType.ELECTRONIC, label, false); assertSinglePaymentEntry(customerOrder.getOrdernum(), "444.95", PaymentGateway.AUTH, Payment.PAYMENT_STATUS_PROCESSING, true); assertEquals("444.95", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); deactivateTestPgParameter(TestPaymentGatewayImpl.PROCESSING); assertTrue(handler.handle( new OrderEventImpl("", customerOrder, null, Collections.EMPTY_MAP))); assertInventory(WAREHOUSE_ID, "CC_TEST9", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); assertMultiPaymentEntry(customerOrder.getOrdernum(), Arrays.asList("444.95", "444.95", "444.95"), Arrays.asList(PaymentGateway.AUTH, PaymentGateway.AUTH, PaymentGateway.CAPTURE), Arrays.asList(Payment.PAYMENT_STATUS_PROCESSING, Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_OK), Arrays.asList(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE)); assertEquals("444.95", customerOrder.getOrderTotal().toPlainString()); assertEquals("444.95", 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);  }