PowerShell
PowerShell
Stripe: Retrieve Balance
Retrieves the current Stripe.com account balance.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# This example assumes the Chilkat HTTP API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$http = New-Object Chilkat.Http
# Set the Authorization header using your secret key,
# which looks something like this: sk_test_Oxo7a3Atz3UMRz5IRiafjkf7
$http.SetRequestHeader("Authorization","Bearer STRIPE_SECRET_KEY")
$jsonResponse = $http.QuickGetStr("https://api.stripe.com/v1/balance")
if ($http.LastMethodSuccess -ne $true) {
$($http.LastErrorText)
exit
}
$json = New-Object Chilkat.JsonObject
$json.Load($jsonResponse)
$json.EmitCompact = $false
if ($http.LastStatus -ne 200) {
# The request failed. Show the error.
$($json.Emit())
$("Error status returned.")
exit
}
# Show the successful response.
$($json.Emit())
# A sample result:
# {
# "object": "balance",
# "available": [
# {
# "currency": "usd",
# "amount": 0,
# "source_types": {
# "card": 0
# }
# }
# ],
# "livemode": false,
# "pending": [
# {
# "currency": "usd",
# "amount": 0,
# "source_types": {
# "card": 0
# }
# }
# ]
# }
# To get some information from the JSON:
$amountAvailable = $json.IntOf("available[0].amount")
$("available amount = " + $amountAvailable)
$amountPending = $json.IntOf("pending[0].amount")
$("pending amount = " + $amountPending)