Classic ASP Requires Chilkat v11.7.0+
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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 = Server.CreateObject("Chilkat.HttpCurl")
set cmd = Server.CreateObject("Chilkat.StringBuilder")
set json = Server.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 = Server.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
Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Chilkat failure code: " & curl.FailReason) & "</pre>"
Response.End
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id")) & "</pre>"
If (success = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("error.message")) & "</pre>"
End If
Response.End
End If
i = 0
count = json.SizeOfArray("data")
Do While (i < count)
json.I = i
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("data[i].id") & " | " & json.StringOf("data[i].amount") & " | " & json.StringOf("data[i].currency") _
& " | " & json.StringOf("data[i].reconciliation_status")) & "</pre>"
If (json.StringOf("data[i].id") = selectedPayout) Then
If ((json.BoolOf("data[i].automatic") <> 1) Or (json.StringOf("data[i].reconciliation_status") <> "completed")) Then
Response.Write "<pre>" & Server.HTMLEncode( "Select an automatic payout with completed reconciliation.") & "</pre>"
Response.End
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
Response.Write "<pre>" & Server.HTMLEncode( "Invalid pagination cursor.") & "</pre>"
Response.End
End If
cursor = next
success = pageSuffix.SetString("&starting_after=")
success = pageSuffix.Append(cursor)
End If
Loop
If (expectedAmount = "") Then
Response.Write "<pre>" & Server.HTMLEncode( "The selected payout was not in this date range.") & "</pre>"
Response.End
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 = Server.CreateObject("Chilkat.StringBuilder")
set pageSuffixTxn = Server.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
Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Chilkat failure code: " & curl.FailReason) & "</pre>"
Response.End
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id")) & "</pre>"
If (success = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("error.message")) & "</pre>"
End If
Response.End
End If
iTxn = 0
countTxn = json.SizeOfArray("data")
Do While (iTxn < countTxn)
json.I = iTxn
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("data[i].id") & " " & json.StringOf("data[i].net")) & "</pre>"
If (json.StringOf("data[i].currency") <> currency) Then
Response.Write "<pre>" & Server.HTMLEncode( "Currency mismatch.") & "</pre>"
Response.End
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
Response.Write "<pre>" & Server.HTMLEncode( "Entry exceeds the supported int range: " & netText) & "</pre>"
Response.End
End If
If (entryNet > 0) Then
If (totalNet > (2147483647 - entryNet)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Total exceeds the supported int range.") & "</pre>"
Response.End
End If
End If
If (entryNet < 0) Then
If (totalNet < ((0 - 2147483647) - (entryNet + 1))) Then
Response.Write "<pre>" & Server.HTMLEncode( "Total exceeds the supported int range.") & "</pre>"
Response.End
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
Response.Write "<pre>" & Server.HTMLEncode( "Invalid pagination cursor.") & "</pre>"
Response.End
End If
cursorTxn = nextTxn
success = pageSuffixTxn.SetString("&starting_after=")
success = pageSuffixTxn.Append(cursorTxn)
End If
Loop
number.IntValue = totalNet
Response.Write "<pre>" & Server.HTMLEncode( "Settlement net: " & totalNet & " Bank payout: " & expectedAmount & " " & currency) & "</pre>"
If (number.GetAsString() = expectedAmount) Then
Response.Write "<pre>" & Server.HTMLEncode( "Payout reconciled.") & "</pre>"
Else
Response.Write "<pre>" & Server.HTMLEncode( "Investigate the difference.") & "</pre>"
End If
%>
</body>
</html>