Java Stripe: List all Refunds

Back to Index

Returns a list of all refunds you’ve previously created.

Documentation: https://stripe.com/docs/api/curl#list_refunds

CURL Command

curl https://api.stripe.com/v1/refunds?limit=3 \
   -u STRIPE_SECRET_KEY: \
   -G

Java Example

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://api.stripe.com/v1/refunds?limit=3
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        System.out.println("ConnectFailReason: " + rest.get_ConnectFailReason());
        System.out.println(rest.lastErrorText());
        return;
        }

    rest.SetAuthBasic("STRIPE_SECRET_KEY","");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestNoBodySb("GET","/v1/refunds?limit=3",sbResponseBody);
    if (success != true) {
        System.out.println(rest.lastErrorText());
        return;
        }

    CkJsonObject jsonResponse = new CkJsonObject();
    jsonResponse.LoadSb(sbResponseBody);

    String object;
    String url;
    boolean has_more;
    int i;
    int count_i;
    String id;
    int amount;
    boolean balance_transaction;
    String charge;
    int created;
    String currency;
    boolean reason;
    boolean receipt_number;
    String status;

    object = jsonResponse.stringOf("object");
    url = jsonResponse.stringOf("url");
    has_more = jsonResponse.BoolOf("has_more");
    i = 0;
    count_i = jsonResponse.SizeOfArray("data");
    while (i < count_i) {
        jsonResponse.put_I(i);
        id = jsonResponse.stringOf("data[i].id");
        object = jsonResponse.stringOf("data[i].object");
        amount = jsonResponse.IntOf("data[i].amount");
        balance_transaction = jsonResponse.IsNullOf("data[i].balance_transaction");
        charge = jsonResponse.stringOf("data[i].charge");
        created = jsonResponse.IntOf("data[i].created");
        currency = jsonResponse.stringOf("data[i].currency");
        reason = jsonResponse.IsNullOf("data[i].reason");
        receipt_number = jsonResponse.IsNullOf("data[i].receipt_number");
        status = jsonResponse.stringOf("data[i].status");
        i = i+1;
        }
  }
}

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/refunds",
  "has_more": false,
  "data": [
    {
      "id": "re_1BnETKGswQrCoh0XT2qLx7S0",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_1BnETKGswQrCoh0XE7kJI2wj",
      "created": 1516662782,
      "currency": "usd",
      "metadata": {},
      "reason": null,
      "receipt_number": null,
      "status": "succeeded"
    }
  ]
}