Xojo Plugin Requires Chilkat v11.7.0+
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
// 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 Chilkat.HttpCurl
Dim cmd As New Chilkat.StringBuilder
Dim json As New Chilkat.JsonObject
Dim replaced As Int32
// 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 Chilkat.StringBuilder
Dim more As Boolean
more = True
Dim cursor As String
cursor = ""
While (more = True)
// 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 <> True) Then
System.DebugLog("No HTTP response. Chilkat failure code: " + Str(curl.FailReason))
Return
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> True)) Then
System.DebugLog("Stripe HTTP " + Str(curl.StatusCode) + " Request-Id: " + curl.GetResponseHeaderField("Request-Id"))
If (success = True) Then
System.DebugLog(json.StringOf("error.message"))
End If
Return
End If
Dim i As Int32
i = 0
Dim count As Int32
count = json.SizeOfArray("data")
While (i < count)
json.I = i
System.DebugLog(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") <> True) Or (json.StringOf("data[i].reconciliation_status") <> "completed")) Then
System.DebugLog("Select an automatic payout with completed reconciliation.")
Return
End If
expectedAmount = json.StringOf("data[i].amount")
currency = json.StringOf("data[i].currency")
End If
i = i + 1
Wend
more = json.BoolOf("has_more")
If (more = True) Then
Dim next As String
next = json.StringOf("data[i].id")
If ((count < 1) Or (next = "") Or (next = cursor)) Then
System.DebugLog("Invalid pagination cursor.")
Return
End If
cursor = next
success = pageSuffix.SetString("&starting_after=")
success = pageSuffix.Append(cursor)
End If
Wend
If (expectedAmount = "") Then
System.DebugLog("The selected payout was not in this date range.")
Return
End If
Dim totalNet As Int32
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 Chilkat.StringBuilder
Dim pageSuffixTxn As New Chilkat.StringBuilder
Dim moreTxn As Boolean
moreTxn = True
Dim cursorTxn As String
cursorTxn = ""
While (moreTxn = True)
// 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 <> True) Then
System.DebugLog("No HTTP response. Chilkat failure code: " + Str(curl.FailReason))
Return
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> True)) Then
System.DebugLog("Stripe HTTP " + Str(curl.StatusCode) + " Request-Id: " + curl.GetResponseHeaderField("Request-Id"))
If (success = True) Then
System.DebugLog(json.StringOf("error.message"))
End If
Return
End If
Dim iTxn As Int32
iTxn = 0
Dim countTxn As Int32
countTxn = json.SizeOfArray("data")
While (iTxn < countTxn)
json.I = iTxn
System.DebugLog(json.StringOf("data[i].id") + " " + json.StringOf("data[i].net"))
If (json.StringOf("data[i].currency") <> currency) Then
System.DebugLog("Currency mismatch.")
Return
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 Int32
entryNet = json.IntOf("data[i].net")
number.IntValue = entryNet
If (number.GetAsString() <> netText) Then
System.DebugLog("Entry exceeds the supported int range: " + netText)
Return
End If
If (entryNet > 0) Then
If (totalNet > (2147483647 - entryNet)) Then
System.DebugLog("Total exceeds the supported int range.")
Return
End If
End If
If (entryNet < 0) Then
If (totalNet < ((0 - 2147483647) - (entryNet + 1))) Then
System.DebugLog("Total exceeds the supported int range.")
Return
End If
End If
totalNet = totalNet + entryNet
End If
iTxn = iTxn + 1
Wend
moreTxn = json.BoolOf("has_more")
If (moreTxn = True) Then
Dim nextTxn As String
nextTxn = json.StringOf("data[i].id")
If ((countTxn < 1) Or (nextTxn = "") Or (nextTxn = cursorTxn)) Then
System.DebugLog("Invalid pagination cursor.")
Return
End If
cursorTxn = nextTxn
success = pageSuffixTxn.SetString("&starting_after=")
success = pageSuffixTxn.Append(cursorTxn)
End If
Wend
number.IntValue = totalNet
System.DebugLog("Settlement net: " + Str(totalNet) + " Bank payout: " + expectedAmount + " " + currency)
If (number.GetAsString() = expectedAmount) Then
System.DebugLog("Payout reconciled.")
Else
System.DebugLog("Investigate the difference.")
End If