@Test(expectedExceptions = IllegalArgumentException.class) public void testGetRefundInvalidRefundId() throws BaseException { RequestContext requestContext = new RequestContext(); requestContext.setBaseUrl("SomeBaseUrl"); ChargeService chargeService = new ChargeService(requestContext); Refund actualRefund = chargeService.getRefund("SomeChargeId", null); }
public Refund getRefund(String chargeId, String refundId) throws BaseException { logger.debug("Enter ChargeService::getRefund"); if (StringUtils.isBlank(chargeId)) { logger.error("IllegalArgumentException {}", chargeId); throw new IllegalArgumentException("chargeId cannot be empty or null"); } if (StringUtils.isBlank(refundId)) { logger.error("IllegalArgumentException {}", refundId); throw new IllegalArgumentException("refundId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString()) .replaceAll("\\{" + "refund_id" + "\\}", refundId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.GET, 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 getRefund(String chargeId, String refundId) throws BaseException { logger.debug("Enter ChargeService::getRefund"); if (StringUtils.isBlank(chargeId)) { logger.error("IllegalArgumentException {}", chargeId); throw new IllegalArgumentException("chargeId cannot be empty or null"); } if (StringUtils.isBlank(refundId)) { logger.error("IllegalArgumentException {}", refundId); throw new IllegalArgumentException("refundId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString()) .replaceAll("\\{" + "refund_id" + "\\}", refundId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.GET, 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 getRefund(String chargeId, String refundId) throws BaseException { logger.debug("Enter ChargeService::getRefund"); if (StringUtils.isBlank(chargeId)) { logger.error("IllegalArgumentException {}", chargeId); throw new IllegalArgumentException("chargeId cannot be empty or null"); } if (StringUtils.isBlank(refundId)) { logger.error("IllegalArgumentException {}", refundId); throw new IllegalArgumentException("refundId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString()) .replaceAll("\\{" + "refund_id" + "\\}", refundId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.GET, 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 getRefund(String chargeId, String refundId) throws BaseException { logger.debug("Enter ChargeService::getRefund"); if (StringUtils.isBlank(chargeId)) { logger.error("IllegalArgumentException {}", chargeId); throw new IllegalArgumentException("chargeId cannot be empty or null"); } if (StringUtils.isBlank(refundId)) { logger.error("IllegalArgumentException {}", refundId); throw new IllegalArgumentException("refundId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString()) .replaceAll("\\{" + "refund_id" + "\\}", refundId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.GET, 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 getRefund(String chargeId, String refundId) throws BaseException { logger.debug("Enter ChargeService::getRefund"); if (StringUtils.isBlank(chargeId)) { logger.error("IllegalArgumentException {}", chargeId); throw new IllegalArgumentException("chargeId cannot be empty or null"); } if (StringUtils.isBlank(refundId)) { logger.error("IllegalArgumentException {}", refundId); throw new IllegalArgumentException("refundId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString()) .replaceAll("\\{" + "refund_id" + "\\}", refundId); logger.info("apiUrl - " + apiUrl); TypeReference<Refund> typeReference = new TypeReference<Refund>() { }; Request request = new Request.RequestBuilder(MethodType.GET, 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);  }