Visual Basic 6.0 Requires Chilkat v11.7.0+
Visual Basic 6.0
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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Requires an unlocked Chilkat bundle. See Global Unlock Sample.
' Supply a restricted sandbox key from merchant-controlled configuration.
Dim apiKey As String
apiKey = "YOUR_STRIPE_TEST_KEY"
Dim curl As New ChilkatHttpCurl
Dim cmd As New ChilkatStringBuilder
Dim json As New ChilkatJsonObject
Dim replaced As Long
' Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
Dim fromTime As String
fromTime = "1790812800"
Dim untilTime As String
untilTime = "1793491200"
Dim selectedPayout As String
selectedPayout = "po_SELECTED_BANK_DEPOSIT"
Dim expectedAmount As String
expectedAmount = ""
Dim currency As String
currency = ""
Dim pageSuffix As New ChilkatStringBuilder
Dim more As Long
more = 1
Dim cursor As String
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
Debug.Print "No HTTP response. Chilkat failure code: " & curl.FailReason
Exit Sub
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
Debug.Print "Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id")
If (success = 1) Then
Debug.Print json.StringOf("error.message")
End If
Exit Sub
End If
Dim i As Long
i = 0
Dim count As Long
count = json.SizeOfArray("data")
Do While (i < count)
json.I = i
Debug.Print 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
Debug.Print "Select an automatic payout with completed reconciliation."
Exit Sub
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
Dim next As String
next = json.StringOf("data[i].id")
If ((count < 1) Or (next = "") Or (next = cursor)) Then
Debug.Print "Invalid pagination cursor."
Exit Sub
End If
cursor = next
success = pageSuffix.SetString("&starting_after=")
success = pageSuffix.Append(cursor)
End If
Loop
If (expectedAmount = "") Then
Debug.Print "The selected payout was not in this date range."
Exit Sub
End If
Dim totalNet As Long
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.
Dim number As New ChilkatStringBuilder
Dim pageSuffixTxn As New ChilkatStringBuilder
Dim moreTxn As Long
moreTxn = 1
Dim cursorTxn As String
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
Debug.Print "No HTTP response. Chilkat failure code: " & curl.FailReason
Exit Sub
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
Debug.Print "Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id")
If (success = 1) Then
Debug.Print json.StringOf("error.message")
End If
Exit Sub
End If
Dim iTxn As Long
iTxn = 0
Dim countTxn As Long
countTxn = json.SizeOfArray("data")
Do While (iTxn < countTxn)
json.I = iTxn
Debug.Print json.StringOf("data[i].id") & " " & json.StringOf("data[i].net")
If (json.StringOf("data[i].currency") <> currency) Then
Debug.Print "Currency mismatch."
Exit Sub
End If
' Exclude the bank withdrawal itself if it appears in this batch.
If (json.StringOf("data[i].source") <> selectedPayout) Then
Dim netText As String
netText = json.StringOf("data[i].net")
Dim entryNet As Long
entryNet = json.IntOf("data[i].net")
number.IntValue = entryNet
If (number.GetAsString() <> netText) Then
Debug.Print "Entry exceeds the supported int range: " & netText
Exit Sub
End If
If (entryNet > 0) Then
If (totalNet > (2147483647 - entryNet)) Then
Debug.Print "Total exceeds the supported int range."
Exit Sub
End If
End If
If (entryNet < 0) Then
If (totalNet < ((0 - 2147483647) - (entryNet + 1))) Then
Debug.Print "Total exceeds the supported int range."
Exit Sub
End If
End If
totalNet = totalNet + entryNet
End If
iTxn = iTxn + 1
Loop
moreTxn = json.BoolOf("has_more")
If (moreTxn = 1) Then
Dim nextTxn As String
nextTxn = json.StringOf("data[i].id")
If ((countTxn < 1) Or (nextTxn = "") Or (nextTxn = cursorTxn)) Then
Debug.Print "Invalid pagination cursor."
Exit Sub
End If
cursorTxn = nextTxn
success = pageSuffixTxn.SetString("&starting_after=")
success = pageSuffixTxn.Append(cursorTxn)
End If
Loop
number.IntValue = totalNet
Debug.Print "Settlement net: " & totalNet & " Bank payout: " & expectedAmount & " " & currency
If (number.GetAsString() = expectedAmount) Then
Debug.Print "Payout reconciled."
Else
Debug.Print "Investigate the difference."
End If