VB.NET Stripe: Retrieve Balance

Back to Index

Retrieves the current account balance, based on the authentication that was used to make the request.

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

CURL Command

curl https://api.stripe.com/v1/balance \
   -u STRIPE_SECRET_KEY:

VB.NET Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://api.stripe.com/v1/balance
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


rest.SetAuthBasic("STRIPE_SECRET_KEY","")


Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/v1/balance",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


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

Dim object As String
Dim livemode As Boolean
Dim i As Integer
Dim count_i As Integer
Dim currency As String
Dim amount As Integer
Dim source_typesCard As Integer

object = jsonResponse.StringOf("object")
livemode = jsonResponse.BoolOf("livemode")
i = 0
count_i = jsonResponse.SizeOfArray("available")
While i < count_i
    jsonResponse.I = i
    currency = jsonResponse.StringOf("available[i].currency")
    amount = jsonResponse.IntOf("available[i].amount")
    source_typesCard = jsonResponse.IntOf("available[i].source_types.card")
    i = i + 1
End While
i = 0
count_i = jsonResponse.SizeOfArray("pending")
While i < count_i
    jsonResponse.I = i
    currency = jsonResponse.StringOf("pending[i].currency")
    amount = jsonResponse.IntOf("pending[i].amount")
    source_typesCard = jsonResponse.IntOf("pending[i].source_types.card")
    i = i + 1
End While

Sample JSON Response Body

{
  "object": "balance",
  "available": [
    {
      "currency": "usd",
      "amount": 0,
      "source_types": {
        "card": 0
      }
    }
  ],
  "livemode": false,
  "pending": [
    {
      "currency": "usd",
      "amount": 0,
      "source_types": {
        "card": 0
      }
    }
  ]
}