@Test public void testHandleStandardReserveFailedPaymentOkRefundOkExternal() throws Exception { configureTestExtPG("1"); String label = assertPgFeatures("testExtFormPaymentGateway", true, true, false, false); CustomerOrder customerOrder = createTestOrder(TestOrderType.STANDARD, label, false); assertTrue(handler.handle( new OrderEventImpl("", customerOrder, null, new HashMap() {{ put(TestExtFormPaymentGatewayImpl.AUTH_RESPONSE_CODE_PARAM_KEY, "1"); }}))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "0.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "1.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_INVENTORY_VOID_WAIT); assertMultiPaymentEntry(customerOrder.getOrdernum(), Arrays.asList("689.74", "689.74"), Arrays.asList(PaymentGateway.AUTH_CAPTURE, PaymentGateway.REFUND), Arrays.asList(Payment.PAYMENT_STATUS_OK, Payment.PAYMENT_STATUS_OK), Arrays.asList(Boolean.TRUE, Boolean.FALSE) ); assertEquals("689.74", 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()); } if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isExternalFormProcessing()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result) || Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } } return super.handle(orderEvent); } }
CancelNewOrderWithRefundOrderEventHandlerImpl 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().isExternalFormProcessing()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result) || Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } } return super.handle(orderEvent); } } }
CancelNewOrderWithRefundOrderEventHandlerImpl 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().isExternalFormProcessing()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result) || Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } } return super.handle(orderEvent); } } CancelNewOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                         final WarehouseService warehouseService,
                                                         final InventoryResolver inventoryResolver,
                                                         final ProductService productService); }
CancelNewOrderWithRefundOrderEventHandlerImpl 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().isExternalFormProcessing()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result) || Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } } return super.handle(orderEvent); } } CancelNewOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                         final WarehouseService warehouseService,
                                                         final InventoryResolver inventoryResolver,
                                                         final ProductService productService); @Override boolean handle(final OrderEvent orderEvent); }
CancelNewOrderWithRefundOrderEventHandlerImpl 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().isExternalFormProcessing()) { final String result = paymentProcessor.authorize(orderEvent.getCustomerOrder(), false, isForceProcessing(orderEvent), orderEvent.getParams()); if (Payment.PAYMENT_STATUS_OK.equals(result) || Payment.PAYMENT_STATUS_PROCESSING.equals(result)) { final String resultCancel = paymentProcessor.cancelOrder(order, isForceProcessing(orderEvent), Collections.emptyMap()); if (!Payment.PAYMENT_STATUS_OK.equals(resultCancel)) { orderEvent.getRuntimeParams().put("cancelFailed", Boolean.TRUE); } } } return super.handle(orderEvent); } } CancelNewOrderWithRefundOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory,
                                                         final WarehouseService warehouseService,
                                                         final InventoryResolver inventoryResolver,
                                                         final ProductService productService); @Override boolean handle(final OrderEvent orderEvent);  }