public static SubscriptionCharge fetch(Long subscriptionChargeId, String accessToken) throws JSONException, IOException, WePayException { JSONObject params = new JSONObject(); params.put("subscription_charge_id", subscriptionChargeId); String response = request("/subscription_charge", params, accessToken); SubscriptionCharge sc = gson.fromJson(response, SubscriptionCharge.class); return sc; }
public void refund(String refundReason, String accessToken) throws JSONException, IOException, WePayException { JSONObject params = new JSONObject(); params.put("subscription_charge_id", this.subscriptionChargeId); params.put("refund_reason", refundReason); String response = request("/subscription_charge/refund", params, accessToken); SubscriptionCharge sc = gson.fromJson(response, SubscriptionCharge.class); this.state = sc.state; this.subscriptionId = sc.subscriptionId; this.subscriptionPlanId = sc.subscriptionPlanId; this.refundReason = refundReason; }
public static SubscriptionCharge[] find(SubscriptionChargeFindData findData, String accessToken) throws JSONException, IOException, WePayException { JSONObject params = new JSONObject(); params.put("subscription_id", findData.subscriptionId); if (findData.start != null) params.put("start", findData.start); if (findData.limit != null) params.put("limit", findData.limit); if (findData.startTime != null) params.put("start_time", findData.startTime); if (findData.endTime != null) params.put("end_time", findData.endTime); if (findData.type != null) params.put("type", findData.type); if (findData.amount != null) params.put("amount", findData.amount); if (findData.state != null) params.put("state", findData.state); JSONArray results = new JSONArray(request("/subscription_charge/find", params, accessToken)); SubscriptionCharge[] found = new SubscriptionCharge[results.length()]; for (int i = 0; i < found.length; i++) { SubscriptionCharge sc = gson.fromJson(results.get(i).toString(), SubscriptionCharge.class); found[i] = sc; } return found; }