@Test public void executePaymentCaptureOperationFailureTest() throws WirecardPaymenException { when(abstractOrderModel.getPaymentTransactions()).thenReturn(Collections.singletonList(transaction1)); when(abstractOrderModel.getPaymentMode()).thenReturn(paymentModeModel); when(paymentModeModel.getCode()).thenReturn(provider1); when(paymentOperationStrategy.getOperation(abstractOrderModel.getPaymentMode(), PaymentTransactionType.CAPTURE.name())) .thenReturn(paymentOperation); when(paymentOperation.doOperation(abstractOrderModel, null)) .thenThrow(WirecardPaymenException.class); OrderStatus orderStatus = wirecardPaymentOperationExecutionService.executePaymentCaptureOperation(abstractOrderModel, additionalParameters); assertEquals("OrderStatus does not match", OrderStatus.PAYMENT_NOT_CAPTURED, orderStatus); }
@Override public OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data) { Payment response = null; if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.AUTHORIZATION)) { if (PaymentMethodName.WIRETRANSFER.value().equals(abstractOrderModel.getPaymentMode().getPaymentAlias())) { return OrderStatus.PAYMENT_AUTHORIZED; } try { response = getPaymentOperationStrategy().getOperation(abstractOrderModel.getPaymentMode(), WirecardPaymentTransactionConstants.CAPTURE) .doOperation(abstractOrderModel, data); } catch (WirecardPaymenException e) { LOGGER.error(e.getMessage(), e); return OrderStatus.PAYMENT_NOT_CAPTURED; } } else if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT_GET_URL) || wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT)) { return OrderStatus.PAYMENT_CAPTURED; } return wirecardPaymentService.getOrderStatus(response); }
DefaultWirecardPOExecutionService implements WirecardPOExecutionService { @Override public OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data) { Payment response = null; if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.AUTHORIZATION)) { if (PaymentMethodName.WIRETRANSFER.value().equals(abstractOrderModel.getPaymentMode().getPaymentAlias())) { return OrderStatus.PAYMENT_AUTHORIZED; } try { response = getPaymentOperationStrategy().getOperation(abstractOrderModel.getPaymentMode(), WirecardPaymentTransactionConstants.CAPTURE) .doOperation(abstractOrderModel, data); } catch (WirecardPaymenException e) { LOGGER.error(e.getMessage(), e); return OrderStatus.PAYMENT_NOT_CAPTURED; } } else if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT_GET_URL) || wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT)) { return OrderStatus.PAYMENT_CAPTURED; } return wirecardPaymentService.getOrderStatus(response); } }
DefaultWirecardPOExecutionService implements WirecardPOExecutionService { @Override public OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data) { Payment response = null; if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.AUTHORIZATION)) { if (PaymentMethodName.WIRETRANSFER.value().equals(abstractOrderModel.getPaymentMode().getPaymentAlias())) { return OrderStatus.PAYMENT_AUTHORIZED; } try { response = getPaymentOperationStrategy().getOperation(abstractOrderModel.getPaymentMode(), WirecardPaymentTransactionConstants.CAPTURE) .doOperation(abstractOrderModel, data); } catch (WirecardPaymenException e) { LOGGER.error(e.getMessage(), e); return OrderStatus.PAYMENT_NOT_CAPTURED; } } else if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT_GET_URL) || wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT)) { return OrderStatus.PAYMENT_CAPTURED; } return wirecardPaymentService.getOrderStatus(response); }  }
DefaultWirecardPOExecutionService implements WirecardPOExecutionService { @Override public OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data) { Payment response = null; if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.AUTHORIZATION)) { if (PaymentMethodName.WIRETRANSFER.value().equals(abstractOrderModel.getPaymentMode().getPaymentAlias())) { return OrderStatus.PAYMENT_AUTHORIZED; } try { response = getPaymentOperationStrategy().getOperation(abstractOrderModel.getPaymentMode(), WirecardPaymentTransactionConstants.CAPTURE) .doOperation(abstractOrderModel, data); } catch (WirecardPaymenException e) { LOGGER.error(e.getMessage(), e); return OrderStatus.PAYMENT_NOT_CAPTURED; } } else if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT_GET_URL) || wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT)) { return OrderStatus.PAYMENT_CAPTURED; } return wirecardPaymentService.getOrderStatus(response); }  @Override OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data); @Override ReturnStatus executePaymentRefundOperation(ReturnRequestModel returnRequestModel, PaymentOperationData data); @Override OrderStatus executeAuthorizationCancelOperation(AbstractOrderModel abstractOrderModel); @Required void setWirecardTransactionService(WirecardTransactionService wirecardTransactionService); @Required void setWirecardPaymentModeService(WirecardPaymentModeService wirecardPaymentModeService); @Required void setWirecardPaymentService(WirecardPaymentService wirecardPaymentService); @Required void setWirecardPaymentConfigurationService(WirecardPaymentConfigurationService wirecardPaymentConfigurationService); @Required void setPaymentOperationStrategy(PaymentOperationStrategy paymentOperationStrategy); }
DefaultWirecardPOExecutionService implements WirecardPOExecutionService { @Override public OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data) { Payment response = null; if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.AUTHORIZATION)) { if (PaymentMethodName.WIRETRANSFER.value().equals(abstractOrderModel.getPaymentMode().getPaymentAlias())) { return OrderStatus.PAYMENT_AUTHORIZED; } try { response = getPaymentOperationStrategy().getOperation(abstractOrderModel.getPaymentMode(), WirecardPaymentTransactionConstants.CAPTURE) .doOperation(abstractOrderModel, data); } catch (WirecardPaymenException e) { LOGGER.error(e.getMessage(), e); return OrderStatus.PAYMENT_NOT_CAPTURED; } } else if (wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT_GET_URL) || wirecardTransactionService.lookForAcceptedTransactions(abstractOrderModel, PaymentTransactionType.DEBIT)) { return OrderStatus.PAYMENT_CAPTURED; } return wirecardPaymentService.getOrderStatus(response); }  @Override OrderStatus executePaymentCaptureOperation(AbstractOrderModel abstractOrderModel, PaymentOperationData data); @Override ReturnStatus executePaymentRefundOperation(ReturnRequestModel returnRequestModel, PaymentOperationData data); @Override OrderStatus executeAuthorizationCancelOperation(AbstractOrderModel abstractOrderModel); @Required void setWirecardTransactionService(WirecardTransactionService wirecardTransactionService); @Required void setWirecardPaymentModeService(WirecardPaymentModeService wirecardPaymentModeService); @Required void setWirecardPaymentService(WirecardPaymentService wirecardPaymentService); @Required void setWirecardPaymentConfigurationService(WirecardPaymentConfigurationService wirecardPaymentConfigurationService); @Required void setPaymentOperationStrategy(PaymentOperationStrategy paymentOperationStrategy);  }