Xojo Plugin Stripe: List Balance History

Back to Index

Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.

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

CURL Command

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

Xojo Plugin Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

//  URL: https://api.stripe.com/v1/balance/history?limit=3
Dim bTls As Boolean
bTls = True
Dim port As Int32
port = 443
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
    System.DebugLog(rest.LastErrorText)
    Return
End If

rest.SetAuthBasic("STRIPE_SECRET_KEY","")

Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/v1/balance/history?limit=3",sbResponseBody)
If (success <> True) Then
    System.DebugLog(rest.LastErrorText)
    Return
End If

Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)

Dim object As String
Dim url As String
Dim has_more As Boolean
Dim i As Int32
Dim count_i As Int32
Dim id As String
Dim amount As Int32
Dim available_on As Int32
Dim created As Int32
Dim currency As String
Dim description As Boolean
Dim exchange_rate As Boolean
Dim fee As Int32
Dim net As Int32
Dim source As String
Dim status As String
Dim type As String
Dim j As Int32
Dim count_j As Int32

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.I = i
    id = jsonResponse.StringOf("data[i].id")
    object = jsonResponse.StringOf("data[i].object")
    amount = jsonResponse.IntOf("data[i].amount")
    available_on = jsonResponse.IntOf("data[i].available_on")
    created = jsonResponse.IntOf("data[i].created")
    currency = jsonResponse.StringOf("data[i].currency")
    description = jsonResponse.IsNullOf("data[i].description")
    exchange_rate = jsonResponse.IsNullOf("data[i].exchange_rate")
    fee = jsonResponse.IntOf("data[i].fee")
    net = jsonResponse.IntOf("data[i].net")
    source = jsonResponse.StringOf("data[i].source")
    status = jsonResponse.StringOf("data[i].status")
    type = jsonResponse.StringOf("data[i].type")
    j = 0
    count_j = jsonResponse.SizeOfArray("data[i].fee_details")
    While j < count_j
        jsonResponse.J = j
        j = j + 1
    Wend
    i = i + 1
Wend

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/balance/history",
  "has_more": false,
  "data": [
    {
      "id": "txn_1BnETJGswQrCoh0XxO2tGYr7",
      "object": "balance_transaction",
      "amount": 100,
      "available_on": 1516662781,
      "created": 1516662781,
      "currency": "usd",
      "description": null,
      "exchange_rate": null,
      "fee": 0,
      "fee_details": [
      ],
      "net": 100,
      "source": "ch_1BnETJGswQrCoh0XTs0EERBj",
      "status": "pending",
      "type": "charge"
    }
  ]
}