@Test(expectedExceptions = IllegalArgumentException.class) public void testVoidTransactionInvalidChargeId() throws BaseException { RequestContext requestContext = new RequestContext(); requestContext.setBaseUrl("SomeBaseUrl"); ChargeService chargeService = new ChargeService(requestContext); Refund actualRefund = chargeService.voidTransaction(null); }
public Refund voidTransaction(String chargeRequestId) throws BaseException { logger.debug("Enter ChargeService::voidTransaction"); if (StringUtils.isBlank(chargeRequestId)) { logger.error("IllegalArgumentException {}", chargeRequestId); throw new IllegalArgumentException("chargeRequestId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "txn-requests/{id}/void".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeRequestId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Refund refundResponse = (Refund) response.getResponseObject(); prepareResponse(request, response, refundResponse); return refundResponse; }
ChargeService extends ServiceBase { public Refund voidTransaction(String chargeRequestId) throws BaseException { logger.debug("Enter ChargeService::voidTransaction"); if (StringUtils.isBlank(chargeRequestId)) { logger.error("IllegalArgumentException {}", chargeRequestId); throw new IllegalArgumentException("chargeRequestId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "txn-requests/{id}/void".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeRequestId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Refund refundResponse = (Refund) response.getResponseObject(); prepareResponse(request, response, refundResponse); return refundResponse; } }
ChargeService extends ServiceBase { public Refund voidTransaction(String chargeRequestId) throws BaseException { logger.debug("Enter ChargeService::voidTransaction"); if (StringUtils.isBlank(chargeRequestId)) { logger.error("IllegalArgumentException {}", chargeRequestId); throw new IllegalArgumentException("chargeRequestId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "txn-requests/{id}/void".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeRequestId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Refund refundResponse = (Refund) response.getResponseObject(); prepareResponse(request, response, refundResponse); return refundResponse; } ChargeService(RequestContext requestContext); protected  ChargeService(); }
ChargeService extends ServiceBase { public Refund voidTransaction(String chargeRequestId) throws BaseException { logger.debug("Enter ChargeService::voidTransaction"); if (StringUtils.isBlank(chargeRequestId)) { logger.error("IllegalArgumentException {}", chargeRequestId); throw new IllegalArgumentException("chargeRequestId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "txn-requests/{id}/void".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeRequestId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Refund refundResponse = (Refund) response.getResponseObject(); prepareResponse(request, response, refundResponse); return refundResponse; } ChargeService(RequestContext requestContext); protected  ChargeService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Charge create(Charge charge); Charge retrieve(String chargeId); Charge capture(String chargeId, Capture capture); Refund refund(String chargeId, Refund refund); Refund getRefund(String chargeId, String refundId); Refund voidTransaction(String chargeRequestId); }
ChargeService extends ServiceBase { public Refund voidTransaction(String chargeRequestId) throws BaseException { logger.debug("Enter ChargeService::voidTransaction"); if (StringUtils.isBlank(chargeRequestId)) { logger.error("IllegalArgumentException {}", chargeRequestId); throw new IllegalArgumentException("chargeRequestId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "txn-requests/{id}/void".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeRequestId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Refund refundResponse = (Refund) response.getResponseObject(); prepareResponse(request, response, refundResponse); return refundResponse; } ChargeService(RequestContext requestContext); protected  ChargeService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Charge create(Charge charge); Charge retrieve(String chargeId); Charge capture(String chargeId, Capture capture); Refund refund(String chargeId, Refund refund); Refund getRefund(String chargeId, String refundId); Refund voidTransaction(String chargeRequestId);  }