Android™ Stripe: List all Events

Back to Index

List events, going back up to 30 days.

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

CURL Command

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

Android™ Example

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://api.stripe.com/v1/events?limit=3
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        Log.i(TAG, "ConnectFailReason: " + String.valueOf(rest.get_ConnectFailReason()));
        Log.i(TAG, rest.lastErrorText());
        return;
        }

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

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestNoBodySb("GET","/v1/events?limit=3",sbResponseBody);
    if (success != true) {
        Log.i(TAG, rest.lastErrorText());
        return;
        }

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

    String object;
    String url;
    boolean has_more;
    int i;
    int count_i;
    String id;
    boolean api_version;
    int created;
    String dataObjectId;
    String dataObjectObject;
    int dataObjectAmount;
    int dataObjectCreated;
    String dataObjectCurrency;
    String dataObjectInterval;
    int dataObjectInterval_count;
    boolean dataObjectLivemode;
    String dataObjectName;
    boolean dataObjectStatement_descriptor;
    boolean dataObjectTrial_period_days;
    boolean livemode;
    int pending_webhooks;
    boolean requestId;
    boolean requestIdempotency_key;
    String type;

    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");
        api_version = jsonResponse.IsNullOf("data[i].api_version");
        created = jsonResponse.IntOf("data[i].created");
        dataObjectId = jsonResponse.stringOf("data[i].data.object.id");
        dataObjectObject = jsonResponse.stringOf("data[i].data.object.object");
        dataObjectAmount = jsonResponse.IntOf("data[i].data.object.amount");
        dataObjectCreated = jsonResponse.IntOf("data[i].data.object.created");
        dataObjectCurrency = jsonResponse.stringOf("data[i].data.object.currency");
        dataObjectInterval = jsonResponse.stringOf("data[i].data.object.interval");
        dataObjectInterval_count = jsonResponse.IntOf("data[i].data.object.interval_count");
        dataObjectLivemode = jsonResponse.BoolOf("data[i].data.object.livemode");
        dataObjectName = jsonResponse.stringOf("data[i].data.object.name");
        dataObjectStatement_descriptor = jsonResponse.IsNullOf("data[i].data.object.statement_descriptor");
        dataObjectTrial_period_days = jsonResponse.IsNullOf("data[i].data.object.trial_period_days");
        livemode = jsonResponse.BoolOf("data[i].livemode");
        pending_webhooks = jsonResponse.IntOf("data[i].pending_webhooks");
        requestId = jsonResponse.IsNullOf("data[i].request.id");
        requestIdempotency_key = jsonResponse.IsNullOf("data[i].request.idempotency_key");
        type = jsonResponse.stringOf("data[i].type");
        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/events",
  "has_more": false,
  "data": [
    {
      "id": "evt_1BnETJGswQrCoh0XAl7jSmFB",
      "object": "event",
      "api_version": null,
      "created": 1516662781,
      "data": {
        "object": {
          "id": "gold",
          "object": "plan",
          "amount": 2000,
          "created": 1516662781,
          "currency": "usd",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {},
          "name": "T-shirt",
          "statement_descriptor": null,
          "trial_period_days": null
        }
      },
      "livemode": false,
      "pending_webhooks": 0,
      "request": {
        "id": null,
        "idempotency_key": null
      },
      "type": "plan.created"
    }
  ]
}