@Test public void testHandleFullMixedReserveFailedPaymentOkRefundProcessingExternalCallback() throws Exception { configureTestExtPG("3"); String label = assertPgFeatures("testExtFormPaymentGateway", true, true, false, false); CustomerOrder customerOrder = createTestOrderFailedReserve(TestOrderType.FULL, label, false); assertTrue(cancelNewOrderHandler.handle( new OrderEventImpl("", customerOrder, null, new HashMap() {{ put(TestExtFormPaymentGatewayImpl.AUTH_RESPONSE_CODE_PARAM_KEY, "1"); }}))); configureTestExtPG("1"); assertTrue(handler.handle( new OrderEventImpl("", customerOrder, null, Collections.emptyMap()))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "0.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "1.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST6", "500.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST5-NOINV", "0.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST9", "0.00", "0.00"); assertTrue(customerOrder.getDelivery().size() == 4); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_INVENTORY_VOID_WAIT); assertMultiPaymentEntry(customerOrder.getOrdernum(), Arrays.asList("1479.20", "1479.20", "1479.20"), Arrays.asList(PaymentGateway.AUTH_CAPTURE, PaymentGateway.REFUND, PaymentGateway.REFUND), Arrays.asList(Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_PROCESSING, Payment.PAYMENT_STATUS_OK), Arrays.asList(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE) ); assertEquals("1479.20", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_CANCELLED, 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.cancelOrder(orderEvent.getCustomerOrder(), isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); handled = true; } } return handled; } }
RefundProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl 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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.cancelOrder(orderEvent.getCustomerOrder(), isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); handled = true; } } return handled; } } }
RefundProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl 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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.cancelOrder(orderEvent.getCustomerOrder(), isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); handled = true; } } return handled; } } RefundProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); }
RefundProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl 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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.cancelOrder(orderEvent.getCustomerOrder(), isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); handled = true; } } return handled; } } RefundProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override boolean handle(final OrderEvent orderEvent); }
RefundProcessedOrderEventHandlerImpl extends AbstractOrderEventHandlerImpl 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()); } boolean handled = false; if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { final String result = paymentProcessor.cancelOrder(orderEvent.getCustomerOrder(), isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result)) { handleInternal(orderEvent); handled = true; } } return handled; } } RefundProcessedOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override boolean handle(final OrderEvent orderEvent);  }