VBScript Requires Chilkat v11.7.0+
VBScript
Stripe: Match an automatic bank payout to its transactions
See more Stripe Examples
Reconcile a selected automatic payout by comparing its amount with the sum of its settlement entries across all result pages.
Stripe documentation and cURL example
Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Requires an unlocked Chilkat bundle. See Global Unlock Sample.
' Supply a restricted sandbox key from merchant-controlled configuration.
apiKey = "YOUR_STRIPE_TEST_KEY"
set curl = CreateObject("Chilkat.HttpCurl")
set cmd = CreateObject("Chilkat.StringBuilder")
set json = CreateObject("Chilkat.JsonObject")
' Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
fromTime = "1790812800"
untilTime = "1793491200"
selectedPayout = "po_SELECTED_BANK_DEPOSIT"
expectedAmount = ""
currency = ""
set pageSuffix = CreateObject("Chilkat.StringBuilder")
more = 1
cursor = ""
Do While (more = 1)
' curl -X GET "https://api.stripe.com/v1/payouts?created%5Bgte%5D={fromTime}&created%5Blt%5D={untilTime}&limit=100" \
' -u "$STRIPE_API_KEY:" \
' -H "Stripe-Version: 2026-10-28.endive"
success = cmd.SetString("curl -X GET ""https://api.stripe.com/v1/payouts?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@""")
success = cmd.Append(" -u ""@KEY@:""")
success = cmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
replaced = cmd.Replace("@CURSOR@",pageSuffix.GetAsString())
replaced = cmd.Replace("@FROM@",fromTime)
replaced = cmd.Replace("@UNTIL@",untilTime)
replaced = cmd.Replace("@KEY@",apiKey)
success = curl.DoYourThing(cmd.GetAsString())
If (success <> 1) Then
outFile.WriteLine("No HTTP response. Chilkat failure code: " & curl.FailReason)
WScript.Quit
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
outFile.WriteLine("Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id"))
If (success = 1) Then
outFile.WriteLine(json.StringOf("error.message"))
End If
WScript.Quit
End If
i = 0
count = json.SizeOfArray("data")
Do While (i < count)
json.I = i
outFile.WriteLine(json.StringOf("data[i].id") & " | " & json.StringOf("data[i].amount") & " | " & json.StringOf("data[i].currency") & " | " & json.StringOf("data[i].reconciliation_status"))
If (json.StringOf("data[i].id") = selectedPayout) Then
If ((json.BoolOf("data[i].automatic") <> 1) Or (json.StringOf("data[i].reconciliation_status") <> "completed")) Then
outFile.WriteLine("Select an automatic payout with completed reconciliation.")
WScript.Quit
End If
expectedAmount = json.StringOf("data[i].amount")
currency = json.StringOf("data[i].currency")
End If
i = i + 1
Loop
more = json.BoolOf("has_more")
If (more = 1) Then
next = json.StringOf("data[i].id")
If ((count < 1) Or (next = "") Or (next = cursor)) Then
outFile.WriteLine("Invalid pagination cursor.")
WScript.Quit
End If
cursor = next
success = pageSuffix.SetString("&starting_after=")
success = pageSuffix.Append(cursor)
End If
Loop
If (expectedAmount = "") Then
outFile.WriteLine("The selected payout was not in this date range.")
WScript.Quit
End If
totalNet = 0
' This portable example uses int for arithmetic. Reject an out-of-range entry
' or sum before adding. A larger ledger can sum the exact strings using decimal arithmetic.
set number = CreateObject("Chilkat.StringBuilder")
set pageSuffixTxn = CreateObject("Chilkat.StringBuilder")
moreTxn = 1
cursorTxn = ""
Do While (moreTxn = 1)
' curl -X GET "https://api.stripe.com/v1/balance_transactions?payout={selectedPayout}&limit=100" \
' -u "$STRIPE_API_KEY:" \
' -H "Stripe-Version: 2026-10-28.endive"
success = cmd.SetString("curl -X GET ""https://api.stripe.com/v1/balance_transactions?payout=@PAYOUT@&limit=100@CURSOR@""")
success = cmd.Append(" -u ""@KEY@:""")
success = cmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
replaced = cmd.Replace("@CURSOR@",pageSuffixTxn.GetAsString())
replaced = cmd.Replace("@PAYOUT@",selectedPayout)
replaced = cmd.Replace("@KEY@",apiKey)
success = curl.DoYourThing(cmd.GetAsString())
If (success <> 1) Then
outFile.WriteLine("No HTTP response. Chilkat failure code: " & curl.FailReason)
WScript.Quit
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
outFile.WriteLine("Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id"))
If (success = 1) Then
outFile.WriteLine(json.StringOf("error.message"))
End If
WScript.Quit
End If
iTxn = 0
countTxn = json.SizeOfArray("data")
Do While (iTxn < countTxn)
json.I = iTxn
outFile.WriteLine(json.StringOf("data[i].id") & " " & json.StringOf("data[i].net"))
If (json.StringOf("data[i].currency") <> currency) Then
outFile.WriteLine("Currency mismatch.")
WScript.Quit
End If
' Exclude the bank withdrawal itself if it appears in this batch.
If (json.StringOf("data[i].source") <> selectedPayout) Then
netText = json.StringOf("data[i].net")
entryNet = json.IntOf("data[i].net")
number.IntValue = entryNet
If (number.GetAsString() <> netText) Then
outFile.WriteLine("Entry exceeds the supported int range: " & netText)
WScript.Quit
End If
If (entryNet > 0) Then
If (totalNet > (2147483647 - entryNet)) Then
outFile.WriteLine("Total exceeds the supported int range.")
WScript.Quit
End If
End If
If (entryNet < 0) Then
If (totalNet < ((0 - 2147483647) - (entryNet + 1))) Then
outFile.WriteLine("Total exceeds the supported int range.")
WScript.Quit
End If
End If
totalNet = totalNet + entryNet
End If
iTxn = iTxn + 1
Loop
moreTxn = json.BoolOf("has_more")
If (moreTxn = 1) Then
nextTxn = json.StringOf("data[i].id")
If ((countTxn < 1) Or (nextTxn = "") Or (nextTxn = cursorTxn)) Then
outFile.WriteLine("Invalid pagination cursor.")
WScript.Quit
End If
cursorTxn = nextTxn
success = pageSuffixTxn.SetString("&starting_after=")
success = pageSuffixTxn.Append(cursorTxn)
End If
Loop
number.IntValue = totalNet
outFile.WriteLine("Settlement net: " & totalNet & " Bank payout: " & expectedAmount & " " & currency)
If (number.GetAsString() = expectedAmount) Then
outFile.WriteLine("Payout reconciled.")
Else
outFile.WriteLine("Investigate the difference.")
End If
outFile.Close