@Test public void testHandleStandardPaymentOkOfflineAuth() throws Exception { String label = assertPgFeatures("courierPaymentGateway", false, false, true, true); CustomerOrder customerOrder = createTestOrderOfflineStandard(label, false); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY); CustomerOrderDelivery delivery = null; for (final CustomerOrderDelivery orderDelivery : customerOrder.getDelivery()) { if (CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY.equals(orderDelivery.getDeliveryStatus())) { assertNull(delivery); delivery = orderDelivery; } } assertTrue(handler.handle( new OrderEventImpl("", customerOrder, delivery, 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_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); assertSinglePaymentEntry(customerOrder.getOrdernum(), "689.74", PaymentGateway.AUTH, Payment.PAYMENT_STATUS_OK, Boolean.FALSE); assertEquals("689.74", 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 CustomerOrderDelivery delivery = orderEvent.getCustomerOrderDelivery(); 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().isSupportAuthorize()) { if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isAutoCapture()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } return true; } }
ReleaseToShipmentOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final CustomerOrderDelivery delivery = orderEvent.getCustomerOrderDelivery(); 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().isSupportAuthorize()) { if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isAutoCapture()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } return true; } } }
ReleaseToShipmentOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final CustomerOrderDelivery delivery = orderEvent.getCustomerOrderDelivery(); 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().isSupportAuthorize()) { if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isAutoCapture()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } return true; } } ReleaseToShipmentOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); }
ReleaseToShipmentOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final CustomerOrderDelivery delivery = orderEvent.getCustomerOrderDelivery(); 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().isSupportAuthorize()) { if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isAutoCapture()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } return true; } } ReleaseToShipmentOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override boolean handle(final OrderEvent orderEvent); }
ReleaseToShipmentOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderException { synchronized (OrderEventHandler.syncMonitor) { final CustomerOrder order = orderEvent.getCustomerOrder(); final CustomerOrderDelivery delivery = orderEvent.getCustomerOrderDelivery(); 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().isSupportAuthorize()) { if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isOnlineGateway()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else if (paymentProcessor.getPaymentGateway().getPaymentGatewayFeatures().isAutoCapture()) { if (Payment.PAYMENT_STATUS_OK.equals(paymentProcessor.shipmentComplete(order, delivery.getDeliveryNum(), isForceProcessing(orderEvent), orderEvent.getParams()))) { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS_WAITING_PAYMENT); } } else { transition(orderEvent, order, delivery, CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_IN_PROGRESS); } return true; } } ReleaseToShipmentOrderEventHandlerImpl(final PaymentProcessorFactory paymentProcessorFactory); @Override boolean handle(final OrderEvent orderEvent);  }