@Test public void testManualNotSupportedCaptureSuccess() { OrderModel orderModel = new OrderModel(); PaymentInfoModel paymentInfoModelMock = mock(PaymentInfoModel.class); when(paymentInfoModelMock.getAdyenPaymentMethod()).thenReturn("paysafe"); orderModel.setPaymentInfo(paymentInfoModelMock); orderModel.setStore(baseStore); when(orderRepositoryMock.getOrderModel(Mockito.any(String.class))).thenReturn(orderModel); CaptureResult result = adyenCaptureCommand.perform(captureRequest); assertEquals(TransactionStatus.ACCEPTED, result.getTransactionStatus()); assertEquals(TransactionStatusDetails.SUCCESFULL, result.getTransactionStatusDetails()); }
@Override public CaptureResult perform(final CaptureRequest request) { CaptureResult result = createCaptureResultFromRequest(request); LOG.info("Capture request received with requestId: " + request.getRequestId() + ", requestToken: " + request.getRequestToken()); String originalPSPReference = request.getRequestId(); String reference = request.getRequestToken(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); OrderModel order = orderRepository.getOrderModel(reference); if (order == null) { LOG.error("Order model with code: " + reference + " cannot be found"); result.setTransactionStatus(TransactionStatus.ERROR); return result; } BaseStoreModel baseStore = order.getStore(); Assert.notNull(baseStore); AdyenPaymentService adyenPaymentService = adyenPaymentServiceFactory.createFromBaseStore(baseStore); final PaymentInfoModel paymentInfo = order.getPaymentInfo(); Assert.notNull(paymentInfo); boolean isImmediateCapture = baseStore.getAdyenImmediateCapture(); Assert.notNull(isImmediateCapture); boolean autoCapture = isImmediateCapture || ! supportsManualCapture(paymentInfo.getAdyenPaymentMethod()); if (autoCapture) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.SUCCESFULL); } else { try { ModificationResult modificationResult = adyenPaymentService.capture(amount, currency, originalPSPReference, reference); if (modificationResult.getResponse() == CAPTURE_RECEIVED_RESPONSE) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.REVIEW_NEEDED); } else { result.setTransactionStatus(TransactionStatus.REJECTED); result.setTransactionStatusDetails(TransactionStatusDetails.UNKNOWN_CODE); } } catch (Exception e) { LOG.error("Capture Exception: " + e, e); } } LOG.info("Capture status: " + result.getTransactionStatus().name() + ":" + result.getTransactionStatusDetails().name()); return result; }
AdyenCaptureCommand implements CaptureCommand { @Override public CaptureResult perform(final CaptureRequest request) { CaptureResult result = createCaptureResultFromRequest(request); LOG.info("Capture request received with requestId: " + request.getRequestId() + ", requestToken: " + request.getRequestToken()); String originalPSPReference = request.getRequestId(); String reference = request.getRequestToken(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); OrderModel order = orderRepository.getOrderModel(reference); if (order == null) { LOG.error("Order model with code: " + reference + " cannot be found"); result.setTransactionStatus(TransactionStatus.ERROR); return result; } BaseStoreModel baseStore = order.getStore(); Assert.notNull(baseStore); AdyenPaymentService adyenPaymentService = adyenPaymentServiceFactory.createFromBaseStore(baseStore); final PaymentInfoModel paymentInfo = order.getPaymentInfo(); Assert.notNull(paymentInfo); boolean isImmediateCapture = baseStore.getAdyenImmediateCapture(); Assert.notNull(isImmediateCapture); boolean autoCapture = isImmediateCapture || ! supportsManualCapture(paymentInfo.getAdyenPaymentMethod()); if (autoCapture) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.SUCCESFULL); } else { try { ModificationResult modificationResult = adyenPaymentService.capture(amount, currency, originalPSPReference, reference); if (modificationResult.getResponse() == CAPTURE_RECEIVED_RESPONSE) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.REVIEW_NEEDED); } else { result.setTransactionStatus(TransactionStatus.REJECTED); result.setTransactionStatusDetails(TransactionStatusDetails.UNKNOWN_CODE); } } catch (Exception e) { LOG.error("Capture Exception: " + e, e); } } LOG.info("Capture status: " + result.getTransactionStatus().name() + ":" + result.getTransactionStatusDetails().name()); return result; } }
AdyenCaptureCommand implements CaptureCommand { @Override public CaptureResult perform(final CaptureRequest request) { CaptureResult result = createCaptureResultFromRequest(request); LOG.info("Capture request received with requestId: " + request.getRequestId() + ", requestToken: " + request.getRequestToken()); String originalPSPReference = request.getRequestId(); String reference = request.getRequestToken(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); OrderModel order = orderRepository.getOrderModel(reference); if (order == null) { LOG.error("Order model with code: " + reference + " cannot be found"); result.setTransactionStatus(TransactionStatus.ERROR); return result; } BaseStoreModel baseStore = order.getStore(); Assert.notNull(baseStore); AdyenPaymentService adyenPaymentService = adyenPaymentServiceFactory.createFromBaseStore(baseStore); final PaymentInfoModel paymentInfo = order.getPaymentInfo(); Assert.notNull(paymentInfo); boolean isImmediateCapture = baseStore.getAdyenImmediateCapture(); Assert.notNull(isImmediateCapture); boolean autoCapture = isImmediateCapture || ! supportsManualCapture(paymentInfo.getAdyenPaymentMethod()); if (autoCapture) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.SUCCESFULL); } else { try { ModificationResult modificationResult = adyenPaymentService.capture(amount, currency, originalPSPReference, reference); if (modificationResult.getResponse() == CAPTURE_RECEIVED_RESPONSE) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.REVIEW_NEEDED); } else { result.setTransactionStatus(TransactionStatus.REJECTED); result.setTransactionStatusDetails(TransactionStatusDetails.UNKNOWN_CODE); } } catch (Exception e) { LOG.error("Capture Exception: " + e, e); } } LOG.info("Capture status: " + result.getTransactionStatus().name() + ":" + result.getTransactionStatusDetails().name()); return result; }  }
AdyenCaptureCommand implements CaptureCommand { @Override public CaptureResult perform(final CaptureRequest request) { CaptureResult result = createCaptureResultFromRequest(request); LOG.info("Capture request received with requestId: " + request.getRequestId() + ", requestToken: " + request.getRequestToken()); String originalPSPReference = request.getRequestId(); String reference = request.getRequestToken(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); OrderModel order = orderRepository.getOrderModel(reference); if (order == null) { LOG.error("Order model with code: " + reference + " cannot be found"); result.setTransactionStatus(TransactionStatus.ERROR); return result; } BaseStoreModel baseStore = order.getStore(); Assert.notNull(baseStore); AdyenPaymentService adyenPaymentService = adyenPaymentServiceFactory.createFromBaseStore(baseStore); final PaymentInfoModel paymentInfo = order.getPaymentInfo(); Assert.notNull(paymentInfo); boolean isImmediateCapture = baseStore.getAdyenImmediateCapture(); Assert.notNull(isImmediateCapture); boolean autoCapture = isImmediateCapture || ! supportsManualCapture(paymentInfo.getAdyenPaymentMethod()); if (autoCapture) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.SUCCESFULL); } else { try { ModificationResult modificationResult = adyenPaymentService.capture(amount, currency, originalPSPReference, reference); if (modificationResult.getResponse() == CAPTURE_RECEIVED_RESPONSE) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.REVIEW_NEEDED); } else { result.setTransactionStatus(TransactionStatus.REJECTED); result.setTransactionStatusDetails(TransactionStatusDetails.UNKNOWN_CODE); } } catch (Exception e) { LOG.error("Capture Exception: " + e, e); } } LOG.info("Capture status: " + result.getTransactionStatus().name() + ":" + result.getTransactionStatusDetails().name()); return result; }  @Override CaptureResult perform(final CaptureRequest request); AdyenPaymentServiceFactory getAdyenPaymentServiceFactory(); void setAdyenPaymentServiceFactory(AdyenPaymentServiceFactory adyenPaymentServiceFactory); OrderRepository getOrderRepository(); void setOrderRepository(OrderRepository orderRepository); }
AdyenCaptureCommand implements CaptureCommand { @Override public CaptureResult perform(final CaptureRequest request) { CaptureResult result = createCaptureResultFromRequest(request); LOG.info("Capture request received with requestId: " + request.getRequestId() + ", requestToken: " + request.getRequestToken()); String originalPSPReference = request.getRequestId(); String reference = request.getRequestToken(); final BigDecimal amount = request.getTotalAmount(); final Currency currency = request.getCurrency(); OrderModel order = orderRepository.getOrderModel(reference); if (order == null) { LOG.error("Order model with code: " + reference + " cannot be found"); result.setTransactionStatus(TransactionStatus.ERROR); return result; } BaseStoreModel baseStore = order.getStore(); Assert.notNull(baseStore); AdyenPaymentService adyenPaymentService = adyenPaymentServiceFactory.createFromBaseStore(baseStore); final PaymentInfoModel paymentInfo = order.getPaymentInfo(); Assert.notNull(paymentInfo); boolean isImmediateCapture = baseStore.getAdyenImmediateCapture(); Assert.notNull(isImmediateCapture); boolean autoCapture = isImmediateCapture || ! supportsManualCapture(paymentInfo.getAdyenPaymentMethod()); if (autoCapture) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.SUCCESFULL); } else { try { ModificationResult modificationResult = adyenPaymentService.capture(amount, currency, originalPSPReference, reference); if (modificationResult.getResponse() == CAPTURE_RECEIVED_RESPONSE) { result.setTransactionStatus(TransactionStatus.ACCEPTED); result.setTransactionStatusDetails(TransactionStatusDetails.REVIEW_NEEDED); } else { result.setTransactionStatus(TransactionStatus.REJECTED); result.setTransactionStatusDetails(TransactionStatusDetails.UNKNOWN_CODE); } } catch (Exception e) { LOG.error("Capture Exception: " + e, e); } } LOG.info("Capture status: " + result.getTransactionStatus().name() + ":" + result.getTransactionStatusDetails().name()); return result; }  @Override CaptureResult perform(final CaptureRequest request); AdyenPaymentServiceFactory getAdyenPaymentServiceFactory(); void setAdyenPaymentServiceFactory(AdyenPaymentServiceFactory adyenPaymentServiceFactory); OrderRepository getOrderRepository(); void setOrderRepository(OrderRepository orderRepository);  }