Refund re = ch.getRefunds().create(params);
/** * Deserializes a refund list JSON payload into a {@link ChargeRefundCollection} object. */ @Override public ChargeRefundCollection deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(ExpandableField.class, new ExpandableFieldDeserializer()) .create(); // API versions 2014-05-19 and earlier render charge refunds as an array instead of an object if (json.isJsonArray()) { Type refundListType = new TypeToken<List<Refund>>() { }.getType(); List<Refund> refunds = gson.fromJson(json, refundListType); ChargeRefundCollection collection = new ChargeRefundCollection(); collection.setData(refunds); collection.setHasMore(false); collection.setTotalCount(Long.valueOf(refunds.size())); return collection; } return gson.fromJson(json, typeOfT); } }
/** * Returns the {@code refunds} list. * * @return the {@code refunds} list */ public ChargeRefundCollection getRefunds() { // API versions 2014-05-19 and earlier render charge refunds as an array // instead of an object, meaning there is no sublist URL. if (refunds != null && refunds.getUrl() == null) { refunds.setUrl(String.format("/v1/charges/%s/refunds", getId())); } return refunds; }
/** * Create a charge refund. * * @deprecated Prefer using the {@link Refund#create(Map)} instead. */ @Deprecated public Refund create(Map<String, Object> params, RequestOptions options) throws StripeException { String url = String.format("%s%s", Stripe.getApiBase(), this.getUrl()); return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Refund.class, options); } // </editor-fold>
/** * List all charge refunds. * * @deprecated Prefer using the {@link Refund#list(Map)} method instead. */ @Deprecated public ChargeRefundCollection list(Map<String, Object> params) throws StripeException { return list(params, null); }
/** * Retrieve a charge refund. * * @deprecated Prefer using the {@link Refund#retrieve(String)} method instead. */ @Deprecated public Refund retrieve(String id) throws StripeException { return retrieve(id, (RequestOptions) null); }
/** * List all charge refunds. * * @deprecated Prefer using the {@link Refund#list(Map, RequestOptions)} method instead. */ @Deprecated public ChargeRefundCollection list(Map<String, Object> params, RequestOptions options) throws StripeException { String url = String.format("%s%s", Stripe.getApiBase(), this.getUrl()); return ApiResource.requestCollection(url, params, ChargeRefundCollection.class, options); } // </editor-fold>
/** * Create a charge refund. * * @deprecated Prefer using the {@link Refund#create(Map)} instead. */ @Deprecated public Refund create(Map<String, Object> params) throws StripeException { return create(params, (RequestOptions) null); }
/** * Retrieve a charge refund. * * @deprecated Prefer using the {@link Refund#retrieve(String, RequestOptions)} method instead. */ @Deprecated public Refund retrieve(String id, RequestOptions options) throws StripeException { String url = String.format("%s%s/%s", Stripe.getApiBase(), this.getUrl(), id); return ApiResource.request(ApiResource.RequestMethod.GET, url, null, Refund.class, options); } // </editor-fold>