DefaultAuthorisedOrderNotificationProcessorStrategy implements OrderNotificationProcessorStrategy { @Override public void processNotificationMessage(final PaymentTransactionModel paymentTransactionModel, final OrderNotificationMessage orderNotificationMessage) { LOG.debug(format("Message for order having code {0} is a success, saving card and changing transaction status to not pending.", orderNotificationMessage.getOrderCode())); final BigDecimal plannedAmount = worldpayOrderService.convertAmount(orderNotificationMessage.getPaymentReply().getAmount()); paymentTransactionModel.setPlannedAmount(plannedAmount); final AbstractOrderModel orderModel = paymentTransactionModel.getOrder(); final List<PaymentTransactionEntryModel> paymentTransactionEntries = worldpayPaymentTransactionService.getPendingPaymentTransactionEntriesForType(paymentTransactionModel, AUTHORIZATION); transactionTemplate.execute(transactionStatus -> { updatePaymentTransactionEntry(paymentTransactionModel, orderNotificationMessage, paymentTransactionEntries, ACCEPTED.name()); try { worldpayPaymentInfoService.setPaymentInfoModel(paymentTransactionModel, orderModel, orderNotificationMessage); } catch (final WorldpayConfigurationException e) { LOG.info("Could not set the paymentInfo to the order.", e); return null; } return null; }); } DefaultAuthorisedOrderNotificationProcessorStrategy(final ModelService modelService,
                                                               final TransactionOperations transactionTemplate,
                                                               final WorldpayPaymentTransactionService worldpayPaymentTransactionService,
                                                               final WorldpayPaymentInfoService worldpayPaymentInfoService,
                                                               final WorldpayOrderService worldpayOrderService); @Override void processNotificationMessage(final PaymentTransactionModel paymentTransactionModel, final OrderNotificationMessage orderNotificationMessage);  }
@Test public void shouldProcessAuthorisedNotificationAndSetRiskScore() throws WorldpayConfigurationException { testObj.processNotificationMessage(paymentTransactionModelMock, orderNotificationMessageMock); verify(worldpayPaymentTransactionServiceMock).updateEntriesStatus(pendingAuthorizationTransactionEntries, ACCEPTED.name()); verify(worldpayPaymentTransactionServiceMock).updateEntriesAmount(pendingAuthorizationTransactionEntries, paymentReplyMock.getAmount()); verify(paymentTransactionModelMock).setPlannedAmount(BigDecimal.valueOf(10.6d)); verify(worldpayPaymentInfoServiceMock).setPaymentInfoModel(paymentTransactionModelMock, orderModelMock, orderNotificationMessageMock); verify(paymentTransactionModelMock).setApmOpen(false); verify(modelServiceMock).save(paymentTransactionModelMock); verify(worldpayPaymentTransactionServiceMock).addRiskScore(paymentTransactionModelMock, paymentReplyMock); }
@Test public void shouldSetAAvFieldsOnTransactionEntry() { testObj.processNotificationMessage(paymentTransactionModelMock, orderNotificationMessageMock); verify(worldpayPaymentTransactionServiceMock, times(2)).addAavFields(paymentTransactionEntryModelMock, paymentReplyMock); }