@Test(expected = WorldpayModelTransformationException.class) public void transform_WhenAmountIsNullOnCaptureRequest_ShouldThrownWorldpayModelTransformationExceptionWhenAmountOnRequestIsNull() throws WorldpayModelTransformationException { when(captureRequestMock.getAmount()).thenReturn(null); testObj.transform(captureRequestMock); }
@Override public PaymentService transform(final ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the capture is invalid."); } final CaptureServiceRequest captureRequest = (CaptureServiceRequest) request; final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); if (captureRequest.getAmount() == null) { throw new WorldpayModelTransformationException("No amount object to transform on the capture request"); } final Modify modify = new Modify(); final OrderModification orderModification = new OrderModification(); orderModification.setOrderCode(request.getOrderCode()); final Capture capture = new Capture(); capture.setAmount((Amount) captureRequest.getAmount().transformToInternalModel()); if (captureRequest.getDate() != null) { capture.setDate((Date) captureRequest.getDate().transformToInternalModel()); } setShippingInfo(captureRequest.getTrackingIds(), capture); orderModification.getCancelOrCaptureOrRefundOrRevokeOrAddBackOfficeCodeOrAuthoriseOrIncreaseAuthorisationOrCancelOrRefundOrDefendOrShopperWebformRefundDetailsOrExtendExpiryDateOrCancelRefundOrCancelRetryOrVoidSale().add(capture); modify.getOrderModificationOrBatchModificationOrAccountBatchModificationOrFuturePayAgreementModificationOrPaymentTokenUpdateOrPaymentTokenDelete().add(orderModification); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(modify); return paymentService; }
CaptureRequestTransformer implements ServiceRequestTransformer { @Override public PaymentService transform(final ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the capture is invalid."); } final CaptureServiceRequest captureRequest = (CaptureServiceRequest) request; final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); if (captureRequest.getAmount() == null) { throw new WorldpayModelTransformationException("No amount object to transform on the capture request"); } final Modify modify = new Modify(); final OrderModification orderModification = new OrderModification(); orderModification.setOrderCode(request.getOrderCode()); final Capture capture = new Capture(); capture.setAmount((Amount) captureRequest.getAmount().transformToInternalModel()); if (captureRequest.getDate() != null) { capture.setDate((Date) captureRequest.getDate().transformToInternalModel()); } setShippingInfo(captureRequest.getTrackingIds(), capture); orderModification.getCancelOrCaptureOrRefundOrRevokeOrAddBackOfficeCodeOrAuthoriseOrIncreaseAuthorisationOrCancelOrRefundOrDefendOrShopperWebformRefundDetailsOrExtendExpiryDateOrCancelRefundOrCancelRetryOrVoidSale().add(capture); modify.getOrderModificationOrBatchModificationOrAccountBatchModificationOrFuturePayAgreementModificationOrPaymentTokenUpdateOrPaymentTokenDelete().add(orderModification); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(modify); return paymentService; } }
CaptureRequestTransformer implements ServiceRequestTransformer { @Override public PaymentService transform(final ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the capture is invalid."); } final CaptureServiceRequest captureRequest = (CaptureServiceRequest) request; final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); if (captureRequest.getAmount() == null) { throw new WorldpayModelTransformationException("No amount object to transform on the capture request"); } final Modify modify = new Modify(); final OrderModification orderModification = new OrderModification(); orderModification.setOrderCode(request.getOrderCode()); final Capture capture = new Capture(); capture.setAmount((Amount) captureRequest.getAmount().transformToInternalModel()); if (captureRequest.getDate() != null) { capture.setDate((Date) captureRequest.getDate().transformToInternalModel()); } setShippingInfo(captureRequest.getTrackingIds(), capture); orderModification.getCancelOrCaptureOrRefundOrRevokeOrAddBackOfficeCodeOrAuthoriseOrIncreaseAuthorisationOrCancelOrRefundOrDefendOrShopperWebformRefundDetailsOrExtendExpiryDateOrCancelRefundOrCancelRetryOrVoidSale().add(capture); modify.getOrderModificationOrBatchModificationOrAccountBatchModificationOrFuturePayAgreementModificationOrPaymentTokenUpdateOrPaymentTokenDelete().add(orderModification); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(modify); return paymentService; } CaptureRequestTransformer(final ConfigurationService configurationService); }
CaptureRequestTransformer implements ServiceRequestTransformer { @Override public PaymentService transform(final ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the capture is invalid."); } final CaptureServiceRequest captureRequest = (CaptureServiceRequest) request; final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); if (captureRequest.getAmount() == null) { throw new WorldpayModelTransformationException("No amount object to transform on the capture request"); } final Modify modify = new Modify(); final OrderModification orderModification = new OrderModification(); orderModification.setOrderCode(request.getOrderCode()); final Capture capture = new Capture(); capture.setAmount((Amount) captureRequest.getAmount().transformToInternalModel()); if (captureRequest.getDate() != null) { capture.setDate((Date) captureRequest.getDate().transformToInternalModel()); } setShippingInfo(captureRequest.getTrackingIds(), capture); orderModification.getCancelOrCaptureOrRefundOrRevokeOrAddBackOfficeCodeOrAuthoriseOrIncreaseAuthorisationOrCancelOrRefundOrDefendOrShopperWebformRefundDetailsOrExtendExpiryDateOrCancelRefundOrCancelRetryOrVoidSale().add(capture); modify.getOrderModificationOrBatchModificationOrAccountBatchModificationOrFuturePayAgreementModificationOrPaymentTokenUpdateOrPaymentTokenDelete().add(orderModification); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(modify); return paymentService; } CaptureRequestTransformer(final ConfigurationService configurationService); @Override PaymentService transform(final ServiceRequest request); }
CaptureRequestTransformer implements ServiceRequestTransformer { @Override public PaymentService transform(final ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the capture is invalid."); } final CaptureServiceRequest captureRequest = (CaptureServiceRequest) request; final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); if (captureRequest.getAmount() == null) { throw new WorldpayModelTransformationException("No amount object to transform on the capture request"); } final Modify modify = new Modify(); final OrderModification orderModification = new OrderModification(); orderModification.setOrderCode(request.getOrderCode()); final Capture capture = new Capture(); capture.setAmount((Amount) captureRequest.getAmount().transformToInternalModel()); if (captureRequest.getDate() != null) { capture.setDate((Date) captureRequest.getDate().transformToInternalModel()); } setShippingInfo(captureRequest.getTrackingIds(), capture); orderModification.getCancelOrCaptureOrRefundOrRevokeOrAddBackOfficeCodeOrAuthoriseOrIncreaseAuthorisationOrCancelOrRefundOrDefendOrShopperWebformRefundDetailsOrExtendExpiryDateOrCancelRefundOrCancelRetryOrVoidSale().add(capture); modify.getOrderModificationOrBatchModificationOrAccountBatchModificationOrFuturePayAgreementModificationOrPaymentTokenUpdateOrPaymentTokenDelete().add(orderModification); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(modify); return paymentService; } CaptureRequestTransformer(final ConfigurationService configurationService); @Override PaymentService transform(final ServiceRequest request);  }